diff --git a/Import/GacUI.cpp b/Import/GacUI.cpp index 767a04e4..c645a744 100644 --- a/Import/GacUI.cpp +++ b/Import/GacUI.cpp @@ -5,663 +5,5397 @@ DEVELOPER: Zihan Chen(vczh) #include "GacUI.h" /*********************************************************************** -GACUIREFLECTIONHELPER.CPP +.\GRAPHICSCOMPOSITION\GUIGRAPHICSEVENTRECEIVER.CPP ***********************************************************************/ -namespace vl -{ - namespace reflection - { - namespace description - { - using namespace parsing; - using namespace parsing::tabling; - using namespace parsing::xml; - using namespace stream; - using namespace collections; - using namespace presentation; - using namespace presentation::elements; - using namespace presentation::compositions; - using namespace presentation::controls; - using namespace presentation::theme; - using namespace presentation::templates; - -/*********************************************************************** -Serialization (Color) -***********************************************************************/ - - Color TypedValueSerializerProvider::GetDefaultValue() - { - return Color(); - } - - bool TypedValueSerializerProvider::Serialize(const Color& input, WString& output) - { - output = input.ToString(); - return true; - } - - bool TypedValueSerializerProvider::Deserialize(const WString& input, Color& output) - { - output = Color::Parse(input); - return true; - } - - IBoxedValue::CompareResult TypedValueSerializerProvider::Compare(const presentation::Color& a, const presentation::Color& b) - { - return TypedValueSerializerProvider::Compare(a.value, b.value); - } - -/*********************************************************************** -Serialization (DocumentFontSize) -***********************************************************************/ - - DocumentFontSize TypedValueSerializerProvider::GetDefaultValue() - { - return DocumentFontSize(); - } - - bool TypedValueSerializerProvider::Serialize(const DocumentFontSize& input, WString& output) - { - output = input.ToString(); - return true; - } - - bool TypedValueSerializerProvider::Deserialize(const WString& input, DocumentFontSize& output) - { - output = DocumentFontSize::Parse(input); - return true; - } - - IBoxedValue::CompareResult TypedValueSerializerProvider::Compare(const presentation::DocumentFontSize& a, const presentation::DocumentFontSize& b) - { - return TypedValueSerializerProvider::Compare(a.ToString(), b.ToString()); - } - -/*********************************************************************** -Serialization (GlobalStringKey) -***********************************************************************/ - - GlobalStringKey TypedValueSerializerProvider::GetDefaultValue() - { - return GlobalStringKey(); - } - - bool TypedValueSerializerProvider::Serialize(const GlobalStringKey& input, WString& output) - { - output = input.ToString(); - return true; - } - - bool TypedValueSerializerProvider::Deserialize(const WString& input, GlobalStringKey& output) - { - output = GlobalStringKey::Get(input); - return true; - } - - IBoxedValue::CompareResult TypedValueSerializerProvider::Compare(const presentation::GlobalStringKey& a, const presentation::GlobalStringKey& b) - { - return TypedValueSerializerProvider::Compare(a.ToString(), b.ToString()); - } - -/*********************************************************************** -External Functions (Basic) -***********************************************************************/ - - GuiGraphicsAnimationManager* GuiControlHost_GetAnimationManager(GuiControlHost* thisObject) - { - return thisObject->GetGraphicsHost()->GetAnimationManager(); - } - - Ptr INativeImage_Constructor(const WString& path) - { - return GetCurrentController()->ImageService()->CreateImageFromFile(path); - } - - INativeCursor* INativeCursor_Constructor1() - { - return GetCurrentController()->ResourceService()->GetDefaultSystemCursor(); - } - - INativeCursor* INativeCursor_Constructor2(INativeCursor::SystemCursorType type) - { - return GetCurrentController()->ResourceService()->GetSystemCursor(type); - } - -/*********************************************************************** -External Functions (Elements) -***********************************************************************/ - - text::TextLines* GuiColorizedTextElement_GetLines(GuiColorizedTextElement* thisObject) - { - return &thisObject->GetLines(); - } - -/*********************************************************************** -External Functions (Compositions) -***********************************************************************/ - - void GuiTableComposition_SetRows(GuiTableComposition* thisObject, vint value) - { - vint columns = thisObject->GetColumns(); - if (columns <= 0) columns = 1; - thisObject->SetRowsAndColumns(value, columns); - } - - void GuiTableComposition_SetColumns(GuiTableComposition* thisObject, vint value) - { - vint row = thisObject->GetRows(); - if (row <= 0) row = 1; - thisObject->SetRowsAndColumns(row, value); - } - - void IGuiAltActionHost_CollectAltActions(IGuiAltActionHost* host, List& actions) - { - Group group; - host->CollectAltActions(group); - for (vint i = 0; i < group.Count(); i++) - { - CopyFrom(actions, group.GetByIndex(i), true); - } - } - -/*********************************************************************** -External Functions (Controls) -***********************************************************************/ - - Ptr CreateWin7Theme() - { - return new win7::Win7Theme(); - } - - Ptr CreateWin8Theme() - { - return new win8::Win8Theme(); - } - } - } -} - -/*********************************************************************** -CONTROLS\GUIAPPLICATION.CPP -***********************************************************************/ - -extern void GuiMain(); - namespace vl { namespace presentation { - namespace controls + namespace compositions { - using namespace collections; - using namespace compositions; - using namespace theme; - using namespace description; /*********************************************************************** -GuiApplication +Event Receiver ***********************************************************************/ - void GuiApplication::InvokeClipboardNotify(compositions::GuiGraphicsComposition* composition, compositions::GuiEventArgs& arguments) - { - if(composition->HasEventReceiver()) - { - composition->GetEventReceiver()->clipboardNotify.Execute(arguments); - } - FOREACH(GuiGraphicsComposition*, subComposition, composition->Children()) - { - InvokeClipboardNotify(subComposition, arguments); - } - } - - void GuiApplication::LeftButtonDown(Point position) - { - OnMouseDown(position); - } - - void GuiApplication::LeftButtonUp(Point position) + GuiGraphicsEventReceiver::GuiGraphicsEventReceiver(GuiGraphicsComposition* _sender) + :sender(_sender) + ,leftButtonDown(_sender) + ,leftButtonUp(_sender) + ,leftButtonDoubleClick(_sender) + ,middleButtonDown(_sender) + ,middleButtonUp(_sender) + ,middleButtonDoubleClick(_sender) + ,rightButtonDown(_sender) + ,rightButtonUp(_sender) + ,rightButtonDoubleClick(_sender) + ,horizontalWheel(_sender) + ,verticalWheel(_sender) + ,mouseMove(_sender) + ,mouseEnter(_sender) + ,mouseLeave(_sender) + ,previewKey(_sender) + ,keyDown(_sender) + ,keyUp(_sender) + ,systemKeyDown(_sender) + ,systemKeyUp(_sender) + ,previewCharInput(_sender) + ,charInput(_sender) + ,gotFocus(_sender) + ,lostFocus(_sender) + ,caretNotify(_sender) + ,clipboardNotify(_sender) { } - void GuiApplication::RightButtonDown(Point position) - { - OnMouseDown(position); - } - - void GuiApplication::RightButtonUp(Point position) + GuiGraphicsEventReceiver::~GuiGraphicsEventReceiver() { } - void GuiApplication::ClipboardUpdated() + GuiGraphicsComposition* GuiGraphicsEventReceiver::GetAssociatedComposition() { - for(vint i=0;iGetNotifyEventArguments(); - windows[i]->ClipboardUpdated.Execute(arguments); - InvokeClipboardNotify(windows[i]->GetBoundsComposition(), arguments); - } - } - - GuiApplication::GuiApplication() - :mainWindow(0) - ,sharedTooltipOwnerWindow(0) - ,sharedTooltipOwner(0) - ,sharedTooltipControl(0) - ,sharedTooltipHovering(false) - ,sharedTooltipClosing(false) - { - GetCurrentController()->CallbackService()->InstallListener(this); - } - - GuiApplication::~GuiApplication() - { - if(sharedTooltipControl) - { - delete sharedTooltipControl; - sharedTooltipControl=0; - } - GetCurrentController()->CallbackService()->UninstallListener(this); - } - - void GuiApplication::RegisterWindow(GuiWindow* window) - { - windows.Add(window); - } - - void GuiApplication::UnregisterWindow(GuiWindow* window) - { - windows.Remove(window); - } - - void GuiApplication::RegisterPopupOpened(GuiPopup* popup) - { - vint index=openingPopups.IndexOf(popup); - if(index==-1) - { - openingPopups.Add(popup); - if(openingPopups.Count()==1) - { - GetCurrentController()->InputService()->StartHookMouse(); - } - } - } - - void GuiApplication::RegisterPopupClosed(GuiPopup* popup) - { - if(openingPopups.Remove(popup)) - { - if(openingPopups.Count()==0) - { - GetCurrentController()->InputService()->StopHookMouse(); - } - } - } - - void GuiApplication::OnMouseDown(Point location) - { - GuiWindow* window=GetWindow(location); - for(vint i=0;iMouseClickedOnOtherWindow(window); - } - } - } - - void GuiApplication::TooltipMouseEnter(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - sharedTooltipHovering=true; - } - - void GuiApplication::TooltipMouseLeave(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - sharedTooltipHovering=false; - if(sharedTooltipClosing) - { - CloseTooltip(); - } - } - - void GuiApplication::Run(GuiWindow* _mainWindow) - { - if(!mainWindow) - { - mainWindow=_mainWindow; - GetCurrentController()->WindowService()->Run(mainWindow->GetNativeWindow()); - mainWindow=0; - } - } - - GuiWindow* GuiApplication::GetMainWindow() - { - return mainWindow; - } - - const collections::List& GuiApplication::GetWindows() - { - return windows; - } - - GuiWindow* GuiApplication::GetWindow(Point location) - { - INativeWindow* nativeWindow=GetCurrentController()->WindowService()->GetWindow(location); - if(nativeWindow) - { - for(vint i=0;iGetNativeWindow()==nativeWindow) - { - return window; - } - } - } - return 0; - } - - void GuiApplication::ShowTooltip(GuiControl* owner, GuiControl* tooltip, vint preferredContentWidth, Point location) - { - GuiWindow* ownerWindow = dynamic_cast(owner->GetRelatedControlHost()); - if (sharedTooltipOwnerWindow != ownerWindow) - { - delete sharedTooltipControl; - sharedTooltipControl = 0; - } - - if(!sharedTooltipControl) - { - GuiWindow::IStyleController* tooltipStyle = 0; - if (ownerWindow) - { - tooltipStyle = dynamic_cast(ownerWindow->GetStyleController())->CreateTooltipStyle(); - } - if (!tooltipStyle) - { - tooltipStyle = GetCurrentTheme()->CreateTooltipStyle(); - } - - sharedTooltipControl=new GuiTooltip(tooltipStyle); - sharedTooltipControl->GetBoundsComposition()->GetEventReceiver()->mouseEnter.AttachMethod(this, &GuiApplication::TooltipMouseEnter); - sharedTooltipControl->GetBoundsComposition()->GetEventReceiver()->mouseLeave.AttachMethod(this, &GuiApplication::TooltipMouseLeave); - } - - sharedTooltipHovering=false; - sharedTooltipClosing=false; - sharedTooltipOwnerWindow = ownerWindow; - sharedTooltipOwner=owner; - sharedTooltipControl->SetTemporaryContentControl(tooltip); - sharedTooltipControl->SetPreferredContentWidth(preferredContentWidth); - sharedTooltipControl->SetClientSize(Size(10, 10)); - sharedTooltipControl->ShowPopup(owner, location); - } - - void GuiApplication::CloseTooltip() - { - if(sharedTooltipControl) - { - if(sharedTooltipHovering) - { - sharedTooltipClosing=true; - } - else - { - sharedTooltipClosing=false; - sharedTooltipControl->Close(); - } - } - } - - GuiControl* GuiApplication::GetTooltipOwner() - { - if(!sharedTooltipControl) return 0; - if(!sharedTooltipControl->GetTemporaryContentControl()) return 0; - return sharedTooltipOwner; - } - - WString GuiApplication::GetExecutablePath() - { - return GetCurrentController()->GetExecutablePath(); - } - - WString GuiApplication::GetExecutableFolder() - { - WString path=GetExecutablePath(); - for(vint i=path.Length()-1;i>=0;i--) - { - if(path[i]==L'\\' || path[i]==L'/') - { - return path.Sub(0, i+1); - } - } - return L""; - } - - bool GuiApplication::IsInMainThread() - { - return GetCurrentController()->AsyncService()->IsInMainThread(); - } - - void GuiApplication::InvokeAsync(const Func& proc) - { - GetCurrentController()->AsyncService()->InvokeAsync(proc); - } - - void GuiApplication::InvokeInMainThread(const Func& proc) - { - GetCurrentController()->AsyncService()->InvokeInMainThread(proc); - } - - bool GuiApplication::InvokeInMainThreadAndWait(const Func& proc, vint milliseconds) - { - return GetCurrentController()->AsyncService()->InvokeInMainThreadAndWait(proc, milliseconds); - } - - Ptr GuiApplication::DelayExecute(const Func& proc, vint milliseconds) - { - return GetCurrentController()->AsyncService()->DelayExecute(proc, milliseconds); - } - - Ptr GuiApplication::DelayExecuteInMainThread(const Func& proc, vint milliseconds) - { - return GetCurrentController()->AsyncService()->DelayExecuteInMainThread(proc, milliseconds); - } - - void GuiApplication::RunGuiTask(const Func& proc) - { - if(IsInMainThread()) - { - return proc(); - } - else - { - InvokeInMainThreadAndWait([&proc]() - { - proc(); - }); - } - } - -/*********************************************************************** -GuiPluginManager -***********************************************************************/ - - class GuiPluginManager : public Object, public IGuiPluginManager - { - protected: - List> plugins; - bool loaded; - public: - GuiPluginManager() - :loaded(false) - { - } - - ~GuiPluginManager() - { - Unload(); - } - - void AddPlugin(Ptr plugin)override - { - plugins.Add(plugin); - if(loaded) - { - plugin->Load(); - } - } - - void Load()override - { - if(!loaded) - { - loaded=true; - FOREACH(Ptr, plugin, plugins) - { - plugin->Load(); - } - FOREACH(Ptr, plugin, plugins) - { - plugin->AfterLoad(); - } - } - } - - void Unload()override - { - if(loaded) - { - loaded=false; - FOREACH(Ptr, plugin, plugins) - { - plugin->Unload(); - } - } - } - - bool IsLoaded()override - { - return loaded; - } - }; - -/*********************************************************************** -Helpers -***********************************************************************/ - - GuiApplication* application=0; - IGuiPluginManager* pluginManager=0; - - GuiApplication* GetApplication() - { - return application; - } - - IGuiPluginManager* GetPluginManager() - { - if(!pluginManager) - { - pluginManager=new GuiPluginManager; - } - return pluginManager; - } - - void DestroyPluginManager() - { - if(pluginManager) - { - delete pluginManager; - pluginManager=0; - } - } - -/*********************************************************************** -GuiApplicationMain -***********************************************************************/ - - class UIThreadAsyncScheduler :public Object, public IAsyncScheduler, public Description - { - public: - void Execute(const Func& callback)override - { - GetApplication()->InvokeInMainThread(callback); - } - - void ExecuteInBackground(const Func& callback)override - { - GetApplication()->InvokeAsync(callback); - } - - void DelayExecute(const Func& callback, vint milliseconds)override - { - GetApplication()->DelayExecuteInMainThread(callback, milliseconds); - } - }; - - class OtherThreadAsyncScheduler :public Object, public IAsyncScheduler, public Description - { - public: - void Execute(const Func& callback)override - { - GetApplication()->InvokeAsync(callback); - } - - void ExecuteInBackground(const Func& callback)override - { - GetApplication()->InvokeAsync(callback); - } - - void DelayExecute(const Func& callback, vint milliseconds)override - { - GetApplication()->DelayExecute(callback, milliseconds); - } - }; - - void GuiApplicationInitialize() - { - // There will be a GacUI theme in the future - // win7::Win7Theme - // win8::Win8Theme - auto theme = MakePtr(); - GetCurrentController()->InputService()->StartTimer(); - -#ifndef VCZH_DEBUG_NO_REFLECTION - GetGlobalTypeManager()->Load(); -#endif - GetPluginManager()->Load(); - theme::SetCurrentTheme(theme.Obj()); - - { - GuiApplication app; - application = &app; - IAsyncScheduler::RegisterSchedulerForCurrentThread(new UIThreadAsyncScheduler); - IAsyncScheduler::RegisterDefaultScheduler(new OtherThreadAsyncScheduler); - GuiMain(); - IAsyncScheduler::UnregisterDefaultScheduler(); - IAsyncScheduler::UnregisterSchedulerForCurrentThread(); - application = nullptr; - } - - theme::SetCurrentTheme(0); - DestroyPluginManager(); - ThreadLocalStorage::DisposeStorages(); - FinalizeGlobalStorage(); -#ifndef VCZH_DEBUG_NO_REFLECTION - DestroyGlobalTypeManager(); -#endif + return sender; } } } } -void GuiApplicationMain() +/*********************************************************************** +.\GRAPHICSCOMPOSITION\GUIGRAPHICSSPECIALIZEDCOMPOSITION.CPP +***********************************************************************/ + +namespace vl { - vl::presentation::controls::GuiApplicationInitialize(); + namespace presentation + { + namespace compositions + { + +/*********************************************************************** +GuiSideAlignedComposition +***********************************************************************/ + + GuiSideAlignedComposition::GuiSideAlignedComposition() + :direction(Top) + ,maxLength(10) + ,maxRatio(1.0) + { + } + + GuiSideAlignedComposition::~GuiSideAlignedComposition() + { + } + + GuiSideAlignedComposition::Direction GuiSideAlignedComposition::GetDirection() + { + return direction; + } + + void GuiSideAlignedComposition::SetDirection(Direction value) + { + direction = value; + InvokeOnCompositionStateChanged(); + } + + vint GuiSideAlignedComposition::GetMaxLength() + { + return maxLength; + } + + void GuiSideAlignedComposition::SetMaxLength(vint value) + { + if (value < 0) value = 0; + maxLength = value; + InvokeOnCompositionStateChanged(); + } + + double GuiSideAlignedComposition::GetMaxRatio() + { + return maxRatio; + } + + void GuiSideAlignedComposition::SetMaxRatio(double value) + { + maxRatio = + value < 0 ? 0 : + value>1 ? 1 : + value; + InvokeOnCompositionStateChanged(); + } + + bool GuiSideAlignedComposition::IsSizeAffectParent() + { + return false; + } + + Rect GuiSideAlignedComposition::GetBounds() + { + Rect result; + GuiGraphicsComposition* parent = GetParent(); + if (parent) + { + Rect bounds = parent->GetBounds(); + vint w = (vint)(bounds.Width()*maxRatio); + vint h = (vint)(bounds.Height()*maxRatio); + if (w > maxLength) w = maxLength; + if (h > maxLength) h = maxLength; + switch (direction) + { + case Left: + { + bounds.x2 = bounds.x1 + w; + } + break; + case Top: + { + bounds.y2 = bounds.y1 + h; + } + break; + case Right: + { + bounds.x1 = bounds.x2 - w; + } + break; + case Bottom: + { + bounds.y1 = bounds.y2 - h; + } + break; + } + result = bounds; + } + UpdatePreviousBounds(result); + return result; + } + +/*********************************************************************** +GuiPartialViewComposition +***********************************************************************/ + + GuiPartialViewComposition::GuiPartialViewComposition() + :wRatio(0.0) + ,wPageSize(1.0) + ,hRatio(0.0) + ,hPageSize(1.0) + { + } + + GuiPartialViewComposition::~GuiPartialViewComposition() + { + } + + double GuiPartialViewComposition::GetWidthRatio() + { + return wRatio; + } + + double GuiPartialViewComposition::GetWidthPageSize() + { + return wPageSize; + } + + double GuiPartialViewComposition::GetHeightRatio() + { + return hRatio; + } + + double GuiPartialViewComposition::GetHeightPageSize() + { + return hPageSize; + } + + void GuiPartialViewComposition::SetWidthRatio(double value) + { + wRatio = value; + InvokeOnCompositionStateChanged(); + } + + void GuiPartialViewComposition::SetWidthPageSize(double value) + { + wPageSize = value; + InvokeOnCompositionStateChanged(); + } + + void GuiPartialViewComposition::SetHeightRatio(double value) + { + hRatio = value; + InvokeOnCompositionStateChanged(); + } + + void GuiPartialViewComposition::SetHeightPageSize(double value) + { + hPageSize = value; + InvokeOnCompositionStateChanged(); + } + + bool GuiPartialViewComposition::IsSizeAffectParent() + { + return false; + } + + Rect GuiPartialViewComposition::GetBounds() + { + Rect result; + GuiGraphicsComposition* parent = GetParent(); + if (parent) + { + Rect bounds = parent->GetBounds(); + vint w = bounds.Width(); + vint h = bounds.Height(); + vint pw = (vint)(wPageSize*w); + vint ph = (vint)(hPageSize*h); + + vint ow = preferredMinSize.x - pw; + if (ow < 0) ow = 0; + vint oh = preferredMinSize.y - ph; + if (oh < 0) oh = 0; + + w -= ow; + h -= oh; + pw += ow; + ph += oh; + + result = Rect(Point((vint)(wRatio*w), (vint)(hRatio*h)), Size(pw, ph)); + } + UpdatePreviousBounds(result); + return result; + } + } + } +} + + +/*********************************************************************** +.\GRAPHICSCOMPOSITION\GUIGRAPHICSSTACKCOMPOSITION.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace compositions + { + +/*********************************************************************** +GuiStackComposition +***********************************************************************/ + + void GuiStackComposition::UpdateStackItemBounds() + { + if (stackItemBounds.Count() != stackItems.Count()) + { + stackItemBounds.Resize(stackItems.Count()); + } + + stackItemTotalSize = Size(0, 0); + Point offset; + for (vint i = 0; i < stackItems.Count(); i++) + { + vint offsetX = 0; + vint offsetY = 0; + Size itemSize = stackItems[i]->GetMinSize(); + stackItemBounds[i] = Rect(offset, itemSize); + +#define ACCUMULATE(U, V) \ + { \ + if (stackItemTotalSize.V < itemSize.V) \ + { \ + stackItemTotalSize.V = itemSize.V; \ + } \ + if (i > 0) \ + { \ + stackItemTotalSize.U += padding; \ + } \ + stackItemTotalSize.U += itemSize.U; \ + } \ + + switch (direction) + { + case GuiStackComposition::Horizontal: + case GuiStackComposition::ReversedHorizontal: + ACCUMULATE(x, y) + break; + case GuiStackComposition::Vertical: + case GuiStackComposition::ReversedVertical: + ACCUMULATE(y, x) + break; + } + +#undef ACCUMULATE + offset.x += itemSize.x + padding; + offset.y += itemSize.y + padding; + } + EnsureStackItemVisible(); + } + + void GuiStackComposition::EnsureStackItemVisible() + { +#define ADJUSTMENT(U, V) \ + if (itemBounds.U() <= 0) \ + { \ + adjustment -= itemBounds.U(); \ + } \ + else \ + { \ + vint overflow = itemBounds.V() - previousBounds.V(); \ + if (overflow > 0) \ + { \ + adjustment -= overflow; \ + } \ + } \ + + if (ensuringVisibleStackItem) + { + Rect itemBounds = ensuringVisibleStackItem->GetBounds(); + switch (direction) + { + case Horizontal: + case ReversedHorizontal: + ADJUSTMENT(Left, Right) + break; + case Vertical: + case ReversedVertical: + ADJUSTMENT(Top, Bottom) + break; + } + } + + InvokeOnCompositionStateChanged(); +#undef ADJUSTMENT + } + + void GuiStackComposition::OnBoundsChanged(GuiGraphicsComposition* sender, GuiEventArgs& arguments) + { + EnsureStackItemVisible(); + } + + void GuiStackComposition::OnChildInserted(GuiGraphicsComposition* child) + { + GuiBoundsComposition::OnChildInserted(child); + GuiStackItemComposition* item = dynamic_cast(child); + if (item) + { + if (!stackItems.Contains(item)) + { + stackItems.Add(item); + } + UpdateStackItemBounds(); + } + } + + void GuiStackComposition::OnChildRemoved(GuiGraphicsComposition* child) + { + GuiBoundsComposition::OnChildRemoved(child); + GuiStackItemComposition* item = dynamic_cast(child); + if (item) + { + stackItems.Remove(item); + if (item == ensuringVisibleStackItem) + { + ensuringVisibleStackItem = 0; + } + UpdateStackItemBounds(); + } + } + + GuiStackComposition::GuiStackComposition() + { + BoundsChanged.AttachMethod(this, &GuiStackComposition::OnBoundsChanged); + } + + GuiStackComposition::~GuiStackComposition() + { + } + + const GuiStackComposition::ItemCompositionList& GuiStackComposition::GetStackItems() + { + return stackItems; + } + + bool GuiStackComposition::InsertStackItem(vint index, GuiStackItemComposition* item) + { + index = stackItems.Insert(index, item); + if (!AddChild(item)) + { + stackItems.RemoveAt(index); + return false; + } + else + { + return true; + } + } + + GuiStackComposition::Direction GuiStackComposition::GetDirection() + { + return direction; + } + + void GuiStackComposition::SetDirection(Direction value) + { + direction = value; + EnsureStackItemVisible(); + } + + vint GuiStackComposition::GetPadding() + { + return padding; + } + + void GuiStackComposition::SetPadding(vint value) + { + padding = value; + EnsureStackItemVisible(); + } + + void GuiStackComposition::ForceCalculateSizeImmediately() + { + GuiBoundsComposition::ForceCalculateSizeImmediately(); + UpdateStackItemBounds(); + } + + Size GuiStackComposition::GetMinPreferredClientSize() + { + Size minSize = GuiBoundsComposition::GetMinPreferredClientSize(); + if (GetMinSizeLimitation() == GuiGraphicsComposition::LimitToElementAndChildren) + { + if (!ensuringVisibleStackItem || direction == Vertical || direction == ReversedVertical) + { + if (minSize.x < stackItemTotalSize.x) + { + minSize.x = stackItemTotalSize.x; + } + } + if (!ensuringVisibleStackItem || direction == Horizontal || direction == ReversedHorizontal) + { + if (minSize.y < stackItemTotalSize.y) + { + minSize.y = stackItemTotalSize.y; + } + } + } + + vint x = 0; + vint y = 0; + if (extraMargin.left > 0) x += extraMargin.left; + if (extraMargin.right > 0) x += extraMargin.right; + if (extraMargin.top > 0) y += extraMargin.top; + if (extraMargin.bottom > 0) y += extraMargin.bottom; + return minSize + Size(x, y); + } + + Rect GuiStackComposition::GetBounds() + { + for (vint i = 0; i < stackItems.Count(); i++) + { + if (stackItemBounds[i].GetSize() != stackItems[i]->GetMinSize()) + { + UpdateStackItemBounds(); + break; + } + } + + Rect bounds = GuiBoundsComposition::GetBounds(); + previousBounds = bounds; + UpdatePreviousBounds(previousBounds); + return bounds; + } + + Margin GuiStackComposition::GetExtraMargin() + { + return extraMargin; + } + + void GuiStackComposition::SetExtraMargin(Margin value) + { + extraMargin=value; + EnsureStackItemVisible(); + } + + bool GuiStackComposition::IsStackItemClipped() + { + Rect clientArea = GetClientArea(); + switch(direction) + { + case Horizontal: + case ReversedHorizontal: + { + vint width = stackItemTotalSize.x + + (extraMargin.left > 0 ? extraMargin.left : 0) + + (extraMargin.right > 0 ? extraMargin.right : 0) + ; + return width > clientArea.Width(); + } + break; + case Vertical: + case ReversedVertical: + { + vint height = stackItemTotalSize.y + + (extraMargin.top > 0 ? extraMargin.top : 0) + + (extraMargin.bottom > 0 ? extraMargin.bottom : 0) + ; + return height > clientArea.Height(); + } + break; + } + return false; + } + + bool GuiStackComposition::EnsureVisible(vint index) + { + if (0 <= index && index < stackItems.Count()) + { + ensuringVisibleStackItem = stackItems[index]; + } + else + { + ensuringVisibleStackItem = 0; + } + EnsureStackItemVisible(); + return ensuringVisibleStackItem != 0; + } + +/*********************************************************************** +GuiStackItemComposition +***********************************************************************/ + + void GuiStackItemComposition::OnParentChanged(GuiGraphicsComposition* oldParent, GuiGraphicsComposition* newParent) + { + GuiGraphicsSite::OnParentChanged(oldParent, newParent); + stackParent = newParent == 0 ? 0 : dynamic_cast(newParent); + } + + Size GuiStackItemComposition::GetMinSize() + { + return GetBoundsInternal(bounds).GetSize(); + } + + GuiStackItemComposition::GuiStackItemComposition() + :stackParent(0) + { + SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + } + + GuiStackItemComposition::~GuiStackItemComposition() + { + } + + bool GuiStackItemComposition::IsSizeAffectParent() + { + return false; + } + + Rect GuiStackItemComposition::GetBounds() + { + Rect result = bounds; + if(stackParent) + { + vint index = stackParent->stackItems.IndexOf(this); + if (index != -1) + { + result = stackParent->stackItemBounds[index]; + } + + Rect parentBounds = stackParent->previousBounds; + Margin margin = stackParent->extraMargin; + if (margin.left <= 0) margin.left = 0; + if (margin.top <= 0) margin.top = 0; + if (margin.right <= 0) margin.right = 0; + if (margin.bottom <= 0) margin.bottom = 0; + + auto x = result.Left(); + auto y = result.Top(); + auto w = result.Width(); + auto h = result.Height(); + + switch (stackParent->direction) + { + case GuiStackComposition::Horizontal: + x += margin.left + stackParent->adjustment; + y = margin.top; + h = parentBounds.Height() - margin.top - margin.bottom; + break; + case GuiStackComposition::ReversedHorizontal: + x = parentBounds.Width() - margin.right - x - w + stackParent->adjustment; + y = margin.top; + h = parentBounds.Height() - margin.top - margin.bottom; + break; + case GuiStackComposition::Vertical: + x = margin.left; + y += margin.top + stackParent->adjustment; + w = parentBounds.Width() - margin.left - margin.right; + break; + case GuiStackComposition::ReversedVertical: + x = margin.left; + y = parentBounds.Height() - margin.bottom - y - h + stackParent->adjustment; + w = parentBounds.Width() - margin.left - margin.right; + break; + } + + result = Rect( + x - extraMargin.left, + y - extraMargin.top, + x + w + extraMargin.right, + y + h + extraMargin.bottom + ); + } + UpdatePreviousBounds(result); + return result; + } + + void GuiStackItemComposition::SetBounds(Rect value) + { + bounds = value; + InvokeOnCompositionStateChanged(); + } + + Margin GuiStackItemComposition::GetExtraMargin() + { + return extraMargin; + } + + void GuiStackItemComposition::SetExtraMargin(Margin value) + { + extraMargin = value; + InvokeOnCompositionStateChanged(); + } + } + } +} + + +/*********************************************************************** +.\GRAPHICSCOMPOSITION\GUIGRAPHICSTABLECOMPOSITION.CPP +***********************************************************************/ +#include + +namespace vl +{ + namespace presentation + { + namespace compositions + { + using namespace collections; + using namespace controls; + using namespace elements; + +/*********************************************************************** +GuiTableComposition +***********************************************************************/ + + namespace update_cell_bounds_helpers + { + vint First(vint a, vint b) + { + return a; + } + + vint Second(vint a, vint b) + { + return b; + } + + vint X(Size s) + { + return s.x; + } + + vint Y(Size s) + { + return s.y; + } + + vint RL(GuiCellComposition* cell) + { + return cell->GetRow(); + } + + vint CL(GuiCellComposition* cell) + { + return cell->GetColumn(); + } + + vint RS(GuiCellComposition* cell) + { + return cell->GetRowSpan(); + } + + vint CS(GuiCellComposition* cell) + { + return cell->GetColumnSpan(); + } + } + using namespace update_cell_bounds_helpers; + + vint GuiTableComposition::GetSiteIndex(vint _rows, vint _columns, vint _row, vint _column) + { + return _row*_columns + _column; + } + + void GuiTableComposition::SetSitedCell(vint _row, vint _column, GuiCellComposition* cell) + { + cellCompositions[GetSiteIndex(rows, columns, _row, _column)] = cell; + } + + void GuiTableComposition::UpdateCellBoundsInternal( + collections::Array& dimSizes, + vint& dimSize, + vint& dimSizeWithPercentage, + collections::Array& dimOptions, + vint GuiTableComposition::* dim1, + vint GuiTableComposition::* dim2, + vint(*getSize)(Size), + vint(*getLocation)(GuiCellComposition*), + vint(*getSpan)(GuiCellComposition*), + vint(*getRow)(vint, vint), + vint(*getCol)(vint, vint), + vint maxPass + ) + { + for (vint pass = 0; pass < maxPass; pass++) + { + for (vint i = 0; i < this->*dim1; i++) + { + GuiCellOption option = dimOptions[i]; + if (pass == 0) + { + dimSizes[i] = 0; + } + switch (option.composeType) + { + case GuiCellOption::Absolute: + { + dimSizes[i] = option.absolute; + } + break; + case GuiCellOption::MinSize: + { + for (vint j = 0; j < this->*dim2; j++) + { + GuiCellComposition* cell = GetSitedCell(getRow(i, j), getCol(i, j)); + if (cell) + { + bool accept = false; + if (pass == 0) + { + accept = getSpan(cell) == 1; + } + else + { + accept = getLocation(cell) + getSpan(cell) == i + 1; + } + if (accept) + { + vint size = getSize(cell->GetPreferredBounds().GetSize()); + vint span = getSpan(cell); + for (vint k = 1; k < span; k++) + { + size -= dimSizes[i - k] + cellPadding; + } + if (dimSizes[i] < size) + { + dimSizes[i] = size; + } + } + } + } + } + break; + default:; + } + } + } + + bool percentageExists = false; + for (vint i = 0; i < this->*dim1; i++) + { + GuiCellOption option = dimOptions[i]; + if (option.composeType == GuiCellOption::Percentage) + { + if (0.001 < option.percentage) + { + percentageExists = true; + } + } + } + + if (percentageExists) + { + for (vint i = 0; i < this->*dim1; i++) + { + GuiCellOption option = dimOptions[i]; + if (option.composeType == GuiCellOption::Percentage) + { + if (0.001 < option.percentage) + { + for (vint j = 0; j < this->*dim2; j++) + { + GuiCellComposition* cell = GetSitedCell(getRow(i, j), getCol(i, j)); + if (cell) + { + vint size = getSize(cell->GetPreferredBounds().GetSize()); + vint start = getLocation(cell); + vint span = getSpan(cell); + size -= (span - 1)*cellPadding; + double totalPercentage = 0; + + for (vint k = start; k < start + span; k++) + { + if (dimOptions[k].composeType == GuiCellOption::Percentage) + { + if (0.001 < dimOptions[k].percentage) + { + totalPercentage += dimOptions[k].percentage; + } + } + else + { + size -= dimSizes[k]; + } + } + + size = (vint)ceil(size*option.percentage / totalPercentage); + if (dimSizes[i] < size) + { + dimSizes[i] = size; + } + } + } + } + } + } + + vint percentageTotalSize = 0; + for (vint i = 0; i < this->*dim1; i++) + { + GuiCellOption option = dimOptions[i]; + if (option.composeType == GuiCellOption::Percentage) + { + if (0.001 < option.percentage) + { + vint size = (vint)ceil(dimSizes[i] / option.percentage); + if (percentageTotalSize < size) + { + percentageTotalSize = size; + } + } + } + } + + double totalPercentage = 0; + for (vint i = 0; i < this->*dim1; i++) + { + GuiCellOption option = dimOptions[i]; + if (option.composeType == GuiCellOption::Percentage) + { + if (0.001 < option.percentage) + { + totalPercentage += option.percentage; + } + } + } + + for (vint i = 0; i < this->*dim1; i++) + { + GuiCellOption option = dimOptions[i]; + if (option.composeType == GuiCellOption::Percentage) + { + if (0.001 < option.percentage) + { + vint size = (vint)ceil(percentageTotalSize*option.percentage / totalPercentage); + if (dimSizes[i] < size) + { + dimSizes[i] = size; + } + } + } + } + } + + for (vint i = 0; i < this->*dim1; i++) + { + if (dimOptions[i].composeType != GuiCellOption::Percentage) + { + dimSize += dimSizes[i]; + } + dimSizeWithPercentage += dimSizes[i]; + } + } + + void GuiTableComposition::UpdateCellBoundsPercentages( + collections::Array& dimSizes, + vint dimSize, + vint maxDimSize, + collections::Array& dimOptions + ) + { + if (maxDimSize > dimSize) + { + double totalPercentage = 0; + vint percentageCount = 0; + for (vint i = 0; i < dimOptions.Count(); i++) + { + GuiCellOption option = dimOptions[i]; + if (option.composeType == GuiCellOption::Percentage) + { + totalPercentage += option.percentage; + percentageCount++; + } + } + if (percentageCount > 0 && totalPercentage > 0.001) + { + for (vint i = 0; i < dimOptions.Count(); i++) + { + GuiCellOption option = dimOptions[i]; + if (option.composeType == GuiCellOption::Percentage) + { + dimSizes[i] = (vint)((maxDimSize - dimSize)*option.percentage / totalPercentage); + } + } + } + } + } + + vint GuiTableComposition::UpdateCellBoundsOffsets( + collections::Array& offsets, + collections::Array& sizes, + vint max + ) + { + offsets[0] = 0; + for (vint i = 1; i < offsets.Count(); i++) + { + offsets[i] = offsets[i - 1] + cellPadding + sizes[i - 1]; + } + + vint last = offsets.Count() - 1; + vint right = offsets[last] + sizes[last]; + return max - right; + } + + void GuiTableComposition::UpdateCellBoundsInternal() + { + rowOffsets.Resize(rows); + rowSizes.Resize(rows); + columnOffsets.Resize(columns); + columnSizes.Resize(columns); + { + vint rowTotal = (rows - 1)*cellPadding; + vint columnTotal = (columns - 1)*cellPadding; + vint rowTotalWithPercentage = rowTotal; + vint columnTotalWithPercentage = columnTotal; + + UpdateCellBoundsInternal( + rowSizes, + rowTotal, + rowTotalWithPercentage, + rowOptions, + &GuiTableComposition::rows, + &GuiTableComposition::columns, + &Y, + &RL, + &RS, + &First, + &Second, + 1 + ); + UpdateCellBoundsInternal( + columnSizes, + columnTotal, + columnTotalWithPercentage, + columnOptions, + &GuiTableComposition::columns, + &GuiTableComposition::rows, + &X, + &CL, + &CS, + &Second, + &First, + 1 + ); + + Rect area = GetCellArea(); + UpdateCellBoundsPercentages(rowSizes, rowTotal, area.Height(), rowOptions); + UpdateCellBoundsPercentages(columnSizes, columnTotal, area.Width(), columnOptions); + rowExtending = UpdateCellBoundsOffsets(rowOffsets, rowSizes, area.Height()); + columnExtending = UpdateCellBoundsOffsets(columnOffsets, columnSizes, area.Width()); + + for (vint i = 0; i < rows; i++) + { + for (vint j = 0; j < columns; j++) + { + vint index = GetSiteIndex(rows, columns, i, j); + cellBounds[index] = Rect(Point(columnOffsets[j], rowOffsets[i]), Size(columnSizes[j], rowSizes[i])); + } + } + } + } + + void GuiTableComposition::UpdateTableContentMinSize() + { + Array rowSizes, columnSizes; + rowSizes.Resize(rows); + columnSizes.Resize(columns); + { + vint rowTotal = (rows - 1) * cellPadding; + vint columnTotal = (columns - 1) * cellPadding; + vint rowTotalWithPercentage = rowTotal; + vint columnTotalWithPercentage = columnTotal; + + UpdateCellBoundsInternal( + rowSizes, + rowTotal, + rowTotalWithPercentage, + rowOptions, + &GuiTableComposition::rows, + &GuiTableComposition::columns, + &Y, + &RL, + &RS, + &First, + &Second, + 2 + ); + UpdateCellBoundsInternal( + columnSizes, + columnTotal, + columnTotalWithPercentage, + columnOptions, + &GuiTableComposition::columns, + &GuiTableComposition::rows, + &X, + &CL, + &CS, + &Second, + &First, + 2 + ); + tableContentMinSize = Size(columnTotalWithPercentage, rowTotalWithPercentage); + } + if (previousContentMinSize != tableContentMinSize) + { + previousContentMinSize = tableContentMinSize; + UpdateCellBoundsInternal(); + InvokeOnCompositionStateChanged(); + } + } + + void GuiTableComposition::OnRenderContextChanged() + { + if(GetRenderTarget()) + { + UpdateTableContentMinSize(); + } + } + + GuiTableComposition::GuiTableComposition() + :rows(0) + , columns(0) + , cellPadding(0) + , borderVisible(true) + , rowExtending(0) + , columnExtending(0) + { + ConfigChanged.SetAssociatedComposition(this); + SetRowsAndColumns(1, 1); + } + + GuiTableComposition::~GuiTableComposition() + { + } + + vint GuiTableComposition::GetRows() + { + return rows; + } + + vint GuiTableComposition::GetColumns() + { + return columns; + } + + bool GuiTableComposition::SetRowsAndColumns(vint _rows, vint _columns) + { + if (_rows <= 0 || _columns <= 0) return false; + rowOptions.Resize(_rows); + columnOptions.Resize(_columns); + cellCompositions.Resize(_rows*_columns); + cellBounds.Resize(_rows*_columns); + for (vint i = 0; i < _rows*_columns; i++) + { + cellCompositions[i] = 0; + cellBounds[i] = Rect(); + } + rows = _rows; + columns = _columns; + vint childCount = Children().Count(); + for (vint i = 0; i < childCount; i++) + { + GuiCellComposition* cell = dynamic_cast(Children().Get(i)); + if (cell) + { + cell->OnTableRowsAndColumnsChanged(); + } + } + ConfigChanged.Execute(GuiEventArgs(this)); + UpdateCellBounds(); + InvokeOnCompositionStateChanged(); + return true; + } + + GuiCellComposition* GuiTableComposition::GetSitedCell(vint _row, vint _column) + { + return cellCompositions[GetSiteIndex(rows, columns, _row, _column)]; + } + + GuiCellOption GuiTableComposition::GetRowOption(vint _row) + { + return rowOptions[_row]; + } + + void GuiTableComposition::SetRowOption(vint _row, GuiCellOption option) + { + rowOptions[_row] = option; + UpdateCellBounds(); + InvokeOnCompositionStateChanged(); + ConfigChanged.Execute(GuiEventArgs(this)); + } + + GuiCellOption GuiTableComposition::GetColumnOption(vint _column) + { + return columnOptions[_column]; + } + + void GuiTableComposition::SetColumnOption(vint _column, GuiCellOption option) + { + columnOptions[_column] = option; + UpdateCellBounds(); + InvokeOnCompositionStateChanged(); + ConfigChanged.Execute(GuiEventArgs(this)); + } + + vint GuiTableComposition::GetCellPadding() + { + return cellPadding; + } + + void GuiTableComposition::SetCellPadding(vint value) + { + if (value < 0) value = 0; + cellPadding = value; + UpdateCellBounds(); + InvokeOnCompositionStateChanged(); + } + + bool GuiTableComposition::GetBorderVisible() + { + return borderVisible; + } + + void GuiTableComposition::SetBorderVisible(bool value) + { + if (borderVisible != value) + { + borderVisible = value; + UpdateCellBounds(); + InvokeOnCompositionStateChanged(); + } + } + + Rect GuiTableComposition::GetCellArea() + { + Rect bounds(Point(0, 0), GuiBoundsComposition::GetBounds().GetSize()); + vint borderThickness = borderVisible ? cellPadding : 0; + bounds.x1 += margin.left + internalMargin.left + borderThickness; + bounds.y1 += margin.top + internalMargin.top + borderThickness; + bounds.x2 -= margin.right + internalMargin.right + borderThickness; + bounds.y2 -= margin.bottom + internalMargin.bottom + borderThickness; + if (bounds.x2 < bounds.x1) bounds.x2 = bounds.x1; + if (bounds.y2 < bounds.y1) bounds.y2 = bounds.y1; + return bounds; + } + + void GuiTableComposition::UpdateCellBounds() + { + UpdateCellBoundsInternal(); + UpdateTableContentMinSize(); + } + + void GuiTableComposition::ForceCalculateSizeImmediately() + { + GuiBoundsComposition::ForceCalculateSizeImmediately(); + UpdateCellBounds(); + UpdateCellBounds(); + } + + Size GuiTableComposition::GetMinPreferredClientSize() + { + vint offset = (borderVisible ? 2 * cellPadding : 0); + return Size(tableContentMinSize.x + offset, tableContentMinSize.y + offset); + } + + Rect GuiTableComposition::GetBounds() + { + Rect result; + if (!IsAlignedToParent() && GetMinSizeLimitation() != GuiGraphicsComposition::NoLimit) + { + result = Rect(compositionBounds.LeftTop(), compositionBounds.GetSize() - Size(columnExtending, rowExtending)); + } + else + { + result = GuiBoundsComposition::GetBounds(); + } + + bool cellMinSizeModified = false; + SortedList cells; + FOREACH(GuiCellComposition*, cell, cellCompositions) + { + if (cell && !cells.Contains(cell)) + { + cells.Add(cell); + Size newSize = cell->GetPreferredBounds().GetSize(); + if (cell->lastPreferredSize != newSize) + { + cell->lastPreferredSize = newSize; + cellMinSizeModified = true; + } + } + } + + if (previousContentBounds != result || cellMinSizeModified) + { + previousContentBounds = result; + UpdateCellBounds(); + InvokeOnCompositionStateChanged(); + } + return result; + } + +/*********************************************************************** +GuiCellComposition +***********************************************************************/ + + void GuiCellComposition::ClearSitedCells(GuiTableComposition* table) + { + if (row != -1 && column != -1) + { + for (vint r = 0; r < rowSpan; r++) + { + for (vint c = 0; c < columnSpan; c++) + { + table->SetSitedCell(row + r, column + c, 0); + } + } + } + } + + void GuiCellComposition::SetSitedCells(GuiTableComposition* table) + { + for (vint r = 0; r < rowSpan; r++) + { + for (vint c = 0; c < columnSpan; c++) + { + table->SetSitedCell(row + r, column + c, this); + } + } + } + + void GuiCellComposition::ResetSiteInternal() + { + row = -1; + column = -1; + rowSpan = 1; + columnSpan = 1; + } + + bool GuiCellComposition::SetSiteInternal(vint _row, vint _column, vint _rowSpan, vint _columnSpan) + { + if (tableParent) + { + if (_row < 0 || _row >= tableParent->rows || _column < 0 || _column >= tableParent->columns) return false; + if (_rowSpan<1 || _row + _rowSpan>tableParent->rows || _columnSpan<1 || _column + _columnSpan>tableParent->columns) return false; + + for (vint r = 0; r < _rowSpan; r++) + { + for (vint c = 0; c < _columnSpan; c++) + { + GuiCellComposition* cell = tableParent->GetSitedCell(_row + r, _column + c); + if (cell && cell != this) + { + return false; + } + } + } + ClearSitedCells(tableParent); + } + + row = _row; + column = _column; + rowSpan = _rowSpan; + columnSpan = _columnSpan; + + if (tableParent) + { + SetSitedCells(tableParent); + } + return true; + } + + void GuiCellComposition::OnParentChanged(GuiGraphicsComposition* oldParent, GuiGraphicsComposition* newParent) + { + GuiGraphicsSite::OnParentChanged(oldParent, newParent); + if (tableParent) + { + ClearSitedCells(tableParent); + } + tableParent = dynamic_cast(newParent); + if (!tableParent || !SetSiteInternal(row, column, rowSpan, columnSpan)) + { + ResetSiteInternal(); + } + if (tableParent) + { + if (row != -1 && column != -1) + { + SetSiteInternal(row, column, rowSpan, columnSpan); + } + tableParent->UpdateCellBounds(); + } + } + + void GuiCellComposition::OnTableRowsAndColumnsChanged() + { + if(!SetSiteInternal(row, column, rowSpan, columnSpan)) + { + ResetSiteInternal(); + } + } + + GuiCellComposition::GuiCellComposition() + :row(-1) + ,column(-1) + ,rowSpan(1) + ,columnSpan(1) + ,tableParent(0) + { + SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + } + + GuiCellComposition::~GuiCellComposition() + { + } + + GuiTableComposition* GuiCellComposition::GetTableParent() + { + return tableParent; + } + + vint GuiCellComposition::GetRow() + { + return row; + } + + vint GuiCellComposition::GetRowSpan() + { + return rowSpan; + } + + vint GuiCellComposition::GetColumn() + { + return column; + } + + vint GuiCellComposition::GetColumnSpan() + { + return columnSpan; + } + + bool GuiCellComposition::SetSite(vint _row, vint _column, vint _rowSpan, vint _columnSpan) + { + if(SetSiteInternal(_row, _column, _rowSpan, _columnSpan)) + { + if (tableParent) + { + tableParent->UpdateCellBounds(); + } + InvokeOnCompositionStateChanged(); + return true; + } + else + { + return false; + } + } + + Rect GuiCellComposition::GetBounds() + { + Rect result; + if(tableParent && row!=-1 && column!=-1) + { + Rect bounds1, bounds2; + { + vint index=tableParent->GetSiteIndex(tableParent->rows, tableParent->columns, row, column); + bounds1=tableParent->cellBounds[index]; + } + { + vint index=tableParent->GetSiteIndex(tableParent->rows, tableParent->columns, row+rowSpan-1, column+columnSpan-1); + bounds2=tableParent->cellBounds[index]; + if(tableParent->GetMinSizeLimitation()==GuiGraphicsComposition::NoLimit) + { + if(row+rowSpan==tableParent->rows) + { + bounds2.y2+=tableParent->rowExtending; + } + if(column+columnSpan==tableParent->columns) + { + bounds2.x2+=tableParent->columnExtending; + } + } + } + vint offset = tableParent->borderVisible ? tableParent->cellPadding : 0; + result = Rect(bounds1.x1 + offset, bounds1.y1 + offset, bounds2.x2 + offset, bounds2.y2 + offset); + } + else + { + result = Rect(); + } + UpdatePreviousBounds(result); + return result; + } + +/*********************************************************************** +GuiTableSplitterCompositionBase +***********************************************************************/ + + void GuiTableSplitterCompositionBase::OnParentChanged(GuiGraphicsComposition* oldParent, GuiGraphicsComposition* newParent) + { + GuiGraphicsSite::OnParentChanged(oldParent, newParent); + tableParent = dynamic_cast(newParent); + } + + void GuiTableSplitterCompositionBase::OnLeftButtonDown(GuiGraphicsComposition* sender, GuiMouseEventArgs& arguments) + { + dragging = true; + draggingPoint = Point(arguments.x, arguments.y); + } + + void GuiTableSplitterCompositionBase::OnLeftButtonUp(GuiGraphicsComposition* sender, GuiMouseEventArgs& arguments) + { + dragging = false; + } + + void GuiTableSplitterCompositionBase::OnMouseMoveHelper( + vint cellsBefore, + vint GuiTableComposition::* cells, + collections::Array& cellSizes, + vint offset, + GuiCellOption(GuiTableComposition::*getOption)(vint), + void(GuiTableComposition::*setOption)(vint, GuiCellOption) + ) + { + if (dragging) + { + if (tableParent) + { + if (0 < cellsBefore && cellsBefore < tableParent->*cells) + { + auto o1 = (tableParent->*getOption)(cellsBefore - 1); + auto o2 = (tableParent->*getOption)(cellsBefore); + + vint indexStart = -1; + vint indexEnd = -1; + vint indexStep = -1; + vint max = 0; + + if (offset < 0) + { + indexStart = cellsBefore - 1; + indexEnd = -1; + indexStep = -1; + } + else if (offset > 0) + { + indexStart = cellsBefore; + indexEnd = tableParent->*cells; + indexStep = 1; + } + else + { + return; + } + + { + auto o = (tableParent->*getOption)(indexStart); + if (o.composeType == GuiCellOption::Absolute) + { + max = o.absolute - 1; + } + else + { + for (vint i = indexStart; i != indexEnd; i += indexStep) + { + o = (tableParent->*getOption)(i); + if (o.composeType == GuiCellOption::Absolute) + { + break; + } + else if (o.composeType == GuiCellOption::Percentage) + { + max += cellSizes[i] - 1; + } + } + } + + if (max <= 0) + { + return; + } + } + + if (offset < 0) + { + if (max < -offset) + { + offset = -max; + } + } + else + { + if (max < offset) + { + offset = max; + } + } + + if (o1.composeType == GuiCellOption::Absolute) + { + o1.absolute += offset; + (tableParent->*setOption)(cellsBefore - 1, o1); + } + if (o2.composeType == GuiCellOption::Absolute) + { + o2.absolute -= offset; + (tableParent->*setOption)(cellsBefore, o2); + } + tableParent->ForceCalculateSizeImmediately(); + } + } + } + } + + Rect GuiTableSplitterCompositionBase::GetBoundsHelper( + vint cellsBefore, + vint GuiTableComposition::* cells, + vint(Rect::* dimSize)()const, + collections::Array& cellOffsets, + vint Rect::* dimU1, + vint Rect::* dimU2, + vint Rect::* dimV1, + vint Rect::* dimV2 + ) + { + Rect result(0, 0, 0, 0); + if (tableParent) + { + if (0 < cellsBefore && cellsBefore < tableParent->*cells) + { + vint offset = tableParent->borderVisible ? tableParent->cellPadding : 0; + result.*dimU1 = offset; + result.*dimU2 = offset + (tableParent->GetCellArea().*dimSize)(); + result.*dimV1 = offset + cellOffsets[cellsBefore] - tableParent->cellPadding; + result.*dimV2 = (result.*dimV1) + tableParent->cellPadding; + } + } + UpdatePreviousBounds(result); + return result; + } + + GuiTableSplitterCompositionBase::GuiTableSplitterCompositionBase() + :tableParent(0) + , dragging(false) + { + SetAssociatedCursor(GetCurrentController()->ResourceService()->GetSystemCursor(INativeCursor::SizeNS)); + GetEventReceiver()->leftButtonDown.AttachMethod(this, &GuiTableSplitterCompositionBase::OnLeftButtonDown); + GetEventReceiver()->leftButtonUp.AttachMethod(this, &GuiTableSplitterCompositionBase::OnLeftButtonUp); + } + + GuiTableSplitterCompositionBase::~GuiTableSplitterCompositionBase() + { + } + + GuiTableComposition* GuiTableSplitterCompositionBase::GetTableParent() + { + return tableParent; + } + +/*********************************************************************** +GuiRowSplitterComposition +***********************************************************************/ + + void GuiRowSplitterComposition::OnMouseMove(GuiGraphicsComposition* sender, GuiMouseEventArgs& arguments) + { + OnMouseMoveHelper( + rowsToTheTop, + &GuiTableComposition::rows, + tableParent->rowSizes, + arguments.y - draggingPoint.y, + &GuiTableComposition::GetRowOption, + &GuiTableComposition::SetRowOption + ); + } + + GuiRowSplitterComposition::GuiRowSplitterComposition() + :rowsToTheTop(0) + { + SetAssociatedCursor(GetCurrentController()->ResourceService()->GetSystemCursor(INativeCursor::SizeNS)); + GetEventReceiver()->mouseMove.AttachMethod(this, &GuiRowSplitterComposition::OnMouseMove); + } + + GuiRowSplitterComposition::~GuiRowSplitterComposition() + { + } + + vint GuiRowSplitterComposition::GetRowsToTheTop() + { + return rowsToTheTop; + } + + void GuiRowSplitterComposition::SetRowsToTheTop(vint value) + { + rowsToTheTop = value; + InvokeOnCompositionStateChanged(); + } + + Rect GuiRowSplitterComposition::GetBounds() + { + return GetBoundsHelper( + rowsToTheTop, + &GuiTableComposition::rows, + &Rect::Width, + tableParent->rowOffsets, + &Rect::x1, + &Rect::x2, + &Rect::y1, + &Rect::y2 + ); + } + +/*********************************************************************** +GuiColumnSplitterComposition +***********************************************************************/ + + void GuiColumnSplitterComposition::OnMouseMove(GuiGraphicsComposition* sender, GuiMouseEventArgs& arguments) + { + OnMouseMoveHelper( + columnsToTheLeft, + &GuiTableComposition::columns, + tableParent->columnSizes, + arguments.x - draggingPoint.x, + &GuiTableComposition::GetColumnOption, + &GuiTableComposition::SetColumnOption + ); + } + + GuiColumnSplitterComposition::GuiColumnSplitterComposition() + :columnsToTheLeft(0) + { + SetAssociatedCursor(GetCurrentController()->ResourceService()->GetSystemCursor(INativeCursor::SizeWE)); + GetEventReceiver()->mouseMove.AttachMethod(this, &GuiColumnSplitterComposition::OnMouseMove); + } + + GuiColumnSplitterComposition::~GuiColumnSplitterComposition() + { + } + + vint GuiColumnSplitterComposition::GetColumnsToTheLeft() + { + return columnsToTheLeft; + } + + void GuiColumnSplitterComposition::SetColumnsToTheLeft(vint value) + { + columnsToTheLeft = value; + InvokeOnCompositionStateChanged(); + } + + Rect GuiColumnSplitterComposition::GetBounds() + { + return GetBoundsHelper( + columnsToTheLeft, + &GuiTableComposition::columns, + &Rect::Height, + tableParent->columnOffsets, + &Rect::y1, + &Rect::y2, + &Rect::x1, + &Rect::x2 + ); + } + } + } } /*********************************************************************** -CONTROLS\GUIBASICCONTROLS.CPP +.\GRAPHICSELEMENT\GUIGRAPHICSDOCUMENTELEMENT.CPP +***********************************************************************/ + +namespace vl +{ + using namespace collections; + + namespace presentation + { + namespace elements + { + +/*********************************************************************** +SetPropertiesVisitor +***********************************************************************/ + + namespace visitors + { + class SetPropertiesVisitor : public Object, public DocumentRun::IVisitor + { + typedef GuiDocumentElement::GuiDocumentElementRenderer Renderer; + typedef DocumentModel::ResolvedStyle ResolvedStyle; + public: + vint start; + vint length; + vint selectionBegin; + vint selectionEnd; + List styles; + + DocumentModel* model; + Renderer* renderer; + Ptr cache; + IGuiGraphicsParagraph* paragraph; + + SetPropertiesVisitor(DocumentModel* _model, Renderer* _renderer, Ptr _cache, vint _selectionBegin, vint _selectionEnd) + :start(0) + ,length(0) + ,model(_model) + ,renderer(_renderer) + ,cache(_cache) + ,paragraph(_cache->graphicsParagraph.Obj()) + ,selectionBegin(_selectionBegin) + ,selectionEnd(_selectionEnd) + { + ResolvedStyle style; + style=model->GetStyle(DocumentModel::DefaultStyleName, style); + styles.Add(style); + } + + void VisitContainer(DocumentContainerRun* run) + { + FOREACH(Ptr, subRun, run->runs) + { + subRun->Accept(this); + } + } + + void ApplyStyle(vint start, vint length, const ResolvedStyle& style) + { + paragraph->SetFont(start, length, style.style.fontFamily); + paragraph->SetSize(start, length, style.style.size); + paragraph->SetStyle(start, length, + (IGuiGraphicsParagraph::TextStyle) + ( (style.style.bold?IGuiGraphicsParagraph::Bold:0) + | (style.style.italic?IGuiGraphicsParagraph::Italic:0) + | (style.style.underline?IGuiGraphicsParagraph::Underline:0) + | (style.style.strikeline?IGuiGraphicsParagraph::Strikeline:0) + )); + } + + void ApplyColor(vint start, vint length, const ResolvedStyle& style) + { + paragraph->SetColor(start, length, style.color); + paragraph->SetBackgroundColor(start, length, style.backgroundColor); + } + + void Visit(DocumentTextRun* run)override + { + length=run->GetRepresentationText().Length(); + if(length>0) + { + ResolvedStyle style=styles[styles.Count()-1]; + ApplyStyle(start, length, style); + ApplyColor(start, length, style); + + vint styleStart=start; + vint styleEnd=styleStart+length; + if(styleStartselectionBegin?styleStart:selectionBegin; + vint s3=selectionEndGetStyle(DocumentModel::SelectionStyleName, style); + ApplyColor(s2, s3-s2, selectionStyle); + } + } + } + start+=length; + } + + void Visit(DocumentStylePropertiesRun* run)override + { + ResolvedStyle style=styles[styles.Count()-1]; + style=model->GetStyle(run->style, style); + styles.Add(style); + VisitContainer(run); + styles.RemoveAt(styles.Count()-1); + } + + void Visit(DocumentStyleApplicationRun* run)override + { + ResolvedStyle style=styles[styles.Count()-1]; + style=model->GetStyle(run->styleName, style); + styles.Add(style); + VisitContainer(run); + styles.RemoveAt(styles.Count()-1); + } + + void Visit(DocumentHyperlinkRun* run)override + { + ResolvedStyle style=styles[styles.Count()-1]; + style=model->GetStyle(run->styleName, style); + styles.Add(style); + VisitContainer(run); + styles.RemoveAt(styles.Count()-1); + } + + void Visit(DocumentImageRun* run)override + { + length=run->GetRepresentationText().Length(); + + Ptr element=GuiImageFrameElement::Create(); + element->SetImage(run->image, run->frameIndex); + element->SetStretch(true); + + IGuiGraphicsParagraph::InlineObjectProperties properties; + properties.size=run->size; + properties.baseline=run->baseline; + properties.breakCondition=IGuiGraphicsParagraph::Alone; + properties.backgroundImage = element; + + paragraph->SetInlineObject(start, length, properties); + + if(startGetStyle(DocumentModel::SelectionStyleName, style); + ApplyColor(start, length, selectionStyle); + } + start+=length; + } + + void Visit(DocumentEmbeddedObjectRun* run)override + { + length=run->GetRepresentationText().Length(); + + IGuiGraphicsParagraph::InlineObjectProperties properties; + properties.breakCondition=IGuiGraphicsParagraph::Alone; + + if (run->name != L"") + { + vint index = renderer->nameCallbackIdMap.Keys().IndexOf(run->name); + if (index != -1) + { + auto id = renderer->nameCallbackIdMap.Values()[index]; + index = cache->embeddedObjects.Keys().IndexOf(id); + if (index != -1) + { + auto eo = cache->embeddedObjects.Values()[index]; + if (eo->start == start) + { + properties.size = eo->size; + properties.callbackId = id; + } + } + } + else + { + auto eo = MakePtr(); + eo->name = run->name; + eo->size = Size(0, 0); + eo->start = start; + + vint id = -1; + vint count = renderer->freeCallbackIds.Count(); + if (count > 0) + { + id = renderer->freeCallbackIds[count - 1]; + renderer->freeCallbackIds.RemoveAt(count - 1); + } + else + { + id = renderer->usedCallbackIds++; + } + + renderer->nameCallbackIdMap.Add(eo->name, id); + cache->embeddedObjects.Add(id, eo); + properties.callbackId = id; + } + } + + paragraph->SetInlineObject(start, length, properties); + + if(startGetStyle(DocumentModel::SelectionStyleName, style); + ApplyColor(start, length, selectionStyle); + } + start+=length; + } + + void Visit(DocumentParagraphRun* run)override + { + VisitContainer(run); + } + + static vint SetProperty(DocumentModel* model, Renderer* renderer, Ptr cache, Ptr run, vint selectionBegin, vint selectionEnd) + { + SetPropertiesVisitor visitor(model, renderer, cache, selectionBegin, selectionEnd); + run->Accept(&visitor); + return visitor.length; + } + }; + } + using namespace visitors; + +/*********************************************************************** +GuiDocumentElement::GuiDocumentElementRenderer +***********************************************************************/ + + Size GuiDocumentElement::GuiDocumentElementRenderer::OnRenderInlineObject(vint callbackId, Rect location) + { + if (element->callback) + { + auto cache = paragraphCaches[renderingParagraph]; + auto relativeLocation = Rect(Point(location.x1 + renderingParagraphOffset.x, location.y1 + renderingParagraphOffset.y), location.GetSize()); + auto eo = cache->embeddedObjects[callbackId]; + auto size = element->callback->OnRenderEmbeddedObject(eo->name, relativeLocation); + eo->resized = eo->size != size; + eo->size = size; + return eo->size; + } + else + { + return Size(); + } + } + + void GuiDocumentElement::GuiDocumentElementRenderer::InitializeInternal() + { + } + + void GuiDocumentElement::GuiDocumentElementRenderer::FinalizeInternal() + { + } + + void GuiDocumentElement::GuiDocumentElementRenderer::RenderTargetChangedInternal(IGuiGraphicsRenderTarget* oldRenderTarget, IGuiGraphicsRenderTarget* newRenderTarget) + { + for(vint i=0;igraphicsParagraph=0; + } + } + } + + Ptr GuiDocumentElement::GuiDocumentElementRenderer::EnsureAndGetCache(vint paragraphIndex, bool createParagraph) + { + if(paragraphIndex<0 || paragraphIndex>=paragraphCaches.Count()) return 0; + Ptr paragraph=element->document->paragraphs[paragraphIndex]; + Ptr cache=paragraphCaches[paragraphIndex]; + if(!cache) + { + cache=new ParagraphCache; + cache->fullText=paragraph->GetText(false); + paragraphCaches[paragraphIndex]=cache; + } + + if(createParagraph) + { + if(!cache->graphicsParagraph) + { + cache->graphicsParagraph=layoutProvider->CreateParagraph(cache->fullText, renderTarget, this); + cache->graphicsParagraph->SetParagraphAlignment(paragraph->alignment ? paragraph->alignment.Value() : Alignment::Left); + SetPropertiesVisitor::SetProperty(element->document.Obj(), this, cache, paragraph, cache->selectionBegin, cache->selectionEnd); + } + if(cache->graphicsParagraph->GetMaxWidth()!=lastMaxWidth) + { + cache->graphicsParagraph->SetMaxWidth(lastMaxWidth); + } + + vint paragraphHeight=paragraphHeights[paragraphIndex]; + vint height=cache->graphicsParagraph->GetHeight(); + if(paragraphHeight!=height) + { + cachedTotalHeight+=height-paragraphHeight; + paragraphHeight=height; + paragraphHeights[paragraphIndex]=paragraphHeight; + minSize=Size(0, cachedTotalHeight); + } + } + + return cache; + } + + bool GuiDocumentElement::GuiDocumentElementRenderer::GetParagraphIndexFromPoint(Point point, vint& top, vint& index) + { + vint y=0; + for(vint i=0;iGetLayoutProvider()) + ,lastCaret(-1, -1) + ,lastCaretFrontSide(false) + { + } + + void GuiDocumentElement::GuiDocumentElementRenderer::Render(Rect bounds) + { + if (element->callback) + { + element->callback->OnStartRender(); + } + renderTarget->PushClipper(bounds); + if(!renderTarget->IsClipperCoverWholeTarget()) + { + vint maxWidth=bounds.Width(); + Rect clipper=renderTarget->GetClipper(); + vint cx=bounds.Left(); + vint cy=bounds.Top(); + vint y1=clipper.Top()-bounds.Top(); + vint y2=y1+clipper.Height(); + vint y=0; + + lastMaxWidth=maxWidth; + + for(vint i=0;i=y2) + { + break; + } + else + { + Ptr paragraph=element->document->paragraphs[i]; + Ptr cache=paragraphCaches[i]; + bool created=cache && cache->graphicsParagraph; + cache=EnsureAndGetCache(i, true); + if(!created && i==lastCaret.row && element->caretVisible) + { + cache->graphicsParagraph->OpenCaret(lastCaret.column, lastCaretColor, lastCaretFrontSide); + } + + paragraphHeight=cache->graphicsParagraph->GetHeight(); + + renderingParagraph = i; + renderingParagraphOffset = Point(cx - bounds.x1, cy + y - bounds.y1); + cache->graphicsParagraph->Render(Rect(Point(cx, cy+y), Size(maxWidth, paragraphHeight))); + renderingParagraph = -1; + + bool resized = false; + for (vint j = 0; j < cache->embeddedObjects.Count(); j++) + { + auto eo = cache->embeddedObjects.Values()[j]; + if (eo->resized) + { + eo->resized = false; + resized = true; + } + } + + if (resized) + { + cache->graphicsParagraph = 0; + } + } + + y+=paragraphHeight+paragraphDistance; + } + } + renderTarget->PopClipper(); + if (element->callback) + { + element->callback->OnFinishRender(); + } + } + + void GuiDocumentElement::GuiDocumentElementRenderer::OnElementStateChanged() + { + if (element->document && element->document->paragraphs.Count() > 0) + { + vint defaultSize = GetCurrentController()->ResourceService()->GetDefaultFont().size; + paragraphDistance = defaultSize; + vint defaultHeight = defaultSize; + + paragraphCaches.Resize(element->document->paragraphs.Count()); + paragraphHeights.Resize(element->document->paragraphs.Count()); + + for (vint i = 0; i < paragraphCaches.Count(); i++) + { + paragraphCaches[i] = 0; + } + for (vint i = 0; i < paragraphHeights.Count(); i++) + { + paragraphHeights[i] = defaultHeight; + } + + cachedTotalHeight = paragraphHeights.Count() * (defaultHeight + paragraphDistance); + if (paragraphHeights.Count()>0) + { + cachedTotalHeight -= paragraphDistance; + } + minSize = Size(0, cachedTotalHeight); + } + else + { + paragraphCaches.Resize(0); + paragraphHeights.Resize(0); + cachedTotalHeight = 0; + minSize = Size(0, 0); + } + + nameCallbackIdMap.Clear(); + freeCallbackIds.Clear(); + usedCallbackIds = 0; + } + + void GuiDocumentElement::GuiDocumentElementRenderer::NotifyParagraphUpdated(vint index, vint oldCount, vint newCount, bool updatedText) + { + if (0 <= index && index < paragraphCaches.Count() && 0 <= oldCount && index + oldCount <= paragraphCaches.Count() && 0 <= newCount) + { + vint paragraphCount = element->document->paragraphs.Count(); + CHECK_ERROR(updatedText || oldCount == newCount, L"GuiDocumentlement::GuiDocumentElementRenderer::NotifyParagraphUpdated(vint, vint, vint, bool)#Illegal values of oldCount and newCount."); + CHECK_ERROR(paragraphCount - paragraphCaches.Count() == newCount - oldCount, L"GuiDocumentElement::GuiDocumentElementRenderer::NotifyParagraphUpdated(vint, vint, vint, bool)#Illegal values of oldCount and newCount."); + + ParagraphCacheArray oldCaches; + CopyFrom(oldCaches, paragraphCaches); + paragraphCaches.Resize(paragraphCount); + + ParagraphHeightArray oldHeights; + CopyFrom(oldHeights, paragraphHeights); + paragraphHeights.Resize(paragraphCount); + + vint defaultHeight = GetCurrentController()->ResourceService()->GetDefaultFont().size; + cachedTotalHeight = 0; + + for (vint i = 0; i < paragraphCount; i++) + { + if (i < index) + { + paragraphCaches[i] = oldCaches[i]; + paragraphHeights[i] = oldHeights[i]; + } + else if (i < index + newCount) + { + paragraphCaches[i] = 0; + paragraphHeights[i] = defaultHeight; + if (!updatedText && i < index + oldCount) + { + auto cache = oldCaches[i]; + if(cache) + { + cache->graphicsParagraph = 0; + } + paragraphCaches[i] = cache; + paragraphHeights[i] = oldHeights[i]; + } + } + else + { + paragraphCaches[i] = oldCaches[i - (newCount - oldCount)]; + paragraphHeights[i] = oldHeights[i - (newCount - oldCount)]; + } + cachedTotalHeight += paragraphHeights[i] + paragraphDistance; + } + if (paragraphCount > 0) + { + cachedTotalHeight -= paragraphDistance; + } + + if (updatedText) + { + vint count = oldCount < newCount ? oldCount : newCount; + for (vint i = 0; i < count; i++) + { + if (auto cache = oldCaches[index + i]) + { + for (vint j = 0; j < cache->embeddedObjects.Count(); j++) + { + auto id = cache->embeddedObjects.Keys()[j]; + auto name = cache->embeddedObjects.Values()[j]->name; + nameCallbackIdMap.Remove(name); + freeCallbackIds.Add(id); + } + } + } + } + } + } + + Ptr GuiDocumentElement::GuiDocumentElementRenderer::GetHyperlinkFromPoint(Point point) + { + vint top=0; + vint index=-1; + if(GetParagraphIndexFromPoint(point, top, index)) + { + Ptr cache=EnsureAndGetCache(index, true); + Point paragraphPoint(point.x, point.y-top); + + vint start=-1; + vint length=0; + if(cache->graphicsParagraph->GetInlineObjectFromPoint(paragraphPoint, start, length)) + { + return element->document->GetHyperlink(index, start, start+length); + } + + vint caret=cache->graphicsParagraph->GetCaretFromPoint(paragraphPoint); + return element->document->GetHyperlink(index, caret, caret); + } + return 0; + } + + void GuiDocumentElement::GuiDocumentElementRenderer::OpenCaret(TextPos caret, Color color, bool frontSide) + { + CloseCaret(caret); + lastCaret=caret; + lastCaretColor=color; + lastCaretFrontSide=frontSide; + + Ptr cache=paragraphCaches[lastCaret.row]; + if(cache && cache->graphicsParagraph) + { + cache->graphicsParagraph->OpenCaret(lastCaret.column, lastCaretColor, lastCaretFrontSide); + } + } + + void GuiDocumentElement::GuiDocumentElementRenderer::CloseCaret(TextPos caret) + { + if(lastCaret!=TextPos(-1, -1)) + { + if(0<=lastCaret.row && lastCaret.row cache=paragraphCaches[lastCaret.row]; + if(cache && cache->graphicsParagraph) + { + cache->graphicsParagraph->CloseCaret(); + } + } + } + lastCaret=caret; + } + + void GuiDocumentElement::GuiDocumentElementRenderer::SetSelection(TextPos begin, TextPos end) + { + if(begin>end) + { + TextPos t=begin; + begin=end; + end=t; + } + if(begin==end) + { + begin=TextPos(-1, -1); + end=TextPos(-1, -1); + } + + for(vint i=0;i cache=EnsureAndGetCache(i, false); + vint newBegin=i==begin.row?begin.column:0; + vint newEnd=i==end.row?end.column:cache->fullText.Length(); + + if(cache->selectionBegin!=newBegin || cache->selectionEnd!=newEnd) + { + cache->selectionBegin=newBegin; + cache->selectionEnd=newEnd; + NotifyParagraphUpdated(i, 1, 1, false); + } + } + else + { + Ptr cache=paragraphCaches[i]; + if(cache) + { + if(cache->selectionBegin!=-1 || cache->selectionEnd!=-1) + { + cache->selectionBegin=-1; + cache->selectionEnd=-1; + NotifyParagraphUpdated(i, 1, 1, false); + } + } + } + } + } + + TextPos GuiDocumentElement::GuiDocumentElementRenderer::CalculateCaret(TextPos comparingCaret, IGuiGraphicsParagraph::CaretRelativePosition position, bool& preferFrontSide) + { + Ptr cache=EnsureAndGetCache(comparingCaret.row, true); + if(cache) + { + switch(position) + { + case IGuiGraphicsParagraph::CaretFirst: + { + preferFrontSide=false; + vint caret=cache->graphicsParagraph->GetCaret(0, IGuiGraphicsParagraph::CaretFirst, preferFrontSide); + return TextPos(comparingCaret.row, caret); + } + case IGuiGraphicsParagraph::CaretLast: + { + preferFrontSide=true; + vint caret=cache->graphicsParagraph->GetCaret(0, IGuiGraphicsParagraph::CaretLast, preferFrontSide); + return TextPos(comparingCaret.row, caret); + } + case IGuiGraphicsParagraph::CaretLineFirst: + { + preferFrontSide=false; + vint caret=cache->graphicsParagraph->GetCaret(comparingCaret.column, IGuiGraphicsParagraph::CaretLineFirst, preferFrontSide); + return TextPos(comparingCaret.row, caret); + } + case IGuiGraphicsParagraph::CaretLineLast: + { + preferFrontSide=true; + vint caret=cache->graphicsParagraph->GetCaret(comparingCaret.column, IGuiGraphicsParagraph::CaretLineLast, preferFrontSide); + return TextPos(comparingCaret.row, caret); + } + case IGuiGraphicsParagraph::CaretMoveUp: + { + vint caret=cache->graphicsParagraph->GetCaret(comparingCaret.column, IGuiGraphicsParagraph::CaretMoveUp, preferFrontSide); + if(caret==comparingCaret.column && comparingCaret.row>0) + { + Rect caretBounds=cache->graphicsParagraph->GetCaretBounds(comparingCaret.column, preferFrontSide); + Ptr anotherCache=EnsureAndGetCache(comparingCaret.row-1, true); + vint height=anotherCache->graphicsParagraph->GetHeight(); + caret=anotherCache->graphicsParagraph->GetCaretFromPoint(Point(caretBounds.x1, height)); + return TextPos(comparingCaret.row-1, caret); + } + else + { + return TextPos(comparingCaret.row, caret); + } + } + case IGuiGraphicsParagraph::CaretMoveDown: + { + vint caret=cache->graphicsParagraph->GetCaret(comparingCaret.column, IGuiGraphicsParagraph::CaretMoveDown, preferFrontSide); + if(caret==comparingCaret.column && comparingCaret.rowgraphicsParagraph->GetCaretBounds(comparingCaret.column, preferFrontSide); + Ptr anotherCache=EnsureAndGetCache(comparingCaret.row+1, true); + caret=anotherCache->graphicsParagraph->GetCaretFromPoint(Point(caretBounds.x1, 0)); + return TextPos(comparingCaret.row+1, caret); + } + else + { + return TextPos(comparingCaret.row, caret); + } + } + case IGuiGraphicsParagraph::CaretMoveLeft: + { + preferFrontSide=false; + vint caret=cache->graphicsParagraph->GetCaret(comparingCaret.column, IGuiGraphicsParagraph::CaretMoveLeft, preferFrontSide); + if(caret==comparingCaret.column && comparingCaret.row>0) + { + Ptr anotherCache=EnsureAndGetCache(comparingCaret.row-1, true); + caret=anotherCache->graphicsParagraph->GetCaret(0, IGuiGraphicsParagraph::CaretLast, preferFrontSide); + return TextPos(comparingCaret.row-1, caret); + } + else + { + return TextPos(comparingCaret.row, caret); + } + } + case IGuiGraphicsParagraph::CaretMoveRight: + { + preferFrontSide=true; + vint caret=cache->graphicsParagraph->GetCaret(comparingCaret.column, IGuiGraphicsParagraph::CaretMoveRight, preferFrontSide); + if(caret==comparingCaret.column && comparingCaret.row anotherCache=EnsureAndGetCache(comparingCaret.row+1, true); + caret=anotherCache->graphicsParagraph->GetCaret(0, IGuiGraphicsParagraph::CaretFirst, preferFrontSide); + return TextPos(comparingCaret.row+1, caret); + } + else + { + return TextPos(comparingCaret.row, caret); + } + } + } + } + return comparingCaret; + } + + TextPos GuiDocumentElement::GuiDocumentElementRenderer::CalculateCaretFromPoint(Point point) + { + vint top=0; + vint index=-1; + if(GetParagraphIndexFromPoint(point, top, index)) + { + Ptr cache=EnsureAndGetCache(index, true); + Point paragraphPoint(point.x, point.y-top); + vint caret=cache->graphicsParagraph->GetCaretFromPoint(paragraphPoint); + return TextPos(index, caret); + } + return TextPos(-1, -1); + } + + Rect GuiDocumentElement::GuiDocumentElementRenderer::GetCaretBounds(TextPos caret, bool frontSide) + { + Ptr cache=EnsureAndGetCache(caret.row, true); + if(cache) + { + Rect bounds=cache->graphicsParagraph->GetCaretBounds(caret.column, frontSide); + if(bounds!=Rect()) + { + vint y=0; + for(vint i=0;i(); + if (elementRenderer) + { + elementRenderer->SetSelection(caretBegin, caretEnd); + if (caretVisible) + { + elementRenderer->OpenCaret(caretEnd, caretColor, caretFrontSide); + } + else + { + elementRenderer->CloseCaret(caretEnd); + } + InvokeOnCompositionStateChanged(); + } + } + + GuiDocumentElement::GuiDocumentElement() + :caretVisible(false) + ,caretFrontSide(false) + { + } + + GuiDocumentElement::ICallback* GuiDocumentElement::GetCallback() + { + return callback; + } + + void GuiDocumentElement::SetCallback(ICallback* value) + { + callback = value; + } + + Ptr GuiDocumentElement::GetDocument() + { + return document; + } + + void GuiDocumentElement::SetDocument(Ptr value) + { + document=value; + InvokeOnElementStateChanged(); + SetCaret(TextPos(), TextPos(), false); + } + + TextPos GuiDocumentElement::GetCaretBegin() + { + return caretBegin; + } + + TextPos GuiDocumentElement::GetCaretEnd() + { + return caretEnd; + } + + bool GuiDocumentElement::IsCaretEndPreferFrontSide() + { + return caretFrontSide; + } + + void GuiDocumentElement::SetCaret(TextPos begin, TextPos end, bool frontSide) + { + caretBegin=begin; + caretEnd=end; + if(caretBegincaretEnd) + { + caretFrontSide=false; + } + else + { + caretFrontSide=frontSide; + } + UpdateCaret(); + } + + bool GuiDocumentElement::GetCaretVisible() + { + return caretVisible; + } + + void GuiDocumentElement::SetCaretVisible(bool value) + { + caretVisible=value; + UpdateCaret(); + } + + Color GuiDocumentElement::GetCaretColor() + { + return caretColor; + } + + void GuiDocumentElement::SetCaretColor(Color value) + { + caretColor=value; + UpdateCaret(); + } + + TextPos GuiDocumentElement::CalculateCaret(TextPos comparingCaret, IGuiGraphicsParagraph::CaretRelativePosition position, bool& preferFrontSide) + { + Ptr elementRenderer=renderer.Cast(); + if(elementRenderer) + { + TextPos caret=elementRenderer->CalculateCaret(comparingCaret, position, preferFrontSide); + return caret.column==-1?comparingCaret:caret; + } + else + { + return comparingCaret; + } + } + + TextPos GuiDocumentElement::CalculateCaretFromPoint(Point point) + { + Ptr elementRenderer=renderer.Cast(); + if(elementRenderer) + { + return elementRenderer->CalculateCaretFromPoint(point); + } + else + { + return TextPos(0, 0); + } + } + + Rect GuiDocumentElement::GetCaretBounds(TextPos caret, bool frontSide) + { + Ptr elementRenderer=renderer.Cast(); + if(elementRenderer) + { + return elementRenderer->GetCaretBounds(caret, frontSide); + } + else + { + return Rect(); + } + } + + void GuiDocumentElement::NotifyParagraphUpdated(vint index, vint oldCount, vint newCount, bool updatedText) + { + auto elementRenderer = renderer.Cast(); + if (elementRenderer) + { + elementRenderer->NotifyParagraphUpdated(index, oldCount, newCount, updatedText); + InvokeOnCompositionStateChanged(); + } + } + + void GuiDocumentElement::EditRun(TextPos begin, TextPos end, Ptr model, bool copy) + { + auto elementRenderer = renderer.Cast(); + if (elementRenderer) + { + if (begin > end) + { + TextPos temp = begin; + begin = end; + end = temp; + } + + vint newRows = document->EditRun(begin, end, model, copy); + if (newRows != -1) + { + elementRenderer->NotifyParagraphUpdated(begin.row, end.row - begin.row + 1, newRows, true); + } + InvokeOnCompositionStateChanged(); + } + } + + void GuiDocumentElement::EditText(TextPos begin, TextPos end, bool frontSide, const collections::Array& text) + { + auto elementRenderer = renderer.Cast(); + if (elementRenderer) + { + if (begin > end) + { + TextPos temp = begin; + begin = end; + end = temp; + } + + vint newRows = document->EditText(begin, end, frontSide, text); + if (newRows != -1) + { + elementRenderer->NotifyParagraphUpdated(begin.row, end.row - begin.row + 1, newRows, true); + } + InvokeOnCompositionStateChanged(); + } + } + + void GuiDocumentElement::EditStyle(TextPos begin, TextPos end, Ptr style) + { + auto elementRenderer = renderer.Cast(); + if (elementRenderer) + { + if (begin > end) + { + TextPos temp = begin; + begin = end; + end = temp; + } + + if (document->EditStyle(begin, end, style)) + { + elementRenderer->NotifyParagraphUpdated(begin.row, end.row - begin.row + 1, end.row - begin.row + 1, false); + } + InvokeOnCompositionStateChanged(); + } + } + + void GuiDocumentElement::EditImage(TextPos begin, TextPos end, Ptr image) + { + auto elementRenderer = renderer.Cast(); + if (elementRenderer) + { + if (begin > end) + { + TextPos temp = begin; + begin = end; + end = temp; + } + + if (document->EditImage(begin, end, image)) + { + elementRenderer->NotifyParagraphUpdated(begin.row, end.row - begin.row + 1, 1, true); + } + InvokeOnCompositionStateChanged(); + } + } + + void GuiDocumentElement::EditHyperlink(vint paragraphIndex, vint begin, vint end, const WString& reference, const WString& normalStyleName, const WString& activeStyleName) + { + auto elementRenderer = renderer.Cast(); + if (elementRenderer) + { + if (begin > end) + { + vint temp = begin; + begin = end; + end = temp; + } + + if (document->EditHyperlink(paragraphIndex, begin, end, reference, normalStyleName, activeStyleName)) + { + elementRenderer->NotifyParagraphUpdated(paragraphIndex, 1, 1, false); + } + InvokeOnCompositionStateChanged(); + } + } + + void GuiDocumentElement::RemoveHyperlink(vint paragraphIndex, vint begin, vint end) + { + auto elementRenderer = renderer.Cast(); + if (elementRenderer) + { + if (begin > end) + { + vint temp = begin; + begin = end; + end = temp; + } + + if (document->RemoveHyperlink(paragraphIndex, begin, end)) + { + elementRenderer->NotifyParagraphUpdated(paragraphIndex, 1, 1, false); + } + InvokeOnCompositionStateChanged(); + } + } + + void GuiDocumentElement::EditStyleName(TextPos begin, TextPos end, const WString& styleName) + { + auto elementRenderer = renderer.Cast(); + if (elementRenderer) + { + if (begin > end) + { + TextPos temp = begin; + begin = end; + end = temp; + } + + if (document->EditStyleName(begin, end, styleName)) + { + elementRenderer->NotifyParagraphUpdated(begin.row, end.row - begin.row + 1, end.row - begin.row + 1, false); + } + InvokeOnCompositionStateChanged(); + } + } + + void GuiDocumentElement::RemoveStyleName(TextPos begin, TextPos end) + { + auto elementRenderer = renderer.Cast(); + if (elementRenderer) + { + if (begin > end) + { + TextPos temp = begin; + begin = end; + end = temp; + } + + if (document->RemoveStyleName(begin, end)) + { + elementRenderer->NotifyParagraphUpdated(begin.row, end.row - begin.row + 1, end.row - begin.row + 1, false); + } + InvokeOnCompositionStateChanged(); + } + } + + void GuiDocumentElement::RenameStyle(const WString& oldStyleName, const WString& newStyleName) + { + auto elementRenderer = renderer.Cast(); + if (elementRenderer) + { + document->RenameStyle(oldStyleName, newStyleName); + } + } + + void GuiDocumentElement::ClearStyle(TextPos begin, TextPos end) + { + auto elementRenderer = renderer.Cast(); + if (elementRenderer) + { + if (begin > end) + { + TextPos temp = begin; + begin = end; + end = temp; + } + + if (document->ClearStyle(begin, end)) + { + elementRenderer->NotifyParagraphUpdated(begin.row, end.row - begin.row + 1, end.row - begin.row + 1, false); + } + InvokeOnCompositionStateChanged(); + } + } + + Ptr GuiDocumentElement::SummarizeStyle(TextPos begin, TextPos end) + { + auto elementRenderer = renderer.Cast(); + if (elementRenderer) + { + if (begin > end) + { + TextPos temp = begin; + begin = end; + end = temp; + } + + return document->SummarizeStyle(begin, end); + } + return nullptr; + } + + void GuiDocumentElement::SetParagraphAlignment(TextPos begin, TextPos end, const collections::Array>& alignments) + { + auto elementRenderer = renderer.Cast(); + if (elementRenderer) + { + vint first = begin.row; + vint last = end.row; + if (first > last) + { + vint temp = first; + first = last; + last = temp; + } + + if (0 <= first && first < document->paragraphs.Count() && 0 <= last && last < document->paragraphs.Count() && last - first + 1 == alignments.Count()) + { + for (vint i = first; i <= last; i++) + { + document->paragraphs[i]->alignment = alignments[i - first]; + } + elementRenderer->NotifyParagraphUpdated(first, alignments.Count(), alignments.Count(), false); + } + InvokeOnCompositionStateChanged(); + } + } + + Nullable GuiDocumentElement::SummarizeParagraphAlignment(TextPos begin, TextPos end) + { + auto elementRenderer = renderer.Cast(); + if (elementRenderer) + { + if (begin > end) + { + TextPos temp = begin; + begin = end; + end = temp; + } + + return document->SummarizeParagraphAlignment(begin, end); + } + return {}; + } + + Ptr GuiDocumentElement::GetHyperlinkFromPoint(Point point) + { + auto elementRenderer=renderer.Cast(); + if(elementRenderer) + { + return elementRenderer->GetHyperlinkFromPoint(point); + } + return nullptr; + } + } + } +} + +/*********************************************************************** +.\GRAPHICSELEMENT\GUIGRAPHICSELEMENT.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace elements + { + using namespace collections; + +/*********************************************************************** +GuiSolidBorderElement +***********************************************************************/ + + GuiSolidBorderElement::GuiSolidBorderElement() + :color(0, 0, 0) + ,shape(ElementShape::Rectangle) + { + } + + Color GuiSolidBorderElement::GetColor() + { + return color; + } + + void GuiSolidBorderElement::SetColor(Color value) + { + if(color!=value) + { + color=value; + InvokeOnElementStateChanged(); + } + } + + ElementShape GuiSolidBorderElement::GetShape() + { + return shape; + } + + void GuiSolidBorderElement::SetShape(ElementShape value) + { + shape=value; + } + +/*********************************************************************** +GuiRoundBorderElement +***********************************************************************/ + + GuiRoundBorderElement::GuiRoundBorderElement() + :color(0, 0, 0) + ,radius(10) + { + } + + Color GuiRoundBorderElement::GetColor() + { + return color; + } + + void GuiRoundBorderElement::SetColor(Color value) + { + if(color!=value) + { + color=value; + InvokeOnElementStateChanged(); + } + } + + vint GuiRoundBorderElement::GetRadius() + { + return radius; + } + + void GuiRoundBorderElement::SetRadius(vint value) + { + if(radius!=value) + { + radius=value; + InvokeOnElementStateChanged(); + } + } + +/*********************************************************************** +Gui3DBorderElement +***********************************************************************/ + + Gui3DBorderElement::Gui3DBorderElement() + { + } + + Color Gui3DBorderElement::GetColor1() + { + return color1; + } + + void Gui3DBorderElement::SetColor1(Color value) + { + SetColors(value, color2); + } + + Color Gui3DBorderElement::GetColor2() + { + return color2; + } + + void Gui3DBorderElement::SetColor2(Color value) + { + SetColors(color1, value); + } + + void Gui3DBorderElement::SetColors(Color value1, Color value2) + { + if(color1!=value1 || color2!=value2) + { + color1=value1; + color2=value2; + InvokeOnElementStateChanged(); + } + } + +/*********************************************************************** +Gui3DSplitterElement +***********************************************************************/ + + Gui3DSplitterElement::Gui3DSplitterElement() + :direction(Horizontal) + { + } + + Color Gui3DSplitterElement::GetColor1() + { + return color1; + } + + void Gui3DSplitterElement::SetColor1(Color value) + { + SetColors(value, color2); + } + + Color Gui3DSplitterElement::GetColor2() + { + return color2; + } + + void Gui3DSplitterElement::SetColor2(Color value) + { + SetColors(color1, value); + } + + void Gui3DSplitterElement::SetColors(Color value1, Color value2) + { + if(color1!=value1 || color2!=value2) + { + color1=value1; + color2=value2; + InvokeOnElementStateChanged(); + } + } + + Gui3DSplitterElement::Direction Gui3DSplitterElement::GetDirection() + { + return direction; + } + + void Gui3DSplitterElement::SetDirection(Direction value) + { + if(direction!=value) + { + direction=value; + InvokeOnElementStateChanged(); + } + } + +/*********************************************************************** +GuiSolidBackgroundElement +***********************************************************************/ + + GuiSolidBackgroundElement::GuiSolidBackgroundElement() + :color(255, 255, 255) + ,shape(ElementShape::Rectangle) + { + } + + Color GuiSolidBackgroundElement::GetColor() + { + return color; + } + + void GuiSolidBackgroundElement::SetColor(Color value) + { + if(color!=value) + { + color=value; + InvokeOnElementStateChanged(); + } + } + + ElementShape GuiSolidBackgroundElement::GetShape() + { + return shape; + } + + void GuiSolidBackgroundElement::SetShape(ElementShape value) + { + shape=value; + } + +/*********************************************************************** +GuiGradientBackgroundElement +***********************************************************************/ + + GuiGradientBackgroundElement::GuiGradientBackgroundElement() + :direction(Horizontal) + ,shape(ElementShape::Rectangle) + { + } + + Color GuiGradientBackgroundElement::GetColor1() + { + return color1; + } + + void GuiGradientBackgroundElement::SetColor1(Color value) + { + SetColors(value, color2); + } + + Color GuiGradientBackgroundElement::GetColor2() + { + return color2; + } + + void GuiGradientBackgroundElement::SetColor2(Color value) + { + SetColors(color1, value); + } + + void GuiGradientBackgroundElement::SetColors(Color value1, Color value2) + { + if(color1!=value1 || color2!=value2) + { + color1=value1; + color2=value2; + InvokeOnElementStateChanged(); + } + } + + GuiGradientBackgroundElement::Direction GuiGradientBackgroundElement::GetDirection() + { + return direction; + } + + void GuiGradientBackgroundElement::SetDirection(Direction value) + { + if(direction!=value) + { + direction=value; + InvokeOnElementStateChanged(); + } + } + + ElementShape GuiGradientBackgroundElement::GetShape() + { + return shape; + } + + void GuiGradientBackgroundElement::SetShape(ElementShape value) + { + shape=value; + } + +/*********************************************************************** +GuiSolidLabelElement +***********************************************************************/ + + GuiSolidLabelElement::GuiSolidLabelElement() + :color(0, 0, 0) + ,hAlignment(Alignment::Left) + ,vAlignment(Alignment::Top) + ,wrapLine(false) + ,ellipse(false) + ,multiline(false) + ,wrapLineHeightCalculation(false) + { + fontProperties.fontFamily=L"Lucida Console"; + fontProperties.size=12; + } + + Color GuiSolidLabelElement::GetColor() + { + return color; + } + + void GuiSolidLabelElement::SetColor(Color value) + { + if(color!=value) + { + color=value; + InvokeOnElementStateChanged(); + } + } + + const FontProperties& GuiSolidLabelElement::GetFont() + { + return fontProperties; + } + + void GuiSolidLabelElement::SetFont(const FontProperties& value) + { + if(fontProperties!=value) + { + fontProperties=value; + InvokeOnElementStateChanged(); + } + } + + const WString& GuiSolidLabelElement::GetText() + { + return text; + } + + void GuiSolidLabelElement::SetText(const WString& value) + { + if(text!=value) + { + text=value; + InvokeOnElementStateChanged(); + } + } + + Alignment GuiSolidLabelElement::GetHorizontalAlignment() + { + return hAlignment; + } + + Alignment GuiSolidLabelElement::GetVerticalAlignment() + { + return vAlignment; + } + + void GuiSolidLabelElement::SetHorizontalAlignment(Alignment value) + { + SetAlignments(value, vAlignment); + } + + void GuiSolidLabelElement::SetVerticalAlignment(Alignment value) + { + SetAlignments(hAlignment, value); + } + + void GuiSolidLabelElement::SetAlignments(Alignment horizontal, Alignment vertical) + { + if(hAlignment!=horizontal || vAlignment!=vertical) + { + hAlignment=horizontal; + vAlignment=vertical; + InvokeOnElementStateChanged(); + } + } + + bool GuiSolidLabelElement::GetWrapLine() + { + return wrapLine; + } + + void GuiSolidLabelElement::SetWrapLine(bool value) + { + if(wrapLine!=value) + { + wrapLine=value; + InvokeOnElementStateChanged(); + } + } + + bool GuiSolidLabelElement::GetEllipse() + { + return ellipse; + } + + void GuiSolidLabelElement::SetEllipse(bool value) + { + if(ellipse!=value) + { + ellipse=value; + InvokeOnElementStateChanged(); + } + } + + bool GuiSolidLabelElement::GetMultiline() + { + return multiline; + } + + void GuiSolidLabelElement::SetMultiline(bool value) + { + if(multiline!=value) + { + multiline=value; + InvokeOnElementStateChanged(); + } + } + + bool GuiSolidLabelElement::GetWrapLineHeightCalculation() + { + return wrapLineHeightCalculation; + } + + void GuiSolidLabelElement::SetWrapLineHeightCalculation(bool value) + { + if(wrapLineHeightCalculation!=value) + { + wrapLineHeightCalculation=value; + InvokeOnElementStateChanged(); + } + } + +/*********************************************************************** +GuiImageFrameElement +***********************************************************************/ + + GuiImageFrameElement::GuiImageFrameElement() + :frameIndex(0) + ,hAlignment(Alignment::Left) + ,vAlignment(Alignment::Top) + ,stretch(false) + ,enabled(true) + { + } + + Ptr GuiImageFrameElement::GetImage() + { + return image; + } + + vint GuiImageFrameElement::GetFrameIndex() + { + return frameIndex; + } + + void GuiImageFrameElement::SetImage(Ptr value) + { + SetImage(value, frameIndex); + } + + void GuiImageFrameElement::SetFrameIndex(vint value) + { + SetImage(image, value); + } + + void GuiImageFrameElement::SetImage(Ptr _image, vint _frameIndex) + { + if(image!=_image || frameIndex!=_frameIndex) + { + if(!_image) + { + image=0; + frameIndex=0; + } + else if(0<=_frameIndex && _frameIndex<_image->GetFrameCount()) + { + image=_image; + frameIndex=_frameIndex; + } + InvokeOnElementStateChanged(); + } + } + + Alignment GuiImageFrameElement::GetHorizontalAlignment() + { + return hAlignment; + } + + Alignment GuiImageFrameElement::GetVerticalAlignment() + { + return vAlignment; + } + + void GuiImageFrameElement::SetHorizontalAlignment(Alignment value) + { + SetAlignments(value, vAlignment); + } + + void GuiImageFrameElement::SetVerticalAlignment(Alignment value) + { + SetAlignments(hAlignment, value); + } + + void GuiImageFrameElement::SetAlignments(Alignment horizontal, Alignment vertical) + { + if(hAlignment!=horizontal || vAlignment!=vertical) + { + hAlignment=horizontal; + vAlignment=vertical; + InvokeOnElementStateChanged(); + } + } + + bool GuiImageFrameElement::GetStretch() + { + return stretch; + } + + void GuiImageFrameElement::SetStretch(bool value) + { + if(stretch!=value) + { + stretch=value; + InvokeOnElementStateChanged(); + } + } + + bool GuiImageFrameElement::GetEnabled() + { + return enabled; + } + + void GuiImageFrameElement::SetEnabled(bool value) + { + if(enabled!=value) + { + enabled=value; + InvokeOnElementStateChanged(); + } + } + +/*********************************************************************** +GuiPolygonElement +***********************************************************************/ + + GuiPolygonElement::GuiPolygonElement() + { + } + + Size GuiPolygonElement::GetSize() + { + return size; + } + + void GuiPolygonElement::SetSize(Size value) + { + if(size!=value) + { + size=value; + InvokeOnElementStateChanged(); + } + } + + const Point& GuiPolygonElement::GetPoint(vint index) + { + return points[index]; + } + + vint GuiPolygonElement::GetPointCount() + { + return points.Count(); + } + + void GuiPolygonElement::SetPoints(const Point* p, vint count) + { + points.Resize(count); + if(count>0) + { + memcpy(&points[0], p, sizeof(*p)*count); + } + InvokeOnElementStateChanged(); + } + + const GuiPolygonElement::PointArray& GuiPolygonElement::GetPointsArray() + { + return points; + } + + void GuiPolygonElement::SetPointsArray(const PointArray& value) + { + CopyFrom(points, value); + } + + Color GuiPolygonElement::GetBorderColor() + { + return borderColor; + } + + void GuiPolygonElement::SetBorderColor(Color value) + { + if(borderColor!=value) + { + borderColor=value; + InvokeOnElementStateChanged(); + } + } + + Color GuiPolygonElement::GetBackgroundColor() + { + return backgroundColor; + } + + void GuiPolygonElement::SetBackgroundColor(Color value) + { + if(backgroundColor!=value) + { + backgroundColor=value; + InvokeOnElementStateChanged(); + } + } + } + } +} + +/*********************************************************************** +.\GRAPHICSELEMENT\GUIGRAPHICSRESOURCEMANAGER.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace elements + { + using namespace collections; + +/*********************************************************************** +GuiGraphicsResourceManager +***********************************************************************/ + + GuiGraphicsResourceManager::GuiGraphicsResourceManager() + { + } + + GuiGraphicsResourceManager::~GuiGraphicsResourceManager() + { + } + + bool GuiGraphicsResourceManager::RegisterElementFactory(IGuiGraphicsElementFactory* factory) + { + if(elementFactories.Keys().Contains(factory->GetElementTypeName())) + { + return false; + } + else + { + elementFactories.Add(factory->GetElementTypeName(), factory); + return true; + } + } + + bool GuiGraphicsResourceManager::RegisterRendererFactory(const WString& elementTypeName, IGuiGraphicsRendererFactory* factory) + { + if(rendererFactories.Keys().Contains(elementTypeName)) + { + return false; + } + else + { + rendererFactories.Add(elementTypeName, factory); + return true; + } + } + + IGuiGraphicsElementFactory* GuiGraphicsResourceManager::GetElementFactory(const WString& elementTypeName) + { + vint index=elementFactories.Keys().IndexOf(elementTypeName); + return index==-1?0:elementFactories.Values().Get(index).Obj(); + } + + IGuiGraphicsRendererFactory* GuiGraphicsResourceManager::GetRendererFactory(const WString& elementTypeName) + { + vint index=rendererFactories.Keys().IndexOf(elementTypeName); + return index==-1?0:rendererFactories.Values().Get(index).Obj(); + } + + GuiGraphicsResourceManager* guiGraphicsResourceManager=0; + + GuiGraphicsResourceManager* GetGuiGraphicsResourceManager() + { + return guiGraphicsResourceManager; + } + + void SetGuiGraphicsResourceManager(GuiGraphicsResourceManager* resourceManager) + { + guiGraphicsResourceManager=resourceManager; + } + + bool RegisterFactories(IGuiGraphicsElementFactory* elementFactory, IGuiGraphicsRendererFactory* rendererFactory) + { + if(guiGraphicsResourceManager && elementFactory && rendererFactory) + { + if(guiGraphicsResourceManager->RegisterElementFactory(elementFactory)) + { + if(guiGraphicsResourceManager->RegisterRendererFactory(elementFactory->GetElementTypeName(), rendererFactory)) + { + return true; + } + } + } + return false; + } + } + } +} + +/*********************************************************************** +.\GRAPHICSELEMENT\GUIGRAPHICSTEXTELEMENT.CPP +***********************************************************************/ + +namespace vl +{ + using namespace collections; + + namespace presentation + { + namespace elements + { + namespace text + { + +/*********************************************************************** +text::TextLine +***********************************************************************/ + + TextLine::TextLine() + :text(0) + ,att(0) + ,availableOffsetCount(0) + ,bufferLength(0) + ,dataLength(0) + ,lexerFinalState(-1) + ,contextFinalState(-1) + { + } + + TextLine::~TextLine() + { + } + + vint TextLine::CalculateBufferLength(vint dataLength) + { + if(dataLength<1)dataLength=1; + vint bufferLength=dataLength-dataLength%BlockSize; + if(bufferLengthdataLength || inputCount<0) return false; + + vint newDataLength=dataLength-count+inputCount; + vint newBufferLength=CalculateBufferLength(newDataLength); + if(newBufferLength!=bufferLength) + { + wchar_t* newText=new wchar_t[newBufferLength]; + memcpy(newText, text, start*sizeof(wchar_t)); + memcpy(newText+start, input, inputCount*sizeof(wchar_t)); + memcpy(newText+start+inputCount, text+start+count, (dataLength-start-count)*sizeof(wchar_t)); + + CharAtt* newAtt=new CharAtt[newBufferLength]; + memcpy(newAtt, att, start*sizeof(CharAtt)); + memset(newAtt+start, 0, inputCount*sizeof(CharAtt)); + memcpy(newAtt+start+inputCount, att+start+count, (dataLength-start-count)*sizeof(CharAtt)); + + delete[] text; + delete[] att; + text=newText; + att=newAtt; + } + else + { + memmove(text+start+inputCount, text+start+count, (dataLength-start-count)*sizeof(wchar_t)); + memmove(att+start+inputCount, att+start+count, (dataLength-start-count)*sizeof(CharAtt)); + memcpy(text+start, input, inputCount*sizeof(wchar_t)); + memset(att+start, 0, inputCount*sizeof(CharAtt)); + } + dataLength=newDataLength; + bufferLength=newBufferLength; + if(availableOffsetCount>start) + { + availableOffsetCount=start; + } + + return true; + } + + TextLine TextLine::Split(vint index) + { + if(index<0 || index>dataLength) return TextLine(); + vint count=dataLength-index; + TextLine line; + line.Initialize(); + line.Modify(0, 0, text+index, count); + memcpy(line.att, att+index, count*sizeof(CharAtt)); + Modify(index, count, L"", 0); + return line; + } + + void TextLine::AppendAndFinalize(TextLine& line) + { + vint oldDataLength=dataLength; + Modify(oldDataLength, 0, line.text, line.dataLength); + memcpy(att+oldDataLength, line.att, line.dataLength*sizeof(CharAtt)); + line.Finalize(); + } + +/*********************************************************************** +text::CharMeasurer +***********************************************************************/ + + CharMeasurer::CharMeasurer(vint _rowHeight) + :oldRenderTarget(0) + ,rowHeight(_rowHeight) + { + memset(widths, 0, sizeof(widths)); + } + + CharMeasurer::~CharMeasurer() + { + } + + void CharMeasurer::SetRenderTarget(IGuiGraphicsRenderTarget* value) + { + if(oldRenderTarget!=value) + { + oldRenderTarget=value; + rowHeight=GetRowHeightInternal(oldRenderTarget); + memset(widths, 0, sizeof(widths)); + } + } + + vint CharMeasurer::MeasureWidth(wchar_t character) + { + vint w=widths[character]; + if(w==0) + { + widths[character]=w=MeasureWidthInternal(character, oldRenderTarget); + } + return w; + } + + vint CharMeasurer::GetRowHeight() + { + return rowHeight; + } + +/*********************************************************************** +text::TextLines +***********************************************************************/ + + TextLines::TextLines(GuiColorizedTextElement* _ownerElement) + :ownerElement(_ownerElement) + ,charMeasurer(0) + ,renderTarget(0) + ,tabWidth(1) + ,tabSpaceCount(4) + ,passwordChar(L'\0') + { + TextLine line; + line.Initialize(); + lines.Add(line); + } + + TextLines::~TextLines() + { + RemoveLines(0, lines.Count()); + } + + //-------------------------------------------------------- + + vint TextLines::GetCount() + { + return lines.Count(); + } + + TextLine& TextLines::GetLine(vint row) + { + return lines[row]; + } + + CharMeasurer* TextLines::GetCharMeasurer() + { + return charMeasurer; + } + + void TextLines::SetCharMeasurer(CharMeasurer* value) + { + charMeasurer=value; + if(charMeasurer) charMeasurer->SetRenderTarget(renderTarget); + ClearMeasurement(); + } + + IGuiGraphicsRenderTarget* TextLines::GetRenderTarget() + { + return renderTarget; + } + + void TextLines::SetRenderTarget(IGuiGraphicsRenderTarget* value) + { + renderTarget=value; + if(charMeasurer) charMeasurer->SetRenderTarget(renderTarget); + ClearMeasurement(); + } + + WString TextLines::GetText(TextPos start, TextPos end) + { + if(!IsAvailable(start) || !IsAvailable(end) || start>end) return L""; + + if(start.row==end.row) + { + return WString(lines[start.row].text+start.column, end.column-start.column); + } + + vint count=0; + for(vint i=start.row+1;i buffer; + buffer.Resize(count+(end.row-start.row)*2); + wchar_t* writing=&buffer[0]; + + for(vint i=start.row;i<=end.row;i++) + { + wchar_t* text=lines[i].text; + vint chars=0; + if(i==start.row) + { + text+=start.column; + chars=lines[i].dataLength-start.column; + } + else if(i==end.row) + { + chars=end.column; + } + else + { + chars=lines[i].dataLength; + } + + if(i!=start.row) + { + *writing++=L'\r'; + *writing++=L'\n'; + } + memcpy(writing, text, chars*sizeof(wchar_t)); + writing+=chars; + } + return WString(&buffer[0], buffer.Count()); + } + + WString TextLines::GetText() + { + return GetText(TextPos(0, 0), TextPos(lines.Count()-1, lines[lines.Count()-1].dataLength)); + } + + void TextLines::SetText(const WString& value) + { + Modify(TextPos(0, 0), TextPos(lines.Count()-1, lines[lines.Count()-1].dataLength), value); + } + + //-------------------------------------------------------- + + bool TextLines::RemoveLines(vint start, vint count) + { + if(start<0 || count<0 || start+count>lines.Count()) return false; + for(vint i=start+count-1;i>=start;i--) + { + lines[i].Finalize(); + } + lines.RemoveRange(start, count); + return true; + } + + bool TextLines::IsAvailable(TextPos pos) + { + return 0<=pos.row && pos.row=lines.Count()) + { + return TextPos(lines.Count()-1, lines[lines.Count()-1].dataLength); + } + else + { + TextLine& line=lines[pos.row]; + if(pos.column<0) + { + return TextPos(pos.row, 0); + } + else if(pos.column>line.dataLength) + { + return TextPos(pos.row, line.dataLength); + } + else + { + return pos; + } + } + } + + TextPos TextLines::Modify(TextPos start, TextPos end, const wchar_t** inputs, vint* inputCounts, vint rows) + { + if(!IsAvailable(start) || !IsAvailable(end) || start>end) return TextPos(-1, -1); + if (ownerElement) + { + ownerElement->InvokeOnElementStateChanged(); + } + + if(rows==1) + { + if(start.row==end.row) + { + lines[start.row].Modify(start.column, end.column-start.column, inputs[0], inputCounts[0]); + } + else + { + if(end.row-start.row>1) + { + RemoveLines(start.row+1, end.row-start.row-1); + } + vint modifyCount=lines[start.row].dataLength-start.column+end.column; + lines[start.row].AppendAndFinalize(lines[start.row+1]); + lines.RemoveAt(start.row+1); + lines[start.row].Modify(start.column, modifyCount, inputs[0], inputCounts[0]); + } + return TextPos(start.row, start.column+inputCounts[0]); + } + + if(start.row==end.row) + { + TextLine newLine=lines[start.row].Split(end.column); + lines.Insert(start.row+1, newLine); + end=TextPos(start.row+1, 0); + } + + vint oldMiddleLines=end.row-start.row-1; + vint newMiddleLines=rows-2; + if(oldMiddleLinesnewMiddleLines) + { + RemoveLines(start.row+newMiddleLines+1, oldMiddleLines-newMiddleLines); + } + end.row+=newMiddleLines-oldMiddleLines; + + lines[start.row].Modify(start.column, lines[start.row].dataLength-start.column, inputs[0], inputCounts[0]); + lines[end.row].Modify(0, end.column, inputs[rows-1], inputCounts[rows-1]); + for(vint i=1;i inputs; + List inputCounts; + const wchar_t* previous=input; + const wchar_t* current=input; + + while(true) + { + if(current==input+inputCount) + { + inputs.Add(previous); + inputCounts.Add(current-previous); + break; + } + else if(*current==L'\r' || *current==L'\n') + { + inputs.Add(previous); + inputCounts.Add(current-previous); + previous=current+(current[1]==L'\n'?2:1); + current=previous; + } + else + { + current++; + } + } + + return Modify(start, end, &inputs[0], &inputCounts[0], inputs.Count()); + } + + TextPos TextLines::Modify(TextPos start, TextPos end, const wchar_t* input) + { + return Modify(start, end, input, wcslen(input)); + } + + TextPos TextLines::Modify(TextPos start, TextPos end, const WString& input) + { + return Modify(start, end, input.Buffer(), input.Length()); + } + + void TextLines::Clear() + { + RemoveLines(0, lines.Count()); + TextLine line; + line.Initialize(); + lines.Add(line); + if (ownerElement) + { + ownerElement->InvokeOnElementStateChanged(); + } + } + + //-------------------------------------------------------- + + void TextLines::ClearMeasurement() + { + for(vint i=0;iMeasureWidth(L' '); + } + if(tabWidth==0) + { + tabWidth=1; + } + if (ownerElement) + { + ownerElement->InvokeOnElementStateChanged(); + } + } + + vint TextLines::GetTabSpaceCount() + { + return tabSpaceCount; + } + + void TextLines::SetTabSpaceCount(vint value) + { + if(value<1) value=1; + if(tabSpaceCount!=value) + { + tabSpaceCount=value; + ClearMeasurement(); + } + } + + void TextLines::MeasureRow(vint row) + { + TextLine& line=lines[row]; + vint offset=0; + if(line.availableOffsetCount) + { + offset=line.att[line.availableOffsetCount-1].rightOffset; + } + for(vint i=line.availableOffsetCount;iMeasureWidth(passwordChar); + } + else if(c==L'\t') + { + width=tabWidth-offset%tabWidth; + } + else + { + width=charMeasurer->MeasureWidth(line.text[i]); + } + offset+=width; + att.rightOffset=(int)offset; + } + line.availableOffsetCount=line.dataLength; + } + + vint TextLines::GetRowWidth(vint row) + { + if(row<0 || row>=lines.Count()) return -1; + TextLine& line=lines[row]; + if(line.dataLength==0) + { + return 0; + } + else + { + MeasureRow(row); + return line.att[line.dataLength-1].rightOffset; + } + } + + vint TextLines::GetRowHeight() + { + return charMeasurer->GetRowHeight(); + } + + vint TextLines::GetMaxWidth() + { + vint width=0; + for(vint i=0;iGetRowHeight(); + } + + TextPos TextLines::GetTextPosFromPoint(Point point) + { + vint h=charMeasurer->GetRowHeight(); + if(point.y<0) + { + point.y=0; + } + else if(point.y>=h*lines.Count()) + { + point.y=h*lines.Count()-1; + } + + vint row=point.y/h; + if(point.x<0) + { + return TextPos(row, 0); + } + else if(point.x>=GetRowWidth(row)) + { + return TextPos(row, lines[row].dataLength); + } + TextLine& line=lines[row]; + + vint i1=0, i2=line.dataLength; + vint p1=0, p2=line.att[line.dataLength-1].rightOffset; + while(i2-i1>1) + { + vint i=(i1+i2)/2; + vint p=i==0?0:line.att[i-1].rightOffset; + if(point.xGetRowHeight(); + if(pos.column==0) + { + return Point(0, y); + } + else + { + MeasureRow(pos.row); + TextLine& line=lines[pos.row]; + return Point(line.att[pos.column-1].rightOffset, y); + } + } + else + { + return Point(-1, -1); + } + } + + Rect TextLines::GetRectFromTextPos(TextPos pos) + { + Point point=GetPointFromTextPos(pos); + if(point==Point(-1, -1)) + { + return Rect(-1, -1, -1, -1); + } + else + { + vint h=charMeasurer->GetRowHeight(); + TextLine& line=lines[pos.row]; + if(pos.column==line.dataLength) + { + return Rect(point, Size(h/2, h)); + } + else + { + return Rect(point, Size(line.att[pos.column].rightOffset-point.x, h)); + } + } + } + + //-------------------------------------------------------- + + wchar_t TextLines::GetPasswordChar() + { + return passwordChar; + } + + void TextLines::SetPasswordChar(wchar_t value) + { + passwordChar=value; + ClearMeasurement(); + } + } + + using namespace text; + +/*********************************************************************** +GuiColorizedTextElement +***********************************************************************/ + + GuiColorizedTextElement::GuiColorizedTextElement() + :callback(0) + ,isVisuallyEnabled(true) + ,isFocused(false) + ,caretVisible(false) + ,lines(this) + { + } + + text::TextLines& GuiColorizedTextElement::GetLines() + { + return lines; + } + + GuiColorizedTextElement::ICallback* GuiColorizedTextElement::GetCallback() + { + return callback; + } + + void GuiColorizedTextElement::SetCallback(ICallback* value) + { + callback=value; + if(!callback) + { + lines.SetCharMeasurer(0); + } + } + + const GuiColorizedTextElement::ColorArray& GuiColorizedTextElement::GetColors() + { + return colors; + } + + void GuiColorizedTextElement::SetColors(const ColorArray& value) + { + CopyFrom(colors, value); + if(callback) callback->ColorChanged(); + InvokeOnElementStateChanged(); + } + + void GuiColorizedTextElement::ResetTextColorIndex(vint index) + { + vint lineCount = lines.GetCount(); + for (vint i = 0; i < lineCount; i++) + { + auto& line = lines.GetLine(i); + line.lexerFinalState = -1; + line.contextFinalState = -1; + for (vint j = 0; j < line.dataLength; j++) + { + line.att[j].colorIndex = (vuint32_t)index; + } + } + } + + const FontProperties& GuiColorizedTextElement::GetFont() + { + return font; + } + + void GuiColorizedTextElement::SetFont(const FontProperties& value) + { + if(font!=value) + { + font=value; + if(callback) + { + callback->FontChanged(); + } + InvokeOnElementStateChanged(); + } + } + + wchar_t GuiColorizedTextElement::GetPasswordChar() + { + return lines.GetPasswordChar(); + } + + void GuiColorizedTextElement::SetPasswordChar(wchar_t value) + { + if(lines.GetPasswordChar()!=value) + { + lines.SetPasswordChar(value); + InvokeOnElementStateChanged(); + } + } + + Point GuiColorizedTextElement::GetViewPosition() + { + return viewPosition; + } + + void GuiColorizedTextElement::SetViewPosition(Point value) + { + if(viewPosition!=value) + { + viewPosition=value; + InvokeOnElementStateChanged(); + } + } + + bool GuiColorizedTextElement::GetVisuallyEnabled() + { + return isVisuallyEnabled; + } + + void GuiColorizedTextElement::SetVisuallyEnabled(bool value) + { + if(isVisuallyEnabled!=value) + { + isVisuallyEnabled=value; + InvokeOnElementStateChanged(); + } + } + + bool GuiColorizedTextElement::GetFocused() + { + return isFocused; + } + + void GuiColorizedTextElement::SetFocused(bool value) + { + if(isFocused!=value) + { + isFocused=value; + InvokeOnElementStateChanged(); + } + } + + TextPos GuiColorizedTextElement::GetCaretBegin() + { + return caretBegin; + } + + void GuiColorizedTextElement::SetCaretBegin(TextPos value) + { + caretBegin=value; + InvokeOnElementStateChanged(); + } + + TextPos GuiColorizedTextElement::GetCaretEnd() + { + return caretEnd; + } + + void GuiColorizedTextElement::SetCaretEnd(TextPos value) + { + caretEnd=value; + InvokeOnElementStateChanged(); + } + + bool GuiColorizedTextElement::GetCaretVisible() + { + return caretVisible; + } + + void GuiColorizedTextElement::SetCaretVisible(bool value) + { + caretVisible=value; + InvokeOnElementStateChanged(); + } + + Color GuiColorizedTextElement::GetCaretColor() + { + return caretColor; + } + + void GuiColorizedTextElement::SetCaretColor(Color value) + { + if(caretColor!=value) + { + caretColor=value; + InvokeOnElementStateChanged(); + } + } + } + } +} + +/*********************************************************************** +.\NATIVEWINDOW\GUINATIVEWINDOW.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + +/*********************************************************************** +INativeWindowListener +***********************************************************************/ + + INativeWindowListener::HitTestResult INativeWindowListener::HitTest(Point location) + { + return INativeWindowListener::NoDecision; + } + + void INativeWindowListener::Moving(Rect& bounds, bool fixSizeOnly) + { + } + + void INativeWindowListener::Moved() + { + } + + void INativeWindowListener::Enabled() + { + } + + void INativeWindowListener::Disabled() + { + } + + void INativeWindowListener::GotFocus() + { + } + + void INativeWindowListener::LostFocus() + { + } + + void INativeWindowListener::Activated() + { + } + + void INativeWindowListener::Deactivated() + { + } + + void INativeWindowListener::Opened() + { + } + + void INativeWindowListener::Closing(bool& cancel) + { + } + + void INativeWindowListener::Closed() + { + } + + void INativeWindowListener::Paint() + { + } + + void INativeWindowListener::Destroying() + { + } + + void INativeWindowListener::Destroyed() + { + } + + void INativeWindowListener::LeftButtonDown(const NativeWindowMouseInfo& info) + { + } + + void INativeWindowListener::LeftButtonUp(const NativeWindowMouseInfo& info) + { + } + + void INativeWindowListener::LeftButtonDoubleClick(const NativeWindowMouseInfo& info) + { + } + + void INativeWindowListener::RightButtonDown(const NativeWindowMouseInfo& info) + { + } + + void INativeWindowListener::RightButtonUp(const NativeWindowMouseInfo& info) + { + } + + void INativeWindowListener::RightButtonDoubleClick(const NativeWindowMouseInfo& info) + { + } + + void INativeWindowListener::MiddleButtonDown(const NativeWindowMouseInfo& info) + { + } + + void INativeWindowListener::MiddleButtonUp(const NativeWindowMouseInfo& info) + { + } + + void INativeWindowListener::MiddleButtonDoubleClick(const NativeWindowMouseInfo& info) + { + } + + void INativeWindowListener::HorizontalWheel(const NativeWindowMouseInfo& info) + { + } + + void INativeWindowListener::VerticalWheel(const NativeWindowMouseInfo& info) + { + } + + void INativeWindowListener::MouseMoving(const NativeWindowMouseInfo& info) + { + } + + void INativeWindowListener::MouseEntered() + { + } + + void INativeWindowListener::MouseLeaved() + { + } + + void INativeWindowListener::KeyDown(const NativeWindowKeyInfo& info) + { + } + + void INativeWindowListener::KeyUp(const NativeWindowKeyInfo& info) + { + } + + void INativeWindowListener::SysKeyDown(const NativeWindowKeyInfo& info) + { + } + + void INativeWindowListener::SysKeyUp(const NativeWindowKeyInfo& info) + { + } + + void INativeWindowListener::Char(const NativeWindowCharInfo& info) + { + } + +/*********************************************************************** +INativeControllerListener +***********************************************************************/ + + void INativeControllerListener::LeftButtonDown(Point position) + { + } + + void INativeControllerListener::LeftButtonUp(Point position) + { + } + + void INativeControllerListener::RightButtonDown(Point position) + { + } + + void INativeControllerListener::RightButtonUp(Point position) + { + } + + void INativeControllerListener::MouseMoving(Point position) + { + } + + void INativeControllerListener::GlobalTimer() + { + } + + void INativeControllerListener::ClipboardUpdated() + { + } + + void INativeControllerListener::NativeWindowCreated(INativeWindow* window) + { + } + + void INativeControllerListener::NativeWindowDestroying(INativeWindow* window) + { + } + +/*********************************************************************** +Native Window Provider +***********************************************************************/ + + INativeController* currentController=0; + + INativeController* GetCurrentController() + { + return currentController; + } + + void SetCurrentController(INativeController* controller) + { + currentController=controller; + } + } +} + +/*********************************************************************** +.\RESOURCES\GUIDOCUMENT.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + using namespace collections; + using namespace parsing::tabling; + using namespace parsing::xml; + using namespace regex; + +/*********************************************************************** +DocumentFontSize +***********************************************************************/ + + DocumentFontSize DocumentFontSize::Parse(const WString& value) + { + if (value.Length() > 0 && value[value.Length() - 1] == L'x') + { + return DocumentFontSize(wtof(value.Left(value.Length() - 1)), true); + } + else + { + return DocumentFontSize(wtof(value), false); + } + } + + WString DocumentFontSize::ToString()const + { + return ftow(size) + (relative ? L"x" : L""); + } + +/*********************************************************************** +DocumentImageRun +***********************************************************************/ + + const wchar_t* DocumentImageRun::RepresentationText=L"[Image]"; + const wchar_t* DocumentEmbeddedObjectRun::RepresentationText=L"[EmbeddedObject]"; + +/*********************************************************************** +ExtractTextVisitor +***********************************************************************/ + + namespace document_operation_visitors + { + class ExtractTextVisitor : public Object, public DocumentRun::IVisitor + { + public: + stream::TextWriter& writer; + bool skipNonTextContent; + + ExtractTextVisitor(stream::TextWriter& _writer, bool _skipNonTextContent) + :writer(_writer) + ,skipNonTextContent(_skipNonTextContent) + { + } + + void VisitContainer(DocumentContainerRun* run) + { + FOREACH(Ptr, subRun, run->runs) + { + subRun->Accept(this); + } + } + + void VisitContent(DocumentContentRun* run) + { + writer.WriteString(run->GetRepresentationText()); + } + + void Visit(DocumentTextRun* run)override + { + VisitContent(run); + } + + void Visit(DocumentStylePropertiesRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentStyleApplicationRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentHyperlinkRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentImageRun* run)override + { + if(!skipNonTextContent) + { + VisitContent(run); + } + } + + void Visit(DocumentEmbeddedObjectRun* run)override + { + if(!skipNonTextContent) + { + VisitContent(run); + } + } + + void Visit(DocumentParagraphRun* run)override + { + VisitContainer(run); + } + }; + } + using namespace document_operation_visitors; + +/*********************************************************************** +DocumentParagraphRun +***********************************************************************/ + + WString DocumentParagraphRun::GetText(bool skipNonTextContent) + { + stream::MemoryStream memoryStream; + { + stream::StreamWriter writer(memoryStream); + GetText(writer, skipNonTextContent); + } + + memoryStream.SeekFromBegin(0); + stream::StreamReader reader(memoryStream); + return reader.ReadToEnd(); + } + + void DocumentParagraphRun::GetText(stream::TextWriter& writer, bool skipNonTextContent) + { + ExtractTextVisitor visitor(writer, skipNonTextContent); + Accept(&visitor); + } + +/*********************************************************************** +DocumentModel +***********************************************************************/ + + const wchar_t* DocumentModel::DefaultStyleName = L"#Default"; + const wchar_t* DocumentModel::SelectionStyleName = L"#Selection"; + const wchar_t* DocumentModel::ContextStyleName = L"#Context"; + const wchar_t* DocumentModel::NormalLinkStyleName = L"#NormalLink"; + const wchar_t* DocumentModel::ActiveLinkStyleName = L"#ActiveLink"; + + DocumentModel::DocumentModel() + { + { + FontProperties font=GetCurrentController()->ResourceService()->GetDefaultFont(); + Ptr sp=new DocumentStyleProperties; + sp->face=font.fontFamily; + sp->size=DocumentFontSize((double)font.size, false); + sp->color=Color(); + sp->backgroundColor=Color(0, 0, 0, 0); + sp->bold=font.bold; + sp->italic=font.italic; + sp->underline=font.underline; + sp->strikeline=font.strikeline; + sp->antialias=font.antialias; + sp->verticalAntialias=font.verticalAntialias; + + Ptr style=new DocumentStyle; + style->styles=sp; + styles.Add(L"#Default", style); + } + { + Ptr sp=new DocumentStyleProperties; + sp->color=Color(255, 255, 255); + sp->backgroundColor=Color(51, 153, 255); + + Ptr style=new DocumentStyle; + style->styles=sp; + styles.Add(L"#Selection", style); + } + { + Ptr sp=new DocumentStyleProperties; + + Ptr style=new DocumentStyle; + style->styles=sp; + styles.Add(L"#Context", style); + } + { + Ptr sp=new DocumentStyleProperties; + sp->color=Color(0, 0, 255); + sp->underline=true; + + Ptr style=new DocumentStyle; + style->parentStyleName=L"#Context"; + style->styles=sp; + styles.Add(L"#NormalLink", style); + } + { + Ptr sp=new DocumentStyleProperties; + sp->color=Color(255, 128, 0); + sp->underline=true; + + Ptr style=new DocumentStyle; + style->parentStyleName=L"#Context"; + style->styles=sp; + styles.Add(L"#ActiveLink", style); + } + } + + void DocumentModel::MergeStyle(Ptr style, Ptr parent) + { + if(!style->face && parent->face) style->face =parent->face; + if(!style->size && parent->size) style->size =parent->size; + if(!style->color && parent->color) style->color =parent->color; + if(!style->backgroundColor && parent->backgroundColor) style->backgroundColor =parent->backgroundColor; + if(!style->bold && parent->bold) style->bold =parent->bold; + if(!style->italic && parent->italic) style->italic =parent->italic; + if(!style->underline && parent->underline) style->underline =parent->underline; + if(!style->strikeline && parent->strikeline) style->strikeline =parent->strikeline; + if(!style->antialias && parent->antialias) style->antialias =parent->antialias; + if(!style->verticalAntialias && parent->verticalAntialias) style->verticalAntialias =parent->verticalAntialias; + } + + void DocumentModel::MergeBaselineStyle(Ptr style, const WString& styleName) + { + auto indexDst = styles.Keys().IndexOf(styleName); + Ptr sp = new DocumentStyleProperties; + MergeStyle(sp, style); + if (indexDst != -1) + { + MergeStyle(sp, styles.Values()[indexDst]->styles); + } + + if (indexDst == -1) + { + auto style = new DocumentStyle; + style->styles = sp; + styles.Add(styleName, style); + } + else + { + styles.Values()[indexDst]->styles = sp; + } + + FOREACH(Ptr, style, styles.Values()) + { + style->resolvedStyles = nullptr; + } + } + + void DocumentModel::MergeBaselineStyle(Ptr baselineDocument, const WString& styleName) + { + auto indexSrc = baselineDocument->styles.Keys().IndexOf(styleName + L"-Override"); + if (indexSrc == -1) + { + return; + } + + auto csp = baselineDocument->styles.Values()[indexSrc]->styles; + MergeBaselineStyle(csp, styleName); + } + + void DocumentModel::MergeBaselineStyles(Ptr baselineDocument) + { + MergeBaselineStyle(baselineDocument, DefaultStyleName); + MergeBaselineStyle(baselineDocument, SelectionStyleName); + MergeBaselineStyle(baselineDocument, ContextStyleName); + MergeBaselineStyle(baselineDocument, NormalLinkStyleName); + MergeBaselineStyle(baselineDocument, ActiveLinkStyleName); + } + + void DocumentModel::MergeDefaultFont(const FontProperties& defaultFont) + { + Ptr style = new DocumentStyleProperties; + + style->face =defaultFont.fontFamily; + style->size =DocumentFontSize((double)defaultFont.size, false); + style->bold =defaultFont.bold; + style->italic =defaultFont.italic; + style->underline =defaultFont.underline; + style->strikeline =defaultFont.strikeline; + style->antialias =defaultFont.antialias; + style->verticalAntialias =defaultFont.verticalAntialias; + + MergeBaselineStyle(style, DefaultStyleName); + } + + DocumentModel::ResolvedStyle DocumentModel::GetStyle(Ptr sp, const ResolvedStyle& context) + { + FontProperties font; + font.fontFamily =sp->face ?sp->face.Value() :context.style.fontFamily; + font.bold =sp->bold ?sp->bold.Value() :context.style.bold; + font.italic =sp->italic ?sp->italic.Value() :context.style.italic; + font.underline =sp->underline ?sp->underline.Value() :context.style.underline; + font.strikeline =sp->strikeline ?sp->strikeline.Value() :context.style.strikeline; + font.antialias =sp->antialias ?sp->antialias.Value() :context.style.antialias; + font.verticalAntialias =sp->verticalAntialias ?sp->verticalAntialias.Value() :context.style.verticalAntialias; + Color color =sp->color ?sp->color.Value() :context.color; + Color backgroundColor =sp->backgroundColor ?sp->backgroundColor.Value() :context.backgroundColor; + + if (sp->size) + { + font.size = (vint)(sp->size.Value().relative ? context.style.size * sp->size.Value().size : sp->size.Value().size); + } + else + { + font.size = context.style.size; + } + return ResolvedStyle(font, color, backgroundColor); + } + + DocumentModel::ResolvedStyle DocumentModel::GetStyle(const WString& styleName, const ResolvedStyle& context) + { + Ptr selectedStyle; + { + vint index=styles.Keys().IndexOf(styleName); + if(index!=-1) + { + selectedStyle=styles.Values()[index]; + } + else + { + selectedStyle=styles[L"#Default"]; + } + } + + if(!selectedStyle->resolvedStyles) + { + Ptr sp = new DocumentStyleProperties; + selectedStyle->resolvedStyles = sp; + + Ptr currentStyle; + WString currentName = styleName; + while(true) + { + vint index = styles.Keys().IndexOf(currentName); + if (index == -1) break; + currentStyle = styles.Values().Get(index); + currentName = currentStyle->parentStyleName; + MergeStyle(sp, currentStyle->styles); + } + } + + Ptr sp=selectedStyle->resolvedStyles; + return GetStyle(sp, context); + } + + WString DocumentModel::GetText(bool skipNonTextContent) + { + stream::MemoryStream memoryStream; + { + stream::StreamWriter writer(memoryStream); + GetText(writer, skipNonTextContent); + } + + memoryStream.SeekFromBegin(0); + stream::StreamReader reader(memoryStream); + return reader.ReadToEnd(); + } + + void DocumentModel::GetText(stream::TextWriter& writer, bool skipNonTextContent) + { + for(vint i=0;i paragraph=paragraphs[i]; + paragraph->GetText(writer, skipNonTextContent); + if(i parent; + + public: + SerializeRunVisitor(DocumentModel* _model, Ptr _parent) + :model(_model) + , parent(_parent) + { + } + + void VisitContainer(Ptr replacedParent, DocumentContainerRun* run) + { + if (replacedParent) + { + parent->subNodes.Add(replacedParent); + Ptr oldParent = parent; + parent = replacedParent; + FOREACH(Ptr, subRun, run->runs) + { + subRun->Accept(this); + } + parent = oldParent; + } + else + { + FOREACH(Ptr, subRun, run->runs) + { + subRun->Accept(this); + } + } + } + + void Visit(DocumentTextRun* run)override + { + if (run->text != L"") + { + auto writer = XmlElementWriter(parent).Element(L"nop"); + auto begin = run->text.Buffer(); + auto reading = begin; + auto last = reading; + while (true) + { + const wchar_t* tag = nullptr; + auto c = *reading; + switch (c) + { + case L'\n': + tag = L"br"; + break; + case L' ': + tag = L"sp"; + break; + case L'\t': + tag = L"tab"; + break; + } + + if (tag || c == 0) + { + if (reading > last) + { + auto end = reading[-1] == L'\r' ? reading - 1 : reading; + if (end > last) + { + writer.Text(run->text.Sub(last - begin, end - last)); + } + last = reading; + } + } + + if (tag) + { + writer.Element(tag); + } + else if (c == 0) + { + break; + } + reading++; + } + } + } + + void Visit(DocumentStylePropertiesRun* run)override + { + Ptr sp = run->style; + Ptr oldParent = parent; + if (sp->face || sp->size || sp->color) + { + Ptr element = new XmlElement; + element->name.value = L"font"; + parent->subNodes.Add(element); + + XmlElementWriter writer(element); + if (sp->face) + { + writer.Attribute(L"face", sp->face.Value()); + } + if (sp->size) + { + writer.Attribute(L"size", sp->size.Value().ToString()); + } + if (sp->color) + { + writer.Attribute(L"color", sp->color.Value().ToString()); + } + if (sp->backgroundColor) + { + writer.Attribute(L"bkcolor", sp->backgroundColor.Value().ToString()); + } + parent = element; + } + if (sp->bold) + { + Ptr element = new XmlElement; + element->name.value = sp->bold.Value() ? L"b" : L"b-"; + parent->subNodes.Add(element); + parent = element; + } + if (sp->italic) + { + Ptr element = new XmlElement; + element->name.value = sp->italic.Value() ? L"i" : L"i-"; + parent->subNodes.Add(element); + parent = element; + } + if (sp->underline) + { + Ptr element = new XmlElement; + element->name.value = sp->underline.Value() ? L"u" : L"u-"; + parent->subNodes.Add(element); + parent = element; + } + if (sp->strikeline) + { + Ptr element = new XmlElement; + element->name.value = sp->strikeline.Value() ? L"s" : L"s-"; + parent->subNodes.Add(element); + parent = element; + } + if (sp->antialias || sp->verticalAntialias) + { + bool ha = sp->antialias ? sp->antialias.Value() : true; + bool va = sp->verticalAntialias ? sp->verticalAntialias.Value() : false; + if (!ha) + { + Ptr element = new XmlElement; + element->name.value = L"ha"; + parent->subNodes.Add(element); + parent = element; + } + else if (!va) + { + Ptr element = new XmlElement; + element->name.value = L"va"; + parent->subNodes.Add(element); + parent = element; + } + else + { + Ptr element = new XmlElement; + element->name.value = L"na"; + parent->subNodes.Add(element); + parent = element; + } + } + VisitContainer(0, run); + parent = oldParent; + } + + void Visit(DocumentStyleApplicationRun* run)override + { + Ptr element = new XmlElement; + element->name.value = L"div"; + XmlElementWriter(element).Attribute(L"style", run->styleName); + VisitContainer(element, run); + } + + void Visit(DocumentHyperlinkRun* run)override + { + Ptr element = new XmlElement; + element->name.value = L"a"; + XmlElementWriter writer(element); + if (run->normalStyleName != L"#NormalLink") + { + writer.Attribute(L"normal", run->normalStyleName); + } + if (run->activeStyleName != L"#ActiveLink") + { + writer.Attribute(L"active", run->activeStyleName); + } + if (run->reference != L"") + { + writer.Attribute(L"href", run->reference); + } + VisitContainer(element, run); + } + + void Visit(DocumentImageRun* run)override + { + XmlElementWriter writer(parent); + writer + .Element(L"img") + .Attribute(L"width", itow(run->size.x)) + .Attribute(L"height", itow(run->size.y)) + .Attribute(L"baseline", itow(run->baseline)) + .Attribute(L"frameIndex", itow(run->frameIndex)) + .Attribute(L"source", run->source) + ; + } + + void Visit(DocumentEmbeddedObjectRun* run)override + { + XmlElementWriter writer(parent); + writer + .Element(L"object") + .Attribute(L"name", run->name) + ; + } + + void Visit(DocumentParagraphRun* run)override + { + Ptr element = new XmlElement; + element->name.value = L"p"; + + XmlElementWriter writer(element); + if (run->alignment) + { + switch (run->alignment.Value()) + { + case Alignment::Left: + writer.Attribute(L"align", L"Left"); + break; + case Alignment::Center: + writer.Attribute(L"align", L"Center"); + break; + case Alignment::Right: + writer.Attribute(L"align", L"Right"); + break; + } + } + VisitContainer(element, run); + } + }; + } + using namespace document_operation_visitors; + +/*********************************************************************** +DocumentModel +***********************************************************************/ + + Ptr DocumentModel::SaveToXml() + { + Ptr xml=new XmlDocument; + Ptr doc=new XmlElement; + doc->name.value=L"Doc"; + xml->rootElement=doc; + { + Ptr content=new XmlElement; + content->name.value=L"Content"; + doc->subNodes.Add(content); + + FOREACH(Ptr, p, paragraphs) + { + SerializeRunVisitor visitor(this, content); + p->Accept(&visitor); + } + } + { + Ptr stylesElement=new XmlElement; + stylesElement->name.value=L"Styles"; + doc->subNodes.Add(stylesElement); + + for(vint i=0;i0 && name[0] == L'#' && (name.Length() <= 9 || name.Right(9) != L"-Override")) continue; + + Ptr style=styles.Values().Get(i); + Ptr sp=style->styles; + Ptr styleElement=new XmlElement; + styleElement->name.value=L"Style"; + stylesElement->subNodes.Add(styleElement); + + XmlElementWriter(styleElement).Attribute(L"name", name); + if(style->parentStyleName!=L"") + { + XmlElementWriter(styleElement).Attribute(L"parent", style->parentStyleName); + } + + if(sp->face) XmlElementWriter(styleElement).Element(L"face").Text( sp->face.Value() ); + if(sp->size) XmlElementWriter(styleElement).Element(L"size").Text( sp->size.Value().ToString() ); + if(sp->color) XmlElementWriter(styleElement).Element(L"color").Text( sp->color.Value().ToString() ); + if(sp->backgroundColor) XmlElementWriter(styleElement).Element(L"bkcolor").Text( sp->backgroundColor.Value().ToString() ); + if(sp->bold) XmlElementWriter(styleElement).Element(L"b").Text( sp->bold.Value()?L"true":L"false" ); + if(sp->italic) XmlElementWriter(styleElement).Element(L"i").Text( sp->italic.Value()?L"true":L"false" ); + if(sp->underline) XmlElementWriter(styleElement).Element(L"u").Text( sp->underline.Value()?L"true":L"false" ); + if(sp->strikeline) XmlElementWriter(styleElement).Element(L"s").Text( sp->strikeline.Value()?L"true":L"false" ); + if(sp->antialias && sp->verticalAntialias) + { + bool h=sp->antialias; + bool v=sp->verticalAntialias; + if(!h) + { + XmlElementWriter(styleElement).Element(L"antialias").Text(L"no"); + } + else if(!v) + { + XmlElementWriter(styleElement).Element(L"antialias").Text(L"horizontal"); + } + else + { + XmlElementWriter(styleElement).Element(L"antialias").Text(L"vertical"); + } + } + } + } + return xml; + } + } +} + +/*********************************************************************** +.\CONTROLS\GUIBASICCONTROLS.CPP ***********************************************************************/ namespace vl @@ -1137,1968 +5871,7 @@ GuiCustomControl } /*********************************************************************** -CONTROLS\GUIBUTTONCONTROLS.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace controls - { - using namespace elements; - using namespace compositions; - using namespace collections; - using namespace reflection::description; - -/*********************************************************************** -GuiButton -***********************************************************************/ - - void GuiButton::OnParentLineChanged() - { - GuiControl::OnParentLineChanged(); - if(GetRelatedControlHost()==0) - { - mousePressing=false; - mouseHoving=false; - UpdateControlState(); - } - } - - void GuiButton::OnActiveAlt() - { - Clicked.Execute(GetNotifyEventArguments()); - } - - void GuiButton::UpdateControlState() - { - auto newControlState = ButtonState::Normal; - if (mousePressing) - { - if (mouseHoving) - { - newControlState = ButtonState::Pressed; - } - else - { - newControlState = ButtonState::Active; - } - } - else - { - if (mouseHoving) - { - newControlState = ButtonState::Active; - } - else - { - newControlState = ButtonState::Normal; - } - } - if (controlState != newControlState) - { - controlState = newControlState; - styleController->Transfer(controlState); - } - } - - void GuiButton::OnLeftButtonDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) - { - if(arguments.eventSource==boundsComposition) - { - mousePressing=true; - boundsComposition->GetRelatedGraphicsHost()->SetFocus(boundsComposition); - UpdateControlState(); - if(!clickOnMouseUp && arguments.eventSource->GetAssociatedControl()==this) - { - Clicked.Execute(GetNotifyEventArguments()); - } - } - } - - void GuiButton::OnLeftButtonUp(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) - { - if(arguments.eventSource==boundsComposition) - { - mousePressing=false; - UpdateControlState(); - } - if(GetVisuallyEnabled()) - { - if(mouseHoving && clickOnMouseUp) - { - auto eventSource = arguments.eventSource->GetAssociatedControl(); - while (eventSource && eventSource != this) - { - if (eventSource->GetFocusableComposition()) - { - return; - } - eventSource = eventSource->GetParent(); - } - Clicked.Execute(GetNotifyEventArguments()); - } - } - } - - void GuiButton::OnMouseEnter(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if(arguments.eventSource==boundsComposition) - { - mouseHoving=true; - UpdateControlState(); - } - } - - void GuiButton::OnMouseLeave(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if(arguments.eventSource==boundsComposition) - { - mouseHoving=false; - UpdateControlState(); - } - } - - GuiButton::GuiButton(IStyleController* _styleController) - :GuiControl(_styleController) - ,styleController(_styleController) - ,clickOnMouseUp(true) - ,mousePressing(false) - ,mouseHoving(false) - ,controlState(ButtonState::Normal) - { - Clicked.SetAssociatedComposition(boundsComposition); - styleController->Transfer(ButtonState::Normal); - SetFocusableComposition(boundsComposition); - - GetEventReceiver()->leftButtonDown.AttachMethod(this, &GuiButton::OnLeftButtonDown); - GetEventReceiver()->leftButtonUp.AttachMethod(this, &GuiButton::OnLeftButtonUp); - GetEventReceiver()->mouseEnter.AttachMethod(this, &GuiButton::OnMouseEnter); - GetEventReceiver()->mouseLeave.AttachMethod(this, &GuiButton::OnMouseLeave); - } - - GuiButton::~GuiButton() - { - } - - bool GuiButton::GetClickOnMouseUp() - { - return clickOnMouseUp; - } - - void GuiButton::SetClickOnMouseUp(bool value) - { - clickOnMouseUp=value; - } - -/*********************************************************************** -GuiSelectableButton::GroupController -***********************************************************************/ - - GuiSelectableButton::GroupController::GroupController() - { - } - - GuiSelectableButton::GroupController::~GroupController() - { - for(vint i=buttons.Count()-1;i>=0;i--) - { - buttons[i]->SetGroupController(0); - } - } - - void GuiSelectableButton::GroupController::Attach(GuiSelectableButton* button) - { - if(!buttons.Contains(button)) - { - buttons.Add(button); - } - } - - void GuiSelectableButton::GroupController::Detach(GuiSelectableButton* button) - { - buttons.Remove(button); - } - -/*********************************************************************** -GuiSelectableButton::MutexGroupController -***********************************************************************/ - - GuiSelectableButton::MutexGroupController::MutexGroupController() - :suppress(false) - { - } - - GuiSelectableButton::MutexGroupController::~MutexGroupController() - { - } - - void GuiSelectableButton::MutexGroupController::OnSelectedChanged(GuiSelectableButton* button) - { - if(!suppress) - { - suppress=true; - for(vint i=0;iSetSelected(buttons[i]==button); - } - suppress=false; - } - } - -/*********************************************************************** -GuiSelectableButton -***********************************************************************/ - - void GuiSelectableButton::OnClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if(autoSelection) - { - SetSelected(!GetSelected()); - } - } - - GuiSelectableButton::GuiSelectableButton(IStyleController* _styleController) - :GuiButton(_styleController) - ,styleController(_styleController) - ,groupController(0) - ,autoSelection(true) - ,isSelected(false) - { - GroupControllerChanged.SetAssociatedComposition(boundsComposition); - AutoSelectionChanged.SetAssociatedComposition(boundsComposition); - SelectedChanged.SetAssociatedComposition(boundsComposition); - - Clicked.AttachMethod(this, &GuiSelectableButton::OnClicked); - styleController->SetSelected(isSelected); - } - - GuiSelectableButton::~GuiSelectableButton() - { - if(groupController) - { - groupController->Detach(this); - } - } - - GuiSelectableButton::GroupController* GuiSelectableButton::GetGroupController() - { - return groupController; - } - - void GuiSelectableButton::SetGroupController(GroupController* value) - { - if(groupController) - { - groupController->Detach(this); - } - groupController=value; - if(groupController) - { - groupController->Attach(this); - } - GroupControllerChanged.Execute(GetNotifyEventArguments()); - } - - bool GuiSelectableButton::GetAutoSelection() - { - return autoSelection; - } - - void GuiSelectableButton::SetAutoSelection(bool value) - { - if(autoSelection!=value) - { - autoSelection=value; - AutoSelectionChanged.Execute(GetNotifyEventArguments()); - } - } - - bool GuiSelectableButton::GetSelected() - { - return isSelected; - } - - void GuiSelectableButton::SetSelected(bool value) - { - if(isSelected!=value) - { - isSelected=value; - styleController->SetSelected(isSelected); - if(groupController) - { - groupController->OnSelectedChanged(this); - } - SelectedChanged.Execute(GetNotifyEventArguments()); - } - } - } - } -} - -/*********************************************************************** -CONTROLS\GUICONTAINERCONTROLS.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - using namespace compositions; - - namespace controls - { - -/*********************************************************************** -GuiTabPage -***********************************************************************/ - - bool GuiTabPage::IsAltAvailable() - { - return false; - } - - void GuiTabPage::OnTextChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if (tab) - { - tab->styleController->SetTabText(tab->tabPages.IndexOf(this), GetText()); - } - } - - void GuiTabPage::OnAltChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if (tab) - { - tab->styleController->SetTabAlt(tab->tabPages.IndexOf(this), GetAlt()); - } - } - - GuiTabPage::GuiTabPage(IStyleController* _styleController) - :GuiCustomControl(_styleController) - { - TextChanged.AttachMethod(this, &GuiTabPage::OnTextChanged); - AltChanged.AttachMethod(this, &GuiTabPage::OnAltChanged); - } - - GuiTabPage::~GuiTabPage() - { - FinalizeAggregation(); - } - -/*********************************************************************** -GuiTabPageList -***********************************************************************/ - - bool GuiTabPageList::QueryInsert(vint index, GuiTabPage* const& value) - { - return !items.Contains(value) && value->tab == nullptr; - } - - void GuiTabPageList::AfterInsert(vint index, GuiTabPage* const& value) - { - tab->styleController->InsertTab(index); - tab->styleController->SetTabText(index, value->GetText()); - tab->styleController->SetTabAlt(index, value->GetAlt()); - - value->tab = tab; - value->SetVisible(false); - value->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); - tab->GetContainerComposition()->AddChild(value->GetBoundsComposition()); - - if (!tab->selectedPage) - { - tab->SetSelectedPage(value); - } - } - - void GuiTabPageList::BeforeRemove(vint index, GuiTabPage* const& value) - { - tab->styleController->RemoveTab(index); - tab->GetContainerComposition()->RemoveChild(value->GetBoundsComposition()); - value->tab = nullptr; - - if (items.Count() == 0) - { - tab->SetSelectedPage(nullptr); - } - else if (tab->selectedPage == value) - { - tab->SetSelectedPage(items[0]); - } - } - - GuiTabPageList::GuiTabPageList(GuiTab* _tab) - :tab(_tab) - { - } - - GuiTabPageList::~GuiTabPageList() - { - } - -/*********************************************************************** -GuiTab -***********************************************************************/ - - GuiTab::CommandExecutor::CommandExecutor(GuiTab* _tab) - :tab(_tab) - { - } - - GuiTab::CommandExecutor::~CommandExecutor() - { - } - - void GuiTab::CommandExecutor::ShowTab(vint index) - { - tab->SetSelectedPage(tab->GetPages().Get(index)); - } - - GuiTab::GuiTab(IStyleController* _styleController) - :GuiControl(_styleController) - , styleController(_styleController) - , tabPages(this) - { - commandExecutor = new CommandExecutor(this); - styleController->SetCommandExecutor(commandExecutor.Obj()); - } - - GuiTab::~GuiTab() - { - } - - GuiTabPageList& GuiTab::GetPages() - { - return tabPages; - } - - GuiTabPage* GuiTab::GetSelectedPage() - { - return selectedPage; - } - - bool GuiTab::SetSelectedPage(GuiTabPage* value) - { - if (!value) - { - if (tabPages.Count() == 0) - { - selectedPage = nullptr; - } - } - else if (value->tab == this) - { - if (selectedPage != value) - { - selectedPage = value; - for (vint i = 0; i < tabPages.Count(); i++) - { - bool selected = tabPages[i] == value; - tabPages[i]->SetVisible(selected); - if (selected) - { - styleController->SetSelectedTab(i); - } - } - SelectedPageChanged.Execute(GetNotifyEventArguments()); - } - } - return selectedPage == value; - } - -/*********************************************************************** -GuiScrollView::StyleController -***********************************************************************/ - - void GuiScrollView::StyleController::UpdateTable() - { - if(horizontalScroll->GetEnabled() || horizontalAlwaysVisible) - { - tableComposition->SetRowOption(1, GuiCellOption::AbsoluteOption(styleProvider->GetDefaultScrollSize())); - } - else - { - tableComposition->SetRowOption(1, GuiCellOption::AbsoluteOption(0)); - } - if(verticalScroll->GetEnabled() || verticalAlwaysVisible) - { - tableComposition->SetColumnOption(1, GuiCellOption::AbsoluteOption(styleProvider->GetDefaultScrollSize())); - } - else - { - tableComposition->SetColumnOption(1, GuiCellOption::AbsoluteOption(0)); - } - tableComposition->UpdateCellBounds(); - } - - GuiScrollView::StyleController::StyleController(IStyleProvider* _styleProvider) - :styleProvider(_styleProvider) - ,scrollView(0) - ,horizontalAlwaysVisible(true) - ,verticalAlwaysVisible(true) - { - horizontalScroll=new GuiScroll(styleProvider->CreateHorizontalScrollStyle()); - horizontalScroll->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); - horizontalScroll->SetEnabled(false); - verticalScroll=new GuiScroll(styleProvider->CreateVerticalScrollStyle()); - verticalScroll->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); - verticalScroll->SetEnabled(false); - - boundsComposition=new GuiBoundsComposition; - GuiGraphicsComposition* tableContainerComposition=styleProvider->InstallBackground(boundsComposition); - - tableComposition=new GuiTableComposition; - tableContainerComposition->AddChild(tableComposition); - tableComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - tableComposition->SetRowsAndColumns(2, 2); - tableComposition->SetRowOption(0, GuiCellOption::PercentageOption(1.0)); - tableComposition->SetRowOption(1, GuiCellOption::MinSizeOption()); - tableComposition->SetColumnOption(0, GuiCellOption::PercentageOption(1.0)); - tableComposition->SetColumnOption(1, GuiCellOption::MinSizeOption()); - UpdateTable(); - { - GuiCellComposition* cell=new GuiCellComposition; - tableComposition->AddChild(cell); - cell->SetSite(1, 0, 1, 1); - cell->AddChild(horizontalScroll->GetBoundsComposition()); - } - { - GuiCellComposition* cell=new GuiCellComposition; - tableComposition->AddChild(cell); - cell->SetSite(0, 1, 1, 1); - cell->AddChild(verticalScroll->GetBoundsComposition()); - } - - containerCellComposition=new GuiCellComposition; - tableComposition->AddChild(containerCellComposition); - containerCellComposition->SetSite(0, 0, 1, 1); - - containerComposition=new GuiBoundsComposition; - containerComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - containerCellComposition->AddChild(containerComposition); - - styleProvider->AssociateStyleController(this); - } - - GuiScrollView::StyleController::~StyleController() - { - } - - void GuiScrollView::StyleController::SetScrollView(GuiScrollView* _scrollView) - { - scrollView=_scrollView; - } - - void GuiScrollView::StyleController::AdjustView(Size fullSize) - { - Size viewSize=containerComposition->GetBounds().GetSize(); - if(fullSize.x<=viewSize.x) - { - horizontalScroll->SetEnabled(false); - horizontalScroll->SetPosition(0); - } - else - { - horizontalScroll->SetEnabled(true); - horizontalScroll->SetTotalSize(fullSize.x); - horizontalScroll->SetPageSize(viewSize.x); - } - if(fullSize.y<=viewSize.y) - { - verticalScroll->SetEnabled(false); - verticalScroll->SetPosition(0); - } - else - { - verticalScroll->SetEnabled(true); - verticalScroll->SetTotalSize(fullSize.y); - verticalScroll->SetPageSize(viewSize.y); - } - UpdateTable(); - } - - GuiScrollView::IStyleProvider* GuiScrollView::StyleController::GetStyleProvider() - { - return styleProvider.Obj(); - } - - GuiScroll* GuiScrollView::StyleController::GetHorizontalScroll() - { - return horizontalScroll; - } - - GuiScroll* GuiScrollView::StyleController::GetVerticalScroll() - { - return verticalScroll; - } - - compositions::GuiTableComposition* GuiScrollView::StyleController::GetInternalTableComposition() - { - return tableComposition; - } - - compositions::GuiBoundsComposition* GuiScrollView::StyleController::GetInternalContainerComposition() - { - return containerComposition; - } - - bool GuiScrollView::StyleController::GetHorizontalAlwaysVisible() - { - return horizontalAlwaysVisible; - } - - void GuiScrollView::StyleController::SetHorizontalAlwaysVisible(bool value) - { - if(horizontalAlwaysVisible!=value) - { - horizontalAlwaysVisible=value; - scrollView->CalculateView(); - } - } - - bool GuiScrollView::StyleController::GetVerticalAlwaysVisible() - { - return verticalAlwaysVisible; - } - - void GuiScrollView::StyleController::SetVerticalAlwaysVisible(bool value) - { - if(verticalAlwaysVisible!=value) - { - verticalAlwaysVisible=value; - scrollView->CalculateView(); - } - } - - compositions::GuiBoundsComposition* GuiScrollView::StyleController::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* GuiScrollView::StyleController::GetContainerComposition() - { - return containerComposition; - } - - void GuiScrollView::StyleController::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - styleProvider->SetFocusableComposition(value); - } - - void GuiScrollView::StyleController::SetText(const WString& value) - { - styleProvider->SetText(value); - } - - void GuiScrollView::StyleController::SetFont(const FontProperties& value) - { - styleProvider->SetFont(value); - } - - void GuiScrollView::StyleController::SetVisuallyEnabled(bool value) - { - styleProvider->SetVisuallyEnabled(value); - } - -/*********************************************************************** -GuiScrollView -***********************************************************************/ - - void GuiScrollView::OnContainerBoundsChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - CalculateView(); - } - - void GuiScrollView::OnHorizontalScroll(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if(!supressScrolling) - { - CallUpdateView(); - } - } - - void GuiScrollView::OnVerticalScroll(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if(!supressScrolling) - { - CallUpdateView(); - } - } - - void GuiScrollView::OnHorizontalWheel(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) - { - if(!supressScrolling) - { - auto scroll = styleController->GetHorizontalScroll(); - vint position = scroll->GetPosition(); - vint move = scroll->GetSmallMove(); - position -= move*arguments.wheel / 60; - scroll->SetPosition(position); - } - } - - void GuiScrollView::OnVerticalWheel(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) - { - if(!supressScrolling && GetVisuallyEnabled()) - { - auto scroll = styleController->GetVerticalScroll(); - vint position = scroll->GetPosition(); - vint move = scroll->GetSmallMove(); - position -= move*arguments.wheel / 60; - scroll->SetPosition(position); - } - } - - void GuiScrollView::CallUpdateView() - { - Rect viewBounds=GetViewBounds(); - UpdateView(viewBounds); - } - - void GuiScrollView::Initialize() - { - styleController=dynamic_cast(GetStyleController()); - styleController->SetScrollView(this); - - styleController->GetInternalContainerComposition()->BoundsChanged.AttachMethod(this, &GuiScrollView::OnContainerBoundsChanged); - styleController->GetHorizontalScroll()->PositionChanged.AttachMethod(this, &GuiScrollView::OnHorizontalScroll); - styleController->GetVerticalScroll()->PositionChanged.AttachMethod(this, &GuiScrollView::OnVerticalScroll); - styleController->GetBoundsComposition()->GetEventReceiver()->horizontalWheel.AttachMethod(this, &GuiScrollView::OnHorizontalWheel); - styleController->GetBoundsComposition()->GetEventReceiver()->verticalWheel.AttachMethod(this, &GuiScrollView::OnVerticalWheel); - } - - GuiScrollView::GuiScrollView(StyleController* _styleController) - :GuiControl(_styleController) - ,supressScrolling(false) - { - Initialize(); - } - - GuiScrollView::GuiScrollView(IStyleProvider* styleProvider) - :GuiControl(new StyleController(styleProvider)) - ,supressScrolling(false) - { - Initialize(); - } - - vint GuiScrollView::GetSmallMove() - { - return GetFont().size * 2; - } - - Size GuiScrollView::GetBigMove() - { - return GetViewSize(); - } - - GuiScrollView::~GuiScrollView() - { - } - - void GuiScrollView::SetFont(const FontProperties& value) - { - GuiControl::SetFont(value); - CalculateView(); - } - - void GuiScrollView::CalculateView() - { - if(!supressScrolling) - { - Size fullSize = QueryFullSize(); - while(true) - { - styleController->AdjustView(fullSize); - styleController->AdjustView(fullSize); - supressScrolling = true; - CallUpdateView(); - supressScrolling = false; - - Size newSize=QueryFullSize(); - if (fullSize == newSize) - { - vint smallMove = GetSmallMove(); - styleController->GetHorizontalScroll()->SetSmallMove(smallMove); - styleController->GetVerticalScroll()->SetSmallMove(smallMove); - Size bigMove = GetBigMove(); - styleController->GetHorizontalScroll()->SetBigMove(bigMove.x); - styleController->GetVerticalScroll()->SetBigMove(bigMove.y); - break; - } - else - { - fullSize=newSize; - } - } - } - } - - Size GuiScrollView::GetViewSize() - { - Size viewSize=styleController->GetInternalContainerComposition()->GetBounds().GetSize(); - return viewSize; - } - - Rect GuiScrollView::GetViewBounds() - { - Point viewPosition= - Point( - styleController->GetHorizontalScroll()->GetPosition(), - styleController->GetVerticalScroll()->GetPosition() - ); - Size viewSize=GetViewSize(); - return Rect(viewPosition, viewSize); - } - - GuiScroll* GuiScrollView::GetHorizontalScroll() - { - return styleController->GetHorizontalScroll(); - } - - GuiScroll* GuiScrollView::GetVerticalScroll() - { - return styleController->GetVerticalScroll(); - } - - bool GuiScrollView::GetHorizontalAlwaysVisible() - { - return styleController->GetHorizontalAlwaysVisible(); - } - - void GuiScrollView::SetHorizontalAlwaysVisible(bool value) - { - styleController->SetHorizontalAlwaysVisible(value); - } - - bool GuiScrollView::GetVerticalAlwaysVisible() - { - return styleController->GetVerticalAlwaysVisible(); - } - - void GuiScrollView::SetVerticalAlwaysVisible(bool value) - { - styleController->SetVerticalAlwaysVisible(value); - } - -/*********************************************************************** -GuiScrollContainer::StyleController -***********************************************************************/ - - GuiScrollContainer::StyleController::StyleController(GuiScrollView::IStyleProvider* styleProvider) - :GuiScrollView::StyleController(styleProvider) - ,extendToFullWidth(false) - { - controlContainerComposition=new GuiBoundsComposition; - controlContainerComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - GetInternalContainerComposition()->AddChild(controlContainerComposition); - } - - GuiScrollContainer::StyleController::~StyleController() - { - } - - compositions::GuiGraphicsComposition* GuiScrollContainer::StyleController::GetContainerComposition() - { - return controlContainerComposition; - } - - void GuiScrollContainer::StyleController::MoveContainer(Point leftTop) - { - controlContainerComposition->SetBounds(Rect(leftTop, Size(0, 0))); - } - - bool GuiScrollContainer::StyleController::GetExtendToFullWidth() - { - return extendToFullWidth; - } - - void GuiScrollContainer::StyleController::SetExtendToFullWidth(bool value) - { - if(extendToFullWidth!=value) - { - extendToFullWidth=value; - if(value) - { - controlContainerComposition->SetAlignmentToParent(Margin(0, -1, 0, -1)); - } - else - { - controlContainerComposition->SetAlignmentToParent(Margin(-1, -1, -1, -1)); - } - } - } - -/*********************************************************************** -GuiScrollContainer -***********************************************************************/ - - void GuiScrollContainer::OnControlContainerBoundsChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - CalculateView(); - } - - Size GuiScrollContainer::QueryFullSize() - { - return styleController->GetContainerComposition()->GetBounds().GetSize(); - } - - void GuiScrollContainer::UpdateView(Rect viewBounds) - { - styleController->MoveContainer(Point(-viewBounds.x1, -viewBounds.y1)); - } - - GuiScrollContainer::GuiScrollContainer(GuiScrollContainer::IStyleProvider* styleProvider) - :GuiScrollView(new StyleController(styleProvider)) - ,styleController(0) - { - styleController=dynamic_cast(GetStyleController()); - GuiBoundsComposition* composition=dynamic_cast(styleController->GetContainerComposition()); - composition->BoundsChanged.AttachMethod(this, &GuiScrollContainer::OnControlContainerBoundsChanged); - } - - GuiScrollContainer::~GuiScrollContainer() - { - } - - bool GuiScrollContainer::GetExtendToFullWidth() - { - return styleController->GetExtendToFullWidth(); - } - - void GuiScrollContainer::SetExtendToFullWidth(bool value) - { - styleController->SetExtendToFullWidth(value); - } - } - } -} - -/*********************************************************************** -CONTROLS\GUIDATETIMECONTROLS.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace controls - { - using namespace collections; - using namespace compositions; - using namespace elements; - -/*********************************************************************** -GuiDatePicker::StyleController -***********************************************************************/ - - vint GetDayCountForMonth(vint year, vint month) - { - bool isLeapYear=(year%100==0)?(year%400==0):(year%4==0); - switch(month) - { - case 1:case 3:case 5:case 7:case 8:case 10:case 12: - return 31; - case 4:case 6:case 9:case 11: - return 30; - default: - return isLeapYear?29:28; - } - } - - void StepPreviousMonth(vint& year, vint& month) - { - if(month==1) - { - year--; - month=12; - } - else - { - month--; - } - } - - void StepNextMonth(vint& year, vint& month) - { - if(month==12) - { - year++; - month=1; - } - else - { - month++; - } - } - - void GuiDatePicker::StyleController::SetDay(const DateTime& day, vint& index, bool currentMonth) - { - dateDays[index]=day; - GuiSolidLabelElement* label=labelDays[index]; - label->SetText(itow(day.day)); - label->SetColor(currentMonth?styleProvider->GetPrimaryTextColor():styleProvider->GetSecondaryTextColor()); - index++; - } - - void GuiDatePicker::StyleController::comboYearMonth_SelectedIndexChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if(!preventComboEvent) - { - if(comboYear->GetSelectedIndex()!=-1 && comboMonth->GetSelectedIndex()!=-1) - { - vint year=comboYear->GetSelectedIndex()+YearFirst; - vint month=comboMonth->GetSelectedIndex()+1; - SetDate(DateTime::FromDateTime(year, month, 1)); - datePicker->NotifyDateChanged(); - datePicker->DateNavigated.Execute(datePicker->GetNotifyEventArguments()); - } - } - } - - void GuiDatePicker::StyleController::buttonDay_SelectedChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if(!preventButtonEvent) - { - GuiSelectableButton* button=dynamic_cast(sender->GetRelatedControl()); - if(button->GetSelected()) - { - vint index=buttonDays.IndexOf(button); - if(index!=-1) - { - DateTime day=dateDays[index]; - if(day.year!=currentDate.year || day.month!=currentDate.month) - { - SetDate(day); - } - else - { - currentDate=day; - } - datePicker->NotifyDateChanged(); - datePicker->DateSelected.Execute(datePicker->GetNotifyEventArguments()); - } - } - } - } - - void GuiDatePicker::StyleController::DisplayMonth(vint year, vint month) - { - if(YearFirst<=year && year<=YearLast && 1<=month && month<=12) - { - preventComboEvent=true; - comboYear->SetSelectedIndex(year-YearFirst); - comboMonth->SetSelectedIndex(month-1); - preventComboEvent=false; - } - - vint yearPrev=year, yearNext=year, monthPrev=month, monthNext=month; - StepPreviousMonth(yearPrev, monthPrev); - StepNextMonth(yearNext, monthNext); - - vint countPrev=GetDayCountForMonth(yearPrev, monthPrev); - vint count=GetDayCountForMonth(year, month); - vint countNext=GetDayCountForMonth(yearNext, monthNext); - - DateTime firstDay=DateTime::FromDateTime(year, month, 1); - vint showPrev=firstDay.dayOfWeek; - if(showPrev==0) showPrev=DaysOfWeek; - vint show=count; - vint showNext=DaysOfWeek*DayRows-showPrev-show; - - vint index=0; - for(vint i=0;iSetSelected(true); - preventButtonEvent=false; - break; - } - } - } - - GuiDatePicker::StyleController::StyleController(IStyleProvider* _styleProvider) - :styleProvider(_styleProvider) - ,datePicker(0) - ,preventComboEvent(false) - ,preventButtonEvent(false) - { - GuiTableComposition* monthTable=0; - GuiTableComposition* dayTable=0; - { - listYears=styleProvider->CreateTextList(); - listYears->SetHorizontalAlwaysVisible(false); - for(vint i=YearFirst;i<=YearLast;i++) - { - listYears->GetItems().Add(new list::TextItem(itow(i))); - } - comboYear=new GuiComboBoxListControl(styleProvider->CreateComboBoxStyle(), listYears); - comboYear->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 2, 0)); - comboYear->SelectedIndexChanged.AttachMethod(this, &StyleController::comboYearMonth_SelectedIndexChanged); - } - { - listMonths=styleProvider->CreateTextList(); - listMonths->SetHorizontalAlwaysVisible(false); - comboMonth=new GuiComboBoxListControl(styleProvider->CreateComboBoxStyle(), listMonths); - comboMonth->GetBoundsComposition()->SetAlignmentToParent(Margin(2, 0, 0, 0)); - comboMonth->SelectedIndexChanged.AttachMethod(this, &StyleController::comboYearMonth_SelectedIndexChanged); - } - { - monthTable=new GuiTableComposition; - monthTable->SetAlignmentToParent(Margin(0, 0, 0, 0)); - monthTable->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - monthTable->SetRowsAndColumns(1, 2); - monthTable->SetRowOption(0, GuiCellOption::MinSizeOption()); - monthTable->SetColumnOption(0, GuiCellOption::PercentageOption(0.5)); - monthTable->SetColumnOption(1, GuiCellOption::PercentageOption(0.5)); - { - GuiCellComposition* cell=new GuiCellComposition; - monthTable->AddChild(cell); - cell->SetSite(0, 0, 1, 1); - cell->AddChild(comboYear->GetBoundsComposition()); - } - { - GuiCellComposition* cell=new GuiCellComposition; - monthTable->AddChild(cell); - cell->SetSite(0, 1, 1, 1); - cell->AddChild(comboMonth->GetBoundsComposition()); - } - } - { - dayTable=new GuiTableComposition; - dayTable->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - dayTable->SetCellPadding(4); - dayTable->SetRowsAndColumns(DayRows+DayRowStart, DaysOfWeek); - - for(vint i=0;iSetRowOption(i, GuiCellOption::MinSizeOption()); - } - for(vint i=0;iSetRowOption(i+DayRowStart, GuiCellOption::PercentageOption(1.0)); - } - for(vint i=0;iSetColumnOption(i, GuiCellOption::PercentageOption(1.0)); - } - - { - GuiCellComposition* cell=new GuiCellComposition; - dayTable->AddChild(cell); - cell->SetSite(0, 0, 1, DaysOfWeek); - cell->AddChild(monthTable); - } - - labelDaysOfWeek.Resize(7); - for(vint i=0;iAddChild(cell); - cell->SetSite(1, i, 1, 1); - - GuiSolidLabelElement* element=GuiSolidLabelElement::Create(); - element->SetAlignments(Alignment::Center, Alignment::Center); - element->SetColor(styleProvider->GetPrimaryTextColor()); - labelDaysOfWeek[i]=element; - cell->SetOwnedElement(element); - } - - buttonDays.Resize(DaysOfWeek*DayRows); - labelDays.Resize(DaysOfWeek*DayRows); - dateDays.Resize(DaysOfWeek*DayRows); - dayMutexController=new GuiSelectableButton::MutexGroupController; - for(vint i=0;iAddChild(cell); - cell->SetSite(j+DayRowStart, i, 1, 1); - - GuiSelectableButton* button=new GuiSelectableButton(styleProvider->CreateDateButtonStyle()); - button->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); - button->SetGroupController(dayMutexController.Obj()); - button->SelectedChanged.AttachMethod(this, &StyleController::buttonDay_SelectedChanged); - cell->AddChild(button->GetBoundsComposition()); - buttonDays[j*DaysOfWeek+i]=button; - - GuiSolidLabelElement* element=GuiSolidLabelElement::Create(); - element->SetAlignments(Alignment::Center, Alignment::Center); - element->SetText(L"0"); - labelDays[j*DaysOfWeek+i]=element; - - GuiBoundsComposition* elementBounds=new GuiBoundsComposition; - elementBounds->SetOwnedElement(element); - elementBounds->SetAlignmentToParent(Margin(0, 0, 0, 0)); - elementBounds->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - button->GetContainerComposition()->AddChild(elementBounds); - } - } - } - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(styleProvider->GetBackgroundColor()); - dayTable->SetOwnedElement(element); - } - - boundsComposition=dayTable; - } - - GuiDatePicker::StyleController::~StyleController() - { - delete styleProvider; - } - - compositions::GuiBoundsComposition* GuiDatePicker::StyleController::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* GuiDatePicker::StyleController::GetContainerComposition() - { - return boundsComposition; - } - - void GuiDatePicker::StyleController::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void GuiDatePicker::StyleController::SetText(const WString& value) - { - } - - void GuiDatePicker::StyleController::SetFont(const FontProperties& value) - { - comboYear->SetFont(value); - listYears->SetFont(value); - comboMonth->SetFont(value); - listMonths->SetFont(value); - FOREACH(GuiSolidLabelElement*, label, From(labelDaysOfWeek).Concat(labelDays)) - { - label->SetFont(value); - } - } - - void GuiDatePicker::StyleController::SetVisuallyEnabled(bool value) - { - } - - void GuiDatePicker::StyleController::SetDatePicker(GuiDatePicker* _datePicker) - { - datePicker=_datePicker; - } - - void GuiDatePicker::StyleController::SetDateLocale(const Locale& _dateLocale) - { - dateLocale=_dateLocale; - for(vint i=0;iSetText(dateLocale.GetShortDayOfWeekName(i)); - } - - listMonths->GetItems().Clear(); - for(vint i=1;i<=12;i++) - { - listMonths->GetItems().Add(new list::TextItem(dateLocale.GetLongMonthName(i))); - } - - SetDate(currentDate, true); - } - - const DateTime& GuiDatePicker::StyleController::GetDate() - { - return currentDate; - } - - void GuiDatePicker::StyleController::SetDate(const DateTime& value, bool forceUpdate) - { - if(forceUpdate || currentDate.year!=value.year || currentDate.month!=value.month || currentDate.day!=value.day) - { - currentDate=value; - DisplayMonth(value.year, value.month); - SelectDay(value.day); - } - } - -/*********************************************************************** -GuiDatePicker -***********************************************************************/ - - void GuiDatePicker::UpdateText() - { - GuiControl::SetText(dateLocale.FormatDate(dateFormat, styleController->GetDate())); - } - - void GuiDatePicker::NotifyDateChanged() - { - UpdateText(); - DateChanged.Execute(GetNotifyEventArguments()); - } - - GuiDatePicker::GuiDatePicker(IStyleProvider* _styleProvider) - :GuiControl(new StyleController(_styleProvider)) - { - styleController=dynamic_cast(GetStyleController()); - styleController->SetDatePicker(this); - - SetDateLocale(Locale::UserDefault()); - SetDate(DateTime::LocalTime()); - - DateChanged.SetAssociatedComposition(GetBoundsComposition()); - DateNavigated.SetAssociatedComposition(GetBoundsComposition()); - DateSelected.SetAssociatedComposition(GetBoundsComposition()); - DateFormatChanged.SetAssociatedComposition(GetBoundsComposition()); - DateLocaleChanged.SetAssociatedComposition(GetBoundsComposition()); - - NotifyDateChanged(); - } - - GuiDatePicker::~GuiDatePicker() - { - } - - const DateTime& GuiDatePicker::GetDate() - { - return styleController->GetDate(); - } - - void GuiDatePicker::SetDate(const DateTime& value) - { - styleController->SetDate(value); - } - - const WString& GuiDatePicker::GetDateFormat() - { - return dateFormat; - } - - void GuiDatePicker::SetDateFormat(const WString& value) - { - dateFormat=value; - UpdateText(); - DateFormatChanged.Execute(GetNotifyEventArguments()); - } - - const Locale& GuiDatePicker::GetDateLocale() - { - return dateLocale; - } - - void GuiDatePicker::SetDateLocale(const Locale& value) - { - dateLocale=value; - List formats; - dateLocale.GetLongDateFormats(formats); - if(formats.Count()>0) - { - dateFormat=formats[0]; - } - styleController->SetDateLocale(dateLocale); - - UpdateText(); - DateFormatChanged.Execute(GetNotifyEventArguments()); - DateLocaleChanged.Execute(GetNotifyEventArguments()); - } - - void GuiDatePicker::SetText(const WString& value) - { - } - -/*********************************************************************** -GuiDateComboBox -***********************************************************************/ - - void GuiDateComboBox::UpdateText() - { - SetText(datePicker->GetDateLocale().FormatDate(datePicker->GetDateFormat(), selectedDate)); - } - - void GuiDateComboBox::NotifyUpdateSelectedDate() - { - UpdateText(); - SelectedDateChanged.Execute(GetNotifyEventArguments()); - } - - void GuiDateComboBox::OnSubMenuOpeningChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - datePicker->SetDate(selectedDate); - } - - void GuiDateComboBox::datePicker_DateLocaleChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - UpdateText(); - } - - void GuiDateComboBox::datePicker_DateFormatChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - UpdateText(); - } - - void GuiDateComboBox::datePicker_DateSelected(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - selectedDate=datePicker->GetDate(); - GetSubMenu()->Hide(); - SelectItem(); - NotifyUpdateSelectedDate(); - } - - GuiDateComboBox::GuiDateComboBox(IStyleController* _styleController, GuiDatePicker* _datePicker) - :GuiComboBoxBase(_styleController) - ,datePicker(_datePicker) - { - SelectedDateChanged.SetAssociatedComposition(GetBoundsComposition()); - - datePicker->DateSelected.AttachMethod(this, &GuiDateComboBox::datePicker_DateSelected); - datePicker->DateLocaleChanged.AttachMethod(this, &GuiDateComboBox::datePicker_DateLocaleChanged); - datePicker->DateFormatChanged.AttachMethod(this, &GuiDateComboBox::datePicker_DateFormatChanged); - datePicker->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); - GetSubMenu()->GetContainerComposition()->AddChild(datePicker->GetBoundsComposition()); - - selectedDate=datePicker->GetDate(); - SubMenuOpeningChanged.AttachMethod(this, &GuiDateComboBox::OnSubMenuOpeningChanged); - SetFont(GetFont()); - SetText(datePicker->GetText()); - } - - GuiDateComboBox::~GuiDateComboBox() - { - } - - void GuiDateComboBox::SetFont(const FontProperties& value) - { - GuiComboBoxBase::SetFont(value); - datePicker->SetFont(value); - } - - const DateTime& GuiDateComboBox::GetSelectedDate() - { - return selectedDate; - } - - void GuiDateComboBox::SetSelectedDate(const DateTime& value) - { - selectedDate=value; - NotifyUpdateSelectedDate(); - } - - GuiDatePicker* GuiDateComboBox::GetDatePicker() - { - return datePicker; - } - } - } -} - -/*********************************************************************** -CONTROLS\GUIDIALOGS.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace controls - { - using namespace elements; - using namespace compositions; - using namespace collections; - using namespace reflection::description; - -/*********************************************************************** -GuiDialogBase -***********************************************************************/ - - GuiWindow* GuiDialogBase::GetHostWindow() - { - if (rootObject) - { - if (auto control = dynamic_cast(rootObject)) - { - if (auto host = control->GetRelatedControlHost()) - { - return dynamic_cast(host); - } - } - else if (auto composition = dynamic_cast(rootObject)) - { - if (auto host = composition->GetRelatedControlHost()) - { - return dynamic_cast(host); - } - } - } - return nullptr; - } - - GuiDialogBase::GuiDialogBase() - { - } - - GuiDialogBase::~GuiDialogBase() - { - } - - void GuiDialogBase::Attach(GuiInstanceRootObject* _rootObject) - { - rootObject = _rootObject; - } - - void GuiDialogBase::Detach(GuiInstanceRootObject* _rootObject) - { - rootObject = nullptr; - } - -/*********************************************************************** -GuiMessageDialog -***********************************************************************/ - - GuiMessageDialog::GuiMessageDialog() - { - } - - GuiMessageDialog::~GuiMessageDialog() - { - } - - INativeDialogService::MessageBoxButtonsInput GuiMessageDialog::GetInput() - { - return input; - } - - void GuiMessageDialog::SetInput(INativeDialogService::MessageBoxButtonsInput value) - { - input = value; - } - - INativeDialogService::MessageBoxDefaultButton GuiMessageDialog::GetDefaultButton() - { - return defaultButton; - } - - void GuiMessageDialog::SetDefaultButton(INativeDialogService::MessageBoxDefaultButton value) - { - defaultButton = value; - } - - INativeDialogService::MessageBoxIcons GuiMessageDialog::GetIcon() - { - return icon; - } - - void GuiMessageDialog::SetIcon(INativeDialogService::MessageBoxIcons value) - { - icon = value; - } - - INativeDialogService::MessageBoxModalOptions GuiMessageDialog::GetModalOption() - { - return modalOption; - } - - void GuiMessageDialog::SetModalOption(INativeDialogService::MessageBoxModalOptions value) - { - modalOption = value; - } - - const WString& GuiMessageDialog::GetText() - { - return text; - } - - void GuiMessageDialog::SetText(const WString& value) - { - text = value; - } - - const WString& GuiMessageDialog::GetTitle() - { - return title; - } - - void GuiMessageDialog::SetTitle(const WString& value) - { - title = value; - } - - INativeDialogService::MessageBoxButtonsOutput GuiMessageDialog::ShowDialog() - { - auto service = GetCurrentController()->DialogService(); - return service->ShowMessageBox(GetHostWindow()->GetNativeWindow(), text, title, input, defaultButton, icon, modalOption); - } - -/*********************************************************************** -GuiColorDialog -***********************************************************************/ - - GuiColorDialog::GuiColorDialog() - { - for (vint i = 0; i < 16; i++) - { - customColors.Add(Color()); - } - } - - GuiColorDialog::~GuiColorDialog() - { - } - - bool GuiColorDialog::GetEnabledCustomColor() - { - return enabledCustomColor; - } - - void GuiColorDialog::SetEnabledCustomColor(bool value) - { - enabledCustomColor = value; - } - - bool GuiColorDialog::GetOpenedCustomColor() - { - return openedCustomColor; - } - - void GuiColorDialog::SetOpenedCustomColor(bool value) - { - openedCustomColor = value; - } - - Color GuiColorDialog::GetSelectedColor() - { - return selectedColor; - } - - void GuiColorDialog::SetSelectedColor(Color value) - { - if (selectedColor != value) - { - selectedColor = value; - SelectedColorChanged.Execute(GuiEventArgs()); - } - } - - collections::List& GuiColorDialog::GetCustomColors() - { - return customColors; - } - - bool GuiColorDialog::ShowDialog() - { - Array colors; - CopyFrom(colors, customColors); - colors.Resize(16); - - INativeDialogService::ColorDialogCustomColorOptions options = - !enabledCustomColor ? INativeDialogService::CustomColorDisabled : - !openedCustomColor ? INativeDialogService::CustomColorEnabled : - INativeDialogService::CustomColorOpened; - - auto service = GetCurrentController()->DialogService(); - if (!service->ShowColorDialog(GetHostWindow()->GetNativeWindow(), selectedColor, showSelection, options, &colors[0])) - { - return false; - } - - CopyFrom(customColors, colors); - SelectedColorChanged.Execute(GuiEventArgs()); - return true; - } - -/*********************************************************************** -GuiFontDialog -***********************************************************************/ - - GuiFontDialog::GuiFontDialog() - { - } - - GuiFontDialog::~GuiFontDialog() - { - } - - const FontProperties& GuiFontDialog::GetSelectedFont() - { - return selectedFont; - } - - void GuiFontDialog::SetSelectedFont(const FontProperties& value) - { - if (selectedFont != value) - { - selectedFont = value; - SelectedFontChanged.Execute(GuiEventArgs()); - } - } - - Color GuiFontDialog::GetSelectedColor() - { - return selectedColor; - } - - void GuiFontDialog::SetSelectedColor(Color value) - { - if (selectedColor != value) - { - selectedColor = value; - SelectedColorChanged.Execute(GuiEventArgs()); - } - } - - bool GuiFontDialog::GetShowSelection() - { - return showSelection; - } - - void GuiFontDialog::SetShowSelection(bool value) - { - showSelection = value; - } - - bool GuiFontDialog::GetShowEffect() - { - return showEffect; - } - - void GuiFontDialog::SetShowEffect(bool value) - { - showEffect = value; - } - - bool GuiFontDialog::GetForceFontExist() - { - return forceFontExist; - } - - void GuiFontDialog::SetForceFontExist(bool value) - { - forceFontExist = value; - } - - bool GuiFontDialog::ShowDialog() - { - auto service = GetCurrentController()->DialogService(); - if (!service->ShowFontDialog(GetHostWindow()->GetNativeWindow(), selectedFont, selectedColor, showSelection, showEffect, forceFontExist)) - { - return false; - } - - SelectedColorChanged.Execute(GuiEventArgs()); - SelectedFontChanged.Execute(GuiEventArgs()); - return true; - } - -/*********************************************************************** -GuiFileDialogBase -***********************************************************************/ - - GuiFileDialogBase::GuiFileDialogBase() - { - } - - GuiFileDialogBase::~GuiFileDialogBase() - { - } - - const WString& GuiFileDialogBase::GetFilter() - { - return filter; - } - - void GuiFileDialogBase::SetFilter(const WString& value) - { - filter = value; - } - - vint GuiFileDialogBase::GetFilterIndex() - { - return filterIndex; - } - - void GuiFileDialogBase::SetFilterIndex(vint value) - { - if (filterIndex != value) - { - filterIndex = value; - FilterIndexChanged.Execute(GuiEventArgs()); - } - } - - bool GuiFileDialogBase::GetEnabledPreview() - { - return enabledPreview; - } - - void GuiFileDialogBase::SetEnabledPreview(bool value) - { - enabledPreview = value; - } - - WString GuiFileDialogBase::GetTitle() - { - return title; - } - - void GuiFileDialogBase::SetTitle(const WString& value) - { - title = value; - } - - WString GuiFileDialogBase::GetFileName() - { - return fileName; - } - - void GuiFileDialogBase::SetFileName(const WString& value) - { - if (fileName != value) - { - FileNameChanged.Execute(GuiEventArgs()); - } - } - - WString GuiFileDialogBase::GetDirectory() - { - return directory; - } - - void GuiFileDialogBase::SetDirectory(const WString& value) - { - directory = value; - } - - WString GuiFileDialogBase::GetDefaultExtension() - { - return defaultExtension; - } - - void GuiFileDialogBase::SetDefaultExtension(const WString& value) - { - defaultExtension = value; - } - - INativeDialogService::FileDialogOptions GuiFileDialogBase::GetOptions() - { - return options; - } - - void GuiFileDialogBase::SetOptions(INativeDialogService::FileDialogOptions value) - { - options = value; - } - -/*********************************************************************** -GuiOpenFileDialog -***********************************************************************/ - - GuiOpenFileDialog::GuiOpenFileDialog() - { - } - - GuiOpenFileDialog::~GuiOpenFileDialog() - { - } - - collections::List& GuiOpenFileDialog::GetFileNames() - { - return fileNames; - } - - bool GuiOpenFileDialog::ShowDialog() - { - fileNames.Clear(); - auto service = GetCurrentController()->DialogService(); - if (!service->ShowFileDialog( - GetHostWindow()->GetNativeWindow(), - fileNames, - filterIndex, - (enabledPreview ? INativeDialogService::FileDialogOpenPreview : INativeDialogService::FileDialogOpen), - title, - fileName, - directory, - defaultExtension, - filter, - options)) - { - return false; - } - - if (fileNames.Count() > 0) - { - fileName = fileNames[0]; - FileNameChanged.Execute(GuiEventArgs()); - FilterIndexChanged.Execute(GuiEventArgs()); - } - return true; - } - -/*********************************************************************** -GuiSaveFileDialog -***********************************************************************/ - - GuiSaveFileDialog::GuiSaveFileDialog() - { - } - - GuiSaveFileDialog::~GuiSaveFileDialog() - { - } - - bool GuiSaveFileDialog::ShowDialog() - { - List fileNames; - auto service = GetCurrentController()->DialogService(); - if (!service->ShowFileDialog( - GetHostWindow()->GetNativeWindow(), - fileNames, - filterIndex, - (enabledPreview ? INativeDialogService::FileDialogSavePreview : INativeDialogService::FileDialogSave), - title, - fileName, - directory, - defaultExtension, - filter, - options)) - { - return false; - } - - if (fileNames.Count() > 0) - { - fileName = fileNames[0]; - FileNameChanged.Execute(GuiEventArgs()); - FilterIndexChanged.Execute(GuiEventArgs()); - } - return true; - } - } - } -} - -/*********************************************************************** -CONTROLS\GUILABELCONTROLS.CPP +.\CONTROLS\GUILABELCONTROLS.CPP ***********************************************************************/ namespace vl @@ -3146,204 +5919,7 @@ GuiLabel } /*********************************************************************** -CONTROLS\GUISCROLLCONTROLS.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace controls - { - using namespace elements; - using namespace compositions; - using namespace collections; - using namespace reflection::description; - -/*********************************************************************** -GuiScroll::CommandExecutor -***********************************************************************/ - - GuiScroll::CommandExecutor::CommandExecutor(GuiScroll* _scroll) - :scroll(_scroll) - { - } - - GuiScroll::CommandExecutor::~CommandExecutor() - { - } - - void GuiScroll::CommandExecutor::SmallDecrease() - { - scroll->SetPosition(scroll->GetPosition()-scroll->GetSmallMove()); - } - - void GuiScroll::CommandExecutor::SmallIncrease() - { - scroll->SetPosition(scroll->GetPosition()+scroll->GetSmallMove()); - } - - void GuiScroll::CommandExecutor::BigDecrease() - { - scroll->SetPosition(scroll->GetPosition()-scroll->GetBigMove()); - } - - void GuiScroll::CommandExecutor::BigIncrease() - { - scroll->SetPosition(scroll->GetPosition()+scroll->GetBigMove()); - } - - void GuiScroll::CommandExecutor::SetTotalSize(vint value) - { - scroll->SetTotalSize(value); - } - - void GuiScroll::CommandExecutor::SetPageSize(vint value) - { - scroll->SetPageSize(value); - } - - void GuiScroll::CommandExecutor::SetPosition(vint value) - { - scroll->SetPosition(value); - } - -/*********************************************************************** -GuiScroll -***********************************************************************/ - - GuiScroll::GuiScroll(IStyleController* _styleController) - :GuiControl(_styleController) - ,styleController(_styleController) - ,totalSize(100) - ,pageSize(10) - ,position(0) - ,smallMove(1) - ,bigMove(10) - { - TotalSizeChanged.SetAssociatedComposition(boundsComposition); - PageSizeChanged.SetAssociatedComposition(boundsComposition); - PositionChanged.SetAssociatedComposition(boundsComposition); - SmallMoveChanged.SetAssociatedComposition(boundsComposition); - BigMoveChanged.SetAssociatedComposition(boundsComposition); - - commandExecutor=new CommandExecutor(this); - styleController->SetCommandExecutor(commandExecutor.Obj()); - styleController->SetPageSize(pageSize); - styleController->SetTotalSize(totalSize); - styleController->SetPosition(position); - } - - GuiScroll::~GuiScroll() - { - } - - vint GuiScroll::GetTotalSize() - { - return totalSize; - } - - void GuiScroll::SetTotalSize(vint value) - { - if(totalSize!=value && 0totalSize) - { - SetPageSize(totalSize); - } - if(position>GetMaxPosition()) - { - SetPosition(GetMaxPosition()); - } - styleController->SetTotalSize(totalSize); - TotalSizeChanged.Execute(GetNotifyEventArguments()); - } - } - - vint GuiScroll::GetPageSize() - { - return pageSize; - } - - void GuiScroll::SetPageSize(vint value) - { - if(pageSize!=value && 0<=value && value<=totalSize) - { - pageSize=value; - if(position>GetMaxPosition()) - { - SetPosition(GetMaxPosition()); - } - styleController->SetPageSize(pageSize); - PageSizeChanged.Execute(GetNotifyEventArguments()); - } - } - - vint GuiScroll::GetPosition() - { - return position; - } - - void GuiScroll::SetPosition(vint value) - { - vint min=GetMinPosition(); - vint max=GetMaxPosition(); - vint newPosition= - valuemax?max: - value; - if(position!=newPosition) - { - position=newPosition; - styleController->SetPosition(position); - PositionChanged.Execute(GetNotifyEventArguments()); - } - } - - vint GuiScroll::GetSmallMove() - { - return smallMove; - } - - void GuiScroll::SetSmallMove(vint value) - { - if(value>0 && smallMove!=value) - { - smallMove=value; - SmallMoveChanged.Execute(GetNotifyEventArguments()); - } - } - - vint GuiScroll::GetBigMove() - { - return bigMove; - } - - void GuiScroll::SetBigMove(vint value) - { - if(value>0 && bigMove!=value) - { - bigMove=value; - BigMoveChanged.Execute(GetNotifyEventArguments()); - } - } - - vint GuiScroll::GetMinPosition() - { - return 0; - } - - vint GuiScroll::GetMaxPosition() - { - return totalSize-pageSize; - } - } - } -} - -/*********************************************************************** -CONTROLS\GUIWINDOWCONTROLS.CPP +.\CONTROLS\GUIWINDOWCONTROLS.CPP ***********************************************************************/ namespace vl @@ -4523,1814 +7099,1077 @@ GuiPopup } /*********************************************************************** -CONTROLS\LISTCONTROLPACKAGE\GUIBINDABLEDATAGRID.CPP +.\GRAPHICSCOMPOSITION\GUIGRAPHICSAXIS.CPP ***********************************************************************/ namespace vl { namespace presentation { - namespace controls + namespace compositions { - using namespace collections; - using namespace description; - using namespace templates; - namespace list +/*********************************************************************** +GuiDefaultAxis +***********************************************************************/ + + GuiDefaultAxis::GuiDefaultAxis() { - -/*********************************************************************** -DataFilterBase -***********************************************************************/ - - void DataFilterBase::InvokeOnProcessorChanged() - { - if (callback) - { - callback->OnProcessorChanged(); - } - } - - DataFilterBase::DataFilterBase() - { - } - - void DataFilterBase::SetCallback(IDataProcessorCallback* value) - { - callback = value; - } - -/*********************************************************************** -DataMultipleFilter -***********************************************************************/ - - DataMultipleFilter::DataMultipleFilter() - { - } - - bool DataMultipleFilter::AddSubFilter(Ptr value) - { - if (!value) return false; - if (filters.Contains(value.Obj())) return false; - filters.Add(value); - value->SetCallback(callback); - InvokeOnProcessorChanged(); - return true; - } - - bool DataMultipleFilter::RemoveSubFilter(Ptr value) - { - if (!value) return false; - if (!filters.Contains(value.Obj())) return false; - value->SetCallback(nullptr); - filters.Remove(value.Obj()); - InvokeOnProcessorChanged(); - return true; - } - - void DataMultipleFilter::SetCallback(IDataProcessorCallback* value) - { - DataFilterBase::SetCallback(value); - for (vint i = 0; i < filters.Count(); i++) - { - filters[i]->SetCallback(value); - } - } - -/*********************************************************************** -DataAndFilter -***********************************************************************/ - - DataAndFilter::DataAndFilter() - { - } - - bool DataAndFilter::Filter(const description::Value& row) - { - return From(filters) - .All([row](Ptr filter) - { - return filter->Filter(row); - }); - } - -/*********************************************************************** -DataOrFilter -***********************************************************************/ - - DataOrFilter::DataOrFilter() - { - } - - bool DataOrFilter::Filter(const description::Value& row) - { - return From(filters) - .Any([row](Ptr filter) - { - return filter->Filter(row); - }); - } - -/*********************************************************************** -DataNotFilter -***********************************************************************/ - - DataNotFilter::DataNotFilter() - { - } - - bool DataNotFilter::SetSubFilter(Ptr value) - { - if (filter == value) return false; - if (filter) filter->SetCallback(nullptr); - filter = value; - if (filter) filter->SetCallback(callback); - InvokeOnProcessorChanged(); - return true; - } - - void DataNotFilter::SetCallback(IDataProcessorCallback* value) - { - DataFilterBase::SetCallback(value); - if (filter) filter->SetCallback(value); - } - - bool DataNotFilter::Filter(const description::Value& row) - { - return filter ? true : !filter->Filter(row); - } - -/*********************************************************************** -DataSorterBase -***********************************************************************/ - - void DataSorterBase::InvokeOnProcessorChanged() - { - if (callback) - { - callback->OnProcessorChanged(); - } - } - - DataSorterBase::DataSorterBase() - { - } - - void DataSorterBase::SetCallback(IDataProcessorCallback* value) - { - callback = value; - } - -/*********************************************************************** -DataMultipleSorter -***********************************************************************/ - - DataMultipleSorter::DataMultipleSorter() - { - } - - bool DataMultipleSorter::SetLeftSorter(Ptr value) - { - if (leftSorter == value) return false; - if (leftSorter) leftSorter->SetCallback(nullptr); - leftSorter = value; - if (leftSorter) leftSorter->SetCallback(callback); - return true; - } - - bool DataMultipleSorter::SetRightSorter(Ptr value) - { - if (rightSorter == value) return false; - if (rightSorter) rightSorter->SetCallback(nullptr); - rightSorter = value; - if (rightSorter) rightSorter->SetCallback(callback); - return true; - } - - void DataMultipleSorter::SetCallback(IDataProcessorCallback* value) - { - DataSorterBase::SetCallback(value); - if (leftSorter) leftSorter->SetCallback(value); - if (rightSorter) rightSorter->SetCallback(value); - } - - vint DataMultipleSorter::Compare(const description::Value& row1, const description::Value& row2) - { - if (leftSorter) - { - vint result = leftSorter->Compare(row1, row2); - if (result != 0) return result; - } - if (rightSorter) - { - vint result = rightSorter->Compare(row1, row2); - if (result != 0) return result; - } - return 0; - } - -/*********************************************************************** -DataReverseSorter -***********************************************************************/ - - DataReverseSorter::DataReverseSorter() - { - } - - bool DataReverseSorter::SetSubSorter(Ptr value) - { - if (sorter == value) return false; - if (sorter) sorter->SetCallback(nullptr); - sorter = value; - if (sorter) sorter->SetCallback(callback); - return true; - } - - void DataReverseSorter::SetCallback(IDataProcessorCallback* value) - { - DataSorterBase::SetCallback(value); - if (sorter) sorter->SetCallback(value); - } - - vint DataReverseSorter::Compare(const description::Value& row1, const description::Value& row2) - { - return sorter ? -sorter->Compare(row1, row2) : 0; - } - -/*********************************************************************** -DataColumn -***********************************************************************/ - - void DataColumn::NotifyAllColumnsUpdate(bool affectItem) - { - if (dataProvider) - { - vint index = dataProvider->columns.IndexOf(this); - if (index != -1) - { - dataProvider->columns.NotifyColumnUpdated(index, affectItem); - } - } - } - - DataColumn::DataColumn() - { - } - - DataColumn::~DataColumn() - { - if (popup && ownPopup) - { - SafeDeleteControl(popup); - } - } - - WString DataColumn::GetText() - { - return text; - } - - void DataColumn::SetText(const WString& value) - { - if (text != value) - { - text = value; - NotifyAllColumnsUpdate(false); - } - } - - vint DataColumn::GetSize() - { - return size; - } - - void DataColumn::SetSize(vint value) - { - if (size != value) - { - size = value; - NotifyAllColumnsUpdate(false); - } - } - - bool DataColumn::GetOwnPopup() - { - return ownPopup; - } - - void DataColumn::SetOwnPopup(bool value) - { - ownPopup = value; - } - - GuiMenu* DataColumn::GetPopup() - { - return popup; - } - - void DataColumn::SetPopup(GuiMenu* value) - { - if (popup != value) - { - popup = value; - NotifyAllColumnsUpdate(false); - } - } - - Ptr DataColumn::GetFilter() - { - return associatedFilter; - } - - void DataColumn::SetFilter(Ptr value) - { - if (associatedFilter) associatedFilter->SetCallback(nullptr); - associatedFilter = value; - if (associatedFilter) associatedFilter->SetCallback(dataProvider); - NotifyAllColumnsUpdate(false); - } - - Ptr DataColumn::GetSorter() - { - return associatedSorter; - } - - void DataColumn::SetSorter(Ptr value) - { - if (associatedSorter) associatedSorter->SetCallback(nullptr); - associatedSorter = value; - if (associatedSorter) associatedSorter->SetCallback(dataProvider); - NotifyAllColumnsUpdate(false); - } - - Ptr DataColumn::GetVisualizerFactory() - { - return visualizerFactory; - } - - void DataColumn::SetVisualizerFactory(Ptr value) - { - visualizerFactory = value; - NotifyAllColumnsUpdate(true); - } - - Ptr DataColumn::GetEditorFactory() - { - return editorFactory; - } - - void DataColumn::SetEditorFactory(Ptr value) - { - editorFactory = value; - NotifyAllColumnsUpdate(true); - } - - WString DataColumn::GetCellText(vint row) - { - if (0 <= row && row < dataProvider->Count()) - { - return ReadProperty(dataProvider->GetBindingValue(row), textProperty); - } - return L""; - } - - description::Value DataColumn::GetCellValue(vint row) - { - if (0 <= row && row < dataProvider->Count()) - { - return ReadProperty(dataProvider->GetBindingValue(row), valueProperty); - } - return Value(); - } - - void DataColumn::SetCellValue(vint row, description::Value value) - { - if (0 <= row && row < dataProvider->Count()) - { - auto rowValue = dataProvider->GetBindingValue(row); - WriteProperty(rowValue, valueProperty, value); - dataProvider->InvokeOnItemModified(row, 1, 1); - } - } - - ItemProperty DataColumn::GetTextProperty() - { - return textProperty; - } - - void DataColumn::SetTextProperty(const ItemProperty& value) - { - if (textProperty != value) - { - textProperty = value; - NotifyAllColumnsUpdate(true); - compositions::GuiEventArgs arguments; - TextPropertyChanged.Execute(arguments); - } - } - - WritableItemProperty DataColumn::GetValueProperty() - { - return valueProperty; - } - - void DataColumn::SetValueProperty(const WritableItemProperty& value) - { - if (valueProperty != value) - { - valueProperty = value; - NotifyAllColumnsUpdate(true); - compositions::GuiEventArgs arguments; - ValuePropertyChanged.Execute(arguments); - } - } - -/*********************************************************************** -DataColumns -***********************************************************************/ - - void DataColumns::NotifyColumnUpdated(vint index, bool affectItem) - { - affectItemFlag = affectItem; - NotifyUpdateInternal(index, 1, 1); - affectItemFlag = true; - } - - void DataColumns::NotifyUpdateInternal(vint start, vint count, vint newCount) - { - dataProvider->NotifyAllColumnsUpdate(); - if (affectItemFlag) - { - dataProvider->NotifyAllItemsUpdate(); - } - } - - bool DataColumns::QueryInsert(vint index, const Ptr& value) - { - return !items.Contains(value.Obj()); - } - - void DataColumns::AfterInsert(vint index, const Ptr& value) - { - value->dataProvider = dataProvider; - } - - void DataColumns::BeforeRemove(vint index, const Ptr& value) - { - value->dataProvider = nullptr; - } - - DataColumns::DataColumns(DataProvider* _dataProvider) - :dataProvider(_dataProvider) - { - } - - DataColumns::~DataColumns() - { - } - -/*********************************************************************** -DataProvider -***********************************************************************/ - - void DataProvider::NotifyAllItemsUpdate() - { - InvokeOnItemModified(0, Count(), Count()); - } - - void DataProvider::NotifyAllColumnsUpdate() - { - if (columnItemViewCallback) - { - columnItemViewCallback->OnColumnChanged(); - } - } - - GuiListControl::IItemProvider* DataProvider::GetItemProvider() - { - return this; - } - - void DataProvider::OnProcessorChanged() - { - RebuildFilter(); - ReorderRows(true); - } - - void DataProvider::OnItemSourceModified(vint start, vint count, vint newCount) - { - if (!currentSorter && !currentFilter && count == newCount) - { - InvokeOnItemModified(start, count, newCount); - } - else - { - ReorderRows(true); - } - } - - ListViewDataColumns& DataProvider::GetDataColumns() - { - return dataColumns; - } - - DataColumns& DataProvider::GetColumns() - { - return columns; - } - - Ptr DataProvider::GetItemSource() - { - return itemSource; - } - - void DataProvider::SetItemSource(Ptr _itemSource) - { - vint oldCount = 0; - if (itemSource) - { - oldCount = itemSource->GetCount(); - } - if (itemChangedEventHandler) - { - auto ol = itemSource.Cast(); - ol->ItemChanged.Remove(itemChangedEventHandler); - } - - itemSource = nullptr; - itemChangedEventHandler = nullptr; - - if (_itemSource) - { - if (auto ol = _itemSource.Cast()) - { - itemSource = ol; - itemChangedEventHandler = ol->ItemChanged.Add([this](vint start, vint oldCount, vint newCount) - { - OnItemSourceModified(start, oldCount, newCount); - }); - } - else if (auto rl = _itemSource.Cast()) - { - itemSource = rl; - } - else - { - itemSource = IValueList::Create(GetLazyList(_itemSource)); - } - } - - OnItemSourceModified(0, oldCount, itemSource ? itemSource->GetCount() : 0); - } - - void DataProvider::RebuildFilter() - { - if (currentFilter) - { - currentFilter->SetCallback(nullptr); - currentFilter = nullptr; - } - - List> selectedFilters; - CopyFrom( - selectedFilters, - From(columns) - .Select([](Ptr column) {return column->GetFilter(); }) - .Where([](Ptr filter) {return filter != nullptr; }) - ); - if (additionalFilter) - { - selectedFilters.Add(additionalFilter); - } - if (selectedFilters.Count() > 0) - { - auto andFilter = MakePtr(); - FOREACH(Ptr, filter, selectedFilters) - { - andFilter->AddSubFilter(filter); - } - currentFilter = andFilter; - } - - if (currentFilter) - { - currentFilter->SetCallback(this); - } - } - - void DataProvider::ReorderRows(bool invokeCallback) - { - vint oldRowCount = virtualRowToSourceRow.Count(); - virtualRowToSourceRow.Clear(); - vint rowCount = itemSource ? itemSource->GetCount() : 0; - - if (currentFilter) - { - for (vint i = 0; i < rowCount; i++) - { - if (currentFilter->Filter(itemSource->Get(i))) - { - virtualRowToSourceRow.Add(i); - } - } - } - else - { - for (vint i = 0; i < rowCount; i++) - { - virtualRowToSourceRow.Add(i); - } - } - - if (currentSorter && virtualRowToSourceRow.Count() > 0) - { - IDataSorter* sorter = currentSorter.Obj(); - SortLambda( - &virtualRowToSourceRow[0], - virtualRowToSourceRow.Count(), - [=](vint a, vint b) - { - return sorter->Compare(itemSource->Get(a), itemSource->Get(b)); - }); - } - - if (invokeCallback) - { - NotifyAllItemsUpdate(); - } - } - - DataProvider::DataProvider(const description::Value& _viewModelContext) - :dataColumns(this) - , columns(this) - , viewModelContext(_viewModelContext) - { - RebuildFilter(); - ReorderRows(false); - } - - DataProvider::~DataProvider() - { - } - - Ptr DataProvider::GetAdditionalFilter() - { - return additionalFilter; - } - - void DataProvider::SetAdditionalFilter(Ptr value) - { - additionalFilter = value; - RebuildFilter(); - ReorderRows(true); - } - - // ===================== GuiListControl::IItemProvider ===================== - - vint DataProvider::Count() - { - return virtualRowToSourceRow.Count(); - } - - WString DataProvider::GetTextValue(vint itemIndex) - { - return GetText(itemIndex); - } - - description::Value DataProvider::GetBindingValue(vint itemIndex) - { - return itemSource ? itemSource->Get(virtualRowToSourceRow[itemIndex]) : Value(); - } - - IDescriptable* DataProvider::RequestView(const WString& identifier) - { - if (identifier == IListViewItemView::Identifier) - { - return (IListViewItemView*)this; - } - else if (identifier == ListViewColumnItemArranger::IColumnItemView::Identifier) - { - return (ListViewColumnItemArranger::IColumnItemView*)this; - } - else if (identifier == IDataGridView::Identifier) - { - return (IDataGridView*)this; - } - else - { - return nullptr; - } - } - - // ===================== list::IListViewItemProvider ===================== - - Ptr DataProvider::GetSmallImage(vint itemIndex) - { - if (0 <= itemIndex && itemIndex < Count()) - { - return ReadProperty(GetBindingValue(itemIndex), smallImageProperty); - } - return nullptr; - } - - Ptr DataProvider::GetLargeImage(vint itemIndex) - { - if (0 <= itemIndex && itemIndex < Count()) - { - return ReadProperty(GetBindingValue(itemIndex), largeImageProperty); - } - return nullptr; - } - - WString DataProvider::GetText(vint itemIndex) - { - if (columns.Count() == 0)return L""; - return columns[0]->GetCellText(itemIndex); - } - - WString DataProvider::GetSubItem(vint itemIndex, vint index) - { - return columns[index + 1]->GetCellText(itemIndex); - } - - vint DataProvider::GetDataColumnCount() - { - return dataColumns.Count(); - } - - vint DataProvider::GetDataColumn(vint index) - { - return dataColumns[index]; - } - - vint DataProvider::GetColumnCount() - { - return columns.Count(); - } - - WString DataProvider::GetColumnText(vint index) - { - return columns[index]->GetText(); - } - - // ===================== list::ListViewColumnItemArranger::IColumnItemView ===================== - - bool DataProvider::AttachCallback(ListViewColumnItemArranger::IColumnItemViewCallback* value) - { - if (columnItemViewCallback)return false; - columnItemViewCallback = value; - return true; - } - - bool DataProvider::DetachCallback(ListViewColumnItemArranger::IColumnItemViewCallback* value) - { - if (!columnItemViewCallback) return false; - columnItemViewCallback = nullptr; - return true; - } - - vint DataProvider::GetColumnSize(vint index) - { - return columns[index]->GetSize(); - } - - void DataProvider::SetColumnSize(vint index, vint value) - { - columns[index]->SetSize(value); - } - - GuiMenu* DataProvider::GetDropdownPopup(vint index) - { - return columns[index]->GetPopup(); - } - - ColumnSortingState DataProvider::GetSortingState(vint index) - { - return columns[index]->sortingState; - } - - // ===================== list::IDataGridView ===================== - - description::Value DataProvider::GetViewModelContext() - { - return viewModelContext; - } - - bool DataProvider::IsColumnSortable(vint column) - { - return columns[column]->GetSorter(); - } - - void DataProvider::SortByColumn(vint column, bool ascending) - { - if (0 <= column && column < columns.Count()) - { - auto sorter = columns[column]->GetSorter(); - if (!sorter) - { - currentSorter = nullptr; - } - else if (ascending) - { - currentSorter = sorter; - } - else - { - Ptr reverseSorter = new DataReverseSorter(); - reverseSorter->SetSubSorter(sorter); - currentSorter = reverseSorter; - } - } - else - { - currentSorter = nullptr; - } - - for (vint i = 0; i < columns.Count(); i++) - { - columns[i]->sortingState = - i != column ? ColumnSortingState::NotSorted : - ascending ? ColumnSortingState::Ascending : - ColumnSortingState::Descending - ; - } - NotifyAllColumnsUpdate(); - ReorderRows(true); - } - - vint DataProvider::GetSortedColumn() - { - for (vint i = 0; i < columns.Count(); i++) - { - auto state = columns[i]->sortingState; - if (state != ColumnSortingState::NotSorted) - { - return i; - } - } - return -1; - } - - bool DataProvider::IsSortOrderAscending() - { - for (vint i = 0; i < columns.Count(); i++) - { - auto state = columns[i]->sortingState; - if (state != ColumnSortingState::NotSorted) - { - return state == ColumnSortingState::Ascending; - } - } - return true; - } - - vint DataProvider::GetCellSpan(vint row, vint column) - { - return 1; - } - - IDataVisualizerFactory* DataProvider::GetCellDataVisualizerFactory(vint row, vint column) - { - return columns[column]->GetVisualizerFactory().Obj(); - } - - IDataEditorFactory* DataProvider::GetCellDataEditorFactory(vint row, vint column) - { - return columns[column]->GetEditorFactory().Obj(); - } - - description::Value DataProvider::GetBindingCellValue(vint row, vint column) - { - return columns[column]->GetCellValue(row); - } - - void DataProvider::SetBindingCellValue(vint row, vint column, const description::Value& value) - { - columns[column]->SetCellValue(row, value); - } + } + + GuiDefaultAxis::~GuiDefaultAxis() + { + } + + Size GuiDefaultAxis::RealSizeToVirtualSize(Size size) + { + return size; + } + + Size GuiDefaultAxis::VirtualSizeToRealSize(Size size) + { + return size; + } + + Point GuiDefaultAxis::RealPointToVirtualPoint(Size realFullSize, Point point) + { + return point; + } + + Point GuiDefaultAxis::VirtualPointToRealPoint(Size realFullSize, Point point) + { + return point; + } + + Rect GuiDefaultAxis::RealRectToVirtualRect(Size realFullSize, Rect rect) + { + return rect; + } + + Rect GuiDefaultAxis::VirtualRectToRealRect(Size realFullSize, Rect rect) + { + return rect; + } + + Margin GuiDefaultAxis::RealMarginToVirtualMargin(Margin margin) + { + return margin; + } + + Margin GuiDefaultAxis::VirtualMarginToRealMargin(Margin margin) + { + return margin; + } + + KeyDirection GuiDefaultAxis::RealKeyDirectionToVirtualKeyDirection(KeyDirection key) + { + return key; } /*********************************************************************** -GuiBindableDataGrid +GuiAxis ***********************************************************************/ - GuiBindableDataGrid::GuiBindableDataGrid(IStyleProvider* _styleProvider, const description::Value& _viewModelContext) - :GuiVirtualDataGrid(_styleProvider, new list::DataProvider(_viewModelContext)) + GuiAxis::GuiAxis(AxisDirection _axisDirection) + :axisDirection(_axisDirection) { - dataProvider = dynamic_cast(GetItemProvider()); } - GuiBindableDataGrid::~GuiBindableDataGrid() + GuiAxis::~GuiAxis() { } - - list::ListViewDataColumns& GuiBindableDataGrid::GetDataColumns() - { - return dataProvider->GetDataColumns(); - } - list::DataColumns& GuiBindableDataGrid::GetColumns() + AxisDirection GuiAxis::GetDirection() { - return dataProvider->GetColumns(); + return axisDirection; } - Ptr GuiBindableDataGrid::GetItemSource() + Size GuiAxis::RealSizeToVirtualSize(Size size) { - return dataProvider->GetItemSource(); - } - - void GuiBindableDataGrid::SetItemSource(Ptr _itemSource) - { - dataProvider->SetItemSource(_itemSource); - } - - Ptr GuiBindableDataGrid::GetAdditionalFilter() - { - return dataProvider->GetAdditionalFilter(); - } - - void GuiBindableDataGrid::SetAdditionalFilter(Ptr value) - { - dataProvider->SetAdditionalFilter(value); - } - - ItemProperty> GuiBindableDataGrid::GetLargeImageProperty() - { - return dataProvider->largeImageProperty; - } - - void GuiBindableDataGrid::SetLargeImageProperty(const ItemProperty>& value) - { - if (dataProvider->largeImageProperty != value) + switch(axisDirection) { - dataProvider->largeImageProperty = value; - dataProvider->NotifyAllItemsUpdate(); - LargeImagePropertyChanged.Execute(GetNotifyEventArguments()); + case AxisDirection::LeftDown: + case AxisDirection::RightDown: + case AxisDirection::LeftUp: + case AxisDirection::RightUp: + return Size(size.x, size.y); + case AxisDirection::DownLeft: + case AxisDirection::DownRight: + case AxisDirection::UpLeft: + case AxisDirection::UpRight: + return Size(size.y, size.x); } + return size; } - ItemProperty> GuiBindableDataGrid::GetSmallImageProperty() + Size GuiAxis::VirtualSizeToRealSize(Size size) { - return dataProvider->smallImageProperty; + return RealSizeToVirtualSize(size); } - void GuiBindableDataGrid::SetSmallImageProperty(const ItemProperty>& value) + Point GuiAxis::RealPointToVirtualPoint(Size realFullSize, Point point) { - if (dataProvider->smallImageProperty != value) + Rect rect(point, Size(0, 0)); + return RealRectToVirtualRect(realFullSize, rect).LeftTop(); + } + + Point GuiAxis::VirtualPointToRealPoint(Size realFullSize, Point point) + { + Rect rect(point, Size(0, 0)); + return VirtualRectToRealRect(realFullSize, rect).LeftTop(); + } + + Rect GuiAxis::RealRectToVirtualRect(Size realFullSize, Rect rect) + { + vint x1=rect.x1; + vint x2=realFullSize.x-rect.x2; + vint y1=rect.y1; + vint y2=realFullSize.y-rect.y2; + vint w=rect.Width(); + vint h=rect.Height(); + switch(axisDirection) { - dataProvider->smallImageProperty = value; - dataProvider->NotifyAllItemsUpdate(); - SmallImagePropertyChanged.Execute(GetNotifyEventArguments()); + case AxisDirection::LeftDown: + return Rect(Point(x2, y1), Size(w, h)); + case AxisDirection::RightDown: + return Rect(Point(x1, y1), Size(w, h)); + case AxisDirection::LeftUp: + return Rect(Point(x2, y2), Size(w, h)); + case AxisDirection::RightUp: + return Rect(Point(x1, y2), Size(w, h)); + case AxisDirection::DownLeft: + return Rect(Point(y1, x2), Size(h, w)); + case AxisDirection::DownRight: + return Rect(Point(y1, x1), Size(h, w)); + case AxisDirection::UpLeft: + return Rect(Point(y2, x2), Size(h, w)); + case AxisDirection::UpRight: + return Rect(Point(y2, x1), Size(h, w)); } + return rect; } - description::Value GuiBindableDataGrid::GetSelectedRowValue() + Rect GuiAxis::VirtualRectToRealRect(Size realFullSize, Rect rect) { - auto pos = GetSelectedCell(); - if (pos.row == -1 || pos.column == -1) + realFullSize=RealSizeToVirtualSize(realFullSize); + vint x1=rect.x1; + vint x2=realFullSize.x-rect.x2; + vint y1=rect.y1; + vint y2=realFullSize.y-rect.y2; + vint w=rect.Width(); + vint h=rect.Height(); + switch(axisDirection) { - return Value(); + case AxisDirection::LeftDown: + return Rect(Point(x2, y1), Size(w, h)); + case AxisDirection::RightDown: + return Rect(Point(x1, y1), Size(w, h)); + case AxisDirection::LeftUp: + return Rect(Point(x2, y2), Size(w, h)); + case AxisDirection::RightUp: + return Rect(Point(x1, y2), Size(w, h)); + case AxisDirection::DownLeft: + return Rect(Point(y2, x1), Size(h, w)); + case AxisDirection::DownRight: + return Rect(Point(y1, x1), Size(h, w)); + case AxisDirection::UpLeft: + return Rect(Point(y2, x2), Size(h, w)); + case AxisDirection::UpRight: + return Rect(Point(y1, x2), Size(h, w)); } - return dataProvider->GetBindingValue(GetSelectedCell().row); + return rect; } - description::Value GuiBindableDataGrid::GetSelectedCellValue() + Margin GuiAxis::RealMarginToVirtualMargin(Margin margin) { - auto pos = GetSelectedCell(); - if (pos.row == -1 || pos.column == -1) + vint x1=margin.left; + vint x2=margin.right; + vint y1=margin.top; + vint y2=margin.bottom; + switch(axisDirection) { - return Value(); + case AxisDirection::LeftDown: + return Margin(x2, y1, x1, y2); + case AxisDirection::RightDown: + return Margin(x1, y1, x2, y2); + case AxisDirection::LeftUp: + return Margin(x2, y2, x1, y1); + case AxisDirection::RightUp: + return Margin(x1, y2, x2, y1); + case AxisDirection::DownLeft: + return Margin(y1, x2, y2, x1); + case AxisDirection::DownRight: + return Margin(y1, x1, y2, x2); + case AxisDirection::UpLeft: + return Margin(y2, x2, y1, x1); + case AxisDirection::UpRight: + return Margin(y2, x1, y1, x2); } - return dataProvider->GetColumns()[pos.column]->GetCellValue(pos.row); + return margin; + } + + Margin GuiAxis::VirtualMarginToRealMargin(Margin margin) + { + vint x1=margin.left; + vint x2=margin.right; + vint y1=margin.top; + vint y2=margin.bottom; + switch(axisDirection) + { + case AxisDirection::LeftDown: + return Margin(x2, y1, x1, y2); + case AxisDirection::RightDown: + return Margin(x1, y1, x2, y2); + case AxisDirection::LeftUp: + return Margin(x2, y2, x1, y1); + case AxisDirection::RightUp: + return Margin(x1, y2, x2, y1); + case AxisDirection::DownLeft: + return Margin(y2, x1, y1, x2); + case AxisDirection::DownRight: + return Margin(y1, x1, y2, x2); + case AxisDirection::UpLeft: + return Margin(y2, x2, y1, x1); + case AxisDirection::UpRight: + return Margin(y1, x2, y2, x1); + default:; + } + return margin; + } + + KeyDirection GuiAxis::RealKeyDirectionToVirtualKeyDirection(KeyDirection key) + { + bool pageKey=false; + switch(key) + { + case KeyDirection::PageUp: + pageKey=true; + key=KeyDirection::Up; + break; + case KeyDirection::PageDown: + pageKey=true; + key=KeyDirection::Down; + break; + case KeyDirection::PageLeft: + pageKey=true; + key=KeyDirection::Left; + break; + case KeyDirection::PageRight: + pageKey=true; + key=KeyDirection::Right; + break; + default:; + } + + switch(key) + { + case KeyDirection::Up: + switch(axisDirection) + { + case AxisDirection::LeftDown: key=KeyDirection::Up; break; + case AxisDirection::RightDown: key=KeyDirection::Up; break; + case AxisDirection::LeftUp: key=KeyDirection::Down; break; + case AxisDirection::RightUp: key=KeyDirection::Down; break; + case AxisDirection::DownLeft: key=KeyDirection::Left; break; + case AxisDirection::DownRight: key=KeyDirection::Left; break; + case AxisDirection::UpLeft: key=KeyDirection::Right; break; + case AxisDirection::UpRight: key=KeyDirection::Right; break; + } + break; + case KeyDirection::Down: + switch(axisDirection) + { + case AxisDirection::LeftDown: key=KeyDirection::Down; break; + case AxisDirection::RightDown: key=KeyDirection::Down; break; + case AxisDirection::LeftUp: key=KeyDirection::Up; break; + case AxisDirection::RightUp: key=KeyDirection::Up; break; + case AxisDirection::DownLeft: key=KeyDirection::Right; break; + case AxisDirection::DownRight: key=KeyDirection::Right; break; + case AxisDirection::UpLeft: key=KeyDirection::Left; break; + case AxisDirection::UpRight: key=KeyDirection::Left; break; + } + break; + case KeyDirection::Left: + switch(axisDirection) + { + case AxisDirection::LeftDown: key=KeyDirection::Right; break; + case AxisDirection::RightDown: key=KeyDirection::Left; break; + case AxisDirection::LeftUp: key=KeyDirection::Right; break; + case AxisDirection::RightUp: key=KeyDirection::Left; break; + case AxisDirection::DownLeft: key=KeyDirection::Down; break; + case AxisDirection::DownRight: key=KeyDirection::Up; break; + case AxisDirection::UpLeft: key=KeyDirection::Down; break; + case AxisDirection::UpRight: key=KeyDirection::Up; break; + } + break; + case KeyDirection::Right: + switch(axisDirection) + { + case AxisDirection::LeftDown: key=KeyDirection::Left; break; + case AxisDirection::RightDown: key=KeyDirection::Right; break; + case AxisDirection::LeftUp: key=KeyDirection::Left; break; + case AxisDirection::RightUp: key=KeyDirection::Right; break; + case AxisDirection::DownLeft: key=KeyDirection::Up; break; + case AxisDirection::DownRight: key=KeyDirection::Down; break; + case AxisDirection::UpLeft: key=KeyDirection::Up; break; + case AxisDirection::UpRight: key=KeyDirection::Down; break; + } + break; + case KeyDirection::Home: + switch(axisDirection) + { + case AxisDirection::LeftDown: key=KeyDirection::Home; break; + case AxisDirection::RightDown: key=KeyDirection::Home; break; + case AxisDirection::LeftUp: key=KeyDirection::End; break; + case AxisDirection::RightUp: key=KeyDirection::End; break; + case AxisDirection::DownLeft: key=KeyDirection::Home; break; + case AxisDirection::DownRight: key=KeyDirection::Home; break; + case AxisDirection::UpLeft: key=KeyDirection::End; break; + case AxisDirection::UpRight: key=KeyDirection::End; break; + } + break; + case KeyDirection::End: + switch(axisDirection) + { + case AxisDirection::LeftDown: key=KeyDirection::End; break; + case AxisDirection::RightDown: key=KeyDirection::End; break; + case AxisDirection::LeftUp: key=KeyDirection::Home; break; + case AxisDirection::RightUp: key=KeyDirection::Home; break; + case AxisDirection::DownLeft: key=KeyDirection::End; break; + case AxisDirection::DownRight: key=KeyDirection::End; break; + case AxisDirection::UpLeft: key=KeyDirection::Home; break; + case AxisDirection::UpRight: key=KeyDirection::Home; break; + } + break; + default:; + } + + if(pageKey) + { + switch(key) + { + case KeyDirection::Up: + key=KeyDirection::PageUp; + break; + case KeyDirection::Down: + key=KeyDirection::PageDown; + break; + case KeyDirection::Left: + key=KeyDirection::PageLeft; + break; + case KeyDirection::Right: + key=KeyDirection::PageRight; + break; + default:; + } + } + return key; } } } } /*********************************************************************** -CONTROLS\LISTCONTROLPACKAGE\GUIBINDABLELISTCONTROLS.CPP +.\GRAPHICSCOMPOSITION\GUIGRAPHICSBASICCOMPOSITION.CPP ***********************************************************************/ namespace vl { namespace presentation { - namespace controls + namespace compositions { using namespace collections; - using namespace list; - using namespace tree; - using namespace reflection::description; - using namespace templates; + using namespace controls; + using namespace elements; /*********************************************************************** -GuiBindableTextList::ItemSource +GuiWindowComposition ***********************************************************************/ - GuiBindableTextList::ItemSource::ItemSource() + GuiWindowComposition::GuiWindowComposition() { } - GuiBindableTextList::ItemSource::~ItemSource() + GuiWindowComposition::~GuiWindowComposition() { - SetItemSource(nullptr); } - Ptr GuiBindableTextList::ItemSource::GetItemSource() + Rect GuiWindowComposition::GetBounds() { - return itemSource; - } - - void GuiBindableTextList::ItemSource::SetItemSource(Ptr _itemSource) - { - vint oldCount = 0; - if (itemSource) + Rect bounds; + if (relatedHostRecord) { - oldCount = itemSource->GetCount(); - } - if (itemChangedEventHandler) - { - auto ol = itemSource.Cast(); - ol->ItemChanged.Remove(itemChangedEventHandler); - } - - itemSource = nullptr; - itemChangedEventHandler = nullptr; - - if (_itemSource) - { - if (auto ol = _itemSource.Cast()) + if (auto window = relatedHostRecord->host->GetNativeWindow()) { - itemSource = ol; - itemChangedEventHandler = ol->ItemChanged.Add([this](vint start, vint oldCount, vint newCount) - { - InvokeOnItemModified(start, oldCount, newCount); - }); - } - else if (auto rl = _itemSource.Cast()) - { - itemSource = rl; - } - else - { - itemSource = IValueList::Create(GetLazyList(_itemSource)); + bounds = Rect(Point(0, 0), window->GetClientSize()); } } - - InvokeOnItemModified(0, oldCount, itemSource ? itemSource->GetCount() : 0); + UpdatePreviousBounds(bounds); + return bounds; } - description::Value GuiBindableTextList::ItemSource::Get(vint index) + void GuiWindowComposition::SetMargin(Margin value) { - if (!itemSource) return Value(); - return itemSource->Get(index); } - void GuiBindableTextList::ItemSource::UpdateBindingProperties() +/*********************************************************************** +GuiBoundsComposition +***********************************************************************/ + + GuiBoundsComposition::GuiBoundsComposition() { - InvokeOnItemModified(0, Count(), Count()); - } - - // ===================== GuiListControl::IItemProvider ===================== - - vint GuiBindableTextList::ItemSource::Count() - { - if (!itemSource) return 0; - return itemSource->GetCount(); } - WString GuiBindableTextList::ItemSource::GetTextValue(vint itemIndex) + GuiBoundsComposition::~GuiBoundsComposition() { - if (itemSource) + } + + Rect GuiBoundsComposition::GetPreferredBounds() + { + Rect result = GetBoundsInternal(compositionBounds); + if (GetParent() && IsAlignedToParent()) { - if (0 <= itemIndex && itemIndex < itemSource->GetCount()) + if (alignmentToParent.left >= 0) { - return ReadProperty(itemSource->Get(itemIndex), textProperty); + vint offset = alignmentToParent.left - result.x1; + result.x1 += offset; + result.x2 += offset; + } + if (alignmentToParent.top >= 0) + { + vint offset = alignmentToParent.top - result.y1; + result.y1 += offset; + result.y2 += offset; + } + if (alignmentToParent.right >= 0) + { + result.x2 += alignmentToParent.right; + } + if (alignmentToParent.bottom >= 0) + { + result.y2 += alignmentToParent.bottom; } } - return L""; + return result; } - - IDescriptable* GuiBindableTextList::ItemSource::RequestView(const WString& identifier) - { - if (identifier == ITextItemView::Identifier) - { - return (ITextItemView*)this; - } - else - { - return 0; - } - } - - // ===================== GuiListControl::IItemBindingView ===================== - description::Value GuiBindableTextList::ItemSource::GetBindingValue(vint itemIndex) + Rect GuiBoundsComposition::GetBounds() { - if (itemSource) + Rect result = GetPreferredBounds(); + if (GetParent() && IsAlignedToParent()) { - if (0 <= itemIndex && itemIndex < itemSource->GetCount()) + Size clientSize = GetParent()->GetClientArea().GetSize(); + if (alignmentToParent.left >= 0 && alignmentToParent.right >= 0) { - return itemSource->Get(itemIndex); + result.x1 = alignmentToParent.left; + result.x2 = clientSize.x - alignmentToParent.right; + } + else if (alignmentToParent.left >= 0) + { + vint width = result.Width(); + result.x1 = alignmentToParent.left; + result.x2 = result.x1 + width; + } + else if (alignmentToParent.right >= 0) + { + vint width = result.Width(); + result.x2 = clientSize.x - alignmentToParent.right; + result.x1 = result.x2 - width; + } + + if (alignmentToParent.top >= 0 && alignmentToParent.bottom >= 0) + { + result.y1 = alignmentToParent.top; + result.y2 = clientSize.y - alignmentToParent.bottom; + } + else if (alignmentToParent.top >= 0) + { + vint height = result.Height(); + result.y1 = alignmentToParent.top; + result.y2 = result.y1 + height; + } + else if (alignmentToParent.bottom >= 0) + { + vint height = result.Height(); + result.y2 = clientSize.y - alignmentToParent.bottom; + result.y1 = result.y2 - height; } } - return Value(); + UpdatePreviousBounds(result); + return result; } - - // ===================== list::TextItemStyleProvider::ITextItemView ===================== - - bool GuiBindableTextList::ItemSource::GetChecked(vint itemIndex) + + void GuiBoundsComposition::SetBounds(Rect value) { - if (itemSource) + compositionBounds = value; + InvokeOnCompositionStateChanged(); + } + + Margin GuiBoundsComposition::GetAlignmentToParent() + { + return alignmentToParent; + } + + void GuiBoundsComposition::SetAlignmentToParent(Margin value) + { + alignmentToParent = value; + InvokeOnCompositionStateChanged(); + } + + bool GuiBoundsComposition::IsAlignedToParent() + { + return alignmentToParent != Margin(-1, -1, -1, -1); + } + } + } +} + +/*********************************************************************** +.\GRAPHICSCOMPOSITION\GUIGRAPHICSCOMPOSITION.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace compositions + { + using namespace collections; + using namespace controls; + using namespace elements; + +/*********************************************************************** +GuiSharedSizeItemComposition +***********************************************************************/ + + void GuiSharedSizeItemComposition::Update() + { + if (parentRoot) { - if (0 <= itemIndex && itemIndex < itemSource->GetCount()) - { - return ReadProperty(itemSource->Get(itemIndex), checkedProperty); - } + parentRoot->ForceCalculateSizeImmediately(); } - return false; + InvokeOnCompositionStateChanged(); } - - void GuiBindableTextList::ItemSource::SetChecked(vint itemIndex, bool value) + + void GuiSharedSizeItemComposition::OnParentLineChanged() { - if (itemSource) + GuiBoundsComposition::OnParentLineChanged(); + if (parentRoot) { - if (0 <= itemIndex && itemIndex < itemSource->GetCount()) + parentRoot->childItems.Remove(this); + parentRoot = 0; + } + + auto current = GetParent(); + while (current) + { + if (auto item = dynamic_cast(current)) { - auto thisValue = itemSource->Get(itemIndex); - WriteProperty(thisValue, checkedProperty, value); - InvokeOnItemModified(itemIndex, 1, 1); + break; } + else if (auto root = dynamic_cast(current)) + { + parentRoot = root; + break; + } + current = current->GetParent(); + } + + if (parentRoot) + { + parentRoot->childItems.Add(this); + } + } + + GuiSharedSizeItemComposition::GuiSharedSizeItemComposition() + :parentRoot(0) + , sharedWidth(false) + , sharedHeight(false) + { + SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + } + + GuiSharedSizeItemComposition::~GuiSharedSizeItemComposition() + { + } + + const WString& GuiSharedSizeItemComposition::GetGroup() + { + return group; + } + + void GuiSharedSizeItemComposition::SetGroup(const WString& value) + { + if (group != value) + { + group = value; + Update(); + } + } + + bool GuiSharedSizeItemComposition::GetSharedWidth() + { + return sharedWidth; + } + + void GuiSharedSizeItemComposition::SetSharedWidth(bool value) + { + if (sharedWidth != value) + { + sharedWidth = value; + Update(); + } + } + + bool GuiSharedSizeItemComposition::GetSharedHeight() + { + return sharedHeight; + } + + void GuiSharedSizeItemComposition::SetSharedHeight(bool value) + { + if (sharedHeight != value) + { + sharedHeight = value; + Update(); } } /*********************************************************************** -GuiBindableTextList +GuiSharedSizeRootComposition ***********************************************************************/ - GuiBindableTextList::GuiBindableTextList(IStyleProvider* _styleProvider) - :GuiVirtualTextList(_styleProvider, new ItemSource) - { - itemSource = dynamic_cast(GetItemProvider()); - - TextPropertyChanged.SetAssociatedComposition(boundsComposition); - TextPropertyChanged.SetAssociatedComposition(boundsComposition); - } - - GuiBindableTextList::~GuiBindableTextList() + GuiSharedSizeRootComposition::GuiSharedSizeRootComposition() { } - Ptr GuiBindableTextList::GetItemSource() - { - return itemSource->GetItemSource(); - } - - void GuiBindableTextList::SetItemSource(Ptr _itemSource) - { - itemSource->SetItemSource(_itemSource); - } - - ItemProperty GuiBindableTextList::GetTextProperty() - { - return itemSource->textProperty; - } - - void GuiBindableTextList::SetTextProperty(const ItemProperty& value) - { - if (itemSource->textProperty != value) - { - itemSource->textProperty = value; - itemSource->UpdateBindingProperties(); - TextPropertyChanged.Execute(GetNotifyEventArguments()); - } - } - - WritableItemProperty GuiBindableTextList::GetCheckedProperty() - { - return itemSource->checkedProperty; - } - - void GuiBindableTextList::SetCheckedProperty(const WritableItemProperty& value) - { - if (itemSource->checkedProperty != value) - { - itemSource->checkedProperty = value; - itemSource->UpdateBindingProperties(); - CheckedPropertyChanged.Execute(GetNotifyEventArguments()); - } - } - - description::Value GuiBindableTextList::GetSelectedItem() - { - vint index = GetSelectedItemIndex(); - if (index == -1) return Value(); - return itemSource->Get(index); - } - -/*********************************************************************** -GuiBindableListView::ItemSource -***********************************************************************/ - - GuiBindableListView::ItemSource::ItemSource() - :columns(this) - , dataColumns(this) + GuiSharedSizeRootComposition::~GuiSharedSizeRootComposition() { } - GuiBindableListView::ItemSource::~ItemSource() + void AddSizeComponent(Dictionary& sizes, const WString& group, vint sizeComponent) { - SetItemSource(nullptr); - } - - Ptr GuiBindableListView::ItemSource::GetItemSource() - { - return itemSource; - } - - void GuiBindableListView::ItemSource::SetItemSource(Ptr _itemSource) - { - vint oldCount = 0; - if (itemSource) - { - oldCount = itemSource->GetCount(); - } - if (itemChangedEventHandler) - { - auto ol = itemSource.Cast(); - ol->ItemChanged.Remove(itemChangedEventHandler); - } - - itemSource = nullptr; - itemChangedEventHandler = nullptr; - - if (_itemSource) - { - if (auto ol = _itemSource.Cast()) - { - itemSource = ol; - itemChangedEventHandler = ol->ItemChanged.Add([this](vint start, vint oldCount, vint newCount) - { - InvokeOnItemModified(start, oldCount, newCount); - }); - } - else if (auto rl = _itemSource.Cast()) - { - itemSource = rl; - } - else - { - itemSource = IValueList::Create(GetLazyList(_itemSource)); - } - } - - InvokeOnItemModified(0, oldCount, itemSource ? itemSource->GetCount() : 0); - } - - description::Value GuiBindableListView::ItemSource::Get(vint index) - { - if (!itemSource) return Value(); - return itemSource->Get(index); - } - - void GuiBindableListView::ItemSource::UpdateBindingProperties() - { - InvokeOnItemModified(0, Count(), Count()); - } - - bool GuiBindableListView::ItemSource::NotifyUpdate(vint start, vint count) - { - if (!itemSource) return false; - if (start<0 || start >= itemSource->GetCount() || count <= 0 || start + count > itemSource->GetCount()) - { - return false; - } - else - { - InvokeOnItemModified(start, count, count); - return true; - } - } - - list::ListViewDataColumns& GuiBindableListView::ItemSource::GetDataColumns() - { - return dataColumns; - } - - list::ListViewColumns& GuiBindableListView::ItemSource::GetColumns() - { - return columns; - } - - // ===================== list::IListViewItemProvider ===================== - - void GuiBindableListView::ItemSource::NotifyAllItemsUpdate() - { - NotifyUpdate(0, Count()); - } - - void GuiBindableListView::ItemSource::NotifyAllColumnsUpdate() - { - for (vint i = 0; i < columnItemViewCallbacks.Count(); i++) - { - columnItemViewCallbacks[i]->OnColumnChanged(); - } - } - - // ===================== GuiListControl::IItemProvider ===================== - - vint GuiBindableListView::ItemSource::Count() - { - if (!itemSource) return 0; - return itemSource->GetCount(); - } - - WString GuiBindableListView::ItemSource::GetTextValue(vint itemIndex) - { - return GetText(itemIndex); - } - - description::Value GuiBindableListView::ItemSource::GetBindingValue(vint itemIndex) - { - if (itemSource) - { - if (0 <= itemIndex && itemIndex < itemSource->GetCount()) - { - return itemSource->Get(itemIndex); - } - } - return Value(); - } - - IDescriptable* GuiBindableListView::ItemSource::RequestView(const WString& identifier) - { - if (identifier == IListViewItemView::Identifier) - { - return (IListViewItemView*)this; - } - else if (identifier == ListViewColumnItemArranger::IColumnItemView::Identifier) - { - return (ListViewColumnItemArranger::IColumnItemView*)this; - } - else - { - return 0; - } - } - - // ===================== list::ListViewItemStyleProvider::IListViewItemView ===================== - - Ptr GuiBindableListView::ItemSource::GetSmallImage(vint itemIndex) - { - if (itemSource) - { - if (0 <= itemIndex && itemIndex < itemSource->GetCount()) - { - return ReadProperty(itemSource->Get(itemIndex), smallImageProperty); - } - } - return nullptr; - } - - Ptr GuiBindableListView::ItemSource::GetLargeImage(vint itemIndex) - { - if (itemSource) - { - if (0 <= itemIndex && itemIndex < itemSource->GetCount()) - { - return ReadProperty(itemSource->Get(itemIndex), largeImageProperty); - } - } - return nullptr; - } - - WString GuiBindableListView::ItemSource::GetText(vint itemIndex) - { - if (itemSource) - { - if (0 <= itemIndex && itemIndex < itemSource->GetCount() && columns.Count()>0) - { - return ReadProperty(itemSource->Get(itemIndex), columns[0]->GetTextProperty()); - } - } - return L""; - } - - WString GuiBindableListView::ItemSource::GetSubItem(vint itemIndex, vint index) - { - if (itemSource) - { - if (0 <= itemIndex && itemIndex < itemSource->GetCount() && 0 <= index && index < columns.Count() - 1) - { - return ReadProperty(itemSource->Get(itemIndex), columns[index + 1]->GetTextProperty()); - } - } - return L""; - } - - vint GuiBindableListView::ItemSource::GetDataColumnCount() - { - return dataColumns.Count(); - } - - vint GuiBindableListView::ItemSource::GetDataColumn(vint index) - { - return dataColumns[index]; - } - - vint GuiBindableListView::ItemSource::GetColumnCount() - { - return columns.Count(); - } - - WString GuiBindableListView::ItemSource::GetColumnText(vint index) - { - if (index < 0 || index >= columns.Count()) - { - return L""; - } - else - { - return columns[index]->GetText(); - } - } - - // ===================== list::ListViewColumnItemArranger::IColumnItemView ===================== - - bool GuiBindableListView::ItemSource::AttachCallback(ListViewColumnItemArranger::IColumnItemViewCallback* value) - { - if(columnItemViewCallbacks.Contains(value)) - { - return false; - } - else - { - columnItemViewCallbacks.Add(value); - return true; - } - } - - bool GuiBindableListView::ItemSource::DetachCallback(ListViewColumnItemArranger::IColumnItemViewCallback* value) - { - vint index = columnItemViewCallbacks.IndexOf(value); + vint index = sizes.Keys().IndexOf(group); if (index == -1) { - return false; + sizes.Add(group, sizeComponent); } - else + else if (sizes.Values().Get(index) < sizeComponent) { - columnItemViewCallbacks.Remove(value); - return true; + sizes.Set(group, sizeComponent); } } - vint GuiBindableListView::ItemSource::GetColumnSize(vint index) + void GuiSharedSizeRootComposition::ForceCalculateSizeImmediately() { - if (index < 0 || index >= columns.Count()) - { - return 0; - } - else - { - return columns[index]->GetSize(); - } - } + Dictionary widths, heights; - void GuiBindableListView::ItemSource::SetColumnSize(vint index, vint value) - { - if (index >= 0 && index < columns.Count()) + FOREACH(GuiSharedSizeItemComposition*, item, childItems) { - columns[index]->SetSize(value); - } - } + auto group = item->GetGroup(); + auto minSize = item->GetPreferredMinSize(); + item->SetPreferredMinSize(Size(0, 0)); + auto size = item->GetPreferredBounds().GetSize(); - GuiMenu* GuiBindableListView::ItemSource::GetDropdownPopup(vint index) - { - if (index < 0 || index >= columns.Count()) - { - return 0; - } - else - { - return columns[index]->GetDropdownPopup(); - } - } + if (item->GetSharedWidth()) + { + AddSizeComponent(widths, group, size.x); + } + if (item->GetSharedHeight()) + { + AddSizeComponent(heights, group, size.y); + } - ColumnSortingState GuiBindableListView::ItemSource::GetSortingState(vint index) + item->SetPreferredMinSize(minSize); + } + + FOREACH(GuiSharedSizeItemComposition*, item, childItems) + { + auto group = item->GetGroup(); + auto size = item->GetPreferredMinSize(); + + if (item->GetSharedWidth()) + { + size.x = widths[group]; + } + if (item->GetSharedHeight()) + { + size.y = heights[group]; + } + + item->SetPreferredMinSize(size); + } + + GuiBoundsComposition::ForceCalculateSizeImmediately(); + } + } + } +} + +/*********************************************************************** +.\GRAPHICSCOMPOSITION\GUIGRAPHICSCOMPOSITIONBASE.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace compositions + { + using namespace collections; + using namespace controls; + using namespace elements; + + void InvokeOnCompositionStateChanged(compositions::GuiGraphicsComposition* composition) { - if (index < 0 || index >= columns.Count()) - { - return ColumnSortingState::NotSorted; - } - else - { - return columns[index]->GetSortingState(); - } + composition->InvokeOnCompositionStateChanged(); } /*********************************************************************** -GuiBindableListView +GuiGraphicsComposition ***********************************************************************/ - GuiBindableListView::GuiBindableListView(IStyleProvider* _styleProvider) - :GuiVirtualListView(_styleProvider, new ItemSource) + void GuiGraphicsComposition::OnControlParentChanged(controls::GuiControl* control) { - itemSource = dynamic_cast(GetItemProvider()); - - LargeImagePropertyChanged.SetAssociatedComposition(boundsComposition); - SmallImagePropertyChanged.SetAssociatedComposition(boundsComposition); - } - - GuiBindableListView::~GuiBindableListView() - { - } - - list::ListViewDataColumns& GuiBindableListView::GetDataColumns() - { - return itemSource->GetDataColumns(); - } - - list::ListViewColumns& GuiBindableListView::GetColumns() - { - return itemSource->GetColumns(); - } - - Ptr GuiBindableListView::GetItemSource() - { - return itemSource->GetItemSource(); - } - - void GuiBindableListView::SetItemSource(Ptr _itemSource) - { - itemSource->SetItemSource(_itemSource); - } - - ItemProperty> GuiBindableListView::GetLargeImageProperty() - { - return itemSource->largeImageProperty; - } - - void GuiBindableListView::SetLargeImageProperty(const ItemProperty>& value) - { - if (itemSource->largeImageProperty != value) + if(associatedControl && associatedControl!=control) { - itemSource->largeImageProperty = value; - itemSource->UpdateBindingProperties(); - LargeImagePropertyChanged.Execute(GetNotifyEventArguments()); - } - } - - ItemProperty> GuiBindableListView::GetSmallImageProperty() - { - return itemSource->smallImageProperty; - } - - void GuiBindableListView::SetSmallImageProperty(const ItemProperty>& value) - { - if (itemSource->smallImageProperty != value) - { - itemSource->smallImageProperty = value; - itemSource->UpdateBindingProperties(); - SmallImagePropertyChanged.Execute(GetNotifyEventArguments()); - } - } - - description::Value GuiBindableListView::GetSelectedItem() - { - vint index = GetSelectedItemIndex(); - if (index == -1) return Value(); - return itemSource->Get(index); - } - -/*********************************************************************** -GuiBindableTreeView::ItemSourceNode -***********************************************************************/ - - void GuiBindableTreeView::ItemSourceNode::PrepareChildren() - { - if (!childrenVirtualList) - { - if (auto value = ReadProperty(itemSource, rootProvider->childrenProperty)) + if(associatedControl->GetParent()) { - if (auto ol = value.Cast()) - { - itemChangedEventHandler = ol->ItemChanged.Add([this](vint start, vint oldCount, vint newCount) - { - callback->OnBeforeItemModified(this, start, oldCount, newCount); - children.RemoveRange(start, oldCount); - for (vint i = 0; i < newCount; i++) - { - Value value = childrenVirtualList->Get(start + i); - auto node = new ItemSourceNode(value, this); - children.Insert(start + i, node); - } - callback->OnAfterItemModified(this, start, oldCount, newCount); - }); - childrenVirtualList = ol; - } - else if (auto rl = value.Cast()) - { - childrenVirtualList = rl; - } - else - { - childrenVirtualList = IValueList::Create(GetLazyList(value)); - } + associatedControl->GetParent()->OnChildRemoved(associatedControl); } - - if (!childrenVirtualList) + if(control) { - childrenVirtualList = IValueList::Create(); + control->OnChildInserted(associatedControl); } - - vint count = childrenVirtualList->GetCount(); - for (vint i = 0; i < count; i++) + } + else + { + for(vint i=0;iGet(i); - auto node = new ItemSourceNode(value, this); - children.Add(node); + children[i]->OnControlParentChanged(control); } } } - void GuiBindableTreeView::ItemSourceNode::UnprepareChildren() + void GuiGraphicsComposition::OnChildInserted(GuiGraphicsComposition* child) { - if (itemChangedEventHandler) + child->OnControlParentChanged(GetRelatedControl()); + } + + void GuiGraphicsComposition::OnChildRemoved(GuiGraphicsComposition* child) + { + child->OnControlParentChanged(0); + } + + void GuiGraphicsComposition::OnParentChanged(GuiGraphicsComposition* oldParent, GuiGraphicsComposition* newParent) + { + OnParentLineChanged(); + } + + void GuiGraphicsComposition::OnParentLineChanged() + { + for (vint i = 0; i < children.Count(); i++) { - auto ol = childrenVirtualList.Cast(); - ol->ItemChanged.Remove(itemChangedEventHandler); - itemChangedEventHandler = nullptr; + children[i]->OnParentLineChanged(); } - childrenVirtualList = nullptr; - FOREACH(Ptr, node, children) + } + + void GuiGraphicsComposition::OnRenderContextChanged() + { + } + + void GuiGraphicsComposition::UpdateRelatedHostRecord(GraphicsHostRecord* record) + { + relatedHostRecord = record; + auto renderTarget = GetRenderTarget(); + + if (ownedElement) { - node->UnprepareChildren(); - } - children.Clear(); - } - - GuiBindableTreeView::ItemSourceNode::ItemSourceNode(const description::Value& _itemSource, ItemSourceNode* _parent) - :itemSource(_itemSource) - , rootProvider(_parent->rootProvider) - , parent(_parent) - , callback(_parent->callback) - { - } - - GuiBindableTreeView::ItemSourceNode::ItemSourceNode(ItemSource* _rootProvider) - :rootProvider(_rootProvider) - , parent(nullptr) - , callback(_rootProvider) - { - } - - GuiBindableTreeView::ItemSourceNode::~ItemSourceNode() - { - SetItemSource(Value()); - } - - description::Value GuiBindableTreeView::ItemSourceNode::GetItemSource() - { - return itemSource; - } - - void GuiBindableTreeView::ItemSourceNode::SetItemSource(const description::Value& _itemSource) - { - vint oldCount = GetChildCount(); - UnprepareChildren(); - itemSource = _itemSource; - vint newCount = GetChildCount(); - callback->OnBeforeItemModified(this, 0, oldCount, newCount); - callback->OnAfterItemModified(this, 0, oldCount, newCount); - } - - bool GuiBindableTreeView::ItemSourceNode::GetExpanding() - { - return this == rootProvider->rootNode.Obj() ? true : expanding; - } - - void GuiBindableTreeView::ItemSourceNode::SetExpanding(bool value) - { - if (this != rootProvider->rootNode.Obj() && expanding != value) - { - expanding = value; - if (expanding) + if (auto renderer = ownedElement->GetRenderer()) { - callback->OnItemExpanded(this); + renderer->SetRenderTarget(renderTarget); } - else + } + + for (vint i = 0; i < children.Count(); i++) + { + children[i]->UpdateRelatedHostRecord(record); + } + + if (HasEventReceiver()) + { + GetEventReceiver()->renderTargetChanged.Execute(GuiEventArgs(this)); + } + if (associatedControl) + { + associatedControl->OnRenderTargetChanged(renderTarget); + } + + OnRenderContextChanged(); + } + + void GuiGraphicsComposition::SetAssociatedControl(controls::GuiControl* control) + { + if (associatedControl) + { + for (vint i = 0; i < children.Count(); i++) { - callback->OnItemCollapsed(this); + children[i]->OnControlParentChanged(0); + } + } + associatedControl = control; + if (associatedControl) + { + for (vint i = 0; i < children.Count(); i++) + { + children[i]->OnControlParentChanged(associatedControl); } } } - vint GuiBindableTreeView::ItemSourceNode::CalculateTotalVisibleNodes() + void GuiGraphicsComposition::InvokeOnCompositionStateChanged() { - if (!GetExpanding()) + if (relatedHostRecord) { - return 1; + relatedHostRecord->host->RequestRender(); } - - PrepareChildren(); - vint count = 1; - FOREACH(Ptr, child, children) - { - count += child->CalculateTotalVisibleNodes(); - } - return count; } - vint GuiBindableTreeView::ItemSourceNode::GetChildCount() + bool GuiGraphicsComposition::SharedPtrDestructorProc(DescriptableObject* obj, bool forceDisposing) { - PrepareChildren(); - return children.Count(); + GuiGraphicsComposition* value=dynamic_cast(obj); + if(value->parent) + { + if (!forceDisposing) return false; + } + SafeDeleteComposition(value); + return true; } - tree::INodeProvider* GuiBindableTreeView::ItemSourceNode::GetParent() + GuiGraphicsComposition::GuiGraphicsComposition() + :visible(true) + ,minSizeLimitation(NoLimit) + ,associatedHitTestResult(INativeWindowListener::NoDecision) + { + sharedPtrDestructorProc = &GuiGraphicsComposition::SharedPtrDestructorProc; + } + + GuiGraphicsComposition::~GuiGraphicsComposition() + { + for(vint i=0;iGetParent()) return false; + children.Insert(index, child); + + // composition parent changed -> control parent changed -> related host changed + child->parent = this; + child->OnParentChanged(nullptr, this); + OnChildInserted(child); + child->UpdateRelatedHostRecord(relatedHostRecord); + + InvokeOnCompositionStateChanged(); + return true; + } + + bool GuiGraphicsComposition::RemoveChild(GuiGraphicsComposition* child) + { + if (!child) return false; + vint index = children.IndexOf(child); + if (index == -1) return false; + + // composition parent changed -> control parent changed -> related host changed + child->parent = nullptr; + child->OnParentChanged(this, nullptr); + OnChildRemoved(child); + child->UpdateRelatedHostRecord(nullptr); + + GuiGraphicsHost* host = GetRelatedGraphicsHost(); + if (host) { - return children[index].Obj(); + host->DisconnectComposition(child); } - return 0; + children.RemoveAt(index); + InvokeOnCompositionStateChanged(); + return true; } - void GuiBindableTreeView::ItemSourceNode::Increase() + bool GuiGraphicsComposition::MoveChild(GuiGraphicsComposition* child, vint newIndex) { + if(!child) return false; + vint index=children.IndexOf(child); + if(index==-1) return false; + children.RemoveAt(index); + children.Insert(newIndex, child); + InvokeOnCompositionStateChanged(); + return true; } - void GuiBindableTreeView::ItemSourceNode::Release() + Ptr GuiGraphicsComposition::GetOwnedElement() { + return ownedElement; } -/*********************************************************************** -GuiBindableTreeView::ItemSource -***********************************************************************/ - - GuiBindableTreeView::ItemSource::ItemSource() + void GuiGraphicsComposition::SetOwnedElement(Ptr element) { - rootNode = new ItemSourceNode(this); - } - - GuiBindableTreeView::ItemSource::~ItemSource() - { - } - - description::Value GuiBindableTreeView::ItemSource::GetItemSource() - { - return rootNode->GetItemSource(); - } - - void GuiBindableTreeView::ItemSource::SetItemSource(const description::Value& _itemSource) - { - rootNode->SetItemSource(_itemSource); - } - - void GuiBindableTreeView::ItemSource::UpdateBindingProperties(bool updateChildrenProperty) - { - vint oldCount = rootNode->GetChildCount(); - if (updateChildrenProperty) + if (ownedElement != element) { - rootNode->UnprepareChildren(); + if (ownedElement) + { + if (auto renderer = ownedElement->GetRenderer()) + { + renderer->SetRenderTarget(nullptr); + } + ownedElement->SetOwnerComposition(nullptr); + } + ownedElement = element; + if (ownedElement) + { + if (auto renderer = ownedElement->GetRenderer()) + { + renderer->SetRenderTarget(GetRenderTarget()); + } + ownedElement->SetOwnerComposition(this); + } + InvokeOnCompositionStateChanged(); } - vint newCount = rootNode->GetChildCount(); - OnBeforeItemModified(rootNode.Obj(), 0, oldCount, newCount); - OnAfterItemModified(rootNode.Obj(), 0, oldCount, newCount); } - // ===================== tree::INodeRootProvider ===================== - - tree::INodeProvider* GuiBindableTreeView::ItemSource::GetRootNode() + bool GuiGraphicsComposition::GetVisible() { - return rootNode.Obj(); + return visible; } - WString GuiBindableTreeView::ItemSource::GetTextValue(tree::INodeProvider* node) + void GuiGraphicsComposition::SetVisible(bool value) { - return ReadProperty(GetBindingValue(node), textProperty); + visible = value; + InvokeOnCompositionStateChanged(); } - description::Value GuiBindableTreeView::ItemSource::GetBindingValue(tree::INodeProvider* node) + GuiGraphicsComposition::MinSizeLimitation GuiGraphicsComposition::GetMinSizeLimitation() { - if (auto itemSourceNode = dynamic_cast(node)) + return minSizeLimitation; + } + + void GuiGraphicsComposition::SetMinSizeLimitation(MinSizeLimitation value) + { + minSizeLimitation = value; + InvokeOnCompositionStateChanged(); + } + + elements::IGuiGraphicsRenderTarget* GuiGraphicsComposition::GetRenderTarget() + { + return relatedHostRecord ? relatedHostRecord->renderTarget : nullptr; + } + + void GuiGraphicsComposition::Render(Size offset) + { + auto renderTarget = GetRenderTarget(); + if (visible && renderTarget && !renderTarget->IsClipperCoverWholeTarget()) { - return itemSourceNode->GetItemSource(); + Rect bounds = GetBounds(); + bounds.x1 += margin.left; + bounds.y1 += margin.top; + bounds.x2 -= margin.right; + bounds.y2 -= margin.bottom; + + if (bounds.x1 <= bounds.x2 && bounds.y1 <= bounds.y2) + { + bounds.x1 += offset.x; + bounds.x2 += offset.x; + bounds.y1 += offset.y; + bounds.y2 += offset.y; + + if (ownedElement) + { + IGuiGraphicsRenderer* renderer = ownedElement->GetRenderer(); + if (renderer) + { + renderer->Render(bounds); + } + } + if (children.Count() > 0) + { + bounds.x1 += internalMargin.left; + bounds.y1 += internalMargin.top; + bounds.x2 -= internalMargin.right; + bounds.y2 -= internalMargin.bottom; + if (bounds.x1 <= bounds.x2 && bounds.y1 <= bounds.y2) + { + offset = bounds.GetSize(); + renderTarget->PushClipper(bounds); + if (!renderTarget->IsClipperCoverWholeTarget()) + { + for (vint i = 0; i < children.Count(); i++) + { + children[i]->Render(Size(bounds.x1, bounds.y1)); + } + } + renderTarget->PopClipper(); + } + } + } } - return Value(); } - IDescriptable* GuiBindableTreeView::ItemSource::RequestView(const WString& identifier) + GuiGraphicsEventReceiver* GuiGraphicsComposition::GetEventReceiver() { - if(identifier==ITreeViewItemView::Identifier) + if(!eventReceiver) { - return (ITreeViewItemView*)this; + eventReceiver=new GuiGraphicsEventReceiver(this); + } + return eventReceiver.Obj(); + } + + bool GuiGraphicsComposition::HasEventReceiver() + { + return eventReceiver; + } + + GuiGraphicsComposition* GuiGraphicsComposition::FindComposition(Point location) + { + if (!visible) return 0; + Rect bounds = GetBounds(); + Rect relativeBounds = Rect(Point(0, 0), bounds.GetSize()); + if (relativeBounds.Contains(location)) + { + Rect clientArea = GetClientArea(); + for (vint i = children.Count() - 1; i >= 0; i--) + { + GuiGraphicsComposition* child = children[i]; + Rect childBounds = child->GetBounds(); + vint offsetX = childBounds.x1 + (clientArea.x1 - bounds.x1); + vint offsetY = childBounds.y1 + (clientArea.y1 - bounds.y1); + Point newLocation = location - Size(offsetX, offsetY); + GuiGraphicsComposition* childResult = child->FindComposition(newLocation); + if (childResult) + { + return childResult; + } + } + return this; } else { @@ -6338,2302 +8177,737 @@ GuiBindableTreeView::ItemSource } } - // ===================== tree::ITreeViewItemView ===================== - - Ptr GuiBindableTreeView::ItemSource::GetNodeImage(tree::INodeProvider* node) + Rect GuiGraphicsComposition::GetGlobalBounds() { - if (auto itemSourceNode = dynamic_cast(node)) + Rect bounds = GetBounds(); + GuiGraphicsComposition* composition = parent; + while (composition) { - return ReadProperty(itemSourceNode->GetItemSource(), imageProperty); + Rect clientArea = composition->GetClientArea(); + Rect parentBounds = composition->GetBounds(); + bounds.x1 += clientArea.x1; + bounds.x2 += clientArea.x1; + bounds.y1 += clientArea.y1; + bounds.y2 += clientArea.y1; + composition = composition->parent; + } + return bounds; + } + + controls::GuiControl* GuiGraphicsComposition::GetAssociatedControl() + { + return associatedControl; + } + + GuiGraphicsHost* GuiGraphicsComposition::GetAssociatedHost() + { + if (relatedHostRecord && relatedHostRecord->host->GetMainComposition() == this) + { + return relatedHostRecord->host; + } + else + { + return nullptr; + } + } + + INativeCursor* GuiGraphicsComposition::GetAssociatedCursor() + { + return associatedCursor; + } + + void GuiGraphicsComposition::SetAssociatedCursor(INativeCursor* cursor) + { + associatedCursor = cursor; + } + + INativeWindowListener::HitTestResult GuiGraphicsComposition::GetAssociatedHitTestResult() + { + return associatedHitTestResult; + } + + void GuiGraphicsComposition::SetAssociatedHitTestResult(INativeWindowListener::HitTestResult value) + { + associatedHitTestResult = value; + } + + controls::GuiControl* GuiGraphicsComposition::GetRelatedControl() + { + GuiGraphicsComposition* composition = this; + while (composition) + { + if (composition->GetAssociatedControl()) + { + return composition->GetAssociatedControl(); + } + else + { + composition = composition->GetParent(); + } } return nullptr; } -/*********************************************************************** -GuiBindableTreeView -***********************************************************************/ - - GuiBindableTreeView::GuiBindableTreeView(IStyleProvider* _styleProvider) - :GuiVirtualTreeView(_styleProvider, new ItemSource) + GuiGraphicsHost* GuiGraphicsComposition::GetRelatedGraphicsHost() { - itemSource = dynamic_cast(GetNodeRootProvider()); - - TextPropertyChanged.SetAssociatedComposition(boundsComposition); - ImagePropertyChanged.SetAssociatedComposition(boundsComposition); - ChildrenPropertyChanged.SetAssociatedComposition(boundsComposition); + return relatedHostRecord ? relatedHostRecord->host : nullptr; } - GuiBindableTreeView::~GuiBindableTreeView() + controls::GuiControlHost* GuiGraphicsComposition::GetRelatedControlHost() { - } - - description::Value GuiBindableTreeView::GetItemSource() - { - return itemSource->GetItemSource(); - } - - void GuiBindableTreeView::SetItemSource(description::Value _itemSource) - { - itemSource->SetItemSource(_itemSource); - } - - ItemProperty GuiBindableTreeView::GetTextProperty() - { - return itemSource->textProperty; - } - - void GuiBindableTreeView::SetTextProperty(const ItemProperty& value) - { - if (itemSource->textProperty != value) + if (auto control = GetRelatedControl()) { - itemSource->textProperty = value; - itemSource->UpdateBindingProperties(false); - TextPropertyChanged.Execute(GetNotifyEventArguments()); + return control->GetRelatedControlHost(); } + return nullptr; } - ItemProperty> GuiBindableTreeView::GetImageProperty() + INativeCursor* GuiGraphicsComposition::GetRelatedCursor() { - return itemSource->imageProperty; - } - - void GuiBindableTreeView::SetImageProperty(const ItemProperty>& value) - { - if (itemSource->imageProperty != value) + GuiGraphicsComposition* composition = this; + while (composition) { - itemSource->imageProperty = value; - itemSource->UpdateBindingProperties(false); - ImagePropertyChanged.Execute(GetNotifyEventArguments()); - } - } - - ItemProperty> GuiBindableTreeView::GetChildrenProperty() - { - return itemSource->childrenProperty; - } - - void GuiBindableTreeView::SetChildrenProperty(const ItemProperty>& value) - { - if (itemSource->childrenProperty != value) - { - itemSource->childrenProperty = value; - itemSource->UpdateBindingProperties(true); - ChildrenPropertyChanged.Execute(GetNotifyEventArguments()); - } - } - - description::Value GuiBindableTreeView::GetSelectedItem() - { - vint index = GetSelectedItemIndex(); - if (index == -1) return Value(); - - Value result; - if (auto node = nodeItemView->RequestNode(index)) - { - if (auto itemSourceNode = dynamic_cast(node)) + if (composition->GetAssociatedCursor()) { - result = itemSourceNode->GetItemSource(); + return composition->GetAssociatedCursor(); + } + else + { + composition = composition->GetParent(); } - nodeItemView->ReleaseNode(node); } - return result; - } - } - } -} - -/*********************************************************************** -CONTROLS\LISTCONTROLPACKAGE\GUICOMBOCONTROLS.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace controls - { - -/*********************************************************************** -GuiComboBoxBase::CommandExecutor -***********************************************************************/ - - GuiComboBoxBase::CommandExecutor::CommandExecutor(GuiComboBoxBase* _combo) - :combo(_combo) - { + return nullptr; } - GuiComboBoxBase::CommandExecutor::~CommandExecutor() + Margin GuiGraphicsComposition::GetMargin() { + return margin; } - void GuiComboBoxBase::CommandExecutor::SelectItem() + void GuiGraphicsComposition::SetMargin(Margin value) { - combo->SelectItem(); + margin = value; + InvokeOnCompositionStateChanged(); + } + + Margin GuiGraphicsComposition::GetInternalMargin() + { + return internalMargin; + } + + void GuiGraphicsComposition::SetInternalMargin(Margin value) + { + internalMargin = value; + InvokeOnCompositionStateChanged(); + } + + Size GuiGraphicsComposition::GetPreferredMinSize() + { + return preferredMinSize; + } + + void GuiGraphicsComposition::SetPreferredMinSize(Size value) + { + preferredMinSize = value; + InvokeOnCompositionStateChanged(); + } + + Rect GuiGraphicsComposition::GetClientArea() + { + Rect bounds=GetBounds(); + bounds.x1+=margin.left+internalMargin.left; + bounds.y1+=margin.top+internalMargin.top; + bounds.x2-=margin.right+internalMargin.right; + bounds.y2-=margin.bottom+internalMargin.bottom; + return bounds; + } + + void GuiGraphicsComposition::ForceCalculateSizeImmediately() + { + for (vint i = 0; i < children.Count(); i++) + { + children[i]->ForceCalculateSizeImmediately(); + } + InvokeOnCompositionStateChanged(); } /*********************************************************************** -GuiComboBoxBase +GuiGraphicsSite ***********************************************************************/ - bool GuiComboBoxBase::IsAltAvailable() + Rect GuiGraphicsSite::GetBoundsInternal(Rect expectedBounds) { - return false; + Size minSize = GetMinPreferredClientSize(); + if (minSize.x < preferredMinSize.x) minSize.x = preferredMinSize.x; + if (minSize.y < preferredMinSize.y) minSize.y = preferredMinSize.y; + + minSize.x += margin.left + margin.right + internalMargin.left + internalMargin.right; + minSize.y += margin.top + margin.bottom + internalMargin.top + internalMargin.bottom; + vint w = expectedBounds.Width(); + vint h = expectedBounds.Height(); + if (minSize.x < w) minSize.x = w; + if (minSize.y < h) minSize.y = h; + return Rect(expectedBounds.LeftTop(), minSize); } - IGuiMenuService::Direction GuiComboBoxBase::GetSubMenuDirection() + void GuiGraphicsSite::UpdatePreviousBounds(Rect bounds) { - return IGuiMenuService::Horizontal; + if (previousBounds != bounds) + { + previousBounds = bounds; + BoundsChanged.Execute(GuiEventArgs(this)); + InvokeOnCompositionStateChanged(); + } } - void GuiComboBoxBase::SelectItem() + GuiGraphicsSite::GuiGraphicsSite() { - styleController->OnItemSelected(); - ItemSelected.Execute(GetNotifyEventArguments()); + BoundsChanged.SetAssociatedComposition(this); } - void GuiComboBoxBase::OnBoundsChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - Size size=GetPreferredMenuClientSize(); - size.x=GetBoundsComposition()->GetBounds().Width(); - SetPreferredMenuClientSize(size); - } - - GuiComboBoxBase::GuiComboBoxBase(IStyleController* _styleController) - :GuiMenuButton(_styleController) - { - commandExecutor=new CommandExecutor(this); - styleController=dynamic_cast(GetStyleController()); - styleController->SetCommandExecutor(commandExecutor.Obj()); - - CreateSubMenu(); - SetCascadeAction(false); - - GetBoundsComposition()->BoundsChanged.AttachMethod(this, &GuiComboBoxBase::OnBoundsChanged); - } - - GuiComboBoxBase::~GuiComboBoxBase() + GuiGraphicsSite::~GuiGraphicsSite() { } -/*********************************************************************** -GuiComboBoxListControl -***********************************************************************/ - - bool GuiComboBoxListControl::IsAltAvailable() + bool GuiGraphicsSite::IsSizeAffectParent() { return true; } - void GuiComboBoxListControl::OnActiveAlt() + Size GuiGraphicsSite::GetMinPreferredClientSize() { - GuiMenuButton::OnActiveAlt(); - GetSubMenu()->GetNativeWindow()->SetFocus(); - containedListControl->SetFocus(); - } - - void GuiComboBoxListControl::RemoveStyleController() - { - if (itemStyleController) + Size minSize; + if (minSizeLimitation != GuiGraphicsComposition::NoLimit) { - SafeDeleteComposition(itemStyleController); - itemStyleController = nullptr; - } - } - - void GuiComboBoxListControl::InstallStyleController(vint itemIndex) - { - if (itemStyleProperty) - { - if (itemIndex != -1) + if (ownedElement) { - auto item = containedListControl->GetItemProvider()->GetBindingValue(itemIndex); - if (!item.IsNull()) + IGuiGraphicsRenderer* renderer = ownedElement->GetRenderer(); + if (renderer) { - if (auto style = itemStyleProperty(item)) - { - itemStyleController = style; - itemStyleController->SetText(GetText()); - itemStyleController->SetFont(GetFont()); - itemStyleController->SetVisuallyEnabled(GetVisuallyEnabled()); - itemStyleController->SetAlignmentToParent(Margin(0, 0, 0, 0)); - GetContainerComposition()->AddChild(itemStyleController); - } + minSize = renderer->GetMinSize(); } } } - } - - void GuiComboBoxListControl::DisplaySelectedContent(vint itemIndex) - { - if(itemIndex==-1) + if (minSizeLimitation == GuiGraphicsComposition::LimitToElementAndChildren) { - SetText(L""); - } - else - { - WString text = containedListControl->GetItemProvider()->GetTextValue(itemIndex); - SetText(text); - GetSubMenu()->Hide(); - } - - RemoveStyleController(); - InstallStyleController(itemIndex); - } - - void GuiComboBoxListControl::OnTextChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if (itemStyleController) - { - itemStyleController->SetText(GetText()); - } - } - - void GuiComboBoxListControl::OnFontChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if (itemStyleController) - { - itemStyleController->SetFont(GetFont()); - } - auto args = GetNotifyEventArguments(); - OnListControlAdoptedSizeInvalidated(nullptr, args); - } - - void GuiComboBoxListControl::OnVisuallyEnabledChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if (itemStyleController) - { - itemStyleController->SetVisuallyEnabled(GetVisuallyEnabled()); - } - } - - void GuiComboBoxListControl::OnListControlAdoptedSizeInvalidated(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - Size expectedSize(0, GetFont().size * 20); - Size adoptedSize = containedListControl->GetAdoptedSize(expectedSize); - - Size clientSize = GetPreferredMenuClientSize(); - clientSize.y = adoptedSize.y + GetSubMenu()->GetClientSize().y - containedListControl->GetBoundsComposition()->GetBounds().Height(); - SetPreferredMenuClientSize(clientSize); - - if (GetSubMenuOpening()) - { - GetSubMenu()->SetClientSize(clientSize); - } - } - - void GuiComboBoxListControl::OnListControlSelectionChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - DisplaySelectedContent(GetSelectedIndex()); - SelectItem(); - SelectedIndexChanged.Execute(GetNotifyEventArguments()); - } - - GuiComboBoxListControl::GuiComboBoxListControl(IStyleController* _styleController, GuiSelectableListControl* _containedListControl) - :GuiComboBoxBase(_styleController) - , styleController(_styleController) - , containedListControl(_containedListControl) - { - styleController->SetTextVisible(true); - TextChanged.AttachMethod(this, &GuiComboBoxListControl::OnTextChanged); - FontChanged.AttachMethod(this, &GuiComboBoxListControl::OnFontChanged); - VisuallyEnabledChanged.AttachMethod(this, &GuiComboBoxListControl::OnVisuallyEnabledChanged); - - containedListControl->SetMultiSelect(false); - containedListControl->AdoptedSizeInvalidated.AttachMethod(this, &GuiComboBoxListControl::OnListControlAdoptedSizeInvalidated); - containedListControl->SelectionChanged.AttachMethod(this, &GuiComboBoxListControl::OnListControlSelectionChanged); - - auto itemProvider = containedListControl->GetItemProvider(); - - SelectedIndexChanged.SetAssociatedComposition(GetBoundsComposition()); - - containedListControl->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); - GetSubMenu()->GetContainerComposition()->AddChild(containedListControl->GetBoundsComposition()); - SetFont(GetFont()); - } - - GuiComboBoxListControl::~GuiComboBoxListControl() - { - } - - GuiSelectableListControl* GuiComboBoxListControl::GetContainedListControl() - { - return containedListControl; - } - - GuiComboBoxListControl::ItemStyleProperty GuiComboBoxListControl::GetItemTemplate() - { - return itemStyleProperty; - } - - void GuiComboBoxListControl::SetItemTemplate(ItemStyleProperty value) - { - RemoveStyleController(); - itemStyleProperty = value; - styleController->SetTextVisible(!itemStyleProperty); - InstallStyleController(GetSelectedIndex()); - ItemTemplateChanged.Execute(GetNotifyEventArguments()); - } - - vint GuiComboBoxListControl::GetSelectedIndex() - { - if(containedListControl->GetSelectedItems().Count()==1) - { - return containedListControl->GetSelectedItems()[0]; - } - else - { - return -1; - } - } - - void GuiComboBoxListControl::SetSelectedIndex(vint value) - { - containedListControl->SetSelected(value, true); - } - - description::Value GuiComboBoxListControl::GetSelectedItem() - { - auto selectedIndex = GetSelectedIndex(); - if (selectedIndex != -1) - { - return containedListControl->GetItemProvider()->GetBindingValue(selectedIndex); - } - return description::Value(); - } - - GuiListControl::IItemProvider* GuiComboBoxListControl::GetItemProvider() - { - return containedListControl->GetItemProvider(); - } - } - } -} - -/*********************************************************************** -CONTROLS\LISTCONTROLPACKAGE\GUIDATAGRIDCONTROLS.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace controls - { - namespace list - { - using namespace compositions; - using namespace collections; - using namespace description; - using namespace templates; - - const wchar_t* const IDataGridView::Identifier = L"vl::presentation::controls::list::IDataGridView"; - -/*********************************************************************** -DefaultDataGridItemTemplate -***********************************************************************/ - - IDataVisualizerFactory* DefaultDataGridItemTemplate::GetDataVisualizerFactory(vint row, vint column) - { - if (auto dataGrid = dynamic_cast(listControl)) + vint childCount = Children().Count(); + for (vint i = 0; i < childCount; i++) { - if (auto factory = dataGrid->dataGridView->GetCellDataVisualizerFactory(row, column)) + GuiGraphicsComposition* child = children[i]; + if (child->IsSizeAffectParent()) { - return factory; + Rect childBounds = child->GetPreferredBounds(); + if (minSize.x < childBounds.x2) minSize.x = childBounds.x2; + if (minSize.y < childBounds.y2) minSize.y = childBounds.y2; } + } + } + return minSize; + } - if (column == 0) + Rect GuiGraphicsSite::GetPreferredBounds() + { + return GetBoundsInternal(Rect(Point(0, 0), GetMinPreferredClientSize())); + } + +/*********************************************************************** +Helper Functions +***********************************************************************/ + + void NotifyFinalizeInstance(controls::GuiControl* value) + { + if (value) + { + NotifyFinalizeInstance(value->GetBoundsComposition()); + } + } + + void NotifyFinalizeInstance(GuiGraphicsComposition* value) + { + if (value) + { + bool finalized = false; + if (auto root = dynamic_cast(value)) + { + if (root->IsFinalized()) { - return dataGrid->defaultMainColumnVisualizerFactory.Obj(); + finalized = true; } else { - return dataGrid->defaultSubColumnVisualizerFactory.Obj(); - } - - } - - return nullptr; - } - - IDataEditorFactory* DefaultDataGridItemTemplate::GetDataEditorFactory(vint row, vint column) - { - if (auto dataGrid = dynamic_cast(listControl)) - { - return dataGrid->dataGridView->GetCellDataEditorFactory(row, column); - } - return nullptr; - } - - vint DefaultDataGridItemTemplate::GetCellColumnIndex(compositions::GuiGraphicsComposition* composition) - { - for (vint i = 0; i < textTable->GetColumns(); i++) - { - auto cell = textTable->GetSitedCell(0, i); - if (composition == cell) - { - return i; + root->FinalizeInstance(); } } - return -1; - } - void DefaultDataGridItemTemplate::OnCellButtonUp(compositions::GuiGraphicsComposition* sender, bool openEditor) - { - if (auto dataGrid = dynamic_cast(listControl)) + if (auto control = value->GetAssociatedControl()) { - vint index = GetCellColumnIndex(sender); - if (index != -1) + if (auto root = dynamic_cast(control)) { - if (currentEditor && dataGrid->GetSelectedCell().column == index) + if (root->IsFinalized()) { - return; - } - - vint currentRow = GetIndex(); - dataGrid->StartEdit(currentRow, index); - } - } - } - - bool DefaultDataGridItemTemplate::IsInEditor(compositions::GuiMouseEventArgs& arguments) - { - if (auto dataGrid = dynamic_cast(listControl)) - { - if (!dataGrid->currentEditor) return false; - auto editorComposition = dataGrid->currentEditor->GetTemplate(); - auto currentComposition = arguments.eventSource; - - while (currentComposition) - { - if (currentComposition == editorComposition) - { - arguments.handled = true; - return true; - } - else if (currentComposition == this) - { - break; + finalized = true; } else { - currentComposition = currentComposition->GetParent(); - } - } - - } - return false; - } - - void DefaultDataGridItemTemplate::OnCellButtonDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) - { - IsInEditor(arguments); - } - - void DefaultDataGridItemTemplate::OnCellLeftButtonUp(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) - { - if (auto dataGrid = dynamic_cast(listControl)) - { - if (!IsInEditor(arguments)) - { - if (dataGrid->GetVisuallyEnabled()) - { - OnCellButtonUp(sender, true); - } - } - } - } - - void DefaultDataGridItemTemplate::OnCellRightButtonUp(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) - { - if (auto dataGrid = dynamic_cast(listControl)) - { - if (!IsInEditor(arguments)) - { - if (dataGrid->GetVisuallyEnabled()) - { - OnCellButtonUp(sender, false); - } - } - } - } - - void DefaultDataGridItemTemplate::OnColumnChanged() - { - UpdateSubItemSize(); - } - - void DefaultDataGridItemTemplate::OnInitialize() - { - DefaultListViewItemTemplate::OnInitialize(); - { - textTable = new GuiTableComposition; - textTable->SetAlignmentToParent(Margin(0, 0, 0, 0)); - textTable->SetRowsAndColumns(1, 1); - textTable->SetRowOption(0, GuiCellOption::MinSizeOption()); - textTable->SetColumnOption(0, GuiCellOption::AbsoluteOption(0)); - AddChild(textTable); - } - - if (auto dataGrid = dynamic_cast(listControl)) - { - vint columnCount = dataGrid->listViewItemView->GetColumnCount(); - vint itemIndex = GetIndex(); - - dataVisualizers.Resize(columnCount); - for (vint i = 0; i < dataVisualizers.Count(); i++) - { - auto factory = GetDataVisualizerFactory(itemIndex, i); - dataVisualizers[i] = factory->CreateVisualizer(dataGrid); - } - - textTable->SetRowsAndColumns(1, columnCount); - for (vint i = 0; i < columnCount; i++) - { - auto cell = new GuiCellComposition; - textTable->AddChild(cell); - cell->SetSite(0, i, 1, 1); - cell->GetEventReceiver()->leftButtonDown.AttachMethod(this, &DefaultDataGridItemTemplate::OnCellButtonDown); - cell->GetEventReceiver()->rightButtonDown.AttachMethod(this, &DefaultDataGridItemTemplate::OnCellButtonDown); - cell->GetEventReceiver()->leftButtonUp.AttachMethod(this, &DefaultDataGridItemTemplate::OnCellLeftButtonUp); - cell->GetEventReceiver()->rightButtonUp.AttachMethod(this, &DefaultDataGridItemTemplate::OnCellRightButtonUp); - - auto composition = dataVisualizers[i]->GetTemplate(); - composition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - cell->AddChild(composition); - } - - for (vint i = 0; i < dataVisualizers.Count(); i++) - { - dataVisualizers[i]->BeforeVisualizeCell(dataGrid->GetItemProvider(), itemIndex, i); - } - - GridPos selectedCell = dataGrid->GetSelectedCell(); - if (selectedCell.row == itemIndex) - { - NotifySelectCell(selectedCell.column); - } - else - { - NotifySelectCell(-1); - } - UpdateSubItemSize(); - } - - SelectedChanged.AttachMethod(this, &DefaultDataGridItemTemplate::OnSelectedChanged); - FontChanged.AttachMethod(this, &DefaultDataGridItemTemplate::OnFontChanged); - - SelectedChanged.Execute(compositions::GuiEventArgs(this)); - FontChanged.Execute(compositions::GuiEventArgs(this)); - } - - void DefaultDataGridItemTemplate::OnSelectedChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if (!GetSelected()) - { - NotifySelectCell(-1); - } - } - - void DefaultDataGridItemTemplate::OnFontChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - FOREACH(Ptr, visualizer, dataVisualizers) - { - visualizer->GetTemplate()->SetFont(GetFont()); - } - if (currentEditor) - { - currentEditor->GetTemplate()->SetFont(GetFont()); - } - } - - DefaultDataGridItemTemplate::DefaultDataGridItemTemplate() - { - } - - DefaultDataGridItemTemplate::~DefaultDataGridItemTemplate() - { - FOREACH(Ptr, visualizer, dataVisualizers) - { - visualizer->NotifyDeletedTemplate(); - } - if (currentEditor) - { - currentEditor->NotifyDeletedTemplate(); - } - } - - void DefaultDataGridItemTemplate::UpdateSubItemSize() - { - if (auto dataGrid = dynamic_cast(listControl)) - { - vint columnCount = dataGrid->listViewItemView->GetColumnCount(); - if (columnCount > textTable->GetColumns()) - { - columnCount = textTable->GetColumns(); - } - for (vint i = 0; i < columnCount; i++) - { - textTable->SetColumnOption(i, GuiCellOption::AbsoluteOption(dataGrid->columnItemView->GetColumnSize(i))); - } - textTable->UpdateCellBounds(); - } - } - - bool DefaultDataGridItemTemplate::IsEditorOpened() - { - return currentEditor != nullptr; - } - - void DefaultDataGridItemTemplate::NotifyOpenEditor(vint column, IDataEditor* editor) - { - currentEditor = editor; - if (currentEditor) - { - auto cell = textTable->GetSitedCell(0, column); - auto* editorBounds = currentEditor->GetTemplate(); - if (editorBounds->GetParent() && editorBounds->GetParent() != cell) - { - editorBounds->GetParent()->RemoveChild(editorBounds); - } - editorBounds->SetAlignmentToParent(Margin(0, 0, 0, 0)); - cell->AddChild(editorBounds); - if (auto focusControl = currentEditor->GetTemplate()->GetFocusControl()) - { - focusControl->SetFocus(); - } - } - } - - void DefaultDataGridItemTemplate::NotifyCloseEditor() - { - if (currentEditor) - { - auto composition = currentEditor->GetTemplate(); - if (composition->GetParent()) - { - composition->GetParent()->RemoveChild(composition); - } - currentEditor = nullptr; - } - } - - void DefaultDataGridItemTemplate::NotifySelectCell(vint column) - { - for (vint i = 0; i < dataVisualizers.Count(); i++) - { - dataVisualizers[i]->SetSelected(i == column); - } - } - - void DefaultDataGridItemTemplate::NotifyCellEdited() - { - for (vint i = 0; i < dataVisualizers.Count(); i++) - { - dataVisualizers[i]->BeforeVisualizeCell(listControl->GetItemProvider(), GetIndex(), i); - } - } - } - -/*********************************************************************** -GuiVirtualDataGrid (Editor) -***********************************************************************/ - - using namespace list; - - void GuiVirtualDataGrid::OnItemModified(vint start, vint count, vint newCount) - { - GuiVirtualListView::OnItemModified(start, count, newCount); - if(!GetItemProvider()->IsEditing()) - { - StopEdit(false); - } - } - - void GuiVirtualDataGrid::OnStyleUninstalled(ItemStyle* style) - { - GuiVirtualListView::OnStyleUninstalled(style); - if (auto itemStyle = dynamic_cast(style)) - { - if (itemStyle->IsEditorOpened()) - { - itemStyle->NotifyCloseEditor(); - currentEditor = nullptr; - currentEditorPos = { -1,-1 }; - } - } - } - - void GuiVirtualDataGrid::NotifyCloseEditor() - { - if (currentEditorPos.row != -1 && GetArranger()) - { - auto style = GetArranger()->GetVisibleStyle(currentEditorPos.row); - if (auto itemStyle = dynamic_cast(style)) - { - itemStyle->NotifyCloseEditor(); - } - } - } - - void GuiVirtualDataGrid::NotifySelectCell(vint row, vint column) - { - selectedCell = { row, column }; - SelectedCellChanged.Execute(GetNotifyEventArguments()); - - auto style = GetArranger()->GetVisibleStyle(row); - if (auto itemStyle = dynamic_cast(style)) - { - itemStyle->NotifySelectCell(column); - } - } - - bool GuiVirtualDataGrid::StartEdit(vint row, vint column) - { - StopEdit(true); - NotifySelectCell(row, column); - - auto style = GetArranger()->GetVisibleStyle(row); - if (auto itemStyle = dynamic_cast(style)) - { - if (auto factory = dataGridView->GetCellDataEditorFactory(row, column)) - { - currentEditorOpeningEditor = true; - currentEditorPos = { row,column }; - currentEditor = factory->CreateEditor(this); - currentEditor->BeforeEditCell(GetItemProvider(), row, column); - itemStyle->NotifyOpenEditor(column, currentEditor.Obj()); - currentEditorOpeningEditor = false; - return true; - } - } - return false; - } - - void GuiVirtualDataGrid::StopEdit(bool forOpenNewEditor) - { - if (GetItemProvider()->IsEditing()) - { - NotifyCloseEditor(); - } - else - { - if (currentEditorPos != GridPos{-1, -1}) - { - if (currentEditor) - { - NotifyCloseEditor(); - } - if (!forOpenNewEditor) - { - NotifySelectCell(-1, -1); - } - } - } - currentEditor = nullptr; - currentEditorPos = { -1,-1 }; - } - -/*********************************************************************** -GuiVirtualDataGrid (IDataGridContext) -***********************************************************************/ - - GuiListViewBase::IStyleProvider* GuiVirtualDataGrid::GetListViewStyleProvider() - { - return GuiVirtualListView::GetListViewStyleProvider(); - } - - description::Value GuiVirtualDataGrid::GetViewModelContext() - { - return dataGridView->GetViewModelContext(); - } - - void GuiVirtualDataGrid::RequestSaveData() - { - if (currentEditor && !currentEditorOpeningEditor) - { - GuiControl* focusedControl = nullptr; - if (auto controlHost = GetRelatedControlHost()) - { - if (auto graphicsHost = controlHost->GetGraphicsHost()) - { - if (auto focusComposition = graphicsHost->GetFocusedComposition()) - { - focusedControl = focusComposition->GetRelatedControl(); + root->FinalizeInstance(); } } } - GetItemProvider()->PushEditing(); - dataGridView->SetBindingCellValue(currentEditorPos.row, currentEditorPos.column, currentEditor->GetTemplate()->GetCellValue()); - GetItemProvider()->PopEditing(); - - auto style = GetArranger()->GetVisibleStyle(currentEditorPos.row); - if (auto itemStyle = dynamic_cast(style)) + if (!finalized) { - itemStyle->NotifyCellEdited(); - } - - if (currentEditor && focusedControl) - { - focusedControl->SetFocus(); + vint count = value->Children().Count(); + for (vint i = 0; i < count; i++) + { + NotifyFinalizeInstance(value->Children()[i]); + } } } } -/*********************************************************************** -GuiVirtualDataGrid -***********************************************************************/ - - void GuiVirtualDataGrid::OnColumnClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiItemEventArgs& arguments) + void SafeDeleteControlInternal(controls::GuiControl* value) { - if(dataGridView->IsColumnSortable(arguments.itemIndex)) + if(value) { - switch(columnItemView->GetSortingState(arguments.itemIndex)) + if (value->GetRelatedControlHost() != value) { - case ColumnSortingState::NotSorted: - dataGridView->SortByColumn(arguments.itemIndex, true); - break; - case ColumnSortingState::Ascending: - dataGridView->SortByColumn(arguments.itemIndex, false); - break; - case ColumnSortingState::Descending: - dataGridView->SortByColumn(-1, false); - break; + GuiGraphicsComposition* bounds = value->GetBoundsComposition(); + if (bounds->GetParent()) + { + bounds->GetParent()->RemoveChild(bounds); + } } + delete value; } } - GuiVirtualDataGrid::GuiVirtualDataGrid(IStyleProvider* _styleProvider, GuiListControl::IItemProvider* _itemProvider) - :GuiVirtualListView(_styleProvider, _itemProvider) + void SafeDeleteCompositionInternal(GuiGraphicsComposition* value) { - listViewItemView = dynamic_cast(_itemProvider->RequestView(IListViewItemView::Identifier)); - columnItemView = dynamic_cast(_itemProvider->RequestView(ListViewColumnItemArranger::IColumnItemView::Identifier)); - dataGridView = dynamic_cast(_itemProvider->RequestView(IDataGridView::Identifier)); - + if (value) { - auto mainProperty = [](const Value&) { return new MainColumnVisualizerTemplate; }; - auto subProperty = [](const Value&) { return new SubColumnVisualizerTemplate; }; - auto cellBorderProperty = [](const Value&) { return new CellBorderVisualizerTemplate; }; - - auto mainFactory = MakePtr(mainProperty); - auto subFactory = MakePtr(subProperty); - defaultMainColumnVisualizerFactory = MakePtr(cellBorderProperty, mainFactory); - defaultSubColumnVisualizerFactory = MakePtr(cellBorderProperty, subFactory); - } - - CHECK_ERROR(listViewItemView != nullptr, L"GuiVirtualDataGrid::GuiVirtualDataGrid(IStyleProvider*, GuiListControl::IItemProvider*)#Missing IListViewItemView from item provider."); - CHECK_ERROR(columnItemView != nullptr, L"GuiVirtualDataGrid::GuiVirtualDataGrid(IStyleProvider*, GuiListControl::IItemProvider*)#Missing ListViewColumnItemArranger::IColumnItemView from item provider."); - CHECK_ERROR(dataGridView != nullptr, L"GuiVirtualDataGrid::GuiVirtualDataGrid(IStyleProvider*, GuiListControl::IItemProvider*)#Missing IDataGridView from item provider."); - - SetViewToDefault(); - ColumnClicked.AttachMethod(this, &GuiVirtualDataGrid::OnColumnClicked); - SelectedCellChanged.SetAssociatedComposition(GetBoundsComposition()); - } - - GuiVirtualDataGrid::~GuiVirtualDataGrid() - { - } - - GuiListControl::IItemProvider* GuiVirtualDataGrid::GetItemProvider() - { - return GuiVirtualListView::GetItemProvider(); - } - - void GuiVirtualDataGrid::SetViewToDefault() - { - SetStyleAndArranger( - [](const Value&) { return new list::DefaultDataGridItemTemplate; }, - new list::ListViewColumnItemArranger - ); - } - - GridPos GuiVirtualDataGrid::GetSelectedCell() - { - return selectedCell; - } - - void GuiVirtualDataGrid::SetSelectedCell(const GridPos& value) - { - if (selectedCell == value) - { - return; - } - - bool validPos = 0 <= value.row && value.row < GetItemProvider()->Count() && 0 <= value.column && value.column < listViewItemView->GetColumnCount(); - StopEdit(true); - - if (validPos) - { - NotifySelectCell(value.row, value.column); - } - else - { - NotifySelectCell(-1, -1); - } - - if (validPos) - { - EnsureItemVisible(value.row); - ClearSelection(); - SetSelected(value.row, true); - StartEdit(value.row, value.column); - } - else - { - ClearSelection(); - } - } - } - } -} - -/*********************************************************************** -CONTROLS\LISTCONTROLPACKAGE\GUIDATAGRIDEXTENSIONS.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace controls - { - namespace list - { - using namespace compositions; - using namespace elements; - using namespace theme; - using namespace templates; - -/*********************************************************************** -DataVisualizerBase -***********************************************************************/ - - DataVisualizerBase::DataVisualizerBase() - { - } - - DataVisualizerBase::~DataVisualizerBase() - { - if (visualizerTemplate) + if (value->GetParent()) { - SafeDeleteComposition(visualizerTemplate); + value->GetParent()->RemoveChild(value); } - } - IDataVisualizerFactory* DataVisualizerBase::GetFactory() - { - return factory; - } - - templates::GuiGridVisualizerTemplate* DataVisualizerBase::GetTemplate() - { - return visualizerTemplate; - } - - void DataVisualizerBase::NotifyDeletedTemplate() - { - visualizerTemplate = nullptr; - } - - void DataVisualizerBase::BeforeVisualizeCell(GuiListControl::IItemProvider* itemProvider, vint row, vint column) - { - if (auto listViewItemView = dynamic_cast(dataGridContext->GetItemProvider()->RequestView(IListViewItemView::Identifier))) + if (value->GetAssociatedControl()) { - auto styleProvider = dataGridContext->GetListViewStyleProvider(); - visualizerTemplate->SetPrimaryTextColor(styleProvider->GetPrimaryTextColor()); - visualizerTemplate->SetSecondaryTextColor(styleProvider->GetSecondaryTextColor()); - visualizerTemplate->SetItemSeparatorColor(styleProvider->GetItemSeparatorColor()); - - visualizerTemplate->SetLargeImage(listViewItemView->GetLargeImage(row)); - visualizerTemplate->SetSmallImage(listViewItemView->GetSmallImage(row)); - visualizerTemplate->SetText(column == 0 ? listViewItemView->GetText(row) : listViewItemView->GetSubItem(row, column - 1)); - } - if (auto dataGridView = dynamic_cast(dataGridContext->GetItemProvider()->RequestView(IDataGridView::Identifier))) - { - visualizerTemplate->SetRowValue(itemProvider->GetBindingValue(row)); - visualizerTemplate->SetCellValue(dataGridView->GetBindingCellValue(row, column)); - } - } - - void DataVisualizerBase::SetSelected(bool value) - { - if (visualizerTemplate) - { - visualizerTemplate->SetSelected(value); - } - } - -/*********************************************************************** -DataVisualizerFactory -***********************************************************************/ - - DataVisualizerFactory::ItemTemplate* DataVisualizerFactory::CreateItemTemplate(controls::list::IDataGridContext* dataGridContext) - { - ItemTemplate* itemTemplate = templateFactory(dataGridContext->GetViewModelContext()); - CHECK_ERROR(itemTemplate, L"DataVisualizerFactory::CreateItemTemplate(IDataGridContext*)#An instance of GuiGridEditorTemplate is expected."); - if (decoratedFactory) - { - auto childTemplate = decoratedFactory->CreateItemTemplate(dataGridContext); - childTemplate->SetAlignmentToParent(Margin(0, 0, 0, 0)); - itemTemplate->GetContainerComposition()->AddChild(childTemplate); - -#define FORWARD_EVENT(NAME)\ - itemTemplate->NAME##Changed.AttachLambda([=](GuiGraphicsComposition* sender, GuiEventArgs& arguments)\ - {\ - childTemplate->Set##NAME(itemTemplate->Get##NAME());\ - });\ - -#define FORWARD_EVENT_IMPL(CLASS, TYPE, NAME) FORWARD_EVENT(NAME) - - GuiTemplate_PROPERTIES(FORWARD_EVENT_IMPL) - GuiControlTemplate_PROPERTIES(FORWARD_EVENT_IMPL) - GuiGridCellTemplate_PROPERTIES(FORWARD_EVENT_IMPL) - GuiGridVisualizerTemplate_PROPERTIES(FORWARD_EVENT_IMPL) - -#undef FORWARD_EVENT_IMPL -#undef FORWARD_EVENT - } - return itemTemplate; - } - - DataVisualizerFactory::DataVisualizerFactory(TemplateProperty _templateFactory, Ptr _decoratedFactory) - :templateFactory(_templateFactory) - , decoratedFactory(_decoratedFactory) - { - } - - DataVisualizerFactory::~DataVisualizerFactory() - { - } - - Ptr DataVisualizerFactory::CreateVisualizer(controls::list::IDataGridContext* dataGridContext) - { - auto dataVisualizer = MakePtr(); - dataVisualizer->factory = this; - dataVisualizer->dataGridContext = dataGridContext; - dataVisualizer->visualizerTemplate = CreateItemTemplate(dataGridContext); - - return dataVisualizer; - } - -/*********************************************************************** -DataEditorBase -***********************************************************************/ - - void DataEditorBase::OnCellValueChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - dataGridContext->RequestSaveData(); - } - - DataEditorBase::DataEditorBase() - { - } - - DataEditorBase::~DataEditorBase() - { - if (editorTemplate) - { - SafeDeleteComposition(editorTemplate); - } - } - - IDataEditorFactory* DataEditorBase::GetFactory() - { - return factory; - } - - templates::GuiGridEditorTemplate* DataEditorBase::GetTemplate() - { - return editorTemplate; - } - - void DataEditorBase::NotifyDeletedTemplate() - { - editorTemplate = nullptr; - } - - void DataEditorBase::BeforeEditCell(GuiListControl::IItemProvider* itemProvider, vint row, vint column) - { - if (auto listViewItemView = dynamic_cast(dataGridContext->GetItemProvider()->RequestView(IListViewItemView::Identifier))) - { - auto styleProvider = dataGridContext->GetListViewStyleProvider(); - editorTemplate->SetPrimaryTextColor(styleProvider->GetPrimaryTextColor()); - editorTemplate->SetSecondaryTextColor(styleProvider->GetSecondaryTextColor()); - editorTemplate->SetItemSeparatorColor(styleProvider->GetItemSeparatorColor()); - - editorTemplate->SetLargeImage(listViewItemView->GetLargeImage(row)); - editorTemplate->SetSmallImage(listViewItemView->GetSmallImage(row)); - editorTemplate->SetText(column == 0 ? listViewItemView->GetText(row) : listViewItemView->GetSubItem(row, column - 1)); - } - if (auto dataGridView = dynamic_cast(dataGridContext->GetItemProvider()->RequestView(IDataGridView::Identifier))) - { - editorTemplate->SetRowValue(itemProvider->GetBindingValue(row)); - editorTemplate->SetCellValue(dataGridView->GetBindingCellValue(row, column)); - } - editorTemplate->CellValueChanged.AttachMethod(this, &DataEditorBase::OnCellValueChanged); - } - - bool DataEditorBase::GetCellValueSaved() - { - if (editorTemplate) - { - return editorTemplate->GetCellValueSaved(); - } - return true; - } - -/*********************************************************************** -DataEditorFactory -***********************************************************************/ - - DataEditorFactory::DataEditorFactory(TemplateProperty _templateFactory) - :templateFactory(_templateFactory) - { - } - - DataEditorFactory::~DataEditorFactory() - { - } - - Ptr DataEditorFactory::CreateEditor(controls::list::IDataGridContext* dataGridContext) - { - auto editor = MakePtr(); - editor->factory = this; - editor->dataGridContext = dataGridContext; - - ItemTemplate* itemTemplate = templateFactory(dataGridContext->GetViewModelContext()); - CHECK_ERROR(itemTemplate, L"DataEditorFactory::CreateEditor(IDataGridContext*)#An instance of GuiGridEditorTemplate is expected."); - editor->editorTemplate = itemTemplate; - return editor; - } - -/*********************************************************************** -MainColumnVisualizerTemplate -***********************************************************************/ - - void MainColumnVisualizerTemplate::OnTextChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - text->SetText(GetText()); - } - - void MainColumnVisualizerTemplate::OnFontChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - text->SetFont(GetFont()); - } - - void MainColumnVisualizerTemplate::OnTextColorChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - text->SetColor(GetPrimaryTextColor()); - } - - void MainColumnVisualizerTemplate::OnSmallImageChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - auto imageData = GetSmallImage(); - if (imageData) - { - image->SetImage(imageData->GetImage(), imageData->GetFrameIndex()); + SafeDeleteControlInternal(value->GetAssociatedControl()); } else { - image->SetImage(nullptr); + for (vint i = value->Children().Count() - 1; i >= 0; i--) + { + SafeDeleteCompositionInternal(value->Children().Get(i)); + } + delete value; } } + } - MainColumnVisualizerTemplate::MainColumnVisualizerTemplate() - { - GuiTableComposition* table = new GuiTableComposition; - table->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - table->SetRowsAndColumns(3, 2); - table->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); - table->SetRowOption(1, GuiCellOption::MinSizeOption()); - table->SetRowOption(2, GuiCellOption::PercentageOption(0.5)); - table->SetColumnOption(0, GuiCellOption::MinSizeOption()); - table->SetColumnOption(1, GuiCellOption::PercentageOption(1.0)); - table->SetCellPadding(2); - { - GuiCellComposition* cell = new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(1, 0, 1, 1); - cell->SetPreferredMinSize(Size(16, 16)); + void SafeDeleteControl(controls::GuiControl* value) + { + NotifyFinalizeInstance(value); + SafeDeleteControlInternal(value); + } - image = GuiImageFrameElement::Create(); - image->SetStretch(true); - cell->SetOwnedElement(image); - } - { - GuiCellComposition* cell = new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 1, 3, 1); - cell->SetMargin(Margin(0, 0, 8, 0)); - - text = GuiSolidLabelElement::Create(); - text->SetAlignments(Alignment::Left, Alignment::Center); - text->SetEllipse(true); - cell->SetOwnedElement(text); - } - table->SetAlignmentToParent(Margin(0, 0, 0, 0)); - - SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - AddChild(table); - - TextChanged.AttachMethod(this, &MainColumnVisualizerTemplate::OnTextChanged); - FontChanged.AttachMethod(this, &MainColumnVisualizerTemplate::OnFontChanged); - PrimaryTextColorChanged.AttachMethod(this, &MainColumnVisualizerTemplate::OnTextColorChanged); - SmallImageChanged.AttachMethod(this, &MainColumnVisualizerTemplate::OnSmallImageChanged); - - TextChanged.Execute(compositions::GuiEventArgs(this)); - FontChanged.Execute(compositions::GuiEventArgs(this)); - PrimaryTextColorChanged.Execute(compositions::GuiEventArgs(this)); - SmallImageChanged.Execute(compositions::GuiEventArgs(this)); - } - - MainColumnVisualizerTemplate::~MainColumnVisualizerTemplate() - { - } - -/*********************************************************************** -SubColumnVisualizerTemplate -***********************************************************************/ - - void SubColumnVisualizerTemplate::OnTextChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - text->SetText(GetText()); - } - - void SubColumnVisualizerTemplate::OnFontChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - text->SetFont(GetFont()); - } - - void SubColumnVisualizerTemplate::OnTextColorChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - text->SetColor(GetSecondaryTextColor()); - } - - void SubColumnVisualizerTemplate::Initialize(bool fixTextColor) - { - text = GuiSolidLabelElement::Create(); - text->SetVerticalAlignment(Alignment::Center); - - SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - SetMargin(Margin(8, 0, 8, 0)); - SetOwnedElement(text); - - TextChanged.AttachMethod(this, &SubColumnVisualizerTemplate::OnTextChanged); - FontChanged.AttachMethod(this, &SubColumnVisualizerTemplate::OnFontChanged); - if (!fixTextColor) - { - SecondaryTextColorChanged.AttachMethod(this, &SubColumnVisualizerTemplate::OnTextColorChanged); - } - - TextChanged.Execute(compositions::GuiEventArgs(this)); - FontChanged.Execute(compositions::GuiEventArgs(this)); - if (!fixTextColor) - { - SecondaryTextColorChanged.Execute(compositions::GuiEventArgs(this)); - } - } - - SubColumnVisualizerTemplate::SubColumnVisualizerTemplate(bool fixTextColor) - { - Initialize(fixTextColor); - } - - SubColumnVisualizerTemplate::SubColumnVisualizerTemplate() - { - Initialize(false); - } - - SubColumnVisualizerTemplate::~SubColumnVisualizerTemplate() - { - } - -/*********************************************************************** -HyperlinkVisualizerTemplate -***********************************************************************/ - - void HyperlinkVisualizerTemplate::label_MouseEnter(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - FontProperties font = text->GetFont(); - font.underline = true; - text->SetFont(font); - } - - void HyperlinkVisualizerTemplate::label_MouseLeave(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - FontProperties font = text->GetFont(); - font.underline = false; - text->SetFont(font); - } - - HyperlinkVisualizerTemplate::HyperlinkVisualizerTemplate() - :SubColumnVisualizerTemplate(true) - { - text->SetColor(Color(0, 0, 255)); - text->SetEllipse(true); - GetEventReceiver()->mouseEnter.AttachMethod(this, &HyperlinkVisualizerTemplate::label_MouseEnter); - GetEventReceiver()->mouseLeave.AttachMethod(this, &HyperlinkVisualizerTemplate::label_MouseLeave); - SetAssociatedCursor(GetCurrentController()->ResourceService()->GetSystemCursor(INativeCursor::Hand)); - } - - HyperlinkVisualizerTemplate::~HyperlinkVisualizerTemplate() - { - } - -/*********************************************************************** -CellBorderVisualizerTemplate -***********************************************************************/ - - void CellBorderVisualizerTemplate::OnItemSeparatorColorChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - border1->SetColor(GetItemSeparatorColor()); - border2->SetColor(GetItemSeparatorColor()); - } - - CellBorderVisualizerTemplate::CellBorderVisualizerTemplate() - { - GuiBoundsComposition* bounds1 = nullptr; - GuiBoundsComposition* bounds2 = nullptr; - { - border1 = GuiSolidBorderElement::Create(); - - bounds1 = new GuiBoundsComposition; - bounds1->SetOwnedElement(border1); - bounds1->SetAlignmentToParent(Margin(-1, 0, 0, 0)); - } - { - border2 = GuiSolidBorderElement::Create(); - - bounds2 = new GuiBoundsComposition; - bounds2->SetOwnedElement(border2); - bounds2->SetAlignmentToParent(Margin(0, -1, 0, 0)); - } - - SetAlignmentToParent(Margin(0, 0, 1, 1)); - SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - AddChild(bounds1); - AddChild(bounds2); - - ItemSeparatorColorChanged.AttachMethod(this, &CellBorderVisualizerTemplate::OnItemSeparatorColorChanged); - - ItemSeparatorColorChanged.Execute(compositions::GuiEventArgs(this)); - } - - CellBorderVisualizerTemplate::~CellBorderVisualizerTemplate() - { - } + void SafeDeleteComposition(GuiGraphicsComposition* value) + { + NotifyFinalizeInstance(value); + SafeDeleteCompositionInternal(value); } } } } /*********************************************************************** -CONTROLS\LISTCONTROLPACKAGE\GUILISTCONTROLITEMARRANGERS.CPP +.\GRAPHICSCOMPOSITION\GUIGRAPHICSFLOWCOMPOSITION.CPP ***********************************************************************/ namespace vl { namespace presentation { - namespace controls + namespace compositions { using namespace collections; - using namespace elements; - using namespace compositions; - namespace list +/*********************************************************************** +GuiFlowComposition +***********************************************************************/ + + void GuiFlowComposition::UpdateFlowItemBounds(bool forceUpdate) { - -/*********************************************************************** -RangedItemArrangerBase -***********************************************************************/ - - void RangedItemArrangerBase::InvalidateAdoptedSize() + if (forceUpdate || needUpdate) { - if (listControl) - { - listControl->AdoptedSizeInvalidated.Execute(listControl->GetNotifyEventArguments()); - } - } + needUpdate = false; + InvokeOnCompositionStateChanged(); - vint RangedItemArrangerBase::CalculateAdoptedSize(vint expectedSize, vint count, vint itemSize) - { - vint visibleCount = expectedSize / itemSize; - if (count < visibleCount) + auto clientMargin = axis->RealMarginToVirtualMargin(extraMargin); + if (clientMargin.left < 0) clientMargin.left = 0; + if (clientMargin.top < 0) clientMargin.top = 0; + if (clientMargin.right < 0) clientMargin.right = 0; + if (clientMargin.bottom < 0) clientMargin.bottom = 0; + + auto realFullSize = previousBounds.GetSize(); + auto clientSize = axis->RealSizeToVirtualSize(realFullSize); + clientSize.x -= (clientMargin.left + clientMargin.right); + clientSize.y -= (clientMargin.top + clientMargin.bottom); + + flowItemBounds.Resize(flowItems.Count()); + for (vint i = 0; i < flowItems.Count(); i++) { - visibleCount = count; + flowItemBounds[i] = Rect(Point(0, 0), flowItems[i]->GetMinSize()); } - else if (count > visibleCount) + + vint currentIndex = 0; + vint rowTop = 0; + + while (currentIndex < flowItems.Count()) { - vint deltaA = expectedSize - count * itemSize; - vint deltaB = itemSize - deltaA; - if (deltaB < deltaA) + auto itemSize = axis->RealSizeToVirtualSize(flowItemBounds[currentIndex].GetSize()); + vint rowWidth = itemSize.x; + vint rowHeight = itemSize.y; + vint rowItemCount = 1; + + for (vint i = currentIndex + 1; i < flowItems.Count(); i++) { - visibleCount++; - } - } - return visibleCount * itemSize; - } - - RangedItemArrangerBase::ItemStyleRecord RangedItemArrangerBase::CreateStyle(vint index) - { - GuiSelectableButton* backgroundButton = nullptr; - if (listControl->GetDisplayItemBackground()) - { - auto style = listControl->GetListControlStyleProvider()->CreateItemBackground(); - if (!style) - { - style = theme::GetCurrentTheme()->CreateListItemBackgroundStyle(); - } - backgroundButton = new GuiSelectableButton(style); - backgroundButton->SetAutoSelection(false); - } - - auto itemStyle = callback->RequestItem(index, backgroundButton->GetBoundsComposition()); - if (backgroundButton) - { - itemStyle->SetAlignmentToParent(Margin(0, 0, 0, 0)); - itemStyle->SelectedChanged.AttachLambda([=](GuiGraphicsComposition* sender, GuiEventArgs& arguments) - { - backgroundButton->SetSelected(itemStyle->GetSelected()); - }); - backgroundButton->GetContainerComposition()->AddChild(itemStyle); - } - return { itemStyle, backgroundButton }; - } - - void RangedItemArrangerBase::DeleteStyle(ItemStyleRecord style) - { - callback->ReleaseItem(style.key); - if (style.value) - { - SafeDeleteControl(style.value); - } - } - - compositions::GuiBoundsComposition* RangedItemArrangerBase::GetStyleBounds(ItemStyleRecord style) - { - return style.value ? style.value->GetBoundsComposition() : style.key; - } - - void RangedItemArrangerBase::ClearStyles() - { - startIndex = 0; - if (callback) - { - for (vint i = 0; i < visibleStyles.Count(); i++) - { - DeleteStyle(visibleStyles[i]); - } - } - visibleStyles.Clear(); - viewBounds = Rect(0, 0, 0, 0); - InvalidateItemSizeCache(); - InvalidateAdoptedSize(); - } - - void RangedItemArrangerBase::OnViewChangedInternal(Rect oldBounds, Rect newBounds) - { - vint endIndex = startIndex + visibleStyles.Count() - 1; - vint newStartIndex = 0; - vint itemCount = itemProvider->Count(); - BeginPlaceItem(true, newBounds, newStartIndex); - if (newStartIndex < 0) newStartIndex = 0; - - StyleList newVisibleStyles; - for (vint i = newStartIndex; i < itemCount; i++) - { - auto style - = startIndex <= i && i <= endIndex - ? visibleStyles[i - startIndex] - : CreateStyle(i) - ; - newVisibleStyles.Add(style); - - Rect bounds; - Margin alignmentToParent; - PlaceItem(true, i, style, newBounds, bounds, alignmentToParent); - if (IsItemOutOfViewBounds(i, style, bounds, newBounds)) - { - break; - } - - bounds.x1 -= newBounds.x1; - bounds.x2 -= newBounds.x1; - bounds.y1 -= newBounds.y1; - bounds.y2 -= newBounds.y1; - } - - vint newEndIndex = newStartIndex + newVisibleStyles.Count() - 1; - for (vint i = 0; i < visibleStyles.Count(); i++) - { - vint index = startIndex + i; - if (index < newStartIndex || index > newEndIndex) - { - DeleteStyle(visibleStyles[i]); - } - } - CopyFrom(visibleStyles, newVisibleStyles); - - if (EndPlaceItem(true, newBounds, newStartIndex)) - { - callback->OnTotalSizeChanged(); - InvalidateAdoptedSize(); - } - startIndex = newStartIndex; - } - - void RangedItemArrangerBase::RearrangeItemBounds() - { - vint newStartIndex = startIndex; - BeginPlaceItem(false, viewBounds, newStartIndex); - for (vint i = 0; i < visibleStyles.Count(); i++) - { - auto style = visibleStyles[i]; - Rect bounds; - Margin alignmentToParent(-1, -1, -1, -1); - PlaceItem(false, startIndex + i, style, viewBounds, bounds, alignmentToParent); - - bounds.x1 -= viewBounds.x1; - bounds.x2 -= viewBounds.x1; - bounds.y1 -= viewBounds.y1; - bounds.y2 -= viewBounds.y1; - - callback->SetStyleAlignmentToParent(GetStyleBounds(style), alignmentToParent); - callback->SetStyleBounds(GetStyleBounds(style), bounds); - } - EndPlaceItem(false, viewBounds, startIndex); - } - - RangedItemArrangerBase::RangedItemArrangerBase() - { - } - - RangedItemArrangerBase::~RangedItemArrangerBase() - { - } - - void RangedItemArrangerBase::OnAttached(GuiListControl::IItemProvider* provider) - { - itemProvider = provider; - if (provider) - { - OnItemModified(0, 0, provider->Count()); - } - } - - void RangedItemArrangerBase::OnItemModified(vint start, vint count, vint newCount) - { - if (callback && !itemProvider->IsEditing()) - { - suppressOnViewChanged = true; - { - vint visibleCount = visibleStyles.Count(); - vint itemCount = itemProvider->Count(); - SortedList reusedStyles; - for (vint i = 0; i < visibleCount; i++) - { - vint index = startIndex + i; - if (index >= itemCount) - { - break; - } - - vint oldIndex = -1; - if (index < start) - { - oldIndex = index; - } - else if (index >= start + newCount) - { - oldIndex = index - newCount + count; - } - - if (oldIndex != -1) - { - if (oldIndex >= startIndex && oldIndex < startIndex + visibleCount) - { - auto style = visibleStyles[oldIndex - startIndex]; - reusedStyles.Add(style); - visibleStyles.Add(style); - } - else - { - oldIndex = -1; - } - } - if (oldIndex == -1) - { - visibleStyles.Add(CreateStyle(index)); - } - } - - for (vint i = 0; i < visibleCount; i++) - { - auto style = visibleStyles[i]; - if (!reusedStyles.Contains(style)) - { - DeleteStyle(style); - } - } - - visibleStyles.RemoveRange(0, visibleCount); - for (vint i = 0; i < visibleStyles.Count(); i++) - { - visibleStyles[i].key->SetIndex(startIndex + i); - } - } - suppressOnViewChanged = false; - - callback->OnTotalSizeChanged(); - callback->SetViewLocation(viewBounds.LeftTop()); - InvalidateAdoptedSize(); - } - } - - void RangedItemArrangerBase::AttachListControl(GuiListControl* value) - { - listControl = value; - InvalidateAdoptedSize(); - } - - void RangedItemArrangerBase::DetachListControl() - { - listControl = 0; - } - - GuiListControl::IItemArrangerCallback* RangedItemArrangerBase::GetCallback() - { - return callback; - } - - void RangedItemArrangerBase::SetCallback(GuiListControl::IItemArrangerCallback* value) - { - if (callback != value) - { - ClearStyles(); - } - callback = value; - } - - Size RangedItemArrangerBase::GetTotalSize() - { - if (callback) - { - return OnCalculateTotalSize(); - } - else - { - return Size(0, 0); - } - } - - GuiListControl::ItemStyle* RangedItemArrangerBase::GetVisibleStyle(vint itemIndex) - { - if (startIndex <= itemIndex && itemIndex < startIndex + visibleStyles.Count()) - { - return visibleStyles[itemIndex - startIndex].key; - } - else - { - return 0; - } - } - - vint RangedItemArrangerBase::GetVisibleIndex(GuiListControl::ItemStyle* style) - { - for (vint i = 0; i < visibleStyles.Count(); i++) - { - if (visibleStyles[i].key == style) - { - return i + startIndex; - } - } - return -1; - } - - void RangedItemArrangerBase::OnViewChanged(Rect bounds) - { - if (!suppressOnViewChanged) - { - suppressOnViewChanged = true; - Rect oldBounds = viewBounds; - viewBounds = bounds; - if (callback) - { - OnViewChangedInternal(oldBounds, viewBounds); - RearrangeItemBounds(); - } - suppressOnViewChanged = false; - } - } - -/*********************************************************************** -FixedHeightItemArranger -***********************************************************************/ - - vint FixedHeightItemArranger::GetWidth() - { - return -1; - } - - vint FixedHeightItemArranger::GetYOffset() - { - return 0; - } - - void FixedHeightItemArranger::BeginPlaceItem(bool forMoving, Rect newBounds, vint& newStartIndex) - { - pi_width = GetWidth(); - if (forMoving) - { - pim_rowHeight = rowHeight; - newStartIndex = (newBounds.Top() - GetYOffset()) / rowHeight; - } - } - - void FixedHeightItemArranger::PlaceItem(bool forMoving, vint index, ItemStyleRecord style, Rect viewBounds, Rect& bounds, Margin& alignmentToParent) - { - vint top = GetYOffset() + index * rowHeight; - if (pi_width == -1) - { - alignmentToParent = Margin(0, -1, 0, -1); - bounds = Rect(Point(0, top), Size(0, rowHeight)); - } - else - { - alignmentToParent = Margin(-1, -1, -1, -1); - bounds = Rect(Point(0, top), Size(pi_width, rowHeight)); - } - if (forMoving) - { - vint styleHeight = callback->GetStylePreferredSize(GetStyleBounds(style)).y; - if (pim_rowHeight < styleHeight) - { - pim_rowHeight = styleHeight; - } - } - } - - bool FixedHeightItemArranger::IsItemOutOfViewBounds(vint index, ItemStyleRecord style, Rect bounds, Rect viewBounds) - { - return bounds.Top() >= viewBounds.Bottom(); - } - - bool FixedHeightItemArranger::EndPlaceItem(bool forMoving, Rect newBounds, vint newStartIndex) - { - if (forMoving) - { - if (pim_rowHeight != rowHeight) - { - vint offset = (pim_rowHeight - rowHeight) * newStartIndex; - rowHeight = pim_rowHeight; - callback->SetViewLocation(Point(0, newBounds.Top() + offset)); - return true; - } - } - return false; - } - - void FixedHeightItemArranger::InvalidateItemSizeCache() - { - rowHeight = 1; - } - - Size FixedHeightItemArranger::OnCalculateTotalSize() - { - vint width = GetWidth(); - if (width < 0) width = 0; - return Size(width, rowHeight * itemProvider->Count() + GetYOffset()); - } - - FixedHeightItemArranger::FixedHeightItemArranger() - :rowHeight(1) - { - } - - FixedHeightItemArranger::~FixedHeightItemArranger() - { - } - - vint FixedHeightItemArranger::FindItem(vint itemIndex, compositions::KeyDirection key) - { - vint count = itemProvider->Count(); - if (count == 0) return -1; - vint groupCount = viewBounds.Height() / rowHeight; - if (groupCount == 0) groupCount = 1; - switch (key) - { - case KeyDirection::Up: - itemIndex--; - break; - case KeyDirection::Down: - itemIndex++; - break; - case KeyDirection::Home: - itemIndex = 0; - break; - case KeyDirection::End: - itemIndex = count; - break; - case KeyDirection::PageUp: - itemIndex -= groupCount; - break; - case KeyDirection::PageDown: - itemIndex += groupCount; - break; - default: - return -1; - } - - if (itemIndex < 0) return 0; - else if (itemIndex >= count) return count - 1; - else return itemIndex; - } - - bool FixedHeightItemArranger::EnsureItemVisible(vint itemIndex) - { - if (callback) - { - if (itemIndex < 0 || itemIndex >= itemProvider->Count()) - { - return false; - } - while (true) - { - vint yOffset = GetYOffset(); - vint top = itemIndex*rowHeight; - vint bottom = top + rowHeight + yOffset; - - if (viewBounds.Height() < rowHeight) - { - if (viewBounds.Top() < bottom && top < viewBounds.Bottom()) - { - break; - } - } - - Point location = viewBounds.LeftTop(); - if (top < viewBounds.Top()) - { - location.y = top; - } - else if (viewBounds.Bottom() < bottom) - { - location.y = bottom - viewBounds.Height(); - } - else + itemSize = axis->RealSizeToVirtualSize(flowItemBounds[i].GetSize()); + vint itemWidth = itemSize.x + columnPadding; + if (rowWidth + itemWidth > clientSize.x) { break; } - callback->SetViewLocation(location); - } - return true; - } - return false; - } - - Size FixedHeightItemArranger::GetAdoptedSize(Size expectedSize) - { - if (itemProvider) - { - vint yOffset = GetYOffset(); - vint y = expectedSize.y - yOffset; - vint itemCount = itemProvider->Count(); - return Size(expectedSize.x, yOffset + CalculateAdoptedSize(y, itemCount, rowHeight)); - } - return expectedSize; - } - -/*********************************************************************** -FixedSizeMultiColumnItemArranger -***********************************************************************/ - - void FixedSizeMultiColumnItemArranger::BeginPlaceItem(bool forMoving, Rect newBounds, vint& newStartIndex) - { - if (forMoving) - { - pim_itemSize = itemSize; - vint rows = newBounds.Top() / itemSize.y; - if (rows < 0) rows = 0; - vint cols = newBounds.Width() / itemSize.x; - if (cols < 1) cols = 1; - newStartIndex = rows * cols; - } - } - - void FixedSizeMultiColumnItemArranger::PlaceItem(bool forMoving, vint index, ItemStyleRecord style, Rect viewBounds, Rect& bounds, Margin& alignmentToParent) - { - vint rowItems = viewBounds.Width() / itemSize.x; - if (rowItems < 1) rowItems = 1; - - vint row = index / rowItems; - vint col = index % rowItems; - bounds = Rect(Point(col * itemSize.x, row * itemSize.y), itemSize); - if (forMoving) - { - Size styleSize = callback->GetStylePreferredSize(GetStyleBounds(style)); - if (pim_itemSize.x < styleSize.x) pim_itemSize.x = styleSize.x; - if (pim_itemSize.y < styleSize.y) pim_itemSize.y = styleSize.y; - } - } - - bool FixedSizeMultiColumnItemArranger::IsItemOutOfViewBounds(vint index, ItemStyleRecord style, Rect bounds, Rect viewBounds) - { - return bounds.Top() >= viewBounds.Bottom(); - } - - bool FixedSizeMultiColumnItemArranger::EndPlaceItem(bool forMoving, Rect newBounds, vint newStartIndex) - { - if (forMoving) - { - if (pim_itemSize != itemSize) - { - itemSize = pim_itemSize; - return true; - } - } - return false; - } - - void FixedSizeMultiColumnItemArranger::CalculateRange(Size itemSize, Rect bounds, vint count, vint& start, vint& end) - { - vint startRow = bounds.Top() / itemSize.y; - if (startRow < 0) startRow = 0; - vint endRow = (bounds.Bottom() - 1) / itemSize.y; - vint cols = bounds.Width() / itemSize.x; - if (cols < 1) cols = 1; - - start = startRow*cols; - end = (endRow + 1)*cols - 1; - if (end >= count) end = count - 1; - } - - void FixedSizeMultiColumnItemArranger::InvalidateItemSizeCache() - { - itemSize = Size(1, 1); - } - - Size FixedSizeMultiColumnItemArranger::OnCalculateTotalSize() - { - vint rowItems = viewBounds.Width() / itemSize.x; - if (rowItems < 1) rowItems = 1; - vint rows = itemProvider->Count() / rowItems; - if (itemProvider->Count() % rowItems) rows++; - - return Size(itemSize.x * rowItems, itemSize.y*rows); - } - - FixedSizeMultiColumnItemArranger::FixedSizeMultiColumnItemArranger() - :itemSize(1, 1) - { - } - - FixedSizeMultiColumnItemArranger::~FixedSizeMultiColumnItemArranger() - { - } - - vint FixedSizeMultiColumnItemArranger::FindItem(vint itemIndex, compositions::KeyDirection key) - { - vint count = itemProvider->Count(); - vint columnCount = viewBounds.Width() / itemSize.x; - if (columnCount == 0) columnCount = 1; - vint rowCount = viewBounds.Height() / itemSize.y; - if (rowCount == 0) rowCount = 1; - - switch (key) - { - case KeyDirection::Up: - itemIndex -= columnCount; - break; - case KeyDirection::Down: - itemIndex += columnCount; - break; - case KeyDirection::Left: - itemIndex--; - break; - case KeyDirection::Right: - itemIndex++; - break; - case KeyDirection::Home: - itemIndex = 0; - break; - case KeyDirection::End: - itemIndex = count; - break; - case KeyDirection::PageUp: - itemIndex -= columnCount*rowCount; - break; - case KeyDirection::PageDown: - itemIndex += columnCount*rowCount; - break; - case KeyDirection::PageLeft: - itemIndex -= itemIndex%columnCount; - break; - case KeyDirection::PageRight: - itemIndex += columnCount - itemIndex%columnCount - 1; - break; - default: - return -1; - } - - if (itemIndex < 0) return 0; - else if (itemIndex >= count) return count - 1; - else return itemIndex; - } - - bool FixedSizeMultiColumnItemArranger::EnsureItemVisible(vint itemIndex) - { - if (callback) - { - if (itemIndex < 0 || itemIndex >= itemProvider->Count()) - { - return false; - } - while (true) - { - vint rowHeight = itemSize.y; - vint columnCount = viewBounds.Width() / itemSize.x; - if (columnCount == 0) columnCount = 1; - vint rowIndex = itemIndex / columnCount; - - vint top = rowIndex*rowHeight; - vint bottom = top + rowHeight; - - if (viewBounds.Height() < rowHeight) + rowWidth += itemWidth; + if (rowHeight < itemSize.y) { - if (viewBounds.Top() < bottom && top < viewBounds.Bottom()) - { - break; - } + rowHeight = itemSize.y; } + rowItemCount++; + } - Point location = viewBounds.LeftTop(); - if (top < viewBounds.Top()) - { - location.y = top; - } - else if (viewBounds.Bottom() < bottom) - { - location.y = bottom - viewBounds.Height(); - } - else + vint baseLine = 0; + Array itemBaseLines(rowItemCount); + for (vint i = 0; i < rowItemCount; i++) + { + vint index = currentIndex + i; + vint itemBaseLine = 0; + itemSize = axis->RealSizeToVirtualSize(flowItemBounds[index].GetSize()); + + auto option = flowItems[index]->GetFlowOption(); + switch (option.baseline) { + case GuiFlowOption::FromTop: + itemBaseLine = option.distance; + break; + case GuiFlowOption::FromBottom: + itemBaseLine = itemSize.y - option.distance; + break; + case GuiFlowOption::Percentage: + itemBaseLine = (vint)(itemSize.y*option.percentage); break; } - callback->SetViewLocation(location); - } - return true; - } - return false; - } - Size FixedSizeMultiColumnItemArranger::GetAdoptedSize(Size expectedSize) - { - if (itemProvider) - { - vint count = itemProvider->Count(); - vint columnCount = viewBounds.Width() / itemSize.x; - vint rowCount = viewBounds.Height() / itemSize.y; - return Size( - CalculateAdoptedSize(expectedSize.x, columnCount, itemSize.x), - CalculateAdoptedSize(expectedSize.y, rowCount, itemSize.y) - ); - } - return expectedSize; - } - -/*********************************************************************** -FixedHeightMultiColumnItemArranger -***********************************************************************/ - - void FixedHeightMultiColumnItemArranger::BeginPlaceItem(bool forMoving, Rect newBounds, vint& newStartIndex) - { - pi_currentWidth = 0; - pi_totalWidth = 0; - if (forMoving) - { - pim_itemHeight = itemHeight; - vint rows = newBounds.Height() / itemHeight; - if (rows < 1) rows = 1; - vint columns = newBounds.Left() / newBounds.Width(); - newStartIndex = rows * columns; - } - } - - void FixedHeightMultiColumnItemArranger::PlaceItem(bool forMoving, vint index, ItemStyleRecord style, Rect viewBounds, Rect& bounds, Margin& alignmentToParent) - { - vint rows = viewBounds.Height() / itemHeight; - if (rows < 1) rows = 1; - - vint row = index % rows; - if (row == 0) - { - pi_totalWidth += pi_currentWidth; - pi_currentWidth = 0; - } - - Size styleSize = callback->GetStylePreferredSize(GetStyleBounds(style)); - if (pi_currentWidth < styleSize.x) pi_currentWidth = styleSize.x; - bounds = Rect(Point(pi_totalWidth + viewBounds.Left(), itemHeight * row), Size(0, 0)); - if (forMoving) - { - if (pim_itemHeight < styleSize.y) pim_itemHeight = styleSize.y; - } - } - - bool FixedHeightMultiColumnItemArranger::IsItemOutOfViewBounds(vint index, ItemStyleRecord style, Rect bounds, Rect viewBounds) - { - return bounds.Left() >= viewBounds.Right(); - } - - bool FixedHeightMultiColumnItemArranger::EndPlaceItem(bool forMoving, Rect newBounds, vint newStartIndex) - { - if (forMoving) - { - if (pim_itemHeight != itemHeight) - { - itemHeight = pim_itemHeight; - return true; - } - } - return false; - } - - void FixedHeightMultiColumnItemArranger::CalculateRange(vint itemHeight, Rect bounds, vint& rows, vint& startColumn) - { - rows = bounds.Height() / itemHeight; - if (rows < 1) rows = 1; - startColumn = bounds.Left() / bounds.Width(); - } - - void FixedHeightMultiColumnItemArranger::InvalidateItemSizeCache() - { - itemHeight = 1; - } - - Size FixedHeightMultiColumnItemArranger::OnCalculateTotalSize() - { - vint rows = viewBounds.Height() / itemHeight; - if (rows < 1) rows = 1; - vint columns = itemProvider->Count() / rows; - if (itemProvider->Count() % rows) columns += 1; - return Size(viewBounds.Width() * columns, 0); - } - - FixedHeightMultiColumnItemArranger::FixedHeightMultiColumnItemArranger() - :itemHeight(1) - { - } - - FixedHeightMultiColumnItemArranger::~FixedHeightMultiColumnItemArranger() - { - } - - vint FixedHeightMultiColumnItemArranger::FindItem(vint itemIndex, compositions::KeyDirection key) - { - vint count = itemProvider->Count(); - vint groupCount = viewBounds.Height() / itemHeight; - if (groupCount == 0) groupCount = 1; - switch (key) - { - case KeyDirection::Up: - itemIndex--; - break; - case KeyDirection::Down: - itemIndex++; - break; - case KeyDirection::Left: - itemIndex -= groupCount; - break; - case KeyDirection::Right: - itemIndex += groupCount; - break; - case KeyDirection::Home: - itemIndex = 0; - break; - case KeyDirection::End: - itemIndex = count; - break; - case KeyDirection::PageUp: - itemIndex -= itemIndex%groupCount; - break; - case KeyDirection::PageDown: - itemIndex += groupCount - itemIndex%groupCount - 1; - break; - default: - return -1; - } - - if (itemIndex < 0) return 0; - else if (itemIndex >= count) return count - 1; - else return itemIndex; - } - - bool FixedHeightMultiColumnItemArranger::EnsureItemVisible(vint itemIndex) - { - if (callback) - { - if (itemIndex < 0 || itemIndex >= itemProvider->Count()) - { - return false; - } - while (true) - { - vint rowCount = viewBounds.Height() / itemHeight; - if (rowCount == 0) rowCount = 1; - vint columnIndex = itemIndex / rowCount; - vint minIndex = startIndex; - vint maxIndex = startIndex + visibleStyles.Count() - 1; - - Point location = viewBounds.LeftTop(); - if (minIndex <= itemIndex && itemIndex <= maxIndex) + itemBaseLines[i] = itemBaseLine; + if (baseLine < itemBaseLine) { - Rect bounds = callback->GetStyleBounds(GetStyleBounds(visibleStyles[itemIndex - startIndex])); - if (0 < bounds.Bottom() && bounds.Top() < viewBounds.Width() && bounds.Width() > viewBounds.Width()) + baseLine = itemBaseLine; + } + } + + vint rowUsedWidth = 0; + for (vint i = 0; i < rowItemCount; i++) + { + vint index = currentIndex + i; + itemSize = axis->RealSizeToVirtualSize(flowItemBounds[index].GetSize()); + + vint itemLeft = 0; + vint itemTop = rowTop + baseLine - itemBaseLines[i]; + + switch (alignment) + { + case FlowAlignment::Left: + itemLeft = rowUsedWidth + i * columnPadding; + break; + case FlowAlignment::Center: + itemLeft = rowUsedWidth + i * columnPadding + (clientSize.x - rowWidth) / 2; + break; + case FlowAlignment::Extend: + if (i == 0) { - break; - } - else if (bounds.Left() < 0) - { - location.x -= viewBounds.Width(); - } - else if (bounds.Right() > viewBounds.Width()) - { - location.x += viewBounds.Width(); + itemLeft = rowUsedWidth; } else { - break; + itemLeft = rowUsedWidth + (vint)((double)(clientSize.x - rowWidth) * i / (rowItemCount - 1)) + i * columnPadding; } - } - else if (columnIndex < minIndex / rowCount) - { - location.x -= viewBounds.Width(); - } - else if (columnIndex >= maxIndex / rowCount) - { - location.x += viewBounds.Width(); - } - else - { break; } - callback->SetViewLocation(location); + + flowItemBounds[index] = axis->VirtualRectToRealRect( + realFullSize, + Rect( + Point( + itemLeft + clientMargin.left, + itemTop + clientMargin.top + ), + itemSize + ) + ); + rowUsedWidth += itemSize.x; } - return true; + + rowTop += rowHeight + rowPadding; + currentIndex += rowItemCount; } - return false; + + minHeight = rowTop == 0 ? 0 : rowTop - rowPadding; + } + } + + void GuiFlowComposition::OnBoundsChanged(GuiGraphicsComposition* sender, GuiEventArgs& arguments) + { + UpdateFlowItemBounds(true); + } + + void GuiFlowComposition::OnChildInserted(GuiGraphicsComposition* child) + { + GuiBoundsComposition::OnChildInserted(child); + auto item = dynamic_cast(child); + if (item && !flowItems.Contains(item)) + { + flowItems.Add(item); + needUpdate = true; + } + } + + void GuiFlowComposition::OnChildRemoved(GuiGraphicsComposition* child) + { + GuiBoundsComposition::OnChildRemoved(child); + auto item = dynamic_cast(child); + if (item) + { + flowItems.Remove(item); + needUpdate = true; + } + } + + GuiFlowComposition::GuiFlowComposition() + :axis(new GuiDefaultAxis) + { + BoundsChanged.AttachMethod(this, &GuiFlowComposition::OnBoundsChanged); + } + + GuiFlowComposition::~GuiFlowComposition() + { + } + + const GuiFlowComposition::ItemCompositionList& GuiFlowComposition::GetFlowItems() + { + return flowItems; + } + + Margin GuiFlowComposition::GetExtraMargin() + { + return extraMargin; + } + + void GuiFlowComposition::SetExtraMargin(Margin value) + { + extraMargin = value; + needUpdate = true; + InvokeOnCompositionStateChanged(); + } + + vint GuiFlowComposition::GetRowPadding() + { + return rowPadding; + } + + void GuiFlowComposition::SetRowPadding(vint value) + { + rowPadding = value; + needUpdate = true; + InvokeOnCompositionStateChanged(); + } + + vint GuiFlowComposition::GetColumnPadding() + { + return columnPadding; + } + + void GuiFlowComposition::SetColumnPadding(vint value) + { + columnPadding = value; + needUpdate = true; + InvokeOnCompositionStateChanged(); + } + + Ptr GuiFlowComposition::GetAxis() + { + return axis; + } + + void GuiFlowComposition::SetAxis(Ptr value) + { + if (value) + { + axis = value; + needUpdate = true; + InvokeOnCompositionStateChanged(); + } + } + + FlowAlignment GuiFlowComposition::GetAlignment() + { + return alignment; + } + + void GuiFlowComposition::SetAlignment(FlowAlignment value) + { + alignment = value; + needUpdate = true; + InvokeOnCompositionStateChanged(); + } + + void GuiFlowComposition::ForceCalculateSizeImmediately() + { + GuiBoundsComposition::ForceCalculateSizeImmediately(); + UpdateFlowItemBounds(true); + } + + Size GuiFlowComposition::GetMinPreferredClientSize() + { + Size minSize = GuiBoundsComposition::GetMinPreferredClientSize(); + if (GetMinSizeLimitation() == GuiGraphicsComposition::LimitToElementAndChildren) + { + auto clientMargin = extraMargin; + if (clientMargin.left < 0) clientMargin.left = 0; + if (clientMargin.top < 0) clientMargin.top = 0; + if (clientMargin.right < 0) clientMargin.right = 0; + if (clientMargin.bottom < 0) clientMargin.bottom = 0; + + auto clientSize = axis->VirtualSizeToRealSize(Size(0, minHeight)); + clientSize.x += clientMargin.left + clientMargin.right; + clientSize.y += clientMargin.top + clientMargin.bottom; + + if (minSize.x < clientSize.x) minSize.x = clientSize.x; + if (minSize.y < clientSize.y) minSize.y = clientSize.y; } - Size FixedHeightMultiColumnItemArranger::GetAdoptedSize(Size expectedSize) + vint x = 0; + vint y = 0; + if (extraMargin.left > 0) x += extraMargin.left; + if (extraMargin.right > 0) x += extraMargin.right; + if (extraMargin.top > 0) y += extraMargin.top; + if (extraMargin.bottom > 0) y += extraMargin.bottom; + return minSize + Size(x, y); + } + + Rect GuiFlowComposition::GetBounds() + { + if (!needUpdate) { - if (itemProvider) + for (vint i = 0; i < flowItems.Count(); i++) { - vint count = itemProvider->Count(); - return Size(expectedSize.x, CalculateAdoptedSize(expectedSize.y, count, itemHeight)); + if (flowItemBounds[i].GetSize() != flowItems[i]->GetMinSize()) + { + needUpdate = true; + break; + } } - return expectedSize; + } + + if (needUpdate) + { + UpdateFlowItemBounds(true); + } + + bounds = GuiBoundsComposition::GetBounds(); + return bounds; + } + +/*********************************************************************** +GuiFlowItemComposition +***********************************************************************/ + + void GuiFlowItemComposition::OnParentChanged(GuiGraphicsComposition* oldParent, GuiGraphicsComposition* newParent) + { + GuiGraphicsSite::OnParentChanged(oldParent, newParent); + flowParent = newParent == 0 ? 0 : dynamic_cast(newParent); + } + + Size GuiFlowItemComposition::GetMinSize() + { + return GetBoundsInternal(bounds).GetSize(); + } + + GuiFlowItemComposition::GuiFlowItemComposition() + { + SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + } + + GuiFlowItemComposition::~GuiFlowItemComposition() + { + } + + bool GuiFlowItemComposition::IsSizeAffectParent() + { + return false; + } + + Rect GuiFlowItemComposition::GetBounds() + { + Rect result = bounds; + if(flowParent) + { + flowParent->UpdateFlowItemBounds(false); + vint index = flowParent->flowItems.IndexOf(this); + if (index != -1) + { + result = flowParent->flowItemBounds[index]; + } + + result = Rect( + result.Left() - extraMargin.left, + result.Top() - extraMargin.top, + result.Right() + extraMargin.right, + result.Bottom() + extraMargin.bottom + ); + } + UpdatePreviousBounds(result); + return result; + } + + void GuiFlowItemComposition::SetBounds(Rect value) + { + bounds = value; + InvokeOnCompositionStateChanged(); + } + + Margin GuiFlowItemComposition::GetExtraMargin() + { + return extraMargin; + } + + void GuiFlowItemComposition::SetExtraMargin(Margin value) + { + extraMargin = value; + InvokeOnCompositionStateChanged(); + } + + GuiFlowOption GuiFlowItemComposition::GetFlowOption() + { + return option; + } + + void GuiFlowItemComposition::SetFlowOption(GuiFlowOption value) + { + option = value; + if (flowParent) + { + flowParent->needUpdate = true; + InvokeOnCompositionStateChanged(); } } } @@ -8641,7 +8915,1627 @@ FixedHeightMultiColumnItemArranger } /*********************************************************************** -CONTROLS\LISTCONTROLPACKAGE\GUILISTCONTROLS.CPP +.\CONTROLS\GUIBUTTONCONTROLS.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace controls + { + using namespace elements; + using namespace compositions; + using namespace collections; + using namespace reflection::description; + +/*********************************************************************** +GuiButton +***********************************************************************/ + + void GuiButton::OnParentLineChanged() + { + GuiControl::OnParentLineChanged(); + if(GetRelatedControlHost()==0) + { + mousePressing=false; + mouseHoving=false; + UpdateControlState(); + } + } + + void GuiButton::OnActiveAlt() + { + Clicked.Execute(GetNotifyEventArguments()); + } + + void GuiButton::UpdateControlState() + { + auto newControlState = ButtonState::Normal; + if (mousePressing) + { + if (mouseHoving) + { + newControlState = ButtonState::Pressed; + } + else + { + newControlState = ButtonState::Active; + } + } + else + { + if (mouseHoving) + { + newControlState = ButtonState::Active; + } + else + { + newControlState = ButtonState::Normal; + } + } + if (controlState != newControlState) + { + controlState = newControlState; + styleController->Transfer(controlState); + } + } + + void GuiButton::OnLeftButtonDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) + { + if(arguments.eventSource==boundsComposition) + { + mousePressing=true; + boundsComposition->GetRelatedGraphicsHost()->SetFocus(boundsComposition); + UpdateControlState(); + if(!clickOnMouseUp && arguments.eventSource->GetAssociatedControl()==this) + { + Clicked.Execute(GetNotifyEventArguments()); + } + } + } + + void GuiButton::OnLeftButtonUp(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) + { + if(arguments.eventSource==boundsComposition) + { + mousePressing=false; + UpdateControlState(); + } + if(GetVisuallyEnabled()) + { + if(mouseHoving && clickOnMouseUp) + { + auto eventSource = arguments.eventSource->GetAssociatedControl(); + while (eventSource && eventSource != this) + { + if (eventSource->GetFocusableComposition()) + { + return; + } + eventSource = eventSource->GetParent(); + } + Clicked.Execute(GetNotifyEventArguments()); + } + } + } + + void GuiButton::OnMouseEnter(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + if(arguments.eventSource==boundsComposition) + { + mouseHoving=true; + UpdateControlState(); + } + } + + void GuiButton::OnMouseLeave(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + if(arguments.eventSource==boundsComposition) + { + mouseHoving=false; + UpdateControlState(); + } + } + + GuiButton::GuiButton(IStyleController* _styleController) + :GuiControl(_styleController) + ,styleController(_styleController) + ,clickOnMouseUp(true) + ,mousePressing(false) + ,mouseHoving(false) + ,controlState(ButtonState::Normal) + { + Clicked.SetAssociatedComposition(boundsComposition); + styleController->Transfer(ButtonState::Normal); + SetFocusableComposition(boundsComposition); + + GetEventReceiver()->leftButtonDown.AttachMethod(this, &GuiButton::OnLeftButtonDown); + GetEventReceiver()->leftButtonUp.AttachMethod(this, &GuiButton::OnLeftButtonUp); + GetEventReceiver()->mouseEnter.AttachMethod(this, &GuiButton::OnMouseEnter); + GetEventReceiver()->mouseLeave.AttachMethod(this, &GuiButton::OnMouseLeave); + } + + GuiButton::~GuiButton() + { + } + + bool GuiButton::GetClickOnMouseUp() + { + return clickOnMouseUp; + } + + void GuiButton::SetClickOnMouseUp(bool value) + { + clickOnMouseUp=value; + } + +/*********************************************************************** +GuiSelectableButton::GroupController +***********************************************************************/ + + GuiSelectableButton::GroupController::GroupController() + { + } + + GuiSelectableButton::GroupController::~GroupController() + { + for(vint i=buttons.Count()-1;i>=0;i--) + { + buttons[i]->SetGroupController(0); + } + } + + void GuiSelectableButton::GroupController::Attach(GuiSelectableButton* button) + { + if(!buttons.Contains(button)) + { + buttons.Add(button); + } + } + + void GuiSelectableButton::GroupController::Detach(GuiSelectableButton* button) + { + buttons.Remove(button); + } + +/*********************************************************************** +GuiSelectableButton::MutexGroupController +***********************************************************************/ + + GuiSelectableButton::MutexGroupController::MutexGroupController() + :suppress(false) + { + } + + GuiSelectableButton::MutexGroupController::~MutexGroupController() + { + } + + void GuiSelectableButton::MutexGroupController::OnSelectedChanged(GuiSelectableButton* button) + { + if(!suppress) + { + suppress=true; + for(vint i=0;iSetSelected(buttons[i]==button); + } + suppress=false; + } + } + +/*********************************************************************** +GuiSelectableButton +***********************************************************************/ + + void GuiSelectableButton::OnClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + if(autoSelection) + { + SetSelected(!GetSelected()); + } + } + + GuiSelectableButton::GuiSelectableButton(IStyleController* _styleController) + :GuiButton(_styleController) + ,styleController(_styleController) + ,groupController(0) + ,autoSelection(true) + ,isSelected(false) + { + GroupControllerChanged.SetAssociatedComposition(boundsComposition); + AutoSelectionChanged.SetAssociatedComposition(boundsComposition); + SelectedChanged.SetAssociatedComposition(boundsComposition); + + Clicked.AttachMethod(this, &GuiSelectableButton::OnClicked); + styleController->SetSelected(isSelected); + } + + GuiSelectableButton::~GuiSelectableButton() + { + if(groupController) + { + groupController->Detach(this); + } + } + + GuiSelectableButton::GroupController* GuiSelectableButton::GetGroupController() + { + return groupController; + } + + void GuiSelectableButton::SetGroupController(GroupController* value) + { + if(groupController) + { + groupController->Detach(this); + } + groupController=value; + if(groupController) + { + groupController->Attach(this); + } + GroupControllerChanged.Execute(GetNotifyEventArguments()); + } + + bool GuiSelectableButton::GetAutoSelection() + { + return autoSelection; + } + + void GuiSelectableButton::SetAutoSelection(bool value) + { + if(autoSelection!=value) + { + autoSelection=value; + AutoSelectionChanged.Execute(GetNotifyEventArguments()); + } + } + + bool GuiSelectableButton::GetSelected() + { + return isSelected; + } + + void GuiSelectableButton::SetSelected(bool value) + { + if(isSelected!=value) + { + isSelected=value; + styleController->SetSelected(isSelected); + if(groupController) + { + groupController->OnSelectedChanged(this); + } + SelectedChanged.Execute(GetNotifyEventArguments()); + } + } + } + } +} + +/*********************************************************************** +.\CONTROLS\GUISCROLLCONTROLS.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace controls + { + using namespace elements; + using namespace compositions; + using namespace collections; + using namespace reflection::description; + +/*********************************************************************** +GuiScroll::CommandExecutor +***********************************************************************/ + + GuiScroll::CommandExecutor::CommandExecutor(GuiScroll* _scroll) + :scroll(_scroll) + { + } + + GuiScroll::CommandExecutor::~CommandExecutor() + { + } + + void GuiScroll::CommandExecutor::SmallDecrease() + { + scroll->SetPosition(scroll->GetPosition()-scroll->GetSmallMove()); + } + + void GuiScroll::CommandExecutor::SmallIncrease() + { + scroll->SetPosition(scroll->GetPosition()+scroll->GetSmallMove()); + } + + void GuiScroll::CommandExecutor::BigDecrease() + { + scroll->SetPosition(scroll->GetPosition()-scroll->GetBigMove()); + } + + void GuiScroll::CommandExecutor::BigIncrease() + { + scroll->SetPosition(scroll->GetPosition()+scroll->GetBigMove()); + } + + void GuiScroll::CommandExecutor::SetTotalSize(vint value) + { + scroll->SetTotalSize(value); + } + + void GuiScroll::CommandExecutor::SetPageSize(vint value) + { + scroll->SetPageSize(value); + } + + void GuiScroll::CommandExecutor::SetPosition(vint value) + { + scroll->SetPosition(value); + } + +/*********************************************************************** +GuiScroll +***********************************************************************/ + + GuiScroll::GuiScroll(IStyleController* _styleController) + :GuiControl(_styleController) + ,styleController(_styleController) + ,totalSize(100) + ,pageSize(10) + ,position(0) + ,smallMove(1) + ,bigMove(10) + { + TotalSizeChanged.SetAssociatedComposition(boundsComposition); + PageSizeChanged.SetAssociatedComposition(boundsComposition); + PositionChanged.SetAssociatedComposition(boundsComposition); + SmallMoveChanged.SetAssociatedComposition(boundsComposition); + BigMoveChanged.SetAssociatedComposition(boundsComposition); + + commandExecutor=new CommandExecutor(this); + styleController->SetCommandExecutor(commandExecutor.Obj()); + styleController->SetPageSize(pageSize); + styleController->SetTotalSize(totalSize); + styleController->SetPosition(position); + } + + GuiScroll::~GuiScroll() + { + } + + vint GuiScroll::GetTotalSize() + { + return totalSize; + } + + void GuiScroll::SetTotalSize(vint value) + { + if(totalSize!=value && 0totalSize) + { + SetPageSize(totalSize); + } + if(position>GetMaxPosition()) + { + SetPosition(GetMaxPosition()); + } + styleController->SetTotalSize(totalSize); + TotalSizeChanged.Execute(GetNotifyEventArguments()); + } + } + + vint GuiScroll::GetPageSize() + { + return pageSize; + } + + void GuiScroll::SetPageSize(vint value) + { + if(pageSize!=value && 0<=value && value<=totalSize) + { + pageSize=value; + if(position>GetMaxPosition()) + { + SetPosition(GetMaxPosition()); + } + styleController->SetPageSize(pageSize); + PageSizeChanged.Execute(GetNotifyEventArguments()); + } + } + + vint GuiScroll::GetPosition() + { + return position; + } + + void GuiScroll::SetPosition(vint value) + { + vint min=GetMinPosition(); + vint max=GetMaxPosition(); + vint newPosition= + valuemax?max: + value; + if(position!=newPosition) + { + position=newPosition; + styleController->SetPosition(position); + PositionChanged.Execute(GetNotifyEventArguments()); + } + } + + vint GuiScroll::GetSmallMove() + { + return smallMove; + } + + void GuiScroll::SetSmallMove(vint value) + { + if(value>0 && smallMove!=value) + { + smallMove=value; + SmallMoveChanged.Execute(GetNotifyEventArguments()); + } + } + + vint GuiScroll::GetBigMove() + { + return bigMove; + } + + void GuiScroll::SetBigMove(vint value) + { + if(value>0 && bigMove!=value) + { + bigMove=value; + BigMoveChanged.Execute(GetNotifyEventArguments()); + } + } + + vint GuiScroll::GetMinPosition() + { + return 0; + } + + vint GuiScroll::GetMaxPosition() + { + return totalSize-pageSize; + } + } + } +} + +/*********************************************************************** +.\CONTROLS\GUICONTAINERCONTROLS.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + using namespace compositions; + + namespace controls + { + +/*********************************************************************** +GuiTabPage +***********************************************************************/ + + bool GuiTabPage::IsAltAvailable() + { + return false; + } + + void GuiTabPage::OnTextChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + if (tab) + { + tab->styleController->SetTabText(tab->tabPages.IndexOf(this), GetText()); + } + } + + void GuiTabPage::OnAltChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + if (tab) + { + tab->styleController->SetTabAlt(tab->tabPages.IndexOf(this), GetAlt()); + } + } + + GuiTabPage::GuiTabPage(IStyleController* _styleController) + :GuiCustomControl(_styleController) + { + TextChanged.AttachMethod(this, &GuiTabPage::OnTextChanged); + AltChanged.AttachMethod(this, &GuiTabPage::OnAltChanged); + } + + GuiTabPage::~GuiTabPage() + { + FinalizeAggregation(); + } + +/*********************************************************************** +GuiTabPageList +***********************************************************************/ + + bool GuiTabPageList::QueryInsert(vint index, GuiTabPage* const& value) + { + return !items.Contains(value) && value->tab == nullptr; + } + + void GuiTabPageList::AfterInsert(vint index, GuiTabPage* const& value) + { + tab->styleController->InsertTab(index); + tab->styleController->SetTabText(index, value->GetText()); + tab->styleController->SetTabAlt(index, value->GetAlt()); + + value->tab = tab; + value->SetVisible(false); + value->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); + tab->GetContainerComposition()->AddChild(value->GetBoundsComposition()); + + if (!tab->selectedPage) + { + tab->SetSelectedPage(value); + } + } + + void GuiTabPageList::BeforeRemove(vint index, GuiTabPage* const& value) + { + tab->styleController->RemoveTab(index); + tab->GetContainerComposition()->RemoveChild(value->GetBoundsComposition()); + value->tab = nullptr; + + if (items.Count() == 0) + { + tab->SetSelectedPage(nullptr); + } + else if (tab->selectedPage == value) + { + tab->SetSelectedPage(items[0]); + } + } + + GuiTabPageList::GuiTabPageList(GuiTab* _tab) + :tab(_tab) + { + } + + GuiTabPageList::~GuiTabPageList() + { + } + +/*********************************************************************** +GuiTab +***********************************************************************/ + + GuiTab::CommandExecutor::CommandExecutor(GuiTab* _tab) + :tab(_tab) + { + } + + GuiTab::CommandExecutor::~CommandExecutor() + { + } + + void GuiTab::CommandExecutor::ShowTab(vint index) + { + tab->SetSelectedPage(tab->GetPages().Get(index)); + } + + GuiTab::GuiTab(IStyleController* _styleController) + :GuiControl(_styleController) + , styleController(_styleController) + , tabPages(this) + { + commandExecutor = new CommandExecutor(this); + styleController->SetCommandExecutor(commandExecutor.Obj()); + } + + GuiTab::~GuiTab() + { + } + + GuiTabPageList& GuiTab::GetPages() + { + return tabPages; + } + + GuiTabPage* GuiTab::GetSelectedPage() + { + return selectedPage; + } + + bool GuiTab::SetSelectedPage(GuiTabPage* value) + { + if (!value) + { + if (tabPages.Count() == 0) + { + selectedPage = nullptr; + } + } + else if (value->tab == this) + { + if (selectedPage != value) + { + selectedPage = value; + for (vint i = 0; i < tabPages.Count(); i++) + { + bool selected = tabPages[i] == value; + tabPages[i]->SetVisible(selected); + if (selected) + { + styleController->SetSelectedTab(i); + } + } + SelectedPageChanged.Execute(GetNotifyEventArguments()); + } + } + return selectedPage == value; + } + +/*********************************************************************** +GuiScrollView::StyleController +***********************************************************************/ + + void GuiScrollView::StyleController::UpdateTable() + { + if(horizontalScroll->GetEnabled() || horizontalAlwaysVisible) + { + tableComposition->SetRowOption(1, GuiCellOption::AbsoluteOption(styleProvider->GetDefaultScrollSize())); + } + else + { + tableComposition->SetRowOption(1, GuiCellOption::AbsoluteOption(0)); + } + if(verticalScroll->GetEnabled() || verticalAlwaysVisible) + { + tableComposition->SetColumnOption(1, GuiCellOption::AbsoluteOption(styleProvider->GetDefaultScrollSize())); + } + else + { + tableComposition->SetColumnOption(1, GuiCellOption::AbsoluteOption(0)); + } + tableComposition->UpdateCellBounds(); + } + + GuiScrollView::StyleController::StyleController(IStyleProvider* _styleProvider) + :styleProvider(_styleProvider) + ,scrollView(0) + ,horizontalAlwaysVisible(true) + ,verticalAlwaysVisible(true) + { + horizontalScroll=new GuiScroll(styleProvider->CreateHorizontalScrollStyle()); + horizontalScroll->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); + horizontalScroll->SetEnabled(false); + verticalScroll=new GuiScroll(styleProvider->CreateVerticalScrollStyle()); + verticalScroll->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); + verticalScroll->SetEnabled(false); + + boundsComposition=new GuiBoundsComposition; + GuiGraphicsComposition* tableContainerComposition=styleProvider->InstallBackground(boundsComposition); + + tableComposition=new GuiTableComposition; + tableContainerComposition->AddChild(tableComposition); + tableComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); + tableComposition->SetRowsAndColumns(2, 2); + tableComposition->SetRowOption(0, GuiCellOption::PercentageOption(1.0)); + tableComposition->SetRowOption(1, GuiCellOption::MinSizeOption()); + tableComposition->SetColumnOption(0, GuiCellOption::PercentageOption(1.0)); + tableComposition->SetColumnOption(1, GuiCellOption::MinSizeOption()); + UpdateTable(); + { + GuiCellComposition* cell=new GuiCellComposition; + tableComposition->AddChild(cell); + cell->SetSite(1, 0, 1, 1); + cell->AddChild(horizontalScroll->GetBoundsComposition()); + } + { + GuiCellComposition* cell=new GuiCellComposition; + tableComposition->AddChild(cell); + cell->SetSite(0, 1, 1, 1); + cell->AddChild(verticalScroll->GetBoundsComposition()); + } + + containerCellComposition=new GuiCellComposition; + tableComposition->AddChild(containerCellComposition); + containerCellComposition->SetSite(0, 0, 1, 1); + + containerComposition=new GuiBoundsComposition; + containerComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); + containerCellComposition->AddChild(containerComposition); + + styleProvider->AssociateStyleController(this); + } + + GuiScrollView::StyleController::~StyleController() + { + } + + void GuiScrollView::StyleController::SetScrollView(GuiScrollView* _scrollView) + { + scrollView=_scrollView; + } + + void GuiScrollView::StyleController::AdjustView(Size fullSize) + { + Size viewSize=containerComposition->GetBounds().GetSize(); + if(fullSize.x<=viewSize.x) + { + horizontalScroll->SetEnabled(false); + horizontalScroll->SetPosition(0); + } + else + { + horizontalScroll->SetEnabled(true); + horizontalScroll->SetTotalSize(fullSize.x); + horizontalScroll->SetPageSize(viewSize.x); + } + if(fullSize.y<=viewSize.y) + { + verticalScroll->SetEnabled(false); + verticalScroll->SetPosition(0); + } + else + { + verticalScroll->SetEnabled(true); + verticalScroll->SetTotalSize(fullSize.y); + verticalScroll->SetPageSize(viewSize.y); + } + UpdateTable(); + } + + GuiScrollView::IStyleProvider* GuiScrollView::StyleController::GetStyleProvider() + { + return styleProvider.Obj(); + } + + GuiScroll* GuiScrollView::StyleController::GetHorizontalScroll() + { + return horizontalScroll; + } + + GuiScroll* GuiScrollView::StyleController::GetVerticalScroll() + { + return verticalScroll; + } + + compositions::GuiTableComposition* GuiScrollView::StyleController::GetInternalTableComposition() + { + return tableComposition; + } + + compositions::GuiBoundsComposition* GuiScrollView::StyleController::GetInternalContainerComposition() + { + return containerComposition; + } + + bool GuiScrollView::StyleController::GetHorizontalAlwaysVisible() + { + return horizontalAlwaysVisible; + } + + void GuiScrollView::StyleController::SetHorizontalAlwaysVisible(bool value) + { + if(horizontalAlwaysVisible!=value) + { + horizontalAlwaysVisible=value; + scrollView->CalculateView(); + } + } + + bool GuiScrollView::StyleController::GetVerticalAlwaysVisible() + { + return verticalAlwaysVisible; + } + + void GuiScrollView::StyleController::SetVerticalAlwaysVisible(bool value) + { + if(verticalAlwaysVisible!=value) + { + verticalAlwaysVisible=value; + scrollView->CalculateView(); + } + } + + compositions::GuiBoundsComposition* GuiScrollView::StyleController::GetBoundsComposition() + { + return boundsComposition; + } + + compositions::GuiGraphicsComposition* GuiScrollView::StyleController::GetContainerComposition() + { + return containerComposition; + } + + void GuiScrollView::StyleController::SetFocusableComposition(compositions::GuiGraphicsComposition* value) + { + styleProvider->SetFocusableComposition(value); + } + + void GuiScrollView::StyleController::SetText(const WString& value) + { + styleProvider->SetText(value); + } + + void GuiScrollView::StyleController::SetFont(const FontProperties& value) + { + styleProvider->SetFont(value); + } + + void GuiScrollView::StyleController::SetVisuallyEnabled(bool value) + { + styleProvider->SetVisuallyEnabled(value); + } + +/*********************************************************************** +GuiScrollView +***********************************************************************/ + + void GuiScrollView::OnContainerBoundsChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + CalculateView(); + } + + void GuiScrollView::OnHorizontalScroll(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + if(!supressScrolling) + { + CallUpdateView(); + } + } + + void GuiScrollView::OnVerticalScroll(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + if(!supressScrolling) + { + CallUpdateView(); + } + } + + void GuiScrollView::OnHorizontalWheel(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) + { + if(!supressScrolling) + { + auto scroll = styleController->GetHorizontalScroll(); + vint position = scroll->GetPosition(); + vint move = scroll->GetSmallMove(); + position -= move*arguments.wheel / 60; + scroll->SetPosition(position); + } + } + + void GuiScrollView::OnVerticalWheel(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) + { + if(!supressScrolling && GetVisuallyEnabled()) + { + auto scroll = styleController->GetVerticalScroll(); + vint position = scroll->GetPosition(); + vint move = scroll->GetSmallMove(); + position -= move*arguments.wheel / 60; + scroll->SetPosition(position); + } + } + + void GuiScrollView::CallUpdateView() + { + Rect viewBounds=GetViewBounds(); + UpdateView(viewBounds); + } + + void GuiScrollView::Initialize() + { + styleController=dynamic_cast(GetStyleController()); + styleController->SetScrollView(this); + + styleController->GetInternalContainerComposition()->BoundsChanged.AttachMethod(this, &GuiScrollView::OnContainerBoundsChanged); + styleController->GetHorizontalScroll()->PositionChanged.AttachMethod(this, &GuiScrollView::OnHorizontalScroll); + styleController->GetVerticalScroll()->PositionChanged.AttachMethod(this, &GuiScrollView::OnVerticalScroll); + styleController->GetBoundsComposition()->GetEventReceiver()->horizontalWheel.AttachMethod(this, &GuiScrollView::OnHorizontalWheel); + styleController->GetBoundsComposition()->GetEventReceiver()->verticalWheel.AttachMethod(this, &GuiScrollView::OnVerticalWheel); + } + + GuiScrollView::GuiScrollView(StyleController* _styleController) + :GuiControl(_styleController) + ,supressScrolling(false) + { + Initialize(); + } + + GuiScrollView::GuiScrollView(IStyleProvider* styleProvider) + :GuiControl(new StyleController(styleProvider)) + ,supressScrolling(false) + { + Initialize(); + } + + vint GuiScrollView::GetSmallMove() + { + return GetFont().size * 2; + } + + Size GuiScrollView::GetBigMove() + { + return GetViewSize(); + } + + GuiScrollView::~GuiScrollView() + { + } + + void GuiScrollView::SetFont(const FontProperties& value) + { + GuiControl::SetFont(value); + CalculateView(); + } + + void GuiScrollView::CalculateView() + { + if(!supressScrolling) + { + Size fullSize = QueryFullSize(); + while(true) + { + styleController->AdjustView(fullSize); + styleController->AdjustView(fullSize); + supressScrolling = true; + CallUpdateView(); + supressScrolling = false; + + Size newSize=QueryFullSize(); + if (fullSize == newSize) + { + vint smallMove = GetSmallMove(); + styleController->GetHorizontalScroll()->SetSmallMove(smallMove); + styleController->GetVerticalScroll()->SetSmallMove(smallMove); + Size bigMove = GetBigMove(); + styleController->GetHorizontalScroll()->SetBigMove(bigMove.x); + styleController->GetVerticalScroll()->SetBigMove(bigMove.y); + break; + } + else + { + fullSize=newSize; + } + } + } + } + + Size GuiScrollView::GetViewSize() + { + Size viewSize=styleController->GetInternalContainerComposition()->GetBounds().GetSize(); + return viewSize; + } + + Rect GuiScrollView::GetViewBounds() + { + Point viewPosition= + Point( + styleController->GetHorizontalScroll()->GetPosition(), + styleController->GetVerticalScroll()->GetPosition() + ); + Size viewSize=GetViewSize(); + return Rect(viewPosition, viewSize); + } + + GuiScroll* GuiScrollView::GetHorizontalScroll() + { + return styleController->GetHorizontalScroll(); + } + + GuiScroll* GuiScrollView::GetVerticalScroll() + { + return styleController->GetVerticalScroll(); + } + + bool GuiScrollView::GetHorizontalAlwaysVisible() + { + return styleController->GetHorizontalAlwaysVisible(); + } + + void GuiScrollView::SetHorizontalAlwaysVisible(bool value) + { + styleController->SetHorizontalAlwaysVisible(value); + } + + bool GuiScrollView::GetVerticalAlwaysVisible() + { + return styleController->GetVerticalAlwaysVisible(); + } + + void GuiScrollView::SetVerticalAlwaysVisible(bool value) + { + styleController->SetVerticalAlwaysVisible(value); + } + +/*********************************************************************** +GuiScrollContainer::StyleController +***********************************************************************/ + + GuiScrollContainer::StyleController::StyleController(GuiScrollView::IStyleProvider* styleProvider) + :GuiScrollView::StyleController(styleProvider) + ,extendToFullWidth(false) + { + controlContainerComposition=new GuiBoundsComposition; + controlContainerComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + GetInternalContainerComposition()->AddChild(controlContainerComposition); + } + + GuiScrollContainer::StyleController::~StyleController() + { + } + + compositions::GuiGraphicsComposition* GuiScrollContainer::StyleController::GetContainerComposition() + { + return controlContainerComposition; + } + + void GuiScrollContainer::StyleController::MoveContainer(Point leftTop) + { + controlContainerComposition->SetBounds(Rect(leftTop, Size(0, 0))); + } + + bool GuiScrollContainer::StyleController::GetExtendToFullWidth() + { + return extendToFullWidth; + } + + void GuiScrollContainer::StyleController::SetExtendToFullWidth(bool value) + { + if(extendToFullWidth!=value) + { + extendToFullWidth=value; + if(value) + { + controlContainerComposition->SetAlignmentToParent(Margin(0, -1, 0, -1)); + } + else + { + controlContainerComposition->SetAlignmentToParent(Margin(-1, -1, -1, -1)); + } + } + } + +/*********************************************************************** +GuiScrollContainer +***********************************************************************/ + + void GuiScrollContainer::OnControlContainerBoundsChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + CalculateView(); + } + + Size GuiScrollContainer::QueryFullSize() + { + return styleController->GetContainerComposition()->GetBounds().GetSize(); + } + + void GuiScrollContainer::UpdateView(Rect viewBounds) + { + styleController->MoveContainer(Point(-viewBounds.x1, -viewBounds.y1)); + } + + GuiScrollContainer::GuiScrollContainer(GuiScrollContainer::IStyleProvider* styleProvider) + :GuiScrollView(new StyleController(styleProvider)) + ,styleController(0) + { + styleController=dynamic_cast(GetStyleController()); + GuiBoundsComposition* composition=dynamic_cast(styleController->GetContainerComposition()); + composition->BoundsChanged.AttachMethod(this, &GuiScrollContainer::OnControlContainerBoundsChanged); + } + + GuiScrollContainer::~GuiScrollContainer() + { + } + + bool GuiScrollContainer::GetExtendToFullWidth() + { + return styleController->GetExtendToFullWidth(); + } + + void GuiScrollContainer::SetExtendToFullWidth(bool value) + { + styleController->SetExtendToFullWidth(value); + } + } + } +} + +/*********************************************************************** +.\CONTROLS\GUIDIALOGS.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace controls + { + using namespace elements; + using namespace compositions; + using namespace collections; + using namespace reflection::description; + +/*********************************************************************** +GuiDialogBase +***********************************************************************/ + + GuiWindow* GuiDialogBase::GetHostWindow() + { + if (rootObject) + { + if (auto control = dynamic_cast(rootObject)) + { + if (auto host = control->GetRelatedControlHost()) + { + return dynamic_cast(host); + } + } + else if (auto composition = dynamic_cast(rootObject)) + { + if (auto host = composition->GetRelatedControlHost()) + { + return dynamic_cast(host); + } + } + } + return nullptr; + } + + GuiDialogBase::GuiDialogBase() + { + } + + GuiDialogBase::~GuiDialogBase() + { + } + + void GuiDialogBase::Attach(GuiInstanceRootObject* _rootObject) + { + rootObject = _rootObject; + } + + void GuiDialogBase::Detach(GuiInstanceRootObject* _rootObject) + { + rootObject = nullptr; + } + +/*********************************************************************** +GuiMessageDialog +***********************************************************************/ + + GuiMessageDialog::GuiMessageDialog() + { + } + + GuiMessageDialog::~GuiMessageDialog() + { + } + + INativeDialogService::MessageBoxButtonsInput GuiMessageDialog::GetInput() + { + return input; + } + + void GuiMessageDialog::SetInput(INativeDialogService::MessageBoxButtonsInput value) + { + input = value; + } + + INativeDialogService::MessageBoxDefaultButton GuiMessageDialog::GetDefaultButton() + { + return defaultButton; + } + + void GuiMessageDialog::SetDefaultButton(INativeDialogService::MessageBoxDefaultButton value) + { + defaultButton = value; + } + + INativeDialogService::MessageBoxIcons GuiMessageDialog::GetIcon() + { + return icon; + } + + void GuiMessageDialog::SetIcon(INativeDialogService::MessageBoxIcons value) + { + icon = value; + } + + INativeDialogService::MessageBoxModalOptions GuiMessageDialog::GetModalOption() + { + return modalOption; + } + + void GuiMessageDialog::SetModalOption(INativeDialogService::MessageBoxModalOptions value) + { + modalOption = value; + } + + const WString& GuiMessageDialog::GetText() + { + return text; + } + + void GuiMessageDialog::SetText(const WString& value) + { + text = value; + } + + const WString& GuiMessageDialog::GetTitle() + { + return title; + } + + void GuiMessageDialog::SetTitle(const WString& value) + { + title = value; + } + + INativeDialogService::MessageBoxButtonsOutput GuiMessageDialog::ShowDialog() + { + auto service = GetCurrentController()->DialogService(); + return service->ShowMessageBox(GetHostWindow()->GetNativeWindow(), text, title, input, defaultButton, icon, modalOption); + } + +/*********************************************************************** +GuiColorDialog +***********************************************************************/ + + GuiColorDialog::GuiColorDialog() + { + for (vint i = 0; i < 16; i++) + { + customColors.Add(Color()); + } + } + + GuiColorDialog::~GuiColorDialog() + { + } + + bool GuiColorDialog::GetEnabledCustomColor() + { + return enabledCustomColor; + } + + void GuiColorDialog::SetEnabledCustomColor(bool value) + { + enabledCustomColor = value; + } + + bool GuiColorDialog::GetOpenedCustomColor() + { + return openedCustomColor; + } + + void GuiColorDialog::SetOpenedCustomColor(bool value) + { + openedCustomColor = value; + } + + Color GuiColorDialog::GetSelectedColor() + { + return selectedColor; + } + + void GuiColorDialog::SetSelectedColor(Color value) + { + if (selectedColor != value) + { + selectedColor = value; + SelectedColorChanged.Execute(GuiEventArgs()); + } + } + + collections::List& GuiColorDialog::GetCustomColors() + { + return customColors; + } + + bool GuiColorDialog::ShowDialog() + { + Array colors; + CopyFrom(colors, customColors); + colors.Resize(16); + + INativeDialogService::ColorDialogCustomColorOptions options = + !enabledCustomColor ? INativeDialogService::CustomColorDisabled : + !openedCustomColor ? INativeDialogService::CustomColorEnabled : + INativeDialogService::CustomColorOpened; + + auto service = GetCurrentController()->DialogService(); + if (!service->ShowColorDialog(GetHostWindow()->GetNativeWindow(), selectedColor, showSelection, options, &colors[0])) + { + return false; + } + + CopyFrom(customColors, colors); + SelectedColorChanged.Execute(GuiEventArgs()); + return true; + } + +/*********************************************************************** +GuiFontDialog +***********************************************************************/ + + GuiFontDialog::GuiFontDialog() + { + } + + GuiFontDialog::~GuiFontDialog() + { + } + + const FontProperties& GuiFontDialog::GetSelectedFont() + { + return selectedFont; + } + + void GuiFontDialog::SetSelectedFont(const FontProperties& value) + { + if (selectedFont != value) + { + selectedFont = value; + SelectedFontChanged.Execute(GuiEventArgs()); + } + } + + Color GuiFontDialog::GetSelectedColor() + { + return selectedColor; + } + + void GuiFontDialog::SetSelectedColor(Color value) + { + if (selectedColor != value) + { + selectedColor = value; + SelectedColorChanged.Execute(GuiEventArgs()); + } + } + + bool GuiFontDialog::GetShowSelection() + { + return showSelection; + } + + void GuiFontDialog::SetShowSelection(bool value) + { + showSelection = value; + } + + bool GuiFontDialog::GetShowEffect() + { + return showEffect; + } + + void GuiFontDialog::SetShowEffect(bool value) + { + showEffect = value; + } + + bool GuiFontDialog::GetForceFontExist() + { + return forceFontExist; + } + + void GuiFontDialog::SetForceFontExist(bool value) + { + forceFontExist = value; + } + + bool GuiFontDialog::ShowDialog() + { + auto service = GetCurrentController()->DialogService(); + if (!service->ShowFontDialog(GetHostWindow()->GetNativeWindow(), selectedFont, selectedColor, showSelection, showEffect, forceFontExist)) + { + return false; + } + + SelectedColorChanged.Execute(GuiEventArgs()); + SelectedFontChanged.Execute(GuiEventArgs()); + return true; + } + +/*********************************************************************** +GuiFileDialogBase +***********************************************************************/ + + GuiFileDialogBase::GuiFileDialogBase() + { + } + + GuiFileDialogBase::~GuiFileDialogBase() + { + } + + const WString& GuiFileDialogBase::GetFilter() + { + return filter; + } + + void GuiFileDialogBase::SetFilter(const WString& value) + { + filter = value; + } + + vint GuiFileDialogBase::GetFilterIndex() + { + return filterIndex; + } + + void GuiFileDialogBase::SetFilterIndex(vint value) + { + if (filterIndex != value) + { + filterIndex = value; + FilterIndexChanged.Execute(GuiEventArgs()); + } + } + + bool GuiFileDialogBase::GetEnabledPreview() + { + return enabledPreview; + } + + void GuiFileDialogBase::SetEnabledPreview(bool value) + { + enabledPreview = value; + } + + WString GuiFileDialogBase::GetTitle() + { + return title; + } + + void GuiFileDialogBase::SetTitle(const WString& value) + { + title = value; + } + + WString GuiFileDialogBase::GetFileName() + { + return fileName; + } + + void GuiFileDialogBase::SetFileName(const WString& value) + { + if (fileName != value) + { + FileNameChanged.Execute(GuiEventArgs()); + } + } + + WString GuiFileDialogBase::GetDirectory() + { + return directory; + } + + void GuiFileDialogBase::SetDirectory(const WString& value) + { + directory = value; + } + + WString GuiFileDialogBase::GetDefaultExtension() + { + return defaultExtension; + } + + void GuiFileDialogBase::SetDefaultExtension(const WString& value) + { + defaultExtension = value; + } + + INativeDialogService::FileDialogOptions GuiFileDialogBase::GetOptions() + { + return options; + } + + void GuiFileDialogBase::SetOptions(INativeDialogService::FileDialogOptions value) + { + options = value; + } + +/*********************************************************************** +GuiOpenFileDialog +***********************************************************************/ + + GuiOpenFileDialog::GuiOpenFileDialog() + { + } + + GuiOpenFileDialog::~GuiOpenFileDialog() + { + } + + collections::List& GuiOpenFileDialog::GetFileNames() + { + return fileNames; + } + + bool GuiOpenFileDialog::ShowDialog() + { + fileNames.Clear(); + auto service = GetCurrentController()->DialogService(); + if (!service->ShowFileDialog( + GetHostWindow()->GetNativeWindow(), + fileNames, + filterIndex, + (enabledPreview ? INativeDialogService::FileDialogOpenPreview : INativeDialogService::FileDialogOpen), + title, + fileName, + directory, + defaultExtension, + filter, + options)) + { + return false; + } + + if (fileNames.Count() > 0) + { + fileName = fileNames[0]; + FileNameChanged.Execute(GuiEventArgs()); + FilterIndexChanged.Execute(GuiEventArgs()); + } + return true; + } + +/*********************************************************************** +GuiSaveFileDialog +***********************************************************************/ + + GuiSaveFileDialog::GuiSaveFileDialog() + { + } + + GuiSaveFileDialog::~GuiSaveFileDialog() + { + } + + bool GuiSaveFileDialog::ShowDialog() + { + List fileNames; + auto service = GetCurrentController()->DialogService(); + if (!service->ShowFileDialog( + GetHostWindow()->GetNativeWindow(), + fileNames, + filterIndex, + (enabledPreview ? INativeDialogService::FileDialogSavePreview : INativeDialogService::FileDialogSave), + title, + fileName, + directory, + defaultExtension, + filter, + options)) + { + return false; + } + + if (fileNames.Count() > 0) + { + fileName = fileNames[0]; + FileNameChanged.Execute(GuiEventArgs()); + FilterIndexChanged.Execute(GuiEventArgs()); + } + return true; + } + } + } +} + +/*********************************************************************** +.\CONTROLS\LISTCONTROLPACKAGE\GUILISTCONTROLS.CPP ***********************************************************************/ namespace vl @@ -9511,12801 +11405,7 @@ ItemProviderBase } /*********************************************************************** -CONTROLS\LISTCONTROLPACKAGE\GUILISTVIEWCONTROLS.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace controls - { - using namespace elements; - using namespace compositions; - using namespace collections; - using namespace reflection::description; - -/*********************************************************************** -GuiListViewColumnHeader -***********************************************************************/ - - GuiListViewColumnHeader::GuiListViewColumnHeader(IStyleController* _styleController) - :GuiMenuButton(_styleController) - ,styleController(_styleController) - { - styleController->SetColumnSortingState(columnSortingState); - } - - GuiListViewColumnHeader::~GuiListViewColumnHeader() - { - } - - bool GuiListViewColumnHeader::IsAltAvailable() - { - return false; - } - - ColumnSortingState GuiListViewColumnHeader::GetColumnSortingState() - { - return columnSortingState; - } - - void GuiListViewColumnHeader::SetColumnSortingState(ColumnSortingState value) - { - if(columnSortingState!=value) - { - columnSortingState=value; - styleController->SetColumnSortingState(columnSortingState); - } - } - -/*********************************************************************** -GuiListViewBase -***********************************************************************/ - - GuiListViewBase::GuiListViewBase(IStyleProvider* _styleProvider, GuiListControl::IItemProvider* _itemProvider) - :GuiSelectableListControl(_styleProvider, _itemProvider) - ,styleProvider(0) - { - styleProvider=dynamic_cast(styleController->GetStyleProvider()); - ColumnClicked.SetAssociatedComposition(boundsComposition); - } - - GuiListViewBase::~GuiListViewBase() - { - } - - GuiListViewBase::IStyleProvider* GuiListViewBase::GetListViewStyleProvider() - { - return styleProvider; - } - - namespace list - { - - const wchar_t* const IListViewItemView::Identifier = L"vl::presentation::controls::list::IListViewItemView"; - -/*********************************************************************** -ListViewColumnItemArranger::ColumnItemViewCallback -***********************************************************************/ - - ListViewColumnItemArranger::ColumnItemViewCallback::ColumnItemViewCallback(ListViewColumnItemArranger* _arranger) - :arranger(_arranger) - { - } - - ListViewColumnItemArranger::ColumnItemViewCallback::~ColumnItemViewCallback() - { - } - - void ListViewColumnItemArranger::ColumnItemViewCallback::OnColumnChanged() - { - arranger->RebuildColumns(); - FOREACH(ItemStyleRecord, style, arranger->visibleStyles) - { - if (auto callback = dynamic_cast(style.key)) - { - callback->OnColumnChanged(); - } - } - } - -/*********************************************************************** -ListViewColumnItemArranger -***********************************************************************/ - - const wchar_t* const ListViewColumnItemArranger::IColumnItemView::Identifier = L"vl::presentation::controls::list::ListViewColumnItemArranger::IColumnItemView"; - - void ListViewColumnItemArranger::ColumnClicked(vint index, compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - GuiItemEventArgs args(listView->ColumnClicked.GetAssociatedComposition()); - args.itemIndex=index; - listView->ColumnClicked.Execute(args); - } - - void ListViewColumnItemArranger::ColumnBoundsChanged(vint index, compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - GuiBoundsComposition* buttonBounds=columnHeaderButtons[index]->GetBoundsComposition(); - vint size=buttonBounds->GetBounds().Width(); - if(size>columnItemView->GetColumnSize(index)) - { - columnItemView->SetColumnSize(index, size); - } - } - - void ListViewColumnItemArranger::ColumnHeaderSplitterLeftButtonDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) - { - if(listView->GetVisuallyEnabled()) - { - arguments.handled=true; - splitterDragging=true; - splitterLatestX=arguments.x; - } - } - - void ListViewColumnItemArranger::ColumnHeaderSplitterLeftButtonUp(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) - { - if(listView->GetVisuallyEnabled()) - { - arguments.handled=true; - splitterDragging=false; - splitterLatestX=0; - } - } - - void ListViewColumnItemArranger::ColumnHeaderSplitterMouseMove(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) - { - if(splitterDragging) - { - vint offset=arguments.x-splitterLatestX; - vint index=columnHeaderSplitters.IndexOf(dynamic_cast(sender)); - if(index!=-1) - { - GuiBoundsComposition* buttonBounds=columnHeaderButtons[index]->GetBoundsComposition(); - Rect bounds=buttonBounds->GetBounds(); - Rect newBounds(bounds.LeftTop(), Size(bounds.Width()+offset, bounds.Height())); - buttonBounds->SetBounds(newBounds); - - vint finalSize=buttonBounds->GetBounds().Width(); - columnItemView->SetColumnSize(index, finalSize); - } - } - } - - void ListViewColumnItemArranger::RearrangeItemBounds() - { - FixedHeightItemArranger::RearrangeItemBounds(); - vint count = columnHeaders->GetParent()->Children().Count(); - columnHeaders->GetParent()->MoveChild(columnHeaders, count - 1); - columnHeaders->SetBounds(Rect(Point(-viewBounds.Left(), 0), Size(0, 0))); - } - - vint ListViewColumnItemArranger::GetWidth() - { - vint width=columnHeaders->GetBounds().Width()-SplitterWidth; - if(widthGetBounds().Height(); - } - - Size ListViewColumnItemArranger::OnCalculateTotalSize() - { - Size size=FixedHeightItemArranger::OnCalculateTotalSize(); - size.x+=SplitterWidth; - return size; - } - - void ListViewColumnItemArranger::DeleteColumnButtons() - { - for(vint i=columnHeaders->GetStackItems().Count()-1;i>=0;i--) - { - GuiStackItemComposition* item=columnHeaders->GetStackItems().Get(i); - columnHeaders->RemoveChild(item); - - GuiControl* button=item->Children().Get(0)->GetAssociatedControl(); - if(button) - { - item->RemoveChild(button->GetBoundsComposition()); - delete button; - } - delete item; - } - columnHeaderButtons.Clear(); - columnHeaderSplitters.Clear(); - } - - void ListViewColumnItemArranger::RebuildColumns() - { - if (columnItemView && columnHeaderButtons.Count() == listViewItemView->GetColumnCount()) - { - for (vint i = 0; i < listViewItemView->GetColumnCount(); i++) - { - GuiListViewColumnHeader* button = columnHeaderButtons[i]; - button->SetText(listViewItemView->GetColumnText(i)); - button->SetSubMenu(columnItemView->GetDropdownPopup(i), false); - button->SetColumnSortingState(columnItemView->GetSortingState(i)); - button->GetBoundsComposition()->SetBounds(Rect(Point(0, 0), Size(columnItemView->GetColumnSize(i), 0))); - } - } - else - { - DeleteColumnButtons(); - if (columnItemView && listViewItemView) - { - for (vint i = 0; i < listViewItemView->GetColumnCount(); i++) - { - GuiBoundsComposition* splitterComposition = new GuiBoundsComposition; - splitterComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - splitterComposition->SetAssociatedCursor(GetCurrentController()->ResourceService()->GetSystemCursor(INativeCursor::SizeWE)); - splitterComposition->SetAlignmentToParent(Margin(0, 0, -1, 0)); - splitterComposition->SetPreferredMinSize(Size(SplitterWidth, 0)); - columnHeaderSplitters.Add(splitterComposition); - - splitterComposition->GetEventReceiver()->leftButtonDown.AttachMethod(this, &ListViewColumnItemArranger::ColumnHeaderSplitterLeftButtonDown); - splitterComposition->GetEventReceiver()->leftButtonUp.AttachMethod(this, &ListViewColumnItemArranger::ColumnHeaderSplitterLeftButtonUp); - splitterComposition->GetEventReceiver()->mouseMove.AttachMethod(this, &ListViewColumnItemArranger::ColumnHeaderSplitterMouseMove); - } - for (vint i = 0; i < listViewItemView->GetColumnCount(); i++) - { - GuiListViewColumnHeader* button = new GuiListViewColumnHeader(styleProvider->CreateColumnStyle()); - button->SetText(listViewItemView->GetColumnText(i)); - button->SetSubMenu(columnItemView->GetDropdownPopup(i), false); - button->SetColumnSortingState(columnItemView->GetSortingState(i)); - button->GetBoundsComposition()->SetBounds(Rect(Point(0, 0), Size(columnItemView->GetColumnSize(i), 0))); - button->Clicked.AttachLambda(Curry(Func(this, &ListViewColumnItemArranger::ColumnClicked))(i)); - button->GetBoundsComposition()->BoundsChanged.AttachLambda(Curry(Func(this, &ListViewColumnItemArranger::ColumnBoundsChanged))(i)); - columnHeaderButtons.Add(button); - if (i > 0) - { - button->GetContainerComposition()->AddChild(columnHeaderSplitters[i - 1]); - } - - GuiStackItemComposition* item = new GuiStackItemComposition; - item->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - item->AddChild(button->GetBoundsComposition()); - columnHeaders->AddChild(item); - } - if (listViewItemView->GetColumnCount() > 0) - { - GuiBoundsComposition* splitterComposition = columnHeaderSplitters[listViewItemView->GetColumnCount() - 1]; - - GuiStackItemComposition* item = new GuiStackItemComposition; - item->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - item->AddChild(splitterComposition); - columnHeaders->AddChild(item); - } - } - } - callback->OnTotalSizeChanged(); - } - - ListViewColumnItemArranger::ListViewColumnItemArranger() - { - columnHeaders = new GuiStackComposition; - columnHeaders->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - columnItemViewCallback = new ColumnItemViewCallback(this); - } - - ListViewColumnItemArranger::~ListViewColumnItemArranger() - { - if(!columnHeaders->GetParent()) - { - DeleteColumnButtons(); - delete columnHeaders; - } - } - - void ListViewColumnItemArranger::AttachListControl(GuiListControl* value) - { - FixedHeightItemArranger::AttachListControl(value); - listView = dynamic_cast(value); - if (listView) - { - styleProvider = listView->GetListViewStyleProvider(); - listView->GetContainerComposition()->AddChild(columnHeaders); - listViewItemView = dynamic_cast(listView->GetItemProvider()->RequestView(IListViewItemView::Identifier)); - columnItemView = dynamic_cast(listView->GetItemProvider()->RequestView(IColumnItemView::Identifier)); - if (columnItemView) - { - columnItemView->AttachCallback(columnItemViewCallback.Obj()); - RebuildColumns(); - } - } - } - - void ListViewColumnItemArranger::DetachListControl() - { - if (listView) - { - if (columnItemView) - { - columnItemView->DetachCallback(columnItemViewCallback.Obj()); - columnItemView = nullptr; - } - listViewItemView = nullptr; - listView->GetContainerComposition()->RemoveChild(columnHeaders); - styleProvider = nullptr; - listView = nullptr; - } - FixedHeightItemArranger::DetachListControl(); - } - -/*********************************************************************** -ListViewSubItems -***********************************************************************/ - - void ListViewSubItems::NotifyUpdateInternal(vint start, vint count, vint newCount) - { - owner->NotifyUpdate(); - } - -/*********************************************************************** -ListViewItem -***********************************************************************/ - - void ListViewItem::NotifyUpdate() - { - if (owner) - { - vint index = owner->IndexOf(this); - owner->NotifyUpdateInternal(index, 1, 1); - } - } - - ListViewItem::ListViewItem() - :owner(0) - { - subItems.owner = this; - } - - ListViewSubItems& ListViewItem::GetSubItems() - { - return subItems; - } - - Ptr ListViewItem::GetSmallImage() - { - return smallImage; - } - - void ListViewItem::SetSmallImage(Ptr value) - { - smallImage = value; - NotifyUpdate(); - } - - Ptr ListViewItem::GetLargeImage() - { - return largeImage; - } - - void ListViewItem::SetLargeImage(Ptr value) - { - largeImage = value; - NotifyUpdate(); - } - - const WString& ListViewItem::GetText() - { - return text; - } - - void ListViewItem::SetText(const WString& value) - { - text = value; - NotifyUpdate(); - } - - description::Value ListViewItem::GetTag() - { - return tag; - } - - void ListViewItem::SetTag(const description::Value& value) - { - tag = value; - NotifyUpdate(); - } - -/*********************************************************************** -ListViewColumn -***********************************************************************/ - - void ListViewColumn::NotifyUpdate(bool affectItem) - { - if (owner) - { - vint index = owner->IndexOf(this); - owner->NotifyColumnUpdated(index, affectItem); - } - } - - ListViewColumn::ListViewColumn(const WString& _text, vint _size) - :text(_text) - ,size(_size) - { - } - - ListViewColumn::~ListViewColumn() - { - if (dropdownPopup && ownPopup) - { - SafeDeleteControl(dropdownPopup); - } - } - - const WString& ListViewColumn::GetText() - { - return text; - } - - void ListViewColumn::SetText(const WString& value) - { - if (text != value) - { - text = value; - NotifyUpdate(false); - } - } - - ItemProperty ListViewColumn::GetTextProperty() - { - return textProperty; - } - - void ListViewColumn::SetTextProperty(const ItemProperty& value) - { - textProperty = value; - NotifyUpdate(true); - } - - vint ListViewColumn::GetSize() - { - return size; - } - - void ListViewColumn::SetSize(vint value) - { - if (size != value) - { - size = value; - NotifyUpdate(false); - } - } - - bool ListViewColumn::GetOwnPopup() - { - return ownPopup; - } - - void ListViewColumn::SetOwnPopup(bool value) - { - ownPopup = value; - } - - GuiMenu* ListViewColumn::GetDropdownPopup() - { - return dropdownPopup; - } - - void ListViewColumn::SetDropdownPopup(GuiMenu* value) - { - if (dropdownPopup != value) - { - dropdownPopup = value; - NotifyUpdate(false); - } - } - - ColumnSortingState ListViewColumn::GetSortingState() - { - return sortingState; - } - - void ListViewColumn::SetSortingState(ColumnSortingState value) - { - if (sortingState != value) - { - sortingState = value; - NotifyUpdate(false); - } - } - -/*********************************************************************** -ListViewDataColumns -***********************************************************************/ - - void ListViewDataColumns::NotifyUpdateInternal(vint start, vint count, vint newCount) - { - itemProvider->NotifyAllItemsUpdate(); - } - - ListViewDataColumns::ListViewDataColumns(IListViewItemProvider* _itemProvider) - :itemProvider(_itemProvider) - { - } - - ListViewDataColumns::~ListViewDataColumns() - { - } - -/*********************************************************************** -ListViewColumns -***********************************************************************/ - - void ListViewColumns::NotifyColumnUpdated(vint column, bool affectItem) - { - affectItemFlag = affectItem; - NotifyUpdate(column, 1); - affectItemFlag = true; - } - - void ListViewColumns::AfterInsert(vint index, const Ptr& value) - { - collections::ObservableListBase>::AfterInsert(index, value); - value->owner = this; - } - - void ListViewColumns::BeforeRemove(vint index, const Ptr& value) - { - value->owner = 0; - collections::ObservableListBase>::BeforeRemove(index, value); - } - - void ListViewColumns::NotifyUpdateInternal(vint start, vint count, vint newCount) - { - itemProvider->NotifyAllColumnsUpdate(); - if (affectItemFlag) - { - itemProvider->NotifyAllItemsUpdate(); - } - } - - ListViewColumns::ListViewColumns(IListViewItemProvider* _itemProvider) - :itemProvider(_itemProvider) - { - } - - ListViewColumns::~ListViewColumns() - { - } - -/*********************************************************************** -ListViewItemProvider -***********************************************************************/ - - void ListViewItemProvider::AfterInsert(vint index, const Ptr& value) - { - ListProvider>::AfterInsert(index, value); - value->owner = this; - } - - void ListViewItemProvider::BeforeRemove(vint index, const Ptr& value) - { - value->owner = 0; - ListProvider>::AfterInsert(index, value); - } - - void ListViewItemProvider::NotifyAllItemsUpdate() - { - NotifyUpdate(0, Count()); - } - - void ListViewItemProvider::NotifyAllColumnsUpdate() - { - for (vint i = 0; i < columnItemViewCallbacks.Count(); i++) - { - columnItemViewCallbacks[i]->OnColumnChanged(); - } - } - - Ptr ListViewItemProvider::GetSmallImage(vint itemIndex) - { - return Get(itemIndex)->smallImage; - } - - Ptr ListViewItemProvider::GetLargeImage(vint itemIndex) - { - return Get(itemIndex)->largeImage; - } - - WString ListViewItemProvider::GetText(vint itemIndex) - { - return Get(itemIndex)->text; - } - - WString ListViewItemProvider::GetSubItem(vint itemIndex, vint index) - { - Ptr item=Get(itemIndex); - if(index<0 || index>=item->GetSubItems().Count()) - { - return L""; - } - else - { - return item->GetSubItems()[index]; - } - } - - vint ListViewItemProvider::GetDataColumnCount() - { - return dataColumns.Count(); - } - - vint ListViewItemProvider::GetDataColumn(vint index) - { - return dataColumns[index]; - } - - vint ListViewItemProvider::GetColumnCount() - { - return columns.Count(); - } - - WString ListViewItemProvider::GetColumnText(vint index) - { - if (index<0 || index >= columns.Count()) - { - return L""; - } - else - { - return columns[index]->GetText(); - } - } - - bool ListViewItemProvider::AttachCallback(ListViewColumnItemArranger::IColumnItemViewCallback* value) - { - if(columnItemViewCallbacks.Contains(value)) - { - return false; - } - else - { - columnItemViewCallbacks.Add(value); - return true; - } - } - - bool ListViewItemProvider::DetachCallback(ListViewColumnItemArranger::IColumnItemViewCallback* value) - { - vint index=columnItemViewCallbacks.IndexOf(value); - if(index==-1) - { - return false; - } - else - { - columnItemViewCallbacks.Remove(value); - return true; - } - } - - vint ListViewItemProvider::GetColumnSize(vint index) - { - if(index<0 || index>=columns.Count()) - { - return 0; - } - else - { - return columns[index]->GetSize(); - } - } - - void ListViewItemProvider::SetColumnSize(vint index, vint value) - { - if(index>=0 && indexSetSize(value); - } - } - - GuiMenu* ListViewItemProvider::GetDropdownPopup(vint index) - { - if(index<0 || index>=columns.Count()) - { - return 0; - } - else - { - return columns[index]->GetDropdownPopup(); - } - } - - ColumnSortingState ListViewItemProvider::GetSortingState(vint index) - { - if (index < 0 || index >= columns.Count()) - { - return ColumnSortingState::NotSorted; - } - else - { - return columns[index]->GetSortingState(); - } - } - - WString ListViewItemProvider::GetTextValue(vint itemIndex) - { - return GetText(itemIndex); - } - - description::Value ListViewItemProvider::GetBindingValue(vint itemIndex) - { - return Value::From(Get(itemIndex)); - } - - ListViewItemProvider::ListViewItemProvider() - :columns(this) - , dataColumns(this) - { - } - - ListViewItemProvider::~ListViewItemProvider() - { - } - - IDescriptable* ListViewItemProvider::RequestView(const WString& identifier) - { - if (identifier == IListViewItemView::Identifier) - { - return (IListViewItemView*)this; - } - else if (identifier == ListViewColumnItemArranger::IColumnItemView::Identifier) - { - return (ListViewColumnItemArranger::IColumnItemView*)this; - } - else - { - return 0; - } - } - - ListViewDataColumns& ListViewItemProvider::GetDataColumns() - { - return dataColumns; - } - - ListViewColumns& ListViewItemProvider::GetColumns() - { - return columns; - } - } - -/*********************************************************************** -GuiListView -***********************************************************************/ - - void GuiVirtualListView::OnStyleInstalled(vint itemIndex, ItemStyle* style) - { - GuiListViewBase::OnStyleInstalled(itemIndex, style); - } - - void GuiVirtualListView::OnItemTemplateChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - view = ListViewView::Unknown; - } - - GuiVirtualListView::GuiVirtualListView(IStyleProvider* _styleProvider, GuiListControl::IItemProvider* _itemProvider) - :GuiListViewBase(_styleProvider, _itemProvider) - { - SetView(ListViewView::Detail); - } - - GuiVirtualListView::~GuiVirtualListView() - { - } - - ListViewView GuiVirtualListView::GetView() - { - return view; - } - - void GuiVirtualListView::SetView(ListViewView _view) - { - switch (_view) - { - case ListViewView::BigIcon: - SetStyleAndArranger( - [](const Value&) { return new list::BigIconListViewItemTemplate; }, - new list::FixedSizeMultiColumnItemArranger - ); - break; - case ListViewView::SmallIcon: - SetStyleAndArranger( - [](const Value&) { return new list::SmallIconListViewItemTemplate; }, - new list::FixedSizeMultiColumnItemArranger - ); - break; - case ListViewView::List: - SetStyleAndArranger( - [](const Value&) { return new list::ListListViewItemTemplate; }, - new list::FixedHeightMultiColumnItemArranger - ); - break; - case ListViewView::Tile: - SetStyleAndArranger( - [](const Value&) { return new list::TileListViewItemTemplate; }, - new list::FixedSizeMultiColumnItemArranger - ); - break; - case ListViewView::Information: - SetStyleAndArranger( - [](const Value&) { return new list::InformationListViewItemTemplate; }, - new list::FixedHeightItemArranger - ); - break; - case ListViewView::Detail: - SetStyleAndArranger( - [](const Value&) { return new list::DetailListViewItemTemplate; }, - new list::ListViewColumnItemArranger - ); - break; - default:; - } - view = _view; - } - -/*********************************************************************** -GuiListView -***********************************************************************/ - - GuiListView::GuiListView(IStyleProvider* _styleProvider) - :GuiVirtualListView(_styleProvider, new list::ListViewItemProvider) - { - items=dynamic_cast(itemProvider.Obj()); - } - - GuiListView::~GuiListView() - { - } - - list::ListViewItemProvider& GuiListView::GetItems() - { - return *items; - } - - list::ListViewDataColumns& GuiListView::GetDataColumns() - { - return items->GetDataColumns(); - } - - list::ListViewColumns& GuiListView::GetColumns() - { - return items->GetColumns(); - } - - Ptr GuiListView::GetSelectedItem() - { - vint index = GetSelectedItemIndex(); - if (index == -1) return 0; - return items->Get(index); - } - } - } -} - -/*********************************************************************** -CONTROLS\LISTCONTROLPACKAGE\GUILISTVIEWITEMTEMPLATES.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace controls - { - using namespace elements; - using namespace compositions; - using namespace collections; - using namespace reflection::description; - - namespace list - { - -/*********************************************************************** -DefaultListViewItemTemplate -***********************************************************************/ - - DefaultListViewItemTemplate::DefaultListViewItemTemplate() - { - SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - } - - DefaultListViewItemTemplate::~DefaultListViewItemTemplate() - { - } - -/*********************************************************************** -BigIconListViewItemTemplate -***********************************************************************/ - - void BigIconListViewItemTemplate::OnInitialize() - { - DefaultListViewItemTemplate::OnInitialize(); - { - auto table = new GuiTableComposition; - AddChild(table); - table->SetRowsAndColumns(2, 3); - table->SetRowOption(0, GuiCellOption::MinSizeOption()); - table->SetRowOption(1, GuiCellOption::MinSizeOption()); - table->SetColumnOption(0, GuiCellOption::PercentageOption(0.5)); - table->SetColumnOption(1, GuiCellOption::MinSizeOption()); - table->SetColumnOption(2, GuiCellOption::PercentageOption(0.5)); - table->SetAlignmentToParent(Margin(0, 0, 0, 0)); - table->SetCellPadding(5); - { - auto cell = new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 1, 1, 1); - cell->SetPreferredMinSize(Size(32, 32)); - - image = GuiImageFrameElement::Create(); - image->SetStretch(true); - cell->SetOwnedElement(image); - } - { - auto cell = new GuiCellComposition; - table->AddChild(cell); - cell->SetMinSizeLimitation(GuiGraphicsComposition::NoLimit); - cell->SetSite(1, 0, 1, 3); - cell->SetPreferredMinSize(Size(64, 40)); - - text = GuiSolidLabelElement::Create(); - text->SetAlignments(Alignment::Center, Alignment::Top); - text->SetWrapLine(true); - text->SetEllipse(true); - cell->SetOwnedElement(text); - } - } - - if (auto listView = dynamic_cast(listControl)) - { - auto styleProvider = listView->GetListViewStyleProvider(); - auto itemIndex = GetIndex(); - if (auto view = dynamic_cast(listView->GetItemProvider()->RequestView(IListViewItemView::Identifier))) - { - auto imageData = view->GetLargeImage(itemIndex); - if (imageData) - { - image->SetImage(imageData->GetImage(), imageData->GetFrameIndex()); - } - else - { - image->SetImage(nullptr); - } - text->SetText(view->GetText(itemIndex)); - text->SetColor(styleProvider->GetPrimaryTextColor()); - } - } - - FontChanged.AttachMethod(this, &BigIconListViewItemTemplate::OnFontChanged); - - FontChanged.Execute(compositions::GuiEventArgs(this)); - } - - void BigIconListViewItemTemplate::OnFontChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - text->SetFont(GetFont()); - } - - BigIconListViewItemTemplate::BigIconListViewItemTemplate() - { - } - - BigIconListViewItemTemplate::~BigIconListViewItemTemplate() - { - } - -/*********************************************************************** -SmallIconListViewItemTemplate -***********************************************************************/ - - void SmallIconListViewItemTemplate::OnInitialize() - { - DefaultListViewItemTemplate::OnInitialize(); - { - auto table = new GuiTableComposition; - AddChild(table); - table->SetRowsAndColumns(3, 2); - table->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); - table->SetRowOption(1, GuiCellOption::MinSizeOption()); - table->SetRowOption(2, GuiCellOption::PercentageOption(0.5)); - table->SetColumnOption(0, GuiCellOption::MinSizeOption()); - table->SetColumnOption(1, GuiCellOption::MinSizeOption()); - table->SetAlignmentToParent(Margin(0, 0, 0, 0)); - table->SetCellPadding(2); - { - GuiCellComposition* cell = new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(1, 0, 1, 1); - cell->SetPreferredMinSize(Size(16, 16)); - - image = GuiImageFrameElement::Create(); - image->SetStretch(true); - cell->SetOwnedElement(image); - } - { - GuiCellComposition* cell = new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 1, 3, 1); - cell->SetPreferredMinSize(Size(192, 0)); - - text = GuiSolidLabelElement::Create(); - text->SetAlignments(Alignment::Left, Alignment::Center); - text->SetEllipse(true); - cell->SetOwnedElement(text); - } - } - - if (auto listView = dynamic_cast(listControl)) - { - auto styleProvider = listView->GetListViewStyleProvider(); - auto itemIndex = GetIndex(); - if (auto view = dynamic_cast(listView->GetItemProvider()->RequestView(IListViewItemView::Identifier))) - { - auto imageData = view->GetSmallImage(itemIndex); - if (imageData) - { - image->SetImage(imageData->GetImage(), imageData->GetFrameIndex()); - } - else - { - image->SetImage(nullptr); - } - text->SetText(view->GetText(itemIndex)); - text->SetColor(styleProvider->GetPrimaryTextColor()); - } - } - - FontChanged.AttachMethod(this, &SmallIconListViewItemTemplate::OnFontChanged); - - FontChanged.Execute(compositions::GuiEventArgs(this)); - } - - void SmallIconListViewItemTemplate::OnFontChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - text->SetFont(GetFont()); - } - - SmallIconListViewItemTemplate::SmallIconListViewItemTemplate() - { - } - - SmallIconListViewItemTemplate::~SmallIconListViewItemTemplate() - { - } - -/*********************************************************************** -ListListViewItemTemplate -***********************************************************************/ - - void ListListViewItemTemplate::OnInitialize() - { - DefaultListViewItemTemplate::OnInitialize(); - { - auto table = new GuiTableComposition; - AddChild(table); - table->SetRowsAndColumns(3, 2); - table->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); - table->SetRowOption(1, GuiCellOption::MinSizeOption()); - table->SetRowOption(2, GuiCellOption::PercentageOption(0.5)); - table->SetColumnOption(0, GuiCellOption::MinSizeOption()); - table->SetColumnOption(1, GuiCellOption::MinSizeOption()); - table->SetAlignmentToParent(Margin(0, 0, 0, 0)); - table->SetCellPadding(2); - { - auto cell = new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(1, 0, 1, 1); - cell->SetPreferredMinSize(Size(16, 16)); - - image = GuiImageFrameElement::Create(); - image->SetStretch(true); - cell->SetOwnedElement(image); - } - { - auto cell = new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 1, 3, 1); - cell->SetMargin(Margin(0, 0, 16, 0)); - - text = GuiSolidLabelElement::Create(); - text->SetAlignments(Alignment::Left, Alignment::Center); - cell->SetOwnedElement(text); - } - } - - if (auto listView = dynamic_cast(listControl)) - { - auto styleProvider = listView->GetListViewStyleProvider(); - auto itemIndex = GetIndex(); - if (auto view = dynamic_cast(listView->GetItemProvider()->RequestView(IListViewItemView::Identifier))) - { - auto imageData = view->GetSmallImage(itemIndex); - if (imageData) - { - image->SetImage(imageData->GetImage(), imageData->GetFrameIndex()); - } - else - { - image->SetImage(nullptr); - } - text->SetText(view->GetText(itemIndex)); - text->SetColor(styleProvider->GetPrimaryTextColor()); - } - } - - FontChanged.AttachMethod(this, &ListListViewItemTemplate::OnFontChanged); - - FontChanged.Execute(compositions::GuiEventArgs(this)); - } - - void ListListViewItemTemplate::OnFontChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - text->SetFont(GetFont()); - } - - ListListViewItemTemplate::ListListViewItemTemplate() - { - } - - ListListViewItemTemplate::~ListListViewItemTemplate() - { - } - -/*********************************************************************** -TileListViewItemTemplate -***********************************************************************/ - - elements::GuiSolidLabelElement* TileListViewItemTemplate::CreateTextElement(vint textRow) - { - auto cell = new GuiCellComposition; - textTable->AddChild(cell); - cell->SetSite(textRow + 1, 0, 1, 1); - - auto textElement = GuiSolidLabelElement::Create(); - textElement->SetAlignments(Alignment::Left, Alignment::Center); - textElement->SetEllipse(true); - cell->SetOwnedElement(textElement); - return textElement; - } - - void TileListViewItemTemplate::ResetTextTable(vint textRows) - { - textTable->SetRowsAndColumns(textRows + 2, 1); - textTable->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); - for (vint i = 0; iSetRowOption(i + 1, GuiCellOption::MinSizeOption()); - } - textTable->SetRowOption(textRows + 1, GuiCellOption::PercentageOption(0.5)); - textTable->SetColumnOption(0, GuiCellOption::PercentageOption(1.0)); - } - - void TileListViewItemTemplate::OnInitialize() - { - DefaultListViewItemTemplate::OnInitialize(); - { - auto table = new GuiTableComposition; - AddChild(table); - table->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - table->SetRowsAndColumns(3, 2); - table->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); - table->SetRowOption(1, GuiCellOption::MinSizeOption()); - table->SetRowOption(2, GuiCellOption::PercentageOption(0.5)); - table->SetColumnOption(0, GuiCellOption::MinSizeOption()); - table->SetColumnOption(1, GuiCellOption::MinSizeOption()); - table->SetAlignmentToParent(Margin(0, 0, 0, 0)); - table->SetCellPadding(4); - { - auto cell = new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(1, 0, 1, 1); - cell->SetPreferredMinSize(Size(32, 32)); - - image = GuiImageFrameElement::Create(); - image->SetStretch(true); - cell->SetOwnedElement(image); - } - { - auto cell = new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 1, 3, 1); - cell->SetPreferredMinSize(Size(224, 0)); - - textTable = new GuiTableComposition; - textTable->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - textTable->SetCellPadding(1); - ResetTextTable(1); - textTable->SetAlignmentToParent(Margin(0, 0, 0, 0)); - cell->AddChild(textTable); - { - text = CreateTextElement(0); - } - } - } - - if (auto listView = dynamic_cast(listControl)) - { - auto styleProvider = listView->GetListViewStyleProvider(); - auto itemIndex = GetIndex(); - if (auto view = dynamic_cast(listView->GetItemProvider()->RequestView(IListViewItemView::Identifier))) - { - auto imageData = view->GetLargeImage(itemIndex); - if (imageData) - { - image->SetImage(imageData->GetImage(), imageData->GetFrameIndex()); - } - else - { - image->SetImage(nullptr); - } - text->SetText(view->GetText(itemIndex)); - text->SetColor(styleProvider->GetPrimaryTextColor()); - - vint dataColumnCount = view->GetDataColumnCount(); - ResetTextTable(dataColumnCount + 1); - dataTexts.Resize(dataColumnCount); - for (vint i = 0; i < dataColumnCount; i++) - { - dataTexts[i] = CreateTextElement(i + 1); - dataTexts[i]->SetText(view->GetSubItem(itemIndex, view->GetDataColumn(i))); - dataTexts[i]->SetColor(styleProvider->GetSecondaryTextColor()); - } - } - } - - FontChanged.AttachMethod(this, &TileListViewItemTemplate::OnFontChanged); - - FontChanged.Execute(compositions::GuiEventArgs(this)); - } - - void TileListViewItemTemplate::OnFontChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - text->SetFont(GetFont()); - if (auto view = dynamic_cast(listControl->GetItemProvider()->RequestView(IListViewItemView::Identifier))) - { - vint dataColumnCount = view->GetDataColumnCount(); - for (vint i = 0; i < dataColumnCount; i++) - { - dataTexts[i]->SetFont(GetFont()); - } - } - } - - TileListViewItemTemplate::TileListViewItemTemplate() - { - } - - TileListViewItemTemplate::~TileListViewItemTemplate() - { - } - -/*********************************************************************** -InformationListViewItemTemplate -***********************************************************************/ - - void InformationListViewItemTemplate::OnInitialize() - { - DefaultListViewItemTemplate::OnInitialize(); - { - bottomLine = GuiSolidBackgroundElement::Create(); - bottomLineComposition = new GuiBoundsComposition; - bottomLineComposition->SetOwnedElement(bottomLine); - bottomLineComposition->SetAlignmentToParent(Margin(8, -1, 8, 0)); - bottomLineComposition->SetPreferredMinSize(Size(0, 1)); - AddChild(bottomLineComposition); - - auto table = new GuiTableComposition; - AddChild(table); - table->SetRowsAndColumns(3, 3); - table->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); - table->SetRowOption(1, GuiCellOption::MinSizeOption()); - table->SetRowOption(2, GuiCellOption::PercentageOption(0.5)); - table->SetColumnOption(0, GuiCellOption::MinSizeOption()); - table->SetColumnOption(1, GuiCellOption::PercentageOption(1.0)); - table->SetColumnOption(2, GuiCellOption::MinSizeOption()); - table->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - table->SetAlignmentToParent(Margin(0, 0, 0, 0)); - table->SetCellPadding(4); - { - auto cell = new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(1, 0, 1, 1); - cell->SetPreferredMinSize(Size(32, 32)); - - image = GuiImageFrameElement::Create(); - image->SetStretch(true); - cell->SetOwnedElement(image); - } - { - auto cell = new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 1, 3, 1); - - text = GuiSolidLabelElement::Create(); - text->SetEllipse(true); - cell->SetOwnedElement(text); - } - { - auto cell = new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 2, 3, 1); - cell->SetPreferredMinSize(Size(224, 0)); - - textTable = new GuiTableComposition; - textTable->SetCellPadding(4); - textTable->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - textTable->SetAlignmentToParent(Margin(0, 0, 0, 0)); - cell->AddChild(textTable); - } - } - - if (auto listView = dynamic_cast(listControl)) - { - auto styleProvider = listView->GetListViewStyleProvider(); - auto itemIndex = GetIndex(); - if (auto view = dynamic_cast(listView->GetItemProvider()->RequestView(IListViewItemView::Identifier))) - { - auto imageData = view->GetLargeImage(itemIndex); - if (imageData) - { - image->SetImage(imageData->GetImage(), imageData->GetFrameIndex()); - } - else - { - image->SetImage(nullptr); - } - text->SetText(view->GetText(itemIndex)); - text->SetColor(styleProvider->GetPrimaryTextColor()); - bottomLine->SetColor(styleProvider->GetItemSeparatorColor()); - - vint dataColumnCount = view->GetDataColumnCount(); - columnTexts.Resize(dataColumnCount); - dataTexts.Resize(dataColumnCount); - - textTable->SetRowsAndColumns(dataColumnCount + 2, 1); - textTable->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); - for (vint i = 0; i < dataColumnCount; i++) - { - textTable->SetRowOption(i + 1, GuiCellOption::MinSizeOption()); - } - textTable->SetRowOption(dataColumnCount + 1, GuiCellOption::PercentageOption(0.5)); - textTable->SetColumnOption(0, GuiCellOption::PercentageOption(1.0)); - - for (vint i = 0; i < dataColumnCount; i++) - { - auto cell = new GuiCellComposition; - textTable->AddChild(cell); - cell->SetSite(i + 1, 0, 1, 1); - - auto dataTable = new GuiTableComposition; - dataTable->SetRowsAndColumns(1, 2); - dataTable->SetRowOption(0, GuiCellOption::MinSizeOption()); - dataTable->SetColumnOption(0, GuiCellOption::MinSizeOption()); - dataTable->SetColumnOption(1, GuiCellOption::PercentageOption(1.0)); - dataTable->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - dataTable->SetAlignmentToParent(Margin(0, 0, 0, 0)); - cell->AddChild(dataTable); - { - auto cell = new GuiCellComposition; - dataTable->AddChild(cell); - cell->SetSite(0, 0, 1, 1); - - columnTexts[i] = GuiSolidLabelElement::Create(); - columnTexts[i]->SetText(view->GetColumnText(view->GetDataColumn(i) + 1) + L": "); - columnTexts[i]->SetColor(styleProvider->GetSecondaryTextColor()); - cell->SetOwnedElement(columnTexts[i]); - } - { - auto cell = new GuiCellComposition; - dataTable->AddChild(cell); - cell->SetSite(0, 1, 1, 1); - - dataTexts[i]= GuiSolidLabelElement::Create(); - dataTexts[i]->SetEllipse(true); - dataTexts[i]->SetText(view->GetSubItem(itemIndex, view->GetDataColumn(i))); - dataTexts[i]->SetColor(styleProvider->GetPrimaryTextColor()); - cell->SetOwnedElement(dataTexts[i]); - } - } - } - } - - FontChanged.AttachMethod(this, &InformationListViewItemTemplate::OnFontChanged); - - FontChanged.Execute(compositions::GuiEventArgs(this)); - } - - void InformationListViewItemTemplate::OnFontChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - { - auto font = GetFont(); - font.size = (vint)(font.size * 1.2); - text->SetFont(font); - } - if (auto view = dynamic_cast(listControl->GetItemProvider()->RequestView(IListViewItemView::Identifier))) - { - vint dataColumnCount = view->GetDataColumnCount(); - for (vint i = 0; i < dataColumnCount; i++) - { - columnTexts[i]->SetFont(GetFont()); - dataTexts[i]->SetFont(GetFont()); - } - } - } - - InformationListViewItemTemplate::InformationListViewItemTemplate() - { - } - - InformationListViewItemTemplate::~InformationListViewItemTemplate() - { - } - -/*********************************************************************** -DetailListViewItemTemplate -***********************************************************************/ - - void DetailListViewItemTemplate::OnInitialize() - { - DefaultListViewItemTemplate::OnInitialize(); - columnItemView = dynamic_cast(listControl->GetItemProvider()->RequestView(ListViewColumnItemArranger::IColumnItemView::Identifier)); - - { - textTable = new GuiTableComposition; - textTable->SetAlignmentToParent(Margin(0, 0, 0, 0)); - textTable->SetRowsAndColumns(1, 1); - textTable->SetRowOption(0, GuiCellOption::MinSizeOption()); - textTable->SetColumnOption(0, GuiCellOption::AbsoluteOption(0)); - AddChild(textTable); - { - auto cell = new GuiCellComposition; - textTable->AddChild(cell); - cell->SetSite(0, 0, 1, 1); - - auto table = new GuiTableComposition; - cell->AddChild(table); - table->SetRowsAndColumns(3, 2); - table->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); - table->SetRowOption(1, GuiCellOption::MinSizeOption()); - table->SetRowOption(2, GuiCellOption::PercentageOption(0.5)); - table->SetColumnOption(0, GuiCellOption::MinSizeOption()); - table->SetColumnOption(1, GuiCellOption::PercentageOption(1.0)); - table->SetAlignmentToParent(Margin(0, 0, 0, 0)); - table->SetCellPadding(2); - { - auto cell = new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(1, 0, 1, 1); - cell->SetPreferredMinSize(Size(16, 16)); - - image = GuiImageFrameElement::Create(); - image->SetStretch(true); - cell->SetOwnedElement(image); - } - { - auto cell = new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 1, 3, 1); - cell->SetMargin(Margin(0, 0, 8, 0)); - - text = GuiSolidLabelElement::Create(); - text->SetAlignments(Alignment::Left, Alignment::Center); - text->SetEllipse(true); - cell->SetOwnedElement(text); - } - } - } - - if (auto listView = dynamic_cast(listControl)) - { - auto styleProvider = listView->GetListViewStyleProvider(); - auto itemIndex = GetIndex(); - if (auto view = dynamic_cast(listView->GetItemProvider()->RequestView(IListViewItemView::Identifier))) - { - auto imageData = view->GetSmallImage(itemIndex); - if (imageData) - { - image->SetImage(imageData->GetImage(), imageData->GetFrameIndex()); - } - else - { - image->SetImage(0); - } - text->SetText(view->GetText(itemIndex)); - text->SetColor(styleProvider->GetPrimaryTextColor()); - - vint columnCount = view->GetColumnCount() - 1; - subItems.Resize(columnCount); - textTable->SetRowsAndColumns(1, columnCount + 1); - for (vint i = 0; i < columnCount; i++) - { - auto cell = new GuiCellComposition; - textTable->AddChild(cell); - cell->SetSite(0, i + 1, 1, 1); - cell->SetMargin(Margin(8, 0, 8, 0)); - - subItems[i] = GuiSolidLabelElement::Create(); - subItems[i]->SetAlignments(Alignment::Left, Alignment::Center); - subItems[i]->SetFont(text->GetFont()); - subItems[i]->SetEllipse(true); - subItems[i]->SetText(view->GetSubItem(itemIndex, i)); - subItems[i]->SetColor(styleProvider->GetSecondaryTextColor()); - cell->SetOwnedElement(subItems[i]); - } - OnColumnChanged(); - } - } - - FontChanged.AttachMethod(this, &DetailListViewItemTemplate::OnFontChanged); - - FontChanged.Execute(compositions::GuiEventArgs(this)); - } - - void DetailListViewItemTemplate::OnColumnChanged() - { - if (auto view = dynamic_cast(listControl->GetItemProvider()->RequestView(IListViewItemView::Identifier))) - { - if (columnItemView) - { - vint columnCount = view->GetColumnCount(); - if (columnCount>textTable->GetColumns()) - { - columnCount = textTable->GetColumns(); - } - for (vint i = 0; iSetColumnOption(i, GuiCellOption::AbsoluteOption(columnItemView->GetColumnSize(i))); - } - textTable->UpdateCellBounds(); - } - } - } - - void DetailListViewItemTemplate::OnFontChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - text->SetFont(GetFont()); - if (auto view = dynamic_cast(listControl->GetItemProvider()->RequestView(IListViewItemView::Identifier))) - { - vint columnCount = view->GetColumnCount() - 1; - for (vint i = 0; i < columnCount; i++) - { - subItems[i]->SetFont(GetFont()); - } - } - } - - DetailListViewItemTemplate::DetailListViewItemTemplate() - { - } - - DetailListViewItemTemplate::~DetailListViewItemTemplate() - { - } - } - } - } -} - -/*********************************************************************** -CONTROLS\LISTCONTROLPACKAGE\GUITEXTLISTCONTROLS.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace controls - { - using namespace collections; - using namespace elements; - using namespace compositions; - using namespace reflection::description; - - namespace list - { - const wchar_t* const ITextItemView::Identifier = L"vl::presentation::controls::list::ITextItemView"; - -/*********************************************************************** -DefaultTextListItemTemplate -***********************************************************************/ - - DefaultTextListItemTemplate::BulletStyle* DefaultTextListItemTemplate::CreateBulletStyle() - { - return nullptr; - } - - void DefaultTextListItemTemplate::OnInitialize() - { - templates::GuiTextListItemTemplate::OnInitialize(); - SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - - textElement = GuiSolidLabelElement::Create(); - textElement->SetAlignments(Alignment::Left, Alignment::Center); - - GuiBoundsComposition* textComposition = new GuiBoundsComposition; - textComposition->SetOwnedElement(textElement); - textComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - - if (auto bulletStyleController = CreateBulletStyle()) - { - bulletButton = new GuiSelectableButton(bulletStyleController); - bulletButton->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); - bulletButton->SelectedChanged.AttachMethod(this, &DefaultTextListItemTemplate::OnBulletSelectedChanged); - - GuiTableComposition* table = new GuiTableComposition; - AddChild(table); - table->SetAlignmentToParent(Margin(0, 0, 0, 0)); - table->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - table->SetRowsAndColumns(1, 2); - table->SetRowOption(0, GuiCellOption::PercentageOption(1.0)); - table->SetColumnOption(0, GuiCellOption::MinSizeOption()); - table->SetColumnOption(1, GuiCellOption::PercentageOption(1.0)); - { - GuiCellComposition* cell = new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 0, 1, 1); - cell->AddChild(bulletButton->GetBoundsComposition()); - } - { - GuiCellComposition* cell = new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 1, 1, 1); - cell->AddChild(textComposition); - textComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - } - } - else - { - AddChild(textComposition); - textComposition->SetAlignmentToParent(Margin(5, 0, 0, 0)); - } - - FontChanged.AttachMethod(this, &DefaultTextListItemTemplate::OnFontChanged); - TextChanged.AttachMethod(this, &DefaultTextListItemTemplate::OnTextChanged); - TextColorChanged.AttachMethod(this, &DefaultTextListItemTemplate::OnTextColorChanged); - CheckedChanged.AttachMethod(this, &DefaultTextListItemTemplate::OnCheckedChanged); - - FontChanged.Execute(compositions::GuiEventArgs(this)); - TextChanged.Execute(compositions::GuiEventArgs(this)); - TextColorChanged.Execute(compositions::GuiEventArgs(this)); - CheckedChanged.Execute(compositions::GuiEventArgs(this)); - } - - void DefaultTextListItemTemplate::OnFontChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - textElement->SetFont(GetFont()); - } - - void DefaultTextListItemTemplate::OnTextChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - textElement->SetText(GetText()); - } - - void DefaultTextListItemTemplate::OnTextColorChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - textElement->SetColor(GetTextColor()); - } - - void DefaultTextListItemTemplate::OnCheckedChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if (bulletButton) - { - supressEdit = true; - bulletButton->SetSelected(GetChecked()); - supressEdit = false; - } - } - - void DefaultTextListItemTemplate::OnBulletSelectedChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if (!supressEdit) - { - if (auto textItemView = dynamic_cast(listControl->GetItemProvider()->RequestView(ITextItemView::Identifier))) - { - BeginEditListItem(); - textItemView->SetChecked(GetIndex(), bulletButton->GetSelected()); - EndEditListItem(); - } - } - } - - DefaultTextListItemTemplate::DefaultTextListItemTemplate() - { - } - - DefaultTextListItemTemplate::~DefaultTextListItemTemplate() - { - } - -/*********************************************************************** -DefaultCheckTextListItemTemplate -***********************************************************************/ - - DefaultTextListItemTemplate::BulletStyle* DefaultCheckTextListItemTemplate::CreateBulletStyle() - { - if (auto textList = dynamic_cast(listControl)) - { - auto style = textList->GetTextListStyleProvider()->CreateCheckBulletStyle(); - if (style) return style; - } - return theme::GetCurrentTheme()->CreateCheckTextListItemStyle(); - } - -/*********************************************************************** -DefaultRadioTextListItemTemplate -***********************************************************************/ - - DefaultTextListItemTemplate::BulletStyle* DefaultRadioTextListItemTemplate::CreateBulletStyle() - { - if (auto textList = dynamic_cast(listControl)) - { - auto style = textList->GetTextListStyleProvider()->CreateRadioBulletStyle(); - if (style) return style; - } - return theme::GetCurrentTheme()->CreateRadioTextListItemStyle(); - } - -/*********************************************************************** -TextItem -***********************************************************************/ - - TextItem::TextItem() - :owner(0) - , checked(false) - { - } - - TextItem::TextItem(const WString& _text, bool _checked) - :owner(0) - , text(_text) - , checked(_checked) - { - } - - TextItem::~TextItem() - { - } - - bool TextItem::operator==(const TextItem& value)const - { - return text==value.text; - } - - bool TextItem::operator!=(const TextItem& value)const - { - return text!=value.text; - } - - const WString& TextItem::GetText() - { - return text; - } - - void TextItem::SetText(const WString& value) - { - if (text != value) - { - text = value; - if (owner) - { - vint index = owner->IndexOf(this); - owner->InvokeOnItemModified(index, 1, 1); - } - } - } - - bool TextItem::GetChecked() - { - return checked; - } - - void TextItem::SetChecked(bool value) - { - if (checked != value) - { - checked = value; - if (owner) - { - vint index = owner->IndexOf(this); - owner->InvokeOnItemModified(index, 1, 1); - - GuiItemEventArgs arguments; - arguments.itemIndex = index; - owner->listControl->ItemChecked.Execute(arguments); - } - } - } - -/*********************************************************************** -TextItemProvider -***********************************************************************/ - - void TextItemProvider::AfterInsert(vint item, const Ptr& value) - { - ListProvider>::AfterInsert(item, value); - value->owner = this; - } - - void TextItemProvider::BeforeRemove(vint item, const Ptr& value) - { - value->owner = 0; - ListProvider>::BeforeRemove(item, value); - } - - WString TextItemProvider::GetTextValue(vint itemIndex) - { - return Get(itemIndex)->GetText(); - } - - description::Value TextItemProvider::GetBindingValue(vint itemIndex) - { - return Value::From(Get(itemIndex)); - } - - bool TextItemProvider::GetChecked(vint itemIndex) - { - return Get(itemIndex)->GetChecked(); - } - - void TextItemProvider::SetChecked(vint itemIndex, bool value) - { - return Get(itemIndex)->SetChecked(value); - } - - TextItemProvider::TextItemProvider() - :listControl(0) - { - } - - TextItemProvider::~TextItemProvider() - { - } - - IDescriptable* TextItemProvider::RequestView(const WString& identifier) - { - if (identifier == ITextItemView::Identifier) - { - return (ITextItemView*)this; - } - else - { - return nullptr; - } - } - } - -/*********************************************************************** -GuiTextList -***********************************************************************/ - - void GuiVirtualTextList::OnStyleInstalled(vint itemIndex, ItemStyle* style) - { - GuiSelectableListControl::OnStyleInstalled(itemIndex, style); - if (auto textItemStyle = dynamic_cast(style)) - { - textItemStyle->SetTextColor(styleProvider->GetTextColor()); - if (auto textItemView = dynamic_cast(itemProvider->RequestView(list::ITextItemView::Identifier))) - { - textItemStyle->SetChecked(textItemView->GetChecked(itemIndex)); - } - } - } - - void GuiVirtualTextList::OnItemTemplateChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - view = TextListView::Unknown; - } - - GuiVirtualTextList::GuiVirtualTextList(IStyleProvider* _styleProvider, GuiListControl::IItemProvider* _itemProvider) - :GuiSelectableListControl(_styleProvider, _itemProvider) - { - ItemTemplateChanged.AttachMethod(this, &GuiVirtualTextList::OnItemTemplateChanged); - ItemChecked.SetAssociatedComposition(boundsComposition); - - styleProvider = dynamic_cast(styleController->GetStyleProvider()); - SetView(TextListView::Text); - } - - GuiVirtualTextList::~GuiVirtualTextList() - { - } - - GuiVirtualTextList::IStyleProvider* GuiVirtualTextList::GetTextListStyleProvider() - { - return styleProvider; - } - - TextListView GuiVirtualTextList::GetView() - { - return view; - } - - void GuiVirtualTextList::SetView(TextListView _view) - { - switch (_view) - { - case TextListView::Text: - SetStyleAndArranger( - [](const Value&) { return new list::DefaultTextListItemTemplate; }, - new list::FixedHeightItemArranger - ); - break; - case TextListView::Check: - SetStyleAndArranger( - [](const Value&) { return new list::DefaultCheckTextListItemTemplate; }, - new list::FixedHeightItemArranger - ); - break; - case TextListView::Radio: - SetStyleAndArranger( - [](const Value&) { return new list::DefaultRadioTextListItemTemplate; }, - new list::FixedHeightItemArranger - ); - break; - default:; - } - view = _view; - } - -/*********************************************************************** -GuiTextList -***********************************************************************/ - - GuiTextList::GuiTextList(IStyleProvider* _styleProvider) - :GuiVirtualTextList(_styleProvider, new list::TextItemProvider) - { - items=dynamic_cast(itemProvider.Obj()); - items->listControl=this; - } - - GuiTextList::~GuiTextList() - { - } - - list::TextItemProvider& GuiTextList::GetItems() - { - return *items; - } - - Ptr GuiTextList::GetSelectedItem() - { - vint index = GetSelectedItemIndex(); - if (index == -1) return 0; - return items->Get(index); - } - } - } -} - -/*********************************************************************** -CONTROLS\LISTCONTROLPACKAGE\GUITREEVIEWCONTROLS.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace controls - { - using namespace elements; - using namespace compositions; - using namespace reflection::description; - - namespace tree - { - const wchar_t* const INodeItemView::Identifier = L"vl::presentation::controls::tree::INodeItemView"; - -/*********************************************************************** -NodeItemProvider -***********************************************************************/ - - INodeProvider* NodeItemProvider::GetNodeByOffset(INodeProvider* provider, vint offset) - { - if(offset==0) return provider; - INodeProvider* result=0; - if(provider->GetExpanding() && offset>0) - { - offset-=1; - vint count=provider->GetChildCount(); - for(vint i=0;(!result && iGetChild(i); - vint visibleCount=child->CalculateTotalVisibleNodes(); - if(offsetGetExpanding()) - { - for(vint i=0;iGetChild(start+i); - offset+=child->CalculateTotalVisibleNodes(); - child->Release(); - } - } - offsetBeforeChildModifieds.Set(parentNode, offset); - } - - void NodeItemProvider::OnAfterItemModified(INodeProvider* parentNode, vint start, vint count, vint newCount) - { - vint offsetBeforeChildModified = 0; - { - vint index = offsetBeforeChildModifieds.Keys().IndexOf(parentNode); - if (index != -1) - { - offsetBeforeChildModified = offsetBeforeChildModifieds.Values().Get(index); - offsetBeforeChildModifieds.Remove(parentNode); - } - } - - vint base=CalculateNodeVisibilityIndexInternal(parentNode); - if(base!=-2 && parentNode->GetExpanding()) - { - vint offset=0; - vint firstChildStart=-1; - for(vint i=0;iGetChild(start+i); - if(i==0) - { - firstChildStart=CalculateNodeVisibilityIndexInternal(child); - } - offset+=child->CalculateTotalVisibleNodes(); - child->Release(); - } - - if(firstChildStart==-1) - { - vint childCount=parentNode->GetChildCount(); - if(childCount==0) - { - firstChildStart=base+1; - } - else if(startGetChild(start); - firstChildStart=CalculateNodeVisibilityIndexInternal(child); - child->Release(); - } - else - { - INodeProvider* child=parentNode->GetChild(start-1); - firstChildStart=CalculateNodeVisibilityIndexInternal(child); - firstChildStart+=child->CalculateTotalVisibleNodes(); - child->Release(); - } - } - InvokeOnItemModified(firstChildStart, offsetBeforeChildModified, offset); - } - } - - void NodeItemProvider::OnItemExpanded(INodeProvider* node) - { - vint base=CalculateNodeVisibilityIndexInternal(node); - if(base!=-2) - { - vint visibility=node->CalculateTotalVisibleNodes(); - InvokeOnItemModified(base+1, 0, visibility-1); - } - } - - void NodeItemProvider::OnItemCollapsed(INodeProvider* node) - { - vint base=CalculateNodeVisibilityIndexInternal(node); - if(base!=-2) - { - vint visibility=0; - vint count=node->GetChildCount(); - for(vint i=0;iGetChild(i); - visibility+=child->CalculateTotalVisibleNodes(); - child->Release(); - } - InvokeOnItemModified(base+1, visibility, 0); - } - } - - vint NodeItemProvider::CalculateNodeVisibilityIndexInternal(INodeProvider* node) - { - INodeProvider* parent=node->GetParent(); - if(parent==0) - { - return -1; - } - if(!parent->GetExpanding()) - { - return -2; - } - - vint index=CalculateNodeVisibilityIndexInternal(parent); - if(index==-2) - { - return -2; - } - - vint count=parent->GetChildCount(); - for(vint i=0;iGetChild(i); - bool findResult=child==node; - if(findResult) - { - index++; - } - else - { - index+=child->CalculateTotalVisibleNodes(); - } - child->Release(); - if(findResult) - { - return index; - } - } - return -1; - } - - vint NodeItemProvider::CalculateNodeVisibilityIndex(INodeProvider* node) - { - vint result=CalculateNodeVisibilityIndexInternal(node); - return result<0?-1:result; - } - - INodeProvider* NodeItemProvider::RequestNode(vint index) - { - if(root->CanGetNodeByVisibleIndex()) - { - return root->GetNodeByVisibleIndex(index+1); - } - else - { - return GetNodeByOffset(root->GetRootNode(), index+1); - } - } - - void NodeItemProvider::ReleaseNode(INodeProvider* node) - { - if(node) - { - node->Release(); - } - } - - NodeItemProvider::NodeItemProvider(Ptr _root) - :root(_root) - { - root->AttachCallback(this); - } - - NodeItemProvider::~NodeItemProvider() - { - root->DetachCallback(this); - } - - Ptr NodeItemProvider::GetRoot() - { - return root; - } - - vint NodeItemProvider::Count() - { - return root->GetRootNode()->CalculateTotalVisibleNodes()-1; - } - - WString NodeItemProvider::GetTextValue(vint itemIndex) - { - if (auto node = RequestNode(itemIndex)) - { - WString result = root->GetTextValue(node); - ReleaseNode(node); - return result; - } - return L""; - } - - description::Value NodeItemProvider::GetBindingValue(vint itemIndex) - { - if (auto node = RequestNode(itemIndex)) - { - Value result = root->GetBindingValue(node); - ReleaseNode(node); - return result; - } - return Value(); - } - - IDescriptable* NodeItemProvider::RequestView(const WString& identifier) - { - if(identifier==INodeItemView::Identifier) - { - return (INodeItemView*)this; - } - else - { - return root->RequestView(identifier); - } - } - -/*********************************************************************** -MemoryNodeProvider::NodeCollection -***********************************************************************/ - - void MemoryNodeProvider::NodeCollection::OnBeforeChildModified(vint start, vint count, vint newCount) - { - ownerProvider->offsetBeforeChildModified=0; - if(ownerProvider->expanding) - { - for(vint i=0;ioffsetBeforeChildModified+=items[start+i]->totalVisibleNodeCount; - } - } - INodeProviderCallback* proxy=ownerProvider->GetCallbackProxyInternal(); - if(proxy) - { - proxy->OnBeforeItemModified(ownerProvider, start, count, newCount); - } - } - - void MemoryNodeProvider::NodeCollection::OnAfterChildModified(vint start, vint count, vint newCount) - { - ownerProvider->childCount+=(newCount-count); - if(ownerProvider->expanding) - { - vint offset=0; - for(vint i=0;itotalVisibleNodeCount; - } - ownerProvider->OnChildTotalVisibleNodesChanged(offset-ownerProvider->offsetBeforeChildModified); - } - INodeProviderCallback* proxy=ownerProvider->GetCallbackProxyInternal(); - if(proxy) - { - proxy->OnAfterItemModified(ownerProvider, start, count, newCount); - } - } - - bool MemoryNodeProvider::NodeCollection::QueryInsert(vint index, Ptr const& child) - { - return child->parent == 0; - } - - bool MemoryNodeProvider::NodeCollection::QueryRemove(vint index, Ptr const& child) - { - return child->parent == ownerProvider; - } - - void MemoryNodeProvider::NodeCollection::BeforeInsert(vint index, Ptr const& child) - { - OnBeforeChildModified(index, 0, 1); - child->parent = ownerProvider; - } - - void MemoryNodeProvider::NodeCollection::BeforeRemove(vint index, Ptr const& child) - { - OnBeforeChildModified(index, 1, 0); - child->parent = 0; - } - - void MemoryNodeProvider::NodeCollection::AfterInsert(vint index, Ptr const& child) - { - OnAfterChildModified(index, 0, 1); - } - - void MemoryNodeProvider::NodeCollection::AfterRemove(vint index, vint count) - { - OnAfterChildModified(index, count, 0); - } - - MemoryNodeProvider::NodeCollection::NodeCollection() - :ownerProvider(0) - { - } - -/*********************************************************************** -MemoryNodeProvider -***********************************************************************/ - - INodeProviderCallback* MemoryNodeProvider::GetCallbackProxyInternal() - { - if(parent) - { - return parent->GetCallbackProxyInternal(); - } - else - { - return 0; - } - } - - void MemoryNodeProvider::OnChildTotalVisibleNodesChanged(vint offset) - { - totalVisibleNodeCount+=offset; - if(parent) - { - parent->OnChildTotalVisibleNodesChanged(offset); - } - } - - MemoryNodeProvider::MemoryNodeProvider(Ptr _data) - :data(_data) - { - children.ownerProvider=this; - } - - MemoryNodeProvider::~MemoryNodeProvider() - { - } - - Ptr MemoryNodeProvider::GetData() - { - return data; - } - - void MemoryNodeProvider::SetData(const Ptr& value) - { - data=value; - NotifyDataModified(); - } - - void MemoryNodeProvider::NotifyDataModified() - { - if(parent) - { - vint index=parent->children.IndexOf(this); - INodeProviderCallback* proxy=GetCallbackProxyInternal(); - if(proxy) - { - proxy->OnBeforeItemModified(parent, index, 1, 1); - proxy->OnAfterItemModified(parent, index, 1, 1); - } - } - } - - MemoryNodeProvider::NodeCollection& MemoryNodeProvider::Children() - { - return children; - } - - bool MemoryNodeProvider::GetExpanding() - { - return expanding; - } - - void MemoryNodeProvider::SetExpanding(bool value) - { - if(expanding!=value) - { - expanding=value; - vint offset=0; - for(vint i=0;itotalVisibleNodeCount; - } - - OnChildTotalVisibleNodesChanged(expanding?offset:-offset); - INodeProviderCallback* proxy=GetCallbackProxyInternal(); - if(proxy) - { - if(expanding) - { - proxy->OnItemExpanded(this); - } - else - { - proxy->OnItemCollapsed(this); - } - } - } - } - - vint MemoryNodeProvider::CalculateTotalVisibleNodes() - { - return totalVisibleNodeCount; - } - - vint MemoryNodeProvider::GetChildCount() - { - return childCount; - } - - INodeProvider* MemoryNodeProvider::GetParent() - { - return parent; - } - - INodeProvider* MemoryNodeProvider::GetChild(vint index) - { - if(0<=index && indexOnBeforeItemModified(parentNode, start, count, newCount); - } - } - - void NodeRootProviderBase::OnAfterItemModified(INodeProvider* parentNode, vint start, vint count, vint newCount) - { - for(vint i=0;iOnAfterItemModified(parentNode, start, count, newCount); - } - } - - void NodeRootProviderBase::OnItemExpanded(INodeProvider* node) - { - for(vint i=0;iOnItemExpanded(node); - } - } - - void NodeRootProviderBase::OnItemCollapsed(INodeProvider* node) - { - for(vint i=0;iOnItemCollapsed(node); - } - } - - NodeRootProviderBase::NodeRootProviderBase() - { - } - - NodeRootProviderBase::~NodeRootProviderBase() - { - } - - bool NodeRootProviderBase::CanGetNodeByVisibleIndex() - { - return false; - } - - INodeProvider* NodeRootProviderBase::GetNodeByVisibleIndex(vint index) - { - return 0; - } - - bool NodeRootProviderBase::AttachCallback(INodeProviderCallback* value) - { - if(callbacks.Contains(value)) - { - return false; - } - else - { - callbacks.Add(value); - value->OnAttached(this); - return true; - } - } - - bool NodeRootProviderBase::DetachCallback(INodeProviderCallback* value) - { - vint index=callbacks.IndexOf(value); - if(index==-1) - { - return false; - } - else - { - value->OnAttached(0); - callbacks.Remove(value); - return true; - } - } - - IDescriptable* NodeRootProviderBase::RequestView(const WString& identifier) - { - return 0; - } - -/*********************************************************************** -MemoryNodeRootProvider -***********************************************************************/ - - INodeProviderCallback* MemoryNodeRootProvider::GetCallbackProxyInternal() - { - return this; - } - - MemoryNodeRootProvider::MemoryNodeRootProvider() - { - SetExpanding(true); - } - - MemoryNodeRootProvider::~MemoryNodeRootProvider() - { - } - - INodeProvider* MemoryNodeRootProvider::GetRootNode() - { - return this; - } - - MemoryNodeProvider* MemoryNodeRootProvider::GetMemoryNode(INodeProvider* node) - { - return dynamic_cast(node); - } - } - -/*********************************************************************** -GuiVirtualTreeListControl -***********************************************************************/ - - void GuiVirtualTreeListControl::OnAttached(tree::INodeRootProvider* provider) - { - } - - void GuiVirtualTreeListControl::OnBeforeItemModified(tree::INodeProvider* parentNode, vint start, vint count, vint newCount) - { - } - - void GuiVirtualTreeListControl::OnAfterItemModified(tree::INodeProvider* parentNode, vint start, vint count, vint newCount) - { - } - - void GuiVirtualTreeListControl::OnItemExpanded(tree::INodeProvider* node) - { - GuiNodeEventArgs arguments; - (GuiEventArgs&)arguments=GetNotifyEventArguments(); - arguments.node=node; - NodeExpanded.Execute(arguments); - } - - void GuiVirtualTreeListControl::OnItemCollapsed(tree::INodeProvider* node) - { - GuiNodeEventArgs arguments; - (GuiEventArgs&)arguments=GetNotifyEventArguments(); - arguments.node=node; - NodeCollapsed.Execute(arguments); - } - - void GuiVirtualTreeListControl::OnItemMouseEvent(compositions::GuiNodeMouseEvent& nodeEvent, compositions::GuiGraphicsComposition* sender, compositions::GuiItemMouseEventArgs& arguments) - { - tree::INodeProvider* node=GetNodeItemView()->RequestNode(arguments.itemIndex); - if(node) - { - GuiNodeMouseEventArgs redirectArguments; - (GuiMouseEventArgs&)redirectArguments=arguments; - redirectArguments.node=node; - nodeEvent.Execute(redirectArguments); - (GuiMouseEventArgs&)arguments=redirectArguments; - GetNodeItemView()->ReleaseNode(node); - } - } - - void GuiVirtualTreeListControl::OnItemNotifyEvent(compositions::GuiNodeNotifyEvent& nodeEvent, compositions::GuiGraphicsComposition* sender, compositions::GuiItemEventArgs& arguments) - { - if(auto node = GetNodeItemView()->RequestNode(arguments.itemIndex)) - { - GuiNodeEventArgs redirectArguments; - (GuiEventArgs&)redirectArguments=arguments; - redirectArguments.node=node; - nodeEvent.Execute(redirectArguments); - (GuiEventArgs&)arguments=redirectArguments; - GetNodeItemView()->ReleaseNode(node); - } - } - -#define ATTACH_ITEM_MOUSE_EVENT(NODEEVENTNAME, ITEMEVENTNAME)\ - {\ - Func func(this, &GuiVirtualTreeListControl::OnItemMouseEvent);\ - ITEMEVENTNAME.AttachFunction(Curry(func)(NODEEVENTNAME));\ - }\ - -#define ATTACH_ITEM_NOTIFY_EVENT(NODEEVENTNAME, ITEMEVENTNAME)\ - {\ - Func func(this, &GuiVirtualTreeListControl::OnItemNotifyEvent);\ - ITEMEVENTNAME.AttachFunction(Curry(func)(NODEEVENTNAME));\ - }\ - - void GuiVirtualTreeListControl::OnNodeLeftButtonDoubleClick(compositions::GuiGraphicsComposition* sender, compositions::GuiNodeMouseEventArgs& arguments) - { - if (arguments.node->GetChildCount() > 0) - { - arguments.node->SetExpanding(!arguments.node->GetExpanding()); - } - } - - GuiVirtualTreeListControl::GuiVirtualTreeListControl(IStyleProvider* _styleProvider, Ptr _nodeRootProvider) - :GuiSelectableListControl(_styleProvider, new tree::NodeItemProvider(_nodeRootProvider)) - { - nodeItemProvider = dynamic_cast(GetItemProvider()); - nodeItemView = dynamic_cast(GetItemProvider()->RequestView(tree::INodeItemView::Identifier)); - - NodeLeftButtonDown.SetAssociatedComposition(boundsComposition); - NodeLeftButtonUp.SetAssociatedComposition(boundsComposition); - NodeLeftButtonDoubleClick.SetAssociatedComposition(boundsComposition); - NodeMiddleButtonDown.SetAssociatedComposition(boundsComposition); - NodeMiddleButtonUp.SetAssociatedComposition(boundsComposition); - NodeMiddleButtonDoubleClick.SetAssociatedComposition(boundsComposition); - NodeRightButtonDown.SetAssociatedComposition(boundsComposition); - NodeRightButtonUp.SetAssociatedComposition(boundsComposition); - NodeRightButtonDoubleClick.SetAssociatedComposition(boundsComposition); - NodeMouseMove.SetAssociatedComposition(boundsComposition); - NodeMouseEnter.SetAssociatedComposition(boundsComposition); - NodeMouseLeave.SetAssociatedComposition(boundsComposition); - NodeExpanded.SetAssociatedComposition(boundsComposition); - NodeCollapsed.SetAssociatedComposition(boundsComposition); - - ATTACH_ITEM_MOUSE_EVENT(NodeLeftButtonDown, ItemLeftButtonDown); - ATTACH_ITEM_MOUSE_EVENT(NodeLeftButtonUp, ItemLeftButtonUp); - ATTACH_ITEM_MOUSE_EVENT(NodeLeftButtonDoubleClick, ItemLeftButtonDoubleClick); - ATTACH_ITEM_MOUSE_EVENT(NodeMiddleButtonDown, ItemMiddleButtonDown); - ATTACH_ITEM_MOUSE_EVENT(NodeMiddleButtonUp, ItemMiddleButtonUp); - ATTACH_ITEM_MOUSE_EVENT(NodeMiddleButtonDoubleClick, ItemMiddleButtonDoubleClick); - ATTACH_ITEM_MOUSE_EVENT(NodeRightButtonDown, ItemRightButtonDown); - ATTACH_ITEM_MOUSE_EVENT(NodeRightButtonUp, ItemRightButtonUp); - ATTACH_ITEM_MOUSE_EVENT(NodeRightButtonDoubleClick, ItemRightButtonDoubleClick); - ATTACH_ITEM_MOUSE_EVENT(NodeMouseMove, ItemMouseMove); - ATTACH_ITEM_NOTIFY_EVENT(NodeMouseEnter, ItemMouseEnter); - ATTACH_ITEM_NOTIFY_EVENT(NodeMouseLeave, ItemMouseLeave); - - nodeItemProvider->GetRoot()->AttachCallback(this); - NodeLeftButtonDoubleClick.AttachMethod(this, &GuiVirtualTreeListControl::OnNodeLeftButtonDoubleClick); - } - -#undef ATTACH_ITEM_MOUSE_EVENT -#undef ATTACH_ITEM_NOTIFY_EVENT - - GuiVirtualTreeListControl::~GuiVirtualTreeListControl() - { - } - - tree::INodeItemView* GuiVirtualTreeListControl::GetNodeItemView() - { - return nodeItemView; - } - - tree::INodeRootProvider* GuiVirtualTreeListControl::GetNodeRootProvider() - { - return nodeItemProvider->GetRoot().Obj(); - } - - namespace tree - { - -/*********************************************************************** -TreeViewItem -***********************************************************************/ - - const wchar_t* const ITreeViewItemView::Identifier = L"vl::presentation::controls::tree::ITreeViewItemView"; - - TreeViewItem::TreeViewItem() - { - } - - TreeViewItem::TreeViewItem(const Ptr& _image, const WString& _text) - :image(_image) - ,text(_text) - { - } - -/*********************************************************************** -TreeViewItemRootProvider -***********************************************************************/ - - Ptr TreeViewItemRootProvider::GetNodeImage(INodeProvider* node) - { - MemoryNodeProvider* memoryNode=dynamic_cast(node); - if(memoryNode) - { - Ptr data=memoryNode->GetData().Cast(); - if(data) - { - return data->image; - } - } - return 0; - } - - WString TreeViewItemRootProvider::GetTextValue(INodeProvider* node) - { - MemoryNodeProvider* memoryNode = dynamic_cast(node); - if (memoryNode) - { - Ptr data = memoryNode->GetData().Cast(); - if (data) - { - return data->text; - } - } - return L""; - } - - description::Value TreeViewItemRootProvider::GetBindingValue(INodeProvider* node) - { - return Value::From(GetTreeViewData(node)); - } - - TreeViewItemRootProvider::TreeViewItemRootProvider() - { - } - - TreeViewItemRootProvider::~TreeViewItemRootProvider() - { - } - - IDescriptable* TreeViewItemRootProvider::RequestView(const WString& identifier) - { - if(identifier==ITreeViewItemView::Identifier) - { - return (ITreeViewItemView*)this; - } - else - { - return MemoryNodeRootProvider::RequestView(identifier); - } - } - - Ptr TreeViewItemRootProvider::GetTreeViewData(INodeProvider* node) - { - MemoryNodeProvider* memoryNode=GetMemoryNode(node); - if(memoryNode) - { - return memoryNode->GetData().Cast(); - } - else - { - return 0; - } - } - - void TreeViewItemRootProvider::SetTreeViewData(INodeProvider* node, Ptr value) - { - MemoryNodeProvider* memoryNode=GetMemoryNode(node); - if(memoryNode) - { - memoryNode->SetData(value); - } - } - - void TreeViewItemRootProvider::UpdateTreeViewData(INodeProvider* node) - { - MemoryNodeProvider* memoryNode=GetMemoryNode(node); - if(memoryNode) - { - memoryNode->NotifyDataModified(); - } - } - } - -/*********************************************************************** -GuiVirtualTreeView -***********************************************************************/ - - templates::GuiTreeItemTemplate* GuiVirtualTreeView::GetStyleFromNode(tree::INodeProvider* node) - { - if (itemArranger) - { - vint index = nodeItemView->CalculateNodeVisibilityIndex(node); - if (index != -1) - { - auto style = itemArranger->GetVisibleStyle(index); - return dynamic_cast(style); - } - } - return nullptr; - } - - void GuiVirtualTreeView::SetStyleExpanding(tree::INodeProvider* node, bool expanding) - { - if (auto treeItemStyle = GetStyleFromNode(node)) - { - treeItemStyle->SetExpanding(expanding); - } - } - - void GuiVirtualTreeView::SetStyleExpandable(tree::INodeProvider* node, bool expandable) - { - if (auto treeItemStyle = GetStyleFromNode(node)) - { - treeItemStyle->SetExpandable(expandable); - } - } - - void GuiVirtualTreeView::OnAfterItemModified(tree::INodeProvider* parentNode, vint start, vint count, vint newCount) - { - GuiVirtualTreeListControl::OnAfterItemModified(parentNode, start, count, newCount); - SetStyleExpandable(parentNode, parentNode->GetChildCount() > 0); - } - - void GuiVirtualTreeView::OnItemExpanded(tree::INodeProvider* node) - { - GuiVirtualTreeListControl::OnItemExpanded(node); - SetStyleExpanding(node, true); - } - - void GuiVirtualTreeView::OnItemCollapsed(tree::INodeProvider* node) - { - GuiVirtualTreeListControl::OnItemCollapsed(node); - SetStyleExpanding(node, false); - } - - void GuiVirtualTreeView::OnStyleInstalled(vint itemIndex, ItemStyle* style) - { - GuiVirtualTreeListControl::OnStyleInstalled(itemIndex, style); - if (auto treeItemStyle = dynamic_cast(style)) - { - treeItemStyle->SetTextColor(styleProvider->GetTextColor()); - - if (treeViewItemView) - { - if (auto node = nodeItemView->RequestNode(itemIndex)) - { - treeItemStyle->SetImage(treeViewItemView->GetNodeImage(node)); - treeItemStyle->SetExpanding(node->GetExpanding()); - treeItemStyle->SetExpandable(node->GetChildCount() > 0); - { - vint level = -1; - auto current = node; - while (current->GetParent()) - { - level++; - current = current->GetParent(); - } - treeItemStyle->SetLevel(level); - } - nodeItemView->ReleaseNode(node); - } - } - } - } - - GuiVirtualTreeView::GuiVirtualTreeView(IStyleProvider* _styleProvider, Ptr _nodeRootProvider) - :GuiVirtualTreeListControl(_styleProvider, _nodeRootProvider) - { - styleProvider = dynamic_cast(styleController->GetStyleProvider()); - treeViewItemView = dynamic_cast(GetNodeRootProvider()->RequestView(tree::ITreeViewItemView::Identifier)); - SetStyleAndArranger( - [](const Value&) { return new tree::DefaultTreeItemTemplate; }, - new list::FixedHeightItemArranger - ); - } - - GuiVirtualTreeView::~GuiVirtualTreeView() - { - } - - GuiVirtualTreeView::IStyleProvider* GuiVirtualTreeView::GetTreeViewStyleProvider() - { - return styleProvider; - } - -/*********************************************************************** -GuiTreeView -***********************************************************************/ - - GuiTreeView::GuiTreeView(IStyleProvider* _styleProvider) - :GuiVirtualTreeView(_styleProvider, new tree::TreeViewItemRootProvider) - { - nodes = nodeItemProvider->GetRoot().Cast(); - } - - GuiTreeView::~GuiTreeView() - { - } - - Ptr GuiTreeView::Nodes() - { - return nodes; - } - - Ptr GuiTreeView::GetSelectedItem() - { - Ptr result; - vint index = GetSelectedItemIndex(); - if (index != -1) - { - if (auto node = nodeItemView->RequestNode(index)) - { - if (auto memoryNode = dynamic_cast(node)) - { - result = memoryNode->GetData().Cast(); - } - nodeItemView->ReleaseNode(node); - } - } - return result; - } - - namespace tree - { - -/*********************************************************************** -DefaultTreeItemTemplate -***********************************************************************/ - - void DefaultTreeItemTemplate::OnInitialize() - { - templates::GuiTreeItemTemplate::OnInitialize(); - SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - - table = new GuiTableComposition; - AddChild(table); - table->SetRowsAndColumns(3, 4); - table->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); - table->SetRowOption(1, GuiCellOption::MinSizeOption()); - table->SetRowOption(2, GuiCellOption::PercentageOption(0.5)); - table->SetColumnOption(0, GuiCellOption::AbsoluteOption(0)); - table->SetColumnOption(1, GuiCellOption::MinSizeOption()); - table->SetColumnOption(2, GuiCellOption::MinSizeOption()); - table->SetColumnOption(3, GuiCellOption::MinSizeOption()); - table->SetAlignmentToParent(Margin(0, 0, 0, 0)); - table->SetCellPadding(2); - { - GuiCellComposition* cell = new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 1, 3, 1); - cell->SetPreferredMinSize(Size(16, 16)); - - GuiSelectableButton::IStyleController* expandingStyle = nullptr; - if (auto treeView = dynamic_cast(listControl)) - { - expandingStyle = treeView->GetTreeViewStyleProvider()->CreateItemExpandingDecorator(); - if (!expandingStyle) - { - expandingStyle = theme::GetCurrentTheme()->CreateTreeItemExpanderStyle(); - } - } - expandingButton = new GuiSelectableButton(expandingStyle); - expandingButton->SetAutoSelection(false); - expandingButton->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); - expandingButton->GetEventReceiver()->leftButtonDoubleClick.AttachMethod(this, &DefaultTreeItemTemplate::OnExpandingButtonDoubleClick); - expandingButton->Clicked.AttachMethod(this, &DefaultTreeItemTemplate::OnExpandingButtonClicked); - cell->AddChild(expandingButton->GetBoundsComposition()); - } - { - GuiCellComposition* cell = new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(1, 2, 1, 1); - cell->SetPreferredMinSize(Size(16, 16)); - - imageElement = GuiImageFrameElement::Create(); - imageElement->SetStretch(true); - cell->SetOwnedElement(imageElement); - } - { - GuiCellComposition* cell = new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 3, 3, 1); - cell->SetPreferredMinSize(Size(192, 0)); - - textElement = GuiSolidLabelElement::Create(); - textElement->SetAlignments(Alignment::Left, Alignment::Center); - textElement->SetEllipse(true); - cell->SetOwnedElement(textElement); - } - - FontChanged.AttachMethod(this, &DefaultTreeItemTemplate::OnFontChanged); - TextChanged.AttachMethod(this, &DefaultTreeItemTemplate::OnTextChanged); - TextColorChanged.AttachMethod(this, &DefaultTreeItemTemplate::OnTextColorChanged); - ExpandingChanged.AttachMethod(this, &DefaultTreeItemTemplate::OnExpandingChanged); - ExpandableChanged.AttachMethod(this, &DefaultTreeItemTemplate::OnExpandableChanged); - LevelChanged.AttachMethod(this, &DefaultTreeItemTemplate::OnLevelChanged); - ImageChanged.AttachMethod(this, &DefaultTreeItemTemplate::OnImageChanged); - - FontChanged.Execute(compositions::GuiEventArgs(this)); - TextChanged.Execute(compositions::GuiEventArgs(this)); - TextColorChanged.Execute(compositions::GuiEventArgs(this)); - ExpandingChanged.Execute(compositions::GuiEventArgs(this)); - ExpandableChanged.Execute(compositions::GuiEventArgs(this)); - LevelChanged.Execute(compositions::GuiEventArgs(this)); - ImageChanged.Execute(compositions::GuiEventArgs(this)); - } - - void DefaultTreeItemTemplate::OnFontChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - textElement->SetFont(GetFont()); - } - - void DefaultTreeItemTemplate::OnTextChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - textElement->SetText(GetText()); - } - - void DefaultTreeItemTemplate::OnTextColorChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - textElement->SetColor(GetTextColor()); - } - - void DefaultTreeItemTemplate::OnExpandingChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - expandingButton->SetSelected(GetExpanding()); - } - - void DefaultTreeItemTemplate::OnExpandableChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - expandingButton->SetVisible(GetExpandable()); - } - - void DefaultTreeItemTemplate::OnLevelChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - table->SetColumnOption(0, GuiCellOption::AbsoluteOption(GetLevel() * 12)); - } - - void DefaultTreeItemTemplate::OnImageChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if (auto imageData = GetImage()) - { - imageElement->SetImage(imageData->GetImage(), imageData->GetFrameIndex()); - } - else - { - imageElement->SetImage(nullptr); - } - } - - void DefaultTreeItemTemplate::OnExpandingButtonDoubleClick(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) - { - arguments.handled = true; - } - - void DefaultTreeItemTemplate::OnExpandingButtonClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if (expandingButton->GetVisuallyEnabled()) - { - if (auto treeControl = dynamic_cast(listControl)) - { - if (auto view = treeControl->GetNodeItemView()) - { - vint index = treeControl->GetArranger()->GetVisibleIndex(this); - if (index != -1) - { - if (auto node = view->RequestNode(index)) - { - bool expanding = node->GetExpanding(); - node->SetExpanding(!expanding); - view->ReleaseNode(node); - } - } - } - } - } - } - - DefaultTreeItemTemplate::DefaultTreeItemTemplate() - { - } - - DefaultTreeItemTemplate::~DefaultTreeItemTemplate() - { - } - } - } - } -} - -/*********************************************************************** -CONTROLS\STYLES\GUICOMMONSTYLES.CPP -***********************************************************************/ -#include - -namespace vl -{ - namespace presentation - { - namespace common_styles - { - using namespace elements; - using namespace compositions; - using namespace controls; - -/*********************************************************************** -CommonScrollStyle -***********************************************************************/ - - void CommonScrollStyle::UpdateHandle() - { - double handlePageSize=(double)pageSize/totalSize; - double handleRatio=(double)position/totalSize; - switch(direction) - { - case Horizontal: - handleComposition->SetWidthRatio(handleRatio); - handleComposition->SetWidthPageSize(handlePageSize); - break; - case Vertical: - handleComposition->SetHeightRatio(handleRatio); - handleComposition->SetHeightPageSize(handlePageSize); - break; - } - } - - void CommonScrollStyle::OnDecreaseButtonClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if(commandExecutor) - { - commandExecutor->SmallDecrease(); - } - } - - void CommonScrollStyle::OnIncreaseButtonClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if(commandExecutor) - { - commandExecutor->SmallIncrease(); - } - } - - void CommonScrollStyle::OnHandleMouseDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) - { - if(commandExecutor && handleButton->GetVisuallyEnabled()) - { - draggingHandle=true; - draggingStartLocation=Point(arguments.x, arguments.y); - } - } - - void CommonScrollStyle::OnHandleMouseMove(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) - { - if(draggingHandle) - { - vint totalPixels=0; - vint currentOffset=0; - vint newOffset=0; - switch(direction) - { - case Horizontal: - totalPixels=handleComposition->GetParent()->GetBounds().Width(); - currentOffset=handleComposition->GetBounds().Left(); - newOffset=currentOffset+(arguments.x-draggingStartLocation.x); - break; - case Vertical: - totalPixels=handleComposition->GetParent()->GetBounds().Height(); - currentOffset=handleComposition->GetBounds().Top(); - newOffset=currentOffset+(arguments.y-draggingStartLocation.y); - break; - } - - double ratio=(double)newOffset/totalPixels; - vint newPosition=(vint)(ratio*totalSize); - - vint offset1=(vint)(((double)newPosition/totalSize)*totalPixels); - vint offset2=vint(((double)(newPosition+1)/totalSize)*totalPixels); - vint delta1=abs((int)(offset1-newOffset)); - vint delta2=abs((int)(offset2-newOffset)); - if(delta1SetPosition(newPosition); - } - else - { - commandExecutor->SetPosition(newPosition+1); - } - } - } - - void CommonScrollStyle::OnHandleMouseUp(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) - { - draggingHandle=false; - } - - void CommonScrollStyle::OnBigMoveMouseDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) - { - if(commandExecutor && handleButton->GetVisuallyEnabled()) - { - if(arguments.eventSource==arguments.compositionSource) - { - Rect handleBounds=handleComposition->GetBounds(); - switch(direction) - { - case Horizontal: - if(arguments.xBigDecrease(); - } - else if(arguments.x>=handleBounds.x2) - { - commandExecutor->BigIncrease(); - } - break; - case Vertical: - if(arguments.yBigDecrease(); - } - else if(arguments.y>=handleBounds.y2) - { - commandExecutor->BigIncrease(); - } - break; - } - } - } - } - - void CommonScrollStyle::BuildStyle(vint defaultSize, vint arrowSize) - { - boundsComposition=new GuiBoundsComposition; - containerComposition=InstallBackground(boundsComposition, direction); - { - GuiBoundsComposition* handleBoundsComposition=new GuiBoundsComposition; - containerComposition->AddChild(handleBoundsComposition); - - handleComposition=new GuiPartialViewComposition; - handleBoundsComposition->AddChild(handleComposition); - handleBoundsComposition->GetEventReceiver()->leftButtonDown.AttachMethod(this, &CommonScrollStyle::OnBigMoveMouseDown); - - switch(direction) - { - case Horizontal: - handleBoundsComposition->SetAlignmentToParent(Margin(defaultSize, 0, defaultSize, 0)); - handleComposition->SetPreferredMinSize(Size(defaultSize, 0)); - boundsComposition->SetPreferredMinSize(Size(0, defaultSize)); - break; - case Vertical: - handleBoundsComposition->SetAlignmentToParent(Margin(0, defaultSize, 0, defaultSize)); - handleComposition->SetPreferredMinSize(Size(0, defaultSize)); - boundsComposition->SetPreferredMinSize(Size(defaultSize, 0)); - break; - } - - handleButton=new GuiButton(CreateHandleButtonStyle(direction)); - handleButton->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); - handleComposition->AddChild(handleButton->GetBoundsComposition()); - - handleButton->GetBoundsComposition()->GetEventReceiver()->leftButtonDown.AttachMethod(this, &CommonScrollStyle::OnHandleMouseDown); - handleButton->GetBoundsComposition()->GetEventReceiver()->mouseMove.AttachMethod(this, &CommonScrollStyle::OnHandleMouseMove); - handleButton->GetBoundsComposition()->GetEventReceiver()->leftButtonUp.AttachMethod(this, &CommonScrollStyle::OnHandleMouseUp); - } - { - decreaseButton=new GuiButton(CreateDecreaseButtonStyle(direction)); - decreaseButton->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); - decreaseButton->Clicked.AttachMethod(this, &CommonScrollStyle::OnDecreaseButtonClicked); - - increaseButton=new GuiButton(CreateIncreaseButtonStyle(direction)); - increaseButton->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); - increaseButton->Clicked.AttachMethod(this, &CommonScrollStyle::OnIncreaseButtonClicked); - } - { - GuiSideAlignedComposition* decreaseComposition=new GuiSideAlignedComposition; - decreaseComposition->SetMaxLength(defaultSize); - decreaseComposition->SetMaxRatio(0.5); - decreaseComposition->AddChild(decreaseButton->GetBoundsComposition()); - containerComposition->AddChild(decreaseComposition); - - GuiSideAlignedComposition* increaseComposition=new GuiSideAlignedComposition; - increaseComposition->SetMaxLength(defaultSize); - increaseComposition->SetMaxRatio(0.5); - increaseComposition->AddChild(increaseButton->GetBoundsComposition()); - containerComposition->AddChild(increaseComposition); - - switch(direction) - { - case Horizontal: - { - decreaseComposition->SetDirection(GuiSideAlignedComposition::Left); - increaseComposition->SetDirection(GuiSideAlignedComposition::Right); - } - break; - case Vertical: - { - decreaseComposition->SetDirection(GuiSideAlignedComposition::Top); - increaseComposition->SetDirection(GuiSideAlignedComposition::Bottom); - } - break; - } - } - } - - CommonScrollStyle::CommonScrollStyle(Direction _direction) - :direction(_direction) - ,commandExecutor(0) - ,decreaseButton(0) - ,increaseButton(0) - ,boundsComposition(0) - ,containerComposition(0) - ,totalSize(1) - ,pageSize(1) - ,position(0) - ,draggingHandle(false) - { - } - - CommonScrollStyle::~CommonScrollStyle() - { - } - - compositions::GuiBoundsComposition* CommonScrollStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* CommonScrollStyle::GetContainerComposition() - { - return containerComposition; - } - - void CommonScrollStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void CommonScrollStyle::SetText(const WString& value) - { - } - - void CommonScrollStyle::SetFont(const FontProperties& value) - { - } - - void CommonScrollStyle::SetVisuallyEnabled(bool value) - { - } - - void CommonScrollStyle::SetCommandExecutor(controls::IScrollCommandExecutor* value) - { - commandExecutor=value; - } - - void CommonScrollStyle::SetTotalSize(vint value) - { - if(totalSize!=value) - { - totalSize=value; - UpdateHandle(); - } - } - - void CommonScrollStyle::SetPageSize(vint value) - { - if(pageSize!=value) - { - pageSize=value; - UpdateHandle(); - } - } - - void CommonScrollStyle::SetPosition(vint value) - { - if(position!=value) - { - position=value; - UpdateHandle(); - } - } - -/*********************************************************************** -CommonTrackStyle -***********************************************************************/ - - void CommonTrackStyle::UpdateHandle() - { - vint maxSize=totalSize-pageSize; - if(maxSize<1) maxSize=1; - double ratio=(double)position/maxSize; - switch(direction) - { - case Horizontal: - handleComposition->SetColumnOption(0, GuiCellOption::PercentageOption(ratio)); - handleComposition->SetColumnOption(2, GuiCellOption::PercentageOption(1-ratio)); - break; - case Vertical: - handleComposition->SetRowOption(0, GuiCellOption::PercentageOption(1-ratio)); - handleComposition->SetRowOption(2, GuiCellOption::PercentageOption(ratio)); - break; - } - handleComposition->UpdateCellBounds(); - } - - void CommonTrackStyle::OnHandleMouseDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) - { - if(commandExecutor && handleButton->GetVisuallyEnabled()) - { - draggingHandle=true; - draggingStartLocation=Point(arguments.x, arguments.y); - } - } - - void CommonTrackStyle::OnHandleMouseMove(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) - { - if(draggingHandle) - { - vint totalPixels=0; - vint currentOffset=0; - vint newOffset=0; - - Rect handleArea=handleComposition->GetBounds(); - Rect handleBounds=handleButton->GetBoundsComposition()->GetParent()->GetBounds(); - switch(direction) - { - case Horizontal: - totalPixels=handleArea.Width()-handleBounds.Width(); - currentOffset=handleBounds.Left(); - newOffset=currentOffset+(arguments.x-draggingStartLocation.x); - break; - case Vertical: - totalPixels=handleArea.Height()-handleBounds.Height(); - currentOffset=handleArea.Height()-handleBounds.Bottom(); - newOffset=currentOffset-(arguments.y-draggingStartLocation.y); - break; - } - - double ratio=(double)newOffset/totalPixels; - vint maxSize=totalSize-pageSize; - if(maxSize<1) maxSize=1; - vint newPosition=(vint)(ratio*maxSize); - - vint offset1=(vint)(((double)newPosition/maxSize)*totalPixels); - vint offset2=vint(((double)(newPosition+1)/maxSize)*totalPixels); - vint delta1=abs((int)(offset1-newOffset)); - vint delta2=abs((int)(offset2-newOffset)); - if(delta1SetPosition(newPosition); - } - else - { - commandExecutor->SetPosition(newPosition+1); - } - } - } - - void CommonTrackStyle::OnHandleMouseUp(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) - { - draggingHandle=false; - } - - void CommonTrackStyle::BuildStyle(vint trackThickness, vint trackPadding, vint handleLong, vint handleShort) - { - boundsComposition=new GuiBoundsComposition; - InstallBackground(boundsComposition, direction); - { - GuiTableComposition* table=new GuiTableComposition; - boundsComposition->AddChild(table); - boundsComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - table->SetAlignmentToParent(Margin(0, 0, 0, 0)); - table->SetRowsAndColumns(3, 3); - table->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - switch(direction) - { - case Horizontal: - table->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); - table->SetRowOption(1, GuiCellOption::AbsoluteOption(handleLong)); - table->SetRowOption(2, GuiCellOption::PercentageOption(0.5)); - table->SetColumnOption(0, GuiCellOption::AbsoluteOption(trackPadding)); - table->SetColumnOption(1, GuiCellOption::PercentageOption(1.0)); - table->SetColumnOption(2, GuiCellOption::AbsoluteOption(trackPadding)); - break; - case Vertical: - table->SetRowOption(0, GuiCellOption::AbsoluteOption(trackPadding)); - table->SetRowOption(1, GuiCellOption::PercentageOption(1.0)); - table->SetRowOption(2, GuiCellOption::AbsoluteOption(trackPadding)); - table->SetColumnOption(0, GuiCellOption::PercentageOption(0.5)); - table->SetColumnOption(1, GuiCellOption::AbsoluteOption(handleLong)); - table->SetColumnOption(2, GuiCellOption::PercentageOption(0.5)); - break; - } - { - GuiCellComposition* contentCell=new GuiCellComposition; - table->AddChild(contentCell); - contentCell->SetSite(1, 1, 1, 1); - { - GuiTableComposition* trackTable=new GuiTableComposition; - trackTable->SetAlignmentToParent(Margin(0, 0, 0, 0)); - contentCell->AddChild(trackTable); - GuiCellComposition* trackCell=new GuiCellComposition; - trackTable->AddChild(trackCell); - - switch(direction) - { - case Horizontal: - trackTable->SetRowsAndColumns(3, 1); - trackTable->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); - trackTable->SetRowOption(1, GuiCellOption::AbsoluteOption(trackThickness)); - trackTable->SetRowOption(2, GuiCellOption::PercentageOption(0.5)); - trackCell->SetSite(1, 0, 1, 1); - break; - case Vertical: - trackTable->SetRowsAndColumns(1, 3); - trackTable->SetColumnOption(0, GuiCellOption::PercentageOption(0.5)); - trackTable->SetColumnOption(1, GuiCellOption::AbsoluteOption(trackThickness)); - trackTable->SetColumnOption(2, GuiCellOption::PercentageOption(0.5)); - trackCell->SetSite(0, 1, 1, 1); - break; - } - InstallTrack(trackCell, direction); - } - { - handleComposition=new GuiTableComposition; - handleComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - contentCell->AddChild(handleComposition); - GuiCellComposition* handleCell=new GuiCellComposition; - handleComposition->AddChild(handleCell); - - switch(direction) - { - case Horizontal: - handleComposition->SetRowsAndColumns(1, 3); - handleComposition->SetColumnOption(0, GuiCellOption::PercentageOption(0.0)); - handleComposition->SetColumnOption(1, GuiCellOption::AbsoluteOption(handleShort)); - handleComposition->SetColumnOption(2, GuiCellOption::PercentageOption(1.0)); - handleCell->SetSite(0, 1, 1, 1); - break; - case Vertical: - handleComposition->SetRowsAndColumns(3, 1); - handleComposition->SetRowOption(0, GuiCellOption::PercentageOption(1.0)); - handleComposition->SetRowOption(1, GuiCellOption::AbsoluteOption(handleShort)); - handleComposition->SetRowOption(2, GuiCellOption::PercentageOption(0.0)); - handleCell->SetSite(1, 0, 1, 1); - break; - } - - handleButton=new GuiButton(CreateHandleButtonStyle(direction)); - handleButton->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); - handleCell->AddChild(handleButton->GetBoundsComposition()); - - handleButton->GetBoundsComposition()->GetEventReceiver()->leftButtonDown.AttachMethod(this, &CommonTrackStyle::OnHandleMouseDown); - handleButton->GetBoundsComposition()->GetEventReceiver()->mouseMove.AttachMethod(this, &CommonTrackStyle::OnHandleMouseMove); - handleButton->GetBoundsComposition()->GetEventReceiver()->leftButtonUp.AttachMethod(this, &CommonTrackStyle::OnHandleMouseUp); - } - } - } - } - - CommonTrackStyle::CommonTrackStyle(Direction _direction) - :direction(_direction) - ,commandExecutor(0) - ,totalSize(1) - ,pageSize(1) - ,position(0) - ,draggingHandle(false) - { - } - - CommonTrackStyle::~CommonTrackStyle() - { - } - - compositions::GuiBoundsComposition* CommonTrackStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* CommonTrackStyle::GetContainerComposition() - { - return boundsComposition; - } - - void CommonTrackStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void CommonTrackStyle::SetText(const WString& value) - { - } - - void CommonTrackStyle::SetFont(const FontProperties& value) - { - } - - void CommonTrackStyle::SetVisuallyEnabled(bool value) - { - } - - void CommonTrackStyle::SetCommandExecutor(controls::IScrollCommandExecutor* value) - { - commandExecutor=value; - if(value) - { - value->SetPageSize(0); - } - } - - void CommonTrackStyle::SetTotalSize(vint value) - { - if(totalSize!=value) - { - totalSize=value; - UpdateHandle(); - } - } - - void CommonTrackStyle::SetPageSize(vint value) - { - if(pageSize!=value) - { - pageSize=value; - UpdateHandle(); - } - } - - void CommonTrackStyle::SetPosition(vint value) - { - if(position!=value) - { - position=value; - UpdateHandle(); - } - } - -/*********************************************************************** -CommonFragmentBuilder -***********************************************************************/ - - void CommonFragmentBuilder::FillUpArrow(elements::GuiPolygonElement* element) - { - Point points[]={Point(0, 3), Point(3, 0), Point(6, 3)}; - element->SetSize(Size(7, 4)); - element->SetPoints(points, sizeof(points)/sizeof(*points)); - } - - void CommonFragmentBuilder::FillDownArrow(elements::GuiPolygonElement* element) - { - Point points[]={Point(0, 0), Point(3, 3), Point(6, 0)}; - element->SetSize(Size(7, 4)); - element->SetPoints(points, sizeof(points)/sizeof(*points)); - } - - void CommonFragmentBuilder::FillLeftArrow(elements::GuiPolygonElement* element) - { - Point points[]={Point(3, 0), Point(0, 3), Point(3, 6)}; - element->SetSize(Size(4, 7)); - element->SetPoints(points, sizeof(points)/sizeof(*points)); - } - - void CommonFragmentBuilder::FillRightArrow(elements::GuiPolygonElement* element) - { - Point points[]={Point(0, 0), Point(3, 3), Point(0, 6)}; - element->SetSize(Size(4, 7)); - element->SetPoints(points, sizeof(points)/sizeof(*points)); - } - - elements::GuiPolygonElement* CommonFragmentBuilder::BuildUpArrow() - { - GuiPolygonElement* element=GuiPolygonElement::Create(); - FillUpArrow(element); - element->SetBorderColor(Color(0, 0, 0)); - element->SetBackgroundColor(Color(0, 0, 0)); - return element; - } - - elements::GuiPolygonElement* CommonFragmentBuilder::BuildDownArrow() - { - GuiPolygonElement* element=GuiPolygonElement::Create(); - FillDownArrow(element); - element->SetBorderColor(Color(0, 0, 0)); - element->SetBackgroundColor(Color(0, 0, 0)); - return element; - } - - elements::GuiPolygonElement* CommonFragmentBuilder::BuildLeftArrow() - { - GuiPolygonElement* element=GuiPolygonElement::Create(); - FillLeftArrow(element); - element->SetBorderColor(Color(0, 0, 0)); - element->SetBackgroundColor(Color(0, 0, 0)); - return element; - } - - elements::GuiPolygonElement* CommonFragmentBuilder::BuildRightArrow() - { - GuiPolygonElement* element=GuiPolygonElement::Create(); - FillRightArrow(element); - element->SetBorderColor(Color(0, 0, 0)); - element->SetBackgroundColor(Color(0, 0, 0)); - return element; - } - - compositions::GuiBoundsComposition* CommonFragmentBuilder::BuildDockedElementContainer(elements::IGuiGraphicsElement* element) - { - GuiBoundsComposition* composition=new GuiBoundsComposition; - composition->SetOwnedElement(element); - composition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - composition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - return composition; - } - - compositions::GuiBoundsComposition* CommonFragmentBuilder::BuildUpArrow(elements::GuiPolygonElement*& elementOut) - { - elementOut=BuildUpArrow(); - return BuildDockedElementContainer(elementOut); - } - - compositions::GuiBoundsComposition* CommonFragmentBuilder::BuildDownArrow(elements::GuiPolygonElement*& elementOut) - { - elementOut=BuildDownArrow(); - return BuildDockedElementContainer(elementOut); - } - - compositions::GuiBoundsComposition* CommonFragmentBuilder::BuildLeftArrow(elements::GuiPolygonElement*& elementOut) - { - elementOut=BuildLeftArrow(); - return BuildDockedElementContainer(elementOut); - } - - compositions::GuiBoundsComposition* CommonFragmentBuilder::BuildRightArrow(elements::GuiPolygonElement*& elementOut) - { - elementOut=BuildRightArrow(); - return BuildDockedElementContainer(elementOut); - } - } - -/*********************************************************************** -Helpers -***********************************************************************/ - - unsigned char IntToColor(vint color) - { - return color<0?0:color>255?255:(unsigned char)color; - } - - Color BlendColor(Color c1, Color c2, vint currentPosition, vint totalLength) - { - return Color( - (unsigned char)IntToColor((c2.r*currentPosition+c1.r*(totalLength-currentPosition))/totalLength), - (unsigned char)IntToColor((c2.g*currentPosition+c1.g*(totalLength-currentPosition))/totalLength), - (unsigned char)IntToColor((c2.b*currentPosition+c1.b*(totalLength-currentPosition))/totalLength), - (unsigned char)IntToColor((c2.a*currentPosition+c1.a*(totalLength-currentPosition))/totalLength) - ); - } - } -} - -/*********************************************************************** -CONTROLS\STYLES\GUITHEMESTYLEFACTORY.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace theme - { - ITheme* currentTheme=0; - - ITheme* GetCurrentTheme() - { - return currentTheme; - } - - void SetCurrentTheme(ITheme* theme) - { - currentTheme=theme; - } - - namespace g - { - controls::GuiWindow* NewWindow() - { - return new controls::GuiWindow(GetCurrentTheme()->CreateWindowStyle()); - } - - controls::GuiCustomControl* NewCustomControl() - { - return new controls::GuiCustomControl(GetCurrentTheme()->CreateCustomControlStyle()); - } - - controls::GuiLabel* NewLabel() - { - return new controls::GuiLabel(GetCurrentTheme()->CreateLabelStyle()); - } - - controls::GuiScrollContainer* NewScrollContainer() - { - return new controls::GuiScrollContainer(GetCurrentTheme()->CreateScrollContainerStyle()); - } - - controls::GuiControl* NewGroupBox() - { - return new controls::GuiControl(GetCurrentTheme()->CreateGroupBoxStyle()); - } - - controls::GuiTab* NewTab() - { - return new controls::GuiTab(GetCurrentTheme()->CreateTabStyle()); - } - - controls::GuiTabPage* NewTabPage() - { - return new controls::GuiTabPage(GetCurrentTheme()->CreateCustomControlStyle()); - } - - controls::GuiComboBoxListControl* NewComboBox(controls::GuiSelectableListControl* containedListControl) - { - return new controls::GuiComboBoxListControl(GetCurrentTheme()->CreateComboBoxStyle(), containedListControl); - } - - controls::GuiMultilineTextBox* NewMultilineTextBox() - { - return new controls::GuiMultilineTextBox(GetCurrentTheme()->CreateMultilineTextBoxStyle()); - } - - controls::GuiSinglelineTextBox* NewTextBox() - { - return new controls::GuiSinglelineTextBox(GetCurrentTheme()->CreateTextBoxStyle()); - } - - controls::GuiDocumentViewer* NewDocumentViewer() - { - return new controls::GuiDocumentViewer(GetCurrentTheme()->CreateDocumentViewerStyle()); - } - - controls::GuiDocumentLabel* NewDocumentLabel() - { - return new controls::GuiDocumentLabel(GetCurrentTheme()->CreateDocumentLabelStyle()); - } - - controls::GuiDocumentLabel* NewDocumentTextBox() - { - return new controls::GuiDocumentLabel(GetCurrentTheme()->CreateDocumentTextBoxStyle()); - } - - controls::GuiListView* NewListView() - { - controls::GuiListView* listview=new controls::GuiListView(GetCurrentTheme()->CreateListViewStyle()); - return listview; - } - - controls::GuiTreeView* NewTreeView() - { - return new controls::GuiTreeView(GetCurrentTheme()->CreateTreeViewStyle()); - } - - controls::GuiToolstripMenu* NewMenu(controls::GuiControl* owner) - { - return new controls::GuiToolstripMenu(GetCurrentTheme()->CreateMenuStyle(), owner); - } - - controls::GuiToolstripMenuBar* NewMenuBar() - { - return new controls::GuiToolstripMenuBar(GetCurrentTheme()->CreateMenuBarStyle()); - } - - controls::GuiControl* NewMenuSplitter() - { - return new controls::GuiControl(GetCurrentTheme()->CreateMenuSplitterStyle()); - } - - controls::GuiToolstripButton* NewMenuBarButton() - { - return new controls::GuiToolstripButton(GetCurrentTheme()->CreateMenuBarButtonStyle()); - } - - controls::GuiToolstripButton* NewMenuItemButton() - { - return new controls::GuiToolstripButton(GetCurrentTheme()->CreateMenuItemButtonStyle()); - } - - controls::GuiToolstripToolBar* NewToolBar() - { - return new controls::GuiToolstripToolBar(GetCurrentTheme()->CreateToolBarStyle()); - } - - controls::GuiToolstripButton* NewToolBarButton() - { - return new controls::GuiToolstripButton(GetCurrentTheme()->CreateToolBarButtonStyle()); - } - - controls::GuiToolstripButton* NewToolBarDropdownButton() - { - return new controls::GuiToolstripButton(GetCurrentTheme()->CreateToolBarDropdownButtonStyle()); - } - - controls::GuiToolstripButton* NewToolBarSplitButton() - { - return new controls::GuiToolstripButton(GetCurrentTheme()->CreateToolBarSplitButtonStyle()); - } - - controls::GuiControl* NewToolBarSplitter() - { - return new controls::GuiControl(GetCurrentTheme()->CreateToolBarSplitterStyle()); - } - - controls::GuiButton* NewButton() - { - return new controls::GuiButton(GetCurrentTheme()->CreateButtonStyle()); - } - - controls::GuiSelectableButton* NewCheckBox() - { - return new controls::GuiSelectableButton(GetCurrentTheme()->CreateCheckBoxStyle()); - } - - controls::GuiSelectableButton* NewRadioButton() - { - return new controls::GuiSelectableButton(GetCurrentTheme()->CreateRadioButtonStyle()); - } - - controls::GuiDatePicker* NewDatePicker() - { - return new controls::GuiDatePicker(GetCurrentTheme()->CreateDatePickerStyle()); - } - - controls::GuiDateComboBox* NewDateComboBox() - { - return new controls::GuiDateComboBox(GetCurrentTheme()->CreateComboBoxStyle(), NewDatePicker()); - } - - controls::GuiScroll* NewHScroll() - { - return new controls::GuiScroll(GetCurrentTheme()->CreateHScrollStyle()); - } - - controls::GuiScroll* NewVScroll() - { - return new controls::GuiScroll(GetCurrentTheme()->CreateVScrollStyle()); - } - - controls::GuiScroll* NewHTracker() - { - controls::GuiScroll* scroll=new controls::GuiScroll(GetCurrentTheme()->CreateHTrackerStyle()); - scroll->SetPageSize(0); - return scroll; - } - - controls::GuiScroll* NewVTracker() - { - controls::GuiScroll* scroll=new controls::GuiScroll(GetCurrentTheme()->CreateVTrackerStyle()); - scroll->SetPageSize(0); - return scroll; - } - - controls::GuiScroll* NewProgressBar() - { - controls::GuiScroll* scroll=new controls::GuiScroll(GetCurrentTheme()->CreateProgressBarStyle()); - scroll->SetPageSize(0); - return scroll; - } - - controls::GuiTextList* NewTextList() - { - return new controls::GuiTextList(GetCurrentTheme()->CreateTextListStyle()); - } - } - } - } -} - -/*********************************************************************** -CONTROLS\STYLES\GUIWIN7STYLES.CPP -***********************************************************************/ - - -namespace vl -{ - namespace presentation - { - namespace win7 - { - using namespace collections; - using namespace elements; - using namespace compositions; - using namespace controls; - -/*********************************************************************** -Win7Theme -***********************************************************************/ - - Win7Theme::Win7Theme() - { - } - - Win7Theme::~Win7Theme() - { - } - - controls::GuiWindow::IStyleController* Win7Theme::CreateWindowStyle() - { - return new Win7WindowStyle; - } - - controls::GuiCustomControl::IStyleController* Win7Theme::CreateCustomControlStyle() - { - return new GuiCustomControl::EmptyStyleController; - } - - controls::GuiTooltip::IStyleController* Win7Theme::CreateTooltipStyle() - { - return new Win7TooltipStyle; - } - - controls::GuiLabel::IStyleController* Win7Theme::CreateLabelStyle() - { - return new Win7LabelStyle(false); - } - - controls::GuiLabel::IStyleController* Win7Theme::CreateShortcutKeyStyle() - { - return new Win7LabelStyle(true); - } - - controls::GuiScrollContainer::IStyleProvider* Win7Theme::CreateScrollContainerStyle() - { - return new Win7ScrollViewProvider; - } - - controls::GuiControl::IStyleController* Win7Theme::CreateGroupBoxStyle() - { - return new Win7GroupBoxStyle; - } - - controls::GuiTab::IStyleController* Win7Theme::CreateTabStyle() - { - return new Win7TabStyle; - } - - controls::GuiComboBoxListControl::IStyleController* Win7Theme::CreateComboBoxStyle() - { - return new Win7DropDownComboBoxStyle; - } - - controls::GuiScrollView::IStyleProvider* Win7Theme::CreateMultilineTextBoxStyle() - { - return new Win7MultilineTextBoxProvider; - } - - controls::GuiSinglelineTextBox::IStyleProvider* Win7Theme::CreateTextBoxStyle() - { - return new Win7SinglelineTextBoxProvider; - } - - elements::text::ColorEntry Win7Theme::GetDefaultTextBoxColorEntry() - { - return Win7GetTextBoxTextColor(); - } - - controls::GuiDocumentViewer::IStyleProvider* Win7Theme::CreateDocumentViewerStyle() - { - return new Win7DocumentViewerStyle; - } - - controls::GuiDocumentLabel::IStyleController* Win7Theme::CreateDocumentLabelStyle() - { - return new Win7DocumentLabelStyle; - } - - controls::GuiDocumentLabel::IStyleController* Win7Theme::CreateDocumentTextBoxStyle() - { - return new Win7DocumentTextBoxStyle; - } - - controls::GuiListView::IStyleProvider* Win7Theme::CreateListViewStyle() - { - return new Win7ListViewProvider; - } - - controls::GuiTreeView::IStyleProvider* Win7Theme::CreateTreeViewStyle() - { - return new Win7TreeViewProvider; - } - - controls::GuiSelectableButton::IStyleController* Win7Theme::CreateListItemBackgroundStyle() - { - return new Win7SelectableItemStyle(); - } - - controls::GuiSelectableButton::IStyleController* Win7Theme::CreateTreeItemExpanderStyle() - { - return new Win7TreeViewExpandingButtonStyle(); - } - - controls::GuiToolstripMenu::IStyleController* Win7Theme::CreateMenuStyle() - { - return new Win7MenuStyle; - } - - controls::GuiToolstripMenuBar::IStyleController* Win7Theme::CreateMenuBarStyle() - { - return new Win7MenuBarStyle; - } - - controls::GuiControl::IStyleController* Win7Theme::CreateMenuSplitterStyle() - { - return new Win7MenuSplitterStyle; - } - - controls::GuiToolstripButton::IStyleController* Win7Theme::CreateMenuBarButtonStyle() - { - return new Win7MenuBarButtonStyle; - } - - controls::GuiToolstripButton::IStyleController* Win7Theme::CreateMenuItemButtonStyle() - { - return new Win7MenuItemButtonStyle; - } - - controls::GuiControl::IStyleController* Win7Theme::CreateToolBarStyle() - { - return new Win7ToolstripToolBarStyle; - } - - controls::GuiToolstripButton::IStyleController* Win7Theme::CreateToolBarButtonStyle() - { - return new Win7ToolstripButtonStyle(Win7ToolstripButtonStyle::CommandButton); - } - - controls::GuiToolstripButton::IStyleController* Win7Theme::CreateToolBarDropdownButtonStyle() - { - return new Win7ToolstripButtonStyle(Win7ToolstripButtonStyle::DropdownButton); - } - - controls::GuiToolstripButton::IStyleController* Win7Theme::CreateToolBarSplitButtonStyle() - { - return new Win7ToolstripButtonStyle(Win7ToolstripButtonStyle::SplitButton); - } - - controls::GuiControl::IStyleController* Win7Theme::CreateToolBarSplitterStyle() - { - return new Win7ToolstripSplitterStyle; - } - - controls::GuiButton::IStyleController* Win7Theme::CreateButtonStyle() - { - return new Win7ButtonStyle; - } - - controls::GuiSelectableButton::IStyleController* Win7Theme::CreateCheckBoxStyle() - { - return new Win7CheckBoxStyle(Win7CheckBoxStyle::CheckBox); - } - - controls::GuiSelectableButton::IStyleController* Win7Theme::CreateRadioButtonStyle() - { - return new Win7CheckBoxStyle(Win7CheckBoxStyle::RadioButton); - } - - controls::GuiDatePicker::IStyleProvider* Win7Theme::CreateDatePickerStyle() - { - return new Win7DatePickerStyle; - } - - controls::GuiScroll::IStyleController* Win7Theme::CreateHScrollStyle() - { - return new Win7ScrollStyle(Win7ScrollStyle::Horizontal); - } - - controls::GuiScroll::IStyleController* Win7Theme::CreateVScrollStyle() - { - return new Win7ScrollStyle(Win7ScrollStyle::Vertical); - } - - controls::GuiScroll::IStyleController* Win7Theme::CreateHTrackerStyle() - { - return new Win7TrackStyle(Win7TrackStyle::Horizontal); - } - - controls::GuiScroll::IStyleController* Win7Theme::CreateVTrackerStyle() - { - return new Win7TrackStyle(Win7TrackStyle::Vertical); - } - - controls::GuiScroll::IStyleController* Win7Theme::CreateProgressBarStyle() - { - return new Win7ProgressBarStyle; - } - - vint Win7Theme::GetScrollDefaultSize() - { - return Win7ScrollStyle::DefaultSize; - } - - vint Win7Theme::GetTrackerDefaultSize() - { - return Win7TrackStyle::HandleLong; - } - - controls::GuiVirtualTextList::IStyleProvider* Win7Theme::CreateTextListStyle() - { - return new Win7TextListProvider; - } - - controls::GuiSelectableButton::IStyleController* Win7Theme::CreateCheckTextListItemStyle() - { - return new Win7CheckBoxStyle(Win7CheckBoxStyle::CheckBox, false); - } - - controls::GuiSelectableButton::IStyleController* Win7Theme::CreateRadioTextListItemStyle() - { - return new Win7CheckBoxStyle(Win7CheckBoxStyle::RadioButton, false); - } - } - } -} - -/*********************************************************************** -CONTROLS\STYLES\GUIWIN8STYLES.CPP -***********************************************************************/ - - -namespace vl -{ - namespace presentation - { - namespace win8 - { - using namespace collections; - using namespace elements; - using namespace compositions; - using namespace controls; - -/*********************************************************************** -Win8Theme -***********************************************************************/ - - Win8Theme::Win8Theme() - { - } - - Win8Theme::~Win8Theme() - { - } - - controls::GuiWindow::IStyleController* Win8Theme::CreateWindowStyle() - { - return new Win8WindowStyle; - } - - controls::GuiCustomControl::IStyleController* Win8Theme::CreateCustomControlStyle() - { - return new GuiCustomControl::EmptyStyleController; - } - - controls::GuiTooltip::IStyleController* Win8Theme::CreateTooltipStyle() - { - return new Win8TooltipStyle; - } - - controls::GuiLabel::IStyleController* Win8Theme::CreateLabelStyle() - { - return new Win8LabelStyle(false); - } - - controls::GuiLabel::IStyleController* Win8Theme::CreateShortcutKeyStyle() - { - return new Win8LabelStyle(true); - } - - controls::GuiScrollContainer::IStyleProvider* Win8Theme::CreateScrollContainerStyle() - { - return new Win8ScrollViewProvider; - } - - controls::GuiControl::IStyleController* Win8Theme::CreateGroupBoxStyle() - { - return new Win8GroupBoxStyle; - } - - controls::GuiTab::IStyleController* Win8Theme::CreateTabStyle() - { - return new Win8TabStyle; - } - - controls::GuiComboBoxListControl::IStyleController* Win8Theme::CreateComboBoxStyle() - { - return new Win8DropDownComboBoxStyle; - } - - controls::GuiScrollView::IStyleProvider* Win8Theme::CreateMultilineTextBoxStyle() - { - return new Win8MultilineTextBoxProvider; - } - - controls::GuiSinglelineTextBox::IStyleProvider* Win8Theme::CreateTextBoxStyle() - { - return new Win8SinglelineTextBoxProvider; - } - - elements::text::ColorEntry Win8Theme::GetDefaultTextBoxColorEntry() - { - return Win8GetTextBoxTextColor(); - } - - controls::GuiDocumentViewer::IStyleProvider* Win8Theme::CreateDocumentViewerStyle() - { - return new Win8DocumentViewerStyle; - } - - controls::GuiDocumentLabel::IStyleController* Win8Theme::CreateDocumentLabelStyle() - { - return new Win8DocumentLabelStyle; - } - - controls::GuiDocumentLabel::IStyleController* Win8Theme::CreateDocumentTextBoxStyle() - { - return new Win8DocumentTextBoxStyle; - } - - controls::GuiListView::IStyleProvider* Win8Theme::CreateListViewStyle() - { - return new Win8ListViewProvider; - } - - controls::GuiTreeView::IStyleProvider* Win8Theme::CreateTreeViewStyle() - { - return new Win8TreeViewProvider; - } - - controls::GuiSelectableButton::IStyleController* Win8Theme::CreateListItemBackgroundStyle() - { - return new Win8SelectableItemStyle(); - } - - controls::GuiSelectableButton::IStyleController* Win8Theme::CreateTreeItemExpanderStyle() - { - return new win7::Win7TreeViewExpandingButtonStyle(); - } - - controls::GuiToolstripMenu::IStyleController* Win8Theme::CreateMenuStyle() - { - return new Win8MenuStyle; - } - - controls::GuiToolstripMenuBar::IStyleController* Win8Theme::CreateMenuBarStyle() - { - return new Win8MenuBarStyle; - } - - controls::GuiControl::IStyleController* Win8Theme::CreateMenuSplitterStyle() - { - return new Win8MenuSplitterStyle; - } - - controls::GuiToolstripButton::IStyleController* Win8Theme::CreateMenuBarButtonStyle() - { - return new Win8MenuBarButtonStyle; - } - - controls::GuiToolstripButton::IStyleController* Win8Theme::CreateMenuItemButtonStyle() - { - return new Win8MenuItemButtonStyle; - } - - controls::GuiControl::IStyleController* Win8Theme::CreateToolBarStyle() - { - return new Win8ToolstripToolBarStyle; - } - - controls::GuiToolstripButton::IStyleController* Win8Theme::CreateToolBarButtonStyle() - { - return new Win8ToolstripButtonStyle(Win8ToolstripButtonStyle::CommandButton); - } - - controls::GuiToolstripButton::IStyleController* Win8Theme::CreateToolBarDropdownButtonStyle() - { - return new Win8ToolstripButtonStyle(Win8ToolstripButtonStyle::DropdownButton); - } - - controls::GuiToolstripButton::IStyleController* Win8Theme::CreateToolBarSplitButtonStyle() - { - return new Win8ToolstripButtonStyle(Win8ToolstripButtonStyle::SplitButton); - } - - controls::GuiControl::IStyleController* Win8Theme::CreateToolBarSplitterStyle() - { - return new Win8ToolstripSplitterStyle; - } - - controls::GuiButton::IStyleController* Win8Theme::CreateButtonStyle() - { - return new Win8ButtonStyle; - } - - controls::GuiSelectableButton::IStyleController* Win8Theme::CreateCheckBoxStyle() - { - return new Win8CheckBoxStyle(Win8CheckBoxStyle::CheckBox); - } - - controls::GuiSelectableButton::IStyleController* Win8Theme::CreateRadioButtonStyle() - { - return new Win8CheckBoxStyle(Win8CheckBoxStyle::RadioButton); - } - - controls::GuiDatePicker::IStyleProvider* Win8Theme::CreateDatePickerStyle() - { - return new Win8DatePickerStyle; - } - - controls::GuiScroll::IStyleController* Win8Theme::CreateHScrollStyle() - { - return new Win8ScrollStyle(common_styles::CommonScrollStyle::Horizontal); - } - - controls::GuiScroll::IStyleController* Win8Theme::CreateVScrollStyle() - { - return new Win8ScrollStyle(common_styles::CommonScrollStyle::Vertical); - } - - controls::GuiScroll::IStyleController* Win8Theme::CreateHTrackerStyle() - { - return new Win8TrackStyle(common_styles::CommonTrackStyle::Horizontal); - } - - controls::GuiScroll::IStyleController* Win8Theme::CreateVTrackerStyle() - { - return new Win8TrackStyle(common_styles::CommonTrackStyle::Vertical); - } - - controls::GuiScroll::IStyleController* Win8Theme::CreateProgressBarStyle() - { - return new Win8ProgressBarStyle; - } - - vint Win8Theme::GetScrollDefaultSize() - { - return Win8ScrollStyle::DefaultSize; - } - - vint Win8Theme::GetTrackerDefaultSize() - { - return Win8TrackStyle::HandleLong; - } - - controls::GuiVirtualTextList::IStyleProvider* Win8Theme::CreateTextListStyle() - { - return new Win8TextListProvider; - } - - controls::GuiSelectableButton::IStyleController* Win8Theme::CreateCheckTextListItemStyle() - { - return new Win8CheckBoxStyle(Win8CheckBoxStyle::CheckBox, false); - } - - controls::GuiSelectableButton::IStyleController* Win8Theme::CreateRadioTextListItemStyle() - { - return new Win8CheckBoxStyle(Win8CheckBoxStyle::RadioButton, false); - } - } - } -} - -/*********************************************************************** -CONTROLS\STYLES\WIN7STYLES\GUIWIN7BUTTONSTYLES.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace win7 - { - using namespace collections; - using namespace elements; - using namespace compositions; - using namespace controls; - -/*********************************************************************** -Win7ButtonStyleBase -***********************************************************************/ - - IMPLEMENT_TRANSFERRING_ANIMATION(Win7ButtonColors, Win7ButtonStyleBase) - { - colorCurrent=Win7ButtonColors::Blend(colorBegin, colorEnd, currentPosition, totalLength); - style->elements.Apply(colorCurrent); - style->AfterApplyColors(colorCurrent); - } - - void Win7ButtonStyleBase::AfterApplyColors(const Win7ButtonColors& colors) - { - } - - Win7ButtonStyleBase::Win7ButtonStyleBase(bool verticalGradient, bool roundBorder, const Win7ButtonColors& initialColor, Alignment horizontal, Alignment vertical) - :controlStyle(ButtonState::Normal) - ,isVisuallyEnabled(true) - ,isSelected(false) - ,transparentWhenInactive(false) - ,transparentWhenDisabled(false) - { - elements=Win7ButtonElements::Create(verticalGradient, roundBorder, horizontal, vertical); - elements.Apply(initialColor); - transferringAnimation=new TransferringAnimation(this, initialColor); - } - - Win7ButtonStyleBase::~Win7ButtonStyleBase() - { - transferringAnimation->Disable(); - } - - compositions::GuiBoundsComposition* Win7ButtonStyleBase::GetBoundsComposition() - { - return elements.mainComposition; - } - - compositions::GuiGraphicsComposition* Win7ButtonStyleBase::GetContainerComposition() - { - return elements.mainComposition; - } - - void Win7ButtonStyleBase::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win7ButtonStyleBase::SetText(const WString& value) - { - elements.textElement->SetText(value); - } - - void Win7ButtonStyleBase::SetFont(const FontProperties& value) - { - Win7SetFont(elements.textElement, elements.textComposition, value); - } - - void Win7ButtonStyleBase::SetVisuallyEnabled(bool value) - { - if(isVisuallyEnabled!=value) - { - isVisuallyEnabled=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected); - } - } - - void Win7ButtonStyleBase::SetSelected(bool value) - { - if(isSelected!=value) - { - isSelected=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected); - } - } - - void Win7ButtonStyleBase::Transfer(ButtonState value) - { - if(controlStyle!=value) - { - controlStyle=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected); - } - } - - bool Win7ButtonStyleBase::GetTransparentWhenInactive() - { - return transparentWhenInactive; - } - - void Win7ButtonStyleBase::SetTransparentWhenInactive(bool value) - { - transparentWhenInactive=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected); - } - - bool Win7ButtonStyleBase::GetTransparentWhenDisabled() - { - return transparentWhenDisabled; - } - - void Win7ButtonStyleBase::SetTransparentWhenDisabled(bool value) - { - transparentWhenDisabled=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected); - } - - bool Win7ButtonStyleBase::GetAutoSizeForText() - { - return elements.textComposition->GetMinSizeLimitation()!=GuiGraphicsComposition::NoLimit; - } - - void Win7ButtonStyleBase::SetAutoSizeForText(bool value) - { - if(value) - { - elements.textComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - } - else - { - elements.textComposition->SetMinSizeLimitation(GuiGraphicsComposition::NoLimit); - } - } - -/*********************************************************************** -Win7ButtonStyle -***********************************************************************/ - - void Win7ButtonStyle::TransferInternal(ButtonState value, bool enabled, bool selected) - { - Win7ButtonColors targetColor; - if(enabled) - { - switch(value) - { - case ButtonState::Normal: - targetColor=Win7ButtonColors::ButtonNormal(); - if(transparentWhenInactive) - { - targetColor.SetAlphaWithoutText(0); - } - break; - case ButtonState::Active: - targetColor=Win7ButtonColors::ButtonActive(); - break; - case ButtonState::Pressed: - targetColor=Win7ButtonColors::ButtonPressed(); - break; - } - } - else - { - targetColor=Win7ButtonColors::ButtonDisabled(); - if(transparentWhenDisabled) - { - targetColor.SetAlphaWithoutText(0); - } - } - transferringAnimation->Transfer(targetColor); - } - - Win7ButtonStyle::Win7ButtonStyle(bool verticalGradient) - :Win7ButtonStyleBase(verticalGradient, true, Win7ButtonColors::ButtonNormal(), Alignment::Center, Alignment::Center) - { - } - - Win7ButtonStyle::~Win7ButtonStyle() - { - } - -/*********************************************************************** -Win7CheckBoxStyle -***********************************************************************/ - - IMPLEMENT_TRANSFERRING_ANIMATION(Win7ButtonColors, Win7CheckBoxStyle) - { - colorCurrent=Win7ButtonColors::Blend(colorBegin, colorEnd, currentPosition, totalLength); - style->elements.Apply(colorCurrent); - } - - void Win7CheckBoxStyle::TransferInternal(ButtonState value, bool enabled, bool selected) - { - if(enabled) - { - switch(value) - { - case ButtonState::Normal: - transferringAnimation->Transfer(Win7ButtonColors::CheckedNormal(selected)); - break; - case ButtonState::Active: - transferringAnimation->Transfer(Win7ButtonColors::CheckedActive(selected)); - break; - case ButtonState::Pressed: - transferringAnimation->Transfer(Win7ButtonColors::CheckedPressed(selected)); - break; - } - } - else - { - transferringAnimation->Transfer(Win7ButtonColors::CheckedDisabled(selected)); - } - } - - Win7CheckBoxStyle::Win7CheckBoxStyle(BulletStyle bulletStyle, bool backgroundVisible) - :controlStyle(ButtonState::Normal) - ,isVisuallyEnabled(true) - ,isSelected(false) - { - Win7ButtonColors initialColor=Win7ButtonColors::CheckedNormal(isSelected); - elements=Win7CheckedButtonElements::Create(bulletStyle==CheckBox?ElementShape::Rectangle:ElementShape::Ellipse, backgroundVisible); - elements.Apply(initialColor); - transferringAnimation=new TransferringAnimation(this, initialColor); - } - - Win7CheckBoxStyle::~Win7CheckBoxStyle() - { - transferringAnimation->Disable(); - } - - compositions::GuiBoundsComposition* Win7CheckBoxStyle::GetBoundsComposition() - { - return elements.mainComposition; - } - - compositions::GuiGraphicsComposition* Win7CheckBoxStyle::GetContainerComposition() - { - return elements.mainComposition; - } - - void Win7CheckBoxStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win7CheckBoxStyle::SetText(const WString& value) - { - elements.textElement->SetText(value); - } - - void Win7CheckBoxStyle::SetFont(const FontProperties& value) - { - Win7SetFont(elements.textElement, elements.textComposition, value); - } - - void Win7CheckBoxStyle::SetVisuallyEnabled(bool value) - { - if(isVisuallyEnabled!=value) - { - isVisuallyEnabled=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected); - } - } - - void Win7CheckBoxStyle::SetSelected(bool value) - { - if(isSelected!=value) - { - isSelected=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected); - } - } - - void Win7CheckBoxStyle::Transfer(ButtonState value) - { - if(controlStyle!=value) - { - controlStyle=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected); - } - } - } - } -} - -/*********************************************************************** -CONTROLS\STYLES\WIN7STYLES\GUIWIN7CONTROLSTYLES.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace win7 - { - using namespace collections; - using namespace elements; - using namespace compositions; - using namespace controls; - -/*********************************************************************** -Win7EmptyStyle -***********************************************************************/ - - Win7EmptyStyle::Win7EmptyStyle(Color color) - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(color); - - boundsComposition=new GuiBoundsComposition; - boundsComposition->SetOwnedElement(element); - } - - Win7EmptyStyle::~Win7EmptyStyle() - { - } - - compositions::GuiBoundsComposition* Win7EmptyStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win7EmptyStyle::GetContainerComposition() - { - return boundsComposition; - } - - void Win7EmptyStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win7EmptyStyle::SetText(const WString& value) - { - } - - void Win7EmptyStyle::SetFont(const FontProperties& value) - { - } - - void Win7EmptyStyle::SetVisuallyEnabled(bool value) - { - } - -/*********************************************************************** -Win7WindowStyle -***********************************************************************/ - - Win7WindowStyle::Win7WindowStyle() - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Win7GetSystemWindowColor()); - - boundsComposition=new GuiBoundsComposition; - boundsComposition->SetOwnedElement(element); - } - - Win7WindowStyle::~Win7WindowStyle() - { - } - - compositions::GuiBoundsComposition* Win7WindowStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win7WindowStyle::GetContainerComposition() - { - return boundsComposition; - } - - void Win7WindowStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win7WindowStyle::SetText(const WString& value) - { - } - - void Win7WindowStyle::SetFont(const FontProperties& value) - { - } - - void Win7WindowStyle::SetVisuallyEnabled(bool value) - { - } - -/*********************************************************************** -Win7TooltipStyle -***********************************************************************/ - - Win7TooltipStyle::Win7TooltipStyle() - { - boundsComposition=new GuiBoundsComposition; - boundsComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - boundsComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - { - GuiSolidBorderElement* element=GuiSolidBorderElement::Create(); - element->SetColor(Color(100, 100, 100)); - boundsComposition->SetOwnedElement(element); - } - - containerComposition=new GuiBoundsComposition; - containerComposition->SetAlignmentToParent(Margin(1, 1, 1, 1)); - containerComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - boundsComposition->AddChild(containerComposition); - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Color(255, 255, 225)); - containerComposition->SetOwnedElement(element); - } - } - - Win7TooltipStyle::~Win7TooltipStyle() - { - } - - compositions::GuiBoundsComposition* Win7TooltipStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win7TooltipStyle::GetContainerComposition() - { - return containerComposition; - } - - void Win7TooltipStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win7TooltipStyle::SetText(const WString& value) - { - } - - void Win7TooltipStyle::SetFont(const FontProperties& value) - { - } - - void Win7TooltipStyle::SetVisuallyEnabled(bool value) - { - } - -/*********************************************************************** -Win7LabelStyle -***********************************************************************/ - - Win7LabelStyle::Win7LabelStyle(bool forShortcutKey) - { - textElement=GuiSolidLabelElement::Create(); - textElement->SetColor(GetDefaultTextColor()); - - boundsComposition=new GuiBoundsComposition; - boundsComposition->SetMinSizeLimitation(GuiBoundsComposition::LimitToElementAndChildren); - if (forShortcutKey) - { - { - GuiSolidBorderElement* element=GuiSolidBorderElement::Create(); - element->SetColor(Color(100, 100, 100)); - boundsComposition->SetOwnedElement(element); - } - - auto containerComposition=new GuiBoundsComposition; - containerComposition->SetAlignmentToParent(Margin(1, 1, 1, 1)); - containerComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - boundsComposition->AddChild(containerComposition); - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Color(255, 255, 225)); - containerComposition->SetOwnedElement(element); - } - - auto labelComposition = new GuiBoundsComposition; - labelComposition->SetAlignmentToParent(Margin(2, 2, 2, 2)); - labelComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - labelComposition->SetOwnedElement(textElement); - containerComposition->AddChild(labelComposition); - } - else - { - boundsComposition->SetOwnedElement(textElement); - } - } - - Win7LabelStyle::~Win7LabelStyle() - { - } - - compositions::GuiBoundsComposition* Win7LabelStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win7LabelStyle::GetContainerComposition() - { - return boundsComposition; - } - - void Win7LabelStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win7LabelStyle::SetText(const WString& value) - { - textElement->SetText(value); - } - - void Win7LabelStyle::SetFont(const FontProperties& value) - { - textElement->SetFont(value); - } - - void Win7LabelStyle::SetVisuallyEnabled(bool value) - { - } - - Color Win7LabelStyle::GetDefaultTextColor() - { - return Win7GetSystemTextColor(true); - } - - void Win7LabelStyle::SetTextColor(Color value) - { - textElement->SetColor(value); - } - -/*********************************************************************** -Win7GroupBoxStyle -***********************************************************************/ - - IMPLEMENT_TRANSFERRING_ANIMATION(Color, Win7GroupBoxStyle) - { - colorCurrent=BlendColor(colorBegin, colorEnd, currentPosition, totalLength); - style->textElement->SetColor(colorCurrent); - } - - void Win7GroupBoxStyle::SetMargins(vint fontSize) - { - fontSize+=4; - vint half=fontSize/2; - sinkBorderComposition->SetAlignmentToParent(Margin(0, half, 1, 1)); - raisedBorderComposition->SetAlignmentToParent(Margin(1, half+1, 0, 0)); - containerComposition->SetAlignmentToParent(Margin(2, fontSize, 2, 2)); - textBackgroundComposition->SetAlignmentToParent(Margin(half, 2, -1, -1)); - } - - Win7GroupBoxStyle::Win7GroupBoxStyle() - { - boundsComposition=new GuiBoundsComposition; - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Win7GetSystemWindowColor()); - - boundsComposition->SetOwnedElement(element); - boundsComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - } - - sinkBorderComposition=new GuiBoundsComposition; - { - GuiRoundBorderElement* element=GuiRoundBorderElement::Create(); - element->SetRadius(3); - element->SetColor(Color(213, 223, 229)); - - sinkBorderComposition->SetOwnedElement(element); - boundsComposition->AddChild(sinkBorderComposition); - } - - raisedBorderComposition=new GuiBoundsComposition; - { - GuiRoundBorderElement* element=GuiRoundBorderElement::Create(); - element->SetRadius(3); - element->SetColor(Color(255, 255, 255)); - - raisedBorderComposition->SetOwnedElement(element); - boundsComposition->AddChild(raisedBorderComposition); - } - - textBackgroundComposition=new GuiBoundsComposition; - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Win7GetSystemWindowColor()); - - textBackgroundComposition->SetOwnedElement(element); - textBackgroundComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - boundsComposition->AddChild(textBackgroundComposition); - } - - textComposition=new GuiBoundsComposition; - { - GuiSolidLabelElement* element=GuiSolidLabelElement::Create(); - element->SetColor(Win7GetSystemTextColor(true)); - textElement=element; - - textComposition->SetOwnedElement(element); - textComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - textComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - textBackgroundComposition->AddChild(textComposition); - } - - containerComposition=new GuiBoundsComposition; - { - boundsComposition->AddChild(containerComposition); - } - - SetMargins(0); - transferringAnimation=new TransferringAnimation(this, Win7GetSystemTextColor(true)); - } - - Win7GroupBoxStyle::~Win7GroupBoxStyle() - { - transferringAnimation->Disable(); - } - - compositions::GuiBoundsComposition* Win7GroupBoxStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win7GroupBoxStyle::GetContainerComposition() - { - return containerComposition; - } - - void Win7GroupBoxStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win7GroupBoxStyle::SetText(const WString& value) - { - textElement->SetText(value); - } - - void Win7GroupBoxStyle::SetFont(const FontProperties& value) - { - textElement->SetFont(value); - SetMargins(value.size); - } - - void Win7GroupBoxStyle::SetVisuallyEnabled(bool value) - { - if(value) - { - transferringAnimation->Transfer(Win7GetSystemTextColor(true)); - } - else - { - transferringAnimation->Transfer(Win7GetSystemTextColor(false)); - } - } - -/*********************************************************************** -Win7DatePickerStyle -***********************************************************************/ - - Win7DatePickerStyle::Win7DatePickerStyle() - { - } - - Win7DatePickerStyle::~Win7DatePickerStyle() - { - } - - void Win7DatePickerStyle::AssociateStyleController(controls::GuiControl::IStyleController* controller) - { - } - - void Win7DatePickerStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win7DatePickerStyle::SetText(const WString& value) - { - } - - void Win7DatePickerStyle::SetFont(const FontProperties& value) - { - } - - void Win7DatePickerStyle::SetVisuallyEnabled(bool value) - { - } - - controls::GuiSelectableButton::IStyleController* Win7DatePickerStyle::CreateDateButtonStyle() - { - return new Win7SelectableItemStyle; - } - - controls::GuiTextList* Win7DatePickerStyle::CreateTextList() - { - return new GuiTextList(new Win7TextListProvider); - } - - controls::GuiComboBoxListControl::IStyleController* Win7DatePickerStyle::CreateComboBoxStyle() - { - return new Win7DropDownComboBoxStyle; - } - - Color Win7DatePickerStyle::GetBackgroundColor() - { - return Win7GetSystemWindowColor(); - } - - Color Win7DatePickerStyle::GetPrimaryTextColor() - { - return Win7GetSystemTextColor(true); - } - - Color Win7DatePickerStyle::GetSecondaryTextColor() - { - return Win7GetSystemTextColor(false); - } - } - } -} - -/*********************************************************************** -CONTROLS\STYLES\WIN7STYLES\GUIWIN7LISTSTYLES.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace win7 - { - using namespace collections; - using namespace elements; - using namespace compositions; - using namespace controls; - -/*********************************************************************** -Win7SelectableItemStyle -***********************************************************************/ - - void Win7SelectableItemStyle::TransferInternal(ButtonState value, bool enabled, bool selected) - { - if(!enabled) - { - transferringAnimation->Transfer(Win7ButtonColors::ItemDisabled()); - } - else if(selected) - { - transferringAnimation->Transfer(Win7ButtonColors::ItemSelected()); - } - else - { - switch(value) - { - case ButtonState::Normal: - transferringAnimation->Transfer(Win7ButtonColors::ItemNormal()); - break; - case ButtonState::Active: - transferringAnimation->Transfer(Win7ButtonColors::ItemActive()); - break; - case ButtonState::Pressed: - transferringAnimation->Transfer(Win7ButtonColors::ItemSelected()); - break; - } - } - } - - Win7SelectableItemStyle::Win7SelectableItemStyle() - :Win7ButtonStyleBase(true, true, Win7ButtonColors::ItemNormal(), Alignment::Left, Alignment::Center) - { - transferringAnimation->SetEnableAnimation(false); - } - - Win7SelectableItemStyle::~Win7SelectableItemStyle() - { - } - -/*********************************************************************** -Win7ListViewColumnDropDownStyle -***********************************************************************/ - - void Win7ListViewColumnDropDownStyle::TransferInternal(controls::ButtonState value, bool enabled, bool selected) - { - if(!enabled) value= ButtonState::Normal; - switch(value) - { - case ButtonState::Normal: - { - leftBorderComposition->SetVisible(true); - borderComposition->SetVisible(false); - gradientComposition->SetVisible(false); - - leftBorderElement->SetColors(Color(223, 234, 247), Color(252, 252, 252)); - } - break; - case ButtonState::Active: - case ButtonState::Pressed: - { - leftBorderComposition->SetVisible(false); - borderComposition->SetVisible(true); - gradientComposition->SetVisible(true); - - borderElement->SetColor(Color(192, 203, 217)); - gradientElement->SetColors(Color(230, 241, 255), Color(224, 226, 253)); - } - break; - } - } - - Win7ListViewColumnDropDownStyle::Win7ListViewColumnDropDownStyle() - :controlStyle(ButtonState::Normal) - ,isVisuallyEnabled(true) - ,isSelected(false) - { - mainComposition=new GuiBoundsComposition; - mainComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - - leftBorderElement=GuiGradientBackgroundElement::Create(); - leftBorderElement->SetDirection(GuiGradientBackgroundElement::Vertical); - leftBorderComposition=new GuiBoundsComposition; - leftBorderComposition->SetOwnedElement(leftBorderElement); - leftBorderComposition->SetAlignmentToParent(Margin(0, 1, -1, 1)); - leftBorderComposition->SetPreferredMinSize(Size(1, 1)); - mainComposition->AddChild(leftBorderComposition); - - borderElement=GuiSolidBorderElement::Create(); - borderComposition=new GuiBoundsComposition; - borderComposition->SetOwnedElement(borderElement); - borderComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - mainComposition->AddChild(borderComposition); - - gradientElement=GuiGradientBackgroundElement::Create(); - gradientElement->SetDirection(GuiGradientBackgroundElement::Vertical); - gradientComposition=new GuiBoundsComposition; - gradientComposition->SetOwnedElement(gradientElement); - gradientComposition->SetAlignmentToParent(Margin(2, 2, 2, 2)); - gradientComposition->SetPreferredMinSize(Size(0, 4)); - mainComposition->AddChild(gradientComposition); - - arrowElement=common_styles::CommonFragmentBuilder::BuildDownArrow(); - arrowElement->SetBackgroundColor(Color(76, 96, 122)); - arrowElement->SetBorderColor(Color(76, 96, 122)); - arrowComposition=new GuiBoundsComposition; - arrowComposition->SetOwnedElement(arrowElement); - arrowComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - arrowComposition->SetAlignmentToParent(Margin(3, 3, 3, 3)); - mainComposition->AddChild(arrowComposition); - - TransferInternal(controlStyle, isVisuallyEnabled, isSelected); - } - - Win7ListViewColumnDropDownStyle::~Win7ListViewColumnDropDownStyle() - { - } - - compositions::GuiBoundsComposition* Win7ListViewColumnDropDownStyle::GetBoundsComposition() - { - return mainComposition; - } - - compositions::GuiGraphicsComposition* Win7ListViewColumnDropDownStyle::GetContainerComposition() - { - return mainComposition; - } - - void Win7ListViewColumnDropDownStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win7ListViewColumnDropDownStyle::SetText(const WString& value) - { - } - - void Win7ListViewColumnDropDownStyle::SetFont(const FontProperties& value) - { - } - - void Win7ListViewColumnDropDownStyle::SetVisuallyEnabled(bool value) - { - if(isVisuallyEnabled!=value) - { - isVisuallyEnabled=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected); - } - } - - void Win7ListViewColumnDropDownStyle::SetSelected(bool value) - { - if(isSelected!=value) - { - isSelected=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected); - } - } - - void Win7ListViewColumnDropDownStyle::Transfer(ButtonState value) - { - if(controlStyle!=value) - { - controlStyle=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected); - } - } - -/*********************************************************************** -Win7ListViewColumnHeaderStyle -***********************************************************************/ - - void Win7ListViewColumnHeaderStyle::TransferInternal(controls::ButtonState value, bool enabled, bool subMenuExisting, bool subMenuOpening) - { - if(!enabled) value= ButtonState::Normal; - switch(value) - { - case ButtonState::Normal: - { - rightBorderComposition->SetVisible(true); - borderComposition->SetVisible(false); - gradientComposition->SetVisible(false); - - backgroundElement->SetColor(Color(252, 252, 252)); - rightBorderElement->SetColors(Color(223, 234, 247), Color(252, 252, 252)); - - dropdownButton->SetVisible(subMenuOpening); - } - break; - case ButtonState::Active: - { - rightBorderComposition->SetVisible(false); - borderComposition->SetVisible(true); - gradientComposition->SetVisible(true); - gradientComposition->SetAlignmentToParent(Margin(2, 2, 2, 2)); - - backgroundElement->SetColor(Color(252, 252, 252)); - borderElement->SetColor(Color(223, 233, 246)); - gradientElement->SetColors(Color(243, 248, 253), Color(239, 243, 249)); - - dropdownButton->SetVisible(isSubMenuExisting); - } - break; - case ButtonState::Pressed: - { - rightBorderComposition->SetVisible(false); - borderComposition->SetVisible(true); - gradientComposition->SetVisible(true); - gradientComposition->SetAlignmentToParent(Margin(1, 0, 1, -1)); - - backgroundElement->SetColor(Color(246, 247, 248)); - borderElement->SetColor(Color(192, 203, 217)); - gradientElement->SetColors(Color(193, 204, 218), Color(252, 252, 252)); - - dropdownButton->SetVisible(isSubMenuExisting); - } - break; - } - } - - Win7ListViewColumnHeaderStyle::Win7ListViewColumnHeaderStyle() - :controlStyle(ButtonState::Normal) - ,isVisuallyEnabled(true) - ,isSubMenuExisting(false) - ,isSubMenuOpening(false) - { - backgroundElement=GuiSolidBackgroundElement::Create(); - mainComposition=new GuiBoundsComposition; - mainComposition->SetOwnedElement(backgroundElement); - mainComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - - rightBorderElement=GuiGradientBackgroundElement::Create(); - rightBorderElement->SetDirection(GuiGradientBackgroundElement::Vertical); - rightBorderComposition=new GuiBoundsComposition; - rightBorderComposition->SetOwnedElement(rightBorderElement); - rightBorderComposition->SetAlignmentToParent(Margin(-1, 0, 0, 0)); - rightBorderComposition->SetPreferredMinSize(Size(1, 1)); - mainComposition->AddChild(rightBorderComposition); - - borderElement=GuiSolidBorderElement::Create(); - borderComposition=new GuiBoundsComposition; - borderComposition->SetOwnedElement(borderElement); - borderComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - mainComposition->AddChild(borderComposition); - - gradientElement=GuiGradientBackgroundElement::Create(); - gradientElement->SetDirection(GuiGradientBackgroundElement::Vertical); - gradientComposition=new GuiBoundsComposition; - gradientComposition->SetOwnedElement(gradientElement); - gradientComposition->SetAlignmentToParent(Margin(2, 2, 2, 2)); - gradientComposition->SetPreferredMinSize(Size(0, 4)); - mainComposition->AddChild(gradientComposition); - - textElement=GuiSolidLabelElement::Create(); - textElement->SetColor(Color(76, 96, 122)); - textComposition=new GuiBoundsComposition; - textComposition->SetOwnedElement(textElement); - textComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - textComposition->SetAlignmentToParent(Margin(15, 7, 18, 5)); - mainComposition->AddChild(textComposition); - - arrowElement=GuiPolygonElement::Create(); - arrowElement->SetBackgroundColor(Color(76, 96, 122)); - arrowElement->SetBorderColor(Color(76, 96, 122)); - arrowComposition=new GuiBoundsComposition; - arrowComposition->SetOwnedElement(arrowElement); - arrowComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - arrowComposition->SetAlignmentToParent(Margin(0, 2, 0, -1)); - mainComposition->AddChild(arrowComposition); - - dropdownButton=new GuiButton(new Win7ListViewColumnDropDownStyle); - dropdownButton->GetBoundsComposition()->SetAlignmentToParent(Margin(-1, 0, 0, 0)); - dropdownButton->SetVisible(false); - mainComposition->AddChild(dropdownButton->GetBoundsComposition()); - - TransferInternal(controlStyle, isVisuallyEnabled, isSubMenuExisting, isSubMenuOpening); - } - - Win7ListViewColumnHeaderStyle::~Win7ListViewColumnHeaderStyle() - { - } - - compositions::GuiBoundsComposition* Win7ListViewColumnHeaderStyle::GetBoundsComposition() - { - return mainComposition; - } - - compositions::GuiGraphicsComposition* Win7ListViewColumnHeaderStyle::GetContainerComposition() - { - return mainComposition; - } - - void Win7ListViewColumnHeaderStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win7ListViewColumnHeaderStyle::SetText(const WString& value) - { - textElement->SetText(value); - } - - void Win7ListViewColumnHeaderStyle::SetFont(const FontProperties& value) - { - textElement->SetFont(value); - } - - void Win7ListViewColumnHeaderStyle::SetVisuallyEnabled(bool value) - { - if(isVisuallyEnabled!=value) - { - isVisuallyEnabled=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSubMenuExisting, isSubMenuOpening); - } - } - - void Win7ListViewColumnHeaderStyle::SetSelected(bool value) - { - } - - void Win7ListViewColumnHeaderStyle::Transfer(ButtonState value) - { - if(controlStyle!=value) - { - controlStyle=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSubMenuExisting, isSubMenuOpening); - } - } - - controls::GuiMenu::IStyleController* Win7ListViewColumnHeaderStyle::CreateSubMenuStyleController() - { - return new Win7MenuStyle; - } - - void Win7ListViewColumnHeaderStyle::SetSubMenuExisting(bool value) - { - if(isSubMenuExisting!=value) - { - isSubMenuExisting=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSubMenuExisting, isSubMenuOpening); - } - } - - void Win7ListViewColumnHeaderStyle::SetSubMenuOpening(bool value) - { - if(isSubMenuOpening!=value) - { - isSubMenuOpening=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSubMenuExisting, isSubMenuOpening); - } - } - - controls::GuiButton* Win7ListViewColumnHeaderStyle::GetSubMenuHost() - { - return dropdownButton; - } - - void Win7ListViewColumnHeaderStyle::SetImage(Ptr value) - { - } - - void Win7ListViewColumnHeaderStyle::SetShortcutText(const WString& value) - { - } - - void Win7ListViewColumnHeaderStyle::SetColumnSortingState(controls::ColumnSortingState value) - { - Margin margin=arrowComposition->GetAlignmentToParent(); - switch(value) - { - case controls::ColumnSortingState::NotSorted: - arrowElement->SetPoints(0, 0); - break; - case controls::ColumnSortingState::Ascending: - common_styles::CommonFragmentBuilder::FillUpArrow(arrowElement); - break; - case controls::ColumnSortingState::Descending: - common_styles::CommonFragmentBuilder::FillDownArrow(arrowElement); - break; - } - } - -/*********************************************************************** -Win7TreeViewExpandingButtonStyle -***********************************************************************/ - - void Win7TreeViewExpandingButtonStyle::TransferInternal(controls::ButtonState value, bool enabled, bool selected) - { - bool expanding=false; - bool activated=false; - if(isVisuallyEnabled) - { - expanding=selected; - activated=value!= ButtonState::Normal; - } - - Point points[3]; - if(expanding) - { - points[0]=Point(5, 2); - points[1]=Point(5, 7); - points[2]=Point(0, 7); - } - else - { - points[0]=Point(0, 1); - points[1]=Point(4, 5); - points[2]=Point(0, 9); - } - polygonElement->SetPoints(points, sizeof(points)/sizeof(*points)); - - if(activated) - { - polygonElement->SetBorderColor(Color(28, 196, 247)); - polygonElement->SetBackgroundColor(Color(130, 223, 251)); - } - else if(expanding) - { - polygonElement->SetBorderColor(Color(38, 38, 38)); - polygonElement->SetBackgroundColor(Color(89, 89, 89)); - } - else - { - polygonElement->SetBorderColor(Color(166, 166, 166)); - polygonElement->SetBackgroundColor(Color(255, 255, 255)); - } - } - - Win7TreeViewExpandingButtonStyle::Win7TreeViewExpandingButtonStyle() - :controlStyle(ButtonState::Normal) - ,isVisuallyEnabled(true) - ,isSelected(false) - { - polygonElement=GuiPolygonElement::Create(); - polygonElement->SetSize(Size(6, 11)); - - mainComposition=new GuiBoundsComposition; - mainComposition->SetOwnedElement(polygonElement); - mainComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - - TransferInternal(controlStyle, true, isSelected); - } - - Win7TreeViewExpandingButtonStyle::~Win7TreeViewExpandingButtonStyle() - { - } - - compositions::GuiBoundsComposition* Win7TreeViewExpandingButtonStyle::GetBoundsComposition() - { - return mainComposition; - } - - compositions::GuiGraphicsComposition* Win7TreeViewExpandingButtonStyle::GetContainerComposition() - { - return mainComposition; - } - - void Win7TreeViewExpandingButtonStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win7TreeViewExpandingButtonStyle::SetText(const WString& value) - { - } - - void Win7TreeViewExpandingButtonStyle::SetFont(const FontProperties& value) - { - } - - void Win7TreeViewExpandingButtonStyle::SetVisuallyEnabled(bool value) - { - if(isVisuallyEnabled!=value) - { - isVisuallyEnabled=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected); - } - } - - void Win7TreeViewExpandingButtonStyle::SetSelected(bool value) - { - if(isSelected!=value) - { - isSelected=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected); - } - } - - void Win7TreeViewExpandingButtonStyle::Transfer(ButtonState value) - { - if(controlStyle!=value) - { - controlStyle=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected); - } - } - -/*********************************************************************** -Win7DropDownComboBoxStyle -***********************************************************************/ - - void Win7DropDownComboBoxStyle::TransferInternal(controls::ButtonState value, bool enabled, bool selected) - { - Win7ButtonColors targetColor; - if(enabled) - { - if(selected) value= ButtonState::Pressed; - switch(value) - { - case ButtonState::Normal: - targetColor=Win7ButtonColors::ButtonNormal(); - break; - case ButtonState::Active: - targetColor=Win7ButtonColors::ButtonActive(); - break; - case ButtonState::Pressed: - targetColor=Win7ButtonColors::ButtonPressed(); - break; - } - } - else - { - targetColor=Win7ButtonColors::ButtonDisabled(); - } - transferringAnimation->Transfer(targetColor); - } - - void Win7DropDownComboBoxStyle::AfterApplyColors(const Win7ButtonColors& colors) - { - Win7ButtonStyle::AfterApplyColors(colors); - dropDownElement->SetBorderColor(colors.textColor); - dropDownElement->SetBackgroundColor(colors.textColor); - } - - Win7DropDownComboBoxStyle::Win7DropDownComboBoxStyle() - :Win7ButtonStyle(true) - , commandExecutor(0) - , textVisible(true) - { - table=new GuiTableComposition; - table->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - table->SetAlignmentToParent(Margin(0, 0, 0, 0)); - table->SetRowsAndColumns(3, 2); - table->SetRowOption(0, GuiCellOption::PercentageOption(1.0)); - table->SetRowOption(1, GuiCellOption::MinSizeOption()); - table->SetRowOption(2, GuiCellOption::PercentageOption(1.0)); - table->SetColumnOption(0, GuiCellOption::PercentageOption(1.0)); - table->SetColumnOption(1, GuiCellOption::MinSizeOption()); - elements.textComposition->AddChild(table); - elements.textComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - - textComposition=new GuiCellComposition; - table->AddChild(textComposition); - textComposition->SetSite(1, 0, 1, 1); - - Ptr element=elements.textComposition->GetOwnedElement(); - elements.textComposition->SetOwnedElement(0); - textComposition->SetOwnedElement(element); - elements.textElement->SetEllipse(true); - elements.textElement->SetAlignments(Alignment::Left, Alignment::Center); - - dropDownElement=common_styles::CommonFragmentBuilder::BuildDownArrow(); - - dropDownComposition=new GuiCellComposition; - table->AddChild(dropDownComposition); - dropDownComposition->SetSite(1, 1, 1, 1); - dropDownComposition->SetOwnedElement(dropDownElement); - dropDownComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - dropDownComposition->SetMargin(Margin(3, 0, 3, 0)); - } - - Win7DropDownComboBoxStyle::~Win7DropDownComboBoxStyle() - { - } - - compositions::GuiGraphicsComposition* Win7DropDownComboBoxStyle::GetContainerComposition() - { - return textComposition; - } - - GuiMenu::IStyleController* Win7DropDownComboBoxStyle::CreateSubMenuStyleController() - { - return new Win7MenuStyle; - } - - void Win7DropDownComboBoxStyle::SetSubMenuExisting(bool value) - { - } - - void Win7DropDownComboBoxStyle::SetSubMenuOpening(bool value) - { - SetSelected(value); - } - - GuiButton* Win7DropDownComboBoxStyle::GetSubMenuHost() - { - return 0; - } - - void Win7DropDownComboBoxStyle::SetImage(Ptr value) - { - } - - void Win7DropDownComboBoxStyle::SetShortcutText(const WString& value) - { - } - - void Win7DropDownComboBoxStyle::SetCommandExecutor(controls::IComboBoxCommandExecutor* value) - { - commandExecutor=value; - } - - void Win7DropDownComboBoxStyle::OnItemSelected() - { - } - - void Win7DropDownComboBoxStyle::SetText(const WString& value) - { - text = value; - if (textVisible) - { - Win7ButtonStyle::SetText(text); - } - } - - void Win7DropDownComboBoxStyle::SetTextVisible(bool value) - { - if (textVisible != value) - { - if ((textVisible = value)) - { - Win7ButtonStyle::SetText(text); - } - else - { - Win7ButtonStyle::SetText(L""); - } - } - } - -/*********************************************************************** -Win7TextListProvider -***********************************************************************/ - - Win7TextListProvider::Win7TextListProvider() - { - } - - Win7TextListProvider::~Win7TextListProvider() - { - } - - Color Win7TextListProvider::GetTextColor() - { - return Win7GetSystemTextColor(true); - } - - controls::GuiSelectableButton::IStyleController* Win7TextListProvider::CreateItemBackground() - { - return nullptr; - } - - controls::GuiSelectableButton::IStyleController* Win7TextListProvider::CreateCheckBulletStyle() - { - return nullptr; - } - - controls::GuiSelectableButton::IStyleController* Win7TextListProvider::CreateRadioBulletStyle() - { - return nullptr; - } - -/*********************************************************************** -Win7ListViewProvider -***********************************************************************/ - - Win7ListViewProvider::Win7ListViewProvider() - { - } - - Win7ListViewProvider::~Win7ListViewProvider() - { - } - - controls::GuiSelectableButton::IStyleController* Win7ListViewProvider::CreateItemBackground() - { - return nullptr; - } - - controls::GuiListViewColumnHeader::IStyleController* Win7ListViewProvider::CreateColumnStyle() - { - return new Win7ListViewColumnHeaderStyle; - } - - Color Win7ListViewProvider::GetPrimaryTextColor() - { - return Win7GetSystemTextColor(true); - } - - Color Win7ListViewProvider::GetSecondaryTextColor() - { - return Win7GetSystemTextColor(false); - } - - Color Win7ListViewProvider::GetItemSeparatorColor() - { - return Color(220, 220, 220); - } - -/*********************************************************************** -Win7TreeViewProvider -***********************************************************************/ - - Win7TreeViewProvider::Win7TreeViewProvider() - { - } - - Win7TreeViewProvider::~Win7TreeViewProvider() - { - } - - controls::GuiSelectableButton::IStyleController* Win7TreeViewProvider::CreateItemBackground() - { - return nullptr; - } - - controls::GuiSelectableButton::IStyleController* Win7TreeViewProvider::CreateItemExpandingDecorator() - { - return nullptr; - } - - Color Win7TreeViewProvider::GetTextColor() - { - return Win7GetSystemTextColor(true); - } - } - } -} - -/*********************************************************************** -CONTROLS\STYLES\WIN7STYLES\GUIWIN7MENUSTYLES.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace win7 - { - using namespace collections; - using namespace elements; - using namespace compositions; - using namespace controls; - -/*********************************************************************** -Win7MenuStyle -***********************************************************************/ - - Win7MenuStyle::Win7MenuStyle() - { - { - GuiSolidBorderElement* element=GuiSolidBorderElement::Create(); - element->SetColor(Color(151, 151, 151)); - boundsComposition=new GuiBoundsComposition; - boundsComposition->SetOwnedElement(element); - } - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Color(245, 245, 245)); - GuiBoundsComposition* subBorder=new GuiBoundsComposition; - subBorder->SetOwnedElement(element); - subBorder->SetAlignmentToParent(Margin(1, 1, 1, 1)); - boundsComposition->AddChild(subBorder); - } - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Win7GetSystemWindowColor()); - containerComposition=new GuiBoundsComposition; - containerComposition->SetOwnedElement(element); - containerComposition->SetAlignmentToParent(Margin(3, 3, 3, 3)); - containerComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - boundsComposition->AddChild(containerComposition); - } - } - - Win7MenuStyle::~Win7MenuStyle() - { - } - - compositions::GuiBoundsComposition* Win7MenuStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win7MenuStyle::GetContainerComposition() - { - return containerComposition; - } - - void Win7MenuStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win7MenuStyle::SetText(const WString& value) - { - } - - void Win7MenuStyle::SetFont(const FontProperties& value) - { - } - - void Win7MenuStyle::SetVisuallyEnabled(bool value) - { - } - -/*********************************************************************** -Win7MenuBarStyle -***********************************************************************/ - - Win7MenuBarStyle::Win7MenuBarStyle() - { - GuiTableComposition* table=new GuiTableComposition; - table->SetAlignmentToParent(Margin(0, 0, 0, 1)); - table->SetRowsAndColumns(2, 1); - table->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); - table->SetRowOption(1, GuiCellOption::PercentageOption(0.5)); - table->SetColumnOption(0, GuiCellOption::PercentageOption(1.0)); - { - GuiGradientBackgroundElement* gradient=GuiGradientBackgroundElement::Create(); - gradient->SetDirection(GuiGradientBackgroundElement::Vertical); - gradient->SetColors(Color(252, 253, 254), Color(229, 234, 245)); - - GuiCellComposition* cell=new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 0, 1, 1); - cell->SetOwnedElement(gradient); - } - { - GuiGradientBackgroundElement* gradient=GuiGradientBackgroundElement::Create(); - gradient->SetDirection(GuiGradientBackgroundElement::Vertical); - gradient->SetColors(Color(212, 219, 237), Color(225, 230, 246)); - - GuiCellComposition* cell=new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(1, 0, 1, 1); - cell->SetOwnedElement(gradient); - } - - boundsComposition=new GuiBoundsComposition; - { - GuiSolidBackgroundElement* solid=GuiSolidBackgroundElement::Create(); - solid->SetColor(Color(182, 188, 204)); - boundsComposition->SetOwnedElement(solid); - boundsComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - } - boundsComposition->AddChild(table); - } - - Win7MenuBarStyle::~Win7MenuBarStyle() - { - } - - compositions::GuiBoundsComposition* Win7MenuBarStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win7MenuBarStyle::GetContainerComposition() - { - return boundsComposition; - } - - void Win7MenuBarStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win7MenuBarStyle::SetText(const WString& value) - { - } - - void Win7MenuBarStyle::SetFont(const FontProperties& value) - { - } - - void Win7MenuBarStyle::SetVisuallyEnabled(bool value) - { - } - -/*********************************************************************** -Win7MenuBarButtonStyle -***********************************************************************/ - - void Win7MenuBarButtonStyle::TransferInternal(ButtonState value, bool enabled, bool opening) - { - Win7ButtonColors targetColor; - if(!enabled) - { - targetColor=Win7ButtonColors::MenuBarButtonDisabled(); - targetColor.SetAlphaWithoutText(0); - } - else if(opening) - { - targetColor=Win7ButtonColors::MenuBarButtonPressed(); - } - else - { - switch(value) - { - case ButtonState::Normal: - targetColor=Win7ButtonColors::MenuBarButtonNormal(); - targetColor.SetAlphaWithoutText(0); - break; - case ButtonState::Active: - targetColor=Win7ButtonColors::MenuBarButtonActive(); - break; - case ButtonState::Pressed: - targetColor=Win7ButtonColors::MenuBarButtonPressed(); - break; - } - } - elements.Apply(targetColor); - } - - Win7MenuBarButtonStyle::Win7MenuBarButtonStyle() - :controlStyle(ButtonState::Normal) - ,isVisuallyEnabled(true) - ,isOpening(false) - { - Win7ButtonColors initialColor=Win7ButtonColors::MenuBarButtonNormal(); - initialColor.SetAlphaWithoutText(0); - - elements=Win7ButtonElements::Create(true, true, Alignment::Center, Alignment::Center); - elements.Apply(initialColor); - } - - Win7MenuBarButtonStyle::~Win7MenuBarButtonStyle() - { - } - - compositions::GuiBoundsComposition* Win7MenuBarButtonStyle::GetBoundsComposition() - { - return elements.mainComposition; - } - - compositions::GuiGraphicsComposition* Win7MenuBarButtonStyle::GetContainerComposition() - { - return elements.mainComposition; - } - - void Win7MenuBarButtonStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win7MenuBarButtonStyle::SetText(const WString& value) - { - elements.textElement->SetText(value); - } - - void Win7MenuBarButtonStyle::SetFont(const FontProperties& value) - { - Win7SetFont(elements.textElement, elements.textComposition, value); - Margin margin=elements.textComposition->GetMargin(); - margin.left*=3; - margin.right*=3; - elements.textComposition->SetMargin(margin); - } - - void Win7MenuBarButtonStyle::SetVisuallyEnabled(bool value) - { - if(isVisuallyEnabled!=value) - { - isVisuallyEnabled=value; - TransferInternal(controlStyle, isVisuallyEnabled, isOpening); - } - } - - void Win7MenuBarButtonStyle::SetSelected(bool value) - { - } - - controls::GuiMenu::IStyleController* Win7MenuBarButtonStyle::CreateSubMenuStyleController() - { - return new Win7MenuStyle; - } - - void Win7MenuBarButtonStyle::SetSubMenuExisting(bool value) - { - } - - void Win7MenuBarButtonStyle::SetSubMenuOpening(bool value) - { - if(isOpening!=value) - { - isOpening=value; - TransferInternal(controlStyle, isVisuallyEnabled, isOpening); - } - } - - controls::GuiButton* Win7MenuBarButtonStyle::GetSubMenuHost() - { - return 0; - } - - void Win7MenuBarButtonStyle::SetImage(Ptr value) - { - } - - void Win7MenuBarButtonStyle::SetShortcutText(const WString& value) - { - } - - void Win7MenuBarButtonStyle::Transfer(ButtonState value) - { - if(controlStyle!=value) - { - controlStyle=value; - TransferInternal(controlStyle, isVisuallyEnabled, isOpening); - } - } - -/*********************************************************************** -Win7MenuItemButtonStyle -***********************************************************************/ - - void Win7MenuItemButtonStyle::TransferInternal(ButtonState value, bool enabled, bool selected, bool opening) - { - Win7ButtonColors targetColor; - bool active=false; - if(enabled) - { - if(opening) - { - targetColor=Win7ButtonColors::MenuItemButtonNormalActive(); - active=true; - } - else - { - switch(value) - { - case ButtonState::Normal: - targetColor=selected?Win7ButtonColors::MenuItemButtonSelected():Win7ButtonColors::MenuItemButtonNormal(); - break; - case ButtonState::Active: - case ButtonState::Pressed: - targetColor=selected?Win7ButtonColors::MenuItemButtonSelectedActive():Win7ButtonColors::MenuItemButtonNormalActive(); - active=true; - break; - } - } - } - else - { - switch(value) - { - case ButtonState::Normal: - targetColor=Win7ButtonColors::MenuItemButtonDisabled(); - break; - case ButtonState::Active: - case ButtonState::Pressed: - targetColor=Win7ButtonColors::MenuItemButtonDisabledActive(); - active=true; - break; - } - } - elements.Apply(targetColor); - elements.SetActive(active || selected); - } - - Win7MenuItemButtonStyle::Win7MenuItemButtonStyle() - :controlStyle(ButtonState::Normal) - ,isVisuallyEnabled(true) - ,isSelected(false) - ,isOpening(false) - { - elements=Win7MenuItemButtonElements::Create(); - elements.Apply(Win7ButtonColors::MenuItemButtonNormal()); - } - - Win7MenuItemButtonStyle::~Win7MenuItemButtonStyle() - { - } - - compositions::GuiBoundsComposition* Win7MenuItemButtonStyle::GetBoundsComposition() - { - return elements.mainComposition; - } - - compositions::GuiGraphicsComposition* Win7MenuItemButtonStyle::GetContainerComposition() - { - return elements.mainComposition; - } - - void Win7MenuItemButtonStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win7MenuItemButtonStyle::SetText(const WString& value) - { - elements.textElement->SetText(value); - } - - void Win7MenuItemButtonStyle::SetFont(const FontProperties& value) - { - Win7SetFont(elements.textElement, elements.textComposition, value); - Win7SetFont(elements.shortcutElement, elements.shortcutComposition, value); - } - - void Win7MenuItemButtonStyle::SetVisuallyEnabled(bool value) - { - if(isVisuallyEnabled!=value) - { - isVisuallyEnabled=value; - elements.imageElement->SetEnabled(value); - TransferInternal(controlStyle, isVisuallyEnabled, isSelected, isOpening); - } - } - - void Win7MenuItemButtonStyle::SetSelected(bool value) - { - if(isSelected!=value) - { - isSelected=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected, isOpening); - } - } - - controls::GuiMenu::IStyleController* Win7MenuItemButtonStyle::CreateSubMenuStyleController() - { - return new Win7MenuStyle; - } - - void Win7MenuItemButtonStyle::SetSubMenuExisting(bool value) - { - elements.SetSubMenuExisting(value); - } - - void Win7MenuItemButtonStyle::SetSubMenuOpening(bool value) - { - if(isOpening!=value) - { - isOpening=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected, isOpening); - } - } - - controls::GuiButton* Win7MenuItemButtonStyle::GetSubMenuHost() - { - return 0; - } - - void Win7MenuItemButtonStyle::SetImage(Ptr value) - { - if(value) - { - elements.imageElement->SetImage(value->GetImage(), value->GetFrameIndex()); - } - else - { - elements.imageElement->SetImage(0, 0); - } - } - - void Win7MenuItemButtonStyle::SetShortcutText(const WString& value) - { - elements.shortcutElement->SetText(value); - } - - void Win7MenuItemButtonStyle::Transfer(ButtonState value) - { - if(controlStyle!=value) - { - controlStyle=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected, isOpening); - } - } - -/*********************************************************************** -Win7MenuSplitterStyle -***********************************************************************/ - - Win7MenuSplitterStyle::Win7MenuSplitterStyle() - { - Color dark=Win7GetSystemBorderSinkColor(); - Color bright=Win7GetSystemBorderRaiseColor(); - - GuiTableComposition* table=new GuiTableComposition; - table->SetAlignmentToParent(Margin(0, 0, 0, 0)); - table->SetRowsAndColumns(1, 3); - table->SetPreferredMinSize(Size(0, 6)); - - table->SetRowOption(0, GuiCellOption::PercentageOption(1.0)); - table->SetColumnOption(0, GuiCellOption::AbsoluteOption(26)); - table->SetColumnOption(1, GuiCellOption::AbsoluteOption(2)); - table->SetColumnOption(2, GuiCellOption::MinSizeOption()); - - { - GuiCellComposition* cell=new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 1, 1, 1); - - Gui3DSplitterElement* element=Gui3DSplitterElement::Create(); - element->SetDirection(Gui3DSplitterElement::Vertical); - element->SetColors(dark, bright); - cell->SetOwnedElement(element); - } - { - GuiCellComposition* cell=new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 2, 1, 1); - - Gui3DSplitterElement* element=Gui3DSplitterElement::Create(); - element->SetDirection(Gui3DSplitterElement::Horizontal); - element->SetColors(dark, bright); - cell->SetOwnedElement(element); - } - boundsComposition=table; - } - - Win7MenuSplitterStyle::~Win7MenuSplitterStyle() - { - } - - compositions::GuiBoundsComposition* Win7MenuSplitterStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win7MenuSplitterStyle::GetContainerComposition() - { - return boundsComposition; - } - - void Win7MenuSplitterStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win7MenuSplitterStyle::SetText(const WString& value) - { - } - - void Win7MenuSplitterStyle::SetFont(const FontProperties& value) - { - } - - void Win7MenuSplitterStyle::SetVisuallyEnabled(bool value) - { - } - } - } -} - -/*********************************************************************** -CONTROLS\STYLES\WIN7STYLES\GUIWIN7SCROLLABLESTYLES.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace win7 - { - using namespace collections; - using namespace elements; - using namespace compositions; - using namespace controls; - -/*********************************************************************** -Win7ButtonStyle -***********************************************************************/ - - void Win7ScrollArrowButtonStyle::TransferInternal(ButtonState value, bool enabled, bool selected) - { - Win7ButtonColors targetColor; - if(enabled) - { - switch(value) - { - case ButtonState::Normal: - targetColor=Win7ButtonColors::ButtonNormal(); - targetColor.SetAlphaWithoutText(0); - break; - case ButtonState::Active: - targetColor=Win7ButtonColors::ButtonActive(); - break; - case ButtonState::Pressed: - targetColor=Win7ButtonColors::ButtonPressed(); - break; - } - } - else - { - targetColor=Win7ButtonColors::ButtonDisabled(); - targetColor.SetAlphaWithoutText(0); - } - transferringAnimation->Transfer(targetColor); - } - - void Win7ScrollArrowButtonStyle::AfterApplyColors(const Win7ButtonColors& colors) - { - Win7ButtonStyleBase::AfterApplyColors(colors); - arrowElement->SetBorderColor(colors.textColor); - arrowElement->SetBackgroundColor(colors.textColor); - } - - Win7ScrollArrowButtonStyle::Win7ScrollArrowButtonStyle(common_styles::CommonScrollStyle::Direction direction, bool increaseButton) - :Win7ButtonStyleBase(direction==common_styles::CommonScrollStyle::Horizontal, true, Win7ButtonColors::ButtonNormal(), Alignment::Center, Alignment::Center) - { - switch(direction) - { - case common_styles::CommonScrollStyle::Horizontal: - if(increaseButton) - { - GetContainerComposition()->AddChild(common_styles::CommonFragmentBuilder::BuildRightArrow(arrowElement)); - } - else - { - GetContainerComposition()->AddChild(common_styles::CommonFragmentBuilder::BuildLeftArrow(arrowElement)); - } - break; - case common_styles::CommonScrollStyle::Vertical: - if(increaseButton) - { - GetContainerComposition()->AddChild(common_styles::CommonFragmentBuilder::BuildDownArrow(arrowElement)); - } - else - { - GetContainerComposition()->AddChild(common_styles::CommonFragmentBuilder::BuildUpArrow(arrowElement)); - } - break; - } - } - - Win7ScrollArrowButtonStyle::~Win7ScrollArrowButtonStyle() - { - } - -/*********************************************************************** -Win7ScrollStyle -***********************************************************************/ - - controls::GuiButton::IStyleController* Win7ScrollStyle::CreateDecreaseButtonStyle(Direction direction) - { - Win7ScrollArrowButtonStyle* decreaseButtonStyle=new Win7ScrollArrowButtonStyle(direction, false); - return decreaseButtonStyle; - } - - controls::GuiButton::IStyleController* Win7ScrollStyle::CreateIncreaseButtonStyle(Direction direction) - { - Win7ScrollArrowButtonStyle* increaseButtonStyle=new Win7ScrollArrowButtonStyle(direction, true); - return increaseButtonStyle; - } - - controls::GuiButton::IStyleController* Win7ScrollStyle::CreateHandleButtonStyle(Direction direction) - { - Win7ButtonStyle* handleButtonStyle=new Win7ButtonStyle(direction==Horizontal); - handleButtonStyle->SetTransparentWhenDisabled(true); - return handleButtonStyle; - } - - compositions::GuiBoundsComposition* Win7ScrollStyle::InstallBackground(compositions::GuiBoundsComposition* boundsComposition, Direction direction) - { - Color sinkColor=Win7GetSystemBorderSinkColor(); - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Win7GetSystemWindowColor()); - boundsComposition->SetOwnedElement(element); - - { - GuiSideAlignedComposition* composition=new GuiSideAlignedComposition; - composition->SetMaxLength(DefaultSize); - composition->SetMaxRatio(0.2); - boundsComposition->AddChild(composition); - - GuiGradientBackgroundElement* gradient=GuiGradientBackgroundElement::Create(); - gradient->SetColors(sinkColor, Win7GetSystemWindowColor()); - composition->SetOwnedElement(gradient); - - switch(direction) - { - case Horizontal: - composition->SetDirection(GuiSideAlignedComposition::Top); - gradient->SetDirection(GuiGradientBackgroundElement::Vertical); - break; - case Vertical: - composition->SetDirection(GuiSideAlignedComposition::Left); - gradient->SetDirection(GuiGradientBackgroundElement::Horizontal); - break; - } - } - { - GuiSideAlignedComposition* composition=new GuiSideAlignedComposition; - composition->SetMaxLength(DefaultSize); - composition->SetMaxRatio(0.2); - boundsComposition->AddChild(composition); - - GuiGradientBackgroundElement* gradient=GuiGradientBackgroundElement::Create(); - gradient->SetColors(Win7GetSystemWindowColor(), sinkColor); - composition->SetOwnedElement(gradient); - - switch(direction) - { - case Horizontal: - composition->SetDirection(GuiSideAlignedComposition::Bottom); - gradient->SetDirection(GuiGradientBackgroundElement::Vertical); - break; - case Vertical: - composition->SetDirection(GuiSideAlignedComposition::Right); - gradient->SetDirection(GuiGradientBackgroundElement::Horizontal); - break; - } - } - { - GuiSolidBorderElement* element=GuiSolidBorderElement::Create(); - element->SetColor(sinkColor); - - GuiBoundsComposition* composition=new GuiBoundsComposition; - composition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - composition->SetOwnedElement(element); - boundsComposition->AddChild(composition); - } - - return boundsComposition; - } - - Win7ScrollStyle::Win7ScrollStyle(Direction _direction) - :CommonScrollStyle(_direction) - { - BuildStyle(DefaultSize, ArrowSize); - } - - Win7ScrollStyle::~Win7ScrollStyle() - { - } - -/*********************************************************************** -Win7TrackStyle -***********************************************************************/ - - controls::GuiButton::IStyleController* Win7TrackStyle::CreateHandleButtonStyle(Direction direction) - { - Win7ButtonStyle* handleButtonStyle=new Win7ButtonStyle(direction==Horizontal); - return handleButtonStyle; - } - - void Win7TrackStyle::InstallBackground(compositions::GuiGraphicsComposition* boundsComposition, Direction direction) - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Win7GetSystemWindowColor()); - boundsComposition->SetOwnedElement(element); - } - - void Win7TrackStyle::InstallTrack(compositions::GuiGraphicsComposition* trackComposition, Direction direction) - { - Gui3DBorderElement* element=Gui3DBorderElement::Create(); - element->SetColors(Color(176, 176, 176), Color(252, 252, 252)); - trackComposition->SetOwnedElement(element); - } - - Win7TrackStyle::Win7TrackStyle(Direction _direction) - :CommonTrackStyle(_direction) - { - BuildStyle(TrackThickness, TrackPadding, HandleLong, HandleShort); - } - - Win7TrackStyle::~Win7TrackStyle() - { - } - -/*********************************************************************** -Win7ProgressBarStyle -***********************************************************************/ - - void Win7ProgressBarStyle::UpdateProgressBar() - { - vint max=totalSize-pageSize; - if(position<0) - { - progressComposition->SetWidthPageSize(0); - } - else if(position>=max) - { - progressComposition->SetWidthPageSize(1); - } - else - { - progressComposition->SetWidthPageSize((double)position/max); - } - } - - void Win7ProgressBarStyle::FillProgressColors(compositions::GuiGraphicsComposition* parent, Color g1, Color g2, Color g3, Color g4, Color g5) - { - { - GuiGradientBackgroundElement* element=GuiGradientBackgroundElement::Create(); - element->SetDirection(GuiGradientBackgroundElement::Vertical); - element->SetColors(g1, g2); - - GuiBoundsComposition* composition=new GuiBoundsComposition; - composition->SetAlignmentToParent(Margin(0, 0, 0, -1)); - composition->SetPreferredMinSize(Size(0, 6)); - composition->SetOwnedElement(element); - parent->AddChild(composition); - } - { - GuiGradientBackgroundElement* element=GuiGradientBackgroundElement::Create(); - element->SetDirection(GuiGradientBackgroundElement::Vertical); - element->SetColors(g3, g4); - - GuiBoundsComposition* composition=new GuiBoundsComposition; - composition->SetAlignmentToParent(Margin(0, 6, 0, 6)); - composition->SetOwnedElement(element); - parent->AddChild(composition); - } - { - GuiGradientBackgroundElement* element=GuiGradientBackgroundElement::Create(); - element->SetDirection(GuiGradientBackgroundElement::Vertical); - element->SetColors(g4, g5); - - GuiBoundsComposition* composition=new GuiBoundsComposition; - composition->SetAlignmentToParent(Margin(0, -1, 0, 0)); - composition->SetPreferredMinSize(Size(0, 6)); - composition->SetOwnedElement(element); - parent->AddChild(composition); - } - } - - Win7ProgressBarStyle::Win7ProgressBarStyle() - :totalSize(1) - ,pageSize(0) - ,position(0) - { - { - boundsComposition=new GuiBoundsComposition; - } - { - containerComposition=new GuiBoundsComposition; - containerComposition->SetAlignmentToParent(Margin(1, 1, 1, 1)); - boundsComposition->AddChild(containerComposition); - FillProgressColors(containerComposition, Color(239, 239, 239), Color(218, 218, 218), Color(201, 201, 201), Color(203, 203, 203), Color(213, 213, 213)); - } - { - GuiRoundBorderElement* element=GuiRoundBorderElement::Create(); - element->SetColor(Color(178, 178, 178)); - element->SetRadius(2); - - GuiBoundsComposition* borderComposition=new GuiBoundsComposition; - borderComposition->SetOwnedElement(element); - borderComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - boundsComposition->AddChild(borderComposition); - } - { - progressComposition=new GuiPartialViewComposition; - progressComposition->SetWidthRatio(0); - progressComposition->SetWidthPageSize(0); - progressComposition->SetHeightRatio(0); - progressComposition->SetHeightPageSize(1); - containerComposition->AddChild(progressComposition); - FillProgressColors(progressComposition, Color(205, 255, 205), Color(156, 238, 172), Color(0, 211, 40), Color(0, 213, 47), Color(74, 232, 93)); - } - } - - Win7ProgressBarStyle::~Win7ProgressBarStyle() - { - } - - compositions::GuiBoundsComposition* Win7ProgressBarStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win7ProgressBarStyle::GetContainerComposition() - { - return containerComposition; - } - - void Win7ProgressBarStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win7ProgressBarStyle::SetText(const WString& value) - { - } - - void Win7ProgressBarStyle::SetFont(const FontProperties& value) - { - } - - void Win7ProgressBarStyle::SetVisuallyEnabled(bool value) - { - } - - void Win7ProgressBarStyle::SetCommandExecutor(controls::IScrollCommandExecutor* value) - { - } - - void Win7ProgressBarStyle::SetTotalSize(vint value) - { - totalSize=value; - UpdateProgressBar(); - } - - void Win7ProgressBarStyle::SetPageSize(vint value) - { - pageSize=value; - UpdateProgressBar(); - } - - void Win7ProgressBarStyle::SetPosition(vint value) - { - position=value; - UpdateProgressBar(); - } - -/*********************************************************************** -Win7ScrollViewProvider -***********************************************************************/ - - Win7ScrollViewProvider::Win7ScrollViewProvider() - { - } - - Win7ScrollViewProvider::~Win7ScrollViewProvider() - { - } - - void Win7ScrollViewProvider::AssociateStyleController(controls::GuiControl::IStyleController* controller) - { - } - - void Win7ScrollViewProvider::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win7ScrollViewProvider::SetText(const WString& value) - { - } - - void Win7ScrollViewProvider::SetFont(const FontProperties& value) - { - } - - void Win7ScrollViewProvider::SetVisuallyEnabled(bool value) - { - } - - controls::GuiScroll::IStyleController* Win7ScrollViewProvider::CreateHorizontalScrollStyle() - { - return new Win7ScrollStyle(Win7ScrollStyle::Horizontal); - } - - controls::GuiScroll::IStyleController* Win7ScrollViewProvider::CreateVerticalScrollStyle() - { - return new Win7ScrollStyle(Win7ScrollStyle::Vertical); - } - - vint Win7ScrollViewProvider::GetDefaultScrollSize() - { - return Win7ScrollStyle::DefaultSize; - } - - compositions::GuiGraphicsComposition* Win7ScrollViewProvider::InstallBackground(compositions::GuiBoundsComposition* boundsComposition) - { - GuiSolidBorderElement* border=GuiSolidBorderElement::Create(); - border->SetColor(Win7GetSystemBorderColor()); - boundsComposition->SetOwnedElement(border); - boundsComposition->SetInternalMargin(Margin(1, 1, 1, 1)); - - GuiSolidBackgroundElement* background=GuiSolidBackgroundElement::Create(); - background->SetColor(Win7GetSystemWindowColor()); - - GuiBoundsComposition* backgroundComposition=new GuiBoundsComposition; - boundsComposition->AddChild(backgroundComposition); - backgroundComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - backgroundComposition->SetOwnedElement(background); - - return boundsComposition; - } - -/*********************************************************************** -Win7TextBoxBackground -***********************************************************************/ - -#define HOST_GETTER_BY_FOCUSABLE_COMPOSITION(STYLE) (style->focusableComposition->GetRelatedGraphicsHost()) - - IMPLEMENT_TRANSFERRING_ANIMATION_BASE(Win7TextBoxColors, Win7TextBoxBackground, HOST_GETTER_BY_FOCUSABLE_COMPOSITION) - { - colorCurrent=Win7TextBoxColors::Blend(colorBegin, colorEnd, currentPosition, totalLength); - style->Apply(colorCurrent); - } - - void Win7TextBoxBackground::UpdateStyle() - { - if(!isVisuallyEnabled) - { - transferringAnimation->Transfer(Win7TextBoxColors::Disabled()); - } - else if(isFocused) - { - transferringAnimation->Transfer(Win7TextBoxColors::Focused()); - } - else if(isMouseEnter) - { - transferringAnimation->Transfer(Win7TextBoxColors::Active()); - } - else - { - transferringAnimation->Transfer(Win7TextBoxColors::Normal()); - } - } - - void Win7TextBoxBackground::Apply(const Win7TextBoxColors& colors) - { - borderElement->SetColor(colors.borderColor); - backgroundElement->SetColor(colors.backgroundColor); - } - - void Win7TextBoxBackground::OnBoundsMouseEnter(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - isMouseEnter=true; - UpdateStyle(); - } - - void Win7TextBoxBackground::OnBoundsMouseLeave(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - isMouseEnter=false; - UpdateStyle(); - } - - void Win7TextBoxBackground::OnBoundsGotFocus(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - isFocused=true; - UpdateStyle(); - } - - void Win7TextBoxBackground::OnBoundsLostFocus(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - isFocused=false; - UpdateStyle(); - } - - Win7TextBoxBackground::Win7TextBoxBackground() - :backgroundElement(0) - ,borderElement(0) - ,focusableComposition(0) - ,isMouseEnter(false) - ,isFocused(false) - ,isVisuallyEnabled(false) - ,styleController(0) - ,textElement(0) - { - transferringAnimation=new TransferringAnimation(this, Win7TextBoxColors::Normal()); - } - - Win7TextBoxBackground::~Win7TextBoxBackground() - { - transferringAnimation->Disable(); - } - - void Win7TextBoxBackground::AssociateStyleController(controls::GuiControl::IStyleController* controller) - { - styleController=controller; - } - - void Win7TextBoxBackground::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - focusableComposition=value; - focusableComposition->GetEventReceiver()->mouseEnter.AttachMethod(this, &Win7TextBoxBackground::OnBoundsMouseEnter); - focusableComposition->GetEventReceiver()->mouseLeave.AttachMethod(this, &Win7TextBoxBackground::OnBoundsMouseLeave); - focusableComposition->GetEventReceiver()->gotFocus.AttachMethod(this, &Win7TextBoxBackground::OnBoundsGotFocus); - focusableComposition->GetEventReceiver()->lostFocus.AttachMethod(this, &Win7TextBoxBackground::OnBoundsLostFocus); - } - - void Win7TextBoxBackground::SetVisuallyEnabled(bool value) - { - isVisuallyEnabled=value; - UpdateStyle(); - } - - compositions::GuiGraphicsComposition* Win7TextBoxBackground::InstallBackground(compositions::GuiBoundsComposition* boundsComposition) - { - { - GuiSolidBackgroundElement* background=GuiSolidBackgroundElement::Create(); - background->SetColor(Color(255, 255, 255)); - - GuiBoundsComposition* backgroundComposition=new GuiBoundsComposition; - boundsComposition->AddChild(backgroundComposition); - backgroundComposition->SetAlignmentToParent(Margin(1, 1, 1, 1)); - backgroundComposition->SetOwnedElement(background); - backgroundElement=background; - } - { - GuiRoundBorderElement* border=GuiRoundBorderElement::Create(); - border->SetColor(Win7GetSystemBorderColor()); - border->SetRadius(2); - borderElement=border; - - GuiBoundsComposition* borderComposition=new GuiBoundsComposition; - boundsComposition->AddChild(borderComposition); - borderComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - borderComposition->SetOwnedElement(border); - } - Apply(Win7TextBoxColors::Normal()); - { - GuiBoundsComposition* containerComposition=new GuiBoundsComposition; - boundsComposition->AddChild(containerComposition); - containerComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - containerComposition->SetAlignmentToParent(Margin(2, 2, 2, 2)); - return containerComposition; - } - } - - void Win7TextBoxBackground::InitializeTextElement(elements::GuiColorizedTextElement* _textElement) - { - textElement=_textElement; - - Array colors; - colors.Resize(1); - { - colors[0]=Win7GetTextBoxTextColor(); - } - textElement->SetColors(colors); - textElement->SetCaretColor(Color(0, 0, 0)); - } - -/*********************************************************************** -Win7MultilineTextBoxProvider -***********************************************************************/ - - Win7MultilineTextBoxProvider::Win7MultilineTextBoxProvider() - :styleController(0) - { - } - - Win7MultilineTextBoxProvider::~Win7MultilineTextBoxProvider() - { - } - - void Win7MultilineTextBoxProvider::AssociateStyleController(controls::GuiControl::IStyleController* controller) - { - styleController=controller; - background.AssociateStyleController(controller); - } - - void Win7MultilineTextBoxProvider::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - background.SetFocusableComposition(value); - GuiMultilineTextBox::StyleController* textBoxController=dynamic_cast(styleController); - if(textBoxController) - { - background.InitializeTextElement(textBoxController->GetTextElement()); - } - } - - void Win7MultilineTextBoxProvider::SetVisuallyEnabled(bool value) - { - background.SetVisuallyEnabled(value); - } - - compositions::GuiGraphicsComposition* Win7MultilineTextBoxProvider::InstallBackground(compositions::GuiBoundsComposition* boundsComposition) - { - return background.InstallBackground(boundsComposition); - } - -/*********************************************************************** -Win7SinglelineTextBoxProvider -***********************************************************************/ - - Win7SinglelineTextBoxProvider::Win7SinglelineTextBoxProvider() - :styleController(0) - { - } - - Win7SinglelineTextBoxProvider::~Win7SinglelineTextBoxProvider() - { - } - - void Win7SinglelineTextBoxProvider::AssociateStyleController(controls::GuiControl::IStyleController* controller) - { - styleController=controller; - background.AssociateStyleController(controller); - } - - void Win7SinglelineTextBoxProvider::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - background.SetFocusableComposition(value); - GuiSinglelineTextBox::StyleController* textBoxController=dynamic_cast(styleController); - background.InitializeTextElement(textBoxController->GetTextElement()); - } - - void Win7SinglelineTextBoxProvider::SetText(const WString& value) - { - } - - void Win7SinglelineTextBoxProvider::SetFont(const FontProperties& value) - { - } - - void Win7SinglelineTextBoxProvider::SetVisuallyEnabled(bool value) - { - background.SetVisuallyEnabled(value); - } - - compositions::GuiGraphicsComposition* Win7SinglelineTextBoxProvider::InstallBackground(compositions::GuiBoundsComposition* boundsComposition) - { - return background.InstallBackground(boundsComposition); - } - -/*********************************************************************** -Win7DocumentViewerStyle -***********************************************************************/ - - Win7DocumentViewerStyle::Win7DocumentViewerStyle() - { - } - - Win7DocumentViewerStyle::~Win7DocumentViewerStyle() - { - } - - Ptr Win7DocumentViewerStyle::GetBaselineDocument() - { - return nullptr; - } - - Color Win7DocumentViewerStyle::GetCaretColor() - { - return Color(0, 0, 0); - } - -/*********************************************************************** -Win7DocumentlabelStyle -***********************************************************************/ - - Win7DocumentLabelStyle::Win7DocumentLabelStyle() - { - } - - Win7DocumentLabelStyle::~Win7DocumentLabelStyle() - { - } - - Ptr Win7DocumentLabelStyle::GetBaselineDocument() - { - return nullptr; - } - - Color Win7DocumentLabelStyle::GetCaretColor() - { - return Color(0, 0, 0); - } - -/*********************************************************************** -Win7DocumentTextBoxStyle -***********************************************************************/ - - Win7DocumentTextBoxStyle::Win7DocumentTextBoxStyle() - { - boundsComposition = new GuiBoundsComposition; - boundsComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - containerComposition = background.InstallBackground(boundsComposition); - background.AssociateStyleController(this); - } - - Win7DocumentTextBoxStyle::~Win7DocumentTextBoxStyle() - { - } - - compositions::GuiBoundsComposition* Win7DocumentTextBoxStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win7DocumentTextBoxStyle::GetContainerComposition() - { - return containerComposition; - } - - void Win7DocumentTextBoxStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - background.SetFocusableComposition(value); - } - - void Win7DocumentTextBoxStyle::SetText(const WString& value) - { - } - - void Win7DocumentTextBoxStyle::SetFont(const FontProperties& value) - { - } - - void Win7DocumentTextBoxStyle::SetVisuallyEnabled(bool value) - { - background.SetVisuallyEnabled(value); - } - - Ptr Win7DocumentTextBoxStyle::GetBaselineDocument() - { - return nullptr; - } - - Color Win7DocumentTextBoxStyle::GetCaretColor() - { - return Color(0, 0, 0); - } - } - } -} - -/*********************************************************************** -CONTROLS\STYLES\WIN7STYLES\GUIWIN7STYLESCOMMON.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace win7 - { - using namespace collections; - using namespace elements; - using namespace compositions; - using namespace controls; - -/*********************************************************************** -Win7ButtonColors -***********************************************************************/ - - void Win7ButtonColors::SetAlphaWithoutText(unsigned char a) - { - borderColor.a=a; - backgroundColor.a=a; - g1.a=a; - g2.a=a; - g3.a=a; - g4.a=a; - } - - Win7ButtonColors Win7ButtonColors::Blend(const Win7ButtonColors& c1, const Win7ButtonColors& c2, vint ratio, vint total) - { - if(ratio<0) ratio=0; - else if(ratio>total) ratio=total; - - Win7ButtonColors result; - result.borderColor=BlendColor(c1.borderColor, c2.borderColor, ratio, total); - result.backgroundColor=BlendColor(c1.backgroundColor, c2.backgroundColor, ratio, total); - result.g1=BlendColor(c1.g1, c2.g1, ratio, total); - result.g2=BlendColor(c1.g2, c2.g2, ratio, total); - result.g3=BlendColor(c1.g3, c2.g3, ratio, total); - result.g4=BlendColor(c1.g4, c2.g4, ratio, total); - result.textColor=BlendColor(c1.textColor, c2.textColor, ratio, total); - result.bulletLight=BlendColor(c1.bulletLight, c2.bulletLight, ratio, total); - result.bulletDark=BlendColor(c1.bulletDark, c2.bulletDark, ratio, total); - return result; - } - - //--------------------------------------------------------- - - Win7ButtonColors Win7ButtonColors::ButtonNormal() - { - Win7ButtonColors colors= - { - Color(122, 122, 122), - Color(251, 251, 251), - Color(250, 250, 250), - Color(235, 235, 235), - Color(221, 221, 221), - Color(207, 207, 207), - Win7GetSystemTextColor(true), - }; - return colors; - } - - Win7ButtonColors Win7ButtonColors::ButtonActive() - { - Win7ButtonColors colors= - { - Color(60, 127, 177), - Color(220, 244, 254), - Color(246, 252, 255), - Color(240, 250, 255), - Color(225, 245, 254), - Color(215, 245, 254), - Win7GetSystemTextColor(true), - }; - return colors; - } - - Win7ButtonColors Win7ButtonColors::ButtonPressed() - { - Win7ButtonColors colors= - { - Color(44, 98, 139), - Color(158, 176, 186), - Color(225, 246, 255), - Color(204, 239, 254), - Color(181, 231, 253), - Color(164, 225, 251), - Win7GetSystemTextColor(true), - }; - return colors; - } - - Win7ButtonColors Win7ButtonColors::ButtonDisabled() - { - Win7ButtonColors colors= - { - Color(173, 178, 181), - Color(252, 252, 252), - Color(244, 244, 244), - Color(244, 244, 244), - Color(244, 244, 244), - Color(244, 244, 244), - Win7GetSystemTextColor(false), - }; - return colors; - } - - //--------------------------------------------------------- - - Win7ButtonColors Win7ButtonColors::ItemNormal() - { - Win7ButtonColors colors= - { - Color(184, 214, 251, 0), - Color(252, 253, 254, 0), - Color(250, 251, 253, 0), - Color(242, 247, 253, 0), - Color(242, 247, 253, 0), - Color(235, 243, 253, 0), - Win7GetSystemTextColor(true), - }; - return colors; - } - - Win7ButtonColors Win7ButtonColors::ItemActive() - { - Win7ButtonColors colors= - { - Color(184, 214, 251), - Color(252, 253, 254), - Color(250, 251, 253), - Color(242, 247, 253), - Color(242, 247, 253), - Color(235, 243, 253), - Win7GetSystemTextColor(true), - }; - return colors; - } - - Win7ButtonColors Win7ButtonColors::ItemSelected() - { - Win7ButtonColors colors= - { - Color(118, 158, 206), - Color(235, 244, 253), - Color(220, 235, 252), - Color(208, 227, 252), - Color(208, 227, 252), - Color(193, 219, 252), - Win7GetSystemTextColor(true), - }; - return colors; - } - - Win7ButtonColors Win7ButtonColors::ItemDisabled() - { - Win7ButtonColors colors= - { - Color(184, 214, 251, 0), - Color(252, 253, 254, 0), - Color(250, 251, 253, 0), - Color(242, 247, 253, 0), - Color(242, 247, 253, 0), - Color(235, 243, 253, 0), - Win7GetSystemTextColor(false), - }; - return colors; - } - - //--------------------------------------------------------- - - Win7ButtonColors Win7ButtonColors::CheckedNormal(bool selected) - { - Win7ButtonColors colors= - { - Color(142, 143, 143), - Color(244, 244, 244), - Color(174, 179, 185), - Color(233, 233, 234), - Color(203, 207, 213), - Color(235, 235, 236), - Win7GetSystemTextColor(true), - Color(76, 97, 152), - Color(76, 97, 152), - }; - if(!selected) - { - colors.bulletLight.a=0; - colors.bulletDark.a=0; - } - return colors; - } - - Win7ButtonColors Win7ButtonColors::CheckedActive(bool selected) - { - Win7ButtonColors colors= - { - Color(85, 134, 163), - Color(222, 249, 250), - Color(121, 198, 249), - Color(207, 236, 253), - Color(177, 233, 253), - Color(231, 247, 254), - Win7GetSystemTextColor(true), - Color(4, 34, 113), - Color(4, 34, 113), - }; - if(!selected) - { - colors.bulletLight.a=0; - colors.bulletDark.a=0; - } - return colors; - } - - Win7ButtonColors Win7ButtonColors::CheckedPressed(bool selected) - { - Win7ButtonColors colors= - { - Color(44, 98, 139), - Color(194, 228, 254), - Color(94, 182, 247), - Color(193, 230, 252), - Color(157, 213, 252), - Color(224, 244, 254), - Win7GetSystemTextColor(true), - Color(63, 93, 153), - Color(63, 93, 153), - }; - if(!selected) - { - colors.bulletLight.a=0; - colors.bulletDark.a=0; - } - return colors; - } - - Win7ButtonColors Win7ButtonColors::CheckedDisabled(bool selected) - { - Win7ButtonColors colors= - { - Color(177, 177, 177), - Color(240, 240, 240), - Color(240, 240, 240), - Color(240, 240, 240), - Color(240, 240, 240), - Color(240, 240, 240), - Win7GetSystemTextColor(false), - Color(177, 177, 177), - Color(177, 177, 177), - }; - if(!selected) - { - colors.bulletLight.a=0; - colors.bulletDark.a=0; - } - return colors; - } - - //--------------------------------------------------------- - - Win7ButtonColors Win7ButtonColors::ToolstripButtonNormal() - { - Win7ButtonColors colors= - { - Win7GetSystemWindowColor(), - Win7GetSystemWindowColor(), - Win7GetSystemWindowColor(), - Win7GetSystemWindowColor(), - Win7GetSystemWindowColor(), - Win7GetSystemWindowColor(), - Win7GetSystemTextColor(true), - }; - return colors; - } - - Win7ButtonColors Win7ButtonColors::ToolstripButtonActive() - { - Win7ButtonColors colors= - { - Color(168, 168, 168), - Color(248, 248, 248), - Color(250, 250, 250), - Color(232, 232, 232), - Color(218, 218, 218), - Color(240, 240, 240), - Win7GetSystemTextColor(true), - }; - return colors; - } - - Win7ButtonColors Win7ButtonColors::ToolstripButtonPressed() - { - Win7ButtonColors colors= - { - Color(84, 84, 84), - Color(156, 156, 156), - Color(240, 240, 240), - Color(228, 228, 228), - Color(222, 222, 222), - Color(230, 230, 230), - Win7GetSystemTextColor(true), - }; - return colors; - } - - Win7ButtonColors Win7ButtonColors::ToolstripButtonSelected() - { - Win7ButtonColors colors= - { - Color(84, 84, 84), - Color(250, 250, 250), - Color(250, 250, 250), - Color(250, 250, 250), - Color(250, 250, 250), - Color(250, 250, 250), - Win7GetSystemTextColor(true), - }; - return colors; - } - - Win7ButtonColors Win7ButtonColors::ToolstripButtonDisabled() - { - Win7ButtonColors colors= - { - Win7GetSystemWindowColor(), - Win7GetSystemWindowColor(), - Win7GetSystemWindowColor(), - Win7GetSystemWindowColor(), - Win7GetSystemWindowColor(), - Win7GetSystemWindowColor(), - Win7GetSystemTextColor(false), - }; - return colors; - } - - //--------------------------------------------------------- - - Win7ButtonColors Win7ButtonColors::MenuBarButtonNormal() - { - Win7ButtonColors colors= - { - Color(176, 176, 176), - Color(234, 238, 247), - Color(246, 248, 250), - Color(211, 217, 231), - Color(199, 204, 218), - Color(224, 228, 243), - Win7GetSystemTextColor(true), - }; - return colors; - } - - Win7ButtonColors Win7ButtonColors::MenuBarButtonActive() - { - Win7ButtonColors colors= - { - Color(176, 176, 176), - Color(234, 238, 247), - Color(246, 248, 250), - Color(211, 217, 231), - Color(199, 204, 218), - Color(224, 228, 243), - Win7GetSystemTextColor(true), - }; - return colors; - } - - Win7ButtonColors Win7ButtonColors::MenuBarButtonPressed() - { - Win7ButtonColors colors= - { - Color(88, 88, 89), - Color(159, 160, 162), - Color(200, 202, 208), - Color(205, 209, 219), - Color(197, 204, 221), - Color(213, 218, 233), - Win7GetSystemTextColor(true), - }; - return colors; - } - - Win7ButtonColors Win7ButtonColors::MenuBarButtonDisabled() - { - Win7ButtonColors colors= - { - Color(176, 176, 176), - Color(234, 238, 247), - Color(246, 248, 250), - Color(211, 217, 231), - Color(199, 204, 218), - Color(224, 228, 243), - Win7GetSystemTextColor(false), - }; - return colors; - } - - //--------------------------------------------------------- - - Win7ButtonColors Win7ButtonColors::MenuItemButtonNormal() - { - Win7ButtonColors colors= - { - Color(0, 0, 0, 0), - Color(0, 0, 0, 0), - Color(0, 0, 0, 0), - Color(0, 0, 0, 0), - Color(227, 227, 227), - Color(255, 255, 255), - Win7GetSystemTextColor(true), - }; - return colors; - } - - Win7ButtonColors Win7ButtonColors::MenuItemButtonNormalActive() - { - Win7ButtonColors colors= - { - Color(175, 208, 247), - Color(248, 248, 250), - Color(243, 245, 247), - Color(231, 238, 247), - Color(229, 233, 238), - Color(245, 249, 255), - Win7GetSystemTextColor(true), - }; - return colors; - } - - Win7ButtonColors Win7ButtonColors::MenuItemButtonSelected() - { - Win7ButtonColors colors= - { - Color(175, 208, 247), - Color(248, 248, 250), - Color(0, 0, 0, 0), - Color(0, 0, 0, 0), - Color(0, 0, 0, 0), - Color(0, 0, 0, 0), - Win7GetSystemTextColor(true), - }; - return colors; - } - - Win7ButtonColors Win7ButtonColors::MenuItemButtonSelectedActive() - { - Win7ButtonColors colors= - { - Color(175, 208, 247), - Color(248, 248, 250), - Color(243, 245, 247), - Color(231, 238, 247), - Color(0, 0, 0, 0), - Color(0, 0, 0, 0), - Win7GetSystemTextColor(true), - }; - return colors; - } - - Win7ButtonColors Win7ButtonColors::MenuItemButtonDisabled() - { - Win7ButtonColors colors= - { - Color(0, 0, 0, 0), - Color(0, 0, 0, 0), - Color(0, 0, 0, 0), - Color(0, 0, 0, 0), - Color(227, 227, 227), - Color(255, 255, 255), - Win7GetSystemTextColor(false), - }; - return colors; - } - - Win7ButtonColors Win7ButtonColors::MenuItemButtonDisabledActive() - { - Win7ButtonColors colors= - { - Color(212, 212, 212), - Color(244, 244, 244), - Color(243, 243, 243), - Color(229, 229, 229), - Color(232, 232, 232), - Color(239, 239, 239), - Win7GetSystemTextColor(false), - }; - return colors; - } - - //--------------------------------------------------------- - - Win7ButtonColors Win7ButtonColors::TabPageHeaderNormal() - { - Win7ButtonColors colors= - { - Color(137, 140, 149), - Color(243, 243, 243), - Color(242, 242, 242), - Color(235, 235, 235), - Color(219, 219, 219), - Color(207, 207, 207), - Win7GetSystemTextColor(true), - }; - return colors; - } - - Win7ButtonColors Win7ButtonColors::TabPageHeaderActive() - { - Win7ButtonColors colors= - { - Color(60, 127, 177), - Color(233, 245, 252), - Color(234, 246, 253), - Color(217, 240, 252), - Color(188, 229, 252), - Color(167, 217, 245), - Win7GetSystemTextColor(true), - }; - return colors; - } - - Win7ButtonColors Win7ButtonColors::TabPageHeaderSelected() - { - Win7ButtonColors colors= - { - Color(137, 140, 149), - Win7GetSystemTabContentColor(), - Win7GetSystemTabContentColor(), - Win7GetSystemTabContentColor(), - Win7GetSystemTabContentColor(), - Win7GetSystemTabContentColor(), - Win7GetSystemTextColor(true), - }; - return colors; - } - -/*********************************************************************** -Win7ButtonElements -***********************************************************************/ - - Win7ButtonElements Win7ButtonElements::Create(bool verticalGradient, bool roundBorder, Alignment horizontal, Alignment vertical) - { - Win7ButtonElements button; - button.rectBorderElement=0; - button.roundBorderElement=0; - { - button.mainComposition=new GuiBoundsComposition; - button.mainComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - } - if(roundBorder) - { - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - button.backgroundElement=element; - - GuiBoundsComposition* composition=new GuiBoundsComposition; - button.backgroundComposition=composition; - button.mainComposition->AddChild(composition); - composition->SetAlignmentToParent(Margin(1, 1, 1, 1)); - composition->SetOwnedElement(element); - } - { - GuiRoundBorderElement* element=GuiRoundBorderElement::Create(); - button.roundBorderElement=element; - element->SetRadius(2); - - GuiBoundsComposition* composition=new GuiBoundsComposition; - button.mainComposition->AddChild(composition); - composition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - composition->SetOwnedElement(element); - } - } - else - { - { - GuiSolidBorderElement* element=GuiSolidBorderElement::Create(); - button.rectBorderElement=element; - - GuiBoundsComposition* composition=new GuiBoundsComposition; - button.mainComposition->AddChild(composition); - composition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - composition->SetOwnedElement(element); - } - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - button.backgroundElement=element; - - GuiBoundsComposition* composition=new GuiBoundsComposition; - button.backgroundComposition=composition; - button.mainComposition->AddChild(composition); - composition->SetAlignmentToParent(Margin(1, 1, 1, 1)); - composition->SetOwnedElement(element); - } - } - { - GuiTableComposition* table=new GuiTableComposition; - button.gradientComposition=table; - table->SetAlignmentToParent(Margin(2, 2, 2, 2)); - button.mainComposition->AddChild(table); - if(verticalGradient) - { - table->SetRowsAndColumns(2, 1); - table->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); - table->SetRowOption(1, GuiCellOption::PercentageOption(0.5)); - table->SetColumnOption(0, GuiCellOption::PercentageOption(1.0)); - } - else - { - table->SetRowsAndColumns(1, 2); - table->SetRowOption(0, GuiCellOption::PercentageOption(1.0)); - table->SetColumnOption(0, GuiCellOption::PercentageOption(0.5)); - table->SetColumnOption(1, GuiCellOption::PercentageOption(0.5)); - } - { - GuiGradientBackgroundElement* element=GuiGradientBackgroundElement::Create(); - button.topGradientElement=element; - element->SetDirection(verticalGradient?GuiGradientBackgroundElement::Vertical:GuiGradientBackgroundElement::Horizontal); - - GuiCellComposition* cell=new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 0, 1, 1); - cell->SetOwnedElement(element); - } - { - GuiGradientBackgroundElement* element=GuiGradientBackgroundElement::Create(); - button.bottomGradientElement=element; - element->SetDirection(verticalGradient?GuiGradientBackgroundElement::Vertical:GuiGradientBackgroundElement::Horizontal); - - GuiCellComposition* cell=new GuiCellComposition; - table->AddChild(cell); - if(verticalGradient) - { - cell->SetSite(1, 0, 1, 1); - } - else - { - cell->SetSite(0, 1, 1, 1); - } - cell->SetOwnedElement(element); - } - } - { - Win7CreateSolidLabelElement(button.textElement, button.textComposition, horizontal, vertical); - button.mainComposition->AddChild(button.textComposition); - } - return button; - } - - void Win7ButtonElements::Apply(const Win7ButtonColors& colors) - { - if(rectBorderElement) - { - rectBorderElement->SetColor(colors.borderColor); - } - if(roundBorderElement) - { - roundBorderElement->SetColor(colors.borderColor); - } - backgroundElement->SetColor(colors.backgroundColor); - topGradientElement->SetColors(colors.g1, colors.g2); - bottomGradientElement->SetColors(colors.g3, colors.g4); - textElement->SetColor(colors.textColor); - } - -/*********************************************************************** -Win7CheckedButtonElements -***********************************************************************/ - - Win7CheckedButtonElements Win7CheckedButtonElements::Create(elements::ElementShape shape, bool backgroundVisible) - { - const vint checkSize=13; - const vint checkPadding=2; - - Win7CheckedButtonElements button; - { - button.mainComposition=new GuiBoundsComposition; - button.mainComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - } - { - GuiTableComposition* mainTable=new GuiTableComposition; - button.mainComposition->AddChild(mainTable); - if(backgroundVisible) - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Win7GetSystemWindowColor()); - mainTable->SetOwnedElement(element); - } - mainTable->SetRowsAndColumns(1, 2); - mainTable->SetAlignmentToParent(Margin(0, 0, 0, 0)); - mainTable->SetRowOption(0, GuiCellOption::PercentageOption(1.0)); - mainTable->SetColumnOption(0, GuiCellOption::AbsoluteOption(checkSize+2*checkPadding)); - mainTable->SetColumnOption(1, GuiCellOption::PercentageOption(1.0)); - - { - GuiCellComposition* cell=new GuiCellComposition; - mainTable->AddChild(cell); - cell->SetSite(0, 0, 1, 1); - - GuiTableComposition* table=new GuiTableComposition; - cell->AddChild(table); - table->SetRowsAndColumns(3, 1); - table->SetAlignmentToParent(Margin(0, 0, 0, 0)); - table->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); - table->SetRowOption(1, GuiCellOption::MinSizeOption()); - table->SetRowOption(2, GuiCellOption::PercentageOption(0.5)); - - { - GuiCellComposition* checkCell=new GuiCellComposition; - table->AddChild(checkCell); - checkCell->SetSite(1, 0, 1, 1); - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - button.backgroundElement=element; - element->SetShape(shape); - - GuiBoundsComposition* borderBounds=new GuiBoundsComposition; - checkCell->AddChild(borderBounds); - borderBounds->SetOwnedElement(element); - borderBounds->SetAlignmentToParent(Margin(checkPadding, -1, checkPadding, -1)); - borderBounds->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - { - GuiSolidBorderElement* element=GuiSolidBorderElement::Create(); - button.borderElement=element; - element->SetShape(shape); - - GuiBoundsComposition* bounds=new GuiBoundsComposition; - borderBounds->AddChild(bounds); - bounds->SetOwnedElement(element); - bounds->SetAlignmentToParent(Margin(0, 0, 0, 0)); - bounds->SetBounds(Rect(Point(0, 0), Size(checkSize, checkSize))); - } - { - GuiGradientBackgroundElement* element=GuiGradientBackgroundElement::Create(); - button.outerGradientElement=element; - element->SetShape(shape); - element->SetDirection(GuiGradientBackgroundElement::Backslash); - - GuiBoundsComposition* bounds=new GuiBoundsComposition; - borderBounds->AddChild(bounds); - bounds->SetOwnedElement(element); - bounds->SetAlignmentToParent(Margin(2, 2, 2, 2)); - } - { - GuiGradientBackgroundElement* element=GuiGradientBackgroundElement::Create(); - button.innerGradientElement=element; - element->SetDirection(GuiGradientBackgroundElement::Backslash); - element->SetShape(shape); - - GuiBoundsComposition* bounds=new GuiBoundsComposition; - borderBounds->AddChild(bounds); - bounds->SetOwnedElement(element); - bounds->SetAlignmentToParent(Margin(3, 3, 3, 3)); - } - } - - button.bulletCheckElement=0; - button.bulletRadioElement=0; - if(shape==ElementShape::Rectangle) - { - button.bulletCheckElement=GuiSolidLabelElement::Create(); - { - FontProperties font; - font.fontFamily=L"Webdings"; - font.size=16; - font.bold=true; - button.bulletCheckElement->SetFont(font); - } - button.bulletCheckElement->SetText(L"a"); - button.bulletCheckElement->SetAlignments(Alignment::Center, Alignment::Center); - - GuiBoundsComposition* composition=new GuiBoundsComposition; - composition->SetOwnedElement(button.bulletCheckElement); - composition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - checkCell->AddChild(composition); - } - else - { - button.bulletRadioElement=GuiSolidBackgroundElement::Create(); - button.bulletRadioElement->SetShape(ElementShape::Ellipse); - - GuiBoundsComposition* composition=new GuiBoundsComposition; - composition->SetOwnedElement(button.bulletRadioElement); - composition->SetAlignmentToParent(Margin(checkPadding+3, 3, checkPadding+3, 3)); - checkCell->AddChild(composition); - } - } - } - - { - GuiCellComposition* textCell=new GuiCellComposition; - mainTable->AddChild(textCell); - textCell->SetSite(0, 1, 1, 1); - { - Win7CreateSolidLabelElement(button.textElement, button.textComposition, Alignment::Left, Alignment::Center); - textCell->AddChild(button.textComposition); - } - } - } - return button; - } - - void Win7CheckedButtonElements::Apply(const Win7ButtonColors& colors) - { - borderElement->SetColor(colors.borderColor); - backgroundElement->SetColor(colors.backgroundColor); - outerGradientElement->SetColors(colors.g1, colors.g2); - innerGradientElement->SetColors(colors.g3, colors.g4); - textElement->SetColor(colors.textColor); - if(bulletCheckElement) - { - bulletCheckElement->SetColor(colors.bulletDark); - } - if(bulletRadioElement) - { - bulletRadioElement->SetColor(colors.bulletDark); - } - } - -/*********************************************************************** -Win7MenuItemButtonElements -***********************************************************************/ - - Win7MenuItemButtonElements Win7MenuItemButtonElements::Create() - { - Win7MenuItemButtonElements button; - { - button.mainComposition=new GuiBoundsComposition; - button.mainComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - } - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - button.backgroundElement=element; - - GuiBoundsComposition* composition=new GuiBoundsComposition; - button.mainComposition->AddChild(composition); - composition->SetAlignmentToParent(Margin(1, 1, 1, 1)); - composition->SetOwnedElement(element); - } - { - GuiRoundBorderElement* element=GuiRoundBorderElement::Create(); - button.borderElement=element; - element->SetRadius(2); - - GuiBoundsComposition* composition=new GuiBoundsComposition; - button.mainComposition->AddChild(composition); - composition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - composition->SetOwnedElement(element); - } - { - GuiGradientBackgroundElement* element=GuiGradientBackgroundElement::Create(); - button.gradientElement=element; - element->SetDirection(GuiGradientBackgroundElement::Vertical); - - GuiBoundsComposition* composition=new GuiBoundsComposition; - button.mainComposition->AddChild(composition); - composition->SetAlignmentToParent(Margin(2, 2, 2, 2)); - composition->SetOwnedElement(element); - } - { - GuiTableComposition* table=new GuiTableComposition; - button.mainComposition->AddChild(table); - table->SetAlignmentToParent(Margin(2, 0, 2, 0)); - table->SetRowsAndColumns(1, 5); - - table->SetRowOption(0, GuiCellOption::PercentageOption(1.0)); - table->SetColumnOption(0, GuiCellOption::AbsoluteOption(24)); - table->SetColumnOption(1, GuiCellOption::AbsoluteOption(2)); - table->SetColumnOption(2, GuiCellOption::PercentageOption(1.0)); - table->SetColumnOption(3, GuiCellOption::MinSizeOption()); - table->SetColumnOption(4, GuiCellOption::AbsoluteOption(10)); - - { - GuiCellComposition* cell=new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 0, 1, 1); - button.splitterComposition=cell; - - GuiImageFrameElement* element=GuiImageFrameElement::Create(); - button.imageElement=element; - element->SetStretch(false); - element->SetAlignments(Alignment::Center, Alignment::Center); - cell->SetOwnedElement(element); - } - { - GuiCellComposition* cell=new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 1, 1, 1); - button.splitterComposition=cell; - - Gui3DSplitterElement* element=Gui3DSplitterElement::Create(); - button.splitterElement=element; - element->SetDirection(Gui3DSplitterElement::Vertical); - cell->SetOwnedElement(element); - } - { - GuiCellComposition* cell=new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 2, 1, 1); - - Win7CreateSolidLabelElement(button.textElement, button.textComposition, L"MenuItem-Text", Alignment::Left, Alignment::Center); - cell->AddChild(button.textComposition); - } - { - GuiCellComposition* cell=new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 3, 1, 1); - - Win7CreateSolidLabelElement(button.shortcutElement, button.shortcutComposition, L"MenuItem-Shortcut", Alignment::Right, Alignment::Center); - cell->AddChild(button.shortcutComposition); - } - { - button.subMenuArrowElement=common_styles::CommonFragmentBuilder::BuildRightArrow(); - - GuiCellComposition* cell=new GuiCellComposition; - button.subMenuArrowComposition=cell; - cell->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - table->AddChild(cell); - cell->SetSite(0, 4, 1, 1); - cell->SetOwnedElement(button.subMenuArrowElement); - cell->SetVisible(false); - } - } - return button; - } - - void Win7MenuItemButtonElements::Apply(const Win7ButtonColors& colors) - { - borderElement->SetColor(colors.borderColor); - backgroundElement->SetColor(colors.backgroundColor); - gradientElement->SetColors(colors.g1, colors.g2); - splitterElement->SetColors(colors.g3, colors.g4); - textElement->SetColor(colors.textColor); - shortcutElement->SetColor(colors.textColor); - subMenuArrowElement->SetBackgroundColor(colors.textColor); - subMenuArrowElement->SetBorderColor(colors.textColor); - } - - void Win7MenuItemButtonElements::SetActive(bool value) - { - if(value) - { - splitterComposition->SetMargin(Margin(0, 1, 0, 2)); - } - else - { - splitterComposition->SetMargin(Margin(0, 0, 0, 0)); - } - } - - void Win7MenuItemButtonElements::SetSubMenuExisting(bool value) - { - subMenuArrowComposition->SetVisible(value); - } - -/*********************************************************************** -Win7TextBoxColors -***********************************************************************/ - - Win7TextBoxColors Win7TextBoxColors::Blend(const Win7TextBoxColors& c1, const Win7TextBoxColors& c2, vint ratio, vint total) - { - if(ratio<0) ratio=0; - else if(ratio>total) ratio=total; - - Win7TextBoxColors result; - result.borderColor=BlendColor(c1.borderColor, c2.borderColor, ratio, total); - result.backgroundColor=BlendColor(c1.backgroundColor, c2.backgroundColor, ratio, total); - return result; - } - - Win7TextBoxColors Win7TextBoxColors::Normal() - { - Win7TextBoxColors result= - { - Color(197, 197, 197), - Color(255, 255, 255), - }; - return result; - } - - Win7TextBoxColors Win7TextBoxColors::Active() - { - Win7TextBoxColors result= - { - Color(197, 218, 237), - Color(255, 255, 255), - }; - return result; - } - - Win7TextBoxColors Win7TextBoxColors::Focused() - { - Win7TextBoxColors result= - { - Color(61, 123, 173), - Color(255, 255, 255), - }; - return result; - } - - Win7TextBoxColors Win7TextBoxColors::Disabled() - { - Win7TextBoxColors result= - { - Color(175, 175, 175), - Win7GetSystemWindowColor(), - }; - return result; - } - -/*********************************************************************** -Helpers -***********************************************************************/ - - Color Win7GetSystemWindowColor() - { - return Color(240, 240, 240); - } - - Color Win7GetSystemTabContentColor() - { - return Color(255, 255, 255); - } - - Color Win7GetSystemBorderColor() - { - return Color(100, 100, 100); - } - - Color Win7GetSystemBorderSinkColor() - { - return Color(227, 227, 227); - } - - Color Win7GetSystemBorderRaiseColor() - { - return Color(255, 255, 255); - } - - Color Win7GetSystemTextColor(bool enabled) - { - return enabled?Color(0, 0, 0):Color(131, 131, 131); - } - - void Win7SetFont(GuiSolidLabelElement* element, GuiBoundsComposition* composition, const FontProperties& fontProperties) - { - vint margin=3; - element->SetFont(fontProperties); - composition->SetMargin(Margin(margin, margin, margin, margin)); - } - - void Win7CreateSolidLabelElement(GuiSolidLabelElement*& element, GuiBoundsComposition*& composition, Alignment horizontal, Alignment vertical) - { - element=GuiSolidLabelElement::Create(); - element->SetAlignments(horizontal, vertical); - - composition=new GuiBoundsComposition; - composition->SetOwnedElement(element); - composition->SetMargin(Margin(0, 0, 0, 0)); - composition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - composition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - } - - void Win7CreateSolidLabelElement(elements::GuiSolidLabelElement*& element, compositions::GuiSharedSizeItemComposition*& composition, const WString& group, Alignment horizontal, Alignment vertical) - { - element=GuiSolidLabelElement::Create(); - element->SetAlignments(horizontal, vertical); - - composition=new GuiSharedSizeItemComposition; - composition->SetGroup(group); - composition->SetSharedWidth(true); - composition->SetOwnedElement(element); - composition->SetMargin(Margin(0, 0, 0, 0)); - composition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - composition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - } - - elements::text::ColorEntry Win7GetTextBoxTextColor() - { - elements::text::ColorEntry entry; - entry.normal.text=Color(0, 0, 0); - entry.normal.background=Color(0, 0, 0, 0); - entry.selectedFocused.text=Color(255, 255, 255); - entry.selectedFocused.background=Color(51, 153, 255); - entry.selectedUnfocused.text=Color(255, 255, 255); - entry.selectedUnfocused.background=Color(51, 153, 255); - return entry; - } - } - } -} - -/*********************************************************************** -CONTROLS\STYLES\WIN7STYLES\GUIWIN7TABSTYLES.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace win7 - { - using namespace collections; - using namespace elements; - using namespace compositions; - using namespace controls; - -/*********************************************************************** -Win7TabPageHeaderStyle -***********************************************************************/ - - void Win7TabPageHeaderStyle::TransferInternal(ButtonState value, bool enabled, bool selected) - { - if(selected) - { - transferringAnimation->Transfer(Win7ButtonColors::TabPageHeaderSelected()); - } - else - { - switch(value) - { - case ButtonState::Normal: - transferringAnimation->Transfer(Win7ButtonColors::TabPageHeaderNormal()); - break; - case ButtonState::Active: - case ButtonState::Pressed: - transferringAnimation->Transfer(Win7ButtonColors::TabPageHeaderActive()); - break; - } - } - } - - Win7TabPageHeaderStyle::Win7TabPageHeaderStyle() - :Win7ButtonStyleBase(true, false, Win7ButtonColors::TabPageHeaderNormal(), Alignment::Left, Alignment::Center) - { - transferringAnimation->SetEnableAnimation(false); - { - Margin margin=elements.backgroundComposition->GetAlignmentToParent(); - margin.bottom=0; - elements.backgroundComposition->SetAlignmentToParent(margin); - } - { - Margin margin=elements.gradientComposition->GetAlignmentToParent(); - margin.bottom=0; - elements.gradientComposition->SetAlignmentToParent(margin); - } - } - - Win7TabPageHeaderStyle::~Win7TabPageHeaderStyle() - { - } - - void Win7TabPageHeaderStyle::SetFont(const FontProperties& value) - { - Win7ButtonStyleBase::SetFont(value); - Margin margin=elements.textComposition->GetMargin(); - margin.left*=2; - margin.right*=2; - elements.textComposition->SetMargin(margin); - } - -/*********************************************************************** -Win7TabStyle -***********************************************************************/ - - void Win7TabStyle::OnHeaderButtonClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if(commandExecutor) - { - vint index=headerButtons.IndexOf(dynamic_cast(sender->GetAssociatedControl())); - if(index!=-1) - { - commandExecutor->ShowTab(index); - } - } - } - - void Win7TabStyle::OnTabHeaderBoundsChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - vint height=headerOverflowButton->GetBoundsComposition()->GetBounds().Height(); - headerOverflowButton->GetBoundsComposition()->SetBounds(Rect(Point(0, 0), Size(height, 0))); - - UpdateHeaderLayout(); - } - - void Win7TabStyle::OnHeaderOverflowButtonClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - headerOverflowMenu->SetClientSize(Size(0, 0)); - headerOverflowMenu->ShowPopup(headerOverflowButton, true); - } - - void Win7TabStyle::OnHeaderOverflowMenuButtonClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - vint index=headerOverflowMenu->GetToolstripItems().IndexOf(sender->GetRelatedControl()); - commandExecutor->ShowTab(index); - } - - void Win7TabStyle::UpdateHeaderOverflowButtonVisibility() - { - if(tabHeaderComposition->IsStackItemClipped()) - { - boundsComposition->SetColumnOption(1, GuiCellOption::MinSizeOption()); - } - else - { - boundsComposition->SetColumnOption(1, GuiCellOption::AbsoluteOption(0)); - } - boundsComposition->ForceCalculateSizeImmediately(); - } - - void Win7TabStyle::UpdateHeaderZOrder() - { - vint itemCount=tabHeaderComposition->GetStackItems().Count(); - vint childCount=tabHeaderComposition->Children().Count(); - for(vint i=0;iGetStackItems().Get(i); - if(headerButtons[i]->GetSelected()) - { - tabHeaderComposition->MoveChild(item, childCount-1); - item->SetExtraMargin(Margin(2, 2, 2, 0)); - } - else - { - item->SetExtraMargin(Margin(0, 0, 0, 0)); - } - } - if(childCount>1) - { - tabHeaderComposition->MoveChild(tabContentTopLineComposition, childCount-2); - } - } - - void Win7TabStyle::UpdateHeaderVisibilityIndex() - { - vint itemCount=tabHeaderComposition->GetStackItems().Count(); - vint selectedItem=-1; - for(vint i=0;iGetSelected()) - { - selectedItem=i; - } - } - - if(selectedItem!=-1) - { - tabHeaderComposition->EnsureVisible(selectedItem); - } - } - - void Win7TabStyle::UpdateHeaderLayout() - { - UpdateHeaderZOrder(); - UpdateHeaderVisibilityIndex(); - UpdateHeaderOverflowButtonVisibility(); - } - - void Win7TabStyle::Initialize() - { - boundsComposition=new GuiTableComposition; - boundsComposition->SetRowsAndColumns(2, 2); - boundsComposition->SetRowOption(0, GuiCellOption::MinSizeOption()); - boundsComposition->SetRowOption(1, GuiCellOption::PercentageOption(1.0)); - boundsComposition->SetColumnOption(0, GuiCellOption::PercentageOption(1.0)); - boundsComposition->SetColumnOption(1, GuiCellOption::AbsoluteOption(0)); - { - GuiCellComposition* cell=new GuiCellComposition; - boundsComposition->AddChild(cell); - cell->SetSite(0, 0, 1, 1); - - tabHeaderComposition=new GuiStackComposition; - tabHeaderComposition->SetExtraMargin(Margin(2, 2, 2, 0)); - tabHeaderComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - tabHeaderComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - tabHeaderComposition->BoundsChanged.AttachMethod(this, &Win7TabStyle::OnTabHeaderBoundsChanged); - cell->AddChild(tabHeaderComposition); - } - { - GuiCellComposition* cell=new GuiCellComposition; - boundsComposition->AddChild(cell); - cell->SetSite(0, 1, 1, 1); - - headerOverflowButton=new GuiButton(CreateMenuButtonStyleController()); - headerOverflowButton->GetContainerComposition()->AddChild(common_styles::CommonFragmentBuilder::BuildDownArrow(headerOverflowArrowElement)); - headerOverflowButton->GetBoundsComposition()->SetAlignmentToParent(Margin(-1, 0, 0, 0)); - headerOverflowButton->Clicked.AttachMethod(this, &Win7TabStyle::OnHeaderOverflowButtonClicked); - cell->AddChild(headerOverflowButton->GetBoundsComposition()); - } - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(GetBorderColor()); - - tabContentTopLineComposition=new GuiBoundsComposition; - tabContentTopLineComposition->SetOwnedElement(element); - tabContentTopLineComposition->SetAlignmentToParent(Margin(0, -1, 0, 0)); - tabContentTopLineComposition->SetPreferredMinSize(Size(0, 1)); - tabHeaderComposition->AddChild(tabContentTopLineComposition); - } - { - GuiCellComposition* cell=new GuiCellComposition; - boundsComposition->AddChild(cell); - cell->SetSite(1, 0, 1, 2); - - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(GetBackgroundColor()); - - containerComposition=new GuiBoundsComposition; - containerComposition->SetOwnedElement(element); - containerComposition->SetAlignmentToParent(Margin(1, 0, 1, 1)); - containerComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - cell->AddChild(containerComposition); - - { - GuiSolidBorderElement* element=GuiSolidBorderElement::Create(); - element->SetColor(GetBorderColor()); - cell->SetOwnedElement(element); - } - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Win7GetSystemTabContentColor()); - containerComposition->SetOwnedElement(element); - } - } - - headerOverflowMenu=new GuiToolstripMenu(CreateMenuStyleController(), 0); - headerController=new GuiSelectableButton::MutexGroupController; - } - - controls::GuiSelectableButton::IStyleController* Win7TabStyle::CreateHeaderStyleController() - { - return new Win7TabPageHeaderStyle; - } - - controls::GuiButton::IStyleController* Win7TabStyle::CreateMenuButtonStyleController() - { - return new Win7ButtonStyle; - } - - controls::GuiToolstripMenu::IStyleController* Win7TabStyle::CreateMenuStyleController() - { - return new Win7MenuStyle; - } - - controls::GuiToolstripButton::IStyleController* Win7TabStyle::CreateMenuItemStyleController() - { - return new Win7MenuItemButtonStyle; - } - - Color Win7TabStyle::GetBorderColor() - { - return Win7ButtonColors::TabPageHeaderNormal().borderColor; - } - - Color Win7TabStyle::GetBackgroundColor() - { - return Win7GetSystemTabContentColor(); - } - - Win7TabStyle::Win7TabStyle(bool initialize) - :boundsComposition(0) - ,containerComposition(0) - ,tabHeaderComposition(0) - ,tabContentTopLineComposition(0) - ,commandExecutor(0) - ,headerOverflowArrowElement(0) - ,headerOverflowButton(0) - ,headerOverflowMenu(0) - { - if(initialize) - { - Initialize(); - } - } - - Win7TabStyle::~Win7TabStyle() - { - delete headerOverflowMenu; - } - - compositions::GuiBoundsComposition* Win7TabStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win7TabStyle::GetContainerComposition() - { - return containerComposition; - } - - void Win7TabStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win7TabStyle::SetText(const WString& value) - { - } - - void Win7TabStyle::SetFont(const FontProperties& value) - { - headerFont=value; - } - - void Win7TabStyle::SetVisuallyEnabled(bool value) - { - } - - void Win7TabStyle::SetCommandExecutor(controls::ITabCommandExecutor* value) - { - commandExecutor=value; - } - - void Win7TabStyle::InsertTab(vint index) - { - GuiSelectableButton* button=new GuiSelectableButton(CreateHeaderStyleController()); - button->SetAutoSelection(false); - button->SetFont(headerFont); - button->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); - button->SetGroupController(headerController.Obj()); - button->Clicked.AttachMethod(this, &Win7TabStyle::OnHeaderButtonClicked); - - GuiStackItemComposition* item=new GuiStackItemComposition; - item->AddChild(button->GetBoundsComposition()); - tabHeaderComposition->InsertStackItem(index, item); - headerButtons.Insert(index, button); - - GuiToolstripButton* menuItem=new GuiToolstripButton(CreateMenuItemStyleController()); - menuItem->Clicked.AttachMethod(this, &Win7TabStyle::OnHeaderOverflowMenuButtonClicked); - headerOverflowMenu->GetToolstripItems().Insert(index, menuItem); - - UpdateHeaderLayout(); - } - - void Win7TabStyle::SetTabText(vint index, const WString& value) - { - headerButtons[index]->SetText(value); - headerOverflowMenu->GetToolstripItems().Get(index)->SetText(value); - - UpdateHeaderLayout(); - } - - void Win7TabStyle::RemoveTab(vint index) - { - GuiStackItemComposition* item=tabHeaderComposition->GetStackItems().Get(index); - GuiSelectableButton* button=headerButtons[index]; - - tabHeaderComposition->RemoveChild(item); - item->RemoveChild(button->GetBoundsComposition()); - headerButtons.RemoveAt(index); - - headerOverflowMenu->GetToolstripItems().RemoveAt(index); - delete item; - delete button; - - UpdateHeaderLayout(); - } - - void Win7TabStyle::SetSelectedTab(vint index) - { - headerButtons[index]->SetSelected(true); - - UpdateHeaderLayout(); - } - - void Win7TabStyle::SetTabAlt(vint index, const WString& value) - { - auto button = headerButtons[index]; - button->SetAlt(value); - } - - compositions::IGuiAltAction* Win7TabStyle::GetTabAltAction(vint index) - { - return headerButtons[index]->QueryTypedService(); - } - } - } -} - -/*********************************************************************** -CONTROLS\STYLES\WIN7STYLES\GUIWIN7TOOLSTRIPSTYLES.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace win7 - { - using namespace collections; - using namespace elements; - using namespace compositions; - using namespace controls; - -/*********************************************************************** -Win7WindowStyle -***********************************************************************/ - - Win7ToolstripToolBarStyle::Win7ToolstripToolBarStyle() - :Win7EmptyStyle(Win7GetSystemWindowColor()) - { - boundsComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - } - - Win7ToolstripToolBarStyle::~Win7ToolstripToolBarStyle() - { - } - -/*********************************************************************** -Win7ToolstripButtonDropdownStyle -***********************************************************************/ - - void Win7ToolstripButtonDropdownStyle::TransferInternal(controls::ButtonState value, bool enabled) - { - splitterComposition->SetVisible(value!= ButtonState::Normal && enabled); - } - - Win7ToolstripButtonDropdownStyle::Win7ToolstripButtonDropdownStyle() - :isVisuallyEnabled(false) - ,controlState(ButtonState::Normal) - { - boundsComposition=new GuiBoundsComposition; - boundsComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - { - Gui3DSplitterElement* splitterElement=Gui3DSplitterElement::Create(); - splitterElement->SetColors(Win7GetSystemBorderSinkColor(), Win7GetSystemBorderRaiseColor()); - splitterElement->SetDirection(Gui3DSplitterElement::Vertical); - - splitterComposition=new GuiBoundsComposition; - splitterComposition->SetAlignmentToParent(Margin(0, 3, -1, 3)); - splitterComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - splitterComposition->SetOwnedElement(splitterElement); - splitterComposition->SetPreferredMinSize(Size(2, 0)); - splitterComposition->SetVisible(false); - boundsComposition->AddChild(splitterComposition); - } - { - containerComposition=new GuiBoundsComposition; - containerComposition->SetAlignmentToParent(Margin(4, 0, 4, 0)); - containerComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - boundsComposition->AddChild(containerComposition); - } - } - - Win7ToolstripButtonDropdownStyle::~Win7ToolstripButtonDropdownStyle() - { - } - - compositions::GuiBoundsComposition* Win7ToolstripButtonDropdownStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win7ToolstripButtonDropdownStyle::GetContainerComposition() - { - return containerComposition; - } - - void Win7ToolstripButtonDropdownStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win7ToolstripButtonDropdownStyle::SetText(const WString& value) - { - } - - void Win7ToolstripButtonDropdownStyle::SetFont(const FontProperties& value) - { - } - - void Win7ToolstripButtonDropdownStyle::SetVisuallyEnabled(bool value) - { - if(isVisuallyEnabled!=value) - { - isVisuallyEnabled=value; - TransferInternal(controlState, isVisuallyEnabled); - } - } - - void Win7ToolstripButtonDropdownStyle::Transfer(controls::ButtonState value) - { - if(controlState!=value) - { - controlState=value; - TransferInternal(controlState, isVisuallyEnabled); - } - } - -/*********************************************************************** -Win7ToolstripButtonStyle -***********************************************************************/ - - IMPLEMENT_TRANSFERRING_ANIMATION(Win7ButtonColors, Win7ToolstripButtonStyle) - { - colorCurrent=Win7ButtonColors::Blend(colorBegin, colorEnd, currentPosition, totalLength); - style->elements.Apply(colorCurrent); - } - - void Win7ToolstripButtonStyle::TransferInternal(ButtonState value, bool enabled, bool selected, bool menuOpening) - { - Win7ButtonColors targetColor; - if(enabled) - { - if(menuOpening) - { - value= ButtonState::Pressed; - } - switch(value) - { - case ButtonState::Normal: - targetColor=selected?Win7ButtonColors::ToolstripButtonSelected():Win7ButtonColors::ToolstripButtonNormal(); - break; - case ButtonState::Active: - targetColor=selected?Win7ButtonColors::ToolstripButtonSelected():Win7ButtonColors::ToolstripButtonActive(); - break; - case ButtonState::Pressed: - targetColor=Win7ButtonColors::ToolstripButtonPressed(); - break; - } - } - else - { - targetColor=Win7ButtonColors::ToolstripButtonDisabled(); - } - transferringAnimation->Transfer(targetColor); - } - - Win7ToolstripButtonStyle::Win7ToolstripButtonStyle(ButtonStyle _buttonStyle) - :controlStyle(ButtonState::Normal) - ,isVisuallyEnabled(true) - ,isSelected(false) - ,isOpening(false) - ,buttonStyle(_buttonStyle) - ,subMenuHost(0) - { - elements=Win7ButtonElements::Create(true, true, Alignment::Center, Alignment::Center); - elements.Apply(Win7ButtonColors::ToolstripButtonNormal()); - transferringAnimation=new TransferringAnimation(this, Win7ButtonColors::ToolstripButtonNormal()); - - elements.textComposition->SetMinSizeLimitation(GuiGraphicsComposition::NoLimit); - imageElement=GuiImageFrameElement::Create(); - imageComposition=new GuiBoundsComposition; - imageComposition->SetOwnedElement(imageElement); - imageComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - imageComposition->SetAlignmentToParent(Margin(4, 4, 4, 4)); - - if(_buttonStyle==CommandButton) - { - GetContainerComposition()->AddChild(imageComposition); - } - else - { - GuiTableComposition* table=new GuiTableComposition; - table->SetAlignmentToParent(Margin(0, 0, 0, 0)); - table->SetRowsAndColumns(1, 2); - table->SetRowOption(0, GuiCellOption::PercentageOption(1.0)); - table->SetColumnOption(0, GuiCellOption::PercentageOption(1.0)); - table->SetColumnOption(1, GuiCellOption::MinSizeOption()); - - { - GuiCellComposition* cell=new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 0, 1, 1); - - cell->AddChild(imageComposition); - } - { - GuiCellComposition* cell=new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 1, 1, 1); - GuiPolygonElement* arrow=0; - GuiBoundsComposition* arrowComposition=common_styles::CommonFragmentBuilder::BuildDownArrow(arrow); - - switch(_buttonStyle) - { - case DropdownButton: - { - arrowComposition->SetAlignmentToParent(Margin(0, 0, 4, 0)); - cell->AddChild(arrowComposition); - } - break; - case SplitButton: - { - - subMenuHost=new GuiButton(new Win7ToolstripButtonDropdownStyle); - subMenuHost->GetContainerComposition()->AddChild(arrowComposition); - subMenuHost->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); - cell->AddChild(subMenuHost->GetBoundsComposition()); - } - break; - default:; - } - } - GetContainerComposition()->AddChild(table); - } - } - - Win7ToolstripButtonStyle::~Win7ToolstripButtonStyle() - { - transferringAnimation->Disable(); - } - - compositions::GuiBoundsComposition* Win7ToolstripButtonStyle::GetBoundsComposition() - { - return elements.mainComposition; - } - - compositions::GuiGraphicsComposition* Win7ToolstripButtonStyle::GetContainerComposition() - { - return elements.mainComposition; - } - - void Win7ToolstripButtonStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win7ToolstripButtonStyle::SetText(const WString& value) - { - } - - void Win7ToolstripButtonStyle::SetFont(const FontProperties& value) - { - Win7SetFont(elements.textElement, elements.textComposition, value); - } - - void Win7ToolstripButtonStyle::SetVisuallyEnabled(bool value) - { - if(isVisuallyEnabled!=value) - { - isVisuallyEnabled=value; - imageElement->SetEnabled(value); - TransferInternal(controlStyle, isVisuallyEnabled, isSelected, isOpening); - } - } - - void Win7ToolstripButtonStyle::SetSelected(bool value) - { - if(isSelected!=value) - { - isSelected=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected, isOpening); - } - } - - controls::GuiMenu::IStyleController* Win7ToolstripButtonStyle::CreateSubMenuStyleController() - { - return new Win7MenuStyle; - } - - void Win7ToolstripButtonStyle::SetSubMenuExisting(bool value) - { - } - - void Win7ToolstripButtonStyle::SetSubMenuOpening(bool value) - { - if(isOpening!=value) - { - isOpening=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected, isOpening); - } - } - - controls::GuiButton* Win7ToolstripButtonStyle::GetSubMenuHost() - { - return subMenuHost; - } - - void Win7ToolstripButtonStyle::SetImage(Ptr value) - { - if(value) - { - imageElement->SetImage(value->GetImage(), value->GetFrameIndex()); - } - else - { - imageElement->SetImage(0, 0); - } - } - - void Win7ToolstripButtonStyle::SetShortcutText(const WString& value) - { - } - - void Win7ToolstripButtonStyle::Transfer(controls::ButtonState value) - { - if(controlStyle!=value) - { - controlStyle=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected, isOpening); - } - } - -/*********************************************************************** -Win7ToolstripSplitterStyle -***********************************************************************/ - - Win7ToolstripSplitterStyle::Win7ToolstripSplitterStyle() - { - Color dark=Win7GetSystemBorderSinkColor(); - Color bright=Win7GetSystemBorderRaiseColor(); - - GuiBoundsComposition* bounds=new GuiBoundsComposition; - bounds->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - boundsComposition=bounds; - - GuiSolidBackgroundElement* backgroundElement=GuiSolidBackgroundElement::Create(); - bounds->SetOwnedElement(backgroundElement); - backgroundElement->SetColor(Win7GetSystemWindowColor()); - - GuiBoundsComposition* splitterComposition=new GuiBoundsComposition; - bounds->AddChild(splitterComposition); - splitterComposition->SetAlignmentToParent(Margin(3, 3, 3, 3)); - - Gui3DSplitterElement* splitterElement=Gui3DSplitterElement::Create(); - splitterComposition->SetOwnedElement(splitterElement); - splitterElement->SetColors(dark, bright); - splitterElement->SetDirection(Gui3DSplitterElement::Vertical); - } - - Win7ToolstripSplitterStyle::~Win7ToolstripSplitterStyle() - { - } - - compositions::GuiBoundsComposition* Win7ToolstripSplitterStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win7ToolstripSplitterStyle::GetContainerComposition() - { - return boundsComposition; - } - - void Win7ToolstripSplitterStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win7ToolstripSplitterStyle::SetText(const WString& value) - { - } - - void Win7ToolstripSplitterStyle::SetFont(const FontProperties& value) - { - } - - void Win7ToolstripSplitterStyle::SetVisuallyEnabled(bool value) - { - } - } - } -} - -/*********************************************************************** -CONTROLS\STYLES\WIN8STYLES\GUIWIN8BUTTONSTYLES.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace win8 - { - using namespace collections; - using namespace elements; - using namespace compositions; - using namespace controls; - -/*********************************************************************** -Win8ButtonStyleBase -***********************************************************************/ - - IMPLEMENT_TRANSFERRING_ANIMATION(Win8ButtonColors, Win8ButtonStyleBase) - { - colorCurrent=Win8ButtonColors::Blend(colorBegin, colorEnd, currentPosition, totalLength); - style->elements.Apply(colorCurrent); - style->AfterApplyColors(colorCurrent); - } - - void Win8ButtonStyleBase::AfterApplyColors(const Win8ButtonColors& colors) - { - } - - Win8ButtonStyleBase::Win8ButtonStyleBase(const Win8ButtonColors& initialColor, Alignment horizontal, Alignment vertical) - :controlStyle(ButtonState::Normal) - ,isVisuallyEnabled(true) - ,isSelected(false) - ,transparentWhenInactive(false) - ,transparentWhenDisabled(false) - { - elements=Win8ButtonElements::Create(horizontal, vertical); - elements.Apply(initialColor); - transferringAnimation=new TransferringAnimation(this, initialColor); - } - - Win8ButtonStyleBase::~Win8ButtonStyleBase() - { - transferringAnimation->Disable(); - } - - compositions::GuiBoundsComposition* Win8ButtonStyleBase::GetBoundsComposition() - { - return elements.mainComposition; - } - - compositions::GuiGraphicsComposition* Win8ButtonStyleBase::GetContainerComposition() - { - return elements.mainComposition; - } - - void Win8ButtonStyleBase::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win8ButtonStyleBase::SetText(const WString& value) - { - elements.textElement->SetText(value); - } - - void Win8ButtonStyleBase::SetFont(const FontProperties& value) - { - Win8SetFont(elements.textElement, elements.textComposition, value); - } - - void Win8ButtonStyleBase::SetVisuallyEnabled(bool value) - { - if(isVisuallyEnabled!=value) - { - isVisuallyEnabled=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected); - } - } - - void Win8ButtonStyleBase::SetSelected(bool value) - { - if(isSelected!=value) - { - isSelected=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected); - } - } - - void Win8ButtonStyleBase::Transfer(ButtonState value) - { - if(controlStyle!=value) - { - controlStyle=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected); - } - } - - bool Win8ButtonStyleBase::GetTransparentWhenInactive() - { - return transparentWhenInactive; - } - - void Win8ButtonStyleBase::SetTransparentWhenInactive(bool value) - { - transparentWhenInactive=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected); - } - - bool Win8ButtonStyleBase::GetTransparentWhenDisabled() - { - return transparentWhenDisabled; - } - - void Win8ButtonStyleBase::SetTransparentWhenDisabled(bool value) - { - transparentWhenDisabled=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected); - } - - bool Win8ButtonStyleBase::GetAutoSizeForText() - { - return elements.textComposition->GetMinSizeLimitation()!=GuiGraphicsComposition::NoLimit; - } - - void Win8ButtonStyleBase::SetAutoSizeForText(bool value) - { - if(value) - { - elements.textComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - } - else - { - elements.textComposition->SetMinSizeLimitation(GuiGraphicsComposition::NoLimit); - } - } - -/*********************************************************************** -Win8ButtonStyle -***********************************************************************/ - - void Win8ButtonStyle::TransferInternal(ButtonState value, bool enabled, bool selected) - { - Win8ButtonColors targetColor; - if(enabled) - { - switch(value) - { - case ButtonState::Normal: - targetColor=Win8ButtonColors::ButtonNormal(); - if(transparentWhenInactive) - { - targetColor.SetAlphaWithoutText(0); - } - break; - case ButtonState::Active: - targetColor=Win8ButtonColors::ButtonActive(); - break; - case ButtonState::Pressed: - targetColor=Win8ButtonColors::ButtonPressed(); - break; - } - } - else - { - targetColor=Win8ButtonColors::ButtonDisabled(); - if(transparentWhenDisabled) - { - targetColor.SetAlphaWithoutText(0); - } - } - transferringAnimation->Transfer(targetColor); - } - - Win8ButtonStyle::Win8ButtonStyle() - :Win8ButtonStyleBase(Win8ButtonColors::ButtonNormal(), Alignment::Center, Alignment::Center) - { - } - - Win8ButtonStyle::~Win8ButtonStyle() - { - } - -/*********************************************************************** -Win7CheckBoxStyle -***********************************************************************/ - - IMPLEMENT_TRANSFERRING_ANIMATION(Win8ButtonColors, Win8CheckBoxStyle) - { - colorCurrent=Win8ButtonColors::Blend(colorBegin, colorEnd, currentPosition, totalLength); - style->elements.Apply(colorCurrent); - } - - void Win8CheckBoxStyle::TransferInternal(ButtonState value, bool enabled, bool selected) - { - if(enabled) - { - switch(value) - { - case ButtonState::Normal: - transferringAnimation->Transfer(Win8ButtonColors::CheckedNormal(selected)); - break; - case ButtonState::Active: - transferringAnimation->Transfer(Win8ButtonColors::CheckedActive(selected)); - break; - case ButtonState::Pressed: - transferringAnimation->Transfer(Win8ButtonColors::CheckedPressed(selected)); - break; - } - } - else - { - transferringAnimation->Transfer(Win8ButtonColors::CheckedDisabled(selected)); - } - } - - Win8CheckBoxStyle::Win8CheckBoxStyle(BulletStyle bulletStyle, bool backgroundVisible) - :controlStyle(ButtonState::Normal) - ,isVisuallyEnabled(true) - ,isSelected(false) - { - Win8ButtonColors initialColor=Win8ButtonColors::CheckedNormal(isSelected); - elements=Win8CheckedButtonElements::Create(bulletStyle==CheckBox?ElementShape::Rectangle:ElementShape::Ellipse, backgroundVisible); - elements.Apply(initialColor); - transferringAnimation=new TransferringAnimation(this, initialColor); - } - - Win8CheckBoxStyle::~Win8CheckBoxStyle() - { - transferringAnimation->Disable(); - } - - compositions::GuiBoundsComposition* Win8CheckBoxStyle::GetBoundsComposition() - { - return elements.mainComposition; - } - - compositions::GuiGraphicsComposition* Win8CheckBoxStyle::GetContainerComposition() - { - return elements.mainComposition; - } - - void Win8CheckBoxStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win8CheckBoxStyle::SetText(const WString& value) - { - elements.textElement->SetText(value); - } - - void Win8CheckBoxStyle::SetFont(const FontProperties& value) - { - Win8SetFont(elements.textElement, elements.textComposition, value); - } - - void Win8CheckBoxStyle::SetVisuallyEnabled(bool value) - { - if(isVisuallyEnabled!=value) - { - isVisuallyEnabled=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected); - } - } - - void Win8CheckBoxStyle::SetSelected(bool value) - { - if(isSelected!=value) - { - isSelected=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected); - } - } - - void Win8CheckBoxStyle::Transfer(ButtonState value) - { - if(controlStyle!=value) - { - controlStyle=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected); - } - } - } - } -} - -/*********************************************************************** -CONTROLS\STYLES\WIN8STYLES\GUIWIN8CONTROLSTYLES.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace win8 - { - using namespace collections; - using namespace elements; - using namespace compositions; - using namespace controls; - -/*********************************************************************** -Win8EmptyStyle -***********************************************************************/ - - Win8EmptyStyle::Win8EmptyStyle(Color color) - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(color); - - boundsComposition=new GuiBoundsComposition; - boundsComposition->SetOwnedElement(element); - } - - Win8EmptyStyle::~Win8EmptyStyle() - { - } - - compositions::GuiBoundsComposition* Win8EmptyStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win8EmptyStyle::GetContainerComposition() - { - return boundsComposition; - } - - void Win8EmptyStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win8EmptyStyle::SetText(const WString& value) - { - } - - void Win8EmptyStyle::SetFont(const FontProperties& value) - { - } - - void Win8EmptyStyle::SetVisuallyEnabled(bool value) - { - } - -/*********************************************************************** -Win8WindowStyle -***********************************************************************/ - - Win8WindowStyle::Win8WindowStyle() - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Win8GetSystemWindowColor()); - - boundsComposition=new GuiBoundsComposition; - boundsComposition->SetOwnedElement(element); - } - - Win8WindowStyle::~Win8WindowStyle() - { - } - - compositions::GuiBoundsComposition* Win8WindowStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win8WindowStyle::GetContainerComposition() - { - return boundsComposition; - } - - void Win8WindowStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win8WindowStyle::SetText(const WString& value) - { - } - - void Win8WindowStyle::SetFont(const FontProperties& value) - { - } - - void Win8WindowStyle::SetVisuallyEnabled(bool value) - { - } - -/*********************************************************************** -Win8TooltipStyle -***********************************************************************/ - - Win8TooltipStyle::Win8TooltipStyle() - { - boundsComposition=new GuiBoundsComposition; - boundsComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - boundsComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - { - GuiSolidBorderElement* element=GuiSolidBorderElement::Create(); - element->SetColor(Color(100, 100, 100)); - boundsComposition->SetOwnedElement(element); - } - - containerComposition=new GuiBoundsComposition; - containerComposition->SetAlignmentToParent(Margin(1, 1, 1, 1)); - containerComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - boundsComposition->AddChild(containerComposition); - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Color(255, 255, 225)); - containerComposition->SetOwnedElement(element); - } - } - - Win8TooltipStyle::~Win8TooltipStyle() - { - } - - compositions::GuiBoundsComposition* Win8TooltipStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win8TooltipStyle::GetContainerComposition() - { - return containerComposition; - } - - void Win8TooltipStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win8TooltipStyle::SetText(const WString& value) - { - } - - void Win8TooltipStyle::SetFont(const FontProperties& value) - { - } - - void Win8TooltipStyle::SetVisuallyEnabled(bool value) - { - } - -/*********************************************************************** -Win8LabelStyle -***********************************************************************/ - - Win8LabelStyle::Win8LabelStyle(bool forShortcutKey) - { - textElement=GuiSolidLabelElement::Create(); - textElement->SetColor(GetDefaultTextColor()); - - boundsComposition=new GuiBoundsComposition; - boundsComposition->SetMinSizeLimitation(GuiBoundsComposition::LimitToElementAndChildren); - if (forShortcutKey) - { - { - GuiSolidBorderElement* element=GuiSolidBorderElement::Create(); - element->SetColor(Color(100, 100, 100)); - boundsComposition->SetOwnedElement(element); - } - - auto containerComposition=new GuiBoundsComposition; - containerComposition->SetAlignmentToParent(Margin(1, 1, 1, 1)); - containerComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - boundsComposition->AddChild(containerComposition); - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Color(255, 255, 225)); - containerComposition->SetOwnedElement(element); - } - - auto labelComposition = new GuiBoundsComposition; - labelComposition->SetAlignmentToParent(Margin(2, 2, 2, 2)); - labelComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - labelComposition->SetOwnedElement(textElement); - containerComposition->AddChild(labelComposition); - } - else - { - boundsComposition->SetOwnedElement(textElement); - } - } - - Win8LabelStyle::~Win8LabelStyle() - { - } - - compositions::GuiBoundsComposition* Win8LabelStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win8LabelStyle::GetContainerComposition() - { - return boundsComposition; - } - - void Win8LabelStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win8LabelStyle::SetText(const WString& value) - { - textElement->SetText(value); - } - - void Win8LabelStyle::SetFont(const FontProperties& value) - { - textElement->SetFont(value); - } - - void Win8LabelStyle::SetVisuallyEnabled(bool value) - { - } - - Color Win8LabelStyle::GetDefaultTextColor() - { - return Win8GetSystemTextColor(true); - } - - void Win8LabelStyle::SetTextColor(Color value) - { - textElement->SetColor(value); - } - -/*********************************************************************** -Win8GroupBoxStyle -***********************************************************************/ - - IMPLEMENT_TRANSFERRING_ANIMATION(Color, Win8GroupBoxStyle) - { - colorCurrent=BlendColor(colorBegin, colorEnd, currentPosition, totalLength); - style->textElement->SetColor(colorCurrent); - } - - void Win8GroupBoxStyle::SetMargins(vint fontSize) - { - fontSize+=4; - vint half=fontSize/2; - borderComposition->SetAlignmentToParent(Margin(0, half, 0, 0)); - containerComposition->SetAlignmentToParent(Margin(1, fontSize, 1, 1)); - textBackgroundComposition->SetAlignmentToParent(Margin(half, 2, -1, -1)); - } - - Win8GroupBoxStyle::Win8GroupBoxStyle() - { - boundsComposition=new GuiBoundsComposition; - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Win8GetSystemWindowColor()); - - boundsComposition->SetOwnedElement(element); - boundsComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - } - - borderComposition=new GuiBoundsComposition; - { - GuiSolidBorderElement* element=GuiSolidBorderElement::Create(); - element->SetColor(Color(221, 221, 221)); - - borderComposition->SetOwnedElement(element); - boundsComposition->AddChild(borderComposition); - } - - textBackgroundComposition=new GuiBoundsComposition; - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Win8GetSystemWindowColor()); - - textBackgroundComposition->SetOwnedElement(element); - textBackgroundComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - boundsComposition->AddChild(textBackgroundComposition); - } - - textComposition=new GuiBoundsComposition; - { - GuiSolidLabelElement* element=GuiSolidLabelElement::Create(); - element->SetColor(Win8GetSystemTextColor(true)); - textElement=element; - - textComposition->SetOwnedElement(element); - textComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - textComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - textBackgroundComposition->AddChild(textComposition); - } - - containerComposition=new GuiBoundsComposition; - { - boundsComposition->AddChild(containerComposition); - } - - SetMargins(0); - transferringAnimation=new TransferringAnimation(this, Win8GetSystemTextColor(true)); - } - - Win8GroupBoxStyle::~Win8GroupBoxStyle() - { - transferringAnimation->Disable(); - } - - compositions::GuiBoundsComposition* Win8GroupBoxStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win8GroupBoxStyle::GetContainerComposition() - { - return containerComposition; - } - - void Win8GroupBoxStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win8GroupBoxStyle::SetText(const WString& value) - { - textElement->SetText(value); - } - - void Win8GroupBoxStyle::SetFont(const FontProperties& value) - { - textElement->SetFont(value); - SetMargins(value.size); - } - - void Win8GroupBoxStyle::SetVisuallyEnabled(bool value) - { - if(value) - { - transferringAnimation->Transfer(Win8GetSystemTextColor(true)); - } - else - { - transferringAnimation->Transfer(Win8GetSystemTextColor(false)); - } - } - -/*********************************************************************** -Win8DatePickerStyle -***********************************************************************/ - - Win8DatePickerStyle::Win8DatePickerStyle() - { - } - - Win8DatePickerStyle::~Win8DatePickerStyle() - { - } - - void Win8DatePickerStyle::AssociateStyleController(controls::GuiControl::IStyleController* controller) - { - } - - void Win8DatePickerStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win8DatePickerStyle::SetText(const WString& value) - { - } - - void Win8DatePickerStyle::SetFont(const FontProperties& value) - { - } - - void Win8DatePickerStyle::SetVisuallyEnabled(bool value) - { - } - - controls::GuiSelectableButton::IStyleController* Win8DatePickerStyle::CreateDateButtonStyle() - { - return new Win8SelectableItemStyle; - } - - controls::GuiTextList* Win8DatePickerStyle::CreateTextList() - { - return new GuiTextList(new Win8TextListProvider); - } - - controls::GuiComboBoxListControl::IStyleController* Win8DatePickerStyle::CreateComboBoxStyle() - { - return new Win8DropDownComboBoxStyle; - } - - Color Win8DatePickerStyle::GetBackgroundColor() - { - return Win8GetSystemWindowColor(); - } - - Color Win8DatePickerStyle::GetPrimaryTextColor() - { - return Win8GetSystemTextColor(true); - } - - Color Win8DatePickerStyle::GetSecondaryTextColor() - { - return Win8GetSystemTextColor(false); - } - } - } -} - -/*********************************************************************** -CONTROLS\STYLES\WIN8STYLES\GUIWIN8LISTSTYLES.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace win8 - { - using namespace collections; - using namespace elements; - using namespace compositions; - using namespace controls; - -/*********************************************************************** -Win8SelectableItemStyle -***********************************************************************/ - - void Win8SelectableItemStyle::TransferInternal(ButtonState value, bool enabled, bool selected) - { - if(!enabled) - { - transferringAnimation->Transfer(Win8ButtonColors::ItemDisabled()); - } - else if(selected) - { - transferringAnimation->Transfer(Win8ButtonColors::ItemSelected()); - } - else - { - switch(value) - { - case ButtonState::Normal: - transferringAnimation->Transfer(Win8ButtonColors::ItemNormal()); - break; - case ButtonState::Active: - transferringAnimation->Transfer(Win8ButtonColors::ItemActive()); - break; - case ButtonState::Pressed: - transferringAnimation->Transfer(Win8ButtonColors::ItemSelected()); - break; - } - } - } - - Win8SelectableItemStyle::Win8SelectableItemStyle() - :Win8ButtonStyleBase(Win8ButtonColors::ItemNormal(), Alignment::Left, Alignment::Center) - { - transferringAnimation->SetEnableAnimation(false); - } - - Win8SelectableItemStyle::~Win8SelectableItemStyle() - { - } - -/*********************************************************************** -Win8DropDownComboBoxStyle -***********************************************************************/ - - void Win8DropDownComboBoxStyle::TransferInternal(controls::ButtonState value, bool enabled, bool selected) - { - Win8ButtonColors targetColor; - if(enabled) - { - if(selected) value= ButtonState::Pressed; - switch(value) - { - case ButtonState::Normal: - targetColor=Win8ButtonColors::ButtonNormal(); - break; - case ButtonState::Active: - targetColor=Win8ButtonColors::ButtonActive(); - break; - case ButtonState::Pressed: - targetColor=Win8ButtonColors::ButtonPressed(); - break; - } - } - else - { - targetColor=Win8ButtonColors::ButtonDisabled(); - } - transferringAnimation->Transfer(targetColor); - } - - void Win8DropDownComboBoxStyle::AfterApplyColors(const Win8ButtonColors& colors) - { - Win8ButtonStyle::AfterApplyColors(colors); - dropDownElement->SetBorderColor(colors.textColor); - dropDownElement->SetBackgroundColor(colors.textColor); - } - - Win8DropDownComboBoxStyle::Win8DropDownComboBoxStyle() - :commandExecutor(0) - , textVisible(true) - { - table=new GuiTableComposition; - table->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - table->SetAlignmentToParent(Margin(0, 0, 0, 0)); - table->SetRowsAndColumns(3, 2); - table->SetRowOption(0, GuiCellOption::PercentageOption(1.0)); - table->SetRowOption(1, GuiCellOption::MinSizeOption()); - table->SetRowOption(2, GuiCellOption::PercentageOption(1.0)); - table->SetColumnOption(0, GuiCellOption::PercentageOption(1.0)); - table->SetColumnOption(1, GuiCellOption::MinSizeOption()); - elements.textComposition->AddChild(table); - elements.textComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - - textComposition=new GuiCellComposition; - table->AddChild(textComposition); - textComposition->SetSite(1, 0, 1, 1); - - Ptr element=elements.textComposition->GetOwnedElement(); - elements.textComposition->SetOwnedElement(0); - textComposition->SetOwnedElement(element); - elements.textElement->SetEllipse(true); - elements.textElement->SetAlignments(Alignment::Left, Alignment::Center); - - dropDownElement=common_styles::CommonFragmentBuilder::BuildDownArrow(); - - dropDownComposition=new GuiCellComposition; - table->AddChild(dropDownComposition); - dropDownComposition->SetSite(1, 1, 1, 1); - dropDownComposition->SetOwnedElement(dropDownElement); - dropDownComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - dropDownComposition->SetMargin(Margin(3, 0, 3, 0)); - } - - Win8DropDownComboBoxStyle::~Win8DropDownComboBoxStyle() - { - } - - compositions::GuiGraphicsComposition* Win8DropDownComboBoxStyle::GetContainerComposition() - { - return textComposition; - } - - GuiMenu::IStyleController* Win8DropDownComboBoxStyle::CreateSubMenuStyleController() - { - return new Win8MenuStyle; - } - - void Win8DropDownComboBoxStyle::SetSubMenuExisting(bool value) - { - } - - void Win8DropDownComboBoxStyle::SetSubMenuOpening(bool value) - { - SetSelected(value); - } - - GuiButton* Win8DropDownComboBoxStyle::GetSubMenuHost() - { - return 0; - } - - void Win8DropDownComboBoxStyle::SetImage(Ptr value) - { - } - - void Win8DropDownComboBoxStyle::SetShortcutText(const WString& value) - { - } - - void Win8DropDownComboBoxStyle::SetCommandExecutor(controls::IComboBoxCommandExecutor* value) - { - commandExecutor=value; - } - - void Win8DropDownComboBoxStyle::OnItemSelected() - { - } - - void Win8DropDownComboBoxStyle::SetText(const WString& value) - { - text = value; - if (textVisible) - { - Win8ButtonStyle::SetText(text); - } - } - - void Win8DropDownComboBoxStyle::SetTextVisible(bool value) - { - if (textVisible != value) - { - if ((textVisible = value)) - { - Win8ButtonStyle::SetText(text); - } - else - { - Win8ButtonStyle::SetText(L""); - } - } - } - -/*********************************************************************** -Win8TextListProvider -***********************************************************************/ - - Win8TextListProvider::Win8TextListProvider() - { - } - - Win8TextListProvider::~Win8TextListProvider() - { - } - - Color Win8TextListProvider::GetTextColor() - { - return Win8GetSystemTextColor(true); - } - - controls::GuiSelectableButton::IStyleController* Win8TextListProvider::CreateItemBackground() - { - return nullptr; - } - - controls::GuiSelectableButton::IStyleController* Win8TextListProvider::CreateCheckBulletStyle() - { - return nullptr; - } - - controls::GuiSelectableButton::IStyleController* Win8TextListProvider::CreateRadioBulletStyle() - { - return nullptr; - } - -/*********************************************************************** -Win8ListViewProvider -***********************************************************************/ - - Win8ListViewProvider::Win8ListViewProvider() - { - } - - Win8ListViewProvider::~Win8ListViewProvider() - { - } - - controls::GuiSelectableButton::IStyleController* Win8ListViewProvider::CreateItemBackground() - { - return nullptr; - } - - controls::GuiListViewColumnHeader::IStyleController* Win8ListViewProvider::CreateColumnStyle() - { - return new win7::Win7ListViewColumnHeaderStyle; - } - - Color Win8ListViewProvider::GetPrimaryTextColor() - { - return Win8GetSystemTextColor(true); - } - - Color Win8ListViewProvider::GetSecondaryTextColor() - { - return Win8GetSystemTextColor(false); - } - - Color Win8ListViewProvider::GetItemSeparatorColor() - { - return Color(220, 220, 220); - } - -/*********************************************************************** -Win8TreeViewProvider -***********************************************************************/ - - Win8TreeViewProvider::Win8TreeViewProvider() - { - } - - Win8TreeViewProvider::~Win8TreeViewProvider() - { - } - - controls::GuiSelectableButton::IStyleController* Win8TreeViewProvider::CreateItemBackground() - { - return nullptr; - } - - controls::GuiSelectableButton::IStyleController* Win8TreeViewProvider::CreateItemExpandingDecorator() - { - return nullptr; - } - - Color Win8TreeViewProvider::GetTextColor() - { - return Win8GetSystemTextColor(true); - } - } - } -} - -/*********************************************************************** -CONTROLS\STYLES\WIN8STYLES\GUIWIN8MENUSTYLES.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace win8 - { - using namespace collections; - using namespace elements; - using namespace compositions; - using namespace controls; - -/*********************************************************************** -Win8MenuStyle -***********************************************************************/ - - Win8MenuStyle::Win8MenuStyle() - { - { - GuiSolidBorderElement* element=GuiSolidBorderElement::Create(); - element->SetColor(Win8GetMenuBorderColor()); - boundsComposition=new GuiBoundsComposition; - boundsComposition->SetOwnedElement(element); - } - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Win8GetSystemWindowColor()); - GuiBoundsComposition* subBorder=new GuiBoundsComposition; - subBorder->SetOwnedElement(element); - subBorder->SetAlignmentToParent(Margin(1, 1, 1, 1)); - boundsComposition->AddChild(subBorder); - } - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Win8GetSystemWindowColor()); - containerComposition=new GuiBoundsComposition; - containerComposition->SetOwnedElement(element); - containerComposition->SetAlignmentToParent(Margin(3, 3, 3, 3)); - containerComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - boundsComposition->AddChild(containerComposition); - } - } - - Win8MenuStyle::~Win8MenuStyle() - { - } - - compositions::GuiBoundsComposition* Win8MenuStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win8MenuStyle::GetContainerComposition() - { - return containerComposition; - } - - void Win8MenuStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win8MenuStyle::SetText(const WString& value) - { - } - - void Win8MenuStyle::SetFont(const FontProperties& value) - { - } - - void Win8MenuStyle::SetVisuallyEnabled(bool value) - { - } - -/*********************************************************************** -Win8MenuBarStyle -***********************************************************************/ - - Win8MenuBarStyle::Win8MenuBarStyle() - { - boundsComposition=new GuiBoundsComposition; - { - GuiSolidBackgroundElement* solid=GuiSolidBackgroundElement::Create(); - solid->SetColor(Color(245, 246, 247)); - boundsComposition->SetOwnedElement(solid); - boundsComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - } - { - Gui3DSplitterElement* element=Gui3DSplitterElement::Create(); - element->SetColors(Color(232, 233, 234), Color(240, 240, 240)); - element->SetDirection(Gui3DSplitterElement::Horizontal); - - GuiBoundsComposition* composition=new GuiBoundsComposition; - composition->SetOwnedElement(element); - composition->SetPreferredMinSize(Size(0, 2)); - composition->SetAlignmentToParent(Margin(0, -1, 0, 0)); - boundsComposition->AddChild(composition); - } - containerComposition=new GuiBoundsComposition; - { - containerComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - containerComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - boundsComposition->AddChild(containerComposition); - } - } - - Win8MenuBarStyle::~Win8MenuBarStyle() - { - } - - compositions::GuiBoundsComposition* Win8MenuBarStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win8MenuBarStyle::GetContainerComposition() - { - return containerComposition; - } - - void Win8MenuBarStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win8MenuBarStyle::SetText(const WString& value) - { - } - - void Win8MenuBarStyle::SetFont(const FontProperties& value) - { - } - - void Win8MenuBarStyle::SetVisuallyEnabled(bool value) - { - } - -/*********************************************************************** -Win8MenuBarButtonStyle -***********************************************************************/ - - void Win8MenuBarButtonStyle::TransferInternal(ButtonState value, bool enabled, bool opening) - { - Win8ButtonColors targetColor; - if(!enabled) - { - targetColor=Win8ButtonColors::MenuBarButtonDisabled(); - targetColor.SetAlphaWithoutText(0); - } - else if(opening) - { - targetColor=Win8ButtonColors::MenuBarButtonPressed(); - } - else - { - switch(value) - { - case ButtonState::Normal: - targetColor=Win8ButtonColors::MenuBarButtonNormal(); - targetColor.SetAlphaWithoutText(0); - break; - case ButtonState::Active: - targetColor=Win8ButtonColors::MenuBarButtonActive(); - break; - case ButtonState::Pressed: - targetColor=Win8ButtonColors::MenuBarButtonPressed(); - break; - } - } - elements.Apply(targetColor); - } - - Win8MenuBarButtonStyle::Win8MenuBarButtonStyle() - :controlStyle(ButtonState::Normal) - ,isVisuallyEnabled(true) - ,isOpening(false) - { - Win8ButtonColors initialColor=Win8ButtonColors::MenuBarButtonNormal(); - initialColor.SetAlphaWithoutText(0); - - elements=Win8ButtonElements::Create(Alignment::Center, Alignment::Center); - elements.Apply(initialColor); - } - - Win8MenuBarButtonStyle::~Win8MenuBarButtonStyle() - { - } - - compositions::GuiBoundsComposition* Win8MenuBarButtonStyle::GetBoundsComposition() - { - return elements.mainComposition; - } - - compositions::GuiGraphicsComposition* Win8MenuBarButtonStyle::GetContainerComposition() - { - return elements.mainComposition; - } - - void Win8MenuBarButtonStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win8MenuBarButtonStyle::SetText(const WString& value) - { - elements.textElement->SetText(value); - } - - void Win8MenuBarButtonStyle::SetFont(const FontProperties& value) - { - Win8SetFont(elements.textElement, elements.textComposition, value); - Margin margin=elements.textComposition->GetMargin(); - margin.left*=3; - margin.right*=3; - elements.textComposition->SetMargin(margin); - } - - void Win8MenuBarButtonStyle::SetVisuallyEnabled(bool value) - { - if(isVisuallyEnabled!=value) - { - isVisuallyEnabled=value; - TransferInternal(controlStyle, isVisuallyEnabled, isOpening); - } - } - - void Win8MenuBarButtonStyle::SetSelected(bool value) - { - } - - controls::GuiMenu::IStyleController* Win8MenuBarButtonStyle::CreateSubMenuStyleController() - { - return new Win8MenuStyle; - } - - void Win8MenuBarButtonStyle::SetSubMenuExisting(bool value) - { - } - - void Win8MenuBarButtonStyle::SetSubMenuOpening(bool value) - { - if(isOpening!=value) - { - isOpening=value; - TransferInternal(controlStyle, isVisuallyEnabled, isOpening); - } - } - - controls::GuiButton* Win8MenuBarButtonStyle::GetSubMenuHost() - { - return 0; - } - - void Win8MenuBarButtonStyle::SetImage(Ptr value) - { - } - - void Win8MenuBarButtonStyle::SetShortcutText(const WString& value) - { - } - - void Win8MenuBarButtonStyle::Transfer(ButtonState value) - { - if(controlStyle!=value) - { - controlStyle=value; - TransferInternal(controlStyle, isVisuallyEnabled, isOpening); - } - } - -/*********************************************************************** -Win8MenuItemButtonStyle -***********************************************************************/ - - void Win8MenuItemButtonStyle::TransferInternal(ButtonState value, bool enabled, bool selected, bool opening) - { - Win8ButtonColors targetColor; - bool active=false; - if(enabled) - { - if(opening) - { - targetColor=Win8ButtonColors::MenuItemButtonNormalActive(); - active=true; - } - else - { - switch(value) - { - case ButtonState::Normal: - targetColor=selected?Win8ButtonColors::MenuItemButtonSelected():Win8ButtonColors::MenuItemButtonNormal(); - break; - case ButtonState::Active: - case ButtonState::Pressed: - targetColor=selected?Win8ButtonColors::MenuItemButtonSelectedActive():Win8ButtonColors::MenuItemButtonNormalActive(); - active=true; - break; - } - } - } - else - { - switch(value) - { - case ButtonState::Normal: - targetColor=Win8ButtonColors::MenuItemButtonDisabled(); - break; - case ButtonState::Active: - case ButtonState::Pressed: - targetColor=Win8ButtonColors::MenuItemButtonDisabledActive(); - active=true; - break; - } - } - elements.Apply(targetColor); - elements.SetActive(active || selected); - } - - Win8MenuItemButtonStyle::Win8MenuItemButtonStyle() - :controlStyle(ButtonState::Normal) - ,isVisuallyEnabled(true) - ,isSelected(false) - ,isOpening(false) - { - elements=Win8MenuItemButtonElements::Create(); - elements.Apply(Win8ButtonColors::MenuItemButtonNormal()); - } - - Win8MenuItemButtonStyle::~Win8MenuItemButtonStyle() - { - } - - compositions::GuiBoundsComposition* Win8MenuItemButtonStyle::GetBoundsComposition() - { - return elements.mainComposition; - } - - compositions::GuiGraphicsComposition* Win8MenuItemButtonStyle::GetContainerComposition() - { - return elements.mainComposition; - } - - void Win8MenuItemButtonStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win8MenuItemButtonStyle::SetText(const WString& value) - { - elements.textElement->SetText(value); - } - - void Win8MenuItemButtonStyle::SetFont(const FontProperties& value) - { - Win8SetFont(elements.textElement, elements.textComposition, value); - Win8SetFont(elements.shortcutElement, elements.shortcutComposition, value); - } - - void Win8MenuItemButtonStyle::SetVisuallyEnabled(bool value) - { - if(isVisuallyEnabled!=value) - { - isVisuallyEnabled=value; - elements.imageElement->SetEnabled(value); - TransferInternal(controlStyle, isVisuallyEnabled, isSelected, isOpening); - } - } - - void Win8MenuItemButtonStyle::SetSelected(bool value) - { - if(isSelected!=value) - { - isSelected=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected, isOpening); - } - } - - controls::GuiMenu::IStyleController* Win8MenuItemButtonStyle::CreateSubMenuStyleController() - { - return new Win8MenuStyle; - } - - void Win8MenuItemButtonStyle::SetSubMenuExisting(bool value) - { - elements.SetSubMenuExisting(value); - } - - void Win8MenuItemButtonStyle::SetSubMenuOpening(bool value) - { - if(isOpening!=value) - { - isOpening=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected, isOpening); - } - } - - controls::GuiButton* Win8MenuItemButtonStyle::GetSubMenuHost() - { - return 0; - } - - void Win8MenuItemButtonStyle::SetImage(Ptr value) - { - if(value) - { - elements.imageElement->SetImage(value->GetImage(), value->GetFrameIndex()); - } - else - { - elements.imageElement->SetImage(0, 0); - } - } - - void Win8MenuItemButtonStyle::SetShortcutText(const WString& value) - { - elements.shortcutElement->SetText(value); - } - - void Win8MenuItemButtonStyle::Transfer(ButtonState value) - { - if(controlStyle!=value) - { - controlStyle=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected, isOpening); - } - } - -/*********************************************************************** -Win8MenuSplitterStyle -***********************************************************************/ - - Win8MenuSplitterStyle::Win8MenuSplitterStyle() - { - boundsComposition=new GuiBoundsComposition; - boundsComposition->SetPreferredMinSize(Size(26, 5)); - { - GuiSolidBorderElement* element=GuiSolidBorderElement::Create(); - element->SetColor(Win8GetMenuSplitterColor()); - - GuiBoundsComposition* composition=new GuiBoundsComposition; - composition->SetPreferredMinSize(Size(1, 0)); - composition->SetOwnedElement(element); - composition->SetAlignmentToParent(Margin(26, 0, -1, 0)); - boundsComposition->AddChild(composition); - } - { - GuiSolidBorderElement* element=GuiSolidBorderElement::Create(); - element->SetColor(Win8GetMenuSplitterColor()); - - GuiBoundsComposition* composition=new GuiBoundsComposition; - composition->SetPreferredMinSize(Size(0, 1)); - composition->SetOwnedElement(element); - composition->SetAlignmentToParent(Margin(27, 2, 0, 2)); - boundsComposition->AddChild(composition); - } - } - - Win8MenuSplitterStyle::~Win8MenuSplitterStyle() - { - } - - compositions::GuiBoundsComposition* Win8MenuSplitterStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win8MenuSplitterStyle::GetContainerComposition() - { - return boundsComposition; - } - - void Win8MenuSplitterStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win8MenuSplitterStyle::SetText(const WString& value) - { - } - - void Win8MenuSplitterStyle::SetFont(const FontProperties& value) - { - } - - void Win8MenuSplitterStyle::SetVisuallyEnabled(bool value) - { - } - } - } -} - -/*********************************************************************** -CONTROLS\STYLES\WIN8STYLES\GUIWIN8SCROLLABLESTYLES.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace win8 - { - using namespace collections; - using namespace elements; - using namespace compositions; - using namespace controls; - -/*********************************************************************** -Win8ScrollHandleButtonStyle -***********************************************************************/ - - void Win8ScrollHandleButtonStyle::TransferInternal(ButtonState value, bool enabled, bool selected) - { - Win8ButtonColors targetColor; - if(enabled) - { - switch(value) - { - case ButtonState::Normal: - targetColor=Win8ButtonColors::ScrollHandleNormal(); - break; - case ButtonState::Active: - targetColor=Win8ButtonColors::ScrollHandleActive(); - break; - case ButtonState::Pressed: - targetColor=Win8ButtonColors::ScrollHandlePressed(); - break; - } - } - else - { - targetColor=Win8ButtonColors::ScrollHandleDisabled(); - } - transferringAnimation->Transfer(targetColor); - } - - Win8ScrollHandleButtonStyle::Win8ScrollHandleButtonStyle() - :Win8ButtonStyleBase(Win8ButtonColors::ScrollHandleNormal(), Alignment::Center, Alignment::Center) - { - } - - Win8ScrollHandleButtonStyle::~Win8ScrollHandleButtonStyle() - { - } - -/*********************************************************************** -Win8ScrollArrowButtonStyle -***********************************************************************/ - - void Win8ScrollArrowButtonStyle::TransferInternal(ButtonState value, bool enabled, bool selected) - { - Win8ButtonColors targetColor; - if(enabled) - { - switch(value) - { - case ButtonState::Normal: - targetColor=Win8ButtonColors::ScrollArrowNormal(); - break; - case ButtonState::Active: - targetColor=Win8ButtonColors::ScrollArrowActive(); - break; - case ButtonState::Pressed: - targetColor=Win8ButtonColors::ScrollArrowPressed(); - break; - } - } - else - { - targetColor=Win8ButtonColors::ScrollArrowDisabled(); - } - transferringAnimation->Transfer(targetColor); - } - - void Win8ScrollArrowButtonStyle::AfterApplyColors(const Win8ButtonColors& colors) - { - Win8ButtonStyleBase::AfterApplyColors(colors); - arrowElement->SetBorderColor(colors.textColor); - arrowElement->SetBackgroundColor(colors.textColor); - } - - Win8ScrollArrowButtonStyle::Win8ScrollArrowButtonStyle(common_styles::CommonScrollStyle::Direction direction, bool increaseButton) - :Win8ButtonStyleBase(Win8ButtonColors::ScrollArrowNormal(), Alignment::Center, Alignment::Center) - { - switch(direction) - { - case common_styles::CommonScrollStyle::Horizontal: - if(increaseButton) - { - GetContainerComposition()->AddChild(common_styles::CommonFragmentBuilder::BuildRightArrow(arrowElement)); - } - else - { - GetContainerComposition()->AddChild(common_styles::CommonFragmentBuilder::BuildLeftArrow(arrowElement)); - } - break; - case common_styles::CommonScrollStyle::Vertical: - if(increaseButton) - { - GetContainerComposition()->AddChild(common_styles::CommonFragmentBuilder::BuildDownArrow(arrowElement)); - } - else - { - GetContainerComposition()->AddChild(common_styles::CommonFragmentBuilder::BuildUpArrow(arrowElement)); - } - break; - } - } - - Win8ScrollArrowButtonStyle::~Win8ScrollArrowButtonStyle() - { - } - -/*********************************************************************** -Win8ScrollStyle -***********************************************************************/ - - controls::GuiButton::IStyleController* Win8ScrollStyle::CreateDecreaseButtonStyle(Direction direction) - { - Win8ScrollArrowButtonStyle* decreaseButtonStyle=new Win8ScrollArrowButtonStyle(direction, false); - return decreaseButtonStyle; - } - - controls::GuiButton::IStyleController* Win8ScrollStyle::CreateIncreaseButtonStyle(Direction direction) - { - Win8ScrollArrowButtonStyle* increaseButtonStyle=new Win8ScrollArrowButtonStyle(direction, true); - return increaseButtonStyle; - } - - controls::GuiButton::IStyleController* Win8ScrollStyle::CreateHandleButtonStyle(Direction direction) - { - Win8ScrollHandleButtonStyle* handleButtonStyle=new Win8ScrollHandleButtonStyle; - return handleButtonStyle; - } - - compositions::GuiBoundsComposition* Win8ScrollStyle::InstallBackground(compositions::GuiBoundsComposition* boundsComposition, Direction direction) - { - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Win8GetSystemWindowColor()); - - boundsComposition->SetOwnedElement(element); - } - - return boundsComposition; - } - - Win8ScrollStyle::Win8ScrollStyle(Direction _direction) - :CommonScrollStyle(_direction) - { - BuildStyle(DefaultSize, ArrowSize); - } - - Win8ScrollStyle::~Win8ScrollStyle() - { - } - -/*********************************************************************** -Win8TrackStyle -***********************************************************************/ - - controls::GuiButton::IStyleController* Win8TrackStyle::CreateHandleButtonStyle(Direction direction) - { - Win8ButtonStyle* handleButtonStyle=new Win8ButtonStyle; - return handleButtonStyle; - } - - void Win8TrackStyle::InstallBackground(compositions::GuiGraphicsComposition* boundsComposition, Direction direction) - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Win8GetSystemWindowColor()); - boundsComposition->SetOwnedElement(element); - } - - void Win8TrackStyle::InstallTrack(compositions::GuiGraphicsComposition* trackComposition, Direction direction) - { - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Color(231, 234, 234)); - trackComposition->SetOwnedElement(element); - } - { - GuiSolidBorderElement* element=GuiSolidBorderElement::Create(); - element->SetColor(Color(214, 214, 214)); - - GuiBoundsComposition* composition=new GuiBoundsComposition; - composition->SetOwnedElement(element); - composition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - trackComposition->AddChild(composition); - } - } - - Win8TrackStyle::Win8TrackStyle(Direction _direction) - :CommonTrackStyle(_direction) - { - BuildStyle(TrackThickness, TrackPadding, HandleLong, HandleShort); - } - - Win8TrackStyle::~Win8TrackStyle() - { - } - -/*********************************************************************** -Win8ProgressBarStyle -***********************************************************************/ - - void Win8ProgressBarStyle::UpdateProgressBar() - { - vint max=totalSize-pageSize; - if(position<0) - { - progressComposition->SetWidthPageSize(0); - } - else if(position>=max) - { - progressComposition->SetWidthPageSize(1); - } - else - { - progressComposition->SetWidthPageSize((double)position/max); - } - } - - Win8ProgressBarStyle::Win8ProgressBarStyle() - :totalSize(1) - ,pageSize(0) - ,position(0) - { - { - boundsComposition=new GuiBoundsComposition; - } - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Color(230, 230, 230)); - - containerComposition=new GuiBoundsComposition; - containerComposition->SetAlignmentToParent(Margin(1, 1, 1, 1)); - containerComposition->SetOwnedElement(element); - boundsComposition->AddChild(containerComposition); - } - { - GuiSolidBorderElement* element=GuiSolidBorderElement::Create(); - element->SetColor(Color(188, 188, 188)); - - GuiBoundsComposition* borderComposition=new GuiBoundsComposition; - borderComposition->SetOwnedElement(element); - borderComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - boundsComposition->AddChild(borderComposition); - } - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Color(6, 176, 37)); - - progressComposition=new GuiPartialViewComposition; - progressComposition->SetWidthRatio(0); - progressComposition->SetWidthPageSize(0); - progressComposition->SetHeightRatio(0); - progressComposition->SetHeightPageSize(1); - progressComposition->SetOwnedElement(element); - containerComposition->AddChild(progressComposition); - } - } - - Win8ProgressBarStyle::~Win8ProgressBarStyle() - { - } - - compositions::GuiBoundsComposition* Win8ProgressBarStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win8ProgressBarStyle::GetContainerComposition() - { - return containerComposition; - } - - void Win8ProgressBarStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win8ProgressBarStyle::SetText(const WString& value) - { - } - - void Win8ProgressBarStyle::SetFont(const FontProperties& value) - { - } - - void Win8ProgressBarStyle::SetVisuallyEnabled(bool value) - { - } - - void Win8ProgressBarStyle::SetCommandExecutor(controls::IScrollCommandExecutor* value) - { - } - - void Win8ProgressBarStyle::SetTotalSize(vint value) - { - totalSize=value; - UpdateProgressBar(); - } - - void Win8ProgressBarStyle::SetPageSize(vint value) - { - pageSize=value; - UpdateProgressBar(); - } - - void Win8ProgressBarStyle::SetPosition(vint value) - { - position=value; - UpdateProgressBar(); - } - -/*********************************************************************** -Win8ScrollViewProvider -***********************************************************************/ - - Win8ScrollViewProvider::Win8ScrollViewProvider() - { - } - - Win8ScrollViewProvider::~Win8ScrollViewProvider() - { - } - - void Win8ScrollViewProvider::AssociateStyleController(controls::GuiControl::IStyleController* controller) - { - } - - void Win8ScrollViewProvider::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win8ScrollViewProvider::SetText(const WString& value) - { - } - - void Win8ScrollViewProvider::SetFont(const FontProperties& value) - { - } - - void Win8ScrollViewProvider::SetVisuallyEnabled(bool value) - { - } - - controls::GuiScroll::IStyleController* Win8ScrollViewProvider::CreateHorizontalScrollStyle() - { - return new Win8ScrollStyle(Win8ScrollStyle::Horizontal); - } - - controls::GuiScroll::IStyleController* Win8ScrollViewProvider::CreateVerticalScrollStyle() - { - return new Win8ScrollStyle(Win8ScrollStyle::Vertical); - } - - vint Win8ScrollViewProvider::GetDefaultScrollSize() - { - return Win8ScrollStyle::DefaultSize; - } - - compositions::GuiGraphicsComposition* Win8ScrollViewProvider::InstallBackground(compositions::GuiBoundsComposition* boundsComposition) - { - GuiSolidBorderElement* border=GuiSolidBorderElement::Create(); - border->SetColor(Win8GetSystemBorderColor()); - boundsComposition->SetOwnedElement(border); - boundsComposition->SetInternalMargin(Margin(1, 1, 1, 1)); - - GuiSolidBackgroundElement* background=GuiSolidBackgroundElement::Create(); - background->SetColor(Win8GetSystemWindowColor()); - - GuiBoundsComposition* backgroundComposition=new GuiBoundsComposition; - boundsComposition->AddChild(backgroundComposition); - backgroundComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - backgroundComposition->SetOwnedElement(background); - - return boundsComposition; - } - -/*********************************************************************** -Win8TextBoxBackground -***********************************************************************/ - -#define HOST_GETTER_BY_FOCUSABLE_COMPOSITION(STYLE) (style->focusableComposition->GetRelatedGraphicsHost()) - - IMPLEMENT_TRANSFERRING_ANIMATION_BASE(Win8TextBoxColors, Win8TextBoxBackground, HOST_GETTER_BY_FOCUSABLE_COMPOSITION) - { - colorCurrent=Win8TextBoxColors::Blend(colorBegin, colorEnd, currentPosition, totalLength); - style->Apply(colorCurrent); - } - - void Win8TextBoxBackground::UpdateStyle() - { - if(!isVisuallyEnabled) - { - transferringAnimation->Transfer(Win8TextBoxColors::Disabled()); - } - else if(isFocused) - { - transferringAnimation->Transfer(Win8TextBoxColors::Focused()); - } - else if(isMouseEnter) - { - transferringAnimation->Transfer(Win8TextBoxColors::Active()); - } - else - { - transferringAnimation->Transfer(Win8TextBoxColors::Normal()); - } - } - - void Win8TextBoxBackground::Apply(const Win8TextBoxColors& colors) - { - borderElement->SetColor(colors.borderColor); - backgroundElement->SetColor(colors.backgroundColor); - } - - void Win8TextBoxBackground::OnBoundsMouseEnter(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - isMouseEnter=true; - UpdateStyle(); - } - - void Win8TextBoxBackground::OnBoundsMouseLeave(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - isMouseEnter=false; - UpdateStyle(); - } - - void Win8TextBoxBackground::OnBoundsGotFocus(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - isFocused=true; - UpdateStyle(); - } - - void Win8TextBoxBackground::OnBoundsLostFocus(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - isFocused=false; - UpdateStyle(); - } - - Win8TextBoxBackground::Win8TextBoxBackground() - :backgroundElement(0) - ,borderElement(0) - ,focusableComposition(0) - ,isMouseEnter(false) - ,isFocused(false) - ,isVisuallyEnabled(false) - ,styleController(0) - ,textElement(0) - { - transferringAnimation=new TransferringAnimation(this, Win8TextBoxColors::Normal()); - } - - Win8TextBoxBackground::~Win8TextBoxBackground() - { - transferringAnimation->Disable(); - } - - void Win8TextBoxBackground::AssociateStyleController(controls::GuiControl::IStyleController* controller) - { - styleController=controller; - } - - void Win8TextBoxBackground::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - focusableComposition=value; - focusableComposition->GetEventReceiver()->mouseEnter.AttachMethod(this, &Win8TextBoxBackground::OnBoundsMouseEnter); - focusableComposition->GetEventReceiver()->mouseLeave.AttachMethod(this, &Win8TextBoxBackground::OnBoundsMouseLeave); - focusableComposition->GetEventReceiver()->gotFocus.AttachMethod(this, &Win8TextBoxBackground::OnBoundsGotFocus); - focusableComposition->GetEventReceiver()->lostFocus.AttachMethod(this, &Win8TextBoxBackground::OnBoundsLostFocus); - } - - void Win8TextBoxBackground::SetVisuallyEnabled(bool value) - { - isVisuallyEnabled=value; - UpdateStyle(); - } - - compositions::GuiGraphicsComposition* Win8TextBoxBackground::InstallBackground(compositions::GuiBoundsComposition* boundsComposition) - { - { - GuiSolidBackgroundElement* background=GuiSolidBackgroundElement::Create(); - background->SetColor(Color(255, 255, 255)); - - GuiBoundsComposition* backgroundComposition=new GuiBoundsComposition; - boundsComposition->AddChild(backgroundComposition); - backgroundComposition->SetAlignmentToParent(Margin(1, 1, 1, 1)); - backgroundComposition->SetOwnedElement(background); - backgroundElement = background; - } - { - GuiSolidBorderElement* border=GuiSolidBorderElement::Create(); - border->SetColor(Win8GetSystemBorderColor()); - borderElement=border; - - GuiBoundsComposition* borderComposition=new GuiBoundsComposition; - boundsComposition->AddChild(borderComposition); - borderComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - borderComposition->SetOwnedElement(border); - } - Apply(Win8TextBoxColors::Normal()); - { - GuiBoundsComposition* containerComposition=new GuiBoundsComposition; - boundsComposition->AddChild(containerComposition); - containerComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - containerComposition->SetAlignmentToParent(Margin(2, 2, 2, 2)); - return containerComposition; - } - } - - void Win8TextBoxBackground::InitializeTextElement(elements::GuiColorizedTextElement* _textElement) - { - textElement=_textElement; - - Array colors; - colors.Resize(1); - { - colors[0]=Win8GetTextBoxTextColor(); - } - textElement->SetColors(colors); - textElement->SetCaretColor(Color(0, 0, 0)); - } - -/*********************************************************************** -Win8MultilineTextBoxProvider -***********************************************************************/ - - Win8MultilineTextBoxProvider::Win8MultilineTextBoxProvider() - :styleController(0) - { - } - - Win8MultilineTextBoxProvider::~Win8MultilineTextBoxProvider() - { - } - - void Win8MultilineTextBoxProvider::AssociateStyleController(controls::GuiControl::IStyleController* controller) - { - styleController=controller; - background.AssociateStyleController(controller); - } - - void Win8MultilineTextBoxProvider::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - background.SetFocusableComposition(value); - GuiMultilineTextBox::StyleController* textBoxController=dynamic_cast(styleController); - if(textBoxController) - { - background.InitializeTextElement(textBoxController->GetTextElement()); - } - } - - void Win8MultilineTextBoxProvider::SetVisuallyEnabled(bool value) - { - background.SetVisuallyEnabled(value); - } - - compositions::GuiGraphicsComposition* Win8MultilineTextBoxProvider::InstallBackground(compositions::GuiBoundsComposition* boundsComposition) - { - return background.InstallBackground(boundsComposition); - } - -/*********************************************************************** -Win8SinglelineTextBoxProvider -***********************************************************************/ - - Win8SinglelineTextBoxProvider::Win8SinglelineTextBoxProvider() - :styleController(0) - { - } - - Win8SinglelineTextBoxProvider::~Win8SinglelineTextBoxProvider() - { - } - - void Win8SinglelineTextBoxProvider::AssociateStyleController(controls::GuiControl::IStyleController* controller) - { - styleController=controller; - background.AssociateStyleController(controller); - } - - void Win8SinglelineTextBoxProvider::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - background.SetFocusableComposition(value); - GuiSinglelineTextBox::StyleController* textBoxController=dynamic_cast(styleController); - background.InitializeTextElement(textBoxController->GetTextElement()); - } - - void Win8SinglelineTextBoxProvider::SetText(const WString& value) - { - } - - void Win8SinglelineTextBoxProvider::SetFont(const FontProperties& value) - { - } - - void Win8SinglelineTextBoxProvider::SetVisuallyEnabled(bool value) - { - background.SetVisuallyEnabled(value); - } - - compositions::GuiGraphicsComposition* Win8SinglelineTextBoxProvider::InstallBackground(compositions::GuiBoundsComposition* boundsComposition) - { - return background.InstallBackground(boundsComposition); - } - -/*********************************************************************** -Win8DocumentViewerStyle -***********************************************************************/ - - Win8DocumentViewerStyle::Win8DocumentViewerStyle() - { - } - - Win8DocumentViewerStyle::~Win8DocumentViewerStyle() - { - } - - Ptr Win8DocumentViewerStyle::GetBaselineDocument() - { - return nullptr; - } - - Color Win8DocumentViewerStyle::GetCaretColor() - { - return Color(0, 0, 0); - } - -/*********************************************************************** -Win8DocumentlabelStyle -***********************************************************************/ - - Win8DocumentLabelStyle::Win8DocumentLabelStyle() - { - } - - Win8DocumentLabelStyle::~Win8DocumentLabelStyle() - { - } - - Ptr Win8DocumentLabelStyle::GetBaselineDocument() - { - return nullptr; - } - - Color Win8DocumentLabelStyle::GetCaretColor() - { - return Color(0, 0, 0); - } - -/*********************************************************************** -Win8DocumentTextBoxStyle -***********************************************************************/ - - Win8DocumentTextBoxStyle::Win8DocumentTextBoxStyle() - { - boundsComposition = new GuiBoundsComposition; - boundsComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - containerComposition = background.InstallBackground(boundsComposition); - background.AssociateStyleController(this); - } - - Win8DocumentTextBoxStyle::~Win8DocumentTextBoxStyle() - { - } - - compositions::GuiBoundsComposition* Win8DocumentTextBoxStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win8DocumentTextBoxStyle::GetContainerComposition() - { - return containerComposition; - } - - void Win8DocumentTextBoxStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - background.SetFocusableComposition(value); - } - - void Win8DocumentTextBoxStyle::SetText(const WString& value) - { - } - - void Win8DocumentTextBoxStyle::SetFont(const FontProperties& value) - { - } - - void Win8DocumentTextBoxStyle::SetVisuallyEnabled(bool value) - { - background.SetVisuallyEnabled(value); - } - - Ptr Win8DocumentTextBoxStyle::GetBaselineDocument() - { - return nullptr; - } - - Color Win8DocumentTextBoxStyle::GetCaretColor() - { - return Color(0, 0, 0); - } - } - } -} - -/*********************************************************************** -CONTROLS\STYLES\WIN8STYLES\GUIWIN8STYLESCOMMON.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace win8 - { - using namespace collections; - using namespace elements; - using namespace compositions; - using namespace controls; - -/*********************************************************************** -Win8ButtonColors -***********************************************************************/ - - void Win8ButtonColors::SetAlphaWithoutText(unsigned char a) - { - borderColor.a=a; - g1.a=a; - g2.a=a; - } - - Win8ButtonColors Win8ButtonColors::Blend(const Win8ButtonColors& c1, const Win8ButtonColors& c2, vint ratio, vint total) - { - if(ratio<0) ratio=0; - else if(ratio>total) ratio=total; - - Win8ButtonColors result; - result.borderColor=BlendColor(c1.borderColor, c2.borderColor, ratio, total); - result.g1=BlendColor(c1.g1, c2.g1, ratio, total); - result.g2=BlendColor(c1.g2, c2.g2, ratio, total); - result.textColor=BlendColor(c1.textColor, c2.textColor, ratio, total); - result.bullet=BlendColor(c1.bullet, c2.bullet, ratio, total); - return result; - } - - //--------------------------------------------------------- - - Win8ButtonColors Win8ButtonColors::ButtonNormal() - { - Win8ButtonColors colors= - { - Color(172, 172, 172), - Color(239, 239, 239), - Color(229, 229, 229), - Win8GetSystemTextColor(true), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::ButtonActive() - { - Win8ButtonColors colors= - { - Color(126, 180, 234), - Color(235, 244, 252), - Color(220, 236, 252), - Win8GetSystemTextColor(true), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::ButtonPressed() - { - Win8ButtonColors colors= - { - Color(86, 157, 229), - Color(218, 236, 252), - Color(196, 224, 252), - Win8GetSystemTextColor(true), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::ButtonDisabled() - { - Win8ButtonColors colors= - { - Color(173, 178, 181), - Color(252, 252, 252), - Color(252, 252, 252), - Win8GetSystemTextColor(false), - }; - return colors; - } - - //--------------------------------------------------------- - - Win8ButtonColors Win8ButtonColors::ItemNormal() - { - Win8ButtonColors colors= - { - Color(112, 192, 231, 0), - Color(229, 243, 251, 0), - Color(229, 243, 251, 0), - Win8GetSystemTextColor(true), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::ItemActive() - { - Win8ButtonColors colors= - { - Color(112, 192, 231), - Color(229, 243, 251), - Color(229, 243, 251), - Win8GetSystemTextColor(true), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::ItemSelected() - { - Win8ButtonColors colors= - { - Color(102, 167, 232), - Color(209, 232, 255), - Color(209, 232, 255), - Win8GetSystemTextColor(true), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::ItemDisabled() - { - Win8ButtonColors colors= - { - Color(112, 192, 231, 0), - Color(229, 243, 251, 0), - Color(229, 243, 251, 0), - Win8GetSystemTextColor(false), - }; - return colors; - } - - //--------------------------------------------------------- - - Win8ButtonColors Win8ButtonColors::CheckedNormal(bool selected) - { - Win8ButtonColors colors= - { - Color(112, 112, 112), - Color(255, 255, 255), - Color(255, 255, 255), - Win8GetSystemTextColor(true), - Color(0, 0, 0), - }; - if(!selected) - { - colors.bullet.a=0; - } - return colors; - } - - Win8ButtonColors Win8ButtonColors::CheckedActive(bool selected) - { - Win8ButtonColors colors= - { - Color(51, 153, 255), - Color(243, 249, 255), - Color(243, 249, 255), - Win8GetSystemTextColor(true), - Color(33, 33, 33), - }; - if(!selected) - { - colors.bullet.a=0; - } - return colors; - } - - Win8ButtonColors Win8ButtonColors::CheckedPressed(bool selected) - { - Win8ButtonColors colors= - { - Color(0, 124, 222), - Color(217, 236, 255), - Color(217, 236, 255), - Win8GetSystemTextColor(true), - Color(0, 0, 0), - }; - if(!selected) - { - colors.bullet.a=0; - } - return colors; - } - - Win8ButtonColors Win8ButtonColors::CheckedDisabled(bool selected) - { - Win8ButtonColors colors= - { - Color(188, 188, 188), - Color(230, 230, 230), - Color(230, 230, 230), - Win8GetSystemTextColor(false), - Color(112, 112, 112), - }; - if(!selected) - { - colors.bullet.a=0; - } - return colors; - } - - //--------------------------------------------------------- - - Win8ButtonColors Win8ButtonColors::ToolstripButtonNormal() - { - Win8ButtonColors colors= - { - Win8GetSystemWindowColor(), - Win8GetSystemWindowColor(), - Win8GetSystemWindowColor(), - Win8GetSystemTextColor(true), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::ToolstripButtonActive() - { - Win8ButtonColors colors= - { - Color(120, 174, 229), - Color(209, 226, 242), - Color(209, 226, 242), - Win8GetSystemTextColor(true), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::ToolstripButtonPressed() - { - Win8ButtonColors colors= - { - Color(96, 161, 226), - Color(180, 212, 244), - Color(180, 212, 244), - Win8GetSystemTextColor(true), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::ToolstripButtonSelected() - { - Win8ButtonColors colors= - { - Color(96, 161, 226), - Color(233, 241, 250), - Color(233, 241, 250), - Win8GetSystemTextColor(true), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::ToolstripButtonDisabled() - { - Win8ButtonColors colors= - { - Win8GetSystemWindowColor(), - Win8GetSystemWindowColor(), - Win8GetSystemWindowColor(), - Win8GetSystemTextColor(false), - }; - return colors; - } - - //--------------------------------------------------------- - - Win8ButtonColors Win8ButtonColors::ScrollHandleNormal() - { - Win8ButtonColors colors= - { - Color(205, 205, 205), - Color(205, 205, 205), - Color(205, 205, 205), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::ScrollHandleActive() - { - Win8ButtonColors colors= - { - Color(166, 166, 166), - Color(166, 166, 166), - Color(166, 166, 166), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::ScrollHandlePressed() - { - Win8ButtonColors colors= - { - Color(166, 166, 166), - Color(166, 166, 166), - Color(166, 166, 166), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::ScrollHandleDisabled() - { - Win8ButtonColors colors= - { - Win8GetSystemWindowColor(), - Win8GetSystemWindowColor(), - Win8GetSystemWindowColor(), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::ScrollArrowNormal() - { - Win8ButtonColors colors= - { - Win8GetSystemWindowColor(), - Win8GetSystemWindowColor(), - Win8GetSystemWindowColor(), - Color(96, 96, 96), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::ScrollArrowActive() - { - Win8ButtonColors colors= - { - Color(218, 218, 218), - Color(218, 218, 218), - Color(218, 218, 218), - Color(0, 0, 0), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::ScrollArrowPressed() - { - Win8ButtonColors colors= - { - Color(96, 96, 96), - Color(96, 96, 96), - Color(96, 96, 96), - Color(255, 255, 255), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::ScrollArrowDisabled() - { - Win8ButtonColors colors= - { - Win8GetSystemWindowColor(), - Win8GetSystemWindowColor(), - Win8GetSystemWindowColor(), - Color(191, 191, 191), - }; - return colors; - } - - //--------------------------------------------------------- - - Win8ButtonColors Win8ButtonColors::MenuBarButtonNormal() - { - Win8ButtonColors colors= - { - Color(245, 246, 247), - Color(245, 246, 247), - Color(245, 246, 247), - Win8GetSystemTextColor(true), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::MenuBarButtonActive() - { - Win8ButtonColors colors= - { - Color(122, 177, 232), - Color(213, 231, 248), - Color(213, 231, 248), - Win8GetSystemTextColor(true), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::MenuBarButtonPressed() - { - Win8ButtonColors colors= - { - Color(98, 163, 229), - Color(184, 216, 249), - Color(184, 216, 249), - Win8GetSystemTextColor(true), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::MenuBarButtonDisabled() - { - Win8ButtonColors colors= - { - Color(245, 246, 247), - Color(245, 246, 247), - Color(245, 246, 247), - Win8GetSystemTextColor(false), - }; - return colors; - } - - //--------------------------------------------------------- - - Win8ButtonColors Win8ButtonColors::MenuItemButtonNormal() - { - Win8ButtonColors colors= - { - Color(240, 240, 240), - Color(240, 240, 240), - Color(240, 240, 240), - Win8GetSystemTextColor(true), - Win8GetMenuSplitterColor(), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::MenuItemButtonNormalActive() - { - Win8ButtonColors colors= - { - Color(120, 174, 229), - Color(209, 226, 242), - Color(209, 226, 242), - Win8GetSystemTextColor(true), - Color(187, 204, 220), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::MenuItemButtonSelected() - { - Win8ButtonColors colors= - { - Color(120, 174, 229), - Color(233, 241, 250), - Color(233, 241, 250), - Win8GetSystemTextColor(true), - Color(233, 241, 250), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::MenuItemButtonSelectedActive() - { - Win8ButtonColors colors= - { - Color(120, 174, 229), - Color(233, 241, 250), - Color(233, 241, 250), - Win8GetSystemTextColor(true), - Color(187, 204, 220), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::MenuItemButtonDisabled() - { - Win8ButtonColors colors= - { - Color(240, 240, 240), - Color(240, 240, 240), - Color(240, 240, 240), - Win8GetSystemTextColor(false), - Win8GetMenuSplitterColor(), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::MenuItemButtonDisabledActive() - { - Win8ButtonColors colors= - { - Color(120, 174, 229), - Color(209, 226, 242), - Color(209, 226, 242), - Win8GetSystemTextColor(false), - Win8GetMenuSplitterColor(), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::TabPageHeaderNormal() - { - Win8ButtonColors colors= - { - Color(172, 172, 172), - Color(239, 239, 239), - Color(229, 229, 229), - Win8GetSystemTextColor(true), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::TabPageHeaderActive() - { - Win8ButtonColors colors= - { - Color(126, 180, 234), - Color(236, 244, 252), - Color(221, 237, 252), - Win8GetSystemTextColor(true), - }; - return colors; - } - - Win8ButtonColors Win8ButtonColors::TabPageHeaderSelected() - { - Win8ButtonColors colors= - { - Color(172, 172, 172), - Color(255, 255, 255), - Color(255, 255, 255), - Win8GetSystemTextColor(true), - }; - return colors; - } - -/*********************************************************************** -Win8ButtonElements -***********************************************************************/ - - Win8ButtonElements Win8ButtonElements::Create(Alignment horizontal, Alignment vertical) - { - Win8ButtonElements button; - { - button.mainComposition=new GuiBoundsComposition; - button.mainComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - } - { - GuiSolidBorderElement* element=GuiSolidBorderElement::Create(); - button.rectBorderElement=element; - - GuiBoundsComposition* composition=new GuiBoundsComposition; - button.mainComposition->AddChild(composition); - composition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - composition->SetOwnedElement(element); - } - { - GuiGradientBackgroundElement* element=GuiGradientBackgroundElement::Create(); - button.backgroundElement=element; - element->SetDirection(GuiGradientBackgroundElement::Vertical); - element->SetShape(ElementShape::Rectangle); - - GuiBoundsComposition* composition=new GuiBoundsComposition; - button.backgroundComposition=composition; - button.mainComposition->AddChild(composition); - composition->SetAlignmentToParent(Margin(1, 1, 1, 1)); - composition->SetOwnedElement(element); - } - { - Win8CreateSolidLabelElement(button.textElement, button.textComposition, horizontal, vertical); - button.mainComposition->AddChild(button.textComposition); - } - return button; - } - - void Win8ButtonElements::Apply(const Win8ButtonColors& colors) - { - if(rectBorderElement) - { - rectBorderElement->SetColor(colors.borderColor); - } - backgroundElement->SetColors(colors.g1, colors.g2); - textElement->SetColor(colors.textColor); - } - -/*********************************************************************** -Win8CheckedButtonElements -***********************************************************************/ - - Win8CheckedButtonElements Win8CheckedButtonElements::Create(elements::ElementShape shape, bool backgroundVisible) - { - const vint checkSize=13; - const vint checkPadding=2; - - Win8CheckedButtonElements button; - { - button.mainComposition=new GuiBoundsComposition; - button.mainComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - } - { - GuiTableComposition* mainTable=new GuiTableComposition; - button.mainComposition->AddChild(mainTable); - if(backgroundVisible) - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Win8GetSystemWindowColor()); - mainTable->SetOwnedElement(element); - } - mainTable->SetRowsAndColumns(1, 2); - mainTable->SetAlignmentToParent(Margin(0, 0, 0, 0)); - mainTable->SetRowOption(0, GuiCellOption::PercentageOption(1.0)); - mainTable->SetColumnOption(0, GuiCellOption::AbsoluteOption(checkSize+2*checkPadding)); - mainTable->SetColumnOption(1, GuiCellOption::PercentageOption(1.0)); - - { - GuiCellComposition* cell=new GuiCellComposition; - mainTable->AddChild(cell); - cell->SetSite(0, 0, 1, 1); - - GuiTableComposition* table=new GuiTableComposition; - cell->AddChild(table); - table->SetRowsAndColumns(3, 1); - table->SetAlignmentToParent(Margin(0, 0, 0, 0)); - table->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); - table->SetRowOption(1, GuiCellOption::MinSizeOption()); - table->SetRowOption(2, GuiCellOption::PercentageOption(0.5)); - - { - GuiCellComposition* checkCell=new GuiCellComposition; - table->AddChild(checkCell); - checkCell->SetSite(1, 0, 1, 1); - { - GuiBoundsComposition* borderBounds=new GuiBoundsComposition; - checkCell->AddChild(borderBounds); - borderBounds->SetAlignmentToParent(Margin(checkPadding, -1, checkPadding, -1)); - borderBounds->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - { - GuiSolidBorderElement* element=GuiSolidBorderElement::Create(); - button.bulletBorderElement=element; - element->SetShape(shape); - - GuiBoundsComposition* bounds=new GuiBoundsComposition; - borderBounds->AddChild(bounds); - bounds->SetOwnedElement(element); - bounds->SetAlignmentToParent(Margin(0, 0, 0, 0)); - bounds->SetBounds(Rect(Point(0, 0), Size(checkSize, checkSize))); - } - { - GuiGradientBackgroundElement* element=GuiGradientBackgroundElement::Create(); - button.bulletBackgroundElement=element; - element->SetShape(shape); - element->SetDirection(GuiGradientBackgroundElement::Vertical); - - GuiBoundsComposition* bounds=new GuiBoundsComposition; - borderBounds->AddChild(bounds); - bounds->SetOwnedElement(element); - bounds->SetAlignmentToParent(Margin(1, 1, 1, 1)); - } - } - - button.bulletCheckElement=0; - button.bulletRadioElement=0; - if(shape==ElementShape::Rectangle) - { - button.bulletCheckElement=GuiSolidLabelElement::Create(); - { - FontProperties font; - font.fontFamily=L"Webdings"; - font.size=16; - font.bold=true; - button.bulletCheckElement->SetFont(font); - } - button.bulletCheckElement->SetText(L"a"); - button.bulletCheckElement->SetAlignments(Alignment::Center, Alignment::Center); - - GuiBoundsComposition* composition=new GuiBoundsComposition; - composition->SetOwnedElement(button.bulletCheckElement); - composition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - checkCell->AddChild(composition); - } - else - { - button.bulletRadioElement=GuiSolidBackgroundElement::Create(); - button.bulletRadioElement->SetShape(ElementShape::Ellipse); - - GuiBoundsComposition* composition=new GuiBoundsComposition; - composition->SetOwnedElement(button.bulletRadioElement); - composition->SetAlignmentToParent(Margin(checkPadding+3, 3, checkPadding+3, 3)); - checkCell->AddChild(composition); - } - } - } - - { - GuiCellComposition* textCell=new GuiCellComposition; - mainTable->AddChild(textCell); - textCell->SetSite(0, 1, 1, 1); - { - Win8CreateSolidLabelElement(button.textElement, button.textComposition, Alignment::Left, Alignment::Center); - textCell->AddChild(button.textComposition); - } - } - } - return button; - } - - void Win8CheckedButtonElements::Apply(const Win8ButtonColors& colors) - { - bulletBorderElement->SetColor(colors.borderColor); - bulletBackgroundElement->SetColors(colors.g1, colors.g2); - textElement->SetColor(colors.textColor); - if(bulletCheckElement) - { - bulletCheckElement->SetColor(colors.bullet); - } - if(bulletRadioElement) - { - bulletRadioElement->SetColor(colors.bullet); - } - } - -/*********************************************************************** -Win8MenuItemButtonElements -***********************************************************************/ - - Win8MenuItemButtonElements Win8MenuItemButtonElements::Create() - { - Win8MenuItemButtonElements button; - { - button.mainComposition=new GuiBoundsComposition; - button.mainComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - } - { - GuiSolidBorderElement* element=GuiSolidBorderElement::Create(); - button.borderElement=element; - - GuiBoundsComposition* composition=new GuiBoundsComposition; - button.mainComposition->AddChild(composition); - composition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - composition->SetOwnedElement(element); - } - { - GuiGradientBackgroundElement* element=GuiGradientBackgroundElement::Create(); - button.backgroundElement=element; - element->SetDirection(GuiGradientBackgroundElement::Vertical); - - GuiBoundsComposition* composition=new GuiBoundsComposition; - button.mainComposition->AddChild(composition); - composition->SetAlignmentToParent(Margin(1, 1, 1, 1)); - composition->SetOwnedElement(element); - } - { - GuiTableComposition* table=new GuiTableComposition; - button.mainComposition->AddChild(table); - table->SetAlignmentToParent(Margin(2, 0, 2, 0)); - table->SetRowsAndColumns(1, 5); - - table->SetRowOption(0, GuiCellOption::PercentageOption(1.0)); - table->SetColumnOption(0, GuiCellOption::AbsoluteOption(24)); - table->SetColumnOption(1, GuiCellOption::AbsoluteOption(1)); - table->SetColumnOption(2, GuiCellOption::PercentageOption(1.0)); - table->SetColumnOption(3, GuiCellOption::MinSizeOption()); - table->SetColumnOption(4, GuiCellOption::AbsoluteOption(10)); - - { - GuiCellComposition* cell=new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 0, 1, 1); - button.splitterComposition=cell; - - GuiImageFrameElement* element=GuiImageFrameElement::Create(); - button.imageElement=element; - element->SetStretch(false); - element->SetAlignments(Alignment::Center, Alignment::Center); - cell->SetOwnedElement(element); - } - { - GuiCellComposition* cell=new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 1, 1, 1); - button.splitterComposition=cell; - - GuiSolidBorderElement* element=GuiSolidBorderElement::Create(); - button.splitterElement=element; - cell->SetOwnedElement(element); - } - { - GuiCellComposition* cell=new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 2, 1, 1); - - Win8CreateSolidLabelElement(button.textElement, button.textComposition, L"MenuItem-Text", Alignment::Left, Alignment::Center); - cell->AddChild(button.textComposition); - } - { - GuiCellComposition* cell=new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 3, 1, 1); - - Win8CreateSolidLabelElement(button.shortcutElement, button.shortcutComposition, L"MenuItem-Shortcut", Alignment::Right, Alignment::Center); - cell->AddChild(button.shortcutComposition); - } - { - button.subMenuArrowElement=common_styles::CommonFragmentBuilder::BuildRightArrow(); - - GuiCellComposition* cell=new GuiCellComposition; - button.subMenuArrowComposition=cell; - cell->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - table->AddChild(cell); - cell->SetSite(0, 4, 1, 1); - cell->SetOwnedElement(button.subMenuArrowElement); - cell->SetVisible(false); - } - } - return button; - } - - void Win8MenuItemButtonElements::Apply(const Win8ButtonColors& colors) - { - borderElement->SetColor(colors.borderColor); - backgroundElement->SetColors(colors.g1, colors.g2); - splitterElement->SetColor(colors.bullet); - textElement->SetColor(colors.textColor); - shortcutElement->SetColor(colors.textColor); - subMenuArrowElement->SetBackgroundColor(colors.textColor); - subMenuArrowElement->SetBorderColor(colors.textColor); - } - - void Win8MenuItemButtonElements::SetActive(bool value) - { - if(value) - { - splitterComposition->SetMargin(Margin(0, 1, 0, 2)); - } - else - { - splitterComposition->SetMargin(Margin(0, 0, 0, 0)); - } - } - - void Win8MenuItemButtonElements::SetSubMenuExisting(bool value) - { - subMenuArrowComposition->SetVisible(value); - } - -/*********************************************************************** -Win8TextBoxColors -***********************************************************************/ - - Win8TextBoxColors Win8TextBoxColors::Blend(const Win8TextBoxColors& c1, const Win8TextBoxColors& c2, vint ratio, vint total) - { - if(ratio<0) ratio=0; - else if(ratio>total) ratio=total; - - Win8TextBoxColors result; - result.borderColor=BlendColor(c1.borderColor, c2.borderColor, ratio, total); - result.backgroundColor=BlendColor(c1.backgroundColor, c2.backgroundColor, ratio, total); - return result; - } - - Win8TextBoxColors Win8TextBoxColors::Normal() - { - Win8TextBoxColors result= - { - Color(171, 173, 179), - Color(255, 255, 255), - }; - return result; - } - - Win8TextBoxColors Win8TextBoxColors::Active() - { - Win8TextBoxColors result= - { - Color(126, 180, 234), - Color(255, 255, 255), - }; - return result; - } - - Win8TextBoxColors Win8TextBoxColors::Focused() - { - Win8TextBoxColors result= - { - Color(86, 157, 229), - Color(255, 255, 255), - }; - return result; - } - - Win8TextBoxColors Win8TextBoxColors::Disabled() - { - Win8TextBoxColors result= - { - Color(217, 217, 217), - Win8GetSystemWindowColor(), - }; - return result; - } - -/*********************************************************************** -Helpers -***********************************************************************/ - - Color Win8GetSystemWindowColor() - { - return Color(240, 240, 240); - } - - Color Win8GetSystemTabContentColor() - { - return Color(255, 255, 255); - } - - Color Win8GetSystemBorderColor() - { - return Color(171, 173, 179); - } - - Color Win8GetSystemTextColor(bool enabled) - { - return enabled?Color(0, 0, 0):Color(131, 131, 131); - } - - Color Win8GetMenuBorderColor() - { - return Color(151, 151, 151); - } - - Color Win8GetMenuSplitterColor() - { - return Color(215, 215, 215); - } - - void Win8SetFont(GuiSolidLabelElement* element, GuiBoundsComposition* composition, const FontProperties& fontProperties) - { - vint margin=3; - element->SetFont(fontProperties); - composition->SetMargin(Margin(margin, margin, margin, margin)); - } - - void Win8CreateSolidLabelElement(GuiSolidLabelElement*& element, GuiBoundsComposition*& composition, Alignment horizontal, Alignment vertical) - { - element=GuiSolidLabelElement::Create(); - element->SetAlignments(horizontal, vertical); - - composition=new GuiBoundsComposition; - composition->SetOwnedElement(element); - composition->SetMargin(Margin(0, 0, 0, 0)); - composition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - composition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - } - - void Win8CreateSolidLabelElement(elements::GuiSolidLabelElement*& element, compositions::GuiSharedSizeItemComposition*& composition, const WString& group, Alignment horizontal, Alignment vertical) - { - element=GuiSolidLabelElement::Create(); - element->SetAlignments(horizontal, vertical); - - composition=new GuiSharedSizeItemComposition; - composition->SetGroup(group); - composition->SetSharedWidth(true); - composition->SetOwnedElement(element); - composition->SetMargin(Margin(0, 0, 0, 0)); - composition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - composition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - } - - elements::text::ColorEntry Win8GetTextBoxTextColor() - { - elements::text::ColorEntry entry; - entry.normal.text=Color(0, 0, 0); - entry.normal.background=Color(0, 0, 0, 0); - entry.selectedFocused.text=Color(255, 255, 255); - entry.selectedFocused.background=Color(51, 153, 255); - entry.selectedUnfocused.text=Color(255, 255, 255); - entry.selectedUnfocused.background=Color(51, 153, 255); - return entry; - } - } - } -} - -/*********************************************************************** -CONTROLS\STYLES\WIN8STYLES\GUIWIN8TABSTYLES.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace win8 - { - using namespace controls; - -/*********************************************************************** -Win8TabPageHeaderStyle -***********************************************************************/ - - void Win8TabPageHeaderStyle::TransferInternal(ButtonState value, bool enabled, bool selected) - { - if(selected) - { - transferringAnimation->Transfer(Win8ButtonColors::TabPageHeaderSelected()); - } - else - { - switch(value) - { - case ButtonState::Normal: - transferringAnimation->Transfer(Win8ButtonColors::TabPageHeaderNormal()); - break; - case ButtonState::Active: - case ButtonState::Pressed: - transferringAnimation->Transfer(Win8ButtonColors::TabPageHeaderActive()); - break; - } - } - } - - Win8TabPageHeaderStyle::Win8TabPageHeaderStyle() - :Win8ButtonStyleBase(Win8ButtonColors::TabPageHeaderNormal(), Alignment::Left, Alignment::Center) - { - transferringAnimation->SetEnableAnimation(false); - { - Margin margin=elements.backgroundComposition->GetAlignmentToParent(); - margin.bottom=0; - elements.backgroundComposition->SetAlignmentToParent(margin); - } - } - - Win8TabPageHeaderStyle::~Win8TabPageHeaderStyle() - { - } - - void Win8TabPageHeaderStyle::SetFont(const FontProperties& value) - { - Win8ButtonStyleBase::SetFont(value); - Margin margin=elements.textComposition->GetMargin(); - margin.left*=2; - margin.right*=2; - elements.textComposition->SetMargin(margin); - } - -/*********************************************************************** -Win8TabStyle -***********************************************************************/ - - controls::GuiSelectableButton::IStyleController* Win8TabStyle::CreateHeaderStyleController() - { - return new Win8TabPageHeaderStyle; - } - - controls::GuiButton::IStyleController* Win8TabStyle::CreateMenuButtonStyleController() - { - return new Win8ButtonStyle; - } - - controls::GuiToolstripMenu::IStyleController* Win8TabStyle::CreateMenuStyleController() - { - return new Win8MenuStyle; - } - - controls::GuiToolstripButton::IStyleController* Win8TabStyle::CreateMenuItemStyleController() - { - return new Win8MenuItemButtonStyle; - } - - Color Win8TabStyle::GetBorderColor() - { - return Win8ButtonColors::TabPageHeaderNormal().borderColor; - } - - Color Win8TabStyle::GetBackgroundColor() - { - return Win8GetSystemTabContentColor(); - } - - Win8TabStyle::Win8TabStyle() - :Win7TabStyle(false) - { - Initialize(); - } - - Win8TabStyle::~Win8TabStyle() - { - } - } - } -} - -/*********************************************************************** -CONTROLS\STYLES\WIN8STYLES\GUIWIN8TOOLSTRIPSTYLES.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace win8 - { - using namespace collections; - using namespace elements; - using namespace compositions; - using namespace controls; - -/*********************************************************************** -Win8WindowStyle -***********************************************************************/ - - Win8ToolstripToolBarStyle::Win8ToolstripToolBarStyle() - { - { - GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); - element->SetColor(Win8GetSystemWindowColor()); - - boundsComposition=new GuiBoundsComposition; - boundsComposition->SetOwnedElement(element); - boundsComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - } - { - Gui3DSplitterElement* element=Gui3DSplitterElement::Create(); - element->SetColors(Color(160, 160, 160), Color(255, 255, 255)); - element->SetDirection(Gui3DSplitterElement::Horizontal); - - GuiBoundsComposition* composition=new GuiBoundsComposition; - composition->SetPreferredMinSize(Size(0, 2)); - composition->SetAlignmentToParent(Margin(0, 0, 0, -1)); - composition->SetOwnedElement(element); - boundsComposition->AddChild(composition); - } - { - containerComposition=new GuiBoundsComposition; - containerComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - containerComposition->SetAlignmentToParent(Margin(0, 2, 0, 0)); - boundsComposition->AddChild(containerComposition); - } - } - - Win8ToolstripToolBarStyle::~Win8ToolstripToolBarStyle() - { - } - - compositions::GuiBoundsComposition* Win8ToolstripToolBarStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win8ToolstripToolBarStyle::GetContainerComposition() - { - return containerComposition; - } - - void Win8ToolstripToolBarStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win8ToolstripToolBarStyle::SetText(const WString& value) - { - } - - void Win8ToolstripToolBarStyle::SetFont(const FontProperties& value) - { - } - - void Win8ToolstripToolBarStyle::SetVisuallyEnabled(bool value) - { - } - -/*********************************************************************** -Win8ToolstripButtonDropdownStyle -***********************************************************************/ - - void Win8ToolstripButtonDropdownStyle::TransferInternal(controls::ButtonState value, bool enabled) - { - splitterComposition->SetVisible(value != ButtonState::Normal && enabled); - } - - Win8ToolstripButtonDropdownStyle::Win8ToolstripButtonDropdownStyle() - :isVisuallyEnabled(false) - ,controlState(ButtonState::Normal) - { - boundsComposition=new GuiBoundsComposition; - boundsComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - { - GuiSolidBorderElement* splitterElement=GuiSolidBorderElement::Create(); - splitterElement->SetColor(Color(132, 132, 132)); - - splitterComposition=new GuiBoundsComposition; - splitterComposition->SetAlignmentToParent(Margin(0, 3, -1, 3)); - splitterComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - splitterComposition->SetOwnedElement(splitterElement); - splitterComposition->SetPreferredMinSize(Size(1, 0)); - splitterComposition->SetVisible(false); - boundsComposition->AddChild(splitterComposition); - } - { - containerComposition=new GuiBoundsComposition; - containerComposition->SetAlignmentToParent(Margin(4, 0, 4, 0)); - containerComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - boundsComposition->AddChild(containerComposition); - } - } - - Win8ToolstripButtonDropdownStyle::~Win8ToolstripButtonDropdownStyle() - { - } - - compositions::GuiBoundsComposition* Win8ToolstripButtonDropdownStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win8ToolstripButtonDropdownStyle::GetContainerComposition() - { - return containerComposition; - } - - void Win8ToolstripButtonDropdownStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win8ToolstripButtonDropdownStyle::SetText(const WString& value) - { - } - - void Win8ToolstripButtonDropdownStyle::SetFont(const FontProperties& value) - { - } - - void Win8ToolstripButtonDropdownStyle::SetVisuallyEnabled(bool value) - { - if(isVisuallyEnabled!=value) - { - isVisuallyEnabled=value; - TransferInternal(controlState, isVisuallyEnabled); - } - } - - void Win8ToolstripButtonDropdownStyle::Transfer(controls::ButtonState value) - { - if(controlState!=value) - { - controlState=value; - TransferInternal(controlState, isVisuallyEnabled); - } - } - -/*********************************************************************** -Win8ToolstripButtonStyle -***********************************************************************/ - - IMPLEMENT_TRANSFERRING_ANIMATION(Win8ButtonColors, Win8ToolstripButtonStyle) - { - colorCurrent=Win8ButtonColors::Blend(colorBegin, colorEnd, currentPosition, totalLength); - style->elements.Apply(colorCurrent); - } - - void Win8ToolstripButtonStyle::TransferInternal(ButtonState value, bool enabled, bool selected, bool menuOpening) - { - Win8ButtonColors targetColor; - if(enabled) - { - if(menuOpening) - { - value=ButtonState::Pressed; - } - switch(value) - { - case ButtonState::Normal: - targetColor=selected?Win8ButtonColors::ToolstripButtonSelected():Win8ButtonColors::ToolstripButtonNormal(); - break; - case ButtonState::Active: - targetColor=selected?Win8ButtonColors::ToolstripButtonSelected():Win8ButtonColors::ToolstripButtonActive(); - break; - case ButtonState::Pressed: - targetColor=Win8ButtonColors::ToolstripButtonPressed(); - break; - } - } - else - { - targetColor=Win8ButtonColors::ToolstripButtonDisabled(); - } - transferringAnimation->Transfer(targetColor); - } - - Win8ToolstripButtonStyle::Win8ToolstripButtonStyle(ButtonStyle _buttonStyle) - :controlStyle(ButtonState::Normal) - ,isVisuallyEnabled(true) - ,isSelected(false) - ,isOpening(false) - ,buttonStyle(_buttonStyle) - ,subMenuHost(0) - { - elements=Win8ButtonElements::Create(Alignment::Center, Alignment::Center); - elements.Apply(Win8ButtonColors::ToolstripButtonNormal()); - transferringAnimation=new TransferringAnimation(this, Win8ButtonColors::ToolstripButtonNormal()); - - elements.textComposition->SetMinSizeLimitation(GuiGraphicsComposition::NoLimit); - imageElement=GuiImageFrameElement::Create(); - imageComposition=new GuiBoundsComposition; - imageComposition->SetOwnedElement(imageElement); - imageComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - imageComposition->SetAlignmentToParent(Margin(4, 4, 4, 4)); - - if(_buttonStyle==CommandButton) - { - GetContainerComposition()->AddChild(imageComposition); - } - else - { - GuiTableComposition* table=new GuiTableComposition; - table->SetAlignmentToParent(Margin(0, 0, 0, 0)); - table->SetRowsAndColumns(1, 2); - table->SetRowOption(0, GuiCellOption::PercentageOption(1.0)); - table->SetColumnOption(0, GuiCellOption::PercentageOption(1.0)); - table->SetColumnOption(1, GuiCellOption::MinSizeOption()); - - { - GuiCellComposition* cell=new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 0, 1, 1); - - cell->AddChild(imageComposition); - } - { - GuiCellComposition* cell=new GuiCellComposition; - table->AddChild(cell); - cell->SetSite(0, 1, 1, 1); - GuiPolygonElement* arrow=0; - GuiBoundsComposition* arrowComposition=common_styles::CommonFragmentBuilder::BuildDownArrow(arrow); - - switch(_buttonStyle) - { - case DropdownButton: - { - arrowComposition->SetAlignmentToParent(Margin(0, 0, 4, 0)); - cell->AddChild(arrowComposition); - } - break; - case SplitButton: - { - - subMenuHost=new GuiButton(new Win8ToolstripButtonDropdownStyle); - subMenuHost->GetContainerComposition()->AddChild(arrowComposition); - subMenuHost->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); - cell->AddChild(subMenuHost->GetBoundsComposition()); - } - break; - default:; - } - } - GetContainerComposition()->AddChild(table); - } - } - - Win8ToolstripButtonStyle::~Win8ToolstripButtonStyle() - { - transferringAnimation->Disable(); - } - - compositions::GuiBoundsComposition* Win8ToolstripButtonStyle::GetBoundsComposition() - { - return elements.mainComposition; - } - - compositions::GuiGraphicsComposition* Win8ToolstripButtonStyle::GetContainerComposition() - { - return elements.mainComposition; - } - - void Win8ToolstripButtonStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win8ToolstripButtonStyle::SetText(const WString& value) - { - } - - void Win8ToolstripButtonStyle::SetFont(const FontProperties& value) - { - Win8SetFont(elements.textElement, elements.textComposition, value); - } - - void Win8ToolstripButtonStyle::SetVisuallyEnabled(bool value) - { - if(isVisuallyEnabled!=value) - { - isVisuallyEnabled=value; - imageElement->SetEnabled(value); - TransferInternal(controlStyle, isVisuallyEnabled, isSelected, isOpening); - } - } - - void Win8ToolstripButtonStyle::SetSelected(bool value) - { - if(isSelected!=value) - { - isSelected=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected, isOpening); - } - } - - controls::GuiMenu::IStyleController* Win8ToolstripButtonStyle::CreateSubMenuStyleController() - { - return new Win8MenuStyle; - } - - void Win8ToolstripButtonStyle::SetSubMenuExisting(bool value) - { - } - - void Win8ToolstripButtonStyle::SetSubMenuOpening(bool value) - { - if(isOpening!=value) - { - isOpening=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected, isOpening); - } - } - - controls::GuiButton* Win8ToolstripButtonStyle::GetSubMenuHost() - { - return subMenuHost; - } - - void Win8ToolstripButtonStyle::SetImage(Ptr value) - { - if(value) - { - imageElement->SetImage(value->GetImage(), value->GetFrameIndex()); - } - else - { - imageElement->SetImage(0, 0); - } - } - - void Win8ToolstripButtonStyle::SetShortcutText(const WString& value) - { - } - - void Win8ToolstripButtonStyle::Transfer(controls::ButtonState value) - { - if(controlStyle!=value) - { - controlStyle=value; - TransferInternal(controlStyle, isVisuallyEnabled, isSelected, isOpening); - } - } - -/*********************************************************************** -Win8ToolstripSplitterStyle -***********************************************************************/ - - Win8ToolstripSplitterStyle::Win8ToolstripSplitterStyle() - { - GuiBoundsComposition* bounds=new GuiBoundsComposition; - bounds->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - boundsComposition=bounds; - - GuiSolidBackgroundElement* backgroundElement=GuiSolidBackgroundElement::Create(); - bounds->SetOwnedElement(backgroundElement); - backgroundElement->SetColor(Win8GetSystemWindowColor()); - - GuiBoundsComposition* splitterComposition=new GuiBoundsComposition; - bounds->AddChild(splitterComposition); - splitterComposition->SetPreferredMinSize(Size(1, 0)); - splitterComposition->SetAlignmentToParent(Margin(3, 3, 3, 3)); - - GuiSolidBorderElement* splitterElement=GuiSolidBorderElement::Create(); - splitterComposition->SetOwnedElement(splitterElement); - splitterElement->SetColor(Color(132, 132, 132)); - } - - Win8ToolstripSplitterStyle::~Win8ToolstripSplitterStyle() - { - } - - compositions::GuiBoundsComposition* Win8ToolstripSplitterStyle::GetBoundsComposition() - { - return boundsComposition; - } - - compositions::GuiGraphicsComposition* Win8ToolstripSplitterStyle::GetContainerComposition() - { - return boundsComposition; - } - - void Win8ToolstripSplitterStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - } - - void Win8ToolstripSplitterStyle::SetText(const WString& value) - { - } - - void Win8ToolstripSplitterStyle::SetFont(const FontProperties& value) - { - } - - void Win8ToolstripSplitterStyle::SetVisuallyEnabled(bool value) - { - } - } - } -} - -/*********************************************************************** -CONTROLS\TEMPLATES\GUICONTROLTEMPLATES.CPP +.\CONTROLS\TEMPLATES\GUICONTROLTEMPLATES.CPP ***********************************************************************/ namespace vl @@ -22377,7 +11477,7 @@ GuiInstanceRootObject return finalized; } - void GuiInstanceRootObject::FinalizeInstanceRecursively(compositions::GuiGraphicsComposition* thisObject) + void GuiInstanceRootObject::FinalizeInstanceRecursively(templates::GuiTemplate* thisObject) { if (!finalized) { @@ -22385,7 +11485,7 @@ GuiInstanceRootObject } } - void GuiInstanceRootObject::FinalizeInstanceRecursively(GuiControl* thisObject) + void GuiInstanceRootObject::FinalizeInstanceRecursively(GuiCustomControl* thisObject) { if (!finalized) { @@ -22393,6 +11493,18 @@ GuiInstanceRootObject } } + void GuiInstanceRootObject::FinalizeInstanceRecursively(GuiControlHost* thisObject) + { + if (!finalized) + { + NotifyFinalizeInstance(thisObject); + } + } + + void GuiInstanceRootObject::FinalizeGeneralInstance(GuiInstanceRootObject* thisObject) + { + } + void GuiInstanceRootObject::SetResourceResolver(Ptr resolver) { resourceResolver = resolver; @@ -22972,1059 +12084,1948 @@ GuiGridEditorTemplate } /*********************************************************************** -CONTROLS\TEMPLATES\GUICONTROLTEMPLATESTYLES.CPP +.\CONTROLS\TOOLSTRIPPACKAGE\GUIMENUCONTROLS.CPP ***********************************************************************/ namespace vl { namespace presentation { - namespace templates + namespace controls { using namespace compositions; - using namespace elements; - using namespace controls; - using namespace controls::list; - using namespace reflection::description; - using namespace collections; - -#define GET_FACTORY_FROM_TEMPLATE(TEMPLATE, PROPERTY)\ - return new TEMPLATE##_StyleProvider(controlTemplate->Get##PROPERTY());\ - -#define GET_FACTORY_FROM_TEMPLATE_OPT(TEMPLATE, PROPERTY)\ - if (!controlTemplate->Get##PROPERTY())\ - {\ - return nullptr;\ - }\ - GET_FACTORY_FROM_TEMPLATE(TEMPLATE, PROPERTY)\ /*********************************************************************** -GuiControlTemplate_StyleProvider +IGuiMenuService ***********************************************************************/ - GuiControlTemplate_StyleProvider::GuiControlTemplate_StyleProvider(TemplateProperty factory, description::Value viewModel) - :associatedStyleController(0) - , controlTemplate(factory(viewModel)) - { - CHECK_ERROR(controlTemplate, L"GuiControlTemplate_StyleProvider::GuiControlTemplate_StyleProvider()#An instance of GuiControlTemplate is expected."); - } + const wchar_t* const IGuiMenuService::Identifier = L"vl::presentation::controls::IGuiMenuService"; - GuiControlTemplate_StyleProvider::~GuiControlTemplate_StyleProvider() + IGuiMenuService::IGuiMenuService() + :openingMenu(0) { } - compositions::GuiBoundsComposition* GuiControlTemplate_StyleProvider::GetBoundsComposition() + void IGuiMenuService::MenuItemExecuted() { - return controlTemplate; - } - - compositions::GuiGraphicsComposition* GuiControlTemplate_StyleProvider::GetContainerComposition() - { - return controlTemplate->GetContainerComposition(); - } - - void GuiControlTemplate_StyleProvider::AssociateStyleController(controls::GuiControl::IStyleController* controller) - { - associatedStyleController = controller; - } - - void GuiControlTemplate_StyleProvider::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - controlTemplate->SetFocusableComposition(value); - } - - void GuiControlTemplate_StyleProvider::SetText(const WString& value) - { - controlTemplate->SetText(value); - } - - void GuiControlTemplate_StyleProvider::SetFont(const FontProperties& value) - { - controlTemplate->SetFont(value); - } - - void GuiControlTemplate_StyleProvider::SetVisuallyEnabled(bool value) - { - controlTemplate->SetVisuallyEnabled(value); - } - -/*********************************************************************** -GuiLabelTemplate_StyleProvider -***********************************************************************/ - - GuiLabelTemplate_StyleProvider::GuiLabelTemplate_StyleProvider(TemplateProperty factory) - :GuiControlTemplate_StyleProvider(factory) - { - if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + if(openingMenu) { - CHECK_FAIL(L"GuiLabelTemplate_StyleProvider::GuiLabelTemplate_StyleProvider()#An instance of GuiLabelTemplate is expected."); + openingMenu->Hide(); + } + if(GetParentMenuService()) + { + GetParentMenuService()->MenuItemExecuted(); } } - GuiLabelTemplate_StyleProvider::~GuiLabelTemplate_StyleProvider() + GuiMenu* IGuiMenuService::GetOpeningMenu() { + return openingMenu; } - Color GuiLabelTemplate_StyleProvider::GetDefaultTextColor() + void IGuiMenuService::MenuOpened(GuiMenu* menu) { - return controlTemplate->GetDefaultTextColor(); - } - - void GuiLabelTemplate_StyleProvider::SetTextColor(Color value) - { - controlTemplate->SetTextColor(value); - } - -/*********************************************************************** -GuiSinglelineTextBoxTemplate_StyleProvider -***********************************************************************/ - - GuiSinglelineTextBoxTemplate_StyleProvider::GuiSinglelineTextBoxTemplate_StyleProvider(TemplateProperty factory) - :GuiControlTemplate_StyleProvider(factory) - { - if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + if(openingMenu!=menu && openingMenu) { - CHECK_FAIL(L"GuiSinglelineTextBoxTemplate_StyleProvider::GuiSinglelineTextBoxTemplate_StyleProvider()#An instance of GuiSinglelineTextBoxTemplate is expected."); + openingMenu->Hide(); } + openingMenu=menu; } - GuiSinglelineTextBoxTemplate_StyleProvider::~GuiSinglelineTextBoxTemplate_StyleProvider() + void IGuiMenuService::MenuClosed(GuiMenu* menu) { - } - - void GuiSinglelineTextBoxTemplate_StyleProvider::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - GuiControlTemplate_StyleProvider::SetFocusableComposition(value); - if (auto style = dynamic_cast(associatedStyleController)) + if(openingMenu==menu) { - auto element = style->GetTextElement(); - Array colors(1); - colors[0] = controlTemplate->GetTextColor(); - element->SetColors(colors); - element->SetCaretColor(controlTemplate->GetCaretColor()); - } - } - - compositions::GuiGraphicsComposition* GuiSinglelineTextBoxTemplate_StyleProvider::InstallBackground(compositions::GuiBoundsComposition* boundsComposition) - { - controlTemplate->SetAlignmentToParent(Margin(0, 0, 0, 0)); - boundsComposition->AddChild(controlTemplate); - return controlTemplate->GetContainerComposition(); - } - -/*********************************************************************** -GuiDocumentLabelTemplate_StyleProvider -***********************************************************************/ - - GuiDocumentLabelTemplate_StyleProvider::GuiDocumentLabelTemplate_StyleProvider(TemplateProperty factory) - :GuiControlTemplate_StyleProvider(factory) - { - if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) - { - CHECK_FAIL(L"GuiDocumentLabelTemplate_StyleProvider::GuiDocumentLabelTemplate_StyleProvider()#An instance of GuiDocumentLabelTemplate is expected."); - } - } - - GuiDocumentLabelTemplate_StyleProvider::~GuiDocumentLabelTemplate_StyleProvider() - { - } - - Ptr GuiDocumentLabelTemplate_StyleProvider::GetBaselineDocument() - { - return controlTemplate->GetBaselineDocument(); - } - - Color GuiDocumentLabelTemplate_StyleProvider::GetCaretColor() - { - return controlTemplate->GetCaretColor(); - } - -/*********************************************************************** -GuiMenuTemplate_StyleProvider -***********************************************************************/ - - GuiMenuTemplate_StyleProvider::GuiMenuTemplate_StyleProvider(TemplateProperty factory) - :GuiControlTemplate_StyleProvider(factory) - { - } - - GuiMenuTemplate_StyleProvider::~GuiMenuTemplate_StyleProvider() - { - } - -/*********************************************************************** -GuiWindowTemplate_StyleProvider -***********************************************************************/ - - GuiWindowTemplate_StyleProvider::GuiWindowTemplate_StyleProvider(TemplateProperty factory) - :GuiControlTemplate_StyleProvider(factory) - , window(0) - { - if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) - { - CHECK_FAIL(L"GuiWindowTemplate_StyleProvider::GuiWindowTemplate_StyleProvider()#An instance of GuiWindowTemplate is expected."); - } - } - - GuiWindowTemplate_StyleProvider::~GuiWindowTemplate_StyleProvider() - { - } - - void GuiWindowTemplate_StyleProvider::AttachWindow(GuiWindow* _window) - { - window = _window; - } - - void GuiWindowTemplate_StyleProvider::InitializeNativeWindowProperties() - { - if (window && window->GetNativeWindow()) - { - window->GetNativeWindow()->EnableCustomFrameMode(); - window->GetNativeWindow()->SetBorder(false); - } - } - - void GuiWindowTemplate_StyleProvider::SetSizeState(INativeWindow::WindowSizeState value) - { - controlTemplate->SetMaximized(value == INativeWindow::Maximized); - } - -#define WINDOW_TEMPLATE_GET(PROPERTY)\ - switch (controlTemplate->Get##PROPERTY##Option())\ - {\ - case BoolOption::AlwaysTrue: return true;\ - case BoolOption::AlwaysFalse: return false;\ - default: return controlTemplate->Get##PROPERTY();\ - }\ - -#define WINDOW_TEMPLATE_SET(PROPERTY)\ - if (controlTemplate->Get##PROPERTY##Option() == BoolOption::Customizable)\ - {\ - controlTemplate->Set##PROPERTY(visible);\ - if (!controlTemplate->GetCustomizedBorder() && window && window->GetNativeWindow())\ - {\ - window->GetNativeWindow()->Set##PROPERTY(visible);\ - }\ - }\ - - bool GuiWindowTemplate_StyleProvider::GetMaximizedBox() - { - WINDOW_TEMPLATE_GET(MaximizedBox); - } - - void GuiWindowTemplate_StyleProvider::SetMaximizedBox(bool visible) - { - WINDOW_TEMPLATE_SET(MaximizedBox); - } - - bool GuiWindowTemplate_StyleProvider::GetMinimizedBox() - { - WINDOW_TEMPLATE_GET(MinimizedBox); - } - - void GuiWindowTemplate_StyleProvider::SetMinimizedBox(bool visible) - { - WINDOW_TEMPLATE_SET(MinimizedBox); - } - - bool GuiWindowTemplate_StyleProvider::GetBorder() - { - WINDOW_TEMPLATE_GET(Border); - } - - void GuiWindowTemplate_StyleProvider::SetBorder(bool visible) - { - WINDOW_TEMPLATE_SET(Border); - } - - bool GuiWindowTemplate_StyleProvider::GetSizeBox() - { - WINDOW_TEMPLATE_GET(SizeBox); - } - - void GuiWindowTemplate_StyleProvider::SetSizeBox(bool visible) - { - WINDOW_TEMPLATE_SET(SizeBox); - } - - bool GuiWindowTemplate_StyleProvider::GetIconVisible() - { - WINDOW_TEMPLATE_GET(IconVisible); - } - - void GuiWindowTemplate_StyleProvider::SetIconVisible(bool visible) - { - WINDOW_TEMPLATE_SET(IconVisible); - } - - bool GuiWindowTemplate_StyleProvider::GetTitleBar() - { - WINDOW_TEMPLATE_GET(TitleBar); - } - - void GuiWindowTemplate_StyleProvider::SetTitleBar(bool visible) - { - WINDOW_TEMPLATE_SET(TitleBar); - } - - controls::GuiWindow::IStyleController* GuiWindowTemplate_StyleProvider::CreateTooltipStyle() - { - GET_FACTORY_FROM_TEMPLATE_OPT(GuiWindowTemplate, TooltipTemplate); - } - - controls::GuiLabel::IStyleController* GuiWindowTemplate_StyleProvider::CreateShortcutKeyStyle() - { - GET_FACTORY_FROM_TEMPLATE_OPT(GuiLabelTemplate, ShortcutKeyTemplate); - } - -#undef WINDOW_TEMPLATE_GET -#undef WINDOW_TEMPLATE_SET - -/*********************************************************************** -GuiButtonTemplate_StyleProvider -***********************************************************************/ - - GuiButtonTemplate_StyleProvider::GuiButtonTemplate_StyleProvider(TemplateProperty factory) - :GuiControlTemplate_StyleProvider(factory) - { - if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) - { - CHECK_FAIL(L"GuiButtonTemplate_StyleProvider::GuiButtonTemplate_StyleProvider()#An instance of GuiButtonTemplate is expected."); - } - } - - GuiButtonTemplate_StyleProvider::~GuiButtonTemplate_StyleProvider() - { - } - - void GuiButtonTemplate_StyleProvider::Transfer(controls::ButtonState value) - { - controlTemplate->SetState(value); - } - -/*********************************************************************** -GuiSelectableButtonTemplate_StyleProvider -***********************************************************************/ - - GuiSelectableButtonTemplate_StyleProvider::GuiSelectableButtonTemplate_StyleProvider(TemplateProperty factory) - :GuiButtonTemplate_StyleProvider(factory) - { - if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) - { - CHECK_FAIL(L"GuiButtonTemplate_StyleProvider::GuiButtonTemplate_StyleProvider()#An instance of GuiSelectableButtonTemplate is expected."); - } - } - - GuiSelectableButtonTemplate_StyleProvider::~GuiSelectableButtonTemplate_StyleProvider() - { - } - - void GuiSelectableButtonTemplate_StyleProvider::SetSelected(bool value) - { - controlTemplate->SetSelected(value); - } - -/*********************************************************************** -GuiToolstripButtonTemplate_StyleProvider -***********************************************************************/ - - GuiToolstripButtonTemplate_StyleProvider::GuiToolstripButtonTemplate_StyleProvider(TemplateProperty factory) - :GuiSelectableButtonTemplate_StyleProvider(factory) - { - if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) - { - CHECK_FAIL(L"GuiButtonTemplate_StyleProvider::GuiButtonTemplate_StyleProvider()#An instance of GuiToolstripButtonTemplate is expected."); - } - } - - GuiToolstripButtonTemplate_StyleProvider::~GuiToolstripButtonTemplate_StyleProvider() - { - } - - controls::GuiMenu::IStyleController* GuiToolstripButtonTemplate_StyleProvider::CreateSubMenuStyleController() - { - GET_FACTORY_FROM_TEMPLATE(GuiMenuTemplate, SubMenuTemplate); - } - - void GuiToolstripButtonTemplate_StyleProvider::SetSubMenuExisting(bool value) - { - controlTemplate->SetSubMenuExisting(value); - } - - void GuiToolstripButtonTemplate_StyleProvider::SetSubMenuOpening(bool value) - { - controlTemplate->SetSubMenuOpening(value); - } - - controls::GuiButton* GuiToolstripButtonTemplate_StyleProvider::GetSubMenuHost() - { - return controlTemplate->GetSubMenuHost(); - } - - void GuiToolstripButtonTemplate_StyleProvider::SetImage(Ptr value) - { - controlTemplate->SetImage(value); - } - - void GuiToolstripButtonTemplate_StyleProvider::SetShortcutText(const WString& value) - { - controlTemplate->SetShortcutText(value); - } - -/*********************************************************************** -GuiListViewColumnHeaderTemplate_StyleProvider -***********************************************************************/ - - GuiListViewColumnHeaderTemplate_StyleProvider::GuiListViewColumnHeaderTemplate_StyleProvider(TemplateProperty factory) - :GuiToolstripButtonTemplate_StyleProvider(factory) - { - if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) - { - CHECK_FAIL(L"GuiListViewColumnHeaderTemplate_StyleProvider::GuiListViewColumnHeaderTemplate_StyleProvider()#An instance of GuiListViewColumnHeaderTemplate is expected."); - } - } - - GuiListViewColumnHeaderTemplate_StyleProvider::~GuiListViewColumnHeaderTemplate_StyleProvider() - { - } - - void GuiListViewColumnHeaderTemplate_StyleProvider::SetColumnSortingState(controls::ColumnSortingState value) - { - controlTemplate->SetSortingState(value); - } - -/*********************************************************************** -GuiComboBoxTemplate_StyleProvider -***********************************************************************/ - - GuiComboBoxTemplate_StyleProvider::GuiComboBoxTemplate_StyleProvider(TemplateProperty factory) - :GuiToolstripButtonTemplate_StyleProvider(factory) - { - if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) - { - CHECK_FAIL(L"GuiComboBoxTemplate_StyleProvider::GuiComboBoxTemplate_StyleProvider()#An instance of GuiComboBoxTemplate is expected."); - } - } - - GuiComboBoxTemplate_StyleProvider::~GuiComboBoxTemplate_StyleProvider() - { - } - - void GuiComboBoxTemplate_StyleProvider::SetCommandExecutor(controls::IComboBoxCommandExecutor* value) - { - controlTemplate->SetCommands(value); - } - - void GuiComboBoxTemplate_StyleProvider::OnItemSelected() - { - } - - void GuiComboBoxTemplate_StyleProvider::SetTextVisible(bool value) - { - controlTemplate->SetTextVisible(value); - } - -/*********************************************************************** -GuiScrollTemplate_StyleProvider -***********************************************************************/ - - GuiScrollTemplate_StyleProvider::GuiScrollTemplate_StyleProvider(TemplateProperty factory) - :GuiControlTemplate_StyleProvider(factory) - { - if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) - { - CHECK_FAIL(L"GuiButtonTemplate_StyleProvider::GuiButtonTemplate_StyleProvider()#An instance of GuiScrollTemplate is expected."); - } - } - - GuiScrollTemplate_StyleProvider::~GuiScrollTemplate_StyleProvider() - { - } - - void GuiScrollTemplate_StyleProvider::SetCommandExecutor(controls::IScrollCommandExecutor* value) - { - controlTemplate->SetCommands(value); - } - - void GuiScrollTemplate_StyleProvider::SetTotalSize(vint value) - { - controlTemplate->SetTotalSize(value); - } - - void GuiScrollTemplate_StyleProvider::SetPageSize(vint value) - { - controlTemplate->SetPageSize(value); - } - - void GuiScrollTemplate_StyleProvider::SetPosition(vint value) - { - controlTemplate->SetPosition(value); - } - -/*********************************************************************** -GuiScrollViewTemplate_StyleProvider -***********************************************************************/ - - GuiScrollViewTemplate_StyleProvider::GuiScrollViewTemplate_StyleProvider(TemplateProperty factory) - :GuiControlTemplate_StyleProvider(factory) - { - if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) - { - CHECK_FAIL(L"GuiScrollViewTemplate_StyleProvider::GuiScrollViewTemplate_StyleProvider()#An instance of GuiScrollViewTemplate is expected."); - } - } - - GuiScrollViewTemplate_StyleProvider::~GuiScrollViewTemplate_StyleProvider() - { - } - - controls::GuiScroll::IStyleController* GuiScrollViewTemplate_StyleProvider::CreateHorizontalScrollStyle() - { - GET_FACTORY_FROM_TEMPLATE(GuiScrollTemplate, HScrollTemplate); - } - - controls::GuiScroll::IStyleController* GuiScrollViewTemplate_StyleProvider::CreateVerticalScrollStyle() - { - GET_FACTORY_FROM_TEMPLATE(GuiScrollTemplate, VScrollTemplate); - } - - vint GuiScrollViewTemplate_StyleProvider::GetDefaultScrollSize() - { - return controlTemplate->GetDefaultScrollSize(); - } - - compositions::GuiGraphicsComposition* GuiScrollViewTemplate_StyleProvider::InstallBackground(compositions::GuiBoundsComposition* boundsComposition) - { - controlTemplate->SetAlignmentToParent(Margin(0, 0, 0, 0)); - boundsComposition->AddChild(controlTemplate); - return controlTemplate->GetContainerComposition(); - } - -/*********************************************************************** -GuiSinglelineTextBoxTemplate_StyleProvider -***********************************************************************/ - - GuiMultilineTextBoxTemplate_StyleProvider::GuiMultilineTextBoxTemplate_StyleProvider(TemplateProperty factory) - :GuiScrollViewTemplate_StyleProvider(factory) - { - if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) - { - CHECK_FAIL(L"GuiMultilineTextBoxTemplate_StyleProvider::GuiMultilineTextBoxTemplate_StyleProvider()#An instance of GuiMultilineTextBoxTemplate is expected."); - } - } - - GuiMultilineTextBoxTemplate_StyleProvider::~GuiMultilineTextBoxTemplate_StyleProvider() - { - } - - void GuiMultilineTextBoxTemplate_StyleProvider::SetFocusableComposition(compositions::GuiGraphicsComposition* value) - { - GuiScrollViewTemplate_StyleProvider::SetFocusableComposition(value); - if (auto style = dynamic_cast(associatedStyleController)) - { - auto element = style->GetTextElement(); - Array colors(1); - colors[0] = controlTemplate->GetTextColor(); - element->SetColors(colors); - element->SetCaretColor(controlTemplate->GetCaretColor()); + openingMenu=0; } } /*********************************************************************** -GuiDocumentViewerTemplate_StyleProvider +GuiMenu ***********************************************************************/ - GuiDocumentViewerTemplate_StyleProvider::GuiDocumentViewerTemplate_StyleProvider(TemplateProperty factory) - :GuiScrollViewTemplate_StyleProvider(factory) + IGuiMenuService* GuiMenu::GetParentMenuService() { - if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + return parentMenuService; + } + + IGuiMenuService::Direction GuiMenu::GetPreferredDirection() + { + return IGuiMenuService::Vertical; + } + + bool GuiMenu::IsActiveState() + { + return true; + } + + bool GuiMenu::IsSubMenuActivatedByMouseDown() + { + return false; + } + + void GuiMenu::MenuItemExecuted() + { + IGuiMenuService::MenuItemExecuted(); + Hide(); + } + + void GuiMenu::OnWindowOpened(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + if(parentMenuService) { - CHECK_FAIL(L"GuiDocumentViewerTemplate_StyleProvider::GuiDocumentViewerTemplate_StyleProvider()#An instance of GuiDocumentViewerTemplate is expected."); + parentMenuService->MenuOpened(this); } } - GuiDocumentViewerTemplate_StyleProvider::~GuiDocumentViewerTemplate_StyleProvider() + void GuiMenu::OnDeactivatedAltHost() { + Hide(); } - Ptr GuiDocumentViewerTemplate_StyleProvider::GetBaselineDocument() + void GuiMenu::MouseClickedOnOtherWindow(GuiWindow* window) { - return controlTemplate->GetBaselineDocument(); - } - - Color GuiDocumentViewerTemplate_StyleProvider::GetCaretColor() - { - return controlTemplate->GetCaretColor(); - } - -/*********************************************************************** -GuiTextListTemplate_StyleProvider -***********************************************************************/ - - GuiTextListTemplate_StyleProvider::GuiTextListTemplate_StyleProvider(TemplateProperty factory) - :GuiScrollViewTemplate_StyleProvider(factory) - { - if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + GuiMenu* targetMenu=dynamic_cast(window); + if(!targetMenu) { - CHECK_FAIL(L"GuiTextListTemplate_StyleProvider::GuiTextListTemplate_StyleProvider()#An instance of GuiTextListTemplate is expected."); + Hide(); } } - GuiTextListTemplate_StyleProvider::~GuiTextListTemplate_StyleProvider() + void GuiMenu::OnWindowClosed(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) { - } - - Color GuiTextListTemplate_StyleProvider::GetTextColor() - { - return controlTemplate->GetTextColor(); - } - - controls::GuiSelectableButton::IStyleController* GuiTextListTemplate_StyleProvider::CreateItemBackground() - { - GET_FACTORY_FROM_TEMPLATE_OPT(GuiSelectableButtonTemplate, BackgroundTemplate); - } - - controls::GuiSelectableButton::IStyleController* GuiTextListTemplate_StyleProvider::CreateCheckBulletStyle() - { - GET_FACTORY_FROM_TEMPLATE_OPT(GuiSelectableButtonTemplate, CheckBulletTemplate); - } - - controls::GuiSelectableButton::IStyleController* GuiTextListTemplate_StyleProvider::CreateRadioBulletStyle() - { - GET_FACTORY_FROM_TEMPLATE_OPT(GuiSelectableButtonTemplate, RadioBulletTemplate); - } - -/*********************************************************************** -GuiListViewTemplate_StyleProvider -***********************************************************************/ - - GuiListViewTemplate_StyleProvider::GuiListViewTemplate_StyleProvider(TemplateProperty factory) - :GuiScrollViewTemplate_StyleProvider(factory) - { - if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + if(parentMenuService) { - CHECK_FAIL(L"GuiListViewTemplate_StyleProvider::GuiListViewTemplate_StyleProvider()#An instance of GuiListViewTemplate is expected."); - } - } - - GuiListViewTemplate_StyleProvider::~GuiListViewTemplate_StyleProvider() - { - } - - controls::GuiSelectableButton::IStyleController* GuiListViewTemplate_StyleProvider::CreateItemBackground() - { - GET_FACTORY_FROM_TEMPLATE_OPT(GuiSelectableButtonTemplate, BackgroundTemplate); - } - - controls::GuiListViewColumnHeader::IStyleController* GuiListViewTemplate_StyleProvider::CreateColumnStyle() - { - GET_FACTORY_FROM_TEMPLATE(GuiListViewColumnHeaderTemplate, ColumnHeaderTemplate); - } - - Color GuiListViewTemplate_StyleProvider::GetPrimaryTextColor() - { - return controlTemplate->GetPrimaryTextColor(); - } - - Color GuiListViewTemplate_StyleProvider::GetSecondaryTextColor() - { - return controlTemplate->GetSecondaryTextColor(); - } - - Color GuiListViewTemplate_StyleProvider::GetItemSeparatorColor() - { - return controlTemplate->GetItemSeparatorColor(); - } - -/*********************************************************************** -GuiTreeViewTemplate_StyleProvider -***********************************************************************/ - - GuiTreeViewTemplate_StyleProvider::GuiTreeViewTemplate_StyleProvider(TemplateProperty factory) - :GuiScrollViewTemplate_StyleProvider(factory) - { - if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) - { - CHECK_FAIL(L"GuiTreeViewTemplate_StyleProvider::GuiTreeViewTemplate_StyleProvider()#An instance of GuiTreeViewTemplate is expected."); - } - } - - GuiTreeViewTemplate_StyleProvider::~GuiTreeViewTemplate_StyleProvider() - { - } - - controls::GuiSelectableButton::IStyleController* GuiTreeViewTemplate_StyleProvider::CreateItemBackground() - { - GET_FACTORY_FROM_TEMPLATE_OPT(GuiSelectableButtonTemplate, BackgroundTemplate); - } - - controls::GuiSelectableButton::IStyleController* GuiTreeViewTemplate_StyleProvider::CreateItemExpandingDecorator() - { - GET_FACTORY_FROM_TEMPLATE_OPT(GuiSelectableButtonTemplate, ExpandingDecoratorTemplate); - } - - Color GuiTreeViewTemplate_StyleProvider::GetTextColor() - { - return controlTemplate->GetTextColor(); - } - -/*********************************************************************** -GuiTabTemplate_StyleProvider -***********************************************************************/ - - controls::GuiSelectableButton::IStyleController* GuiTabTemplate_StyleProvider::CreateHeaderTemplate() - { - GET_FACTORY_FROM_TEMPLATE(GuiSelectableButtonTemplate, HeaderTemplate); - } - - controls::GuiButton::IStyleController* GuiTabTemplate_StyleProvider::CreateDropdownTemplate() - { - GET_FACTORY_FROM_TEMPLATE(GuiButtonTemplate, DropdownTemplate); - } - - controls::GuiMenu::IStyleController* GuiTabTemplate_StyleProvider::CreateMenuTemplate() - { - GET_FACTORY_FROM_TEMPLATE(GuiMenuTemplate, MenuTemplate); - } - - controls::GuiToolstripButton::IStyleController* GuiTabTemplate_StyleProvider::CreateMenuItemTemplate() - { - GET_FACTORY_FROM_TEMPLATE(GuiToolstripButtonTemplate, MenuItemTemplate); - } - - void GuiTabTemplate_StyleProvider::OnHeaderButtonClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if(commandExecutor) - { - vint index=headerButtons.IndexOf(dynamic_cast(sender->GetAssociatedControl())); - if(index!=-1) + parentMenuService->MenuClosed(this); + GuiMenu* openingSubMenu=GetOpeningMenu(); + if(openingSubMenu) { - commandExecutor->ShowTab(index); + openingSubMenu->Hide(); } } } - void GuiTabTemplate_StyleProvider::OnTabHeaderBoundsChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + GuiMenu::GuiMenu(IStyleController* _styleController, GuiControl* _owner) + :GuiPopup(_styleController) + ,owner(_owner) + ,parentMenuService(0) { - vint height=headerOverflowButton->GetBoundsComposition()->GetBounds().Height(); - headerOverflowButton->GetBoundsComposition()->SetBounds(Rect(Point(0, 0), Size(height, 0))); - - UpdateHeaderLayout(); + GetNativeWindow()->SetAlwaysPassFocusToParent(true); + UpdateMenuService(); + WindowOpened.AttachMethod(this, &GuiMenu::OnWindowOpened); + WindowClosed.AttachMethod(this, &GuiMenu::OnWindowClosed); } - void GuiTabTemplate_StyleProvider::OnHeaderOverflowButtonClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + GuiMenu::~GuiMenu() { - headerOverflowMenu->SetClientSize(Size(0, 0)); - headerOverflowMenu->ShowPopup(headerOverflowButton, true); } - void GuiTabTemplate_StyleProvider::OnHeaderOverflowMenuButtonClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + void GuiMenu::UpdateMenuService() { - vint index=headerOverflowMenu->GetToolstripItems().IndexOf(sender->GetRelatedControl()); - commandExecutor->ShowTab(index); - } - - void GuiTabTemplate_StyleProvider::UpdateHeaderOverflowButtonVisibility() - { - if(tabHeaderComposition->IsStackItemClipped()) + if(owner) { - tabBoundsComposition->SetColumnOption(1, GuiCellOption::MinSizeOption()); + parentMenuService=owner->QueryTypedService(); + } + } + + IDescriptable* GuiMenu::QueryService(const WString& identifier) + { + if(identifier==IGuiMenuService::Identifier) + { + return (IGuiMenuService*)this; } else { - tabBoundsComposition->SetColumnOption(1, GuiCellOption::AbsoluteOption(0)); + return GuiPopup::QueryService(identifier); } - tabBoundsComposition->ForceCalculateSizeImmediately(); } - void GuiTabTemplate_StyleProvider::UpdateHeaderZOrder() +/*********************************************************************** +GuiMenuBar +***********************************************************************/ + + IGuiMenuService* GuiMenuBar::GetParentMenuService() { - vint itemCount=tabHeaderComposition->GetStackItems().Count(); - vint childCount=tabHeaderComposition->Children().Count(); - for(vint i=0;iGetStackItems().Get(i); - if(headerButtons[i]->GetSelected()) + return (IGuiMenuService*)this; + } + else + { + return GuiControl::QueryService(identifier); + } + } + +/*********************************************************************** +GuiMenuButton +***********************************************************************/ + + GuiButton* GuiMenuButton::GetSubMenuHost() + { + GuiButton* button=styleController->GetSubMenuHost(); + return button?button:this; + } + + void GuiMenuButton::OpenSubMenuInternal() + { + if(!GetSubMenuOpening()) + { + if(ownerMenuService) { - tabHeaderComposition->MoveChild(item, childCount-1); - vint padding = controlTemplate->GetHeaderPadding(); - item->SetExtraMargin(Margin(padding, padding, padding, 0)); + GuiMenu* openingSiblingMenu=ownerMenuService->GetOpeningMenu(); + if(openingSiblingMenu) + { + openingSiblingMenu->Hide(); + } + } + SetSubMenuOpening(true); + } + } + + void GuiMenuButton::OnParentLineChanged() + { + GuiButton::OnParentLineChanged(); + ownerMenuService=QueryTypedService(); + if(ownerMenuService) + { + SetClickOnMouseUp(!ownerMenuService->IsSubMenuActivatedByMouseDown()); + } + if(subMenu) + { + subMenu->UpdateMenuService(); + } + } + + bool GuiMenuButton::IsAltAvailable() + { + return true; + } + + compositions::IGuiAltActionHost* GuiMenuButton::GetActivatingAltHost() + { + if (subMenu) + { + return subMenu->QueryTypedService(); + } + return 0; + } + + void GuiMenuButton::OnSubMenuWindowOpened(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + SubMenuOpeningChanged.Execute(GetNotifyEventArguments()); + styleController->SetSubMenuOpening(true); + } + + void GuiMenuButton::OnSubMenuWindowClosed(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + SubMenuOpeningChanged.Execute(GetNotifyEventArguments()); + styleController->SetSubMenuOpening(false); + } + + void GuiMenuButton::OnMouseEnter(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + if(GetVisuallyEnabled()) + { + if(cascadeAction && ownerMenuService && ownerMenuService->IsActiveState()) + { + OpenSubMenuInternal(); + } + } + } + + void GuiMenuButton::OnClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + if(GetVisuallyEnabled()) + { + if(GetSubMenu()) + { + OpenSubMenuInternal(); + } + else if(ownerMenuService) + { + ownerMenuService->MenuItemExecuted(); + } + } + } + + IGuiMenuService::Direction GuiMenuButton::GetSubMenuDirection() + { + return ownerMenuService?ownerMenuService->GetPreferredDirection():IGuiMenuService::Horizontal; + } + + GuiMenuButton::GuiMenuButton(IStyleController* _styleController) + :GuiSelectableButton(_styleController) + ,styleController(_styleController) + ,subMenu(0) + ,ownedSubMenu(false) + ,ownerMenuService(0) + ,cascadeAction(true) + { + SetAutoSelection(false); + SubMenuOpeningChanged.SetAssociatedComposition(boundsComposition); + ImageChanged.SetAssociatedComposition(boundsComposition); + ShortcutTextChanged.SetAssociatedComposition(boundsComposition); + GetSubMenuHost()->Clicked.AttachMethod(this, &GuiMenuButton::OnClicked); + GetSubMenuHost()->GetEventReceiver()->mouseEnter.AttachMethod(this, &GuiMenuButton::OnMouseEnter); + } + + GuiMenuButton::~GuiMenuButton() + { + if(subMenu && ownedSubMenu) + { + delete subMenu; + } + } + + Ptr GuiMenuButton::GetImage() + { + return image; + } + + void GuiMenuButton::SetImage(Ptr value) + { + if(image!=value) + { + image=value; + styleController->SetImage(image); + ImageChanged.Execute(GetNotifyEventArguments()); + } + } + + const WString& GuiMenuButton::GetShortcutText() + { + return shortcutText; + } + + void GuiMenuButton::SetShortcutText(const WString& value) + { + if(shortcutText!=value) + { + shortcutText=value; + styleController->SetShortcutText(shortcutText); + ShortcutTextChanged.Execute(GetNotifyEventArguments()); + } + } + + bool GuiMenuButton::IsSubMenuExists() + { + return subMenu!=0; + } + + GuiMenu* GuiMenuButton::GetSubMenu() + { + return subMenu; + } + + GuiMenu* GuiMenuButton::CreateSubMenu(GuiMenu::IStyleController* subMenuStyleController) + { + if(!subMenu) + { + GuiMenu* newSubMenu=new GuiMenu(subMenuStyleController?subMenuStyleController:styleController->CreateSubMenuStyleController(), this); + SetSubMenu(newSubMenu, true); + } + return subMenu; + } + + void GuiMenuButton::SetSubMenu(GuiMenu* value, bool owned) + { + if(subMenu) + { + if(ownedSubMenu) + { + delete subMenu; + } + } + subMenu=value; + ownedSubMenu=owned; + if(subMenu) + { + subMenu->WindowOpened.AttachMethod(this, &GuiMenuButton::OnSubMenuWindowOpened); + subMenu->WindowClosed.AttachMethod(this, &GuiMenuButton::OnSubMenuWindowClosed); + } + styleController->SetSubMenuExisting(subMenu!=0); + } + + void GuiMenuButton::DestroySubMenu() + { + if(subMenu) + { + if(ownedSubMenu) + { + delete subMenu; + } + subMenu=0; + ownedSubMenu=false; + styleController->SetSubMenuExisting(false); + } + } + + bool GuiMenuButton::GetOwnedSubMenu() + { + return subMenu && ownedSubMenu; + } + + bool GuiMenuButton::GetSubMenuOpening() + { + if(subMenu) + { + return subMenu->GetOpening(); + } + else + { + return false; + } + } + + void GuiMenuButton::SetSubMenuOpening(bool value) + { + if(subMenu) + { + if(value) + { + subMenu->SetClientSize(preferredMenuClientSize); + IGuiMenuService::Direction direction=GetSubMenuDirection(); + subMenu->ShowPopup(GetSubMenuHost(), direction==IGuiMenuService::Horizontal); } else { - item->SetExtraMargin(Margin(0, 0, 0, 0)); + subMenu->Close(); } } - if(childCount>1) - { - tabHeaderComposition->MoveChild(tabContentTopLineComposition, childCount-2); - } } - void GuiTabTemplate_StyleProvider::UpdateHeaderVisibilityIndex() + Size GuiMenuButton::GetPreferredMenuClientSize() { - vint itemCount=tabHeaderComposition->GetStackItems().Count(); - vint selectedItem=-1; - for(vint i=0;iGetSelected()) - { - selectedItem=i; - } - } - - if(selectedItem!=-1) - { - tabHeaderComposition->EnsureVisible(selectedItem); - } + return preferredMenuClientSize; } - void GuiTabTemplate_StyleProvider::UpdateHeaderLayout() + void GuiMenuButton::SetPreferredMenuClientSize(Size value) { - UpdateHeaderZOrder(); - UpdateHeaderVisibilityIndex(); - UpdateHeaderOverflowButtonVisibility(); + preferredMenuClientSize=value; } - void GuiTabTemplate_StyleProvider::Initialize() + bool GuiMenuButton::GetCascadeAction() { - tabBoundsComposition=new GuiTableComposition; - tabBoundsComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); - tabBoundsComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); - tabBoundsComposition->SetRowsAndColumns(1, 2); - tabBoundsComposition->SetRowOption(0, GuiCellOption::MinSizeOption()); - tabBoundsComposition->SetColumnOption(0, GuiCellOption::PercentageOption(1.0)); - tabBoundsComposition->SetColumnOption(1, GuiCellOption::AbsoluteOption(0)); - controlTemplate->GetHeaderComposition()->AddChild(tabBoundsComposition); - - vint padding = controlTemplate->GetHeaderPadding(); - { - GuiCellComposition* cell=new GuiCellComposition; - tabBoundsComposition->AddChild(cell); - cell->SetSite(0, 0, 1, 1); - - vint padding = controlTemplate->GetHeaderPadding(); - tabHeaderComposition=new GuiStackComposition; - tabHeaderComposition->SetExtraMargin(Margin(padding, padding, padding, 0)); - tabHeaderComposition->SetAlignmentToParent(Margin(0, 0, 1, 0)); - tabHeaderComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - tabHeaderComposition->BoundsChanged.AttachMethod(this, &GuiTabTemplate_StyleProvider::OnTabHeaderBoundsChanged); - cell->AddChild(tabHeaderComposition); - } - { - GuiCellComposition* cell=new GuiCellComposition; - tabBoundsComposition->AddChild(cell); - cell->SetSite(0, 1, 1, 1); - - headerOverflowButton=new GuiButton(CreateDropdownTemplate()); - headerOverflowButton->GetBoundsComposition()->SetAlignmentToParent(Margin(-1, padding, 0, 0)); - headerOverflowButton->Clicked.AttachMethod(this, &GuiTabTemplate_StyleProvider::OnHeaderOverflowButtonClicked); - cell->AddChild(headerOverflowButton->GetBoundsComposition()); - } - - headerOverflowMenu=new GuiToolstripMenu(CreateMenuTemplate(), 0); - headerController=new GuiSelectableButton::MutexGroupController; + return cascadeAction; } - GuiTabTemplate_StyleProvider::GuiTabTemplate_StyleProvider(TemplateProperty factory) - :GuiControlTemplate_StyleProvider(factory) + void GuiMenuButton::SetCascadeAction(bool value) { - if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) - { - CHECK_FAIL(L"GuiTabTemplate_StyleProvider::GuiTabTemplate_StyleProvider()#An instance of GuiTabTemplate is expected."); - } - Initialize(); - } - - GuiTabTemplate_StyleProvider::~GuiTabTemplate_StyleProvider() - { - delete headerOverflowMenu; - } - - void GuiTabTemplate_StyleProvider::SetCommandExecutor(controls::ITabCommandExecutor* value) - { - commandExecutor=value; - } - - void GuiTabTemplate_StyleProvider::InsertTab(vint index) - { - GuiSelectableButton* button=new GuiSelectableButton(CreateHeaderTemplate()); - button->SetAutoSelection(false); - button->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); - button->SetGroupController(headerController.Obj()); - button->Clicked.AttachMethod(this, &GuiTabTemplate_StyleProvider::OnHeaderButtonClicked); - - GuiStackItemComposition* item=new GuiStackItemComposition; - item->AddChild(button->GetBoundsComposition()); - tabHeaderComposition->InsertStackItem(index, item); - headerButtons.Insert(index, button); - - GuiToolstripButton* menuItem=new GuiToolstripButton(CreateMenuItemTemplate()); - menuItem->Clicked.AttachMethod(this, &GuiTabTemplate_StyleProvider::OnHeaderOverflowMenuButtonClicked); - headerOverflowMenu->GetToolstripItems().Insert(index, menuItem); - - UpdateHeaderLayout(); - } - - void GuiTabTemplate_StyleProvider::SetTabText(vint index, const WString& value) - { - headerButtons[index]->SetText(value); - headerOverflowMenu->GetToolstripItems().Get(index)->SetText(value); - - UpdateHeaderLayout(); - } - - void GuiTabTemplate_StyleProvider::RemoveTab(vint index) - { - GuiStackItemComposition* item=tabHeaderComposition->GetStackItems().Get(index); - GuiSelectableButton* button=headerButtons[index]; - - tabHeaderComposition->RemoveChild(item); - item->RemoveChild(button->GetBoundsComposition()); - headerButtons.RemoveAt(index); - - headerOverflowMenu->GetToolstripItems().RemoveAt(index); - delete item; - delete button; - - UpdateHeaderLayout(); - } - - void GuiTabTemplate_StyleProvider::SetSelectedTab(vint index) - { - headerButtons[index]->SetSelected(true); - - UpdateHeaderLayout(); - } - - void GuiTabTemplate_StyleProvider::SetTabAlt(vint index, const WString& value) - { - auto button = headerButtons[index]; - button->SetAlt(value); - } - - compositions::IGuiAltAction* GuiTabTemplate_StyleProvider::GetTabAltAction(vint index) - { - return headerButtons[index]->QueryTypedService(); - } - -/*********************************************************************** -GuiDatePickerTemplate_StyleProvider -***********************************************************************/ - - GuiDatePickerTemplate_StyleProvider::GuiDatePickerTemplate_StyleProvider(TemplateProperty factory) - :GuiControlTemplate_StyleProvider(factory) - { - if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) - { - CHECK_FAIL(L"GuiDatePickerTemplate_StyleProvider::GuiDatePickerTemplate_StyleProvider()#An instance of GuiDatePickerTemplate is expected."); - } - } - - GuiDatePickerTemplate_StyleProvider::~GuiDatePickerTemplate_StyleProvider() - { - delete controlTemplate; - } - - controls::GuiSelectableButton::IStyleController* GuiDatePickerTemplate_StyleProvider::CreateDateButtonStyle() - { - GET_FACTORY_FROM_TEMPLATE(GuiSelectableButtonTemplate, DateButtonTemplate); - } - - GuiTextListTemplate_StyleProvider* GuiDatePickerTemplate_StyleProvider::CreateTextListStyle() - { - GET_FACTORY_FROM_TEMPLATE(GuiTextListTemplate, DateTextListTemplate); - } - - controls::GuiTextList* GuiDatePickerTemplate_StyleProvider::CreateTextList() - { - auto style = CreateTextListStyle(); - return new GuiTextList(style); - } - - controls::GuiComboBoxListControl::IStyleController* GuiDatePickerTemplate_StyleProvider::CreateComboBoxStyle() - { - GET_FACTORY_FROM_TEMPLATE(GuiComboBoxTemplate, DateComboBoxTemplate); - } - - Color GuiDatePickerTemplate_StyleProvider::GetBackgroundColor() - { - return controlTemplate->GetBackgroundColor(); - } - - Color GuiDatePickerTemplate_StyleProvider::GetPrimaryTextColor() - { - return controlTemplate->GetPrimaryTextColor(); - } - - Color GuiDatePickerTemplate_StyleProvider::GetSecondaryTextColor() - { - return controlTemplate->GetSecondaryTextColor(); - } - -/*********************************************************************** -GuiDateComboBoxTemplate_StyleProvider -***********************************************************************/ - - GuiDateComboBoxTemplate_StyleProvider::GuiDateComboBoxTemplate_StyleProvider(TemplateProperty factory) - :GuiComboBoxTemplate_StyleProvider(factory) - { - if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) - { - CHECK_FAIL(L"GuiDateComboBoxTemplate_StyleProvider::GuiDateComboBoxTemplate_StyleProvider()#An instance of GuiDateComboBoxTemplate is expected."); - } - } - - GuiDateComboBoxTemplate_StyleProvider::~GuiDateComboBoxTemplate_StyleProvider() - { - } - - controls::GuiDatePicker* GuiDateComboBoxTemplate_StyleProvider::CreateArgument() - { - return new GuiDatePicker(CreateDatePickerStyle()); - } - - controls::GuiDatePicker::IStyleProvider* GuiDateComboBoxTemplate_StyleProvider::CreateDatePickerStyle() - { - GET_FACTORY_FROM_TEMPLATE(GuiDatePickerTemplate, DatePickerTemplate); - } - -/*********************************************************************** -Helper Functions -***********************************************************************/ - - void SplitBySemicolon(const WString& input, collections::List& fragments) - { - const wchar_t* attValue = input.Buffer(); - while(*attValue) - { - // split the value by ';' - const wchar_t* attSemicolon = wcschr(attValue, L';'); - WString pattern; - if(attSemicolon) - { - pattern = WString(attValue, vint(attSemicolon - attValue)); - attValue = attSemicolon + 1; - } - else - { - vint len = wcslen(attValue); - pattern = WString(attValue, len); - attValue += len; - } - - fragments.Add(pattern); - } + cascadeAction=value; } } } } -#undef GET_FACTORY_FROM_TEMPLATE -#undef GET_FACTORY_FROM_TEMPLATE_OPT +/*********************************************************************** +.\CONTROLS\GUIDATETIMECONTROLS.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace controls + { + using namespace collections; + using namespace compositions; + using namespace elements; /*********************************************************************** -CONTROLS\TEXTEDITORPACKAGE\GUIDOCUMENTVIEWER.CPP +GuiDatePicker::StyleController +***********************************************************************/ + + vint GetDayCountForMonth(vint year, vint month) + { + bool isLeapYear=(year%100==0)?(year%400==0):(year%4==0); + switch(month) + { + case 1:case 3:case 5:case 7:case 8:case 10:case 12: + return 31; + case 4:case 6:case 9:case 11: + return 30; + default: + return isLeapYear?29:28; + } + } + + void StepPreviousMonth(vint& year, vint& month) + { + if(month==1) + { + year--; + month=12; + } + else + { + month--; + } + } + + void StepNextMonth(vint& year, vint& month) + { + if(month==12) + { + year++; + month=1; + } + else + { + month++; + } + } + + void GuiDatePicker::StyleController::SetDay(const DateTime& day, vint& index, bool currentMonth) + { + dateDays[index]=day; + GuiSolidLabelElement* label=labelDays[index]; + label->SetText(itow(day.day)); + label->SetColor(currentMonth?styleProvider->GetPrimaryTextColor():styleProvider->GetSecondaryTextColor()); + index++; + } + + void GuiDatePicker::StyleController::comboYearMonth_SelectedIndexChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + if(!preventComboEvent) + { + if(comboYear->GetSelectedIndex()!=-1 && comboMonth->GetSelectedIndex()!=-1) + { + vint year=comboYear->GetSelectedIndex()+YearFirst; + vint month=comboMonth->GetSelectedIndex()+1; + SetDate(DateTime::FromDateTime(year, month, 1)); + datePicker->NotifyDateChanged(); + datePicker->DateNavigated.Execute(datePicker->GetNotifyEventArguments()); + } + } + } + + void GuiDatePicker::StyleController::buttonDay_SelectedChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + if(!preventButtonEvent) + { + GuiSelectableButton* button=dynamic_cast(sender->GetRelatedControl()); + if(button->GetSelected()) + { + vint index=buttonDays.IndexOf(button); + if(index!=-1) + { + DateTime day=dateDays[index]; + if(day.year!=currentDate.year || day.month!=currentDate.month) + { + SetDate(day); + } + else + { + currentDate=day; + } + datePicker->NotifyDateChanged(); + datePicker->DateSelected.Execute(datePicker->GetNotifyEventArguments()); + } + } + } + } + + void GuiDatePicker::StyleController::DisplayMonth(vint year, vint month) + { + if(YearFirst<=year && year<=YearLast && 1<=month && month<=12) + { + preventComboEvent=true; + comboYear->SetSelectedIndex(year-YearFirst); + comboMonth->SetSelectedIndex(month-1); + preventComboEvent=false; + } + + vint yearPrev=year, yearNext=year, monthPrev=month, monthNext=month; + StepPreviousMonth(yearPrev, monthPrev); + StepNextMonth(yearNext, monthNext); + + vint countPrev=GetDayCountForMonth(yearPrev, monthPrev); + vint count=GetDayCountForMonth(year, month); + vint countNext=GetDayCountForMonth(yearNext, monthNext); + + DateTime firstDay=DateTime::FromDateTime(year, month, 1); + vint showPrev=firstDay.dayOfWeek; + if(showPrev==0) showPrev=DaysOfWeek; + vint show=count; + vint showNext=DaysOfWeek*DayRows-showPrev-show; + + vint index=0; + for(vint i=0;iSetSelected(true); + preventButtonEvent=false; + break; + } + } + } + + GuiDatePicker::StyleController::StyleController(IStyleProvider* _styleProvider) + :styleProvider(_styleProvider) + ,datePicker(0) + ,preventComboEvent(false) + ,preventButtonEvent(false) + { + GuiTableComposition* monthTable=0; + GuiTableComposition* dayTable=0; + { + listYears=styleProvider->CreateTextList(); + listYears->SetHorizontalAlwaysVisible(false); + for(vint i=YearFirst;i<=YearLast;i++) + { + listYears->GetItems().Add(new list::TextItem(itow(i))); + } + comboYear=new GuiComboBoxListControl(styleProvider->CreateComboBoxStyle(), listYears); + comboYear->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 2, 0)); + comboYear->SelectedIndexChanged.AttachMethod(this, &StyleController::comboYearMonth_SelectedIndexChanged); + } + { + listMonths=styleProvider->CreateTextList(); + listMonths->SetHorizontalAlwaysVisible(false); + comboMonth=new GuiComboBoxListControl(styleProvider->CreateComboBoxStyle(), listMonths); + comboMonth->GetBoundsComposition()->SetAlignmentToParent(Margin(2, 0, 0, 0)); + comboMonth->SelectedIndexChanged.AttachMethod(this, &StyleController::comboYearMonth_SelectedIndexChanged); + } + { + monthTable=new GuiTableComposition; + monthTable->SetAlignmentToParent(Margin(0, 0, 0, 0)); + monthTable->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + monthTable->SetRowsAndColumns(1, 2); + monthTable->SetRowOption(0, GuiCellOption::MinSizeOption()); + monthTable->SetColumnOption(0, GuiCellOption::PercentageOption(0.5)); + monthTable->SetColumnOption(1, GuiCellOption::PercentageOption(0.5)); + { + GuiCellComposition* cell=new GuiCellComposition; + monthTable->AddChild(cell); + cell->SetSite(0, 0, 1, 1); + cell->AddChild(comboYear->GetBoundsComposition()); + } + { + GuiCellComposition* cell=new GuiCellComposition; + monthTable->AddChild(cell); + cell->SetSite(0, 1, 1, 1); + cell->AddChild(comboMonth->GetBoundsComposition()); + } + } + { + dayTable=new GuiTableComposition; + dayTable->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + dayTable->SetCellPadding(4); + dayTable->SetRowsAndColumns(DayRows+DayRowStart, DaysOfWeek); + + for(vint i=0;iSetRowOption(i, GuiCellOption::MinSizeOption()); + } + for(vint i=0;iSetRowOption(i+DayRowStart, GuiCellOption::PercentageOption(1.0)); + } + for(vint i=0;iSetColumnOption(i, GuiCellOption::PercentageOption(1.0)); + } + + { + GuiCellComposition* cell=new GuiCellComposition; + dayTable->AddChild(cell); + cell->SetSite(0, 0, 1, DaysOfWeek); + cell->AddChild(monthTable); + } + + labelDaysOfWeek.Resize(7); + for(vint i=0;iAddChild(cell); + cell->SetSite(1, i, 1, 1); + + GuiSolidLabelElement* element=GuiSolidLabelElement::Create(); + element->SetAlignments(Alignment::Center, Alignment::Center); + element->SetColor(styleProvider->GetPrimaryTextColor()); + labelDaysOfWeek[i]=element; + cell->SetOwnedElement(element); + } + + buttonDays.Resize(DaysOfWeek*DayRows); + labelDays.Resize(DaysOfWeek*DayRows); + dateDays.Resize(DaysOfWeek*DayRows); + dayMutexController=new GuiSelectableButton::MutexGroupController; + for(vint i=0;iAddChild(cell); + cell->SetSite(j+DayRowStart, i, 1, 1); + + GuiSelectableButton* button=new GuiSelectableButton(styleProvider->CreateDateButtonStyle()); + button->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); + button->SetGroupController(dayMutexController.Obj()); + button->SelectedChanged.AttachMethod(this, &StyleController::buttonDay_SelectedChanged); + cell->AddChild(button->GetBoundsComposition()); + buttonDays[j*DaysOfWeek+i]=button; + + GuiSolidLabelElement* element=GuiSolidLabelElement::Create(); + element->SetAlignments(Alignment::Center, Alignment::Center); + element->SetText(L"0"); + labelDays[j*DaysOfWeek+i]=element; + + GuiBoundsComposition* elementBounds=new GuiBoundsComposition; + elementBounds->SetOwnedElement(element); + elementBounds->SetAlignmentToParent(Margin(0, 0, 0, 0)); + elementBounds->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); + button->GetContainerComposition()->AddChild(elementBounds); + } + } + } + { + GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); + element->SetColor(styleProvider->GetBackgroundColor()); + dayTable->SetOwnedElement(element); + } + + boundsComposition=dayTable; + } + + GuiDatePicker::StyleController::~StyleController() + { + delete styleProvider; + } + + compositions::GuiBoundsComposition* GuiDatePicker::StyleController::GetBoundsComposition() + { + return boundsComposition; + } + + compositions::GuiGraphicsComposition* GuiDatePicker::StyleController::GetContainerComposition() + { + return boundsComposition; + } + + void GuiDatePicker::StyleController::SetFocusableComposition(compositions::GuiGraphicsComposition* value) + { + } + + void GuiDatePicker::StyleController::SetText(const WString& value) + { + } + + void GuiDatePicker::StyleController::SetFont(const FontProperties& value) + { + comboYear->SetFont(value); + listYears->SetFont(value); + comboMonth->SetFont(value); + listMonths->SetFont(value); + FOREACH(GuiSolidLabelElement*, label, From(labelDaysOfWeek).Concat(labelDays)) + { + label->SetFont(value); + } + } + + void GuiDatePicker::StyleController::SetVisuallyEnabled(bool value) + { + } + + void GuiDatePicker::StyleController::SetDatePicker(GuiDatePicker* _datePicker) + { + datePicker=_datePicker; + } + + void GuiDatePicker::StyleController::SetDateLocale(const Locale& _dateLocale) + { + dateLocale=_dateLocale; + for(vint i=0;iSetText(dateLocale.GetShortDayOfWeekName(i)); + } + + listMonths->GetItems().Clear(); + for(vint i=1;i<=12;i++) + { + listMonths->GetItems().Add(new list::TextItem(dateLocale.GetLongMonthName(i))); + } + + SetDate(currentDate, true); + } + + const DateTime& GuiDatePicker::StyleController::GetDate() + { + return currentDate; + } + + void GuiDatePicker::StyleController::SetDate(const DateTime& value, bool forceUpdate) + { + if(forceUpdate || currentDate.year!=value.year || currentDate.month!=value.month || currentDate.day!=value.day) + { + currentDate=value; + DisplayMonth(value.year, value.month); + SelectDay(value.day); + } + } + +/*********************************************************************** +GuiDatePicker +***********************************************************************/ + + void GuiDatePicker::UpdateText() + { + GuiControl::SetText(dateLocale.FormatDate(dateFormat, styleController->GetDate())); + } + + void GuiDatePicker::NotifyDateChanged() + { + UpdateText(); + DateChanged.Execute(GetNotifyEventArguments()); + } + + GuiDatePicker::GuiDatePicker(IStyleProvider* _styleProvider) + :GuiControl(new StyleController(_styleProvider)) + { + styleController=dynamic_cast(GetStyleController()); + styleController->SetDatePicker(this); + + SetDateLocale(Locale::UserDefault()); + SetDate(DateTime::LocalTime()); + + DateChanged.SetAssociatedComposition(GetBoundsComposition()); + DateNavigated.SetAssociatedComposition(GetBoundsComposition()); + DateSelected.SetAssociatedComposition(GetBoundsComposition()); + DateFormatChanged.SetAssociatedComposition(GetBoundsComposition()); + DateLocaleChanged.SetAssociatedComposition(GetBoundsComposition()); + + NotifyDateChanged(); + } + + GuiDatePicker::~GuiDatePicker() + { + } + + const DateTime& GuiDatePicker::GetDate() + { + return styleController->GetDate(); + } + + void GuiDatePicker::SetDate(const DateTime& value) + { + styleController->SetDate(value); + } + + const WString& GuiDatePicker::GetDateFormat() + { + return dateFormat; + } + + void GuiDatePicker::SetDateFormat(const WString& value) + { + dateFormat=value; + UpdateText(); + DateFormatChanged.Execute(GetNotifyEventArguments()); + } + + const Locale& GuiDatePicker::GetDateLocale() + { + return dateLocale; + } + + void GuiDatePicker::SetDateLocale(const Locale& value) + { + dateLocale=value; + List formats; + dateLocale.GetLongDateFormats(formats); + if(formats.Count()>0) + { + dateFormat=formats[0]; + } + styleController->SetDateLocale(dateLocale); + + UpdateText(); + DateFormatChanged.Execute(GetNotifyEventArguments()); + DateLocaleChanged.Execute(GetNotifyEventArguments()); + } + + void GuiDatePicker::SetText(const WString& value) + { + } + +/*********************************************************************** +GuiDateComboBox +***********************************************************************/ + + void GuiDateComboBox::UpdateText() + { + SetText(datePicker->GetDateLocale().FormatDate(datePicker->GetDateFormat(), selectedDate)); + } + + void GuiDateComboBox::NotifyUpdateSelectedDate() + { + UpdateText(); + SelectedDateChanged.Execute(GetNotifyEventArguments()); + } + + void GuiDateComboBox::OnSubMenuOpeningChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + datePicker->SetDate(selectedDate); + } + + void GuiDateComboBox::datePicker_DateLocaleChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + UpdateText(); + } + + void GuiDateComboBox::datePicker_DateFormatChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + UpdateText(); + } + + void GuiDateComboBox::datePicker_DateSelected(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + selectedDate=datePicker->GetDate(); + GetSubMenu()->Hide(); + SelectItem(); + NotifyUpdateSelectedDate(); + } + + GuiDateComboBox::GuiDateComboBox(IStyleController* _styleController, GuiDatePicker* _datePicker) + :GuiComboBoxBase(_styleController) + ,datePicker(_datePicker) + { + SelectedDateChanged.SetAssociatedComposition(GetBoundsComposition()); + + datePicker->DateSelected.AttachMethod(this, &GuiDateComboBox::datePicker_DateSelected); + datePicker->DateLocaleChanged.AttachMethod(this, &GuiDateComboBox::datePicker_DateLocaleChanged); + datePicker->DateFormatChanged.AttachMethod(this, &GuiDateComboBox::datePicker_DateFormatChanged); + datePicker->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); + GetSubMenu()->GetContainerComposition()->AddChild(datePicker->GetBoundsComposition()); + + selectedDate=datePicker->GetDate(); + SubMenuOpeningChanged.AttachMethod(this, &GuiDateComboBox::OnSubMenuOpeningChanged); + SetFont(GetFont()); + SetText(datePicker->GetText()); + } + + GuiDateComboBox::~GuiDateComboBox() + { + } + + void GuiDateComboBox::SetFont(const FontProperties& value) + { + GuiComboBoxBase::SetFont(value); + datePicker->SetFont(value); + } + + const DateTime& GuiDateComboBox::GetSelectedDate() + { + return selectedDate; + } + + void GuiDateComboBox::SetSelectedDate(const DateTime& value) + { + selectedDate=value; + NotifyUpdateSelectedDate(); + } + + GuiDatePicker* GuiDateComboBox::GetDatePicker() + { + return datePicker; + } + } + } +} + +/*********************************************************************** +.\CONTROLS\LISTCONTROLPACKAGE\GUICOMBOCONTROLS.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace controls + { + +/*********************************************************************** +GuiComboBoxBase::CommandExecutor +***********************************************************************/ + + GuiComboBoxBase::CommandExecutor::CommandExecutor(GuiComboBoxBase* _combo) + :combo(_combo) + { + } + + GuiComboBoxBase::CommandExecutor::~CommandExecutor() + { + } + + void GuiComboBoxBase::CommandExecutor::SelectItem() + { + combo->SelectItem(); + } + +/*********************************************************************** +GuiComboBoxBase +***********************************************************************/ + + bool GuiComboBoxBase::IsAltAvailable() + { + return false; + } + + IGuiMenuService::Direction GuiComboBoxBase::GetSubMenuDirection() + { + return IGuiMenuService::Horizontal; + } + + void GuiComboBoxBase::SelectItem() + { + styleController->OnItemSelected(); + ItemSelected.Execute(GetNotifyEventArguments()); + } + + void GuiComboBoxBase::OnBoundsChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + Size size=GetPreferredMenuClientSize(); + size.x=GetBoundsComposition()->GetBounds().Width(); + SetPreferredMenuClientSize(size); + } + + GuiComboBoxBase::GuiComboBoxBase(IStyleController* _styleController) + :GuiMenuButton(_styleController) + { + commandExecutor=new CommandExecutor(this); + styleController=dynamic_cast(GetStyleController()); + styleController->SetCommandExecutor(commandExecutor.Obj()); + + CreateSubMenu(); + SetCascadeAction(false); + + GetBoundsComposition()->BoundsChanged.AttachMethod(this, &GuiComboBoxBase::OnBoundsChanged); + } + + GuiComboBoxBase::~GuiComboBoxBase() + { + } + +/*********************************************************************** +GuiComboBoxListControl +***********************************************************************/ + + bool GuiComboBoxListControl::IsAltAvailable() + { + return true; + } + + void GuiComboBoxListControl::OnActiveAlt() + { + GuiMenuButton::OnActiveAlt(); + GetSubMenu()->GetNativeWindow()->SetFocus(); + containedListControl->SetFocus(); + } + + void GuiComboBoxListControl::RemoveStyleController() + { + if (itemStyleController) + { + SafeDeleteComposition(itemStyleController); + itemStyleController = nullptr; + } + } + + void GuiComboBoxListControl::InstallStyleController(vint itemIndex) + { + if (itemStyleProperty) + { + if (itemIndex != -1) + { + auto item = containedListControl->GetItemProvider()->GetBindingValue(itemIndex); + if (!item.IsNull()) + { + if (auto style = itemStyleProperty(item)) + { + itemStyleController = style; + itemStyleController->SetText(GetText()); + itemStyleController->SetFont(GetFont()); + itemStyleController->SetVisuallyEnabled(GetVisuallyEnabled()); + itemStyleController->SetAlignmentToParent(Margin(0, 0, 0, 0)); + GetContainerComposition()->AddChild(itemStyleController); + } + } + } + } + } + + void GuiComboBoxListControl::DisplaySelectedContent(vint itemIndex) + { + if(itemIndex==-1) + { + SetText(L""); + } + else + { + WString text = containedListControl->GetItemProvider()->GetTextValue(itemIndex); + SetText(text); + GetSubMenu()->Hide(); + } + + RemoveStyleController(); + InstallStyleController(itemIndex); + } + + void GuiComboBoxListControl::OnTextChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + if (itemStyleController) + { + itemStyleController->SetText(GetText()); + } + } + + void GuiComboBoxListControl::OnFontChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + if (itemStyleController) + { + itemStyleController->SetFont(GetFont()); + } + auto args = GetNotifyEventArguments(); + OnListControlAdoptedSizeInvalidated(nullptr, args); + } + + void GuiComboBoxListControl::OnVisuallyEnabledChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + if (itemStyleController) + { + itemStyleController->SetVisuallyEnabled(GetVisuallyEnabled()); + } + } + + void GuiComboBoxListControl::OnListControlAdoptedSizeInvalidated(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + Size expectedSize(0, GetFont().size * 20); + Size adoptedSize = containedListControl->GetAdoptedSize(expectedSize); + + Size clientSize = GetPreferredMenuClientSize(); + clientSize.y = adoptedSize.y + GetSubMenu()->GetClientSize().y - containedListControl->GetBoundsComposition()->GetBounds().Height(); + SetPreferredMenuClientSize(clientSize); + + if (GetSubMenuOpening()) + { + GetSubMenu()->SetClientSize(clientSize); + } + } + + void GuiComboBoxListControl::OnListControlSelectionChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + DisplaySelectedContent(GetSelectedIndex()); + SelectItem(); + SelectedIndexChanged.Execute(GetNotifyEventArguments()); + } + + GuiComboBoxListControl::GuiComboBoxListControl(IStyleController* _styleController, GuiSelectableListControl* _containedListControl) + :GuiComboBoxBase(_styleController) + , styleController(_styleController) + , containedListControl(_containedListControl) + { + styleController->SetTextVisible(true); + TextChanged.AttachMethod(this, &GuiComboBoxListControl::OnTextChanged); + FontChanged.AttachMethod(this, &GuiComboBoxListControl::OnFontChanged); + VisuallyEnabledChanged.AttachMethod(this, &GuiComboBoxListControl::OnVisuallyEnabledChanged); + + containedListControl->SetMultiSelect(false); + containedListControl->AdoptedSizeInvalidated.AttachMethod(this, &GuiComboBoxListControl::OnListControlAdoptedSizeInvalidated); + containedListControl->SelectionChanged.AttachMethod(this, &GuiComboBoxListControl::OnListControlSelectionChanged); + + auto itemProvider = containedListControl->GetItemProvider(); + + SelectedIndexChanged.SetAssociatedComposition(GetBoundsComposition()); + + containedListControl->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); + GetSubMenu()->GetContainerComposition()->AddChild(containedListControl->GetBoundsComposition()); + SetFont(GetFont()); + } + + GuiComboBoxListControl::~GuiComboBoxListControl() + { + } + + GuiSelectableListControl* GuiComboBoxListControl::GetContainedListControl() + { + return containedListControl; + } + + GuiComboBoxListControl::ItemStyleProperty GuiComboBoxListControl::GetItemTemplate() + { + return itemStyleProperty; + } + + void GuiComboBoxListControl::SetItemTemplate(ItemStyleProperty value) + { + RemoveStyleController(); + itemStyleProperty = value; + styleController->SetTextVisible(!itemStyleProperty); + InstallStyleController(GetSelectedIndex()); + ItemTemplateChanged.Execute(GetNotifyEventArguments()); + } + + vint GuiComboBoxListControl::GetSelectedIndex() + { + if(containedListControl->GetSelectedItems().Count()==1) + { + return containedListControl->GetSelectedItems()[0]; + } + else + { + return -1; + } + } + + void GuiComboBoxListControl::SetSelectedIndex(vint value) + { + containedListControl->SetSelected(value, true); + } + + description::Value GuiComboBoxListControl::GetSelectedItem() + { + auto selectedIndex = GetSelectedIndex(); + if (selectedIndex != -1) + { + return containedListControl->GetItemProvider()->GetBindingValue(selectedIndex); + } + return description::Value(); + } + + GuiListControl::IItemProvider* GuiComboBoxListControl::GetItemProvider() + { + return containedListControl->GetItemProvider(); + } + } + } +} + + +/*********************************************************************** +.\CONTROLS\TEXTEDITORPACKAGE\EDITORCALLBACK\GUITEXTGENERALOPERATIONS.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace controls + { + } + } +} + +/*********************************************************************** +.\CONTROLS\TEXTEDITORPACKAGE\EDITORCALLBACK\GUITEXTCOLORIZER.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace controls + { + using namespace elements; + using namespace elements::text; + +/*********************************************************************** +GuiTextBoxColorizerBase +***********************************************************************/ + + void GuiTextBoxColorizerBase::ColorizerThreadProc(void* argument) + { + GuiTextBoxColorizerBase* colorizer=(GuiTextBoxColorizerBase*)argument; + while(!colorizer->isFinalizing) + { + vint lineIndex=-1; + wchar_t* text=0; + vuint32_t* colors=0; + vint length=0; + vint lexerState=-1; + vint contextState=-1; + + SPIN_LOCK(*colorizer->elementModifyLock) + { + if(colorizer->colorizedLineCount>=colorizer->element->GetLines().GetCount()) + { + colorizer->isColorizerRunning=false; + goto CANCEL_COLORIZING; + } + + lineIndex=colorizer->colorizedLineCount++; + TextLine& line=colorizer->element->GetLines().GetLine(lineIndex); + length=line.dataLength; + text=new wchar_t[length+2]; + colors=new vuint32_t[length+2]; + memcpy(text, line.text, sizeof(wchar_t)*length); + text[length]=L'\r'; + text[length+1]=L'\n'; + lexerState=lineIndex==0?colorizer->GetLexerStartState():colorizer->element->GetLines().GetLine(lineIndex-1).lexerFinalState; + contextState=lineIndex==0?colorizer->GetContextStartState():colorizer->element->GetLines().GetLine(lineIndex-1).contextFinalState; + } + + colorizer->ColorizeLineWithCRLF(lineIndex, text, colors, length+2, lexerState, contextState); + + SPIN_LOCK(*colorizer->elementModifyLock) + { + if(lineIndexcolorizedLineCount && lineIndexelement->GetLines().GetCount()) + { + TextLine& line=colorizer->element->GetLines().GetLine(lineIndex); + line.lexerFinalState=lexerState; + line.contextFinalState=contextState; + for(vint i=0;icolorizerRunningEvent.Leave(); + } + + void GuiTextBoxColorizerBase::StartColorizer() + { + if(!isColorizerRunning) + { + isColorizerRunning=true; + colorizerRunningEvent.Enter(); + ThreadPoolLite::Queue(&GuiTextBoxColorizerBase::ColorizerThreadProc, this); + } + } + + void GuiTextBoxColorizerBase::StopColorizer(bool forever) + { + isFinalizing=true; + colorizerRunningEvent.Enter(); + colorizerRunningEvent.Leave(); + colorizedLineCount=0; + if(!forever) + { + isFinalizing=false; + } + } + + void GuiTextBoxColorizerBase::StopColorizerForever() + { + StopColorizer(true); + } + + GuiTextBoxColorizerBase::GuiTextBoxColorizerBase() + :element(0) + ,elementModifyLock(0) + ,colorizedLineCount(0) + ,isColorizerRunning(false) + ,isFinalizing(false) + { + } + + GuiTextBoxColorizerBase::~GuiTextBoxColorizerBase() + { + StopColorizerForever(); + } + + void GuiTextBoxColorizerBase::Attach(elements::GuiColorizedTextElement* _element, SpinLock& _elementModifyLock, compositions::GuiGraphicsComposition* _ownerComposition, vuint editVersion) + { + if(_element) + { + SPIN_LOCK(_elementModifyLock) + { + element=_element; + elementModifyLock=&_elementModifyLock; + StartColorizer(); + } + } + } + + void GuiTextBoxColorizerBase::Detach() + { + if(element && elementModifyLock) + { + StopColorizer(false); + SPIN_LOCK(*elementModifyLock) + { + element=0; + elementModifyLock=0; + } + } + } + + void GuiTextBoxColorizerBase::TextEditPreview(TextEditPreviewStruct& arguments) + { + } + + void GuiTextBoxColorizerBase::TextEditNotify(const TextEditNotifyStruct& arguments) + { + if(element && elementModifyLock) + { + SPIN_LOCK(*elementModifyLock) + { + vint line + =arguments.originalStart.rowline) + { + colorizedLineCount=line; + } + StartColorizer(); + } + } + } + + void GuiTextBoxColorizerBase::TextCaretChanged(const TextCaretChangedStruct& arguments) + { + } + + void GuiTextBoxColorizerBase::TextEditFinished(vuint editVersion) + { + } + + void GuiTextBoxColorizerBase::RestartColorizer() + { + if(element && elementModifyLock) + { + SPIN_LOCK(*elementModifyLock) + { + colorizedLineCount=0; + StartColorizer(); + } + } + } + +/*********************************************************************** +GuiTextBoxRegexColorizer +***********************************************************************/ + + struct GuiTextBoxRegexColorizerProcData + { + GuiTextBoxRegexColorizer* colorizer; + vint lineIndex; + const wchar_t* text; + vuint32_t* colors; + vint contextState; + }; + + void GuiTextBoxRegexColorizer::ColorizerProc(void* argument, vint start, vint length, vint token) + { + GuiTextBoxRegexColorizerProcData& data=*(GuiTextBoxRegexColorizerProcData*)argument; + data.colorizer->ColorizeTokenContextSensitive(data.lineIndex, data.text, start, length, token, data.contextState); + for(vint i=0;i& GuiTextBoxRegexColorizer::GetTokenRegexes() + { + return tokenRegexes; + } + + collections::List& GuiTextBoxRegexColorizer::GetTokenColors() + { + return tokenColors; + } + + collections::List& GuiTextBoxRegexColorizer::GetExtraTokenColors() + { + return extraTokenColors; + } + + vint GuiTextBoxRegexColorizer::GetExtraTokenIndexStart() + { + if(lexer) + { + return tokenColors.Count(); + } + else + { + return -1; + } + } + + bool GuiTextBoxRegexColorizer::SetDefaultColor(elements::text::ColorEntry value) + { + if(lexer) + { + return false; + } + else + { + defaultColor=value; + return true; + } + } + + vint GuiTextBoxRegexColorizer::AddToken(const WString& regex, elements::text::ColorEntry color) + { + if(lexer) + { + return -1; + } + else + { + tokenRegexes.Add(regex); + tokenColors.Add(color); + return tokenColors.Count()-1; + } + } + + vint GuiTextBoxRegexColorizer::AddExtraToken(elements::text::ColorEntry color) + { + if(lexer) + { + return -1; + } + else + { + extraTokenColors.Add(color); + return extraTokenColors.Count()-1; + } + } + + void GuiTextBoxRegexColorizer::ClearTokens() + { + tokenRegexes.Clear(); + tokenColors.Clear(); + extraTokenColors.Clear(); + lexer=0; + } + + void GuiTextBoxRegexColorizer::Setup() + { + if(lexer || tokenRegexes.Count()==0) + { + colors.Resize(1); + colors[0]=defaultColor; + } + else + { + lexer=new regex::RegexLexer(tokenRegexes); + colors.Resize(1+tokenRegexes.Count()+extraTokenColors.Count()); + colors[0]=defaultColor; + for(vint i=0;iColorize()); + } + } + + void GuiTextBoxRegexColorizer::ColorizeTokenContextSensitive(vint lineIndex, const wchar_t* text, vint start, vint length, vint& token, vint& contextState) + { + } + + vint GuiTextBoxRegexColorizer::GetLexerStartState() + { + return lexer?colorizer->GetStartState():-1; + } + + vint GuiTextBoxRegexColorizer::GetContextStartState() + { + return 0; + } + + void GuiTextBoxRegexColorizer::ColorizeLineWithCRLF(vint lineIndex, const wchar_t* text, vuint32_t* colors, vint length, vint& lexerState, vint& contextState) + { + memset(colors, 0, sizeof(*colors)*length); + if(lexer) + { + GuiTextBoxRegexColorizerProcData data; + data.colorizer=this; + data.lineIndex=lineIndex; + data.text=text; + data.colors=colors; + data.contextState=contextState; + + colorizer->Reset(lexerState); + colorizer->Colorize(text, length, &GuiTextBoxRegexColorizer::ColorizerProc, &data); + + lexerState=colorizer->GetCurrentState(); + contextState=data.contextState; + } + else + { + lexerState=-1; + contextState=-1; + } + } + + const GuiTextBoxRegexColorizer::ColorArray& GuiTextBoxRegexColorizer::GetColors() + { + return colors; + } + } + } +} + +/*********************************************************************** +.\CONTROLS\TEXTEDITORPACKAGE\EDITORCALLBACK\GUITEXTUNDOREDO.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace controls + { + using namespace elements; + using namespace elements::text; + using namespace compositions; + +/*********************************************************************** +GuiGeneralUndoRedoProcessor +***********************************************************************/ + + GuiGeneralUndoRedoProcessor::GuiGeneralUndoRedoProcessor() + :firstFutureStep(0) + ,savedStep(0) + ,performingUndoRedo(false) + { + } + + GuiGeneralUndoRedoProcessor::~GuiGeneralUndoRedoProcessor() + { + } + + void GuiGeneralUndoRedoProcessor::PushStep(Ptr step) + { + if(!performingUndoRedo) + { + if(firstFutureStep0) + { + steps.RemoveRange(firstFutureStep, count); + } + + steps.Add(step); + firstFutureStep=steps.Count(); + UndoRedoChanged(); + ModifiedChanged(); + } + } + + bool GuiGeneralUndoRedoProcessor::CanUndo() + { + return firstFutureStep>0; + } + + bool GuiGeneralUndoRedoProcessor::CanRedo() + { + return steps.Count()>firstFutureStep; + } + + void GuiGeneralUndoRedoProcessor::ClearUndoRedo() + { + if(!performingUndoRedo) + { + steps.Clear(); + firstFutureStep=0; + savedStep=-1; + } + } + + bool GuiGeneralUndoRedoProcessor::GetModified() + { + return firstFutureStep!=savedStep; + } + + void GuiGeneralUndoRedoProcessor::NotifyModificationSaved() + { + if(!performingUndoRedo) + { + savedStep=firstFutureStep; + ModifiedChanged(); + } + } + + bool GuiGeneralUndoRedoProcessor::Undo() + { + if(!CanUndo()) return false; + performingUndoRedo=true; + firstFutureStep--; + steps[firstFutureStep]->Undo(); + performingUndoRedo=false; + UndoRedoChanged(); + ModifiedChanged(); + return true; + } + + bool GuiGeneralUndoRedoProcessor::Redo() + { + if(!CanRedo()) return false; + performingUndoRedo=true; + firstFutureStep++; + steps[firstFutureStep-1]->Redo(); + performingUndoRedo=false; + UndoRedoChanged(); + ModifiedChanged(); + return true; + } + +/*********************************************************************** +GuiTextBoxUndoRedoProcessor::EditStep +***********************************************************************/ + + void GuiTextBoxUndoRedoProcessor::EditStep::Undo() + { + GuiTextBoxCommonInterface* ci=dynamic_cast(processor->ownerComposition->GetRelatedControl()); + if(ci) + { + ci->Select(arguments.inputStart, arguments.inputEnd); + ci->SetSelectionText(arguments.originalText); + ci->Select(arguments.originalStart, arguments.originalEnd); + } + } + + void GuiTextBoxUndoRedoProcessor::EditStep::Redo() + { + GuiTextBoxCommonInterface* ci=dynamic_cast(processor->ownerComposition->GetRelatedControl()); + if(ci) + { + ci->Select(arguments.originalStart, arguments.originalEnd); + ci->SetSelectionText(arguments.inputText); + ci->Select(arguments.inputStart, arguments.inputEnd); + } + } + +/*********************************************************************** +GuiTextBoxUndoRedoProcessor +***********************************************************************/ + + GuiTextBoxUndoRedoProcessor::GuiTextBoxUndoRedoProcessor() + :ownerComposition(0) + { + } + + GuiTextBoxUndoRedoProcessor::~GuiTextBoxUndoRedoProcessor() + { + } + + void GuiTextBoxUndoRedoProcessor::Attach(elements::GuiColorizedTextElement* element, SpinLock& elementModifyLock, compositions::GuiGraphicsComposition* _ownerComposition, vuint editVersion) + { + ownerComposition=_ownerComposition; + } + + void GuiTextBoxUndoRedoProcessor::Detach() + { + ClearUndoRedo(); + } + + void GuiTextBoxUndoRedoProcessor::TextEditPreview(TextEditPreviewStruct& arguments) + { + } + + void GuiTextBoxUndoRedoProcessor::TextEditNotify(const TextEditNotifyStruct& arguments) + { + Ptr step=new EditStep; + step->processor=this; + step->arguments=arguments; + PushStep(step); + } + + void GuiTextBoxUndoRedoProcessor::TextCaretChanged(const TextCaretChangedStruct& arguments) + { + } + + void GuiTextBoxUndoRedoProcessor::TextEditFinished(vuint editVersion) + { + } + +/*********************************************************************** +GuiDocumentUndoRedoProcessor::ReplaceModelStep +***********************************************************************/ + + void GuiDocumentUndoRedoProcessor::ReplaceModelStep::Undo() + { + GuiDocumentCommonInterface* ci=dynamic_cast(processor->ownerComposition->GetRelatedControl()); + if(ci) + { + ci->EditRun(arguments.inputStart, arguments.inputEnd, arguments.originalModel, true); + ci->SetCaret(arguments.originalStart, arguments.originalEnd); + } + } + + void GuiDocumentUndoRedoProcessor::ReplaceModelStep::Redo() + { + GuiDocumentCommonInterface* ci=dynamic_cast(processor->ownerComposition->GetRelatedControl()); + if(ci) + { + ci->EditRun(arguments.originalStart, arguments.originalEnd, arguments.inputModel, true); + ci->SetCaret(arguments.inputStart, arguments.inputEnd); + } + } + +/*********************************************************************** +GuiDocumentUndoRedoProcessor::RenameStyleStep +***********************************************************************/ + + void GuiDocumentUndoRedoProcessor::RenameStyleStep::Undo() + { + GuiDocumentCommonInterface* ci=dynamic_cast(processor->ownerComposition->GetRelatedControl()); + if(ci) + { + ci->RenameStyle(arguments.newStyleName, arguments.oldStyleName); + } + } + + void GuiDocumentUndoRedoProcessor::RenameStyleStep::Redo() + { + GuiDocumentCommonInterface* ci=dynamic_cast(processor->ownerComposition->GetRelatedControl()); + if(ci) + { + ci->RenameStyle(arguments.oldStyleName, arguments.newStyleName); + } + } + +/*********************************************************************** +GuiDocumentUndoRedoProcessor::SetAlignmentStep +***********************************************************************/ + + void GuiDocumentUndoRedoProcessor::SetAlignmentStep::Undo() + { + GuiDocumentCommonInterface* ci=dynamic_cast(processor->ownerComposition->GetRelatedControl()); + if(ci) + { + ci->SetParagraphAlignments(TextPos(arguments->start, 0), TextPos(arguments->end, 0), arguments->originalAlignments); + } + } + + void GuiDocumentUndoRedoProcessor::SetAlignmentStep::Redo() + { + GuiDocumentCommonInterface* ci=dynamic_cast(processor->ownerComposition->GetRelatedControl()); + if(ci) + { + ci->SetParagraphAlignments(TextPos(arguments->start, 0), TextPos(arguments->end, 0), arguments->inputAlignments); + } + } + +/*********************************************************************** +GuiDocumentUndoRedoProcessor +***********************************************************************/ + + GuiDocumentUndoRedoProcessor::GuiDocumentUndoRedoProcessor() + :element(0) + ,ownerComposition(0) + { + } + + GuiDocumentUndoRedoProcessor::~GuiDocumentUndoRedoProcessor() + { + } + + void GuiDocumentUndoRedoProcessor::Setup(elements::GuiDocumentElement* _element, compositions::GuiGraphicsComposition* _ownerComposition) + { + element=_element; + ownerComposition=_ownerComposition; + } + + void GuiDocumentUndoRedoProcessor::OnReplaceModel(const ReplaceModelStruct& arguments) + { + Ptr step=new ReplaceModelStep; + step->processor=this; + step->arguments=arguments; + PushStep(step); + } + + void GuiDocumentUndoRedoProcessor::OnRenameStyle(const RenameStyleStruct& arguments) + { + Ptr step=new RenameStyleStep; + step->processor=this; + step->arguments=arguments; + PushStep(step); + } + + void GuiDocumentUndoRedoProcessor::OnSetAlignment(Ptr arguments) + { + Ptr step=new SetAlignmentStep; + step->processor=this; + step->arguments=arguments; + PushStep(step); + } + } + } +} + +/*********************************************************************** +.\CONTROLS\TEXTEDITORPACKAGE\GUIDOCUMENTVIEWER.CPP ***********************************************************************/ namespace vl @@ -25211,7 +15212,7 @@ GuiDocumentLabel } /*********************************************************************** -CONTROLS\TEXTEDITORPACKAGE\GUITEXTCOMMONINTERFACE.CPP +.\CONTROLS\TEXTEDITORPACKAGE\GUITEXTCOMMONINTERFACE.CPP ***********************************************************************/ namespace vl @@ -26149,7 +16150,7 @@ GuiTextBoxCommonInterface } /*********************************************************************** -CONTROLS\TEXTEDITORPACKAGE\GUITEXTCONTROLS.CPP +.\CONTROLS\TEXTEDITORPACKAGE\GUITEXTCONTROLS.CPP ***********************************************************************/ namespace vl @@ -26626,7 +16627,5554 @@ GuiSinglelineTextBox } /*********************************************************************** -CONTROLS\TEXTEDITORPACKAGE\EDITORCALLBACK\GUITEXTAUTOCOMPLETE.CPP +.\CONTROLS\LISTCONTROLPACKAGE\GUIBINDABLEDATAGRID.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace controls + { + using namespace collections; + using namespace description; + using namespace templates; + + namespace list + { + +/*********************************************************************** +DataFilterBase +***********************************************************************/ + + void DataFilterBase::InvokeOnProcessorChanged() + { + if (callback) + { + callback->OnProcessorChanged(); + } + } + + DataFilterBase::DataFilterBase() + { + } + + void DataFilterBase::SetCallback(IDataProcessorCallback* value) + { + callback = value; + } + +/*********************************************************************** +DataMultipleFilter +***********************************************************************/ + + DataMultipleFilter::DataMultipleFilter() + { + } + + bool DataMultipleFilter::AddSubFilter(Ptr value) + { + if (!value) return false; + if (filters.Contains(value.Obj())) return false; + filters.Add(value); + value->SetCallback(callback); + InvokeOnProcessorChanged(); + return true; + } + + bool DataMultipleFilter::RemoveSubFilter(Ptr value) + { + if (!value) return false; + if (!filters.Contains(value.Obj())) return false; + value->SetCallback(nullptr); + filters.Remove(value.Obj()); + InvokeOnProcessorChanged(); + return true; + } + + void DataMultipleFilter::SetCallback(IDataProcessorCallback* value) + { + DataFilterBase::SetCallback(value); + for (vint i = 0; i < filters.Count(); i++) + { + filters[i]->SetCallback(value); + } + } + +/*********************************************************************** +DataAndFilter +***********************************************************************/ + + DataAndFilter::DataAndFilter() + { + } + + bool DataAndFilter::Filter(const description::Value& row) + { + return From(filters) + .All([row](Ptr filter) + { + return filter->Filter(row); + }); + } + +/*********************************************************************** +DataOrFilter +***********************************************************************/ + + DataOrFilter::DataOrFilter() + { + } + + bool DataOrFilter::Filter(const description::Value& row) + { + return From(filters) + .Any([row](Ptr filter) + { + return filter->Filter(row); + }); + } + +/*********************************************************************** +DataNotFilter +***********************************************************************/ + + DataNotFilter::DataNotFilter() + { + } + + bool DataNotFilter::SetSubFilter(Ptr value) + { + if (filter == value) return false; + if (filter) filter->SetCallback(nullptr); + filter = value; + if (filter) filter->SetCallback(callback); + InvokeOnProcessorChanged(); + return true; + } + + void DataNotFilter::SetCallback(IDataProcessorCallback* value) + { + DataFilterBase::SetCallback(value); + if (filter) filter->SetCallback(value); + } + + bool DataNotFilter::Filter(const description::Value& row) + { + return filter ? true : !filter->Filter(row); + } + +/*********************************************************************** +DataSorterBase +***********************************************************************/ + + void DataSorterBase::InvokeOnProcessorChanged() + { + if (callback) + { + callback->OnProcessorChanged(); + } + } + + DataSorterBase::DataSorterBase() + { + } + + void DataSorterBase::SetCallback(IDataProcessorCallback* value) + { + callback = value; + } + +/*********************************************************************** +DataMultipleSorter +***********************************************************************/ + + DataMultipleSorter::DataMultipleSorter() + { + } + + bool DataMultipleSorter::SetLeftSorter(Ptr value) + { + if (leftSorter == value) return false; + if (leftSorter) leftSorter->SetCallback(nullptr); + leftSorter = value; + if (leftSorter) leftSorter->SetCallback(callback); + return true; + } + + bool DataMultipleSorter::SetRightSorter(Ptr value) + { + if (rightSorter == value) return false; + if (rightSorter) rightSorter->SetCallback(nullptr); + rightSorter = value; + if (rightSorter) rightSorter->SetCallback(callback); + return true; + } + + void DataMultipleSorter::SetCallback(IDataProcessorCallback* value) + { + DataSorterBase::SetCallback(value); + if (leftSorter) leftSorter->SetCallback(value); + if (rightSorter) rightSorter->SetCallback(value); + } + + vint DataMultipleSorter::Compare(const description::Value& row1, const description::Value& row2) + { + if (leftSorter) + { + vint result = leftSorter->Compare(row1, row2); + if (result != 0) return result; + } + if (rightSorter) + { + vint result = rightSorter->Compare(row1, row2); + if (result != 0) return result; + } + return 0; + } + +/*********************************************************************** +DataReverseSorter +***********************************************************************/ + + DataReverseSorter::DataReverseSorter() + { + } + + bool DataReverseSorter::SetSubSorter(Ptr value) + { + if (sorter == value) return false; + if (sorter) sorter->SetCallback(nullptr); + sorter = value; + if (sorter) sorter->SetCallback(callback); + return true; + } + + void DataReverseSorter::SetCallback(IDataProcessorCallback* value) + { + DataSorterBase::SetCallback(value); + if (sorter) sorter->SetCallback(value); + } + + vint DataReverseSorter::Compare(const description::Value& row1, const description::Value& row2) + { + return sorter ? -sorter->Compare(row1, row2) : 0; + } + +/*********************************************************************** +DataColumn +***********************************************************************/ + + void DataColumn::NotifyAllColumnsUpdate(bool affectItem) + { + if (dataProvider) + { + vint index = dataProvider->columns.IndexOf(this); + if (index != -1) + { + dataProvider->columns.NotifyColumnUpdated(index, affectItem); + } + } + } + + DataColumn::DataColumn() + { + } + + DataColumn::~DataColumn() + { + if (popup && ownPopup) + { + SafeDeleteControl(popup); + } + } + + WString DataColumn::GetText() + { + return text; + } + + void DataColumn::SetText(const WString& value) + { + if (text != value) + { + text = value; + NotifyAllColumnsUpdate(false); + } + } + + vint DataColumn::GetSize() + { + return size; + } + + void DataColumn::SetSize(vint value) + { + if (size != value) + { + size = value; + NotifyAllColumnsUpdate(false); + } + } + + bool DataColumn::GetOwnPopup() + { + return ownPopup; + } + + void DataColumn::SetOwnPopup(bool value) + { + ownPopup = value; + } + + GuiMenu* DataColumn::GetPopup() + { + return popup; + } + + void DataColumn::SetPopup(GuiMenu* value) + { + if (popup != value) + { + popup = value; + NotifyAllColumnsUpdate(false); + } + } + + Ptr DataColumn::GetFilter() + { + return associatedFilter; + } + + void DataColumn::SetFilter(Ptr value) + { + if (associatedFilter) associatedFilter->SetCallback(nullptr); + associatedFilter = value; + if (associatedFilter) associatedFilter->SetCallback(dataProvider); + NotifyAllColumnsUpdate(false); + } + + Ptr DataColumn::GetSorter() + { + return associatedSorter; + } + + void DataColumn::SetSorter(Ptr value) + { + if (associatedSorter) associatedSorter->SetCallback(nullptr); + associatedSorter = value; + if (associatedSorter) associatedSorter->SetCallback(dataProvider); + NotifyAllColumnsUpdate(false); + } + + Ptr DataColumn::GetVisualizerFactory() + { + return visualizerFactory; + } + + void DataColumn::SetVisualizerFactory(Ptr value) + { + visualizerFactory = value; + NotifyAllColumnsUpdate(true); + } + + Ptr DataColumn::GetEditorFactory() + { + return editorFactory; + } + + void DataColumn::SetEditorFactory(Ptr value) + { + editorFactory = value; + NotifyAllColumnsUpdate(true); + } + + WString DataColumn::GetCellText(vint row) + { + if (0 <= row && row < dataProvider->Count()) + { + return ReadProperty(dataProvider->GetBindingValue(row), textProperty); + } + return L""; + } + + description::Value DataColumn::GetCellValue(vint row) + { + if (0 <= row && row < dataProvider->Count()) + { + return ReadProperty(dataProvider->GetBindingValue(row), valueProperty); + } + return Value(); + } + + void DataColumn::SetCellValue(vint row, description::Value value) + { + if (0 <= row && row < dataProvider->Count()) + { + auto rowValue = dataProvider->GetBindingValue(row); + WriteProperty(rowValue, valueProperty, value); + dataProvider->InvokeOnItemModified(row, 1, 1); + } + } + + ItemProperty DataColumn::GetTextProperty() + { + return textProperty; + } + + void DataColumn::SetTextProperty(const ItemProperty& value) + { + if (textProperty != value) + { + textProperty = value; + NotifyAllColumnsUpdate(true); + compositions::GuiEventArgs arguments; + TextPropertyChanged.Execute(arguments); + } + } + + WritableItemProperty DataColumn::GetValueProperty() + { + return valueProperty; + } + + void DataColumn::SetValueProperty(const WritableItemProperty& value) + { + if (valueProperty != value) + { + valueProperty = value; + NotifyAllColumnsUpdate(true); + compositions::GuiEventArgs arguments; + ValuePropertyChanged.Execute(arguments); + } + } + +/*********************************************************************** +DataColumns +***********************************************************************/ + + void DataColumns::NotifyColumnUpdated(vint index, bool affectItem) + { + affectItemFlag = affectItem; + NotifyUpdateInternal(index, 1, 1); + affectItemFlag = true; + } + + void DataColumns::NotifyUpdateInternal(vint start, vint count, vint newCount) + { + dataProvider->NotifyAllColumnsUpdate(); + if (affectItemFlag) + { + dataProvider->NotifyAllItemsUpdate(); + } + } + + bool DataColumns::QueryInsert(vint index, const Ptr& value) + { + return !items.Contains(value.Obj()); + } + + void DataColumns::AfterInsert(vint index, const Ptr& value) + { + value->dataProvider = dataProvider; + } + + void DataColumns::BeforeRemove(vint index, const Ptr& value) + { + value->dataProvider = nullptr; + } + + DataColumns::DataColumns(DataProvider* _dataProvider) + :dataProvider(_dataProvider) + { + } + + DataColumns::~DataColumns() + { + } + +/*********************************************************************** +DataProvider +***********************************************************************/ + + void DataProvider::NotifyAllItemsUpdate() + { + InvokeOnItemModified(0, Count(), Count()); + } + + void DataProvider::NotifyAllColumnsUpdate() + { + if (columnItemViewCallback) + { + columnItemViewCallback->OnColumnChanged(); + } + } + + GuiListControl::IItemProvider* DataProvider::GetItemProvider() + { + return this; + } + + void DataProvider::OnProcessorChanged() + { + RebuildFilter(); + ReorderRows(true); + } + + void DataProvider::OnItemSourceModified(vint start, vint count, vint newCount) + { + if (!currentSorter && !currentFilter && count == newCount) + { + InvokeOnItemModified(start, count, newCount); + } + else + { + ReorderRows(true); + } + } + + ListViewDataColumns& DataProvider::GetDataColumns() + { + return dataColumns; + } + + DataColumns& DataProvider::GetColumns() + { + return columns; + } + + Ptr DataProvider::GetItemSource() + { + return itemSource; + } + + void DataProvider::SetItemSource(Ptr _itemSource) + { + vint oldCount = 0; + if (itemSource) + { + oldCount = itemSource->GetCount(); + } + if (itemChangedEventHandler) + { + auto ol = itemSource.Cast(); + ol->ItemChanged.Remove(itemChangedEventHandler); + } + + itemSource = nullptr; + itemChangedEventHandler = nullptr; + + if (_itemSource) + { + if (auto ol = _itemSource.Cast()) + { + itemSource = ol; + itemChangedEventHandler = ol->ItemChanged.Add([this](vint start, vint oldCount, vint newCount) + { + OnItemSourceModified(start, oldCount, newCount); + }); + } + else if (auto rl = _itemSource.Cast()) + { + itemSource = rl; + } + else + { + itemSource = IValueList::Create(GetLazyList(_itemSource)); + } + } + + OnItemSourceModified(0, oldCount, itemSource ? itemSource->GetCount() : 0); + } + + void DataProvider::RebuildFilter() + { + if (currentFilter) + { + currentFilter->SetCallback(nullptr); + currentFilter = nullptr; + } + + List> selectedFilters; + CopyFrom( + selectedFilters, + From(columns) + .Select([](Ptr column) {return column->GetFilter(); }) + .Where([](Ptr filter) {return filter != nullptr; }) + ); + if (additionalFilter) + { + selectedFilters.Add(additionalFilter); + } + if (selectedFilters.Count() > 0) + { + auto andFilter = MakePtr(); + FOREACH(Ptr, filter, selectedFilters) + { + andFilter->AddSubFilter(filter); + } + currentFilter = andFilter; + } + + if (currentFilter) + { + currentFilter->SetCallback(this); + } + } + + void DataProvider::ReorderRows(bool invokeCallback) + { + vint oldRowCount = virtualRowToSourceRow.Count(); + virtualRowToSourceRow.Clear(); + vint rowCount = itemSource ? itemSource->GetCount() : 0; + + if (currentFilter) + { + for (vint i = 0; i < rowCount; i++) + { + if (currentFilter->Filter(itemSource->Get(i))) + { + virtualRowToSourceRow.Add(i); + } + } + } + else + { + for (vint i = 0; i < rowCount; i++) + { + virtualRowToSourceRow.Add(i); + } + } + + if (currentSorter && virtualRowToSourceRow.Count() > 0) + { + IDataSorter* sorter = currentSorter.Obj(); + SortLambda( + &virtualRowToSourceRow[0], + virtualRowToSourceRow.Count(), + [=](vint a, vint b) + { + return sorter->Compare(itemSource->Get(a), itemSource->Get(b)); + }); + } + + if (invokeCallback) + { + NotifyAllItemsUpdate(); + } + } + + DataProvider::DataProvider(const description::Value& _viewModelContext) + :dataColumns(this) + , columns(this) + , viewModelContext(_viewModelContext) + { + RebuildFilter(); + ReorderRows(false); + } + + DataProvider::~DataProvider() + { + } + + Ptr DataProvider::GetAdditionalFilter() + { + return additionalFilter; + } + + void DataProvider::SetAdditionalFilter(Ptr value) + { + additionalFilter = value; + RebuildFilter(); + ReorderRows(true); + } + + // ===================== GuiListControl::IItemProvider ===================== + + vint DataProvider::Count() + { + return virtualRowToSourceRow.Count(); + } + + WString DataProvider::GetTextValue(vint itemIndex) + { + return GetText(itemIndex); + } + + description::Value DataProvider::GetBindingValue(vint itemIndex) + { + return itemSource ? itemSource->Get(virtualRowToSourceRow[itemIndex]) : Value(); + } + + IDescriptable* DataProvider::RequestView(const WString& identifier) + { + if (identifier == IListViewItemView::Identifier) + { + return (IListViewItemView*)this; + } + else if (identifier == ListViewColumnItemArranger::IColumnItemView::Identifier) + { + return (ListViewColumnItemArranger::IColumnItemView*)this; + } + else if (identifier == IDataGridView::Identifier) + { + return (IDataGridView*)this; + } + else + { + return nullptr; + } + } + + // ===================== list::IListViewItemProvider ===================== + + Ptr DataProvider::GetSmallImage(vint itemIndex) + { + if (0 <= itemIndex && itemIndex < Count()) + { + return ReadProperty(GetBindingValue(itemIndex), smallImageProperty); + } + return nullptr; + } + + Ptr DataProvider::GetLargeImage(vint itemIndex) + { + if (0 <= itemIndex && itemIndex < Count()) + { + return ReadProperty(GetBindingValue(itemIndex), largeImageProperty); + } + return nullptr; + } + + WString DataProvider::GetText(vint itemIndex) + { + if (columns.Count() == 0)return L""; + return columns[0]->GetCellText(itemIndex); + } + + WString DataProvider::GetSubItem(vint itemIndex, vint index) + { + return columns[index + 1]->GetCellText(itemIndex); + } + + vint DataProvider::GetDataColumnCount() + { + return dataColumns.Count(); + } + + vint DataProvider::GetDataColumn(vint index) + { + return dataColumns[index]; + } + + vint DataProvider::GetColumnCount() + { + return columns.Count(); + } + + WString DataProvider::GetColumnText(vint index) + { + return columns[index]->GetText(); + } + + // ===================== list::ListViewColumnItemArranger::IColumnItemView ===================== + + bool DataProvider::AttachCallback(ListViewColumnItemArranger::IColumnItemViewCallback* value) + { + if (columnItemViewCallback)return false; + columnItemViewCallback = value; + return true; + } + + bool DataProvider::DetachCallback(ListViewColumnItemArranger::IColumnItemViewCallback* value) + { + if (!columnItemViewCallback) return false; + columnItemViewCallback = nullptr; + return true; + } + + vint DataProvider::GetColumnSize(vint index) + { + return columns[index]->GetSize(); + } + + void DataProvider::SetColumnSize(vint index, vint value) + { + columns[index]->SetSize(value); + } + + GuiMenu* DataProvider::GetDropdownPopup(vint index) + { + return columns[index]->GetPopup(); + } + + ColumnSortingState DataProvider::GetSortingState(vint index) + { + return columns[index]->sortingState; + } + + // ===================== list::IDataGridView ===================== + + description::Value DataProvider::GetViewModelContext() + { + return viewModelContext; + } + + bool DataProvider::IsColumnSortable(vint column) + { + return columns[column]->GetSorter(); + } + + void DataProvider::SortByColumn(vint column, bool ascending) + { + if (0 <= column && column < columns.Count()) + { + auto sorter = columns[column]->GetSorter(); + if (!sorter) + { + currentSorter = nullptr; + } + else if (ascending) + { + currentSorter = sorter; + } + else + { + Ptr reverseSorter = new DataReverseSorter(); + reverseSorter->SetSubSorter(sorter); + currentSorter = reverseSorter; + } + } + else + { + currentSorter = nullptr; + } + + for (vint i = 0; i < columns.Count(); i++) + { + columns[i]->sortingState = + i != column ? ColumnSortingState::NotSorted : + ascending ? ColumnSortingState::Ascending : + ColumnSortingState::Descending + ; + } + NotifyAllColumnsUpdate(); + ReorderRows(true); + } + + vint DataProvider::GetSortedColumn() + { + for (vint i = 0; i < columns.Count(); i++) + { + auto state = columns[i]->sortingState; + if (state != ColumnSortingState::NotSorted) + { + return i; + } + } + return -1; + } + + bool DataProvider::IsSortOrderAscending() + { + for (vint i = 0; i < columns.Count(); i++) + { + auto state = columns[i]->sortingState; + if (state != ColumnSortingState::NotSorted) + { + return state == ColumnSortingState::Ascending; + } + } + return true; + } + + vint DataProvider::GetCellSpan(vint row, vint column) + { + return 1; + } + + IDataVisualizerFactory* DataProvider::GetCellDataVisualizerFactory(vint row, vint column) + { + return columns[column]->GetVisualizerFactory().Obj(); + } + + IDataEditorFactory* DataProvider::GetCellDataEditorFactory(vint row, vint column) + { + return columns[column]->GetEditorFactory().Obj(); + } + + description::Value DataProvider::GetBindingCellValue(vint row, vint column) + { + return columns[column]->GetCellValue(row); + } + + void DataProvider::SetBindingCellValue(vint row, vint column, const description::Value& value) + { + columns[column]->SetCellValue(row, value); + } + } + +/*********************************************************************** +GuiBindableDataGrid +***********************************************************************/ + + GuiBindableDataGrid::GuiBindableDataGrid(IStyleProvider* _styleProvider, const description::Value& _viewModelContext) + :GuiVirtualDataGrid(_styleProvider, new list::DataProvider(_viewModelContext)) + { + dataProvider = dynamic_cast(GetItemProvider()); + } + + GuiBindableDataGrid::~GuiBindableDataGrid() + { + } + + list::ListViewDataColumns& GuiBindableDataGrid::GetDataColumns() + { + return dataProvider->GetDataColumns(); + } + + list::DataColumns& GuiBindableDataGrid::GetColumns() + { + return dataProvider->GetColumns(); + } + + Ptr GuiBindableDataGrid::GetItemSource() + { + return dataProvider->GetItemSource(); + } + + void GuiBindableDataGrid::SetItemSource(Ptr _itemSource) + { + dataProvider->SetItemSource(_itemSource); + } + + Ptr GuiBindableDataGrid::GetAdditionalFilter() + { + return dataProvider->GetAdditionalFilter(); + } + + void GuiBindableDataGrid::SetAdditionalFilter(Ptr value) + { + dataProvider->SetAdditionalFilter(value); + } + + ItemProperty> GuiBindableDataGrid::GetLargeImageProperty() + { + return dataProvider->largeImageProperty; + } + + void GuiBindableDataGrid::SetLargeImageProperty(const ItemProperty>& value) + { + if (dataProvider->largeImageProperty != value) + { + dataProvider->largeImageProperty = value; + dataProvider->NotifyAllItemsUpdate(); + LargeImagePropertyChanged.Execute(GetNotifyEventArguments()); + } + } + + ItemProperty> GuiBindableDataGrid::GetSmallImageProperty() + { + return dataProvider->smallImageProperty; + } + + void GuiBindableDataGrid::SetSmallImageProperty(const ItemProperty>& value) + { + if (dataProvider->smallImageProperty != value) + { + dataProvider->smallImageProperty = value; + dataProvider->NotifyAllItemsUpdate(); + SmallImagePropertyChanged.Execute(GetNotifyEventArguments()); + } + } + + description::Value GuiBindableDataGrid::GetSelectedRowValue() + { + auto pos = GetSelectedCell(); + if (pos.row == -1 || pos.column == -1) + { + return Value(); + } + return dataProvider->GetBindingValue(GetSelectedCell().row); + } + + description::Value GuiBindableDataGrid::GetSelectedCellValue() + { + auto pos = GetSelectedCell(); + if (pos.row == -1 || pos.column == -1) + { + return Value(); + } + return dataProvider->GetColumns()[pos.column]->GetCellValue(pos.row); + } + } + } +} + +/*********************************************************************** +.\CONTROLS\LISTCONTROLPACKAGE\GUILISTVIEWCONTROLS.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace controls + { + using namespace elements; + using namespace compositions; + using namespace collections; + using namespace reflection::description; + +/*********************************************************************** +GuiListViewColumnHeader +***********************************************************************/ + + GuiListViewColumnHeader::GuiListViewColumnHeader(IStyleController* _styleController) + :GuiMenuButton(_styleController) + ,styleController(_styleController) + { + styleController->SetColumnSortingState(columnSortingState); + } + + GuiListViewColumnHeader::~GuiListViewColumnHeader() + { + } + + bool GuiListViewColumnHeader::IsAltAvailable() + { + return false; + } + + ColumnSortingState GuiListViewColumnHeader::GetColumnSortingState() + { + return columnSortingState; + } + + void GuiListViewColumnHeader::SetColumnSortingState(ColumnSortingState value) + { + if(columnSortingState!=value) + { + columnSortingState=value; + styleController->SetColumnSortingState(columnSortingState); + } + } + +/*********************************************************************** +GuiListViewBase +***********************************************************************/ + + GuiListViewBase::GuiListViewBase(IStyleProvider* _styleProvider, GuiListControl::IItemProvider* _itemProvider) + :GuiSelectableListControl(_styleProvider, _itemProvider) + ,styleProvider(0) + { + styleProvider=dynamic_cast(styleController->GetStyleProvider()); + ColumnClicked.SetAssociatedComposition(boundsComposition); + } + + GuiListViewBase::~GuiListViewBase() + { + } + + GuiListViewBase::IStyleProvider* GuiListViewBase::GetListViewStyleProvider() + { + return styleProvider; + } + + namespace list + { + + const wchar_t* const IListViewItemView::Identifier = L"vl::presentation::controls::list::IListViewItemView"; + +/*********************************************************************** +ListViewColumnItemArranger::ColumnItemViewCallback +***********************************************************************/ + + ListViewColumnItemArranger::ColumnItemViewCallback::ColumnItemViewCallback(ListViewColumnItemArranger* _arranger) + :arranger(_arranger) + { + } + + ListViewColumnItemArranger::ColumnItemViewCallback::~ColumnItemViewCallback() + { + } + + void ListViewColumnItemArranger::ColumnItemViewCallback::OnColumnChanged() + { + arranger->RebuildColumns(); + FOREACH(ItemStyleRecord, style, arranger->visibleStyles) + { + if (auto callback = dynamic_cast(style.key)) + { + callback->OnColumnChanged(); + } + } + } + +/*********************************************************************** +ListViewColumnItemArranger +***********************************************************************/ + + const wchar_t* const ListViewColumnItemArranger::IColumnItemView::Identifier = L"vl::presentation::controls::list::ListViewColumnItemArranger::IColumnItemView"; + + void ListViewColumnItemArranger::ColumnClicked(vint index, compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + GuiItemEventArgs args(listView->ColumnClicked.GetAssociatedComposition()); + args.itemIndex=index; + listView->ColumnClicked.Execute(args); + } + + void ListViewColumnItemArranger::ColumnBoundsChanged(vint index, compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + GuiBoundsComposition* buttonBounds=columnHeaderButtons[index]->GetBoundsComposition(); + vint size=buttonBounds->GetBounds().Width(); + if(size>columnItemView->GetColumnSize(index)) + { + columnItemView->SetColumnSize(index, size); + } + } + + void ListViewColumnItemArranger::ColumnHeaderSplitterLeftButtonDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) + { + if(listView->GetVisuallyEnabled()) + { + arguments.handled=true; + splitterDragging=true; + splitterLatestX=arguments.x; + } + } + + void ListViewColumnItemArranger::ColumnHeaderSplitterLeftButtonUp(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) + { + if(listView->GetVisuallyEnabled()) + { + arguments.handled=true; + splitterDragging=false; + splitterLatestX=0; + } + } + + void ListViewColumnItemArranger::ColumnHeaderSplitterMouseMove(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) + { + if(splitterDragging) + { + vint offset=arguments.x-splitterLatestX; + vint index=columnHeaderSplitters.IndexOf(dynamic_cast(sender)); + if(index!=-1) + { + GuiBoundsComposition* buttonBounds=columnHeaderButtons[index]->GetBoundsComposition(); + Rect bounds=buttonBounds->GetBounds(); + Rect newBounds(bounds.LeftTop(), Size(bounds.Width()+offset, bounds.Height())); + buttonBounds->SetBounds(newBounds); + + vint finalSize=buttonBounds->GetBounds().Width(); + columnItemView->SetColumnSize(index, finalSize); + } + } + } + + void ListViewColumnItemArranger::RearrangeItemBounds() + { + FixedHeightItemArranger::RearrangeItemBounds(); + vint count = columnHeaders->GetParent()->Children().Count(); + columnHeaders->GetParent()->MoveChild(columnHeaders, count - 1); + columnHeaders->SetBounds(Rect(Point(-viewBounds.Left(), 0), Size(0, 0))); + } + + vint ListViewColumnItemArranger::GetWidth() + { + vint width=columnHeaders->GetBounds().Width()-SplitterWidth; + if(widthGetBounds().Height(); + } + + Size ListViewColumnItemArranger::OnCalculateTotalSize() + { + Size size=FixedHeightItemArranger::OnCalculateTotalSize(); + size.x+=SplitterWidth; + return size; + } + + void ListViewColumnItemArranger::DeleteColumnButtons() + { + for(vint i=columnHeaders->GetStackItems().Count()-1;i>=0;i--) + { + GuiStackItemComposition* item=columnHeaders->GetStackItems().Get(i); + columnHeaders->RemoveChild(item); + + GuiControl* button=item->Children().Get(0)->GetAssociatedControl(); + if(button) + { + item->RemoveChild(button->GetBoundsComposition()); + delete button; + } + delete item; + } + columnHeaderButtons.Clear(); + columnHeaderSplitters.Clear(); + } + + void ListViewColumnItemArranger::RebuildColumns() + { + if (columnItemView && columnHeaderButtons.Count() == listViewItemView->GetColumnCount()) + { + for (vint i = 0; i < listViewItemView->GetColumnCount(); i++) + { + GuiListViewColumnHeader* button = columnHeaderButtons[i]; + button->SetText(listViewItemView->GetColumnText(i)); + button->SetSubMenu(columnItemView->GetDropdownPopup(i), false); + button->SetColumnSortingState(columnItemView->GetSortingState(i)); + button->GetBoundsComposition()->SetBounds(Rect(Point(0, 0), Size(columnItemView->GetColumnSize(i), 0))); + } + } + else + { + DeleteColumnButtons(); + if (columnItemView && listViewItemView) + { + for (vint i = 0; i < listViewItemView->GetColumnCount(); i++) + { + GuiBoundsComposition* splitterComposition = new GuiBoundsComposition; + splitterComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); + splitterComposition->SetAssociatedCursor(GetCurrentController()->ResourceService()->GetSystemCursor(INativeCursor::SizeWE)); + splitterComposition->SetAlignmentToParent(Margin(0, 0, -1, 0)); + splitterComposition->SetPreferredMinSize(Size(SplitterWidth, 0)); + columnHeaderSplitters.Add(splitterComposition); + + splitterComposition->GetEventReceiver()->leftButtonDown.AttachMethod(this, &ListViewColumnItemArranger::ColumnHeaderSplitterLeftButtonDown); + splitterComposition->GetEventReceiver()->leftButtonUp.AttachMethod(this, &ListViewColumnItemArranger::ColumnHeaderSplitterLeftButtonUp); + splitterComposition->GetEventReceiver()->mouseMove.AttachMethod(this, &ListViewColumnItemArranger::ColumnHeaderSplitterMouseMove); + } + for (vint i = 0; i < listViewItemView->GetColumnCount(); i++) + { + GuiListViewColumnHeader* button = new GuiListViewColumnHeader(styleProvider->CreateColumnStyle()); + button->SetText(listViewItemView->GetColumnText(i)); + button->SetSubMenu(columnItemView->GetDropdownPopup(i), false); + button->SetColumnSortingState(columnItemView->GetSortingState(i)); + button->GetBoundsComposition()->SetBounds(Rect(Point(0, 0), Size(columnItemView->GetColumnSize(i), 0))); + button->Clicked.AttachLambda(Curry(Func(this, &ListViewColumnItemArranger::ColumnClicked))(i)); + button->GetBoundsComposition()->BoundsChanged.AttachLambda(Curry(Func(this, &ListViewColumnItemArranger::ColumnBoundsChanged))(i)); + columnHeaderButtons.Add(button); + if (i > 0) + { + button->GetContainerComposition()->AddChild(columnHeaderSplitters[i - 1]); + } + + GuiStackItemComposition* item = new GuiStackItemComposition; + item->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + item->AddChild(button->GetBoundsComposition()); + columnHeaders->AddChild(item); + } + if (listViewItemView->GetColumnCount() > 0) + { + GuiBoundsComposition* splitterComposition = columnHeaderSplitters[listViewItemView->GetColumnCount() - 1]; + + GuiStackItemComposition* item = new GuiStackItemComposition; + item->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + item->AddChild(splitterComposition); + columnHeaders->AddChild(item); + } + } + } + callback->OnTotalSizeChanged(); + } + + ListViewColumnItemArranger::ListViewColumnItemArranger() + { + columnHeaders = new GuiStackComposition; + columnHeaders->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + columnItemViewCallback = new ColumnItemViewCallback(this); + } + + ListViewColumnItemArranger::~ListViewColumnItemArranger() + { + if(!columnHeaders->GetParent()) + { + DeleteColumnButtons(); + delete columnHeaders; + } + } + + void ListViewColumnItemArranger::AttachListControl(GuiListControl* value) + { + FixedHeightItemArranger::AttachListControl(value); + listView = dynamic_cast(value); + if (listView) + { + styleProvider = listView->GetListViewStyleProvider(); + listView->GetContainerComposition()->AddChild(columnHeaders); + listViewItemView = dynamic_cast(listView->GetItemProvider()->RequestView(IListViewItemView::Identifier)); + columnItemView = dynamic_cast(listView->GetItemProvider()->RequestView(IColumnItemView::Identifier)); + if (columnItemView) + { + columnItemView->AttachCallback(columnItemViewCallback.Obj()); + RebuildColumns(); + } + } + } + + void ListViewColumnItemArranger::DetachListControl() + { + if (listView) + { + if (columnItemView) + { + columnItemView->DetachCallback(columnItemViewCallback.Obj()); + columnItemView = nullptr; + } + listViewItemView = nullptr; + listView->GetContainerComposition()->RemoveChild(columnHeaders); + styleProvider = nullptr; + listView = nullptr; + } + FixedHeightItemArranger::DetachListControl(); + } + +/*********************************************************************** +ListViewSubItems +***********************************************************************/ + + void ListViewSubItems::NotifyUpdateInternal(vint start, vint count, vint newCount) + { + owner->NotifyUpdate(); + } + +/*********************************************************************** +ListViewItem +***********************************************************************/ + + void ListViewItem::NotifyUpdate() + { + if (owner) + { + vint index = owner->IndexOf(this); + owner->NotifyUpdateInternal(index, 1, 1); + } + } + + ListViewItem::ListViewItem() + :owner(0) + { + subItems.owner = this; + } + + ListViewSubItems& ListViewItem::GetSubItems() + { + return subItems; + } + + Ptr ListViewItem::GetSmallImage() + { + return smallImage; + } + + void ListViewItem::SetSmallImage(Ptr value) + { + smallImage = value; + NotifyUpdate(); + } + + Ptr ListViewItem::GetLargeImage() + { + return largeImage; + } + + void ListViewItem::SetLargeImage(Ptr value) + { + largeImage = value; + NotifyUpdate(); + } + + const WString& ListViewItem::GetText() + { + return text; + } + + void ListViewItem::SetText(const WString& value) + { + text = value; + NotifyUpdate(); + } + + description::Value ListViewItem::GetTag() + { + return tag; + } + + void ListViewItem::SetTag(const description::Value& value) + { + tag = value; + NotifyUpdate(); + } + +/*********************************************************************** +ListViewColumn +***********************************************************************/ + + void ListViewColumn::NotifyUpdate(bool affectItem) + { + if (owner) + { + vint index = owner->IndexOf(this); + owner->NotifyColumnUpdated(index, affectItem); + } + } + + ListViewColumn::ListViewColumn(const WString& _text, vint _size) + :text(_text) + ,size(_size) + { + } + + ListViewColumn::~ListViewColumn() + { + if (dropdownPopup && ownPopup) + { + SafeDeleteControl(dropdownPopup); + } + } + + const WString& ListViewColumn::GetText() + { + return text; + } + + void ListViewColumn::SetText(const WString& value) + { + if (text != value) + { + text = value; + NotifyUpdate(false); + } + } + + ItemProperty ListViewColumn::GetTextProperty() + { + return textProperty; + } + + void ListViewColumn::SetTextProperty(const ItemProperty& value) + { + textProperty = value; + NotifyUpdate(true); + } + + vint ListViewColumn::GetSize() + { + return size; + } + + void ListViewColumn::SetSize(vint value) + { + if (size != value) + { + size = value; + NotifyUpdate(false); + } + } + + bool ListViewColumn::GetOwnPopup() + { + return ownPopup; + } + + void ListViewColumn::SetOwnPopup(bool value) + { + ownPopup = value; + } + + GuiMenu* ListViewColumn::GetDropdownPopup() + { + return dropdownPopup; + } + + void ListViewColumn::SetDropdownPopup(GuiMenu* value) + { + if (dropdownPopup != value) + { + dropdownPopup = value; + NotifyUpdate(false); + } + } + + ColumnSortingState ListViewColumn::GetSortingState() + { + return sortingState; + } + + void ListViewColumn::SetSortingState(ColumnSortingState value) + { + if (sortingState != value) + { + sortingState = value; + NotifyUpdate(false); + } + } + +/*********************************************************************** +ListViewDataColumns +***********************************************************************/ + + void ListViewDataColumns::NotifyUpdateInternal(vint start, vint count, vint newCount) + { + itemProvider->NotifyAllItemsUpdate(); + } + + ListViewDataColumns::ListViewDataColumns(IListViewItemProvider* _itemProvider) + :itemProvider(_itemProvider) + { + } + + ListViewDataColumns::~ListViewDataColumns() + { + } + +/*********************************************************************** +ListViewColumns +***********************************************************************/ + + void ListViewColumns::NotifyColumnUpdated(vint column, bool affectItem) + { + affectItemFlag = affectItem; + NotifyUpdate(column, 1); + affectItemFlag = true; + } + + void ListViewColumns::AfterInsert(vint index, const Ptr& value) + { + collections::ObservableListBase>::AfterInsert(index, value); + value->owner = this; + } + + void ListViewColumns::BeforeRemove(vint index, const Ptr& value) + { + value->owner = 0; + collections::ObservableListBase>::BeforeRemove(index, value); + } + + void ListViewColumns::NotifyUpdateInternal(vint start, vint count, vint newCount) + { + itemProvider->NotifyAllColumnsUpdate(); + if (affectItemFlag) + { + itemProvider->NotifyAllItemsUpdate(); + } + } + + ListViewColumns::ListViewColumns(IListViewItemProvider* _itemProvider) + :itemProvider(_itemProvider) + { + } + + ListViewColumns::~ListViewColumns() + { + } + +/*********************************************************************** +ListViewItemProvider +***********************************************************************/ + + void ListViewItemProvider::AfterInsert(vint index, const Ptr& value) + { + ListProvider>::AfterInsert(index, value); + value->owner = this; + } + + void ListViewItemProvider::BeforeRemove(vint index, const Ptr& value) + { + value->owner = 0; + ListProvider>::AfterInsert(index, value); + } + + void ListViewItemProvider::NotifyAllItemsUpdate() + { + NotifyUpdate(0, Count()); + } + + void ListViewItemProvider::NotifyAllColumnsUpdate() + { + for (vint i = 0; i < columnItemViewCallbacks.Count(); i++) + { + columnItemViewCallbacks[i]->OnColumnChanged(); + } + } + + Ptr ListViewItemProvider::GetSmallImage(vint itemIndex) + { + return Get(itemIndex)->smallImage; + } + + Ptr ListViewItemProvider::GetLargeImage(vint itemIndex) + { + return Get(itemIndex)->largeImage; + } + + WString ListViewItemProvider::GetText(vint itemIndex) + { + return Get(itemIndex)->text; + } + + WString ListViewItemProvider::GetSubItem(vint itemIndex, vint index) + { + Ptr item=Get(itemIndex); + if(index<0 || index>=item->GetSubItems().Count()) + { + return L""; + } + else + { + return item->GetSubItems()[index]; + } + } + + vint ListViewItemProvider::GetDataColumnCount() + { + return dataColumns.Count(); + } + + vint ListViewItemProvider::GetDataColumn(vint index) + { + return dataColumns[index]; + } + + vint ListViewItemProvider::GetColumnCount() + { + return columns.Count(); + } + + WString ListViewItemProvider::GetColumnText(vint index) + { + if (index<0 || index >= columns.Count()) + { + return L""; + } + else + { + return columns[index]->GetText(); + } + } + + bool ListViewItemProvider::AttachCallback(ListViewColumnItemArranger::IColumnItemViewCallback* value) + { + if(columnItemViewCallbacks.Contains(value)) + { + return false; + } + else + { + columnItemViewCallbacks.Add(value); + return true; + } + } + + bool ListViewItemProvider::DetachCallback(ListViewColumnItemArranger::IColumnItemViewCallback* value) + { + vint index=columnItemViewCallbacks.IndexOf(value); + if(index==-1) + { + return false; + } + else + { + columnItemViewCallbacks.Remove(value); + return true; + } + } + + vint ListViewItemProvider::GetColumnSize(vint index) + { + if(index<0 || index>=columns.Count()) + { + return 0; + } + else + { + return columns[index]->GetSize(); + } + } + + void ListViewItemProvider::SetColumnSize(vint index, vint value) + { + if(index>=0 && indexSetSize(value); + } + } + + GuiMenu* ListViewItemProvider::GetDropdownPopup(vint index) + { + if(index<0 || index>=columns.Count()) + { + return 0; + } + else + { + return columns[index]->GetDropdownPopup(); + } + } + + ColumnSortingState ListViewItemProvider::GetSortingState(vint index) + { + if (index < 0 || index >= columns.Count()) + { + return ColumnSortingState::NotSorted; + } + else + { + return columns[index]->GetSortingState(); + } + } + + WString ListViewItemProvider::GetTextValue(vint itemIndex) + { + return GetText(itemIndex); + } + + description::Value ListViewItemProvider::GetBindingValue(vint itemIndex) + { + return Value::From(Get(itemIndex)); + } + + ListViewItemProvider::ListViewItemProvider() + :columns(this) + , dataColumns(this) + { + } + + ListViewItemProvider::~ListViewItemProvider() + { + } + + IDescriptable* ListViewItemProvider::RequestView(const WString& identifier) + { + if (identifier == IListViewItemView::Identifier) + { + return (IListViewItemView*)this; + } + else if (identifier == ListViewColumnItemArranger::IColumnItemView::Identifier) + { + return (ListViewColumnItemArranger::IColumnItemView*)this; + } + else + { + return 0; + } + } + + ListViewDataColumns& ListViewItemProvider::GetDataColumns() + { + return dataColumns; + } + + ListViewColumns& ListViewItemProvider::GetColumns() + { + return columns; + } + } + +/*********************************************************************** +GuiListView +***********************************************************************/ + + void GuiVirtualListView::OnStyleInstalled(vint itemIndex, ItemStyle* style) + { + GuiListViewBase::OnStyleInstalled(itemIndex, style); + } + + void GuiVirtualListView::OnItemTemplateChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + view = ListViewView::Unknown; + } + + GuiVirtualListView::GuiVirtualListView(IStyleProvider* _styleProvider, GuiListControl::IItemProvider* _itemProvider) + :GuiListViewBase(_styleProvider, _itemProvider) + { + SetView(ListViewView::Detail); + } + + GuiVirtualListView::~GuiVirtualListView() + { + } + + ListViewView GuiVirtualListView::GetView() + { + return view; + } + + void GuiVirtualListView::SetView(ListViewView _view) + { + switch (_view) + { + case ListViewView::BigIcon: + SetStyleAndArranger( + [](const Value&) { return new list::BigIconListViewItemTemplate; }, + new list::FixedSizeMultiColumnItemArranger + ); + break; + case ListViewView::SmallIcon: + SetStyleAndArranger( + [](const Value&) { return new list::SmallIconListViewItemTemplate; }, + new list::FixedSizeMultiColumnItemArranger + ); + break; + case ListViewView::List: + SetStyleAndArranger( + [](const Value&) { return new list::ListListViewItemTemplate; }, + new list::FixedHeightMultiColumnItemArranger + ); + break; + case ListViewView::Tile: + SetStyleAndArranger( + [](const Value&) { return new list::TileListViewItemTemplate; }, + new list::FixedSizeMultiColumnItemArranger + ); + break; + case ListViewView::Information: + SetStyleAndArranger( + [](const Value&) { return new list::InformationListViewItemTemplate; }, + new list::FixedHeightItemArranger + ); + break; + case ListViewView::Detail: + SetStyleAndArranger( + [](const Value&) { return new list::DetailListViewItemTemplate; }, + new list::ListViewColumnItemArranger + ); + break; + default:; + } + view = _view; + } + +/*********************************************************************** +GuiListView +***********************************************************************/ + + GuiListView::GuiListView(IStyleProvider* _styleProvider) + :GuiVirtualListView(_styleProvider, new list::ListViewItemProvider) + { + items=dynamic_cast(itemProvider.Obj()); + } + + GuiListView::~GuiListView() + { + } + + list::ListViewItemProvider& GuiListView::GetItems() + { + return *items; + } + + list::ListViewDataColumns& GuiListView::GetDataColumns() + { + return items->GetDataColumns(); + } + + list::ListViewColumns& GuiListView::GetColumns() + { + return items->GetColumns(); + } + + Ptr GuiListView::GetSelectedItem() + { + vint index = GetSelectedItemIndex(); + if (index == -1) return 0; + return items->Get(index); + } + } + } +} + +/*********************************************************************** +.\CONTROLS\LISTCONTROLPACKAGE\GUILISTVIEWITEMTEMPLATES.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace controls + { + using namespace elements; + using namespace compositions; + using namespace collections; + using namespace reflection::description; + + namespace list + { + +/*********************************************************************** +DefaultListViewItemTemplate +***********************************************************************/ + + DefaultListViewItemTemplate::DefaultListViewItemTemplate() + { + SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + } + + DefaultListViewItemTemplate::~DefaultListViewItemTemplate() + { + } + +/*********************************************************************** +BigIconListViewItemTemplate +***********************************************************************/ + + void BigIconListViewItemTemplate::OnInitialize() + { + DefaultListViewItemTemplate::OnInitialize(); + { + auto table = new GuiTableComposition; + AddChild(table); + table->SetRowsAndColumns(2, 3); + table->SetRowOption(0, GuiCellOption::MinSizeOption()); + table->SetRowOption(1, GuiCellOption::MinSizeOption()); + table->SetColumnOption(0, GuiCellOption::PercentageOption(0.5)); + table->SetColumnOption(1, GuiCellOption::MinSizeOption()); + table->SetColumnOption(2, GuiCellOption::PercentageOption(0.5)); + table->SetAlignmentToParent(Margin(0, 0, 0, 0)); + table->SetCellPadding(5); + { + auto cell = new GuiCellComposition; + table->AddChild(cell); + cell->SetSite(0, 1, 1, 1); + cell->SetPreferredMinSize(Size(32, 32)); + + image = GuiImageFrameElement::Create(); + image->SetStretch(true); + cell->SetOwnedElement(image); + } + { + auto cell = new GuiCellComposition; + table->AddChild(cell); + cell->SetMinSizeLimitation(GuiGraphicsComposition::NoLimit); + cell->SetSite(1, 0, 1, 3); + cell->SetPreferredMinSize(Size(64, 40)); + + text = GuiSolidLabelElement::Create(); + text->SetAlignments(Alignment::Center, Alignment::Top); + text->SetWrapLine(true); + text->SetEllipse(true); + cell->SetOwnedElement(text); + } + } + + if (auto listView = dynamic_cast(listControl)) + { + auto styleProvider = listView->GetListViewStyleProvider(); + auto itemIndex = GetIndex(); + if (auto view = dynamic_cast(listView->GetItemProvider()->RequestView(IListViewItemView::Identifier))) + { + auto imageData = view->GetLargeImage(itemIndex); + if (imageData) + { + image->SetImage(imageData->GetImage(), imageData->GetFrameIndex()); + } + else + { + image->SetImage(nullptr); + } + text->SetText(view->GetText(itemIndex)); + text->SetColor(styleProvider->GetPrimaryTextColor()); + } + } + + FontChanged.AttachMethod(this, &BigIconListViewItemTemplate::OnFontChanged); + + FontChanged.Execute(compositions::GuiEventArgs(this)); + } + + void BigIconListViewItemTemplate::OnFontChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + text->SetFont(GetFont()); + } + + BigIconListViewItemTemplate::BigIconListViewItemTemplate() + { + } + + BigIconListViewItemTemplate::~BigIconListViewItemTemplate() + { + } + +/*********************************************************************** +SmallIconListViewItemTemplate +***********************************************************************/ + + void SmallIconListViewItemTemplate::OnInitialize() + { + DefaultListViewItemTemplate::OnInitialize(); + { + auto table = new GuiTableComposition; + AddChild(table); + table->SetRowsAndColumns(3, 2); + table->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); + table->SetRowOption(1, GuiCellOption::MinSizeOption()); + table->SetRowOption(2, GuiCellOption::PercentageOption(0.5)); + table->SetColumnOption(0, GuiCellOption::MinSizeOption()); + table->SetColumnOption(1, GuiCellOption::MinSizeOption()); + table->SetAlignmentToParent(Margin(0, 0, 0, 0)); + table->SetCellPadding(2); + { + GuiCellComposition* cell = new GuiCellComposition; + table->AddChild(cell); + cell->SetSite(1, 0, 1, 1); + cell->SetPreferredMinSize(Size(16, 16)); + + image = GuiImageFrameElement::Create(); + image->SetStretch(true); + cell->SetOwnedElement(image); + } + { + GuiCellComposition* cell = new GuiCellComposition; + table->AddChild(cell); + cell->SetSite(0, 1, 3, 1); + cell->SetPreferredMinSize(Size(192, 0)); + + text = GuiSolidLabelElement::Create(); + text->SetAlignments(Alignment::Left, Alignment::Center); + text->SetEllipse(true); + cell->SetOwnedElement(text); + } + } + + if (auto listView = dynamic_cast(listControl)) + { + auto styleProvider = listView->GetListViewStyleProvider(); + auto itemIndex = GetIndex(); + if (auto view = dynamic_cast(listView->GetItemProvider()->RequestView(IListViewItemView::Identifier))) + { + auto imageData = view->GetSmallImage(itemIndex); + if (imageData) + { + image->SetImage(imageData->GetImage(), imageData->GetFrameIndex()); + } + else + { + image->SetImage(nullptr); + } + text->SetText(view->GetText(itemIndex)); + text->SetColor(styleProvider->GetPrimaryTextColor()); + } + } + + FontChanged.AttachMethod(this, &SmallIconListViewItemTemplate::OnFontChanged); + + FontChanged.Execute(compositions::GuiEventArgs(this)); + } + + void SmallIconListViewItemTemplate::OnFontChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + text->SetFont(GetFont()); + } + + SmallIconListViewItemTemplate::SmallIconListViewItemTemplate() + { + } + + SmallIconListViewItemTemplate::~SmallIconListViewItemTemplate() + { + } + +/*********************************************************************** +ListListViewItemTemplate +***********************************************************************/ + + void ListListViewItemTemplate::OnInitialize() + { + DefaultListViewItemTemplate::OnInitialize(); + { + auto table = new GuiTableComposition; + AddChild(table); + table->SetRowsAndColumns(3, 2); + table->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); + table->SetRowOption(1, GuiCellOption::MinSizeOption()); + table->SetRowOption(2, GuiCellOption::PercentageOption(0.5)); + table->SetColumnOption(0, GuiCellOption::MinSizeOption()); + table->SetColumnOption(1, GuiCellOption::MinSizeOption()); + table->SetAlignmentToParent(Margin(0, 0, 0, 0)); + table->SetCellPadding(2); + { + auto cell = new GuiCellComposition; + table->AddChild(cell); + cell->SetSite(1, 0, 1, 1); + cell->SetPreferredMinSize(Size(16, 16)); + + image = GuiImageFrameElement::Create(); + image->SetStretch(true); + cell->SetOwnedElement(image); + } + { + auto cell = new GuiCellComposition; + table->AddChild(cell); + cell->SetSite(0, 1, 3, 1); + cell->SetMargin(Margin(0, 0, 16, 0)); + + text = GuiSolidLabelElement::Create(); + text->SetAlignments(Alignment::Left, Alignment::Center); + cell->SetOwnedElement(text); + } + } + + if (auto listView = dynamic_cast(listControl)) + { + auto styleProvider = listView->GetListViewStyleProvider(); + auto itemIndex = GetIndex(); + if (auto view = dynamic_cast(listView->GetItemProvider()->RequestView(IListViewItemView::Identifier))) + { + auto imageData = view->GetSmallImage(itemIndex); + if (imageData) + { + image->SetImage(imageData->GetImage(), imageData->GetFrameIndex()); + } + else + { + image->SetImage(nullptr); + } + text->SetText(view->GetText(itemIndex)); + text->SetColor(styleProvider->GetPrimaryTextColor()); + } + } + + FontChanged.AttachMethod(this, &ListListViewItemTemplate::OnFontChanged); + + FontChanged.Execute(compositions::GuiEventArgs(this)); + } + + void ListListViewItemTemplate::OnFontChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + text->SetFont(GetFont()); + } + + ListListViewItemTemplate::ListListViewItemTemplate() + { + } + + ListListViewItemTemplate::~ListListViewItemTemplate() + { + } + +/*********************************************************************** +TileListViewItemTemplate +***********************************************************************/ + + elements::GuiSolidLabelElement* TileListViewItemTemplate::CreateTextElement(vint textRow) + { + auto cell = new GuiCellComposition; + textTable->AddChild(cell); + cell->SetSite(textRow + 1, 0, 1, 1); + + auto textElement = GuiSolidLabelElement::Create(); + textElement->SetAlignments(Alignment::Left, Alignment::Center); + textElement->SetEllipse(true); + cell->SetOwnedElement(textElement); + return textElement; + } + + void TileListViewItemTemplate::ResetTextTable(vint textRows) + { + textTable->SetRowsAndColumns(textRows + 2, 1); + textTable->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); + for (vint i = 0; iSetRowOption(i + 1, GuiCellOption::MinSizeOption()); + } + textTable->SetRowOption(textRows + 1, GuiCellOption::PercentageOption(0.5)); + textTable->SetColumnOption(0, GuiCellOption::PercentageOption(1.0)); + } + + void TileListViewItemTemplate::OnInitialize() + { + DefaultListViewItemTemplate::OnInitialize(); + { + auto table = new GuiTableComposition; + AddChild(table); + table->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + table->SetRowsAndColumns(3, 2); + table->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); + table->SetRowOption(1, GuiCellOption::MinSizeOption()); + table->SetRowOption(2, GuiCellOption::PercentageOption(0.5)); + table->SetColumnOption(0, GuiCellOption::MinSizeOption()); + table->SetColumnOption(1, GuiCellOption::MinSizeOption()); + table->SetAlignmentToParent(Margin(0, 0, 0, 0)); + table->SetCellPadding(4); + { + auto cell = new GuiCellComposition; + table->AddChild(cell); + cell->SetSite(1, 0, 1, 1); + cell->SetPreferredMinSize(Size(32, 32)); + + image = GuiImageFrameElement::Create(); + image->SetStretch(true); + cell->SetOwnedElement(image); + } + { + auto cell = new GuiCellComposition; + table->AddChild(cell); + cell->SetSite(0, 1, 3, 1); + cell->SetPreferredMinSize(Size(224, 0)); + + textTable = new GuiTableComposition; + textTable->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + textTable->SetCellPadding(1); + ResetTextTable(1); + textTable->SetAlignmentToParent(Margin(0, 0, 0, 0)); + cell->AddChild(textTable); + { + text = CreateTextElement(0); + } + } + } + + if (auto listView = dynamic_cast(listControl)) + { + auto styleProvider = listView->GetListViewStyleProvider(); + auto itemIndex = GetIndex(); + if (auto view = dynamic_cast(listView->GetItemProvider()->RequestView(IListViewItemView::Identifier))) + { + auto imageData = view->GetLargeImage(itemIndex); + if (imageData) + { + image->SetImage(imageData->GetImage(), imageData->GetFrameIndex()); + } + else + { + image->SetImage(nullptr); + } + text->SetText(view->GetText(itemIndex)); + text->SetColor(styleProvider->GetPrimaryTextColor()); + + vint dataColumnCount = view->GetDataColumnCount(); + ResetTextTable(dataColumnCount + 1); + dataTexts.Resize(dataColumnCount); + for (vint i = 0; i < dataColumnCount; i++) + { + dataTexts[i] = CreateTextElement(i + 1); + dataTexts[i]->SetText(view->GetSubItem(itemIndex, view->GetDataColumn(i))); + dataTexts[i]->SetColor(styleProvider->GetSecondaryTextColor()); + } + } + } + + FontChanged.AttachMethod(this, &TileListViewItemTemplate::OnFontChanged); + + FontChanged.Execute(compositions::GuiEventArgs(this)); + } + + void TileListViewItemTemplate::OnFontChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + text->SetFont(GetFont()); + if (auto view = dynamic_cast(listControl->GetItemProvider()->RequestView(IListViewItemView::Identifier))) + { + vint dataColumnCount = view->GetDataColumnCount(); + for (vint i = 0; i < dataColumnCount; i++) + { + dataTexts[i]->SetFont(GetFont()); + } + } + } + + TileListViewItemTemplate::TileListViewItemTemplate() + { + } + + TileListViewItemTemplate::~TileListViewItemTemplate() + { + } + +/*********************************************************************** +InformationListViewItemTemplate +***********************************************************************/ + + void InformationListViewItemTemplate::OnInitialize() + { + DefaultListViewItemTemplate::OnInitialize(); + { + bottomLine = GuiSolidBackgroundElement::Create(); + bottomLineComposition = new GuiBoundsComposition; + bottomLineComposition->SetOwnedElement(bottomLine); + bottomLineComposition->SetAlignmentToParent(Margin(8, -1, 8, 0)); + bottomLineComposition->SetPreferredMinSize(Size(0, 1)); + AddChild(bottomLineComposition); + + auto table = new GuiTableComposition; + AddChild(table); + table->SetRowsAndColumns(3, 3); + table->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); + table->SetRowOption(1, GuiCellOption::MinSizeOption()); + table->SetRowOption(2, GuiCellOption::PercentageOption(0.5)); + table->SetColumnOption(0, GuiCellOption::MinSizeOption()); + table->SetColumnOption(1, GuiCellOption::PercentageOption(1.0)); + table->SetColumnOption(2, GuiCellOption::MinSizeOption()); + table->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + table->SetAlignmentToParent(Margin(0, 0, 0, 0)); + table->SetCellPadding(4); + { + auto cell = new GuiCellComposition; + table->AddChild(cell); + cell->SetSite(1, 0, 1, 1); + cell->SetPreferredMinSize(Size(32, 32)); + + image = GuiImageFrameElement::Create(); + image->SetStretch(true); + cell->SetOwnedElement(image); + } + { + auto cell = new GuiCellComposition; + table->AddChild(cell); + cell->SetSite(0, 1, 3, 1); + + text = GuiSolidLabelElement::Create(); + text->SetEllipse(true); + cell->SetOwnedElement(text); + } + { + auto cell = new GuiCellComposition; + table->AddChild(cell); + cell->SetSite(0, 2, 3, 1); + cell->SetPreferredMinSize(Size(224, 0)); + + textTable = new GuiTableComposition; + textTable->SetCellPadding(4); + textTable->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + textTable->SetAlignmentToParent(Margin(0, 0, 0, 0)); + cell->AddChild(textTable); + } + } + + if (auto listView = dynamic_cast(listControl)) + { + auto styleProvider = listView->GetListViewStyleProvider(); + auto itemIndex = GetIndex(); + if (auto view = dynamic_cast(listView->GetItemProvider()->RequestView(IListViewItemView::Identifier))) + { + auto imageData = view->GetLargeImage(itemIndex); + if (imageData) + { + image->SetImage(imageData->GetImage(), imageData->GetFrameIndex()); + } + else + { + image->SetImage(nullptr); + } + text->SetText(view->GetText(itemIndex)); + text->SetColor(styleProvider->GetPrimaryTextColor()); + bottomLine->SetColor(styleProvider->GetItemSeparatorColor()); + + vint dataColumnCount = view->GetDataColumnCount(); + columnTexts.Resize(dataColumnCount); + dataTexts.Resize(dataColumnCount); + + textTable->SetRowsAndColumns(dataColumnCount + 2, 1); + textTable->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); + for (vint i = 0; i < dataColumnCount; i++) + { + textTable->SetRowOption(i + 1, GuiCellOption::MinSizeOption()); + } + textTable->SetRowOption(dataColumnCount + 1, GuiCellOption::PercentageOption(0.5)); + textTable->SetColumnOption(0, GuiCellOption::PercentageOption(1.0)); + + for (vint i = 0; i < dataColumnCount; i++) + { + auto cell = new GuiCellComposition; + textTable->AddChild(cell); + cell->SetSite(i + 1, 0, 1, 1); + + auto dataTable = new GuiTableComposition; + dataTable->SetRowsAndColumns(1, 2); + dataTable->SetRowOption(0, GuiCellOption::MinSizeOption()); + dataTable->SetColumnOption(0, GuiCellOption::MinSizeOption()); + dataTable->SetColumnOption(1, GuiCellOption::PercentageOption(1.0)); + dataTable->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + dataTable->SetAlignmentToParent(Margin(0, 0, 0, 0)); + cell->AddChild(dataTable); + { + auto cell = new GuiCellComposition; + dataTable->AddChild(cell); + cell->SetSite(0, 0, 1, 1); + + columnTexts[i] = GuiSolidLabelElement::Create(); + columnTexts[i]->SetText(view->GetColumnText(view->GetDataColumn(i) + 1) + L": "); + columnTexts[i]->SetColor(styleProvider->GetSecondaryTextColor()); + cell->SetOwnedElement(columnTexts[i]); + } + { + auto cell = new GuiCellComposition; + dataTable->AddChild(cell); + cell->SetSite(0, 1, 1, 1); + + dataTexts[i]= GuiSolidLabelElement::Create(); + dataTexts[i]->SetEllipse(true); + dataTexts[i]->SetText(view->GetSubItem(itemIndex, view->GetDataColumn(i))); + dataTexts[i]->SetColor(styleProvider->GetPrimaryTextColor()); + cell->SetOwnedElement(dataTexts[i]); + } + } + } + } + + FontChanged.AttachMethod(this, &InformationListViewItemTemplate::OnFontChanged); + + FontChanged.Execute(compositions::GuiEventArgs(this)); + } + + void InformationListViewItemTemplate::OnFontChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + { + auto font = GetFont(); + font.size = (vint)(font.size * 1.2); + text->SetFont(font); + } + if (auto view = dynamic_cast(listControl->GetItemProvider()->RequestView(IListViewItemView::Identifier))) + { + vint dataColumnCount = view->GetDataColumnCount(); + for (vint i = 0; i < dataColumnCount; i++) + { + columnTexts[i]->SetFont(GetFont()); + dataTexts[i]->SetFont(GetFont()); + } + } + } + + InformationListViewItemTemplate::InformationListViewItemTemplate() + { + } + + InformationListViewItemTemplate::~InformationListViewItemTemplate() + { + } + +/*********************************************************************** +DetailListViewItemTemplate +***********************************************************************/ + + void DetailListViewItemTemplate::OnInitialize() + { + DefaultListViewItemTemplate::OnInitialize(); + columnItemView = dynamic_cast(listControl->GetItemProvider()->RequestView(ListViewColumnItemArranger::IColumnItemView::Identifier)); + + { + textTable = new GuiTableComposition; + textTable->SetAlignmentToParent(Margin(0, 0, 0, 0)); + textTable->SetRowsAndColumns(1, 1); + textTable->SetRowOption(0, GuiCellOption::MinSizeOption()); + textTable->SetColumnOption(0, GuiCellOption::AbsoluteOption(0)); + AddChild(textTable); + { + auto cell = new GuiCellComposition; + textTable->AddChild(cell); + cell->SetSite(0, 0, 1, 1); + + auto table = new GuiTableComposition; + cell->AddChild(table); + table->SetRowsAndColumns(3, 2); + table->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); + table->SetRowOption(1, GuiCellOption::MinSizeOption()); + table->SetRowOption(2, GuiCellOption::PercentageOption(0.5)); + table->SetColumnOption(0, GuiCellOption::MinSizeOption()); + table->SetColumnOption(1, GuiCellOption::PercentageOption(1.0)); + table->SetAlignmentToParent(Margin(0, 0, 0, 0)); + table->SetCellPadding(2); + { + auto cell = new GuiCellComposition; + table->AddChild(cell); + cell->SetSite(1, 0, 1, 1); + cell->SetPreferredMinSize(Size(16, 16)); + + image = GuiImageFrameElement::Create(); + image->SetStretch(true); + cell->SetOwnedElement(image); + } + { + auto cell = new GuiCellComposition; + table->AddChild(cell); + cell->SetSite(0, 1, 3, 1); + cell->SetMargin(Margin(0, 0, 8, 0)); + + text = GuiSolidLabelElement::Create(); + text->SetAlignments(Alignment::Left, Alignment::Center); + text->SetEllipse(true); + cell->SetOwnedElement(text); + } + } + } + + if (auto listView = dynamic_cast(listControl)) + { + auto styleProvider = listView->GetListViewStyleProvider(); + auto itemIndex = GetIndex(); + if (auto view = dynamic_cast(listView->GetItemProvider()->RequestView(IListViewItemView::Identifier))) + { + auto imageData = view->GetSmallImage(itemIndex); + if (imageData) + { + image->SetImage(imageData->GetImage(), imageData->GetFrameIndex()); + } + else + { + image->SetImage(0); + } + text->SetText(view->GetText(itemIndex)); + text->SetColor(styleProvider->GetPrimaryTextColor()); + + vint columnCount = view->GetColumnCount() - 1; + subItems.Resize(columnCount); + textTable->SetRowsAndColumns(1, columnCount + 1); + for (vint i = 0; i < columnCount; i++) + { + auto cell = new GuiCellComposition; + textTable->AddChild(cell); + cell->SetSite(0, i + 1, 1, 1); + cell->SetMargin(Margin(8, 0, 8, 0)); + + subItems[i] = GuiSolidLabelElement::Create(); + subItems[i]->SetAlignments(Alignment::Left, Alignment::Center); + subItems[i]->SetFont(text->GetFont()); + subItems[i]->SetEllipse(true); + subItems[i]->SetText(view->GetSubItem(itemIndex, i)); + subItems[i]->SetColor(styleProvider->GetSecondaryTextColor()); + cell->SetOwnedElement(subItems[i]); + } + OnColumnChanged(); + } + } + + FontChanged.AttachMethod(this, &DetailListViewItemTemplate::OnFontChanged); + + FontChanged.Execute(compositions::GuiEventArgs(this)); + } + + void DetailListViewItemTemplate::OnColumnChanged() + { + if (auto view = dynamic_cast(listControl->GetItemProvider()->RequestView(IListViewItemView::Identifier))) + { + if (columnItemView) + { + vint columnCount = view->GetColumnCount(); + if (columnCount>textTable->GetColumns()) + { + columnCount = textTable->GetColumns(); + } + for (vint i = 0; iSetColumnOption(i, GuiCellOption::AbsoluteOption(columnItemView->GetColumnSize(i))); + } + textTable->UpdateCellBounds(); + } + } + } + + void DetailListViewItemTemplate::OnFontChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + text->SetFont(GetFont()); + if (auto view = dynamic_cast(listControl->GetItemProvider()->RequestView(IListViewItemView::Identifier))) + { + vint columnCount = view->GetColumnCount() - 1; + for (vint i = 0; i < columnCount; i++) + { + subItems[i]->SetFont(GetFont()); + } + } + } + + DetailListViewItemTemplate::DetailListViewItemTemplate() + { + } + + DetailListViewItemTemplate::~DetailListViewItemTemplate() + { + } + } + } + } +} + +/*********************************************************************** +.\CONTROLS\GUIAPPLICATION.CPP +***********************************************************************/ + +extern void GuiMain(); + +namespace vl +{ + namespace presentation + { + namespace controls + { + using namespace collections; + using namespace compositions; + using namespace theme; + using namespace description; + +/*********************************************************************** +GuiApplication +***********************************************************************/ + + void GuiApplication::InvokeClipboardNotify(compositions::GuiGraphicsComposition* composition, compositions::GuiEventArgs& arguments) + { + if(composition->HasEventReceiver()) + { + composition->GetEventReceiver()->clipboardNotify.Execute(arguments); + } + FOREACH(GuiGraphicsComposition*, subComposition, composition->Children()) + { + InvokeClipboardNotify(subComposition, arguments); + } + } + + void GuiApplication::LeftButtonDown(Point position) + { + OnMouseDown(position); + } + + void GuiApplication::LeftButtonUp(Point position) + { + } + + void GuiApplication::RightButtonDown(Point position) + { + OnMouseDown(position); + } + + void GuiApplication::RightButtonUp(Point position) + { + } + + void GuiApplication::ClipboardUpdated() + { + for(vint i=0;iGetNotifyEventArguments(); + windows[i]->ClipboardUpdated.Execute(arguments); + InvokeClipboardNotify(windows[i]->GetBoundsComposition(), arguments); + } + } + + GuiApplication::GuiApplication() + :mainWindow(0) + ,sharedTooltipOwnerWindow(0) + ,sharedTooltipOwner(0) + ,sharedTooltipControl(0) + ,sharedTooltipHovering(false) + ,sharedTooltipClosing(false) + { + GetCurrentController()->CallbackService()->InstallListener(this); + } + + GuiApplication::~GuiApplication() + { + if(sharedTooltipControl) + { + delete sharedTooltipControl; + sharedTooltipControl=0; + } + GetCurrentController()->CallbackService()->UninstallListener(this); + } + + void GuiApplication::RegisterWindow(GuiWindow* window) + { + windows.Add(window); + } + + void GuiApplication::UnregisterWindow(GuiWindow* window) + { + windows.Remove(window); + } + + void GuiApplication::RegisterPopupOpened(GuiPopup* popup) + { + vint index=openingPopups.IndexOf(popup); + if(index==-1) + { + openingPopups.Add(popup); + if(openingPopups.Count()==1) + { + GetCurrentController()->InputService()->StartHookMouse(); + } + } + } + + void GuiApplication::RegisterPopupClosed(GuiPopup* popup) + { + if(openingPopups.Remove(popup)) + { + if(openingPopups.Count()==0) + { + GetCurrentController()->InputService()->StopHookMouse(); + } + } + } + + void GuiApplication::OnMouseDown(Point location) + { + GuiWindow* window=GetWindow(location); + for(vint i=0;iMouseClickedOnOtherWindow(window); + } + } + } + + void GuiApplication::TooltipMouseEnter(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + sharedTooltipHovering=true; + } + + void GuiApplication::TooltipMouseLeave(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + sharedTooltipHovering=false; + if(sharedTooltipClosing) + { + CloseTooltip(); + } + } + + void GuiApplication::Run(GuiWindow* _mainWindow) + { + if(!mainWindow) + { + mainWindow=_mainWindow; + GetCurrentController()->WindowService()->Run(mainWindow->GetNativeWindow()); + mainWindow=0; + } + } + + GuiWindow* GuiApplication::GetMainWindow() + { + return mainWindow; + } + + const collections::List& GuiApplication::GetWindows() + { + return windows; + } + + GuiWindow* GuiApplication::GetWindow(Point location) + { + INativeWindow* nativeWindow=GetCurrentController()->WindowService()->GetWindow(location); + if(nativeWindow) + { + for(vint i=0;iGetNativeWindow()==nativeWindow) + { + return window; + } + } + } + return 0; + } + + void GuiApplication::ShowTooltip(GuiControl* owner, GuiControl* tooltip, vint preferredContentWidth, Point location) + { + GuiWindow* ownerWindow = dynamic_cast(owner->GetRelatedControlHost()); + if (sharedTooltipOwnerWindow != ownerWindow) + { + delete sharedTooltipControl; + sharedTooltipControl = 0; + } + + if(!sharedTooltipControl) + { + GuiWindow::IStyleController* tooltipStyle = 0; + if (ownerWindow) + { + tooltipStyle = dynamic_cast(ownerWindow->GetStyleController())->CreateTooltipStyle(); + } + if (!tooltipStyle) + { + tooltipStyle = GetCurrentTheme()->CreateTooltipStyle(); + } + + sharedTooltipControl=new GuiTooltip(tooltipStyle); + sharedTooltipControl->GetBoundsComposition()->GetEventReceiver()->mouseEnter.AttachMethod(this, &GuiApplication::TooltipMouseEnter); + sharedTooltipControl->GetBoundsComposition()->GetEventReceiver()->mouseLeave.AttachMethod(this, &GuiApplication::TooltipMouseLeave); + } + + sharedTooltipHovering=false; + sharedTooltipClosing=false; + sharedTooltipOwnerWindow = ownerWindow; + sharedTooltipOwner=owner; + sharedTooltipControl->SetTemporaryContentControl(tooltip); + sharedTooltipControl->SetPreferredContentWidth(preferredContentWidth); + sharedTooltipControl->SetClientSize(Size(10, 10)); + sharedTooltipControl->ShowPopup(owner, location); + } + + void GuiApplication::CloseTooltip() + { + if(sharedTooltipControl) + { + if(sharedTooltipHovering) + { + sharedTooltipClosing=true; + } + else + { + sharedTooltipClosing=false; + sharedTooltipControl->Close(); + } + } + } + + GuiControl* GuiApplication::GetTooltipOwner() + { + if(!sharedTooltipControl) return 0; + if(!sharedTooltipControl->GetTemporaryContentControl()) return 0; + return sharedTooltipOwner; + } + + WString GuiApplication::GetExecutablePath() + { + return GetCurrentController()->GetExecutablePath(); + } + + WString GuiApplication::GetExecutableFolder() + { + WString path=GetExecutablePath(); + for(vint i=path.Length()-1;i>=0;i--) + { + if(path[i]==L'\\' || path[i]==L'/') + { + return path.Sub(0, i+1); + } + } + return L""; + } + + bool GuiApplication::IsInMainThread() + { + return GetCurrentController()->AsyncService()->IsInMainThread(); + } + + void GuiApplication::InvokeAsync(const Func& proc) + { + GetCurrentController()->AsyncService()->InvokeAsync(proc); + } + + void GuiApplication::InvokeInMainThread(const Func& proc) + { + GetCurrentController()->AsyncService()->InvokeInMainThread(proc); + } + + bool GuiApplication::InvokeInMainThreadAndWait(const Func& proc, vint milliseconds) + { + return GetCurrentController()->AsyncService()->InvokeInMainThreadAndWait(proc, milliseconds); + } + + Ptr GuiApplication::DelayExecute(const Func& proc, vint milliseconds) + { + return GetCurrentController()->AsyncService()->DelayExecute(proc, milliseconds); + } + + Ptr GuiApplication::DelayExecuteInMainThread(const Func& proc, vint milliseconds) + { + return GetCurrentController()->AsyncService()->DelayExecuteInMainThread(proc, milliseconds); + } + + void GuiApplication::RunGuiTask(const Func& proc) + { + if(IsInMainThread()) + { + return proc(); + } + else + { + InvokeInMainThreadAndWait([&proc]() + { + proc(); + }); + } + } + +/*********************************************************************** +GuiPluginManager +***********************************************************************/ + + class GuiPluginManager : public Object, public IGuiPluginManager + { + protected: + List> plugins; + bool loaded; + public: + GuiPluginManager() + :loaded(false) + { + } + + ~GuiPluginManager() + { + Unload(); + } + + void AddPlugin(Ptr plugin)override + { + CHECK_ERROR(!loaded, L"GuiPluginManager::AddPlugin(Ptr)#Load function has already been executed."); + auto name = plugin->GetName(); + if (name != L"") + { + FOREACH(Ptr, plugin, plugins) + { + CHECK_ERROR(plugin->GetName() != name, L"GuiPluginManager::AddPlugin(Ptr)#Duplicated plugin name."); + } + } + plugins.Add(plugin); + } + + void Load()override + { + CHECK_ERROR(!loaded, L"GuiPluginManager::AddPlugin(Ptr)#Load function has already been executed."); + loaded=true; + + SortedList loaded; + Group loading; + Dictionary> pluginsToLoad; + FOREACH(Ptr, plugin, plugins) + { + auto name = plugin->GetName(); + pluginsToLoad.Add(name, plugin); + List dependencies; + plugin->GetDependencies(dependencies); + FOREACH(WString, dependency, dependencies) + { + loading.Add(name, dependency); + } + } + + while (pluginsToLoad.Count() > 0) + { + vint count = pluginsToLoad.Count(); + { + FOREACH_INDEXER(WString, name, index, pluginsToLoad.Keys()) + { + if (!loading.Keys().Contains(name)) + { + for (vint i = loading.Count() - 1; i >= 0; i--) + { + loading.Remove(loading.Keys()[i], name); + } + loaded.Add(name); + + auto plugin = pluginsToLoad.Values()[index]; + pluginsToLoad.Remove(name); + plugin->Load(); + break; + } + } + } + if (count == pluginsToLoad.Count()) + { + WString message; + FOREACH(Ptr, plugin, pluginsToLoad.Values()) + { + message += L"Cannot load plugin \"" + plugin->GetName() + L"\" because part of its dependencies are not ready:"; + List dependencies; + plugin->GetDependencies(dependencies); + bool first = true; + FOREACH(WString, dependency, dependencies) + { + if (!loaded.Contains(dependency)) + { + message += L" \"" + dependency + L"\";"; + } + } + message += L"\r\n"; + } + throw Exception(message); + } + } + } + + void Unload()override + { + CHECK_ERROR(loaded, L"GuiPluginManager::AddPlugin(Ptr)#Load function has not been executed."); + loaded=false; + FOREACH(Ptr, plugin, plugins) + { + plugin->Unload(); + } + } + + bool IsLoaded()override + { + return loaded; + } + }; + +/*********************************************************************** +Helpers +***********************************************************************/ + + GuiApplication* application=0; + IGuiPluginManager* pluginManager=0; + + GuiApplication* GetApplication() + { + return application; + } + + IGuiPluginManager* GetPluginManager() + { + if(!pluginManager) + { + pluginManager=new GuiPluginManager; + } + return pluginManager; + } + + void DestroyPluginManager() + { + if(pluginManager) + { + delete pluginManager; + pluginManager=0; + } + } + +/*********************************************************************** +GuiApplicationMain +***********************************************************************/ + + class UIThreadAsyncScheduler :public Object, public IAsyncScheduler, public Description + { + public: + void Execute(const Func& callback)override + { + GetApplication()->InvokeInMainThread(callback); + } + + void ExecuteInBackground(const Func& callback)override + { + GetApplication()->InvokeAsync(callback); + } + + void DelayExecute(const Func& callback, vint milliseconds)override + { + GetApplication()->DelayExecuteInMainThread(callback, milliseconds); + } + }; + + class OtherThreadAsyncScheduler :public Object, public IAsyncScheduler, public Description + { + public: + void Execute(const Func& callback)override + { + GetApplication()->InvokeAsync(callback); + } + + void ExecuteInBackground(const Func& callback)override + { + GetApplication()->InvokeAsync(callback); + } + + void DelayExecute(const Func& callback, vint milliseconds)override + { + GetApplication()->DelayExecute(callback, milliseconds); + } + }; + + void GuiApplicationInitialize() + { + GetCurrentController()->InputService()->StartTimer(); + theme::InitializeTheme(); + +#ifndef VCZH_DEBUG_NO_REFLECTION + GetGlobalTypeManager()->Load(); +#endif + GetPluginManager()->Load(); + + { + GuiApplication app; + application = &app; + IAsyncScheduler::RegisterSchedulerForCurrentThread(new UIThreadAsyncScheduler); + IAsyncScheduler::RegisterDefaultScheduler(new OtherThreadAsyncScheduler); + GuiMain(); + IAsyncScheduler::UnregisterDefaultScheduler(); + IAsyncScheduler::UnregisterSchedulerForCurrentThread(); + application = nullptr; + } + + DestroyPluginManager(); + theme::FinalizeTheme(); + ThreadLocalStorage::DisposeStorages(); + FinalizeGlobalStorage(); +#ifndef VCZH_DEBUG_NO_REFLECTION + DestroyGlobalTypeManager(); +#endif + } + } + } +} + +void GuiApplicationMain() +{ + vl::presentation::controls::GuiApplicationInitialize(); +} + +/*********************************************************************** +.\CONTROLS\LISTCONTROLPACKAGE\GUILISTCONTROLITEMARRANGERS.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace controls + { + using namespace collections; + using namespace elements; + using namespace compositions; + + namespace list + { + +/*********************************************************************** +RangedItemArrangerBase +***********************************************************************/ + + void RangedItemArrangerBase::InvalidateAdoptedSize() + { + if (listControl) + { + listControl->AdoptedSizeInvalidated.Execute(listControl->GetNotifyEventArguments()); + } + } + + vint RangedItemArrangerBase::CalculateAdoptedSize(vint expectedSize, vint count, vint itemSize) + { + vint visibleCount = expectedSize / itemSize; + if (count < visibleCount) + { + visibleCount = count; + } + else if (count > visibleCount) + { + vint deltaA = expectedSize - count * itemSize; + vint deltaB = itemSize - deltaA; + if (deltaB < deltaA) + { + visibleCount++; + } + } + return visibleCount * itemSize; + } + + RangedItemArrangerBase::ItemStyleRecord RangedItemArrangerBase::CreateStyle(vint index) + { + GuiSelectableButton* backgroundButton = nullptr; + if (listControl->GetDisplayItemBackground()) + { + auto style = listControl->GetListControlStyleProvider()->CreateItemBackground(); + if (!style) + { + style = theme::GetCurrentTheme()->CreateListItemBackgroundStyle(); + } + backgroundButton = new GuiSelectableButton(style); + backgroundButton->SetAutoSelection(false); + } + + auto itemStyle = callback->RequestItem(index, backgroundButton->GetBoundsComposition()); + if (backgroundButton) + { + itemStyle->SetAlignmentToParent(Margin(0, 0, 0, 0)); + itemStyle->SelectedChanged.AttachLambda([=](GuiGraphicsComposition* sender, GuiEventArgs& arguments) + { + backgroundButton->SetSelected(itemStyle->GetSelected()); + }); + backgroundButton->GetContainerComposition()->AddChild(itemStyle); + } + return { itemStyle, backgroundButton }; + } + + void RangedItemArrangerBase::DeleteStyle(ItemStyleRecord style) + { + callback->ReleaseItem(style.key); + if (style.value) + { + SafeDeleteControl(style.value); + } + } + + compositions::GuiBoundsComposition* RangedItemArrangerBase::GetStyleBounds(ItemStyleRecord style) + { + return style.value ? style.value->GetBoundsComposition() : style.key; + } + + void RangedItemArrangerBase::ClearStyles() + { + startIndex = 0; + if (callback) + { + for (vint i = 0; i < visibleStyles.Count(); i++) + { + DeleteStyle(visibleStyles[i]); + } + } + visibleStyles.Clear(); + viewBounds = Rect(0, 0, 0, 0); + InvalidateItemSizeCache(); + InvalidateAdoptedSize(); + } + + void RangedItemArrangerBase::OnViewChangedInternal(Rect oldBounds, Rect newBounds) + { + vint endIndex = startIndex + visibleStyles.Count() - 1; + vint newStartIndex = 0; + vint itemCount = itemProvider->Count(); + BeginPlaceItem(true, newBounds, newStartIndex); + if (newStartIndex < 0) newStartIndex = 0; + + StyleList newVisibleStyles; + for (vint i = newStartIndex; i < itemCount; i++) + { + auto style + = startIndex <= i && i <= endIndex + ? visibleStyles[i - startIndex] + : CreateStyle(i) + ; + newVisibleStyles.Add(style); + + Rect bounds; + Margin alignmentToParent; + PlaceItem(true, i, style, newBounds, bounds, alignmentToParent); + if (IsItemOutOfViewBounds(i, style, bounds, newBounds)) + { + break; + } + + bounds.x1 -= newBounds.x1; + bounds.x2 -= newBounds.x1; + bounds.y1 -= newBounds.y1; + bounds.y2 -= newBounds.y1; + } + + vint newEndIndex = newStartIndex + newVisibleStyles.Count() - 1; + for (vint i = 0; i < visibleStyles.Count(); i++) + { + vint index = startIndex + i; + if (index < newStartIndex || index > newEndIndex) + { + DeleteStyle(visibleStyles[i]); + } + } + CopyFrom(visibleStyles, newVisibleStyles); + + if (EndPlaceItem(true, newBounds, newStartIndex)) + { + callback->OnTotalSizeChanged(); + InvalidateAdoptedSize(); + } + startIndex = newStartIndex; + } + + void RangedItemArrangerBase::RearrangeItemBounds() + { + vint newStartIndex = startIndex; + BeginPlaceItem(false, viewBounds, newStartIndex); + for (vint i = 0; i < visibleStyles.Count(); i++) + { + auto style = visibleStyles[i]; + Rect bounds; + Margin alignmentToParent(-1, -1, -1, -1); + PlaceItem(false, startIndex + i, style, viewBounds, bounds, alignmentToParent); + + bounds.x1 -= viewBounds.x1; + bounds.x2 -= viewBounds.x1; + bounds.y1 -= viewBounds.y1; + bounds.y2 -= viewBounds.y1; + + callback->SetStyleAlignmentToParent(GetStyleBounds(style), alignmentToParent); + callback->SetStyleBounds(GetStyleBounds(style), bounds); + } + EndPlaceItem(false, viewBounds, startIndex); + } + + RangedItemArrangerBase::RangedItemArrangerBase() + { + } + + RangedItemArrangerBase::~RangedItemArrangerBase() + { + } + + void RangedItemArrangerBase::OnAttached(GuiListControl::IItemProvider* provider) + { + itemProvider = provider; + if (provider) + { + OnItemModified(0, 0, provider->Count()); + } + } + + void RangedItemArrangerBase::OnItemModified(vint start, vint count, vint newCount) + { + if (callback && !itemProvider->IsEditing()) + { + suppressOnViewChanged = true; + { + vint visibleCount = visibleStyles.Count(); + vint itemCount = itemProvider->Count(); + SortedList reusedStyles; + for (vint i = 0; i < visibleCount; i++) + { + vint index = startIndex + i; + if (index >= itemCount) + { + break; + } + + vint oldIndex = -1; + if (index < start) + { + oldIndex = index; + } + else if (index >= start + newCount) + { + oldIndex = index - newCount + count; + } + + if (oldIndex != -1) + { + if (oldIndex >= startIndex && oldIndex < startIndex + visibleCount) + { + auto style = visibleStyles[oldIndex - startIndex]; + reusedStyles.Add(style); + visibleStyles.Add(style); + } + else + { + oldIndex = -1; + } + } + if (oldIndex == -1) + { + visibleStyles.Add(CreateStyle(index)); + } + } + + for (vint i = 0; i < visibleCount; i++) + { + auto style = visibleStyles[i]; + if (!reusedStyles.Contains(style)) + { + DeleteStyle(style); + } + } + + visibleStyles.RemoveRange(0, visibleCount); + for (vint i = 0; i < visibleStyles.Count(); i++) + { + visibleStyles[i].key->SetIndex(startIndex + i); + } + } + suppressOnViewChanged = false; + + callback->OnTotalSizeChanged(); + callback->SetViewLocation(viewBounds.LeftTop()); + InvalidateAdoptedSize(); + } + } + + void RangedItemArrangerBase::AttachListControl(GuiListControl* value) + { + listControl = value; + InvalidateAdoptedSize(); + } + + void RangedItemArrangerBase::DetachListControl() + { + listControl = 0; + } + + GuiListControl::IItemArrangerCallback* RangedItemArrangerBase::GetCallback() + { + return callback; + } + + void RangedItemArrangerBase::SetCallback(GuiListControl::IItemArrangerCallback* value) + { + if (callback != value) + { + ClearStyles(); + } + callback = value; + } + + Size RangedItemArrangerBase::GetTotalSize() + { + if (callback) + { + return OnCalculateTotalSize(); + } + else + { + return Size(0, 0); + } + } + + GuiListControl::ItemStyle* RangedItemArrangerBase::GetVisibleStyle(vint itemIndex) + { + if (startIndex <= itemIndex && itemIndex < startIndex + visibleStyles.Count()) + { + return visibleStyles[itemIndex - startIndex].key; + } + else + { + return 0; + } + } + + vint RangedItemArrangerBase::GetVisibleIndex(GuiListControl::ItemStyle* style) + { + for (vint i = 0; i < visibleStyles.Count(); i++) + { + if (visibleStyles[i].key == style) + { + return i + startIndex; + } + } + return -1; + } + + void RangedItemArrangerBase::OnViewChanged(Rect bounds) + { + if (!suppressOnViewChanged) + { + suppressOnViewChanged = true; + Rect oldBounds = viewBounds; + viewBounds = bounds; + if (callback) + { + OnViewChangedInternal(oldBounds, viewBounds); + RearrangeItemBounds(); + } + suppressOnViewChanged = false; + } + } + +/*********************************************************************** +FixedHeightItemArranger +***********************************************************************/ + + vint FixedHeightItemArranger::GetWidth() + { + return -1; + } + + vint FixedHeightItemArranger::GetYOffset() + { + return 0; + } + + void FixedHeightItemArranger::BeginPlaceItem(bool forMoving, Rect newBounds, vint& newStartIndex) + { + pi_width = GetWidth(); + if (forMoving) + { + pim_rowHeight = rowHeight; + newStartIndex = (newBounds.Top() - GetYOffset()) / rowHeight; + } + } + + void FixedHeightItemArranger::PlaceItem(bool forMoving, vint index, ItemStyleRecord style, Rect viewBounds, Rect& bounds, Margin& alignmentToParent) + { + vint top = GetYOffset() + index * rowHeight; + if (pi_width == -1) + { + alignmentToParent = Margin(0, -1, 0, -1); + bounds = Rect(Point(0, top), Size(0, rowHeight)); + } + else + { + alignmentToParent = Margin(-1, -1, -1, -1); + bounds = Rect(Point(0, top), Size(pi_width, rowHeight)); + } + if (forMoving) + { + vint styleHeight = callback->GetStylePreferredSize(GetStyleBounds(style)).y; + if (pim_rowHeight < styleHeight) + { + pim_rowHeight = styleHeight; + } + } + } + + bool FixedHeightItemArranger::IsItemOutOfViewBounds(vint index, ItemStyleRecord style, Rect bounds, Rect viewBounds) + { + return bounds.Top() >= viewBounds.Bottom(); + } + + bool FixedHeightItemArranger::EndPlaceItem(bool forMoving, Rect newBounds, vint newStartIndex) + { + if (forMoving) + { + if (pim_rowHeight != rowHeight) + { + vint offset = (pim_rowHeight - rowHeight) * newStartIndex; + rowHeight = pim_rowHeight; + callback->SetViewLocation(Point(0, newBounds.Top() + offset)); + return true; + } + } + return false; + } + + void FixedHeightItemArranger::InvalidateItemSizeCache() + { + rowHeight = 1; + } + + Size FixedHeightItemArranger::OnCalculateTotalSize() + { + vint width = GetWidth(); + if (width < 0) width = 0; + return Size(width, rowHeight * itemProvider->Count() + GetYOffset()); + } + + FixedHeightItemArranger::FixedHeightItemArranger() + :rowHeight(1) + { + } + + FixedHeightItemArranger::~FixedHeightItemArranger() + { + } + + vint FixedHeightItemArranger::FindItem(vint itemIndex, compositions::KeyDirection key) + { + vint count = itemProvider->Count(); + if (count == 0) return -1; + vint groupCount = viewBounds.Height() / rowHeight; + if (groupCount == 0) groupCount = 1; + switch (key) + { + case KeyDirection::Up: + itemIndex--; + break; + case KeyDirection::Down: + itemIndex++; + break; + case KeyDirection::Home: + itemIndex = 0; + break; + case KeyDirection::End: + itemIndex = count; + break; + case KeyDirection::PageUp: + itemIndex -= groupCount; + break; + case KeyDirection::PageDown: + itemIndex += groupCount; + break; + default: + return -1; + } + + if (itemIndex < 0) return 0; + else if (itemIndex >= count) return count - 1; + else return itemIndex; + } + + bool FixedHeightItemArranger::EnsureItemVisible(vint itemIndex) + { + if (callback) + { + if (itemIndex < 0 || itemIndex >= itemProvider->Count()) + { + return false; + } + while (true) + { + vint yOffset = GetYOffset(); + vint top = itemIndex*rowHeight; + vint bottom = top + rowHeight + yOffset; + + if (viewBounds.Height() < rowHeight) + { + if (viewBounds.Top() < bottom && top < viewBounds.Bottom()) + { + break; + } + } + + Point location = viewBounds.LeftTop(); + if (top < viewBounds.Top()) + { + location.y = top; + } + else if (viewBounds.Bottom() < bottom) + { + location.y = bottom - viewBounds.Height(); + } + else + { + break; + } + callback->SetViewLocation(location); + } + return true; + } + return false; + } + + Size FixedHeightItemArranger::GetAdoptedSize(Size expectedSize) + { + if (itemProvider) + { + vint yOffset = GetYOffset(); + vint y = expectedSize.y - yOffset; + vint itemCount = itemProvider->Count(); + return Size(expectedSize.x, yOffset + CalculateAdoptedSize(y, itemCount, rowHeight)); + } + return expectedSize; + } + +/*********************************************************************** +FixedSizeMultiColumnItemArranger +***********************************************************************/ + + void FixedSizeMultiColumnItemArranger::BeginPlaceItem(bool forMoving, Rect newBounds, vint& newStartIndex) + { + if (forMoving) + { + pim_itemSize = itemSize; + vint rows = newBounds.Top() / itemSize.y; + if (rows < 0) rows = 0; + vint cols = newBounds.Width() / itemSize.x; + if (cols < 1) cols = 1; + newStartIndex = rows * cols; + } + } + + void FixedSizeMultiColumnItemArranger::PlaceItem(bool forMoving, vint index, ItemStyleRecord style, Rect viewBounds, Rect& bounds, Margin& alignmentToParent) + { + vint rowItems = viewBounds.Width() / itemSize.x; + if (rowItems < 1) rowItems = 1; + + vint row = index / rowItems; + vint col = index % rowItems; + bounds = Rect(Point(col * itemSize.x, row * itemSize.y), itemSize); + if (forMoving) + { + Size styleSize = callback->GetStylePreferredSize(GetStyleBounds(style)); + if (pim_itemSize.x < styleSize.x) pim_itemSize.x = styleSize.x; + if (pim_itemSize.y < styleSize.y) pim_itemSize.y = styleSize.y; + } + } + + bool FixedSizeMultiColumnItemArranger::IsItemOutOfViewBounds(vint index, ItemStyleRecord style, Rect bounds, Rect viewBounds) + { + return bounds.Top() >= viewBounds.Bottom(); + } + + bool FixedSizeMultiColumnItemArranger::EndPlaceItem(bool forMoving, Rect newBounds, vint newStartIndex) + { + if (forMoving) + { + if (pim_itemSize != itemSize) + { + itemSize = pim_itemSize; + return true; + } + } + return false; + } + + void FixedSizeMultiColumnItemArranger::CalculateRange(Size itemSize, Rect bounds, vint count, vint& start, vint& end) + { + vint startRow = bounds.Top() / itemSize.y; + if (startRow < 0) startRow = 0; + vint endRow = (bounds.Bottom() - 1) / itemSize.y; + vint cols = bounds.Width() / itemSize.x; + if (cols < 1) cols = 1; + + start = startRow*cols; + end = (endRow + 1)*cols - 1; + if (end >= count) end = count - 1; + } + + void FixedSizeMultiColumnItemArranger::InvalidateItemSizeCache() + { + itemSize = Size(1, 1); + } + + Size FixedSizeMultiColumnItemArranger::OnCalculateTotalSize() + { + vint rowItems = viewBounds.Width() / itemSize.x; + if (rowItems < 1) rowItems = 1; + vint rows = itemProvider->Count() / rowItems; + if (itemProvider->Count() % rowItems) rows++; + + return Size(itemSize.x * rowItems, itemSize.y*rows); + } + + FixedSizeMultiColumnItemArranger::FixedSizeMultiColumnItemArranger() + :itemSize(1, 1) + { + } + + FixedSizeMultiColumnItemArranger::~FixedSizeMultiColumnItemArranger() + { + } + + vint FixedSizeMultiColumnItemArranger::FindItem(vint itemIndex, compositions::KeyDirection key) + { + vint count = itemProvider->Count(); + vint columnCount = viewBounds.Width() / itemSize.x; + if (columnCount == 0) columnCount = 1; + vint rowCount = viewBounds.Height() / itemSize.y; + if (rowCount == 0) rowCount = 1; + + switch (key) + { + case KeyDirection::Up: + itemIndex -= columnCount; + break; + case KeyDirection::Down: + itemIndex += columnCount; + break; + case KeyDirection::Left: + itemIndex--; + break; + case KeyDirection::Right: + itemIndex++; + break; + case KeyDirection::Home: + itemIndex = 0; + break; + case KeyDirection::End: + itemIndex = count; + break; + case KeyDirection::PageUp: + itemIndex -= columnCount*rowCount; + break; + case KeyDirection::PageDown: + itemIndex += columnCount*rowCount; + break; + case KeyDirection::PageLeft: + itemIndex -= itemIndex%columnCount; + break; + case KeyDirection::PageRight: + itemIndex += columnCount - itemIndex%columnCount - 1; + break; + default: + return -1; + } + + if (itemIndex < 0) return 0; + else if (itemIndex >= count) return count - 1; + else return itemIndex; + } + + bool FixedSizeMultiColumnItemArranger::EnsureItemVisible(vint itemIndex) + { + if (callback) + { + if (itemIndex < 0 || itemIndex >= itemProvider->Count()) + { + return false; + } + while (true) + { + vint rowHeight = itemSize.y; + vint columnCount = viewBounds.Width() / itemSize.x; + if (columnCount == 0) columnCount = 1; + vint rowIndex = itemIndex / columnCount; + + vint top = rowIndex*rowHeight; + vint bottom = top + rowHeight; + + if (viewBounds.Height() < rowHeight) + { + if (viewBounds.Top() < bottom && top < viewBounds.Bottom()) + { + break; + } + } + + Point location = viewBounds.LeftTop(); + if (top < viewBounds.Top()) + { + location.y = top; + } + else if (viewBounds.Bottom() < bottom) + { + location.y = bottom - viewBounds.Height(); + } + else + { + break; + } + callback->SetViewLocation(location); + } + return true; + } + return false; + } + + Size FixedSizeMultiColumnItemArranger::GetAdoptedSize(Size expectedSize) + { + if (itemProvider) + { + vint count = itemProvider->Count(); + vint columnCount = viewBounds.Width() / itemSize.x; + vint rowCount = viewBounds.Height() / itemSize.y; + return Size( + CalculateAdoptedSize(expectedSize.x, columnCount, itemSize.x), + CalculateAdoptedSize(expectedSize.y, rowCount, itemSize.y) + ); + } + return expectedSize; + } + +/*********************************************************************** +FixedHeightMultiColumnItemArranger +***********************************************************************/ + + void FixedHeightMultiColumnItemArranger::BeginPlaceItem(bool forMoving, Rect newBounds, vint& newStartIndex) + { + pi_currentWidth = 0; + pi_totalWidth = 0; + if (forMoving) + { + pim_itemHeight = itemHeight; + vint rows = newBounds.Height() / itemHeight; + if (rows < 1) rows = 1; + vint columns = newBounds.Left() / newBounds.Width(); + newStartIndex = rows * columns; + } + } + + void FixedHeightMultiColumnItemArranger::PlaceItem(bool forMoving, vint index, ItemStyleRecord style, Rect viewBounds, Rect& bounds, Margin& alignmentToParent) + { + vint rows = viewBounds.Height() / itemHeight; + if (rows < 1) rows = 1; + + vint row = index % rows; + if (row == 0) + { + pi_totalWidth += pi_currentWidth; + pi_currentWidth = 0; + } + + Size styleSize = callback->GetStylePreferredSize(GetStyleBounds(style)); + if (pi_currentWidth < styleSize.x) pi_currentWidth = styleSize.x; + bounds = Rect(Point(pi_totalWidth + viewBounds.Left(), itemHeight * row), Size(0, 0)); + if (forMoving) + { + if (pim_itemHeight < styleSize.y) pim_itemHeight = styleSize.y; + } + } + + bool FixedHeightMultiColumnItemArranger::IsItemOutOfViewBounds(vint index, ItemStyleRecord style, Rect bounds, Rect viewBounds) + { + return bounds.Left() >= viewBounds.Right(); + } + + bool FixedHeightMultiColumnItemArranger::EndPlaceItem(bool forMoving, Rect newBounds, vint newStartIndex) + { + if (forMoving) + { + if (pim_itemHeight != itemHeight) + { + itemHeight = pim_itemHeight; + return true; + } + } + return false; + } + + void FixedHeightMultiColumnItemArranger::CalculateRange(vint itemHeight, Rect bounds, vint& rows, vint& startColumn) + { + rows = bounds.Height() / itemHeight; + if (rows < 1) rows = 1; + startColumn = bounds.Left() / bounds.Width(); + } + + void FixedHeightMultiColumnItemArranger::InvalidateItemSizeCache() + { + itemHeight = 1; + } + + Size FixedHeightMultiColumnItemArranger::OnCalculateTotalSize() + { + vint rows = viewBounds.Height() / itemHeight; + if (rows < 1) rows = 1; + vint columns = itemProvider->Count() / rows; + if (itemProvider->Count() % rows) columns += 1; + return Size(viewBounds.Width() * columns, 0); + } + + FixedHeightMultiColumnItemArranger::FixedHeightMultiColumnItemArranger() + :itemHeight(1) + { + } + + FixedHeightMultiColumnItemArranger::~FixedHeightMultiColumnItemArranger() + { + } + + vint FixedHeightMultiColumnItemArranger::FindItem(vint itemIndex, compositions::KeyDirection key) + { + vint count = itemProvider->Count(); + vint groupCount = viewBounds.Height() / itemHeight; + if (groupCount == 0) groupCount = 1; + switch (key) + { + case KeyDirection::Up: + itemIndex--; + break; + case KeyDirection::Down: + itemIndex++; + break; + case KeyDirection::Left: + itemIndex -= groupCount; + break; + case KeyDirection::Right: + itemIndex += groupCount; + break; + case KeyDirection::Home: + itemIndex = 0; + break; + case KeyDirection::End: + itemIndex = count; + break; + case KeyDirection::PageUp: + itemIndex -= itemIndex%groupCount; + break; + case KeyDirection::PageDown: + itemIndex += groupCount - itemIndex%groupCount - 1; + break; + default: + return -1; + } + + if (itemIndex < 0) return 0; + else if (itemIndex >= count) return count - 1; + else return itemIndex; + } + + bool FixedHeightMultiColumnItemArranger::EnsureItemVisible(vint itemIndex) + { + if (callback) + { + if (itemIndex < 0 || itemIndex >= itemProvider->Count()) + { + return false; + } + while (true) + { + vint rowCount = viewBounds.Height() / itemHeight; + if (rowCount == 0) rowCount = 1; + vint columnIndex = itemIndex / rowCount; + vint minIndex = startIndex; + vint maxIndex = startIndex + visibleStyles.Count() - 1; + + Point location = viewBounds.LeftTop(); + if (minIndex <= itemIndex && itemIndex <= maxIndex) + { + Rect bounds = callback->GetStyleBounds(GetStyleBounds(visibleStyles[itemIndex - startIndex])); + if (0 < bounds.Bottom() && bounds.Top() < viewBounds.Width() && bounds.Width() > viewBounds.Width()) + { + break; + } + else if (bounds.Left() < 0) + { + location.x -= viewBounds.Width(); + } + else if (bounds.Right() > viewBounds.Width()) + { + location.x += viewBounds.Width(); + } + else + { + break; + } + } + else if (columnIndex < minIndex / rowCount) + { + location.x -= viewBounds.Width(); + } + else if (columnIndex >= maxIndex / rowCount) + { + location.x += viewBounds.Width(); + } + else + { + break; + } + callback->SetViewLocation(location); + } + return true; + } + return false; + } + + Size FixedHeightMultiColumnItemArranger::GetAdoptedSize(Size expectedSize) + { + if (itemProvider) + { + vint count = itemProvider->Count(); + return Size(expectedSize.x, CalculateAdoptedSize(expectedSize.y, count, itemHeight)); + } + return expectedSize; + } + } + } + } +} + +/*********************************************************************** +.\CONTROLS\LISTCONTROLPACKAGE\GUITEXTLISTCONTROLS.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace controls + { + using namespace collections; + using namespace elements; + using namespace compositions; + using namespace reflection::description; + + namespace list + { + const wchar_t* const ITextItemView::Identifier = L"vl::presentation::controls::list::ITextItemView"; + +/*********************************************************************** +DefaultTextListItemTemplate +***********************************************************************/ + + DefaultTextListItemTemplate::BulletStyle* DefaultTextListItemTemplate::CreateBulletStyle() + { + return nullptr; + } + + void DefaultTextListItemTemplate::OnInitialize() + { + templates::GuiTextListItemTemplate::OnInitialize(); + SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + + textElement = GuiSolidLabelElement::Create(); + textElement->SetAlignments(Alignment::Left, Alignment::Center); + + GuiBoundsComposition* textComposition = new GuiBoundsComposition; + textComposition->SetOwnedElement(textElement); + textComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); + + if (auto bulletStyleController = CreateBulletStyle()) + { + bulletButton = new GuiSelectableButton(bulletStyleController); + bulletButton->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); + bulletButton->SelectedChanged.AttachMethod(this, &DefaultTextListItemTemplate::OnBulletSelectedChanged); + + GuiTableComposition* table = new GuiTableComposition; + AddChild(table); + table->SetAlignmentToParent(Margin(0, 0, 0, 0)); + table->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + table->SetRowsAndColumns(1, 2); + table->SetRowOption(0, GuiCellOption::PercentageOption(1.0)); + table->SetColumnOption(0, GuiCellOption::MinSizeOption()); + table->SetColumnOption(1, GuiCellOption::PercentageOption(1.0)); + { + GuiCellComposition* cell = new GuiCellComposition; + table->AddChild(cell); + cell->SetSite(0, 0, 1, 1); + cell->AddChild(bulletButton->GetBoundsComposition()); + } + { + GuiCellComposition* cell = new GuiCellComposition; + table->AddChild(cell); + cell->SetSite(0, 1, 1, 1); + cell->AddChild(textComposition); + textComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); + } + } + else + { + AddChild(textComposition); + textComposition->SetAlignmentToParent(Margin(5, 0, 0, 0)); + } + + FontChanged.AttachMethod(this, &DefaultTextListItemTemplate::OnFontChanged); + TextChanged.AttachMethod(this, &DefaultTextListItemTemplate::OnTextChanged); + TextColorChanged.AttachMethod(this, &DefaultTextListItemTemplate::OnTextColorChanged); + CheckedChanged.AttachMethod(this, &DefaultTextListItemTemplate::OnCheckedChanged); + + FontChanged.Execute(compositions::GuiEventArgs(this)); + TextChanged.Execute(compositions::GuiEventArgs(this)); + TextColorChanged.Execute(compositions::GuiEventArgs(this)); + CheckedChanged.Execute(compositions::GuiEventArgs(this)); + } + + void DefaultTextListItemTemplate::OnFontChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + textElement->SetFont(GetFont()); + } + + void DefaultTextListItemTemplate::OnTextChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + textElement->SetText(GetText()); + } + + void DefaultTextListItemTemplate::OnTextColorChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + textElement->SetColor(GetTextColor()); + } + + void DefaultTextListItemTemplate::OnCheckedChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + if (bulletButton) + { + supressEdit = true; + bulletButton->SetSelected(GetChecked()); + supressEdit = false; + } + } + + void DefaultTextListItemTemplate::OnBulletSelectedChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + if (!supressEdit) + { + if (auto textItemView = dynamic_cast(listControl->GetItemProvider()->RequestView(ITextItemView::Identifier))) + { + BeginEditListItem(); + textItemView->SetChecked(GetIndex(), bulletButton->GetSelected()); + EndEditListItem(); + } + } + } + + DefaultTextListItemTemplate::DefaultTextListItemTemplate() + { + } + + DefaultTextListItemTemplate::~DefaultTextListItemTemplate() + { + } + +/*********************************************************************** +DefaultCheckTextListItemTemplate +***********************************************************************/ + + DefaultTextListItemTemplate::BulletStyle* DefaultCheckTextListItemTemplate::CreateBulletStyle() + { + if (auto textList = dynamic_cast(listControl)) + { + auto style = textList->GetTextListStyleProvider()->CreateCheckBulletStyle(); + if (style) return style; + } + return theme::GetCurrentTheme()->CreateCheckTextListItemStyle(); + } + +/*********************************************************************** +DefaultRadioTextListItemTemplate +***********************************************************************/ + + DefaultTextListItemTemplate::BulletStyle* DefaultRadioTextListItemTemplate::CreateBulletStyle() + { + if (auto textList = dynamic_cast(listControl)) + { + auto style = textList->GetTextListStyleProvider()->CreateRadioBulletStyle(); + if (style) return style; + } + return theme::GetCurrentTheme()->CreateRadioTextListItemStyle(); + } + +/*********************************************************************** +TextItem +***********************************************************************/ + + TextItem::TextItem() + :owner(0) + , checked(false) + { + } + + TextItem::TextItem(const WString& _text, bool _checked) + :owner(0) + , text(_text) + , checked(_checked) + { + } + + TextItem::~TextItem() + { + } + + bool TextItem::operator==(const TextItem& value)const + { + return text==value.text; + } + + bool TextItem::operator!=(const TextItem& value)const + { + return text!=value.text; + } + + const WString& TextItem::GetText() + { + return text; + } + + void TextItem::SetText(const WString& value) + { + if (text != value) + { + text = value; + if (owner) + { + vint index = owner->IndexOf(this); + owner->InvokeOnItemModified(index, 1, 1); + } + } + } + + bool TextItem::GetChecked() + { + return checked; + } + + void TextItem::SetChecked(bool value) + { + if (checked != value) + { + checked = value; + if (owner) + { + vint index = owner->IndexOf(this); + owner->InvokeOnItemModified(index, 1, 1); + + GuiItemEventArgs arguments; + arguments.itemIndex = index; + owner->listControl->ItemChecked.Execute(arguments); + } + } + } + +/*********************************************************************** +TextItemProvider +***********************************************************************/ + + void TextItemProvider::AfterInsert(vint item, const Ptr& value) + { + ListProvider>::AfterInsert(item, value); + value->owner = this; + } + + void TextItemProvider::BeforeRemove(vint item, const Ptr& value) + { + value->owner = 0; + ListProvider>::BeforeRemove(item, value); + } + + WString TextItemProvider::GetTextValue(vint itemIndex) + { + return Get(itemIndex)->GetText(); + } + + description::Value TextItemProvider::GetBindingValue(vint itemIndex) + { + return Value::From(Get(itemIndex)); + } + + bool TextItemProvider::GetChecked(vint itemIndex) + { + return Get(itemIndex)->GetChecked(); + } + + void TextItemProvider::SetChecked(vint itemIndex, bool value) + { + return Get(itemIndex)->SetChecked(value); + } + + TextItemProvider::TextItemProvider() + :listControl(0) + { + } + + TextItemProvider::~TextItemProvider() + { + } + + IDescriptable* TextItemProvider::RequestView(const WString& identifier) + { + if (identifier == ITextItemView::Identifier) + { + return (ITextItemView*)this; + } + else + { + return nullptr; + } + } + } + +/*********************************************************************** +GuiTextList +***********************************************************************/ + + void GuiVirtualTextList::OnStyleInstalled(vint itemIndex, ItemStyle* style) + { + GuiSelectableListControl::OnStyleInstalled(itemIndex, style); + if (auto textItemStyle = dynamic_cast(style)) + { + textItemStyle->SetTextColor(styleProvider->GetTextColor()); + if (auto textItemView = dynamic_cast(itemProvider->RequestView(list::ITextItemView::Identifier))) + { + textItemStyle->SetChecked(textItemView->GetChecked(itemIndex)); + } + } + } + + void GuiVirtualTextList::OnItemTemplateChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + view = TextListView::Unknown; + } + + GuiVirtualTextList::GuiVirtualTextList(IStyleProvider* _styleProvider, GuiListControl::IItemProvider* _itemProvider) + :GuiSelectableListControl(_styleProvider, _itemProvider) + { + ItemTemplateChanged.AttachMethod(this, &GuiVirtualTextList::OnItemTemplateChanged); + ItemChecked.SetAssociatedComposition(boundsComposition); + + styleProvider = dynamic_cast(styleController->GetStyleProvider()); + SetView(TextListView::Text); + } + + GuiVirtualTextList::~GuiVirtualTextList() + { + } + + GuiVirtualTextList::IStyleProvider* GuiVirtualTextList::GetTextListStyleProvider() + { + return styleProvider; + } + + TextListView GuiVirtualTextList::GetView() + { + return view; + } + + void GuiVirtualTextList::SetView(TextListView _view) + { + switch (_view) + { + case TextListView::Text: + SetStyleAndArranger( + [](const Value&) { return new list::DefaultTextListItemTemplate; }, + new list::FixedHeightItemArranger + ); + break; + case TextListView::Check: + SetStyleAndArranger( + [](const Value&) { return new list::DefaultCheckTextListItemTemplate; }, + new list::FixedHeightItemArranger + ); + break; + case TextListView::Radio: + SetStyleAndArranger( + [](const Value&) { return new list::DefaultRadioTextListItemTemplate; }, + new list::FixedHeightItemArranger + ); + break; + default:; + } + view = _view; + } + +/*********************************************************************** +GuiTextList +***********************************************************************/ + + GuiTextList::GuiTextList(IStyleProvider* _styleProvider) + :GuiVirtualTextList(_styleProvider, new list::TextItemProvider) + { + items=dynamic_cast(itemProvider.Obj()); + items->listControl=this; + } + + GuiTextList::~GuiTextList() + { + } + + list::TextItemProvider& GuiTextList::GetItems() + { + return *items; + } + + Ptr GuiTextList::GetSelectedItem() + { + vint index = GetSelectedItemIndex(); + if (index == -1) return 0; + return items->Get(index); + } + } + } +} + +/*********************************************************************** +.\CONTROLS\LISTCONTROLPACKAGE\GUITREEVIEWCONTROLS.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace controls + { + using namespace elements; + using namespace compositions; + using namespace reflection::description; + + namespace tree + { + const wchar_t* const INodeItemView::Identifier = L"vl::presentation::controls::tree::INodeItemView"; + +/*********************************************************************** +NodeItemProvider +***********************************************************************/ + + INodeProvider* NodeItemProvider::GetNodeByOffset(INodeProvider* provider, vint offset) + { + if(offset==0) return provider; + INodeProvider* result=0; + if(provider->GetExpanding() && offset>0) + { + offset-=1; + vint count=provider->GetChildCount(); + for(vint i=0;(!result && iGetChild(i); + vint visibleCount=child->CalculateTotalVisibleNodes(); + if(offsetGetExpanding()) + { + for(vint i=0;iGetChild(start+i); + offset+=child->CalculateTotalVisibleNodes(); + child->Release(); + } + } + offsetBeforeChildModifieds.Set(parentNode, offset); + } + + void NodeItemProvider::OnAfterItemModified(INodeProvider* parentNode, vint start, vint count, vint newCount) + { + vint offsetBeforeChildModified = 0; + { + vint index = offsetBeforeChildModifieds.Keys().IndexOf(parentNode); + if (index != -1) + { + offsetBeforeChildModified = offsetBeforeChildModifieds.Values().Get(index); + offsetBeforeChildModifieds.Remove(parentNode); + } + } + + vint base=CalculateNodeVisibilityIndexInternal(parentNode); + if(base!=-2 && parentNode->GetExpanding()) + { + vint offset=0; + vint firstChildStart=-1; + for(vint i=0;iGetChild(start+i); + if(i==0) + { + firstChildStart=CalculateNodeVisibilityIndexInternal(child); + } + offset+=child->CalculateTotalVisibleNodes(); + child->Release(); + } + + if(firstChildStart==-1) + { + vint childCount=parentNode->GetChildCount(); + if(childCount==0) + { + firstChildStart=base+1; + } + else if(startGetChild(start); + firstChildStart=CalculateNodeVisibilityIndexInternal(child); + child->Release(); + } + else + { + INodeProvider* child=parentNode->GetChild(start-1); + firstChildStart=CalculateNodeVisibilityIndexInternal(child); + firstChildStart+=child->CalculateTotalVisibleNodes(); + child->Release(); + } + } + InvokeOnItemModified(firstChildStart, offsetBeforeChildModified, offset); + } + } + + void NodeItemProvider::OnItemExpanded(INodeProvider* node) + { + vint base=CalculateNodeVisibilityIndexInternal(node); + if(base!=-2) + { + vint visibility=node->CalculateTotalVisibleNodes(); + InvokeOnItemModified(base+1, 0, visibility-1); + } + } + + void NodeItemProvider::OnItemCollapsed(INodeProvider* node) + { + vint base=CalculateNodeVisibilityIndexInternal(node); + if(base!=-2) + { + vint visibility=0; + vint count=node->GetChildCount(); + for(vint i=0;iGetChild(i); + visibility+=child->CalculateTotalVisibleNodes(); + child->Release(); + } + InvokeOnItemModified(base+1, visibility, 0); + } + } + + vint NodeItemProvider::CalculateNodeVisibilityIndexInternal(INodeProvider* node) + { + INodeProvider* parent=node->GetParent(); + if(parent==0) + { + return -1; + } + if(!parent->GetExpanding()) + { + return -2; + } + + vint index=CalculateNodeVisibilityIndexInternal(parent); + if(index==-2) + { + return -2; + } + + vint count=parent->GetChildCount(); + for(vint i=0;iGetChild(i); + bool findResult=child==node; + if(findResult) + { + index++; + } + else + { + index+=child->CalculateTotalVisibleNodes(); + } + child->Release(); + if(findResult) + { + return index; + } + } + return -1; + } + + vint NodeItemProvider::CalculateNodeVisibilityIndex(INodeProvider* node) + { + vint result=CalculateNodeVisibilityIndexInternal(node); + return result<0?-1:result; + } + + INodeProvider* NodeItemProvider::RequestNode(vint index) + { + if(root->CanGetNodeByVisibleIndex()) + { + return root->GetNodeByVisibleIndex(index+1); + } + else + { + return GetNodeByOffset(root->GetRootNode(), index+1); + } + } + + void NodeItemProvider::ReleaseNode(INodeProvider* node) + { + if(node) + { + node->Release(); + } + } + + NodeItemProvider::NodeItemProvider(Ptr _root) + :root(_root) + { + root->AttachCallback(this); + } + + NodeItemProvider::~NodeItemProvider() + { + root->DetachCallback(this); + } + + Ptr NodeItemProvider::GetRoot() + { + return root; + } + + vint NodeItemProvider::Count() + { + return root->GetRootNode()->CalculateTotalVisibleNodes()-1; + } + + WString NodeItemProvider::GetTextValue(vint itemIndex) + { + if (auto node = RequestNode(itemIndex)) + { + WString result = root->GetTextValue(node); + ReleaseNode(node); + return result; + } + return L""; + } + + description::Value NodeItemProvider::GetBindingValue(vint itemIndex) + { + if (auto node = RequestNode(itemIndex)) + { + Value result = root->GetBindingValue(node); + ReleaseNode(node); + return result; + } + return Value(); + } + + IDescriptable* NodeItemProvider::RequestView(const WString& identifier) + { + if(identifier==INodeItemView::Identifier) + { + return (INodeItemView*)this; + } + else + { + return root->RequestView(identifier); + } + } + +/*********************************************************************** +MemoryNodeProvider::NodeCollection +***********************************************************************/ + + void MemoryNodeProvider::NodeCollection::OnBeforeChildModified(vint start, vint count, vint newCount) + { + ownerProvider->offsetBeforeChildModified=0; + if(ownerProvider->expanding) + { + for(vint i=0;ioffsetBeforeChildModified+=items[start+i]->totalVisibleNodeCount; + } + } + INodeProviderCallback* proxy=ownerProvider->GetCallbackProxyInternal(); + if(proxy) + { + proxy->OnBeforeItemModified(ownerProvider, start, count, newCount); + } + } + + void MemoryNodeProvider::NodeCollection::OnAfterChildModified(vint start, vint count, vint newCount) + { + ownerProvider->childCount+=(newCount-count); + if(ownerProvider->expanding) + { + vint offset=0; + for(vint i=0;itotalVisibleNodeCount; + } + ownerProvider->OnChildTotalVisibleNodesChanged(offset-ownerProvider->offsetBeforeChildModified); + } + INodeProviderCallback* proxy=ownerProvider->GetCallbackProxyInternal(); + if(proxy) + { + proxy->OnAfterItemModified(ownerProvider, start, count, newCount); + } + } + + bool MemoryNodeProvider::NodeCollection::QueryInsert(vint index, Ptr const& child) + { + return child->parent == 0; + } + + bool MemoryNodeProvider::NodeCollection::QueryRemove(vint index, Ptr const& child) + { + return child->parent == ownerProvider; + } + + void MemoryNodeProvider::NodeCollection::BeforeInsert(vint index, Ptr const& child) + { + OnBeforeChildModified(index, 0, 1); + child->parent = ownerProvider; + } + + void MemoryNodeProvider::NodeCollection::BeforeRemove(vint index, Ptr const& child) + { + OnBeforeChildModified(index, 1, 0); + child->parent = 0; + } + + void MemoryNodeProvider::NodeCollection::AfterInsert(vint index, Ptr const& child) + { + OnAfterChildModified(index, 0, 1); + } + + void MemoryNodeProvider::NodeCollection::AfterRemove(vint index, vint count) + { + OnAfterChildModified(index, count, 0); + } + + MemoryNodeProvider::NodeCollection::NodeCollection() + :ownerProvider(0) + { + } + +/*********************************************************************** +MemoryNodeProvider +***********************************************************************/ + + INodeProviderCallback* MemoryNodeProvider::GetCallbackProxyInternal() + { + if(parent) + { + return parent->GetCallbackProxyInternal(); + } + else + { + return 0; + } + } + + void MemoryNodeProvider::OnChildTotalVisibleNodesChanged(vint offset) + { + totalVisibleNodeCount+=offset; + if(parent) + { + parent->OnChildTotalVisibleNodesChanged(offset); + } + } + + MemoryNodeProvider::MemoryNodeProvider(Ptr _data) + :data(_data) + { + children.ownerProvider=this; + } + + MemoryNodeProvider::~MemoryNodeProvider() + { + } + + Ptr MemoryNodeProvider::GetData() + { + return data; + } + + void MemoryNodeProvider::SetData(const Ptr& value) + { + data=value; + NotifyDataModified(); + } + + void MemoryNodeProvider::NotifyDataModified() + { + if(parent) + { + vint index=parent->children.IndexOf(this); + INodeProviderCallback* proxy=GetCallbackProxyInternal(); + if(proxy) + { + proxy->OnBeforeItemModified(parent, index, 1, 1); + proxy->OnAfterItemModified(parent, index, 1, 1); + } + } + } + + MemoryNodeProvider::NodeCollection& MemoryNodeProvider::Children() + { + return children; + } + + bool MemoryNodeProvider::GetExpanding() + { + return expanding; + } + + void MemoryNodeProvider::SetExpanding(bool value) + { + if(expanding!=value) + { + expanding=value; + vint offset=0; + for(vint i=0;itotalVisibleNodeCount; + } + + OnChildTotalVisibleNodesChanged(expanding?offset:-offset); + INodeProviderCallback* proxy=GetCallbackProxyInternal(); + if(proxy) + { + if(expanding) + { + proxy->OnItemExpanded(this); + } + else + { + proxy->OnItemCollapsed(this); + } + } + } + } + + vint MemoryNodeProvider::CalculateTotalVisibleNodes() + { + return totalVisibleNodeCount; + } + + vint MemoryNodeProvider::GetChildCount() + { + return childCount; + } + + INodeProvider* MemoryNodeProvider::GetParent() + { + return parent; + } + + INodeProvider* MemoryNodeProvider::GetChild(vint index) + { + if(0<=index && indexOnBeforeItemModified(parentNode, start, count, newCount); + } + } + + void NodeRootProviderBase::OnAfterItemModified(INodeProvider* parentNode, vint start, vint count, vint newCount) + { + for(vint i=0;iOnAfterItemModified(parentNode, start, count, newCount); + } + } + + void NodeRootProviderBase::OnItemExpanded(INodeProvider* node) + { + for(vint i=0;iOnItemExpanded(node); + } + } + + void NodeRootProviderBase::OnItemCollapsed(INodeProvider* node) + { + for(vint i=0;iOnItemCollapsed(node); + } + } + + NodeRootProviderBase::NodeRootProviderBase() + { + } + + NodeRootProviderBase::~NodeRootProviderBase() + { + } + + bool NodeRootProviderBase::CanGetNodeByVisibleIndex() + { + return false; + } + + INodeProvider* NodeRootProviderBase::GetNodeByVisibleIndex(vint index) + { + return 0; + } + + bool NodeRootProviderBase::AttachCallback(INodeProviderCallback* value) + { + if(callbacks.Contains(value)) + { + return false; + } + else + { + callbacks.Add(value); + value->OnAttached(this); + return true; + } + } + + bool NodeRootProviderBase::DetachCallback(INodeProviderCallback* value) + { + vint index=callbacks.IndexOf(value); + if(index==-1) + { + return false; + } + else + { + value->OnAttached(0); + callbacks.Remove(value); + return true; + } + } + + IDescriptable* NodeRootProviderBase::RequestView(const WString& identifier) + { + return 0; + } + +/*********************************************************************** +MemoryNodeRootProvider +***********************************************************************/ + + INodeProviderCallback* MemoryNodeRootProvider::GetCallbackProxyInternal() + { + return this; + } + + MemoryNodeRootProvider::MemoryNodeRootProvider() + { + SetExpanding(true); + } + + MemoryNodeRootProvider::~MemoryNodeRootProvider() + { + } + + INodeProvider* MemoryNodeRootProvider::GetRootNode() + { + return this; + } + + MemoryNodeProvider* MemoryNodeRootProvider::GetMemoryNode(INodeProvider* node) + { + return dynamic_cast(node); + } + } + +/*********************************************************************** +GuiVirtualTreeListControl +***********************************************************************/ + + void GuiVirtualTreeListControl::OnAttached(tree::INodeRootProvider* provider) + { + } + + void GuiVirtualTreeListControl::OnBeforeItemModified(tree::INodeProvider* parentNode, vint start, vint count, vint newCount) + { + } + + void GuiVirtualTreeListControl::OnAfterItemModified(tree::INodeProvider* parentNode, vint start, vint count, vint newCount) + { + } + + void GuiVirtualTreeListControl::OnItemExpanded(tree::INodeProvider* node) + { + GuiNodeEventArgs arguments; + (GuiEventArgs&)arguments=GetNotifyEventArguments(); + arguments.node=node; + NodeExpanded.Execute(arguments); + } + + void GuiVirtualTreeListControl::OnItemCollapsed(tree::INodeProvider* node) + { + GuiNodeEventArgs arguments; + (GuiEventArgs&)arguments=GetNotifyEventArguments(); + arguments.node=node; + NodeCollapsed.Execute(arguments); + } + + void GuiVirtualTreeListControl::OnItemMouseEvent(compositions::GuiNodeMouseEvent& nodeEvent, compositions::GuiGraphicsComposition* sender, compositions::GuiItemMouseEventArgs& arguments) + { + tree::INodeProvider* node=GetNodeItemView()->RequestNode(arguments.itemIndex); + if(node) + { + GuiNodeMouseEventArgs redirectArguments; + (GuiMouseEventArgs&)redirectArguments=arguments; + redirectArguments.node=node; + nodeEvent.Execute(redirectArguments); + (GuiMouseEventArgs&)arguments=redirectArguments; + GetNodeItemView()->ReleaseNode(node); + } + } + + void GuiVirtualTreeListControl::OnItemNotifyEvent(compositions::GuiNodeNotifyEvent& nodeEvent, compositions::GuiGraphicsComposition* sender, compositions::GuiItemEventArgs& arguments) + { + if(auto node = GetNodeItemView()->RequestNode(arguments.itemIndex)) + { + GuiNodeEventArgs redirectArguments; + (GuiEventArgs&)redirectArguments=arguments; + redirectArguments.node=node; + nodeEvent.Execute(redirectArguments); + (GuiEventArgs&)arguments=redirectArguments; + GetNodeItemView()->ReleaseNode(node); + } + } + +#define ATTACH_ITEM_MOUSE_EVENT(NODEEVENTNAME, ITEMEVENTNAME)\ + {\ + Func func(this, &GuiVirtualTreeListControl::OnItemMouseEvent);\ + ITEMEVENTNAME.AttachFunction(Curry(func)(NODEEVENTNAME));\ + }\ + +#define ATTACH_ITEM_NOTIFY_EVENT(NODEEVENTNAME, ITEMEVENTNAME)\ + {\ + Func func(this, &GuiVirtualTreeListControl::OnItemNotifyEvent);\ + ITEMEVENTNAME.AttachFunction(Curry(func)(NODEEVENTNAME));\ + }\ + + void GuiVirtualTreeListControl::OnNodeLeftButtonDoubleClick(compositions::GuiGraphicsComposition* sender, compositions::GuiNodeMouseEventArgs& arguments) + { + if (arguments.node->GetChildCount() > 0) + { + arguments.node->SetExpanding(!arguments.node->GetExpanding()); + } + } + + GuiVirtualTreeListControl::GuiVirtualTreeListControl(IStyleProvider* _styleProvider, Ptr _nodeRootProvider) + :GuiSelectableListControl(_styleProvider, new tree::NodeItemProvider(_nodeRootProvider)) + { + nodeItemProvider = dynamic_cast(GetItemProvider()); + nodeItemView = dynamic_cast(GetItemProvider()->RequestView(tree::INodeItemView::Identifier)); + + NodeLeftButtonDown.SetAssociatedComposition(boundsComposition); + NodeLeftButtonUp.SetAssociatedComposition(boundsComposition); + NodeLeftButtonDoubleClick.SetAssociatedComposition(boundsComposition); + NodeMiddleButtonDown.SetAssociatedComposition(boundsComposition); + NodeMiddleButtonUp.SetAssociatedComposition(boundsComposition); + NodeMiddleButtonDoubleClick.SetAssociatedComposition(boundsComposition); + NodeRightButtonDown.SetAssociatedComposition(boundsComposition); + NodeRightButtonUp.SetAssociatedComposition(boundsComposition); + NodeRightButtonDoubleClick.SetAssociatedComposition(boundsComposition); + NodeMouseMove.SetAssociatedComposition(boundsComposition); + NodeMouseEnter.SetAssociatedComposition(boundsComposition); + NodeMouseLeave.SetAssociatedComposition(boundsComposition); + NodeExpanded.SetAssociatedComposition(boundsComposition); + NodeCollapsed.SetAssociatedComposition(boundsComposition); + + ATTACH_ITEM_MOUSE_EVENT(NodeLeftButtonDown, ItemLeftButtonDown); + ATTACH_ITEM_MOUSE_EVENT(NodeLeftButtonUp, ItemLeftButtonUp); + ATTACH_ITEM_MOUSE_EVENT(NodeLeftButtonDoubleClick, ItemLeftButtonDoubleClick); + ATTACH_ITEM_MOUSE_EVENT(NodeMiddleButtonDown, ItemMiddleButtonDown); + ATTACH_ITEM_MOUSE_EVENT(NodeMiddleButtonUp, ItemMiddleButtonUp); + ATTACH_ITEM_MOUSE_EVENT(NodeMiddleButtonDoubleClick, ItemMiddleButtonDoubleClick); + ATTACH_ITEM_MOUSE_EVENT(NodeRightButtonDown, ItemRightButtonDown); + ATTACH_ITEM_MOUSE_EVENT(NodeRightButtonUp, ItemRightButtonUp); + ATTACH_ITEM_MOUSE_EVENT(NodeRightButtonDoubleClick, ItemRightButtonDoubleClick); + ATTACH_ITEM_MOUSE_EVENT(NodeMouseMove, ItemMouseMove); + ATTACH_ITEM_NOTIFY_EVENT(NodeMouseEnter, ItemMouseEnter); + ATTACH_ITEM_NOTIFY_EVENT(NodeMouseLeave, ItemMouseLeave); + + nodeItemProvider->GetRoot()->AttachCallback(this); + NodeLeftButtonDoubleClick.AttachMethod(this, &GuiVirtualTreeListControl::OnNodeLeftButtonDoubleClick); + } + +#undef ATTACH_ITEM_MOUSE_EVENT +#undef ATTACH_ITEM_NOTIFY_EVENT + + GuiVirtualTreeListControl::~GuiVirtualTreeListControl() + { + } + + tree::INodeItemView* GuiVirtualTreeListControl::GetNodeItemView() + { + return nodeItemView; + } + + tree::INodeRootProvider* GuiVirtualTreeListControl::GetNodeRootProvider() + { + return nodeItemProvider->GetRoot().Obj(); + } + + namespace tree + { + +/*********************************************************************** +TreeViewItem +***********************************************************************/ + + const wchar_t* const ITreeViewItemView::Identifier = L"vl::presentation::controls::tree::ITreeViewItemView"; + + TreeViewItem::TreeViewItem() + { + } + + TreeViewItem::TreeViewItem(const Ptr& _image, const WString& _text) + :image(_image) + ,text(_text) + { + } + +/*********************************************************************** +TreeViewItemRootProvider +***********************************************************************/ + + Ptr TreeViewItemRootProvider::GetNodeImage(INodeProvider* node) + { + MemoryNodeProvider* memoryNode=dynamic_cast(node); + if(memoryNode) + { + Ptr data=memoryNode->GetData().Cast(); + if(data) + { + return data->image; + } + } + return 0; + } + + WString TreeViewItemRootProvider::GetTextValue(INodeProvider* node) + { + MemoryNodeProvider* memoryNode = dynamic_cast(node); + if (memoryNode) + { + Ptr data = memoryNode->GetData().Cast(); + if (data) + { + return data->text; + } + } + return L""; + } + + description::Value TreeViewItemRootProvider::GetBindingValue(INodeProvider* node) + { + return Value::From(GetTreeViewData(node)); + } + + TreeViewItemRootProvider::TreeViewItemRootProvider() + { + } + + TreeViewItemRootProvider::~TreeViewItemRootProvider() + { + } + + IDescriptable* TreeViewItemRootProvider::RequestView(const WString& identifier) + { + if(identifier==ITreeViewItemView::Identifier) + { + return (ITreeViewItemView*)this; + } + else + { + return MemoryNodeRootProvider::RequestView(identifier); + } + } + + Ptr TreeViewItemRootProvider::GetTreeViewData(INodeProvider* node) + { + MemoryNodeProvider* memoryNode=GetMemoryNode(node); + if(memoryNode) + { + return memoryNode->GetData().Cast(); + } + else + { + return 0; + } + } + + void TreeViewItemRootProvider::SetTreeViewData(INodeProvider* node, Ptr value) + { + MemoryNodeProvider* memoryNode=GetMemoryNode(node); + if(memoryNode) + { + memoryNode->SetData(value); + } + } + + void TreeViewItemRootProvider::UpdateTreeViewData(INodeProvider* node) + { + MemoryNodeProvider* memoryNode=GetMemoryNode(node); + if(memoryNode) + { + memoryNode->NotifyDataModified(); + } + } + } + +/*********************************************************************** +GuiVirtualTreeView +***********************************************************************/ + + templates::GuiTreeItemTemplate* GuiVirtualTreeView::GetStyleFromNode(tree::INodeProvider* node) + { + if (itemArranger) + { + vint index = nodeItemView->CalculateNodeVisibilityIndex(node); + if (index != -1) + { + auto style = itemArranger->GetVisibleStyle(index); + return dynamic_cast(style); + } + } + return nullptr; + } + + void GuiVirtualTreeView::SetStyleExpanding(tree::INodeProvider* node, bool expanding) + { + if (auto treeItemStyle = GetStyleFromNode(node)) + { + treeItemStyle->SetExpanding(expanding); + } + } + + void GuiVirtualTreeView::SetStyleExpandable(tree::INodeProvider* node, bool expandable) + { + if (auto treeItemStyle = GetStyleFromNode(node)) + { + treeItemStyle->SetExpandable(expandable); + } + } + + void GuiVirtualTreeView::OnAfterItemModified(tree::INodeProvider* parentNode, vint start, vint count, vint newCount) + { + GuiVirtualTreeListControl::OnAfterItemModified(parentNode, start, count, newCount); + SetStyleExpandable(parentNode, parentNode->GetChildCount() > 0); + } + + void GuiVirtualTreeView::OnItemExpanded(tree::INodeProvider* node) + { + GuiVirtualTreeListControl::OnItemExpanded(node); + SetStyleExpanding(node, true); + } + + void GuiVirtualTreeView::OnItemCollapsed(tree::INodeProvider* node) + { + GuiVirtualTreeListControl::OnItemCollapsed(node); + SetStyleExpanding(node, false); + } + + void GuiVirtualTreeView::OnStyleInstalled(vint itemIndex, ItemStyle* style) + { + GuiVirtualTreeListControl::OnStyleInstalled(itemIndex, style); + if (auto treeItemStyle = dynamic_cast(style)) + { + treeItemStyle->SetTextColor(styleProvider->GetTextColor()); + + if (treeViewItemView) + { + if (auto node = nodeItemView->RequestNode(itemIndex)) + { + treeItemStyle->SetImage(treeViewItemView->GetNodeImage(node)); + treeItemStyle->SetExpanding(node->GetExpanding()); + treeItemStyle->SetExpandable(node->GetChildCount() > 0); + { + vint level = -1; + auto current = node; + while (current->GetParent()) + { + level++; + current = current->GetParent(); + } + treeItemStyle->SetLevel(level); + } + nodeItemView->ReleaseNode(node); + } + } + } + } + + GuiVirtualTreeView::GuiVirtualTreeView(IStyleProvider* _styleProvider, Ptr _nodeRootProvider) + :GuiVirtualTreeListControl(_styleProvider, _nodeRootProvider) + { + styleProvider = dynamic_cast(styleController->GetStyleProvider()); + treeViewItemView = dynamic_cast(GetNodeRootProvider()->RequestView(tree::ITreeViewItemView::Identifier)); + SetStyleAndArranger( + [](const Value&) { return new tree::DefaultTreeItemTemplate; }, + new list::FixedHeightItemArranger + ); + } + + GuiVirtualTreeView::~GuiVirtualTreeView() + { + } + + GuiVirtualTreeView::IStyleProvider* GuiVirtualTreeView::GetTreeViewStyleProvider() + { + return styleProvider; + } + +/*********************************************************************** +GuiTreeView +***********************************************************************/ + + GuiTreeView::GuiTreeView(IStyleProvider* _styleProvider) + :GuiVirtualTreeView(_styleProvider, new tree::TreeViewItemRootProvider) + { + nodes = nodeItemProvider->GetRoot().Cast(); + } + + GuiTreeView::~GuiTreeView() + { + } + + Ptr GuiTreeView::Nodes() + { + return nodes; + } + + Ptr GuiTreeView::GetSelectedItem() + { + Ptr result; + vint index = GetSelectedItemIndex(); + if (index != -1) + { + if (auto node = nodeItemView->RequestNode(index)) + { + if (auto memoryNode = dynamic_cast(node)) + { + result = memoryNode->GetData().Cast(); + } + nodeItemView->ReleaseNode(node); + } + } + return result; + } + + namespace tree + { + +/*********************************************************************** +DefaultTreeItemTemplate +***********************************************************************/ + + void DefaultTreeItemTemplate::OnInitialize() + { + templates::GuiTreeItemTemplate::OnInitialize(); + SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + + table = new GuiTableComposition; + AddChild(table); + table->SetRowsAndColumns(3, 4); + table->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); + table->SetRowOption(1, GuiCellOption::MinSizeOption()); + table->SetRowOption(2, GuiCellOption::PercentageOption(0.5)); + table->SetColumnOption(0, GuiCellOption::AbsoluteOption(0)); + table->SetColumnOption(1, GuiCellOption::MinSizeOption()); + table->SetColumnOption(2, GuiCellOption::MinSizeOption()); + table->SetColumnOption(3, GuiCellOption::MinSizeOption()); + table->SetAlignmentToParent(Margin(0, 0, 0, 0)); + table->SetCellPadding(2); + { + GuiCellComposition* cell = new GuiCellComposition; + table->AddChild(cell); + cell->SetSite(0, 1, 3, 1); + cell->SetPreferredMinSize(Size(16, 16)); + + GuiSelectableButton::IStyleController* expandingStyle = nullptr; + if (auto treeView = dynamic_cast(listControl)) + { + expandingStyle = treeView->GetTreeViewStyleProvider()->CreateItemExpandingDecorator(); + if (!expandingStyle) + { + expandingStyle = theme::GetCurrentTheme()->CreateTreeItemExpanderStyle(); + } + } + expandingButton = new GuiSelectableButton(expandingStyle); + expandingButton->SetAutoSelection(false); + expandingButton->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); + expandingButton->GetEventReceiver()->leftButtonDoubleClick.AttachMethod(this, &DefaultTreeItemTemplate::OnExpandingButtonDoubleClick); + expandingButton->Clicked.AttachMethod(this, &DefaultTreeItemTemplate::OnExpandingButtonClicked); + cell->AddChild(expandingButton->GetBoundsComposition()); + } + { + GuiCellComposition* cell = new GuiCellComposition; + table->AddChild(cell); + cell->SetSite(1, 2, 1, 1); + cell->SetPreferredMinSize(Size(16, 16)); + + imageElement = GuiImageFrameElement::Create(); + imageElement->SetStretch(true); + cell->SetOwnedElement(imageElement); + } + { + GuiCellComposition* cell = new GuiCellComposition; + table->AddChild(cell); + cell->SetSite(0, 3, 3, 1); + cell->SetPreferredMinSize(Size(192, 0)); + + textElement = GuiSolidLabelElement::Create(); + textElement->SetAlignments(Alignment::Left, Alignment::Center); + textElement->SetEllipse(true); + cell->SetOwnedElement(textElement); + } + + FontChanged.AttachMethod(this, &DefaultTreeItemTemplate::OnFontChanged); + TextChanged.AttachMethod(this, &DefaultTreeItemTemplate::OnTextChanged); + TextColorChanged.AttachMethod(this, &DefaultTreeItemTemplate::OnTextColorChanged); + ExpandingChanged.AttachMethod(this, &DefaultTreeItemTemplate::OnExpandingChanged); + ExpandableChanged.AttachMethod(this, &DefaultTreeItemTemplate::OnExpandableChanged); + LevelChanged.AttachMethod(this, &DefaultTreeItemTemplate::OnLevelChanged); + ImageChanged.AttachMethod(this, &DefaultTreeItemTemplate::OnImageChanged); + + FontChanged.Execute(compositions::GuiEventArgs(this)); + TextChanged.Execute(compositions::GuiEventArgs(this)); + TextColorChanged.Execute(compositions::GuiEventArgs(this)); + ExpandingChanged.Execute(compositions::GuiEventArgs(this)); + ExpandableChanged.Execute(compositions::GuiEventArgs(this)); + LevelChanged.Execute(compositions::GuiEventArgs(this)); + ImageChanged.Execute(compositions::GuiEventArgs(this)); + } + + void DefaultTreeItemTemplate::OnFontChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + textElement->SetFont(GetFont()); + } + + void DefaultTreeItemTemplate::OnTextChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + textElement->SetText(GetText()); + } + + void DefaultTreeItemTemplate::OnTextColorChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + textElement->SetColor(GetTextColor()); + } + + void DefaultTreeItemTemplate::OnExpandingChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + expandingButton->SetSelected(GetExpanding()); + } + + void DefaultTreeItemTemplate::OnExpandableChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + expandingButton->SetVisible(GetExpandable()); + } + + void DefaultTreeItemTemplate::OnLevelChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + table->SetColumnOption(0, GuiCellOption::AbsoluteOption(GetLevel() * 12)); + } + + void DefaultTreeItemTemplate::OnImageChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + if (auto imageData = GetImage()) + { + imageElement->SetImage(imageData->GetImage(), imageData->GetFrameIndex()); + } + else + { + imageElement->SetImage(nullptr); + } + } + + void DefaultTreeItemTemplate::OnExpandingButtonDoubleClick(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) + { + arguments.handled = true; + } + + void DefaultTreeItemTemplate::OnExpandingButtonClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + if (expandingButton->GetVisuallyEnabled()) + { + if (auto treeControl = dynamic_cast(listControl)) + { + if (auto view = treeControl->GetNodeItemView()) + { + vint index = treeControl->GetArranger()->GetVisibleIndex(this); + if (index != -1) + { + if (auto node = view->RequestNode(index)) + { + bool expanding = node->GetExpanding(); + node->SetExpanding(!expanding); + view->ReleaseNode(node); + } + } + } + } + } + } + + DefaultTreeItemTemplate::DefaultTreeItemTemplate() + { + } + + DefaultTreeItemTemplate::~DefaultTreeItemTemplate() + { + } + } + } + } +} + +/*********************************************************************** +.\CONTROLS\TEXTEDITORPACKAGE\EDITORCALLBACK\GUITEXTAUTOCOMPLETE.CPP ***********************************************************************/ namespace vl @@ -26941,3247 +22489,7 @@ GuiTextBoxAutoCompleteBase } /*********************************************************************** -CONTROLS\TEXTEDITORPACKAGE\EDITORCALLBACK\GUITEXTCOLORIZER.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace controls - { - using namespace elements; - using namespace elements::text; - -/*********************************************************************** -GuiTextBoxColorizerBase -***********************************************************************/ - - void GuiTextBoxColorizerBase::ColorizerThreadProc(void* argument) - { - GuiTextBoxColorizerBase* colorizer=(GuiTextBoxColorizerBase*)argument; - while(!colorizer->isFinalizing) - { - vint lineIndex=-1; - wchar_t* text=0; - vuint32_t* colors=0; - vint length=0; - vint lexerState=-1; - vint contextState=-1; - - SPIN_LOCK(*colorizer->elementModifyLock) - { - if(colorizer->colorizedLineCount>=colorizer->element->GetLines().GetCount()) - { - colorizer->isColorizerRunning=false; - goto CANCEL_COLORIZING; - } - - lineIndex=colorizer->colorizedLineCount++; - TextLine& line=colorizer->element->GetLines().GetLine(lineIndex); - length=line.dataLength; - text=new wchar_t[length+2]; - colors=new vuint32_t[length+2]; - memcpy(text, line.text, sizeof(wchar_t)*length); - text[length]=L'\r'; - text[length+1]=L'\n'; - lexerState=lineIndex==0?colorizer->GetLexerStartState():colorizer->element->GetLines().GetLine(lineIndex-1).lexerFinalState; - contextState=lineIndex==0?colorizer->GetContextStartState():colorizer->element->GetLines().GetLine(lineIndex-1).contextFinalState; - } - - colorizer->ColorizeLineWithCRLF(lineIndex, text, colors, length+2, lexerState, contextState); - - SPIN_LOCK(*colorizer->elementModifyLock) - { - if(lineIndexcolorizedLineCount && lineIndexelement->GetLines().GetCount()) - { - TextLine& line=colorizer->element->GetLines().GetLine(lineIndex); - line.lexerFinalState=lexerState; - line.contextFinalState=contextState; - for(vint i=0;icolorizerRunningEvent.Leave(); - } - - void GuiTextBoxColorizerBase::StartColorizer() - { - if(!isColorizerRunning) - { - isColorizerRunning=true; - colorizerRunningEvent.Enter(); - ThreadPoolLite::Queue(&GuiTextBoxColorizerBase::ColorizerThreadProc, this); - } - } - - void GuiTextBoxColorizerBase::StopColorizer(bool forever) - { - isFinalizing=true; - colorizerRunningEvent.Enter(); - colorizerRunningEvent.Leave(); - colorizedLineCount=0; - if(!forever) - { - isFinalizing=false; - } - } - - void GuiTextBoxColorizerBase::StopColorizerForever() - { - StopColorizer(true); - } - - GuiTextBoxColorizerBase::GuiTextBoxColorizerBase() - :element(0) - ,elementModifyLock(0) - ,colorizedLineCount(0) - ,isColorizerRunning(false) - ,isFinalizing(false) - { - } - - GuiTextBoxColorizerBase::~GuiTextBoxColorizerBase() - { - StopColorizerForever(); - } - - void GuiTextBoxColorizerBase::Attach(elements::GuiColorizedTextElement* _element, SpinLock& _elementModifyLock, compositions::GuiGraphicsComposition* _ownerComposition, vuint editVersion) - { - if(_element) - { - SPIN_LOCK(_elementModifyLock) - { - element=_element; - elementModifyLock=&_elementModifyLock; - StartColorizer(); - } - } - } - - void GuiTextBoxColorizerBase::Detach() - { - if(element && elementModifyLock) - { - StopColorizer(false); - SPIN_LOCK(*elementModifyLock) - { - element=0; - elementModifyLock=0; - } - } - } - - void GuiTextBoxColorizerBase::TextEditPreview(TextEditPreviewStruct& arguments) - { - } - - void GuiTextBoxColorizerBase::TextEditNotify(const TextEditNotifyStruct& arguments) - { - if(element && elementModifyLock) - { - SPIN_LOCK(*elementModifyLock) - { - vint line - =arguments.originalStart.rowline) - { - colorizedLineCount=line; - } - StartColorizer(); - } - } - } - - void GuiTextBoxColorizerBase::TextCaretChanged(const TextCaretChangedStruct& arguments) - { - } - - void GuiTextBoxColorizerBase::TextEditFinished(vuint editVersion) - { - } - - void GuiTextBoxColorizerBase::RestartColorizer() - { - if(element && elementModifyLock) - { - SPIN_LOCK(*elementModifyLock) - { - colorizedLineCount=0; - StartColorizer(); - } - } - } - -/*********************************************************************** -GuiTextBoxRegexColorizer -***********************************************************************/ - - struct GuiTextBoxRegexColorizerProcData - { - GuiTextBoxRegexColorizer* colorizer; - vint lineIndex; - const wchar_t* text; - vuint32_t* colors; - vint contextState; - }; - - void GuiTextBoxRegexColorizer::ColorizerProc(void* argument, vint start, vint length, vint token) - { - GuiTextBoxRegexColorizerProcData& data=*(GuiTextBoxRegexColorizerProcData*)argument; - data.colorizer->ColorizeTokenContextSensitive(data.lineIndex, data.text, start, length, token, data.contextState); - for(vint i=0;i& GuiTextBoxRegexColorizer::GetTokenRegexes() - { - return tokenRegexes; - } - - collections::List& GuiTextBoxRegexColorizer::GetTokenColors() - { - return tokenColors; - } - - collections::List& GuiTextBoxRegexColorizer::GetExtraTokenColors() - { - return extraTokenColors; - } - - vint GuiTextBoxRegexColorizer::GetExtraTokenIndexStart() - { - if(lexer) - { - return tokenColors.Count(); - } - else - { - return -1; - } - } - - bool GuiTextBoxRegexColorizer::SetDefaultColor(elements::text::ColorEntry value) - { - if(lexer) - { - return false; - } - else - { - defaultColor=value; - return true; - } - } - - vint GuiTextBoxRegexColorizer::AddToken(const WString& regex, elements::text::ColorEntry color) - { - if(lexer) - { - return -1; - } - else - { - tokenRegexes.Add(regex); - tokenColors.Add(color); - return tokenColors.Count()-1; - } - } - - vint GuiTextBoxRegexColorizer::AddExtraToken(elements::text::ColorEntry color) - { - if(lexer) - { - return -1; - } - else - { - extraTokenColors.Add(color); - return extraTokenColors.Count()-1; - } - } - - void GuiTextBoxRegexColorizer::ClearTokens() - { - tokenRegexes.Clear(); - tokenColors.Clear(); - extraTokenColors.Clear(); - lexer=0; - } - - void GuiTextBoxRegexColorizer::Setup() - { - if(lexer || tokenRegexes.Count()==0) - { - colors.Resize(1); - colors[0]=defaultColor; - } - else - { - lexer=new regex::RegexLexer(tokenRegexes); - colors.Resize(1+tokenRegexes.Count()+extraTokenColors.Count()); - colors[0]=defaultColor; - for(vint i=0;iColorize()); - } - } - - void GuiTextBoxRegexColorizer::ColorizeTokenContextSensitive(vint lineIndex, const wchar_t* text, vint start, vint length, vint& token, vint& contextState) - { - } - - vint GuiTextBoxRegexColorizer::GetLexerStartState() - { - return lexer?colorizer->GetStartState():-1; - } - - vint GuiTextBoxRegexColorizer::GetContextStartState() - { - return 0; - } - - void GuiTextBoxRegexColorizer::ColorizeLineWithCRLF(vint lineIndex, const wchar_t* text, vuint32_t* colors, vint length, vint& lexerState, vint& contextState) - { - memset(colors, 0, sizeof(*colors)*length); - if(lexer) - { - GuiTextBoxRegexColorizerProcData data; - data.colorizer=this; - data.lineIndex=lineIndex; - data.text=text; - data.colors=colors; - data.contextState=contextState; - - colorizer->Reset(lexerState); - colorizer->Colorize(text, length, &GuiTextBoxRegexColorizer::ColorizerProc, &data); - - lexerState=colorizer->GetCurrentState(); - contextState=data.contextState; - } - else - { - lexerState=-1; - contextState=-1; - } - } - - const GuiTextBoxRegexColorizer::ColorArray& GuiTextBoxRegexColorizer::GetColors() - { - return colors; - } - } - } -} - -/*********************************************************************** -CONTROLS\TEXTEDITORPACKAGE\EDITORCALLBACK\GUITEXTGENERALOPERATIONS.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace controls - { - } - } -} - -/*********************************************************************** -CONTROLS\TEXTEDITORPACKAGE\EDITORCALLBACK\GUITEXTUNDOREDO.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace controls - { - using namespace elements; - using namespace elements::text; - using namespace compositions; - -/*********************************************************************** -GuiGeneralUndoRedoProcessor -***********************************************************************/ - - GuiGeneralUndoRedoProcessor::GuiGeneralUndoRedoProcessor() - :firstFutureStep(0) - ,savedStep(0) - ,performingUndoRedo(false) - { - } - - GuiGeneralUndoRedoProcessor::~GuiGeneralUndoRedoProcessor() - { - } - - void GuiGeneralUndoRedoProcessor::PushStep(Ptr step) - { - if(!performingUndoRedo) - { - if(firstFutureStep0) - { - steps.RemoveRange(firstFutureStep, count); - } - - steps.Add(step); - firstFutureStep=steps.Count(); - UndoRedoChanged(); - ModifiedChanged(); - } - } - - bool GuiGeneralUndoRedoProcessor::CanUndo() - { - return firstFutureStep>0; - } - - bool GuiGeneralUndoRedoProcessor::CanRedo() - { - return steps.Count()>firstFutureStep; - } - - void GuiGeneralUndoRedoProcessor::ClearUndoRedo() - { - if(!performingUndoRedo) - { - steps.Clear(); - firstFutureStep=0; - savedStep=-1; - } - } - - bool GuiGeneralUndoRedoProcessor::GetModified() - { - return firstFutureStep!=savedStep; - } - - void GuiGeneralUndoRedoProcessor::NotifyModificationSaved() - { - if(!performingUndoRedo) - { - savedStep=firstFutureStep; - ModifiedChanged(); - } - } - - bool GuiGeneralUndoRedoProcessor::Undo() - { - if(!CanUndo()) return false; - performingUndoRedo=true; - firstFutureStep--; - steps[firstFutureStep]->Undo(); - performingUndoRedo=false; - UndoRedoChanged(); - ModifiedChanged(); - return true; - } - - bool GuiGeneralUndoRedoProcessor::Redo() - { - if(!CanRedo()) return false; - performingUndoRedo=true; - firstFutureStep++; - steps[firstFutureStep-1]->Redo(); - performingUndoRedo=false; - UndoRedoChanged(); - ModifiedChanged(); - return true; - } - -/*********************************************************************** -GuiTextBoxUndoRedoProcessor::EditStep -***********************************************************************/ - - void GuiTextBoxUndoRedoProcessor::EditStep::Undo() - { - GuiTextBoxCommonInterface* ci=dynamic_cast(processor->ownerComposition->GetRelatedControl()); - if(ci) - { - ci->Select(arguments.inputStart, arguments.inputEnd); - ci->SetSelectionText(arguments.originalText); - ci->Select(arguments.originalStart, arguments.originalEnd); - } - } - - void GuiTextBoxUndoRedoProcessor::EditStep::Redo() - { - GuiTextBoxCommonInterface* ci=dynamic_cast(processor->ownerComposition->GetRelatedControl()); - if(ci) - { - ci->Select(arguments.originalStart, arguments.originalEnd); - ci->SetSelectionText(arguments.inputText); - ci->Select(arguments.inputStart, arguments.inputEnd); - } - } - -/*********************************************************************** -GuiTextBoxUndoRedoProcessor -***********************************************************************/ - - GuiTextBoxUndoRedoProcessor::GuiTextBoxUndoRedoProcessor() - :ownerComposition(0) - { - } - - GuiTextBoxUndoRedoProcessor::~GuiTextBoxUndoRedoProcessor() - { - } - - void GuiTextBoxUndoRedoProcessor::Attach(elements::GuiColorizedTextElement* element, SpinLock& elementModifyLock, compositions::GuiGraphicsComposition* _ownerComposition, vuint editVersion) - { - ownerComposition=_ownerComposition; - } - - void GuiTextBoxUndoRedoProcessor::Detach() - { - ClearUndoRedo(); - } - - void GuiTextBoxUndoRedoProcessor::TextEditPreview(TextEditPreviewStruct& arguments) - { - } - - void GuiTextBoxUndoRedoProcessor::TextEditNotify(const TextEditNotifyStruct& arguments) - { - Ptr step=new EditStep; - step->processor=this; - step->arguments=arguments; - PushStep(step); - } - - void GuiTextBoxUndoRedoProcessor::TextCaretChanged(const TextCaretChangedStruct& arguments) - { - } - - void GuiTextBoxUndoRedoProcessor::TextEditFinished(vuint editVersion) - { - } - -/*********************************************************************** -GuiDocumentUndoRedoProcessor::ReplaceModelStep -***********************************************************************/ - - void GuiDocumentUndoRedoProcessor::ReplaceModelStep::Undo() - { - GuiDocumentCommonInterface* ci=dynamic_cast(processor->ownerComposition->GetRelatedControl()); - if(ci) - { - ci->EditRun(arguments.inputStart, arguments.inputEnd, arguments.originalModel, true); - ci->SetCaret(arguments.originalStart, arguments.originalEnd); - } - } - - void GuiDocumentUndoRedoProcessor::ReplaceModelStep::Redo() - { - GuiDocumentCommonInterface* ci=dynamic_cast(processor->ownerComposition->GetRelatedControl()); - if(ci) - { - ci->EditRun(arguments.originalStart, arguments.originalEnd, arguments.inputModel, true); - ci->SetCaret(arguments.inputStart, arguments.inputEnd); - } - } - -/*********************************************************************** -GuiDocumentUndoRedoProcessor::RenameStyleStep -***********************************************************************/ - - void GuiDocumentUndoRedoProcessor::RenameStyleStep::Undo() - { - GuiDocumentCommonInterface* ci=dynamic_cast(processor->ownerComposition->GetRelatedControl()); - if(ci) - { - ci->RenameStyle(arguments.newStyleName, arguments.oldStyleName); - } - } - - void GuiDocumentUndoRedoProcessor::RenameStyleStep::Redo() - { - GuiDocumentCommonInterface* ci=dynamic_cast(processor->ownerComposition->GetRelatedControl()); - if(ci) - { - ci->RenameStyle(arguments.oldStyleName, arguments.newStyleName); - } - } - -/*********************************************************************** -GuiDocumentUndoRedoProcessor::SetAlignmentStep -***********************************************************************/ - - void GuiDocumentUndoRedoProcessor::SetAlignmentStep::Undo() - { - GuiDocumentCommonInterface* ci=dynamic_cast(processor->ownerComposition->GetRelatedControl()); - if(ci) - { - ci->SetParagraphAlignments(TextPos(arguments->start, 0), TextPos(arguments->end, 0), arguments->originalAlignments); - } - } - - void GuiDocumentUndoRedoProcessor::SetAlignmentStep::Redo() - { - GuiDocumentCommonInterface* ci=dynamic_cast(processor->ownerComposition->GetRelatedControl()); - if(ci) - { - ci->SetParagraphAlignments(TextPos(arguments->start, 0), TextPos(arguments->end, 0), arguments->inputAlignments); - } - } - -/*********************************************************************** -GuiDocumentUndoRedoProcessor -***********************************************************************/ - - GuiDocumentUndoRedoProcessor::GuiDocumentUndoRedoProcessor() - :element(0) - ,ownerComposition(0) - { - } - - GuiDocumentUndoRedoProcessor::~GuiDocumentUndoRedoProcessor() - { - } - - void GuiDocumentUndoRedoProcessor::Setup(elements::GuiDocumentElement* _element, compositions::GuiGraphicsComposition* _ownerComposition) - { - element=_element; - ownerComposition=_ownerComposition; - } - - void GuiDocumentUndoRedoProcessor::OnReplaceModel(const ReplaceModelStruct& arguments) - { - Ptr step=new ReplaceModelStep; - step->processor=this; - step->arguments=arguments; - PushStep(step); - } - - void GuiDocumentUndoRedoProcessor::OnRenameStyle(const RenameStyleStruct& arguments) - { - Ptr step=new RenameStyleStep; - step->processor=this; - step->arguments=arguments; - PushStep(step); - } - - void GuiDocumentUndoRedoProcessor::OnSetAlignment(Ptr arguments) - { - Ptr step=new SetAlignmentStep; - step->processor=this; - step->arguments=arguments; - PushStep(step); - } - } - } -} - -/*********************************************************************** -CONTROLS\TEXTEDITORPACKAGE\LANGUAGESERVICE\GUILANGUAGEAUTOCOMPLETE.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace controls - { - using namespace elements; - using namespace regex; - using namespace parsing; - using namespace parsing::tabling; - using namespace collections; - -/*********************************************************************** -GuiGrammarAutoComplete -***********************************************************************/ - - void GuiGrammarAutoComplete::Attach(elements::GuiColorizedTextElement* _element, SpinLock& _elementModifyLock, compositions::GuiGraphicsComposition* _ownerComposition, vuint editVersion) - { - GuiTextBoxAutoCompleteBase::Attach(_element, _elementModifyLock, _ownerComposition, editVersion); - RepeatingParsingExecutor::CallbackBase::Attach(_element, _elementModifyLock, _ownerComposition, editVersion); - } - - void GuiGrammarAutoComplete::Detach() - { - GuiTextBoxAutoCompleteBase::Detach(); - RepeatingParsingExecutor::CallbackBase::Detach(); - if(element && elementModifyLock) - { - EnsureAutoCompleteFinished(); - } - } - - void GuiGrammarAutoComplete::TextEditPreview(TextEditPreviewStruct& arguments) - { - GuiTextBoxAutoCompleteBase::TextEditPreview(arguments); - RepeatingParsingExecutor::CallbackBase::TextEditPreview(arguments); - - if(element && elementModifyLock) - { - if(IsListOpening() && arguments.keyInput && arguments.originalText==L"" && arguments.inputText!=L"") - { - WString selectedItem=GetSelectedListItem(); - if(selectedItem!=L"") - { - TextPos begin=GetListStartPosition(); - TextPos end=arguments.originalStart; - WString editingText=element->GetLines().GetText(begin, end); - editingText+=arguments.inputText; - if(grammarParser->GetTable()->GetLexer().Walk().IsClosedToken(editingText)) - { - arguments.originalStart=begin; - arguments.inputText=selectedItem+arguments.inputText; - CloseList(); - } - } - } - } - } - - void GuiGrammarAutoComplete::TextEditNotify(const TextEditNotifyStruct& arguments) - { - GuiTextBoxAutoCompleteBase::TextEditNotify(arguments); - RepeatingParsingExecutor::CallbackBase::TextEditNotify(arguments); - if(element && elementModifyLock) - { - editing=true; - SPIN_LOCK(editTraceLock) - { - editTrace.Add(arguments); - } - } - } - - void GuiGrammarAutoComplete::TextCaretChanged(const TextCaretChangedStruct& arguments) - { - GuiTextBoxAutoCompleteBase::TextCaretChanged(arguments); - RepeatingParsingExecutor::CallbackBase::TextCaretChanged(arguments); - if(element && elementModifyLock) - { - SPIN_LOCK(editTraceLock) - { - // queue a fake TextEditNotifyStruct - // a fake struct can be detected by (trace.originalText==L"" && trace.inputText==L"") - TextEditNotifyStruct trace; - trace.editVersion=arguments.editVersion; - trace.originalStart=arguments.oldBegin; - trace.originalEnd=arguments.oldEnd; - trace.inputStart=arguments.newBegin; - trace.inputEnd=arguments.newEnd; - - // ensure trace.originalStart<=trace.originalEnd - if(trace.originalStart>trace.originalEnd) - { - TextPos temp=trace.originalStart; - trace.originalStart=trace.originalEnd; - trace.originalEnd=temp; - } - // ensure trace.inputStart<=trace.inputEnd - if(trace.inputStart>trace.inputEnd) - { - TextPos temp=trace.inputStart; - trace.inputStart=trace.inputEnd; - trace.inputEnd=temp; - } - editTrace.Add(trace); - } - - SPIN_LOCK(contextLock) - { - if(context.input.node) - { - if(editing) - { - // if the current caret changing is caused by editing - // submit a task with valid editVersion and invalid node and code - RepeatingParsingOutput input; - input.editVersion=context.input.editVersion; - SubmitTask(input); - } - else if(context.input.editVersion == arguments.editVersion) - { - // if the current caret changing is not caused by editing - // submit a task with the previous input - SubmitTask(context.input); - } - } - } - } - } - - void GuiGrammarAutoComplete::TextEditFinished(vuint editVersion) - { - GuiTextBoxAutoCompleteBase::TextEditFinished(editVersion); - RepeatingParsingExecutor::CallbackBase::TextEditFinished(editVersion); - if(element && elementModifyLock) - { - editing=false; - } - } - - void GuiGrammarAutoComplete::OnParsingFinishedAsync(const RepeatingParsingOutput& arguments) - { - if(element && elementModifyLock) - { - GetApplication()->InvokeInMainThread([=]() - { - // submit a task if the RepeatingParsingExecutor notices a new parsing result - SubmitTask(arguments); - }); - } - } - - void GuiGrammarAutoComplete::CollectLeftRecursiveRules() - { - leftRecursiveRules.Clear(); - Ptr parser=parsingExecutor->GetParser(); - Ptr table=parser->GetTable(); - vint stateCount=table->GetStateCount(); - vint tokenCount=table->GetTokenCount(); - for(vint i=0;i bag=table->GetTransitionBag(i, j); - if(bag) - { - FOREACH(Ptr, item, bag->transitionItems) - { - FOREACH(ParsingTable::Instruction, ins, item->instructions) - { - if(ins.instructionType==ParsingTable::Instruction::LeftRecursiveReduce) - { - if(!leftRecursiveRules.Contains(ins.creatorRule)) - { - leftRecursiveRules.Add(ins.creatorRule); - } - } - } - } - } - } - } - } - - vint GuiGrammarAutoComplete::UnsafeGetEditTraceIndex(vuint editVersion) - { - // get the index of the latest TextEditNotifyStruct of a specified edit version - // this function should be called inside SPIN_LOCK(editTraceLock) - // perform a binary search - vint start = 0; - vint end = editTrace.Count() - 1; - while (start <= end) - { - vint middle = (start + end) / 2; - TextEditNotifyStruct& trace = editTrace[middle]; - - if (editVersiontrace.editVersion) - { - start = middle + 1; - } - else - { - // if multiple TextEditNotifyStruct is found, choose the latest one - while (middle < editTrace.Count() - 1) - { - if (editTrace[middle + 1].editVersion == editTrace[middle].editVersion) - { - middle++; - } - else - { - break; - } - } - return middle; - } - } - return -1; - } - - TextPos GuiGrammarAutoComplete::ChooseCorrectTextPos(TextPos pos, const regex::RegexTokens& tokens) - { - Ptr table=grammarParser->GetTable(); - RegexToken lastToken; - lastToken.reading=0; - - FOREACH(RegexToken, token, tokens) - { - // we treat "class| Name" as editing the first token - if(TextPos(token.rowEnd, token.columnEnd+1)>=pos) - { - if(table->GetTableTokenIndex(token.token)!=-1 && lastToken.reading) - { - pos=TextPos(lastToken.rowStart, lastToken.columnStart); - } - break; - } - lastToken=token; - } - return pos; - } - - void GuiGrammarAutoComplete::ExecuteRefresh(AutoCompleteContext& newContext) - { - // process the input of a task is submitted not by text editing - // find the text selection by the edit version of the input - TextPos startPos, endPos; - { - SPIN_LOCK(editTraceLock) - { - vint traceIndex = UnsafeGetEditTraceIndex(newContext.input.editVersion); - if (traceIndex == -1) return; - - TextEditNotifyStruct& trace = editTrace[traceIndex]; - startPos = trace.inputStart; - endPos = trace.inputEnd; - } - - const RegexLexer& lexer = grammarParser->GetTable()->GetLexer(); - RegexTokens tokens = lexer.Parse(newContext.input.code); - startPos = ChooseCorrectTextPos(startPos, tokens); - } - - // locate the deepest node using the text selection - ParsingTextPos start(startPos.row, startPos.column); - ParsingTextPos end(endPos.row, endPos.column); - ParsingTextRange range(start, end); - ParsingTreeNode* found = newContext.input.node->FindDeepestNode(range); - ParsingTreeObject* selectedNode = 0; - - // if the location failed, choose the root node - if (!found || startPos == TextPos(0, 0)) - { - found = newContext.input.node.Obj(); - } - - if (!selectedNode) - { - // from the deepest node, traverse towards the root node - // find the deepest node whose created rule is a left recursive rule and whose parent is not - ParsingTreeObject* lrec = 0; - ParsingTreeNode* current = found; - while (current) - { - ParsingTreeObject* obj = dynamic_cast(current); - if (obj) - { - FOREACH(WString, rule, obj->GetCreatorRules()) - { - if (leftRecursiveRules.Contains(rule)) - { - lrec = obj; - break; - } - } - if (obj && lrec && lrec != obj) - { - selectedNode = lrec; - break; - } - } - current = current->GetParent(); - } - } - - if (!selectedNode) - { - // if there is no left recursive rule that creates the deepest node and all indirect parents - // choose the deepest ParsingTreeObject - ParsingTreeNode* current = found; - while (current) - { - ParsingTreeObject* obj = dynamic_cast(current); - if (obj) - { - selectedNode = obj; - break; - } - current = current->GetParent(); - } - } - - if (selectedNode) - { - // get the code range of the selected node - start = selectedNode->GetCodeRange().start; - end = selectedNode->GetCodeRange().end; - - // get all properties from the selected node - newContext.rule = selectedNode->GetCreatorRules()[selectedNode->GetCreatorRules().Count() - 1]; - newContext.originalRange = selectedNode->GetCodeRange(); - newContext.originalNode = dynamic_cast(selectedNode); - newContext.modifiedNode = newContext.originalNode; - newContext.modifiedEditVersion = newContext.input.editVersion; - - // get the corresponding code of the selected node - if (start.index >= 0 && end.index >= 0) - { - newContext.modifiedCode = newContext.input.code.Sub(start.index, end.index - start.index + 1).Buffer(); - } - } - } - - bool GuiGrammarAutoComplete::NormalizeTextPos(AutoCompleteContext& newContext, elements::text::TextLines& lines, TextPos& pos) - { - // get the start position - TextPos start(newContext.originalRange.start.row, newContext.originalRange.start.column); - - // get the end position of the end of lines - TextPos end - = lines.GetCount() <= 1 - ? TextPos(start.row, start.column + lines.GetLine(0).dataLength) - : TextPos(start.row + lines.GetCount() - 1, lines.GetLine(lines.GetCount() - 1).dataLength) - ; - - if (start <= pos && pos <= end) - { - // if the pos is inside the range - // normalize the pos to a new coordinate that the beginning position of lines is (row=0, column=0) - pos.row -= start.row; - if (pos.row == 0) - { - pos.column -= start.column; - } - return true; - } - else - { - return false; - } - } - - void GuiGrammarAutoComplete::ExecuteEdit(AutoCompleteContext& newContext) - { - // process the input of a task that is submitted by text editing - // this function make an approximiation to the context if the RepeatingParsingExecutor is not fast enough - // copy all TextEditNotifyStruct that is caused by a text editing before (and including) the edit version of the input - List usedTrace; - { - SPIN_LOCK(editTraceLock) - { - CopyFrom( - usedTrace, - From(editTrace) - .Where([&newContext](const TextEditNotifyStruct& value) - { - return (value.originalText != L"" || value.inputText != L"") && value.editVersion > newContext.modifiedEditVersion; - }) - ); - } - } - - // apply all modification to get the new modifiedCode - bool failed = false; - if (usedTrace.Count() > 0) - { - if (usedTrace[0].editVersion != newContext.modifiedEditVersion + 1) - { - // failed if any TextEditNotifyStruct is missing - failed = true; - } - else - { - // initialize a TextLines with the latest modifiedCode - text::TextLines lines(nullptr); - lines.SetText(newContext.modifiedCode); - FOREACH(TextEditNotifyStruct, trace, usedTrace) - { - // apply a modification to lines - TextPos start = trace.originalStart; - TextPos end = trace.originalEnd; - - // only if the modification is meaningful - if (NormalizeTextPos(newContext, lines, start) && NormalizeTextPos(newContext, lines, end)) - { - lines.Modify(start, end, trace.inputText); - } - else - { - // otherwise, failed - failed = true; - break; - } - } - - if (!failed) - { - newContext.modifiedCode = lines.GetText(); - } - } - } - - if (failed) - { - // clear originalNode to notify that the current context goes wrong - newContext.originalNode = 0; - } - - if (usedTrace.Count() > 0) - { - // update the edit version - newContext.modifiedEditVersion = usedTrace[usedTrace.Count() - 1].editVersion; - } - } - - void GuiGrammarAutoComplete::DeleteFutures(collections::List& futures) - { - // delete all futures and clear the list - FOREACH(ParsingState::Future*, future, futures) - { - delete future; - } - futures.Clear(); - } - - regex::RegexToken* GuiGrammarAutoComplete::TraverseTransitions( - parsing::tabling::ParsingState& state, - parsing::tabling::ParsingTransitionCollector& transitionCollector, - TextPos stopPosition, - collections::List& nonRecoveryFutures, - collections::List& recoveryFutures - ) - { - const List& transitions = transitionCollector.GetTransitions(); - for (vint index = 0; index < transitions.Count(); index++) - { - const ParsingState::TransitionResult& transition = transitions[index]; - switch (transition.transitionType) - { - case ParsingState::TransitionResult::AmbiguityBegin: - break; - case ParsingState::TransitionResult::AmbiguityBranch: - // ambiguity branches are not nested - // tokens in different braches are the same - // so we only need to run one branch, and skip the others - index = transitionCollector.GetAmbiguityEndFromBegin(transitionCollector.GetAmbiguityBeginFromBranch(index)); - break; - case ParsingState::TransitionResult::AmbiguityEnd: - break; - case ParsingState::TransitionResult::ExecuteInstructions: - { - // test does the token reach the stop position - if (transition.token) - { - // we treat "A|B" as editing A if token A is endless, otherwise treated as editing B - TextPos tokenEnd(transition.token->rowEnd, transition.token->columnEnd + 1); - - // if the caret is not at the end of the token - if (tokenEnd > stopPosition) - { - // stop the traversing and return the editing token - return transition.token; - } - else if (tokenEnd == stopPosition) - { - // if the caret is at the end of the token, and it is a closed token - // e.g. identifier is not a closed token, string is a closed token - if (!grammarParser->GetTable()->GetLexer().Walk().IsClosedToken(transition.token->reading, transition.token->length)) - { - // stop the traversing and return the editing token - return transition.token; - } - } - } - - // traverse the PDA using the token specified in the current transition - vint tableTokenIndex = transition.tableTokenIndex; - List possibilities; - if (recoveryFutures.Count() > 0) - { - FOREACH(ParsingState::Future*, future, recoveryFutures) - { - state.Explore(tableTokenIndex, future, possibilities); - } - } - else - { - FOREACH(ParsingState::Future*, future, nonRecoveryFutures) - { - state.Explore(tableTokenIndex, future, possibilities); - } - } - - // delete duplicated futures - List selectedPossibilities; - for (vint i = 0; i < possibilities.Count(); i++) - { - ParsingState::Future* candidateFuture = possibilities[i]; - bool duplicated = false; - FOREACH(ParsingState::Future*, future, selectedPossibilities) - { - if ( - candidateFuture->currentState == future->currentState && - candidateFuture->reduceStateCount == future->reduceStateCount && - candidateFuture->shiftStates.Count() == future->shiftStates.Count() - ) - { - bool same = true; - for (vint j = 0; j < future->shiftStates.Count(); j++) - { - if (candidateFuture->shiftStates[i] != future->shiftStates[i]) - { - same = false; - break; - } - } - - if ((duplicated = same)) - { - break; - } - } - } - - if (duplicated) - { - delete candidateFuture; - } - else - { - selectedPossibilities.Add(candidateFuture); - } - } - - // step forward - if (transition.token || transition.tableTokenIndex == ParsingTable::TokenBegin) - { - DeleteFutures(nonRecoveryFutures); - DeleteFutures(recoveryFutures); - CopyFrom(nonRecoveryFutures, selectedPossibilities); - } - else - { - DeleteFutures(recoveryFutures); - CopyFrom(recoveryFutures, selectedPossibilities); - } - } - break; - default:; - } - } - return 0; - } - - regex::RegexToken* GuiGrammarAutoComplete::SearchValidInputToken( - parsing::tabling::ParsingState& state, - parsing::tabling::ParsingTransitionCollector& transitionCollector, - TextPos stopPosition, - AutoCompleteContext& newContext, - collections::SortedList& tableTokenIndices - ) - { - // initialize the PDA state - state.Reset(newContext.rule); - List nonRecoveryFutures, recoveryFutures; - nonRecoveryFutures.Add(state.ExploreCreateRootFuture()); - - // traverse the PDA until it reach the stop position - // nonRecoveryFutures store the state when the last token (existing) is reached - // recoveryFutures store the state when the last token (inserted by error recovery) is reached - RegexToken* token = TraverseTransitions(state, transitionCollector, stopPosition, nonRecoveryFutures, recoveryFutures); - - // explore all possibilities from the last token before the stop position - List possibilities; - for (vint i = 0; i < nonRecoveryFutures.Count(); i++) - { - state.Explore(ParsingTable::NormalReduce, nonRecoveryFutures[i], nonRecoveryFutures); - state.Explore(ParsingTable::LeftRecursiveReduce, nonRecoveryFutures[i], nonRecoveryFutures); - } - FOREACH(ParsingState::Future*, future, nonRecoveryFutures) - { - vint count = state.GetTable()->GetTokenCount(); - for (vint i = ParsingTable::UserTokenStart; i < count; i++) - { - state.Explore(i, future, possibilities); - } - } - - // get all possible tokens that marked using @AutoCompleteCandidate - FOREACH(ParsingState::Future*, future, possibilities) - { - if (!tableTokenIndices.Contains(future->selectedToken)) - { - tableTokenIndices.Add(future->selectedToken); - } - } - - // release all data - DeleteFutures(possibilities); - DeleteFutures(nonRecoveryFutures); - DeleteFutures(recoveryFutures); - - // return the editing token - return token; - } - - TextPos GuiGrammarAutoComplete::GlobalTextPosToModifiedTextPos(AutoCompleteContext& newContext, TextPos pos) - { - pos.row-=newContext.originalRange.start.row; - if(pos.row==0) - { - pos.column-=newContext.originalRange.start.column; - } - return pos; - } - - TextPos GuiGrammarAutoComplete::ModifiedTextPosToGlobalTextPos(AutoCompleteContext& newContext, TextPos pos) - { - if(pos.row==0) - { - pos.column+=newContext.originalRange.start.column; - } - pos.row+=newContext.originalRange.start.row; - return pos; - } - - void GuiGrammarAutoComplete::ExecuteCalculateList(AutoCompleteContext& newContext) - { - // calcuate the content of the auto complete list - // it is sad that, because the parser's algorithm is too complex - // we need to reparse and track the internal state of the PDA(push-down automaton) here. - // initialize the PDA - ParsingState state(newContext.modifiedCode, grammarParser->GetTable()); - state.Reset(newContext.rule); - - // prepare to get all transitions - ParsingTransitionCollector collector; - List> errors; - - // reparse and get all transitions during parsing - if (grammarParser->Parse(state, collector, errors)) - { - // if modifiedNode is not prepared (the task is submitted because of text editing) - // use the transition to build the syntax tree - if (!newContext.modifiedNode) - { - ParsingTreeBuilder builder; - builder.Reset(); - bool succeeded = true; - FOREACH(ParsingState::TransitionResult, transition, collector.GetTransitions()) - { - if (!(succeeded = builder.Run(transition))) - { - break; - } - } - - if (succeeded) - { - Ptr parsedNode = builder.GetNode(); - newContext.modifiedNode = parsedNode.Cast(); - newContext.modifiedNode->InitializeQueryCache(); - } - } - - if (newContext.modifiedNode) - { - // get the latest text editing trace - TextEditNotifyStruct trace; - SPIN_LOCK(editTraceLock) - { - vint index = UnsafeGetEditTraceIndex(newContext.modifiedEditVersion); - if (index == -1) - { - return; - } - else - { - trace = editTrace[index]; - } - } - - // calculate the stop position for PDA traversing - TextPos stopPosition = GlobalTextPosToModifiedTextPos(newContext, trace.inputStart); - - // find all possible token before the current caret using the PDA - Ptr autoComplete = new AutoCompleteData; - SortedList tableTokenIndices; - RegexToken* editingToken = SearchValidInputToken(state, collector, stopPosition, newContext, tableTokenIndices); - - // collect all auto complete types - { - // collect all keywords that can be put into the auto complete list - FOREACH(vint, token, tableTokenIndices) - { - vint regexToken = token - ParsingTable::UserTokenStart; - if (regexToken >= 0) - { - autoComplete->candidates.Add(regexToken); - if (parsingExecutor->GetTokenMetaData(regexToken).isCandidate) - { - autoComplete->shownCandidates.Add(regexToken); - } - } - } - - // calculate the arranged stopPosition - if (editingToken) - { - TextPos tokenPos(editingToken->rowStart, editingToken->columnStart); - if (tokenPos < stopPosition) - { - stopPosition = tokenPos; - } - } - - // calculate the start/end position for PDA traversing - TextPos startPos, endPos; - { - startPos = ModifiedTextPosToGlobalTextPos(newContext, stopPosition); - autoComplete->startPosition = startPos; - endPos = trace.inputEnd; - if (newContext.modifiedNode != newContext.originalNode) - { - startPos = GlobalTextPosToModifiedTextPos(newContext, startPos); - endPos = GlobalTextPosToModifiedTextPos(newContext, endPos); - } - if (startPos0) - { - endPos.column--; - } - } - - // calculate the auto complete type - if (editingToken && parsingExecutor->GetTokenMetaData(editingToken->token).hasAutoComplete) - { - ParsingTextRange range(ParsingTextPos(startPos.row, startPos.column), ParsingTextPos(endPos.row, endPos.column)); - AutoCompleteData::RetriveContext(*autoComplete.Obj(), range, newContext.modifiedNode.Obj(), parsingExecutor.Obj()); - } - } - newContext.autoComplete = autoComplete; - } - } - } - - void GuiGrammarAutoComplete::Execute(const RepeatingParsingOutput& input) - { - SPIN_LOCK(contextLock) - { - if(input.editVersionInvokeInMainThread([=]() - { - PostList(newContext, byGlobalCorrection); - }); - } - } - - void GuiGrammarAutoComplete::PostList(const AutoCompleteContext& newContext, bool byGlobalCorrection) - { - bool openList = true; // true: make the list visible - bool keepListState = false; // true: don't change the list visibility - Ptr autoComplete = newContext.autoComplete; - - // if failed to get the auto complete list, close - if (!autoComplete) - { - openList = false; - } - if (openList) - { - if (autoComplete->shownCandidates.Count() + autoComplete->candidateItems.Count() == 0) - { - openList = false; - } - } - - TextPos startPosition, endPosition; - WString editingText; - if (openList) - { - SPIN_LOCK(editTraceLock) - { - // if the edit version is invalid, cancel - vint traceIndex = UnsafeGetEditTraceIndex(newContext.modifiedEditVersion); - if (traceIndex == -1) - { - return; - } - // an edit version has two trace at most, for text change and caret change, here we peak the text change - if (traceIndex > 0 && editTrace[traceIndex - 1].editVersion == context.modifiedEditVersion) - { - traceIndex--; - } - // if the edit version is not created by keyboard input, close - if (traceIndex >= 0) - { - TextEditNotifyStruct& trace = editTrace[traceIndex]; - if (!trace.keyInput) - { - openList = false; - } - } - - // scan all traces from the calculation's edit version until now - if (openList) - { - keepListState = true; - startPosition = autoComplete->startPosition; - endPosition = editTrace[editTrace.Count() - 1].inputEnd; - for (vint i = traceIndex; i < editTrace.Count(); i++) - { - TextEditNotifyStruct& trace = editTrace[i]; - // if there are no text change trace until now, don't change the list - if (trace.originalText != L"" || trace.inputText != L"") - { - keepListState = false; - } - // if the edit position goes before the start position of the auto complete, refresh - if (trace.inputEnd <= startPosition) - { - openList = false; - break; - } - } - } - - if (traceIndex > 0) - { - editTrace.RemoveRange(0, traceIndex); - } - } - } - - // if there is a global correction send to the UI thread but the list is not opening, cancel - if (byGlobalCorrection && !IsListOpening()) - { - return; - } - - // if the input text from the start position to the current position crosses a token, close - if (openList && element) - { - editingText = element->GetLines().GetText(startPosition, endPosition); - if (grammarParser->GetTable()->GetLexer().Walk().IsClosedToken(editingText)) - { - openList = false; - } - } - - // calculate the content of the list - if (autoComplete && ((!keepListState && openList) || IsListOpening())) - { - SortedList itemKeys; - List itemValues; - - // copy all candidate keywords - FOREACH(vint, token, autoComplete->shownCandidates) - { - WString literal = parsingExecutor->GetTokenMetaData(token).unescapedRegexText; - if (literal != L"" && !itemKeys.Contains(literal)) - { - ParsingCandidateItem item; - item.name = literal; - item.semanticId = -1; - itemValues.Insert(itemKeys.Add(literal), item); - } - } - - // copy all candidate symbols - if (autoComplete->acceptableSemanticIds) - { - FOREACH(ParsingCandidateItem, item, autoComplete->candidateItems) - { - if (autoComplete->acceptableSemanticIds->Contains(item.semanticId)) - { - // add all acceptable display of a symbol - // because a symbol can has multiple representation in different places - if (item.name != L"" && !itemKeys.Contains(item.name)) - { - itemValues.Insert(itemKeys.Add(item.name), item); - } - } - } - } - - // fill the list - List candidateItems; - for (vint i = 0; i < itemValues.Count(); i++) - { - auto& item = itemValues[i]; - if (item.tag.IsNull()) - { - if (auto analyzer = parsingExecutor->GetAnalyzer()) - { - item.tag = analyzer->CreateTagForCandidateItem(item); - } - } - - GuiTextBoxAutoCompleteBase::AutoCompleteItem candidateItem; - candidateItem.text = item.name; - candidateItem.tag = item.tag; - candidateItems.Add(candidateItem); - } - SetListContent(candidateItems); - } - - // set the list state - if (!keepListState) - { - if (openList) - { - OpenList(startPosition); - } - else - { - CloseList(); - } - } - - if (IsListOpening()) - { - HighlightList(editingText); - } - } - - void GuiGrammarAutoComplete::Initialize() - { - grammarParser=CreateAutoRecoverParser(parsingExecutor->GetParser()->GetTable()); - CollectLeftRecursiveRules(); - parsingExecutor->AttachCallback(this); - } - - void GuiGrammarAutoComplete::OnContextFinishedAsync(AutoCompleteContext& context) - { - if (auto analyzer = parsingExecutor->GetAnalyzer()) - { - if (context.autoComplete && context.autoComplete->acceptableSemanticIds) - { - analyzer->GetCandidateItemsAsync(*context.autoComplete.Obj(), context, context.autoComplete->candidateItems); - } - } - } - - void GuiGrammarAutoComplete::EnsureAutoCompleteFinished() - { - parsingExecutor->EnsureTaskFinished(); - SPIN_LOCK(contextLock) - { - context = AutoCompleteContext(); - } - } - - GuiGrammarAutoComplete::GuiGrammarAutoComplete(Ptr _parsingExecutor) - :RepeatingParsingExecutor::CallbackBase(_parsingExecutor) - ,editing(false) - { - Initialize(); - } - - GuiGrammarAutoComplete::GuiGrammarAutoComplete(Ptr _grammarParser, const WString& _grammarRule) - :RepeatingParsingExecutor::CallbackBase(new RepeatingParsingExecutor(_grammarParser, _grammarRule)) - ,editing(false) - { - Initialize(); - } - - GuiGrammarAutoComplete::~GuiGrammarAutoComplete() - { - EnsureAutoCompleteFinished(); - parsingExecutor->DetachCallback(this); - } - - Ptr GuiGrammarAutoComplete::GetParsingExecutor() - { - return parsingExecutor; - } - } - } -} - -/*********************************************************************** -CONTROLS\TEXTEDITORPACKAGE\LANGUAGESERVICE\GUILANGUAGECOLORIZER.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace controls - { - using namespace elements; - using namespace parsing; - using namespace parsing::tabling; - using namespace collections; - using namespace theme; - -/*********************************************************************** -GuiGrammarColorizer -***********************************************************************/ - - void GuiGrammarColorizer::OnParsingFinishedAsync(const RepeatingParsingOutput& output) - { - SPIN_LOCK(contextLock) - { - context=output; - OnContextFinishedAsync(context); - } - RestartColorizer(); - } - - void GuiGrammarColorizer::OnContextFinishedAsync(const RepeatingParsingOutput& context) - { - } - - void GuiGrammarColorizer::Attach(elements::GuiColorizedTextElement* _element, SpinLock& _elementModifyLock, compositions::GuiGraphicsComposition* _ownerComposition, vuint editVersion) - { - GuiTextBoxRegexColorizer::Attach(_element, _elementModifyLock, _ownerComposition, editVersion); - RepeatingParsingExecutor::CallbackBase::Attach(_element, _elementModifyLock, _ownerComposition, editVersion); - } - - void GuiGrammarColorizer::Detach() - { - GuiTextBoxRegexColorizer::Detach(); - RepeatingParsingExecutor::CallbackBase::Detach(); - if(element && elementModifyLock) - { - parsingExecutor->EnsureTaskFinished(); - StopColorizer(false); - } - } - - void GuiGrammarColorizer::TextEditPreview(TextEditPreviewStruct& arguments) - { - GuiTextBoxRegexColorizer::TextEditPreview(arguments); - RepeatingParsingExecutor::CallbackBase::TextEditPreview(arguments); - } - - void GuiGrammarColorizer::TextEditNotify(const TextEditNotifyStruct& arguments) - { - GuiTextBoxRegexColorizer::TextEditNotify(arguments); - RepeatingParsingExecutor::CallbackBase::TextEditNotify(arguments); - } - - void GuiGrammarColorizer::TextCaretChanged(const TextCaretChangedStruct& arguments) - { - GuiTextBoxRegexColorizer::TextCaretChanged(arguments); - RepeatingParsingExecutor::CallbackBase::TextCaretChanged(arguments); - } - - void GuiGrammarColorizer::TextEditFinished(vuint editVersion) - { - GuiTextBoxRegexColorizer::TextEditFinished(editVersion); - RepeatingParsingExecutor::CallbackBase::TextEditFinished(editVersion); - } - - void GuiGrammarColorizer::OnSemanticColorize(SemanticColorizeContext& context, const RepeatingParsingOutput& input) - { - if (auto analyzer = parsingExecutor->GetAnalyzer()) - { - auto semanticId = analyzer->GetSemanticIdForTokenAsync(context, input); - if(semanticId!=-1) - { - context.semanticId=semanticId; - } - } - } - - void GuiGrammarColorizer::EnsureColorizerFinished() - { - parsingExecutor->EnsureTaskFinished(); - StopColorizerForever(); - SPIN_LOCK(contextLock) - { - context=RepeatingParsingOutput(); - } - } - - GuiGrammarColorizer::GuiGrammarColorizer(Ptr _parsingExecutor) - :RepeatingParsingExecutor::CallbackBase(_parsingExecutor) - { - parsingExecutor->AttachCallback(this); - BeginSetColors(); - } - - GuiGrammarColorizer::GuiGrammarColorizer(Ptr _grammarParser, const WString& _grammarRule) - :RepeatingParsingExecutor::CallbackBase(new RepeatingParsingExecutor(_grammarParser, _grammarRule)) - { - parsingExecutor->AttachCallback(this); - BeginSetColors(); - } - - GuiGrammarColorizer::~GuiGrammarColorizer() - { - EnsureColorizerFinished(); - parsingExecutor->DetachCallback(this); - } - - void GuiGrammarColorizer::BeginSetColors() - { - ClearTokens(); - colorSettings.Clear(); - text::ColorEntry entry=GetCurrentTheme()->GetDefaultTextBoxColorEntry(); - SetDefaultColor(entry); - colorSettings.Add(L"Default", entry); - } - - const collections::SortedList& GuiGrammarColorizer::GetColorNames() - { - return colorSettings.Keys(); - } - - GuiGrammarColorizer::ColorEntry GuiGrammarColorizer::GetColor(const WString& name) - { - vint index=colorSettings.Keys().IndexOf(name); - return index==-1?GetDefaultColor():colorSettings.Values().Get(index); - } - - void GuiGrammarColorizer::SetColor(const WString& name, const ColorEntry& entry) - { - colorSettings.Set(name, entry); - } - - void GuiGrammarColorizer::SetColor(const WString& name, const Color& color) - { - text::ColorEntry entry=GetDefaultColor(); - entry.normal.text=color; - SetColor(name, entry); - } - - void GuiGrammarColorizer::EndSetColors() - { - SortedList tokenColors; - Ptr table=parsingExecutor->GetParser()->GetTable(); - semanticColorMap.Clear(); - - vint tokenCount=table->GetTokenCount(); - for(vint token=ParsingTable::UserTokenStart;tokenGetTokenInfo(token); - const RepeatingParsingExecutor::TokenMetaData& md=parsingExecutor->GetTokenMetaData(token-ParsingTable::UserTokenStart); - if(md.defaultColorIndex==-1) - { - AddToken(tokenInfo.regex, GetDefaultColor()); - } - else - { - WString name=parsingExecutor->GetSemanticName(md.defaultColorIndex); - vint color=AddToken(tokenInfo.regex, GetColor(name)); - semanticColorMap.Set(md.defaultColorIndex, color); - tokenColors.Add(name); - } - } - - FOREACH_INDEXER(WString, color, index, colorSettings.Keys()) - { - if(!tokenColors.Contains(color)) - { - vint semanticId=parsingExecutor->GetSemanticId(color); - if(semanticId!=-1) - { - vint tokenId=AddExtraToken(colorSettings.Values().Get(index)); - vint color=tokenId+tokenCount-ParsingTable::UserTokenStart; - semanticColorMap.Set(semanticId, color); - } - } - } - Setup(); - } - - void GuiGrammarColorizer::ColorizeTokenContextSensitive(vint lineIndex, const wchar_t* text, vint start, vint length, vint& token, vint& contextState) - { - SPIN_LOCK(contextLock) - { - ParsingTreeObject* node=context.node.Obj(); - if(node && token!=-1 && parsingExecutor->GetTokenMetaData(token).hasContextColor) - { - ParsingTextPos pos(lineIndex, start); - SemanticColorizeContext scContext; - if(SemanticColorizeContext::RetriveContext(scContext, pos, node, parsingExecutor.Obj())) - { - const RepeatingParsingExecutor::FieldMetaData& md=parsingExecutor->GetFieldMetaData(scContext.type, scContext.field); - vint semantic=md.colorIndex; - scContext.semanticId=-1; - - if(scContext.acceptableSemanticIds) - { - OnSemanticColorize(scContext, context); - if(md.semantics->Contains(scContext.semanticId)) - { - semantic=scContext.semanticId; - } - } - - if(semantic!=-1) - { - vint index=semanticColorMap.Keys().IndexOf(semantic); - if(index!=-1) - { - token=semanticColorMap.Values()[index]; - } - } - } - } - } - } - - Ptr GuiGrammarColorizer::GetParsingExecutor() - { - return parsingExecutor; - } - } - } -} - -/*********************************************************************** -CONTROLS\TEXTEDITORPACKAGE\LANGUAGESERVICE\GUILANGUAGEOPERATIONS.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace controls - { - using namespace collections; - using namespace parsing; - using namespace parsing::tabling; - using namespace regex_internal; - -/*********************************************************************** -ParsingContext -***********************************************************************/ - - bool ParsingTokenContext::RetriveContext(ParsingTokenContext& output, parsing::ParsingTreeNode* foundNode, RepeatingParsingExecutor* executor) - { - ParsingTreeToken* foundToken=dynamic_cast(foundNode); - if(!foundToken) return false; - ParsingTreeObject* tokenParent=dynamic_cast(foundNode->GetParent()); - if(!tokenParent) return false; - vint index=tokenParent->GetMembers().Values().IndexOf(foundNode); - if(index==-1) return false; - - WString type=tokenParent->GetType(); - WString field=tokenParent->GetMembers().Keys().Get(index); - const RepeatingParsingExecutor::FieldMetaData& md=executor->GetFieldMetaData(type, field); - - output.foundToken=foundToken; - output.tokenParent=tokenParent; - output.type=type; - output.field=field; - output.acceptableSemanticIds=md.semantics; - return true; - } - - bool ParsingTokenContext::RetriveContext(ParsingTokenContext& output, parsing::ParsingTextPos pos, parsing::ParsingTreeObject* rootNode, RepeatingParsingExecutor* executor) - { - ParsingTreeNode* foundNode=rootNode->FindDeepestNode(pos); - if(!foundNode) return false; - return RetriveContext(output, foundNode, executor); - } - - bool ParsingTokenContext::RetriveContext(ParsingTokenContext& output, parsing::ParsingTextRange range, ParsingTreeObject* rootNode, RepeatingParsingExecutor* executor) - { - ParsingTreeNode* foundNode=rootNode->FindDeepestNode(range); - if(!foundNode) return false; - return RetriveContext(output, foundNode, executor); - } - -/*********************************************************************** -RepeatingParsingExecutor::IParsingAnalyzer -***********************************************************************/ - - parsing::ParsingTreeNode* RepeatingParsingExecutor::IParsingAnalyzer::ToParent(parsing::ParsingTreeNode* node, const RepeatingPartialParsingOutput* output) - { - if (!output || !output->modifiedNode) return node; - return node == output->modifiedNode.Obj() - ? output->originalNode.Obj() - : node; - } - - parsing::ParsingTreeObject* RepeatingParsingExecutor::IParsingAnalyzer::ToChild(parsing::ParsingTreeObject* node, const RepeatingPartialParsingOutput* output) - { - if (!output || !output->modifiedNode) return node; - return node == output->originalNode.Obj() - ? output->modifiedNode.Obj() - : node; - } - - Ptr RepeatingParsingExecutor::IParsingAnalyzer::ToChild(Ptr node, const RepeatingPartialParsingOutput* output) - { - if (!output) return node; - return node == output->originalNode - ? output->modifiedNode.Cast() - : node; - } - - parsing::ParsingTreeNode* RepeatingParsingExecutor::IParsingAnalyzer::GetParent(parsing::ParsingTreeNode* node, const RepeatingPartialParsingOutput* output) - { - return ToParent(node, output)->GetParent(); - } - - Ptr RepeatingParsingExecutor::IParsingAnalyzer::GetMember(parsing::ParsingTreeObject* node, const WString& name, const RepeatingPartialParsingOutput* output) - { - return ToChild(ToChild(node, output)->GetMember(name), output); - } - - Ptr RepeatingParsingExecutor::IParsingAnalyzer::GetItem(parsing::ParsingTreeArray* node, vint index, const RepeatingPartialParsingOutput* output) - { - return ToChild(node->GetItem(index), output); - } - -/*********************************************************************** -RepeatingParsingExecutor::CallbackBase -***********************************************************************/ - - RepeatingParsingExecutor::CallbackBase::CallbackBase(Ptr _parsingExecutor) - :parsingExecutor(_parsingExecutor) - ,callbackAutoPushing(false) - ,callbackElement(0) - ,callbackElementModifyLock(0) - { - } - - RepeatingParsingExecutor::CallbackBase::~CallbackBase() - { - } - - void RepeatingParsingExecutor::CallbackBase::RequireAutoSubmitTask(bool enabled) - { - callbackAutoPushing=enabled; - } - - void RepeatingParsingExecutor::CallbackBase::Attach(elements::GuiColorizedTextElement* _element, SpinLock& _elementModifyLock, compositions::GuiGraphicsComposition* _ownerComposition, vuint editVersion) - { - if(_element) - { - SPIN_LOCK(_elementModifyLock) - { - callbackElement=_element; - callbackElementModifyLock=&_elementModifyLock; - } - } - - parsingExecutor->ActivateCallback(this); - if(callbackElement && callbackElementModifyLock && callbackAutoPushing) - { - SPIN_LOCK(*callbackElementModifyLock) - { - RepeatingParsingInput input; - input.editVersion=editVersion; - input.code=callbackElement->GetLines().GetText(); - parsingExecutor->SubmitTask(input); - } - } - } - - void RepeatingParsingExecutor::CallbackBase::Detach() - { - if(callbackElement && callbackElementModifyLock) - { - SPIN_LOCK(*callbackElementModifyLock) - { - callbackElement=0; - callbackElementModifyLock=0; - } - } - - parsingExecutor->DeactivateCallback(this); - } - - void RepeatingParsingExecutor::CallbackBase::TextEditPreview(TextEditPreviewStruct& arguments) - { - } - - void RepeatingParsingExecutor::CallbackBase::TextEditNotify(const TextEditNotifyStruct& arguments) - { - } - - void RepeatingParsingExecutor::CallbackBase::TextCaretChanged(const TextCaretChangedStruct& arguments) - { - } - - void RepeatingParsingExecutor::CallbackBase::TextEditFinished(vuint editVersion) - { - if(callbackElement && callbackElementModifyLock && callbackAutoPushing) - { - SPIN_LOCK(*callbackElementModifyLock) - { - RepeatingParsingInput input; - input.editVersion=editVersion; - input.code=callbackElement->GetLines().GetText(); - parsingExecutor->SubmitTask(input); - } - } - } - -/*********************************************************************** -RepeatingParsingExecutor -***********************************************************************/ - - void RepeatingParsingExecutor::Execute(const RepeatingParsingInput& input) - { - List> errors; - Ptr node=grammarParser->Parse(input.code, grammarRule, errors).Cast(); - if(node) - { - node->InitializeQueryCache(); - } - - RepeatingParsingOutput result; - result.node=node; - result.editVersion=input.editVersion; - result.code=input.code; - if(node) - { - OnContextFinishedAsync(result); - FOREACH(ICallback*, callback, callbacks) - { - callback->OnParsingFinishedAsync(result); - } - } - } - - void RepeatingParsingExecutor::PrepareMetaData() - { - Ptr table=grammarParser->GetTable(); - tokenIndexMap.Clear(); - semanticIndexMap.Clear(); - tokenMetaDatas.Clear(); - fieldMetaDatas.Clear(); - - Dictionary> tokenColorAtts, tokenContextColorAtts, tokenCandidateAtts, tokenAutoCompleteAtts; - Dictionary> fieldColorAtts, fieldSemanticAtts; - - { - vint tokenCount=table->GetTokenCount(); - for(vint token=ParsingTable::UserTokenStart;tokenGetTokenInfo(token); - vint tokenIndex=token-ParsingTable::UserTokenStart; - tokenIndexMap.Add(tokenInfo.name, tokenIndex); - - if(Ptr att=GetColorAttribute(tokenInfo.attributeIndex)) - { - tokenColorAtts.Add(tokenIndex, att); - } - if(Ptr att=GetContextColorAttribute(tokenInfo.attributeIndex)) - { - tokenContextColorAtts.Add(tokenIndex, att); - } - if(Ptr att=GetCandidateAttribute(tokenInfo.attributeIndex)) - { - tokenCandidateAtts.Add(tokenIndex, att); - } - if(Ptr att=GetAutoCompleteAttribute(tokenInfo.attributeIndex)) - { - tokenAutoCompleteAtts.Add(tokenIndex, att); - } - } - } - { - vint fieldCount=table->GetTreeFieldInfoCount(); - for(vint field=0;fieldGetTreeFieldInfo(field); - FieldDesc fieldDesc(fieldInfo.type, fieldInfo.field); - - if(Ptr att=GetColorAttribute(fieldInfo.attributeIndex)) - { - fieldColorAtts.Add(fieldDesc, att); - } - if(Ptr att=GetSemanticAttribute(fieldInfo.attributeIndex)) - { - fieldSemanticAtts.Add(fieldDesc, att); - } - } - } - - FOREACH(Ptr, att, - From(tokenColorAtts.Values()) - .Concat(tokenContextColorAtts.Values()) - .Concat(fieldColorAtts.Values()) - .Concat(fieldSemanticAtts.Values()) - ) - { - FOREACH(WString, argument, att->arguments) - { - if(!semanticIndexMap.Contains(argument)) - { - semanticIndexMap.Add(argument); - } - } - } - - vint index=0; - FOREACH(vint, tokenIndex, tokenIndexMap.Values()) - { - TokenMetaData md; - md.tableTokenIndex=tokenIndex+ParsingTable::UserTokenStart; - md.lexerTokenIndex=tokenIndex; - md.defaultColorIndex=-1; - md.hasContextColor=false; - md.hasAutoComplete=false; - md.isCandidate=false; - - if((index=tokenColorAtts.Keys().IndexOf(tokenIndex))!=-1) - { - md.defaultColorIndex=semanticIndexMap.IndexOf(tokenColorAtts.Values()[index]->arguments[0]); - } - md.hasContextColor=tokenContextColorAtts.Keys().Contains(tokenIndex); - md.hasAutoComplete=tokenAutoCompleteAtts.Keys().Contains(tokenIndex); - if((md.isCandidate=tokenCandidateAtts.Keys().Contains(tokenIndex))) - { - const ParsingTable::TokenInfo& tokenInfo=table->GetTokenInfo(md.tableTokenIndex); - if(IsRegexEscapedLiteralString(tokenInfo.regex)) - { - md.unescapedRegexText=UnescapeTextForRegex(tokenInfo.regex); - } - else - { - md.isCandidate=false; - } - } - - tokenMetaDatas.Add(tokenIndex, md); - } - { - vint fieldCount=table->GetTreeFieldInfoCount(); - for(vint field=0;fieldGetTreeFieldInfo(field); - FieldDesc fieldDesc(fieldInfo.type, fieldInfo.field); - - FieldMetaData md; - md.colorIndex=-1; - - if((index=fieldColorAtts.Keys().IndexOf(fieldDesc))!=-1) - { - md.colorIndex=semanticIndexMap.IndexOf(fieldColorAtts.Values()[index]->arguments[0]); - } - if((index=fieldSemanticAtts.Keys().IndexOf(fieldDesc))!=-1) - { - md.semantics=new List; - FOREACH(WString, argument, fieldSemanticAtts.Values()[index]->arguments) - { - md.semantics->Add(semanticIndexMap.IndexOf(argument)); - } - } - - fieldMetaDatas.Add(fieldDesc, md); - } - } - } - - void RepeatingParsingExecutor::OnContextFinishedAsync(RepeatingParsingOutput& context) - { - if(analyzer) - { - context.cache = analyzer->CreateCacheAsync(context); - } - } - - RepeatingParsingExecutor::RepeatingParsingExecutor(Ptr _grammarParser, const WString& _grammarRule, Ptr _analyzer) - :grammarParser(_grammarParser) - ,grammarRule(_grammarRule) - ,analyzer(_analyzer) - ,autoPushingCallback(0) - { - PrepareMetaData(); - if (analyzer) - { - analyzer->Attach(this); - } - } - - RepeatingParsingExecutor::~RepeatingParsingExecutor() - { - EnsureTaskFinished(); - if (analyzer) - { - analyzer->Detach(this); - } - } - - Ptr RepeatingParsingExecutor::GetParser() - { - return grammarParser; - } - - bool RepeatingParsingExecutor::AttachCallback(ICallback* value) - { - if(!value) return false; - if(callbacks.Contains(value)) return false; - callbacks.Add(value); - return true; - } - - bool RepeatingParsingExecutor::DetachCallback(ICallback* value) - { - if(!value) return false; - if(!callbacks.Contains(value)) return false; - DeactivateCallback(value); - callbacks.Remove(value); - return true; - } - - bool RepeatingParsingExecutor::ActivateCallback(ICallback* value) - { - if(!value) return false; - if(!callbacks.Contains(value)) return false; - if(activatedCallbacks.Contains(value)) return false; - activatedCallbacks.Add(value); - - if(!autoPushingCallback) - { - autoPushingCallback=value; - autoPushingCallback->RequireAutoSubmitTask(true); - } - return true; - } - - bool RepeatingParsingExecutor::DeactivateCallback(ICallback* value) - { - if(!value) return false; - if(!callbacks.Contains(value)) return false; - if(!activatedCallbacks.Contains(value)) return false; - - if(autoPushingCallback==value) - { - autoPushingCallback->RequireAutoSubmitTask(false); - autoPushingCallback=0; - } - activatedCallbacks.Remove(value); - if(!autoPushingCallback && activatedCallbacks.Count()>0) - { - autoPushingCallback=activatedCallbacks[0]; - autoPushingCallback->RequireAutoSubmitTask(true); - } - return true; - } - - Ptr RepeatingParsingExecutor::GetAnalyzer() - { - return analyzer; - } - - vint RepeatingParsingExecutor::GetTokenIndex(const WString& tokenName) - { - vint index=tokenIndexMap.Keys().IndexOf(tokenName); - return index==-1?-1:tokenIndexMap.Values()[index]; - } - - vint RepeatingParsingExecutor::GetSemanticId(const WString& name) - { - return semanticIndexMap.IndexOf(name); - } - - WString RepeatingParsingExecutor::GetSemanticName(vint id) - { - return 0<=id&&id RepeatingParsingExecutor::GetAttribute(vint index, const WString& name, vint argumentCount) - { - if(index!=-1) - { - Ptr att=grammarParser->GetTable()->GetAttributeInfo(index)->FindFirst(name); - if(att && (argumentCount==-1 || att->arguments.Count()==argumentCount)) - { - return att; - } - } - return 0; - } - - Ptr RepeatingParsingExecutor::GetColorAttribute(vint index) - { - return GetAttribute(index, L"Color", 1); - } - - Ptr RepeatingParsingExecutor::GetContextColorAttribute(vint index) - { - return GetAttribute(index, L"ContextColor", 0); - } - - Ptr RepeatingParsingExecutor::GetSemanticAttribute(vint index) - { - return GetAttribute(index, L"Semantic", -1); - } - - Ptr RepeatingParsingExecutor::GetCandidateAttribute(vint index) - { - return GetAttribute(index, L"Candidate", 0); - } - - Ptr RepeatingParsingExecutor::GetAutoCompleteAttribute(vint index) - { - return GetAttribute(index, L"AutoComplete", 0); - } - } - } -} - -/*********************************************************************** -CONTROLS\TOOLSTRIPPACKAGE\GUIMENUCONTROLS.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace controls - { - using namespace compositions; - -/*********************************************************************** -IGuiMenuService -***********************************************************************/ - - const wchar_t* const IGuiMenuService::Identifier = L"vl::presentation::controls::IGuiMenuService"; - - IGuiMenuService::IGuiMenuService() - :openingMenu(0) - { - } - - void IGuiMenuService::MenuItemExecuted() - { - if(openingMenu) - { - openingMenu->Hide(); - } - if(GetParentMenuService()) - { - GetParentMenuService()->MenuItemExecuted(); - } - } - - GuiMenu* IGuiMenuService::GetOpeningMenu() - { - return openingMenu; - } - - void IGuiMenuService::MenuOpened(GuiMenu* menu) - { - if(openingMenu!=menu && openingMenu) - { - openingMenu->Hide(); - } - openingMenu=menu; - } - - void IGuiMenuService::MenuClosed(GuiMenu* menu) - { - if(openingMenu==menu) - { - openingMenu=0; - } - } - -/*********************************************************************** -GuiMenu -***********************************************************************/ - - IGuiMenuService* GuiMenu::GetParentMenuService() - { - return parentMenuService; - } - - IGuiMenuService::Direction GuiMenu::GetPreferredDirection() - { - return IGuiMenuService::Vertical; - } - - bool GuiMenu::IsActiveState() - { - return true; - } - - bool GuiMenu::IsSubMenuActivatedByMouseDown() - { - return false; - } - - void GuiMenu::MenuItemExecuted() - { - IGuiMenuService::MenuItemExecuted(); - Hide(); - } - - void GuiMenu::OnWindowOpened(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if(parentMenuService) - { - parentMenuService->MenuOpened(this); - } - } - - void GuiMenu::OnDeactivatedAltHost() - { - Hide(); - } - - void GuiMenu::MouseClickedOnOtherWindow(GuiWindow* window) - { - GuiMenu* targetMenu=dynamic_cast(window); - if(!targetMenu) - { - Hide(); - } - } - - void GuiMenu::OnWindowClosed(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if(parentMenuService) - { - parentMenuService->MenuClosed(this); - GuiMenu* openingSubMenu=GetOpeningMenu(); - if(openingSubMenu) - { - openingSubMenu->Hide(); - } - } - } - - GuiMenu::GuiMenu(IStyleController* _styleController, GuiControl* _owner) - :GuiPopup(_styleController) - ,owner(_owner) - ,parentMenuService(0) - { - GetNativeWindow()->SetAlwaysPassFocusToParent(true); - UpdateMenuService(); - WindowOpened.AttachMethod(this, &GuiMenu::OnWindowOpened); - WindowClosed.AttachMethod(this, &GuiMenu::OnWindowClosed); - } - - GuiMenu::~GuiMenu() - { - } - - void GuiMenu::UpdateMenuService() - { - if(owner) - { - parentMenuService=owner->QueryTypedService(); - } - } - - IDescriptable* GuiMenu::QueryService(const WString& identifier) - { - if(identifier==IGuiMenuService::Identifier) - { - return (IGuiMenuService*)this; - } - else - { - return GuiPopup::QueryService(identifier); - } - } - -/*********************************************************************** -GuiMenuBar -***********************************************************************/ - - IGuiMenuService* GuiMenuBar::GetParentMenuService() - { - return 0; - } - - IGuiMenuService::Direction GuiMenuBar::GetPreferredDirection() - { - return IGuiMenuService::Horizontal; - } - - bool GuiMenuBar::IsActiveState() - { - return GetOpeningMenu()!=0; - } - - bool GuiMenuBar::IsSubMenuActivatedByMouseDown() - { - return true; - } - - GuiMenuBar::GuiMenuBar(GuiControl::IStyleController* _styleController) - :GuiControl(_styleController) - { - } - - GuiMenuBar::~GuiMenuBar() - { - } - - IDescriptable* GuiMenuBar::QueryService(const WString& identifier) - { - if(identifier==IGuiMenuService::Identifier) - { - return (IGuiMenuService*)this; - } - else - { - return GuiControl::QueryService(identifier); - } - } - -/*********************************************************************** -GuiMenuButton -***********************************************************************/ - - GuiButton* GuiMenuButton::GetSubMenuHost() - { - GuiButton* button=styleController->GetSubMenuHost(); - return button?button:this; - } - - void GuiMenuButton::OpenSubMenuInternal() - { - if(!GetSubMenuOpening()) - { - if(ownerMenuService) - { - GuiMenu* openingSiblingMenu=ownerMenuService->GetOpeningMenu(); - if(openingSiblingMenu) - { - openingSiblingMenu->Hide(); - } - } - SetSubMenuOpening(true); - } - } - - void GuiMenuButton::OnParentLineChanged() - { - GuiButton::OnParentLineChanged(); - ownerMenuService=QueryTypedService(); - if(ownerMenuService) - { - SetClickOnMouseUp(!ownerMenuService->IsSubMenuActivatedByMouseDown()); - } - if(subMenu) - { - subMenu->UpdateMenuService(); - } - } - - bool GuiMenuButton::IsAltAvailable() - { - return true; - } - - compositions::IGuiAltActionHost* GuiMenuButton::GetActivatingAltHost() - { - if (subMenu) - { - return subMenu->QueryTypedService(); - } - return 0; - } - - void GuiMenuButton::OnSubMenuWindowOpened(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - SubMenuOpeningChanged.Execute(GetNotifyEventArguments()); - styleController->SetSubMenuOpening(true); - } - - void GuiMenuButton::OnSubMenuWindowClosed(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - SubMenuOpeningChanged.Execute(GetNotifyEventArguments()); - styleController->SetSubMenuOpening(false); - } - - void GuiMenuButton::OnMouseEnter(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if(GetVisuallyEnabled()) - { - if(cascadeAction && ownerMenuService && ownerMenuService->IsActiveState()) - { - OpenSubMenuInternal(); - } - } - } - - void GuiMenuButton::OnClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - if(GetVisuallyEnabled()) - { - if(GetSubMenu()) - { - OpenSubMenuInternal(); - } - else if(ownerMenuService) - { - ownerMenuService->MenuItemExecuted(); - } - } - } - - IGuiMenuService::Direction GuiMenuButton::GetSubMenuDirection() - { - return ownerMenuService?ownerMenuService->GetPreferredDirection():IGuiMenuService::Horizontal; - } - - GuiMenuButton::GuiMenuButton(IStyleController* _styleController) - :GuiSelectableButton(_styleController) - ,styleController(_styleController) - ,subMenu(0) - ,ownedSubMenu(false) - ,ownerMenuService(0) - ,cascadeAction(true) - { - SetAutoSelection(false); - SubMenuOpeningChanged.SetAssociatedComposition(boundsComposition); - ImageChanged.SetAssociatedComposition(boundsComposition); - ShortcutTextChanged.SetAssociatedComposition(boundsComposition); - GetSubMenuHost()->Clicked.AttachMethod(this, &GuiMenuButton::OnClicked); - GetSubMenuHost()->GetEventReceiver()->mouseEnter.AttachMethod(this, &GuiMenuButton::OnMouseEnter); - } - - GuiMenuButton::~GuiMenuButton() - { - if(subMenu && ownedSubMenu) - { - delete subMenu; - } - } - - Ptr GuiMenuButton::GetImage() - { - return image; - } - - void GuiMenuButton::SetImage(Ptr value) - { - if(image!=value) - { - image=value; - styleController->SetImage(image); - ImageChanged.Execute(GetNotifyEventArguments()); - } - } - - const WString& GuiMenuButton::GetShortcutText() - { - return shortcutText; - } - - void GuiMenuButton::SetShortcutText(const WString& value) - { - if(shortcutText!=value) - { - shortcutText=value; - styleController->SetShortcutText(shortcutText); - ShortcutTextChanged.Execute(GetNotifyEventArguments()); - } - } - - bool GuiMenuButton::IsSubMenuExists() - { - return subMenu!=0; - } - - GuiMenu* GuiMenuButton::GetSubMenu() - { - return subMenu; - } - - GuiMenu* GuiMenuButton::CreateSubMenu(GuiMenu::IStyleController* subMenuStyleController) - { - if(!subMenu) - { - GuiMenu* newSubMenu=new GuiMenu(subMenuStyleController?subMenuStyleController:styleController->CreateSubMenuStyleController(), this); - SetSubMenu(newSubMenu, true); - } - return subMenu; - } - - void GuiMenuButton::SetSubMenu(GuiMenu* value, bool owned) - { - if(subMenu) - { - if(ownedSubMenu) - { - delete subMenu; - } - } - subMenu=value; - ownedSubMenu=owned; - if(subMenu) - { - subMenu->WindowOpened.AttachMethod(this, &GuiMenuButton::OnSubMenuWindowOpened); - subMenu->WindowClosed.AttachMethod(this, &GuiMenuButton::OnSubMenuWindowClosed); - } - styleController->SetSubMenuExisting(subMenu!=0); - } - - void GuiMenuButton::DestroySubMenu() - { - if(subMenu) - { - if(ownedSubMenu) - { - delete subMenu; - } - subMenu=0; - ownedSubMenu=false; - styleController->SetSubMenuExisting(false); - } - } - - bool GuiMenuButton::GetOwnedSubMenu() - { - return subMenu && ownedSubMenu; - } - - bool GuiMenuButton::GetSubMenuOpening() - { - if(subMenu) - { - return subMenu->GetOpening(); - } - else - { - return false; - } - } - - void GuiMenuButton::SetSubMenuOpening(bool value) - { - if(subMenu) - { - if(value) - { - subMenu->SetClientSize(preferredMenuClientSize); - IGuiMenuService::Direction direction=GetSubMenuDirection(); - subMenu->ShowPopup(GetSubMenuHost(), direction==IGuiMenuService::Horizontal); - } - else - { - subMenu->Close(); - } - } - } - - Size GuiMenuButton::GetPreferredMenuClientSize() - { - return preferredMenuClientSize; - } - - void GuiMenuButton::SetPreferredMenuClientSize(Size value) - { - preferredMenuClientSize=value; - } - - bool GuiMenuButton::GetCascadeAction() - { - return cascadeAction; - } - - void GuiMenuButton::SetCascadeAction(bool value) - { - cascadeAction=value; - } - } - } -} - -/*********************************************************************** -CONTROLS\TOOLSTRIPPACKAGE\GUITOOLSTRIPCOMMAND.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace controls - { - using namespace collections; - using namespace compositions; - using namespace regex; - using namespace parsing; - -/*********************************************************************** -GuiToolstripCommand -***********************************************************************/ - - void GuiToolstripCommand::OnShortcutKeyItemExecuted(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - Executed.ExecuteWithNewSender(arguments, sender); - } - - void GuiToolstripCommand::OnRenderTargetChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) - { - UpdateShortcutOwner(); - } - - void GuiToolstripCommand::InvokeDescriptionChanged() - { - GuiEventArgs arguments; - DescriptionChanged.Execute(arguments); - } - - void GuiToolstripCommand::ReplaceShortcut(compositions::IGuiShortcutKeyItem* value, Ptr builder) - { - if (shortcutKeyItem != value) - { - if (shortcutKeyItem) - { - shortcutKeyItem->Executed.Detach(shortcutKeyItemExecutedHandler); - if (shortcutBuilder) - { - auto manager = dynamic_cast(shortcutOwner->GetShortcutKeyManager()); - if (manager) - { - manager->DestroyShortcut(shortcutBuilder->ctrl, shortcutBuilder->shift, shortcutBuilder->alt, shortcutBuilder->key); - } - } - } - shortcutKeyItem = nullptr; - shortcutKeyItemExecutedHandler = nullptr; - shortcutBuilder = value ? builder : nullptr; - if (value) - { - shortcutKeyItem = value; - shortcutKeyItemExecutedHandler = shortcutKeyItem->Executed.AttachMethod(this, &GuiToolstripCommand::OnShortcutKeyItemExecuted); - } - InvokeDescriptionChanged(); - } - } - - void GuiToolstripCommand::BuildShortcut(const WString& builderText) - { - List> errors; - if (auto parser = GetParserManager()->GetParser(L"SHORTCUT")) - { - if (Ptr builder = parser->ParseInternal(builderText, errors)) - { - if (shortcutOwner) - { - if (!shortcutOwner->GetShortcutKeyManager()) - { - shortcutOwner->SetShortcutKeyManager(new GuiShortcutKeyManager); - } - if (auto manager = dynamic_cast(shortcutOwner->GetShortcutKeyManager())) - { - IGuiShortcutKeyItem* item = manager->TryGetShortcut(builder->ctrl, builder->shift, builder->alt, builder->key); - if (!item) - { - item = manager->CreateShortcut(builder->ctrl, builder->shift, builder->alt, builder->key); - if (item) - { - ReplaceShortcut(item, builder); - } - } - } - } - else - { - shortcutBuilder = builder; - } - } - } - } - - void GuiToolstripCommand::UpdateShortcutOwner() - { - GuiControlHost* host = nullptr; - if (auto control = dynamic_cast(attachedRootObject)) - { - host = control->GetRelatedControlHost(); - } - else if (auto composition = dynamic_cast(attachedRootObject)) - { - host = composition->GetRelatedControlHost(); - } - - if (shortcutOwner != host) - { - if (shortcutOwner) - { - ReplaceShortcut(nullptr, nullptr); - shortcutOwner = nullptr; - } - shortcutOwner = host; - if (shortcutBuilder && !shortcutKeyItem) - { - BuildShortcut(shortcutBuilder->text); - } - } - } - - GuiToolstripCommand::GuiToolstripCommand() - { - } - - GuiToolstripCommand::~GuiToolstripCommand() - { - } - - void GuiToolstripCommand::Attach(GuiInstanceRootObject* rootObject) - { - GuiGraphicsComposition* rootComposition = nullptr; - - if (attachedRootObject != rootObject) - { - if (attachedRootObject) - { - if (auto control = dynamic_cast(attachedRootObject)) - { - control->RenderTargetChanged.Detach(renderTargetChangedHandler); - } - else if (auto composition = dynamic_cast(attachedRootObject)) - { - composition->GetEventReceiver()->renderTargetChanged.Detach(renderTargetChangedHandler); - } - renderTargetChangedHandler = nullptr; - } - - attachedRootObject = rootObject; - if (attachedRootObject) - { - if (auto control = dynamic_cast(attachedRootObject)) - { - renderTargetChangedHandler = control->RenderTargetChanged.AttachMethod(this, &GuiToolstripCommand::OnRenderTargetChanged); - } - else if (auto composition = dynamic_cast(attachedRootObject)) - { - renderTargetChangedHandler = composition->GetEventReceiver()->renderTargetChanged.AttachMethod(this, &GuiToolstripCommand::OnRenderTargetChanged); - } - } - UpdateShortcutOwner(); - } - } - - void GuiToolstripCommand::Detach(GuiInstanceRootObject* rootObject) - { - Attach(nullptr); - } - - Ptr GuiToolstripCommand::GetImage() - { - return image; - } - - void GuiToolstripCommand::SetImage(Ptr value) - { - if(image!=value) - { - image=value; - InvokeDescriptionChanged(); - } - } - - const WString& GuiToolstripCommand::GetText() - { - return text; - } - - void GuiToolstripCommand::SetText(const WString& value) - { - if(text!=value) - { - text=value; - InvokeDescriptionChanged(); - } - } - - compositions::IGuiShortcutKeyItem* GuiToolstripCommand::GetShortcut() - { - return shortcutKeyItem; - } - - void GuiToolstripCommand::SetShortcut(compositions::IGuiShortcutKeyItem* value) - { - ReplaceShortcut(value, 0); - } - - WString GuiToolstripCommand::GetShortcutBuilder() - { - return shortcutBuilder ? shortcutBuilder->text : L""; - } - - void GuiToolstripCommand::SetShortcutBuilder(const WString& value) - { - BuildShortcut(value); - } - - bool GuiToolstripCommand::GetEnabled() - { - return enabled; - } - - void GuiToolstripCommand::SetEnabled(bool value) - { - if(enabled!=value) - { - enabled=value; - InvokeDescriptionChanged(); - } - } - - bool GuiToolstripCommand::GetSelected() - { - return selected; - } - - void GuiToolstripCommand::SetSelected(bool value) - { - if(selected!=value) - { - selected=value; - InvokeDescriptionChanged(); - } - } - -/*********************************************************************** -GuiToolstripCommand::ShortcutBuilder Parser -***********************************************************************/ - - class GuiToolstripCommandShortcutParser : public Object, public IGuiParser - { - typedef GuiToolstripCommand::ShortcutBuilder ShortcutBuilder; - public: - Regex regexShortcut; - - GuiToolstripCommandShortcutParser() - :regexShortcut(L"((Ctrl)/+|(Shift)/+|(Alt)/+)*(/.+)") - { - } - - Ptr ParseInternal(const WString& text, collections::List>& errors)override - { - Ptr match=regexShortcut.MatchHead(text); - if (match && match->Result().Length() != text.Length()) - { - errors.Add(new ParsingError(L"Failed to parse a shortcut \"" + text + L"\".")); - return 0; - } - - Ptr builder = new ShortcutBuilder; - builder->text = text; - builder->ctrl = match->Groups().Contains(L"ctrl"); - builder->shift = match->Groups().Contains(L"shift"); - builder->alt = match->Groups().Contains(L"alt"); - - WString name = match->Groups()[L"key"][0].Value(); - builder->key = GetCurrentController()->InputService()->GetKey(name); - - return builder->key == -1 ? nullptr : builder; - } - }; - -/*********************************************************************** -GuiToolstripCommandPlugin -***********************************************************************/ - - class GuiToolstripCommandPlugin : public Object, public IGuiPlugin - { - public: - GuiToolstripCommandPlugin() - { - } - - void Load()override - { - } - - void AfterLoad()override - { - IGuiParserManager* manager=GetParserManager(); - manager->SetParser(L"SHORTCUT", new GuiToolstripCommandShortcutParser); - } - - void Unload()override - { - } - }; - GUI_REGISTER_PLUGIN(GuiToolstripCommandPlugin) - } - } -} - -/*********************************************************************** -CONTROLS\TOOLSTRIPPACKAGE\GUITOOLSTRIPMENU.CPP +.\CONTROLS\TOOLSTRIPPACKAGE\GUITOOLSTRIPMENU.CPP ***********************************************************************/ namespace vl @@ -30681,5346 +22989,7 @@ GuiToolstripButton } /*********************************************************************** -GRAPHICSCOMPOSITION\GUIGRAPHICSAXIS.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace compositions - { - -/*********************************************************************** -GuiDefaultAxis -***********************************************************************/ - - GuiDefaultAxis::GuiDefaultAxis() - { - } - - GuiDefaultAxis::~GuiDefaultAxis() - { - } - - Size GuiDefaultAxis::RealSizeToVirtualSize(Size size) - { - return size; - } - - Size GuiDefaultAxis::VirtualSizeToRealSize(Size size) - { - return size; - } - - Point GuiDefaultAxis::RealPointToVirtualPoint(Size realFullSize, Point point) - { - return point; - } - - Point GuiDefaultAxis::VirtualPointToRealPoint(Size realFullSize, Point point) - { - return point; - } - - Rect GuiDefaultAxis::RealRectToVirtualRect(Size realFullSize, Rect rect) - { - return rect; - } - - Rect GuiDefaultAxis::VirtualRectToRealRect(Size realFullSize, Rect rect) - { - return rect; - } - - Margin GuiDefaultAxis::RealMarginToVirtualMargin(Margin margin) - { - return margin; - } - - Margin GuiDefaultAxis::VirtualMarginToRealMargin(Margin margin) - { - return margin; - } - - KeyDirection GuiDefaultAxis::RealKeyDirectionToVirtualKeyDirection(KeyDirection key) - { - return key; - } - -/*********************************************************************** -GuiAxis -***********************************************************************/ - - GuiAxis::GuiAxis(AxisDirection _axisDirection) - :axisDirection(_axisDirection) - { - } - - GuiAxis::~GuiAxis() - { - } - - AxisDirection GuiAxis::GetDirection() - { - return axisDirection; - } - - Size GuiAxis::RealSizeToVirtualSize(Size size) - { - switch(axisDirection) - { - case AxisDirection::LeftDown: - case AxisDirection::RightDown: - case AxisDirection::LeftUp: - case AxisDirection::RightUp: - return Size(size.x, size.y); - case AxisDirection::DownLeft: - case AxisDirection::DownRight: - case AxisDirection::UpLeft: - case AxisDirection::UpRight: - return Size(size.y, size.x); - } - return size; - } - - Size GuiAxis::VirtualSizeToRealSize(Size size) - { - return RealSizeToVirtualSize(size); - } - - Point GuiAxis::RealPointToVirtualPoint(Size realFullSize, Point point) - { - Rect rect(point, Size(0, 0)); - return RealRectToVirtualRect(realFullSize, rect).LeftTop(); - } - - Point GuiAxis::VirtualPointToRealPoint(Size realFullSize, Point point) - { - Rect rect(point, Size(0, 0)); - return VirtualRectToRealRect(realFullSize, rect).LeftTop(); - } - - Rect GuiAxis::RealRectToVirtualRect(Size realFullSize, Rect rect) - { - vint x1=rect.x1; - vint x2=realFullSize.x-rect.x2; - vint y1=rect.y1; - vint y2=realFullSize.y-rect.y2; - vint w=rect.Width(); - vint h=rect.Height(); - switch(axisDirection) - { - case AxisDirection::LeftDown: - return Rect(Point(x2, y1), Size(w, h)); - case AxisDirection::RightDown: - return Rect(Point(x1, y1), Size(w, h)); - case AxisDirection::LeftUp: - return Rect(Point(x2, y2), Size(w, h)); - case AxisDirection::RightUp: - return Rect(Point(x1, y2), Size(w, h)); - case AxisDirection::DownLeft: - return Rect(Point(y1, x2), Size(h, w)); - case AxisDirection::DownRight: - return Rect(Point(y1, x1), Size(h, w)); - case AxisDirection::UpLeft: - return Rect(Point(y2, x2), Size(h, w)); - case AxisDirection::UpRight: - return Rect(Point(y2, x1), Size(h, w)); - } - return rect; - } - - Rect GuiAxis::VirtualRectToRealRect(Size realFullSize, Rect rect) - { - realFullSize=RealSizeToVirtualSize(realFullSize); - vint x1=rect.x1; - vint x2=realFullSize.x-rect.x2; - vint y1=rect.y1; - vint y2=realFullSize.y-rect.y2; - vint w=rect.Width(); - vint h=rect.Height(); - switch(axisDirection) - { - case AxisDirection::LeftDown: - return Rect(Point(x2, y1), Size(w, h)); - case AxisDirection::RightDown: - return Rect(Point(x1, y1), Size(w, h)); - case AxisDirection::LeftUp: - return Rect(Point(x2, y2), Size(w, h)); - case AxisDirection::RightUp: - return Rect(Point(x1, y2), Size(w, h)); - case AxisDirection::DownLeft: - return Rect(Point(y2, x1), Size(h, w)); - case AxisDirection::DownRight: - return Rect(Point(y1, x1), Size(h, w)); - case AxisDirection::UpLeft: - return Rect(Point(y2, x2), Size(h, w)); - case AxisDirection::UpRight: - return Rect(Point(y1, x2), Size(h, w)); - } - return rect; - } - - Margin GuiAxis::RealMarginToVirtualMargin(Margin margin) - { - vint x1=margin.left; - vint x2=margin.right; - vint y1=margin.top; - vint y2=margin.bottom; - switch(axisDirection) - { - case AxisDirection::LeftDown: - return Margin(x2, y1, x1, y2); - case AxisDirection::RightDown: - return Margin(x1, y1, x2, y2); - case AxisDirection::LeftUp: - return Margin(x2, y2, x1, y1); - case AxisDirection::RightUp: - return Margin(x1, y2, x2, y1); - case AxisDirection::DownLeft: - return Margin(y1, x2, y2, x1); - case AxisDirection::DownRight: - return Margin(y1, x1, y2, x2); - case AxisDirection::UpLeft: - return Margin(y2, x2, y1, x1); - case AxisDirection::UpRight: - return Margin(y2, x1, y1, x2); - } - return margin; - } - - Margin GuiAxis::VirtualMarginToRealMargin(Margin margin) - { - vint x1=margin.left; - vint x2=margin.right; - vint y1=margin.top; - vint y2=margin.bottom; - switch(axisDirection) - { - case AxisDirection::LeftDown: - return Margin(x2, y1, x1, y2); - case AxisDirection::RightDown: - return Margin(x1, y1, x2, y2); - case AxisDirection::LeftUp: - return Margin(x2, y2, x1, y1); - case AxisDirection::RightUp: - return Margin(x1, y2, x2, y1); - case AxisDirection::DownLeft: - return Margin(y2, x1, y1, x2); - case AxisDirection::DownRight: - return Margin(y1, x1, y2, x2); - case AxisDirection::UpLeft: - return Margin(y2, x2, y1, x1); - case AxisDirection::UpRight: - return Margin(y1, x2, y2, x1); - default:; - } - return margin; - } - - KeyDirection GuiAxis::RealKeyDirectionToVirtualKeyDirection(KeyDirection key) - { - bool pageKey=false; - switch(key) - { - case KeyDirection::PageUp: - pageKey=true; - key=KeyDirection::Up; - break; - case KeyDirection::PageDown: - pageKey=true; - key=KeyDirection::Down; - break; - case KeyDirection::PageLeft: - pageKey=true; - key=KeyDirection::Left; - break; - case KeyDirection::PageRight: - pageKey=true; - key=KeyDirection::Right; - break; - default:; - } - - switch(key) - { - case KeyDirection::Up: - switch(axisDirection) - { - case AxisDirection::LeftDown: key=KeyDirection::Up; break; - case AxisDirection::RightDown: key=KeyDirection::Up; break; - case AxisDirection::LeftUp: key=KeyDirection::Down; break; - case AxisDirection::RightUp: key=KeyDirection::Down; break; - case AxisDirection::DownLeft: key=KeyDirection::Left; break; - case AxisDirection::DownRight: key=KeyDirection::Left; break; - case AxisDirection::UpLeft: key=KeyDirection::Right; break; - case AxisDirection::UpRight: key=KeyDirection::Right; break; - } - break; - case KeyDirection::Down: - switch(axisDirection) - { - case AxisDirection::LeftDown: key=KeyDirection::Down; break; - case AxisDirection::RightDown: key=KeyDirection::Down; break; - case AxisDirection::LeftUp: key=KeyDirection::Up; break; - case AxisDirection::RightUp: key=KeyDirection::Up; break; - case AxisDirection::DownLeft: key=KeyDirection::Right; break; - case AxisDirection::DownRight: key=KeyDirection::Right; break; - case AxisDirection::UpLeft: key=KeyDirection::Left; break; - case AxisDirection::UpRight: key=KeyDirection::Left; break; - } - break; - case KeyDirection::Left: - switch(axisDirection) - { - case AxisDirection::LeftDown: key=KeyDirection::Right; break; - case AxisDirection::RightDown: key=KeyDirection::Left; break; - case AxisDirection::LeftUp: key=KeyDirection::Right; break; - case AxisDirection::RightUp: key=KeyDirection::Left; break; - case AxisDirection::DownLeft: key=KeyDirection::Down; break; - case AxisDirection::DownRight: key=KeyDirection::Up; break; - case AxisDirection::UpLeft: key=KeyDirection::Down; break; - case AxisDirection::UpRight: key=KeyDirection::Up; break; - } - break; - case KeyDirection::Right: - switch(axisDirection) - { - case AxisDirection::LeftDown: key=KeyDirection::Left; break; - case AxisDirection::RightDown: key=KeyDirection::Right; break; - case AxisDirection::LeftUp: key=KeyDirection::Left; break; - case AxisDirection::RightUp: key=KeyDirection::Right; break; - case AxisDirection::DownLeft: key=KeyDirection::Up; break; - case AxisDirection::DownRight: key=KeyDirection::Down; break; - case AxisDirection::UpLeft: key=KeyDirection::Up; break; - case AxisDirection::UpRight: key=KeyDirection::Down; break; - } - break; - case KeyDirection::Home: - switch(axisDirection) - { - case AxisDirection::LeftDown: key=KeyDirection::Home; break; - case AxisDirection::RightDown: key=KeyDirection::Home; break; - case AxisDirection::LeftUp: key=KeyDirection::End; break; - case AxisDirection::RightUp: key=KeyDirection::End; break; - case AxisDirection::DownLeft: key=KeyDirection::Home; break; - case AxisDirection::DownRight: key=KeyDirection::Home; break; - case AxisDirection::UpLeft: key=KeyDirection::End; break; - case AxisDirection::UpRight: key=KeyDirection::End; break; - } - break; - case KeyDirection::End: - switch(axisDirection) - { - case AxisDirection::LeftDown: key=KeyDirection::End; break; - case AxisDirection::RightDown: key=KeyDirection::End; break; - case AxisDirection::LeftUp: key=KeyDirection::Home; break; - case AxisDirection::RightUp: key=KeyDirection::Home; break; - case AxisDirection::DownLeft: key=KeyDirection::End; break; - case AxisDirection::DownRight: key=KeyDirection::End; break; - case AxisDirection::UpLeft: key=KeyDirection::Home; break; - case AxisDirection::UpRight: key=KeyDirection::Home; break; - } - break; - default:; - } - - if(pageKey) - { - switch(key) - { - case KeyDirection::Up: - key=KeyDirection::PageUp; - break; - case KeyDirection::Down: - key=KeyDirection::PageDown; - break; - case KeyDirection::Left: - key=KeyDirection::PageLeft; - break; - case KeyDirection::Right: - key=KeyDirection::PageRight; - break; - default:; - } - } - return key; - } - } - } -} - -/*********************************************************************** -GRAPHICSCOMPOSITION\GUIGRAPHICSBASICCOMPOSITION.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace compositions - { - using namespace collections; - using namespace controls; - using namespace elements; - -/*********************************************************************** -GuiWindowComposition -***********************************************************************/ - - GuiWindowComposition::GuiWindowComposition() - { - } - - GuiWindowComposition::~GuiWindowComposition() - { - } - - Rect GuiWindowComposition::GetBounds() - { - Rect bounds; - if (relatedHostRecord) - { - if (auto window = relatedHostRecord->host->GetNativeWindow()) - { - bounds = Rect(Point(0, 0), window->GetClientSize()); - } - } - UpdatePreviousBounds(bounds); - return bounds; - } - - void GuiWindowComposition::SetMargin(Margin value) - { - } - -/*********************************************************************** -GuiBoundsComposition -***********************************************************************/ - - GuiBoundsComposition::GuiBoundsComposition() - { - } - - GuiBoundsComposition::~GuiBoundsComposition() - { - } - - Rect GuiBoundsComposition::GetPreferredBounds() - { - Rect result = GetBoundsInternal(compositionBounds); - if (GetParent() && IsAlignedToParent()) - { - if (alignmentToParent.left >= 0) - { - vint offset = alignmentToParent.left - result.x1; - result.x1 += offset; - result.x2 += offset; - } - if (alignmentToParent.top >= 0) - { - vint offset = alignmentToParent.top - result.y1; - result.y1 += offset; - result.y2 += offset; - } - if (alignmentToParent.right >= 0) - { - result.x2 += alignmentToParent.right; - } - if (alignmentToParent.bottom >= 0) - { - result.y2 += alignmentToParent.bottom; - } - } - return result; - } - - Rect GuiBoundsComposition::GetBounds() - { - Rect result = GetPreferredBounds(); - if (GetParent() && IsAlignedToParent()) - { - Size clientSize = GetParent()->GetClientArea().GetSize(); - if (alignmentToParent.left >= 0 && alignmentToParent.right >= 0) - { - result.x1 = alignmentToParent.left; - result.x2 = clientSize.x - alignmentToParent.right; - } - else if (alignmentToParent.left >= 0) - { - vint width = result.Width(); - result.x1 = alignmentToParent.left; - result.x2 = result.x1 + width; - } - else if (alignmentToParent.right >= 0) - { - vint width = result.Width(); - result.x2 = clientSize.x - alignmentToParent.right; - result.x1 = result.x2 - width; - } - - if (alignmentToParent.top >= 0 && alignmentToParent.bottom >= 0) - { - result.y1 = alignmentToParent.top; - result.y2 = clientSize.y - alignmentToParent.bottom; - } - else if (alignmentToParent.top >= 0) - { - vint height = result.Height(); - result.y1 = alignmentToParent.top; - result.y2 = result.y1 + height; - } - else if (alignmentToParent.bottom >= 0) - { - vint height = result.Height(); - result.y2 = clientSize.y - alignmentToParent.bottom; - result.y1 = result.y2 - height; - } - } - UpdatePreviousBounds(result); - return result; - } - - void GuiBoundsComposition::SetBounds(Rect value) - { - compositionBounds = value; - InvokeOnCompositionStateChanged(); - } - - Margin GuiBoundsComposition::GetAlignmentToParent() - { - return alignmentToParent; - } - - void GuiBoundsComposition::SetAlignmentToParent(Margin value) - { - alignmentToParent = value; - InvokeOnCompositionStateChanged(); - } - - bool GuiBoundsComposition::IsAlignedToParent() - { - return alignmentToParent != Margin(-1, -1, -1, -1); - } - } - } -} - -/*********************************************************************** -GRAPHICSCOMPOSITION\GUIGRAPHICSCOMPOSITION.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace compositions - { - using namespace collections; - using namespace controls; - using namespace elements; - -/*********************************************************************** -GuiSharedSizeItemComposition -***********************************************************************/ - - void GuiSharedSizeItemComposition::Update() - { - if (parentRoot) - { - parentRoot->ForceCalculateSizeImmediately(); - } - InvokeOnCompositionStateChanged(); - } - - void GuiSharedSizeItemComposition::OnParentLineChanged() - { - GuiBoundsComposition::OnParentLineChanged(); - if (parentRoot) - { - parentRoot->childItems.Remove(this); - parentRoot = 0; - } - - auto current = GetParent(); - while (current) - { - if (auto item = dynamic_cast(current)) - { - break; - } - else if (auto root = dynamic_cast(current)) - { - parentRoot = root; - break; - } - current = current->GetParent(); - } - - if (parentRoot) - { - parentRoot->childItems.Add(this); - } - } - - GuiSharedSizeItemComposition::GuiSharedSizeItemComposition() - :parentRoot(0) - , sharedWidth(false) - , sharedHeight(false) - { - SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - } - - GuiSharedSizeItemComposition::~GuiSharedSizeItemComposition() - { - } - - const WString& GuiSharedSizeItemComposition::GetGroup() - { - return group; - } - - void GuiSharedSizeItemComposition::SetGroup(const WString& value) - { - if (group != value) - { - group = value; - Update(); - } - } - - bool GuiSharedSizeItemComposition::GetSharedWidth() - { - return sharedWidth; - } - - void GuiSharedSizeItemComposition::SetSharedWidth(bool value) - { - if (sharedWidth != value) - { - sharedWidth = value; - Update(); - } - } - - bool GuiSharedSizeItemComposition::GetSharedHeight() - { - return sharedHeight; - } - - void GuiSharedSizeItemComposition::SetSharedHeight(bool value) - { - if (sharedHeight != value) - { - sharedHeight = value; - Update(); - } - } - -/*********************************************************************** -GuiSharedSizeRootComposition -***********************************************************************/ - - GuiSharedSizeRootComposition::GuiSharedSizeRootComposition() - { - } - - GuiSharedSizeRootComposition::~GuiSharedSizeRootComposition() - { - } - - void AddSizeComponent(Dictionary& sizes, const WString& group, vint sizeComponent) - { - vint index = sizes.Keys().IndexOf(group); - if (index == -1) - { - sizes.Add(group, sizeComponent); - } - else if (sizes.Values().Get(index) < sizeComponent) - { - sizes.Set(group, sizeComponent); - } - } - - void GuiSharedSizeRootComposition::ForceCalculateSizeImmediately() - { - Dictionary widths, heights; - - FOREACH(GuiSharedSizeItemComposition*, item, childItems) - { - auto group = item->GetGroup(); - auto minSize = item->GetPreferredMinSize(); - item->SetPreferredMinSize(Size(0, 0)); - auto size = item->GetPreferredBounds().GetSize(); - - if (item->GetSharedWidth()) - { - AddSizeComponent(widths, group, size.x); - } - if (item->GetSharedHeight()) - { - AddSizeComponent(heights, group, size.y); - } - - item->SetPreferredMinSize(minSize); - } - - FOREACH(GuiSharedSizeItemComposition*, item, childItems) - { - auto group = item->GetGroup(); - auto size = item->GetPreferredMinSize(); - - if (item->GetSharedWidth()) - { - size.x = widths[group]; - } - if (item->GetSharedHeight()) - { - size.y = heights[group]; - } - - item->SetPreferredMinSize(size); - } - - GuiBoundsComposition::ForceCalculateSizeImmediately(); - } - } - } -} - -/*********************************************************************** -GRAPHICSCOMPOSITION\GUIGRAPHICSCOMPOSITIONBASE.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace compositions - { - using namespace collections; - using namespace controls; - using namespace elements; - - void InvokeOnCompositionStateChanged(compositions::GuiGraphicsComposition* composition) - { - composition->InvokeOnCompositionStateChanged(); - } - -/*********************************************************************** -GuiGraphicsComposition -***********************************************************************/ - - void GuiGraphicsComposition::OnControlParentChanged(controls::GuiControl* control) - { - if(associatedControl && associatedControl!=control) - { - if(associatedControl->GetParent()) - { - associatedControl->GetParent()->OnChildRemoved(associatedControl); - } - if(control) - { - control->OnChildInserted(associatedControl); - } - } - else - { - for(vint i=0;iOnControlParentChanged(control); - } - } - } - - void GuiGraphicsComposition::OnChildInserted(GuiGraphicsComposition* child) - { - child->OnControlParentChanged(GetRelatedControl()); - } - - void GuiGraphicsComposition::OnChildRemoved(GuiGraphicsComposition* child) - { - child->OnControlParentChanged(0); - } - - void GuiGraphicsComposition::OnParentChanged(GuiGraphicsComposition* oldParent, GuiGraphicsComposition* newParent) - { - OnParentLineChanged(); - } - - void GuiGraphicsComposition::OnParentLineChanged() - { - for (vint i = 0; i < children.Count(); i++) - { - children[i]->OnParentLineChanged(); - } - } - - void GuiGraphicsComposition::OnRenderContextChanged() - { - } - - void GuiGraphicsComposition::UpdateRelatedHostRecord(GraphicsHostRecord* record) - { - relatedHostRecord = record; - auto renderTarget = GetRenderTarget(); - - if (ownedElement) - { - if (auto renderer = ownedElement->GetRenderer()) - { - renderer->SetRenderTarget(renderTarget); - } - } - - for (vint i = 0; i < children.Count(); i++) - { - children[i]->UpdateRelatedHostRecord(record); - } - - if (HasEventReceiver()) - { - GetEventReceiver()->renderTargetChanged.Execute(GuiEventArgs(this)); - } - if (associatedControl) - { - associatedControl->OnRenderTargetChanged(renderTarget); - } - - OnRenderContextChanged(); - } - - void GuiGraphicsComposition::SetAssociatedControl(controls::GuiControl* control) - { - if (associatedControl) - { - for (vint i = 0; i < children.Count(); i++) - { - children[i]->OnControlParentChanged(0); - } - } - associatedControl = control; - if (associatedControl) - { - for (vint i = 0; i < children.Count(); i++) - { - children[i]->OnControlParentChanged(associatedControl); - } - } - } - - void GuiGraphicsComposition::InvokeOnCompositionStateChanged() - { - if (relatedHostRecord) - { - relatedHostRecord->host->RequestRender(); - } - } - - bool GuiGraphicsComposition::SharedPtrDestructorProc(DescriptableObject* obj, bool forceDisposing) - { - GuiGraphicsComposition* value=dynamic_cast(obj); - if(value->parent) - { - if (!forceDisposing) return false; - } - SafeDeleteComposition(value); - return true; - } - - GuiGraphicsComposition::GuiGraphicsComposition() - :visible(true) - ,minSizeLimitation(NoLimit) - ,associatedHitTestResult(INativeWindowListener::NoDecision) - { - sharedPtrDestructorProc = &GuiGraphicsComposition::SharedPtrDestructorProc; - } - - GuiGraphicsComposition::~GuiGraphicsComposition() - { - for(vint i=0;iGetParent()) return false; - children.Insert(index, child); - - // composition parent changed -> control parent changed -> related host changed - child->parent = this; - child->OnParentChanged(nullptr, this); - OnChildInserted(child); - child->UpdateRelatedHostRecord(relatedHostRecord); - - InvokeOnCompositionStateChanged(); - return true; - } - - bool GuiGraphicsComposition::RemoveChild(GuiGraphicsComposition* child) - { - if (!child) return false; - vint index = children.IndexOf(child); - if (index == -1) return false; - - // composition parent changed -> control parent changed -> related host changed - child->parent = nullptr; - child->OnParentChanged(this, nullptr); - OnChildRemoved(child); - child->UpdateRelatedHostRecord(nullptr); - - GuiGraphicsHost* host = GetRelatedGraphicsHost(); - if (host) - { - host->DisconnectComposition(child); - } - children.RemoveAt(index); - InvokeOnCompositionStateChanged(); - return true; - } - - bool GuiGraphicsComposition::MoveChild(GuiGraphicsComposition* child, vint newIndex) - { - if(!child) return false; - vint index=children.IndexOf(child); - if(index==-1) return false; - children.RemoveAt(index); - children.Insert(newIndex, child); - InvokeOnCompositionStateChanged(); - return true; - } - - Ptr GuiGraphicsComposition::GetOwnedElement() - { - return ownedElement; - } - - void GuiGraphicsComposition::SetOwnedElement(Ptr element) - { - if (ownedElement != element) - { - if (ownedElement) - { - if (auto renderer = ownedElement->GetRenderer()) - { - renderer->SetRenderTarget(nullptr); - } - ownedElement->SetOwnerComposition(nullptr); - } - ownedElement = element; - if (ownedElement) - { - if (auto renderer = ownedElement->GetRenderer()) - { - renderer->SetRenderTarget(GetRenderTarget()); - } - ownedElement->SetOwnerComposition(this); - } - InvokeOnCompositionStateChanged(); - } - } - - bool GuiGraphicsComposition::GetVisible() - { - return visible; - } - - void GuiGraphicsComposition::SetVisible(bool value) - { - visible = value; - InvokeOnCompositionStateChanged(); - } - - GuiGraphicsComposition::MinSizeLimitation GuiGraphicsComposition::GetMinSizeLimitation() - { - return minSizeLimitation; - } - - void GuiGraphicsComposition::SetMinSizeLimitation(MinSizeLimitation value) - { - minSizeLimitation = value; - InvokeOnCompositionStateChanged(); - } - - elements::IGuiGraphicsRenderTarget* GuiGraphicsComposition::GetRenderTarget() - { - return relatedHostRecord ? relatedHostRecord->renderTarget : nullptr; - } - - void GuiGraphicsComposition::Render(Size offset) - { - auto renderTarget = GetRenderTarget(); - if (visible && renderTarget && !renderTarget->IsClipperCoverWholeTarget()) - { - Rect bounds = GetBounds(); - bounds.x1 += margin.left; - bounds.y1 += margin.top; - bounds.x2 -= margin.right; - bounds.y2 -= margin.bottom; - - if (bounds.x1 <= bounds.x2 && bounds.y1 <= bounds.y2) - { - bounds.x1 += offset.x; - bounds.x2 += offset.x; - bounds.y1 += offset.y; - bounds.y2 += offset.y; - - if (ownedElement) - { - IGuiGraphicsRenderer* renderer = ownedElement->GetRenderer(); - if (renderer) - { - renderer->Render(bounds); - } - } - if (children.Count() > 0) - { - bounds.x1 += internalMargin.left; - bounds.y1 += internalMargin.top; - bounds.x2 -= internalMargin.right; - bounds.y2 -= internalMargin.bottom; - if (bounds.x1 <= bounds.x2 && bounds.y1 <= bounds.y2) - { - offset = bounds.GetSize(); - renderTarget->PushClipper(bounds); - if (!renderTarget->IsClipperCoverWholeTarget()) - { - for (vint i = 0; i < children.Count(); i++) - { - children[i]->Render(Size(bounds.x1, bounds.y1)); - } - } - renderTarget->PopClipper(); - } - } - } - } - } - - GuiGraphicsEventReceiver* GuiGraphicsComposition::GetEventReceiver() - { - if(!eventReceiver) - { - eventReceiver=new GuiGraphicsEventReceiver(this); - } - return eventReceiver.Obj(); - } - - bool GuiGraphicsComposition::HasEventReceiver() - { - return eventReceiver; - } - - GuiGraphicsComposition* GuiGraphicsComposition::FindComposition(Point location) - { - if (!visible) return 0; - Rect bounds = GetBounds(); - Rect relativeBounds = Rect(Point(0, 0), bounds.GetSize()); - if (relativeBounds.Contains(location)) - { - Rect clientArea = GetClientArea(); - for (vint i = children.Count() - 1; i >= 0; i--) - { - GuiGraphicsComposition* child = children[i]; - Rect childBounds = child->GetBounds(); - vint offsetX = childBounds.x1 + (clientArea.x1 - bounds.x1); - vint offsetY = childBounds.y1 + (clientArea.y1 - bounds.y1); - Point newLocation = location - Size(offsetX, offsetY); - GuiGraphicsComposition* childResult = child->FindComposition(newLocation); - if (childResult) - { - return childResult; - } - } - return this; - } - else - { - return 0; - } - } - - Rect GuiGraphicsComposition::GetGlobalBounds() - { - Rect bounds = GetBounds(); - GuiGraphicsComposition* composition = parent; - while (composition) - { - Rect clientArea = composition->GetClientArea(); - Rect parentBounds = composition->GetBounds(); - bounds.x1 += clientArea.x1; - bounds.x2 += clientArea.x1; - bounds.y1 += clientArea.y1; - bounds.y2 += clientArea.y1; - composition = composition->parent; - } - return bounds; - } - - controls::GuiControl* GuiGraphicsComposition::GetAssociatedControl() - { - return associatedControl; - } - - GuiGraphicsHost* GuiGraphicsComposition::GetAssociatedHost() - { - if (relatedHostRecord && relatedHostRecord->host->GetMainComposition() == this) - { - return relatedHostRecord->host; - } - else - { - return nullptr; - } - } - - INativeCursor* GuiGraphicsComposition::GetAssociatedCursor() - { - return associatedCursor; - } - - void GuiGraphicsComposition::SetAssociatedCursor(INativeCursor* cursor) - { - associatedCursor = cursor; - } - - INativeWindowListener::HitTestResult GuiGraphicsComposition::GetAssociatedHitTestResult() - { - return associatedHitTestResult; - } - - void GuiGraphicsComposition::SetAssociatedHitTestResult(INativeWindowListener::HitTestResult value) - { - associatedHitTestResult = value; - } - - controls::GuiControl* GuiGraphicsComposition::GetRelatedControl() - { - GuiGraphicsComposition* composition = this; - while (composition) - { - if (composition->GetAssociatedControl()) - { - return composition->GetAssociatedControl(); - } - else - { - composition = composition->GetParent(); - } - } - return nullptr; - } - - GuiGraphicsHost* GuiGraphicsComposition::GetRelatedGraphicsHost() - { - return relatedHostRecord ? relatedHostRecord->host : nullptr; - } - - controls::GuiControlHost* GuiGraphicsComposition::GetRelatedControlHost() - { - if (auto control = GetRelatedControl()) - { - return control->GetRelatedControlHost(); - } - return nullptr; - } - - INativeCursor* GuiGraphicsComposition::GetRelatedCursor() - { - GuiGraphicsComposition* composition = this; - while (composition) - { - if (composition->GetAssociatedCursor()) - { - return composition->GetAssociatedCursor(); - } - else - { - composition = composition->GetParent(); - } - } - return nullptr; - } - - Margin GuiGraphicsComposition::GetMargin() - { - return margin; - } - - void GuiGraphicsComposition::SetMargin(Margin value) - { - margin = value; - InvokeOnCompositionStateChanged(); - } - - Margin GuiGraphicsComposition::GetInternalMargin() - { - return internalMargin; - } - - void GuiGraphicsComposition::SetInternalMargin(Margin value) - { - internalMargin = value; - InvokeOnCompositionStateChanged(); - } - - Size GuiGraphicsComposition::GetPreferredMinSize() - { - return preferredMinSize; - } - - void GuiGraphicsComposition::SetPreferredMinSize(Size value) - { - preferredMinSize = value; - InvokeOnCompositionStateChanged(); - } - - Rect GuiGraphicsComposition::GetClientArea() - { - Rect bounds=GetBounds(); - bounds.x1+=margin.left+internalMargin.left; - bounds.y1+=margin.top+internalMargin.top; - bounds.x2-=margin.right+internalMargin.right; - bounds.y2-=margin.bottom+internalMargin.bottom; - return bounds; - } - - void GuiGraphicsComposition::ForceCalculateSizeImmediately() - { - for (vint i = 0; i < children.Count(); i++) - { - children[i]->ForceCalculateSizeImmediately(); - } - InvokeOnCompositionStateChanged(); - } - -/*********************************************************************** -GuiGraphicsSite -***********************************************************************/ - - Rect GuiGraphicsSite::GetBoundsInternal(Rect expectedBounds) - { - Size minSize = GetMinPreferredClientSize(); - if (minSize.x < preferredMinSize.x) minSize.x = preferredMinSize.x; - if (minSize.y < preferredMinSize.y) minSize.y = preferredMinSize.y; - - minSize.x += margin.left + margin.right + internalMargin.left + internalMargin.right; - minSize.y += margin.top + margin.bottom + internalMargin.top + internalMargin.bottom; - vint w = expectedBounds.Width(); - vint h = expectedBounds.Height(); - if (minSize.x < w) minSize.x = w; - if (minSize.y < h) minSize.y = h; - return Rect(expectedBounds.LeftTop(), minSize); - } - - void GuiGraphicsSite::UpdatePreviousBounds(Rect bounds) - { - if (previousBounds != bounds) - { - previousBounds = bounds; - BoundsChanged.Execute(GuiEventArgs(this)); - InvokeOnCompositionStateChanged(); - } - } - - GuiGraphicsSite::GuiGraphicsSite() - { - BoundsChanged.SetAssociatedComposition(this); - } - - GuiGraphicsSite::~GuiGraphicsSite() - { - } - - bool GuiGraphicsSite::IsSizeAffectParent() - { - return true; - } - - Size GuiGraphicsSite::GetMinPreferredClientSize() - { - Size minSize; - if (minSizeLimitation != GuiGraphicsComposition::NoLimit) - { - if (ownedElement) - { - IGuiGraphicsRenderer* renderer = ownedElement->GetRenderer(); - if (renderer) - { - minSize = renderer->GetMinSize(); - } - } - } - if (minSizeLimitation == GuiGraphicsComposition::LimitToElementAndChildren) - { - vint childCount = Children().Count(); - for (vint i = 0; i < childCount; i++) - { - GuiGraphicsComposition* child = children[i]; - if (child->IsSizeAffectParent()) - { - Rect childBounds = child->GetPreferredBounds(); - if (minSize.x < childBounds.x2) minSize.x = childBounds.x2; - if (minSize.y < childBounds.y2) minSize.y = childBounds.y2; - } - } - } - return minSize; - } - - Rect GuiGraphicsSite::GetPreferredBounds() - { - return GetBoundsInternal(Rect(Point(0, 0), GetMinPreferredClientSize())); - } - -/*********************************************************************** -Helper Functions -***********************************************************************/ - - void NotifyFinalizeInstance(controls::GuiControl* value) - { - if (value) - { - NotifyFinalizeInstance(value->GetBoundsComposition()); - } - } - - void NotifyFinalizeInstance(GuiGraphicsComposition* value) - { - if (value) - { - bool finalized = false; - if (auto root = dynamic_cast(value)) - { - if (root->IsFinalized()) - { - finalized = true; - } - else - { - root->FinalizeInstance(); - } - } - - if (auto control = value->GetAssociatedControl()) - { - if (auto root = dynamic_cast(control)) - { - if (root->IsFinalized()) - { - finalized = true; - } - else - { - root->FinalizeInstance(); - } - } - } - - if (!finalized) - { - vint count = value->Children().Count(); - for (vint i = 0; i < count; i++) - { - NotifyFinalizeInstance(value->Children()[i]); - } - } - } - } - - void SafeDeleteControlInternal(controls::GuiControl* value) - { - if(value) - { - if (value->GetRelatedControlHost() != value) - { - GuiGraphicsComposition* bounds = value->GetBoundsComposition(); - if (bounds->GetParent()) - { - bounds->GetParent()->RemoveChild(bounds); - } - } - delete value; - } - } - - void SafeDeleteCompositionInternal(GuiGraphicsComposition* value) - { - if (value) - { - if (value->GetParent()) - { - value->GetParent()->RemoveChild(value); - } - - if (value->GetAssociatedControl()) - { - SafeDeleteControlInternal(value->GetAssociatedControl()); - } - else - { - for (vint i = value->Children().Count() - 1; i >= 0; i--) - { - SafeDeleteCompositionInternal(value->Children().Get(i)); - } - delete value; - } - } - } - - void SafeDeleteControl(controls::GuiControl* value) - { - NotifyFinalizeInstance(value); - SafeDeleteControlInternal(value); - } - - void SafeDeleteComposition(GuiGraphicsComposition* value) - { - NotifyFinalizeInstance(value); - SafeDeleteCompositionInternal(value); - } - } - } -} - -/*********************************************************************** -GRAPHICSCOMPOSITION\GUIGRAPHICSEVENTRECEIVER.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace compositions - { - -/*********************************************************************** -Event Receiver -***********************************************************************/ - - GuiGraphicsEventReceiver::GuiGraphicsEventReceiver(GuiGraphicsComposition* _sender) - :sender(_sender) - ,leftButtonDown(_sender) - ,leftButtonUp(_sender) - ,leftButtonDoubleClick(_sender) - ,middleButtonDown(_sender) - ,middleButtonUp(_sender) - ,middleButtonDoubleClick(_sender) - ,rightButtonDown(_sender) - ,rightButtonUp(_sender) - ,rightButtonDoubleClick(_sender) - ,horizontalWheel(_sender) - ,verticalWheel(_sender) - ,mouseMove(_sender) - ,mouseEnter(_sender) - ,mouseLeave(_sender) - ,previewKey(_sender) - ,keyDown(_sender) - ,keyUp(_sender) - ,systemKeyDown(_sender) - ,systemKeyUp(_sender) - ,previewCharInput(_sender) - ,charInput(_sender) - ,gotFocus(_sender) - ,lostFocus(_sender) - ,caretNotify(_sender) - ,clipboardNotify(_sender) - { - } - - GuiGraphicsEventReceiver::~GuiGraphicsEventReceiver() - { - } - - GuiGraphicsComposition* GuiGraphicsEventReceiver::GetAssociatedComposition() - { - return sender; - } - } - } -} - -/*********************************************************************** -GRAPHICSCOMPOSITION\GUIGRAPHICSFLOWCOMPOSITION.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace compositions - { - using namespace collections; - -/*********************************************************************** -GuiFlowComposition -***********************************************************************/ - - void GuiFlowComposition::UpdateFlowItemBounds(bool forceUpdate) - { - if (forceUpdate || needUpdate) - { - needUpdate = false; - InvokeOnCompositionStateChanged(); - - auto clientMargin = axis->RealMarginToVirtualMargin(extraMargin); - if (clientMargin.left < 0) clientMargin.left = 0; - if (clientMargin.top < 0) clientMargin.top = 0; - if (clientMargin.right < 0) clientMargin.right = 0; - if (clientMargin.bottom < 0) clientMargin.bottom = 0; - - auto realFullSize = previousBounds.GetSize(); - auto clientSize = axis->RealSizeToVirtualSize(realFullSize); - clientSize.x -= (clientMargin.left + clientMargin.right); - clientSize.y -= (clientMargin.top + clientMargin.bottom); - - flowItemBounds.Resize(flowItems.Count()); - for (vint i = 0; i < flowItems.Count(); i++) - { - flowItemBounds[i] = Rect(Point(0, 0), flowItems[i]->GetMinSize()); - } - - vint currentIndex = 0; - vint rowTop = 0; - - while (currentIndex < flowItems.Count()) - { - auto itemSize = axis->RealSizeToVirtualSize(flowItemBounds[currentIndex].GetSize()); - vint rowWidth = itemSize.x; - vint rowHeight = itemSize.y; - vint rowItemCount = 1; - - for (vint i = currentIndex + 1; i < flowItems.Count(); i++) - { - itemSize = axis->RealSizeToVirtualSize(flowItemBounds[i].GetSize()); - vint itemWidth = itemSize.x + columnPadding; - if (rowWidth + itemWidth > clientSize.x) - { - break; - } - rowWidth += itemWidth; - if (rowHeight < itemSize.y) - { - rowHeight = itemSize.y; - } - rowItemCount++; - } - - vint baseLine = 0; - Array itemBaseLines(rowItemCount); - for (vint i = 0; i < rowItemCount; i++) - { - vint index = currentIndex + i; - vint itemBaseLine = 0; - itemSize = axis->RealSizeToVirtualSize(flowItemBounds[index].GetSize()); - - auto option = flowItems[index]->GetFlowOption(); - switch (option.baseline) - { - case GuiFlowOption::FromTop: - itemBaseLine = option.distance; - break; - case GuiFlowOption::FromBottom: - itemBaseLine = itemSize.y - option.distance; - break; - case GuiFlowOption::Percentage: - itemBaseLine = (vint)(itemSize.y*option.percentage); - break; - } - - itemBaseLines[i] = itemBaseLine; - if (baseLine < itemBaseLine) - { - baseLine = itemBaseLine; - } - } - - vint rowUsedWidth = 0; - for (vint i = 0; i < rowItemCount; i++) - { - vint index = currentIndex + i; - itemSize = axis->RealSizeToVirtualSize(flowItemBounds[index].GetSize()); - - vint itemLeft = 0; - vint itemTop = rowTop + baseLine - itemBaseLines[i]; - - switch (alignment) - { - case FlowAlignment::Left: - itemLeft = rowUsedWidth + i * columnPadding; - break; - case FlowAlignment::Center: - itemLeft = rowUsedWidth + i * columnPadding + (clientSize.x - rowWidth) / 2; - break; - case FlowAlignment::Extend: - if (i == 0) - { - itemLeft = rowUsedWidth; - } - else - { - itemLeft = rowUsedWidth + (vint)((double)(clientSize.x - rowWidth) * i / (rowItemCount - 1)) + i * columnPadding; - } - break; - } - - flowItemBounds[index] = axis->VirtualRectToRealRect( - realFullSize, - Rect( - Point( - itemLeft + clientMargin.left, - itemTop + clientMargin.top - ), - itemSize - ) - ); - rowUsedWidth += itemSize.x; - } - - rowTop += rowHeight + rowPadding; - currentIndex += rowItemCount; - } - - minHeight = rowTop == 0 ? 0 : rowTop - rowPadding; - } - } - - void GuiFlowComposition::OnBoundsChanged(GuiGraphicsComposition* sender, GuiEventArgs& arguments) - { - UpdateFlowItemBounds(true); - } - - void GuiFlowComposition::OnChildInserted(GuiGraphicsComposition* child) - { - GuiBoundsComposition::OnChildInserted(child); - auto item = dynamic_cast(child); - if (item && !flowItems.Contains(item)) - { - flowItems.Add(item); - needUpdate = true; - } - } - - void GuiFlowComposition::OnChildRemoved(GuiGraphicsComposition* child) - { - GuiBoundsComposition::OnChildRemoved(child); - auto item = dynamic_cast(child); - if (item) - { - flowItems.Remove(item); - needUpdate = true; - } - } - - GuiFlowComposition::GuiFlowComposition() - :axis(new GuiDefaultAxis) - { - BoundsChanged.AttachMethod(this, &GuiFlowComposition::OnBoundsChanged); - } - - GuiFlowComposition::~GuiFlowComposition() - { - } - - const GuiFlowComposition::ItemCompositionList& GuiFlowComposition::GetFlowItems() - { - return flowItems; - } - - Margin GuiFlowComposition::GetExtraMargin() - { - return extraMargin; - } - - void GuiFlowComposition::SetExtraMargin(Margin value) - { - extraMargin = value; - needUpdate = true; - InvokeOnCompositionStateChanged(); - } - - vint GuiFlowComposition::GetRowPadding() - { - return rowPadding; - } - - void GuiFlowComposition::SetRowPadding(vint value) - { - rowPadding = value; - needUpdate = true; - InvokeOnCompositionStateChanged(); - } - - vint GuiFlowComposition::GetColumnPadding() - { - return columnPadding; - } - - void GuiFlowComposition::SetColumnPadding(vint value) - { - columnPadding = value; - needUpdate = true; - InvokeOnCompositionStateChanged(); - } - - Ptr GuiFlowComposition::GetAxis() - { - return axis; - } - - void GuiFlowComposition::SetAxis(Ptr value) - { - if (value) - { - axis = value; - needUpdate = true; - InvokeOnCompositionStateChanged(); - } - } - - FlowAlignment GuiFlowComposition::GetAlignment() - { - return alignment; - } - - void GuiFlowComposition::SetAlignment(FlowAlignment value) - { - alignment = value; - needUpdate = true; - InvokeOnCompositionStateChanged(); - } - - void GuiFlowComposition::ForceCalculateSizeImmediately() - { - GuiBoundsComposition::ForceCalculateSizeImmediately(); - UpdateFlowItemBounds(true); - } - - Size GuiFlowComposition::GetMinPreferredClientSize() - { - Size minSize = GuiBoundsComposition::GetMinPreferredClientSize(); - if (GetMinSizeLimitation() == GuiGraphicsComposition::LimitToElementAndChildren) - { - auto clientMargin = extraMargin; - if (clientMargin.left < 0) clientMargin.left = 0; - if (clientMargin.top < 0) clientMargin.top = 0; - if (clientMargin.right < 0) clientMargin.right = 0; - if (clientMargin.bottom < 0) clientMargin.bottom = 0; - - auto clientSize = axis->VirtualSizeToRealSize(Size(0, minHeight)); - clientSize.x += clientMargin.left + clientMargin.right; - clientSize.y += clientMargin.top + clientMargin.bottom; - - if (minSize.x < clientSize.x) minSize.x = clientSize.x; - if (minSize.y < clientSize.y) minSize.y = clientSize.y; - } - - vint x = 0; - vint y = 0; - if (extraMargin.left > 0) x += extraMargin.left; - if (extraMargin.right > 0) x += extraMargin.right; - if (extraMargin.top > 0) y += extraMargin.top; - if (extraMargin.bottom > 0) y += extraMargin.bottom; - return minSize + Size(x, y); - } - - Rect GuiFlowComposition::GetBounds() - { - if (!needUpdate) - { - for (vint i = 0; i < flowItems.Count(); i++) - { - if (flowItemBounds[i].GetSize() != flowItems[i]->GetMinSize()) - { - needUpdate = true; - break; - } - } - } - - if (needUpdate) - { - UpdateFlowItemBounds(true); - } - - bounds = GuiBoundsComposition::GetBounds(); - return bounds; - } - -/*********************************************************************** -GuiFlowItemComposition -***********************************************************************/ - - void GuiFlowItemComposition::OnParentChanged(GuiGraphicsComposition* oldParent, GuiGraphicsComposition* newParent) - { - GuiGraphicsSite::OnParentChanged(oldParent, newParent); - flowParent = newParent == 0 ? 0 : dynamic_cast(newParent); - } - - Size GuiFlowItemComposition::GetMinSize() - { - return GetBoundsInternal(bounds).GetSize(); - } - - GuiFlowItemComposition::GuiFlowItemComposition() - { - SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - } - - GuiFlowItemComposition::~GuiFlowItemComposition() - { - } - - bool GuiFlowItemComposition::IsSizeAffectParent() - { - return false; - } - - Rect GuiFlowItemComposition::GetBounds() - { - Rect result = bounds; - if(flowParent) - { - flowParent->UpdateFlowItemBounds(false); - vint index = flowParent->flowItems.IndexOf(this); - if (index != -1) - { - result = flowParent->flowItemBounds[index]; - } - - result = Rect( - result.Left() - extraMargin.left, - result.Top() - extraMargin.top, - result.Right() + extraMargin.right, - result.Bottom() + extraMargin.bottom - ); - } - UpdatePreviousBounds(result); - return result; - } - - void GuiFlowItemComposition::SetBounds(Rect value) - { - bounds = value; - InvokeOnCompositionStateChanged(); - } - - Margin GuiFlowItemComposition::GetExtraMargin() - { - return extraMargin; - } - - void GuiFlowItemComposition::SetExtraMargin(Margin value) - { - extraMargin = value; - InvokeOnCompositionStateChanged(); - } - - GuiFlowOption GuiFlowItemComposition::GetFlowOption() - { - return option; - } - - void GuiFlowItemComposition::SetFlowOption(GuiFlowOption value) - { - option = value; - if (flowParent) - { - flowParent->needUpdate = true; - InvokeOnCompositionStateChanged(); - } - } - } - } -} - -/*********************************************************************** -GRAPHICSCOMPOSITION\GUIGRAPHICSSPECIALIZEDCOMPOSITION.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace compositions - { - -/*********************************************************************** -GuiSideAlignedComposition -***********************************************************************/ - - GuiSideAlignedComposition::GuiSideAlignedComposition() - :direction(Top) - ,maxLength(10) - ,maxRatio(1.0) - { - } - - GuiSideAlignedComposition::~GuiSideAlignedComposition() - { - } - - GuiSideAlignedComposition::Direction GuiSideAlignedComposition::GetDirection() - { - return direction; - } - - void GuiSideAlignedComposition::SetDirection(Direction value) - { - direction = value; - InvokeOnCompositionStateChanged(); - } - - vint GuiSideAlignedComposition::GetMaxLength() - { - return maxLength; - } - - void GuiSideAlignedComposition::SetMaxLength(vint value) - { - if (value < 0) value = 0; - maxLength = value; - InvokeOnCompositionStateChanged(); - } - - double GuiSideAlignedComposition::GetMaxRatio() - { - return maxRatio; - } - - void GuiSideAlignedComposition::SetMaxRatio(double value) - { - maxRatio = - value < 0 ? 0 : - value>1 ? 1 : - value; - InvokeOnCompositionStateChanged(); - } - - bool GuiSideAlignedComposition::IsSizeAffectParent() - { - return false; - } - - Rect GuiSideAlignedComposition::GetBounds() - { - Rect result; - GuiGraphicsComposition* parent = GetParent(); - if (parent) - { - Rect bounds = parent->GetBounds(); - vint w = (vint)(bounds.Width()*maxRatio); - vint h = (vint)(bounds.Height()*maxRatio); - if (w > maxLength) w = maxLength; - if (h > maxLength) h = maxLength; - switch (direction) - { - case Left: - { - bounds.x2 = bounds.x1 + w; - } - break; - case Top: - { - bounds.y2 = bounds.y1 + h; - } - break; - case Right: - { - bounds.x1 = bounds.x2 - w; - } - break; - case Bottom: - { - bounds.y1 = bounds.y2 - h; - } - break; - } - result = bounds; - } - UpdatePreviousBounds(result); - return result; - } - -/*********************************************************************** -GuiPartialViewComposition -***********************************************************************/ - - GuiPartialViewComposition::GuiPartialViewComposition() - :wRatio(0.0) - ,wPageSize(1.0) - ,hRatio(0.0) - ,hPageSize(1.0) - { - } - - GuiPartialViewComposition::~GuiPartialViewComposition() - { - } - - double GuiPartialViewComposition::GetWidthRatio() - { - return wRatio; - } - - double GuiPartialViewComposition::GetWidthPageSize() - { - return wPageSize; - } - - double GuiPartialViewComposition::GetHeightRatio() - { - return hRatio; - } - - double GuiPartialViewComposition::GetHeightPageSize() - { - return hPageSize; - } - - void GuiPartialViewComposition::SetWidthRatio(double value) - { - wRatio = value; - InvokeOnCompositionStateChanged(); - } - - void GuiPartialViewComposition::SetWidthPageSize(double value) - { - wPageSize = value; - InvokeOnCompositionStateChanged(); - } - - void GuiPartialViewComposition::SetHeightRatio(double value) - { - hRatio = value; - InvokeOnCompositionStateChanged(); - } - - void GuiPartialViewComposition::SetHeightPageSize(double value) - { - hPageSize = value; - InvokeOnCompositionStateChanged(); - } - - bool GuiPartialViewComposition::IsSizeAffectParent() - { - return false; - } - - Rect GuiPartialViewComposition::GetBounds() - { - Rect result; - GuiGraphicsComposition* parent = GetParent(); - if (parent) - { - Rect bounds = parent->GetBounds(); - vint w = bounds.Width(); - vint h = bounds.Height(); - vint pw = (vint)(wPageSize*w); - vint ph = (vint)(hPageSize*h); - - vint ow = preferredMinSize.x - pw; - if (ow < 0) ow = 0; - vint oh = preferredMinSize.y - ph; - if (oh < 0) oh = 0; - - w -= ow; - h -= oh; - pw += ow; - ph += oh; - - result = Rect(Point((vint)(wRatio*w), (vint)(hRatio*h)), Size(pw, ph)); - } - UpdatePreviousBounds(result); - return result; - } - } - } -} - -/*********************************************************************** -GRAPHICSCOMPOSITION\GUIGRAPHICSSTACKCOMPOSITION.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace compositions - { - -/*********************************************************************** -GuiStackComposition -***********************************************************************/ - - void GuiStackComposition::UpdateStackItemBounds() - { - if (stackItemBounds.Count() != stackItems.Count()) - { - stackItemBounds.Resize(stackItems.Count()); - } - - stackItemTotalSize = Size(0, 0); - Point offset; - for (vint i = 0; i < stackItems.Count(); i++) - { - vint offsetX = 0; - vint offsetY = 0; - Size itemSize = stackItems[i]->GetMinSize(); - stackItemBounds[i] = Rect(offset, itemSize); - -#define ACCUMULATE(U, V) \ - { \ - if (stackItemTotalSize.V < itemSize.V) \ - { \ - stackItemTotalSize.V = itemSize.V; \ - } \ - if (i > 0) \ - { \ - stackItemTotalSize.U += padding; \ - } \ - stackItemTotalSize.U += itemSize.U; \ - } \ - - switch (direction) - { - case GuiStackComposition::Horizontal: - case GuiStackComposition::ReversedHorizontal: - ACCUMULATE(x, y) - break; - case GuiStackComposition::Vertical: - case GuiStackComposition::ReversedVertical: - ACCUMULATE(y, x) - break; - } - -#undef ACCUMULATE - offset.x += itemSize.x + padding; - offset.y += itemSize.y + padding; - } - EnsureStackItemVisible(); - } - - void GuiStackComposition::EnsureStackItemVisible() - { -#define ADJUSTMENT(U, V) \ - if (itemBounds.U() <= 0) \ - { \ - adjustment -= itemBounds.U(); \ - } \ - else \ - { \ - vint overflow = itemBounds.V() - previousBounds.V(); \ - if (overflow > 0) \ - { \ - adjustment -= overflow; \ - } \ - } \ - - if (ensuringVisibleStackItem) - { - Rect itemBounds = ensuringVisibleStackItem->GetBounds(); - switch (direction) - { - case Horizontal: - case ReversedHorizontal: - ADJUSTMENT(Left, Right) - break; - case Vertical: - case ReversedVertical: - ADJUSTMENT(Top, Bottom) - break; - } - } - - InvokeOnCompositionStateChanged(); -#undef ADJUSTMENT - } - - void GuiStackComposition::OnBoundsChanged(GuiGraphicsComposition* sender, GuiEventArgs& arguments) - { - EnsureStackItemVisible(); - } - - void GuiStackComposition::OnChildInserted(GuiGraphicsComposition* child) - { - GuiBoundsComposition::OnChildInserted(child); - GuiStackItemComposition* item = dynamic_cast(child); - if (item) - { - if (!stackItems.Contains(item)) - { - stackItems.Add(item); - } - UpdateStackItemBounds(); - } - } - - void GuiStackComposition::OnChildRemoved(GuiGraphicsComposition* child) - { - GuiBoundsComposition::OnChildRemoved(child); - GuiStackItemComposition* item = dynamic_cast(child); - if (item) - { - stackItems.Remove(item); - if (item == ensuringVisibleStackItem) - { - ensuringVisibleStackItem = 0; - } - UpdateStackItemBounds(); - } - } - - GuiStackComposition::GuiStackComposition() - { - BoundsChanged.AttachMethod(this, &GuiStackComposition::OnBoundsChanged); - } - - GuiStackComposition::~GuiStackComposition() - { - } - - const GuiStackComposition::ItemCompositionList& GuiStackComposition::GetStackItems() - { - return stackItems; - } - - bool GuiStackComposition::InsertStackItem(vint index, GuiStackItemComposition* item) - { - index = stackItems.Insert(index, item); - if (!AddChild(item)) - { - stackItems.RemoveAt(index); - return false; - } - else - { - return true; - } - } - - GuiStackComposition::Direction GuiStackComposition::GetDirection() - { - return direction; - } - - void GuiStackComposition::SetDirection(Direction value) - { - direction = value; - EnsureStackItemVisible(); - } - - vint GuiStackComposition::GetPadding() - { - return padding; - } - - void GuiStackComposition::SetPadding(vint value) - { - padding = value; - EnsureStackItemVisible(); - } - - void GuiStackComposition::ForceCalculateSizeImmediately() - { - GuiBoundsComposition::ForceCalculateSizeImmediately(); - UpdateStackItemBounds(); - } - - Size GuiStackComposition::GetMinPreferredClientSize() - { - Size minSize = GuiBoundsComposition::GetMinPreferredClientSize(); - if (GetMinSizeLimitation() == GuiGraphicsComposition::LimitToElementAndChildren) - { - if (!ensuringVisibleStackItem || direction == Vertical || direction == ReversedVertical) - { - if (minSize.x < stackItemTotalSize.x) - { - minSize.x = stackItemTotalSize.x; - } - } - if (!ensuringVisibleStackItem || direction == Horizontal || direction == ReversedHorizontal) - { - if (minSize.y < stackItemTotalSize.y) - { - minSize.y = stackItemTotalSize.y; - } - } - } - - vint x = 0; - vint y = 0; - if (extraMargin.left > 0) x += extraMargin.left; - if (extraMargin.right > 0) x += extraMargin.right; - if (extraMargin.top > 0) y += extraMargin.top; - if (extraMargin.bottom > 0) y += extraMargin.bottom; - return minSize + Size(x, y); - } - - Rect GuiStackComposition::GetBounds() - { - for (vint i = 0; i < stackItems.Count(); i++) - { - if (stackItemBounds[i].GetSize() != stackItems[i]->GetMinSize()) - { - UpdateStackItemBounds(); - break; - } - } - - Rect bounds = GuiBoundsComposition::GetBounds(); - previousBounds = bounds; - UpdatePreviousBounds(previousBounds); - return bounds; - } - - Margin GuiStackComposition::GetExtraMargin() - { - return extraMargin; - } - - void GuiStackComposition::SetExtraMargin(Margin value) - { - extraMargin=value; - EnsureStackItemVisible(); - } - - bool GuiStackComposition::IsStackItemClipped() - { - Rect clientArea = GetClientArea(); - switch(direction) - { - case Horizontal: - case ReversedHorizontal: - { - vint width = stackItemTotalSize.x - + (extraMargin.left > 0 ? extraMargin.left : 0) - + (extraMargin.right > 0 ? extraMargin.right : 0) - ; - return width > clientArea.Width(); - } - break; - case Vertical: - case ReversedVertical: - { - vint height = stackItemTotalSize.y - + (extraMargin.top > 0 ? extraMargin.top : 0) - + (extraMargin.bottom > 0 ? extraMargin.bottom : 0) - ; - return height > clientArea.Height(); - } - break; - } - return false; - } - - bool GuiStackComposition::EnsureVisible(vint index) - { - if (0 <= index && index < stackItems.Count()) - { - ensuringVisibleStackItem = stackItems[index]; - } - else - { - ensuringVisibleStackItem = 0; - } - EnsureStackItemVisible(); - return ensuringVisibleStackItem != 0; - } - -/*********************************************************************** -GuiStackItemComposition -***********************************************************************/ - - void GuiStackItemComposition::OnParentChanged(GuiGraphicsComposition* oldParent, GuiGraphicsComposition* newParent) - { - GuiGraphicsSite::OnParentChanged(oldParent, newParent); - stackParent = newParent == 0 ? 0 : dynamic_cast(newParent); - } - - Size GuiStackItemComposition::GetMinSize() - { - return GetBoundsInternal(bounds).GetSize(); - } - - GuiStackItemComposition::GuiStackItemComposition() - :stackParent(0) - { - SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - } - - GuiStackItemComposition::~GuiStackItemComposition() - { - } - - bool GuiStackItemComposition::IsSizeAffectParent() - { - return false; - } - - Rect GuiStackItemComposition::GetBounds() - { - Rect result = bounds; - if(stackParent) - { - vint index = stackParent->stackItems.IndexOf(this); - if (index != -1) - { - result = stackParent->stackItemBounds[index]; - } - - Rect parentBounds = stackParent->previousBounds; - Margin margin = stackParent->extraMargin; - if (margin.left <= 0) margin.left = 0; - if (margin.top <= 0) margin.top = 0; - if (margin.right <= 0) margin.right = 0; - if (margin.bottom <= 0) margin.bottom = 0; - - auto x = result.Left(); - auto y = result.Top(); - auto w = result.Width(); - auto h = result.Height(); - - switch (stackParent->direction) - { - case GuiStackComposition::Horizontal: - x += margin.left + stackParent->adjustment; - y = margin.top; - h = parentBounds.Height() - margin.top - margin.bottom; - break; - case GuiStackComposition::ReversedHorizontal: - x = parentBounds.Width() - margin.right - x - w + stackParent->adjustment; - y = margin.top; - h = parentBounds.Height() - margin.top - margin.bottom; - break; - case GuiStackComposition::Vertical: - x = margin.left; - y += margin.top + stackParent->adjustment; - w = parentBounds.Width() - margin.left - margin.right; - break; - case GuiStackComposition::ReversedVertical: - x = margin.left; - y = parentBounds.Height() - margin.bottom - y - h + stackParent->adjustment; - w = parentBounds.Width() - margin.left - margin.right; - break; - } - - result = Rect( - x - extraMargin.left, - y - extraMargin.top, - x + w + extraMargin.right, - y + h + extraMargin.bottom - ); - } - UpdatePreviousBounds(result); - return result; - } - - void GuiStackItemComposition::SetBounds(Rect value) - { - bounds = value; - InvokeOnCompositionStateChanged(); - } - - Margin GuiStackItemComposition::GetExtraMargin() - { - return extraMargin; - } - - void GuiStackItemComposition::SetExtraMargin(Margin value) - { - extraMargin = value; - InvokeOnCompositionStateChanged(); - } - } - } -} - -/*********************************************************************** -GRAPHICSCOMPOSITION\GUIGRAPHICSTABLECOMPOSITION.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace compositions - { - using namespace collections; - using namespace controls; - using namespace elements; - -/*********************************************************************** -GuiTableComposition -***********************************************************************/ - - namespace update_cell_bounds_helpers - { - vint First(vint a, vint b) - { - return a; - } - - vint Second(vint a, vint b) - { - return b; - } - - vint X(Size s) - { - return s.x; - } - - vint Y(Size s) - { - return s.y; - } - - vint RL(GuiCellComposition* cell) - { - return cell->GetRow(); - } - - vint CL(GuiCellComposition* cell) - { - return cell->GetColumn(); - } - - vint RS(GuiCellComposition* cell) - { - return cell->GetRowSpan(); - } - - vint CS(GuiCellComposition* cell) - { - return cell->GetColumnSpan(); - } - } - using namespace update_cell_bounds_helpers; - - vint GuiTableComposition::GetSiteIndex(vint _rows, vint _columns, vint _row, vint _column) - { - return _row*_columns + _column; - } - - void GuiTableComposition::SetSitedCell(vint _row, vint _column, GuiCellComposition* cell) - { - cellCompositions[GetSiteIndex(rows, columns, _row, _column)] = cell; - } - - void GuiTableComposition::UpdateCellBoundsInternal( - collections::Array& dimSizes, - vint& dimSize, - vint& dimSizeWithPercentage, - collections::Array& dimOptions, - vint GuiTableComposition::* dim1, - vint GuiTableComposition::* dim2, - vint(*getSize)(Size), - vint(*getLocation)(GuiCellComposition*), - vint(*getSpan)(GuiCellComposition*), - vint(*getRow)(vint, vint), - vint(*getCol)(vint, vint), - vint maxPass - ) - { - for (vint pass = 0; pass < maxPass; pass++) - { - for (vint i = 0; i < this->*dim1; i++) - { - GuiCellOption option = dimOptions[i]; - if (pass == 0) - { - dimSizes[i] = 0; - } - switch (option.composeType) - { - case GuiCellOption::Absolute: - { - dimSizes[i] = option.absolute; - } - break; - case GuiCellOption::MinSize: - { - for (vint j = 0; j < this->*dim2; j++) - { - GuiCellComposition* cell = GetSitedCell(getRow(i, j), getCol(i, j)); - if (cell) - { - bool accept = false; - if (pass == 0) - { - accept = getSpan(cell) == 1; - } - else - { - accept = getLocation(cell) + getSpan(cell) == i + 1; - } - if (accept) - { - vint size = getSize(cell->GetPreferredBounds().GetSize()); - vint span = getSpan(cell); - for (vint k = 1; k < span; k++) - { - size -= dimSizes[i - k] + cellPadding; - } - if (dimSizes[i] < size) - { - dimSizes[i] = size; - } - } - } - } - } - break; - default:; - } - } - } - - bool percentageExists = false; - for (vint i = 0; i < this->*dim1; i++) - { - GuiCellOption option = dimOptions[i]; - if (option.composeType == GuiCellOption::Percentage) - { - if (0.001 < option.percentage) - { - percentageExists = true; - } - } - } - - if (percentageExists) - { - for (vint i = 0; i < this->*dim1; i++) - { - GuiCellOption option = dimOptions[i]; - if (option.composeType == GuiCellOption::Percentage) - { - if (0.001 < option.percentage) - { - for (vint j = 0; j < this->*dim2; j++) - { - GuiCellComposition* cell = GetSitedCell(getRow(i, j), getCol(i, j)); - if (cell) - { - vint size = getSize(cell->GetPreferredBounds().GetSize()); - vint start = getLocation(cell); - vint span = getSpan(cell); - size -= (span - 1)*cellPadding; - double totalPercentage = 0; - - for (vint k = start; k < start + span; k++) - { - if (dimOptions[k].composeType == GuiCellOption::Percentage) - { - if (0.001 < dimOptions[k].percentage) - { - totalPercentage += dimOptions[k].percentage; - } - } - else - { - size -= dimSizes[k]; - } - } - - size = (vint)ceil(size*option.percentage / totalPercentage); - if (dimSizes[i] < size) - { - dimSizes[i] = size; - } - } - } - } - } - } - - vint percentageTotalSize = 0; - for (vint i = 0; i < this->*dim1; i++) - { - GuiCellOption option = dimOptions[i]; - if (option.composeType == GuiCellOption::Percentage) - { - if (0.001 < option.percentage) - { - vint size = (vint)ceil(dimSizes[i] / option.percentage); - if (percentageTotalSize < size) - { - percentageTotalSize = size; - } - } - } - } - - double totalPercentage = 0; - for (vint i = 0; i < this->*dim1; i++) - { - GuiCellOption option = dimOptions[i]; - if (option.composeType == GuiCellOption::Percentage) - { - if (0.001 < option.percentage) - { - totalPercentage += option.percentage; - } - } - } - - for (vint i = 0; i < this->*dim1; i++) - { - GuiCellOption option = dimOptions[i]; - if (option.composeType == GuiCellOption::Percentage) - { - if (0.001 < option.percentage) - { - vint size = (vint)ceil(percentageTotalSize*option.percentage / totalPercentage); - if (dimSizes[i] < size) - { - dimSizes[i] = size; - } - } - } - } - } - - for (vint i = 0; i < this->*dim1; i++) - { - if (dimOptions[i].composeType != GuiCellOption::Percentage) - { - dimSize += dimSizes[i]; - } - dimSizeWithPercentage += dimSizes[i]; - } - } - - void GuiTableComposition::UpdateCellBoundsPercentages( - collections::Array& dimSizes, - vint dimSize, - vint maxDimSize, - collections::Array& dimOptions - ) - { - if (maxDimSize > dimSize) - { - double totalPercentage = 0; - vint percentageCount = 0; - for (vint i = 0; i < dimOptions.Count(); i++) - { - GuiCellOption option = dimOptions[i]; - if (option.composeType == GuiCellOption::Percentage) - { - totalPercentage += option.percentage; - percentageCount++; - } - } - if (percentageCount > 0 && totalPercentage > 0.001) - { - for (vint i = 0; i < dimOptions.Count(); i++) - { - GuiCellOption option = dimOptions[i]; - if (option.composeType == GuiCellOption::Percentage) - { - dimSizes[i] = (vint)((maxDimSize - dimSize)*option.percentage / totalPercentage); - } - } - } - } - } - - vint GuiTableComposition::UpdateCellBoundsOffsets( - collections::Array& offsets, - collections::Array& sizes, - vint max - ) - { - offsets[0] = 0; - for (vint i = 1; i < offsets.Count(); i++) - { - offsets[i] = offsets[i - 1] + cellPadding + sizes[i - 1]; - } - - vint last = offsets.Count() - 1; - vint right = offsets[last] + sizes[last]; - return max - right; - } - - void GuiTableComposition::UpdateCellBoundsInternal() - { - rowOffsets.Resize(rows); - rowSizes.Resize(rows); - columnOffsets.Resize(columns); - columnSizes.Resize(columns); - { - vint rowTotal = (rows - 1)*cellPadding; - vint columnTotal = (columns - 1)*cellPadding; - vint rowTotalWithPercentage = rowTotal; - vint columnTotalWithPercentage = columnTotal; - - UpdateCellBoundsInternal( - rowSizes, - rowTotal, - rowTotalWithPercentage, - rowOptions, - &GuiTableComposition::rows, - &GuiTableComposition::columns, - &Y, - &RL, - &RS, - &First, - &Second, - 1 - ); - UpdateCellBoundsInternal( - columnSizes, - columnTotal, - columnTotalWithPercentage, - columnOptions, - &GuiTableComposition::columns, - &GuiTableComposition::rows, - &X, - &CL, - &CS, - &Second, - &First, - 1 - ); - - Rect area = GetCellArea(); - UpdateCellBoundsPercentages(rowSizes, rowTotal, area.Height(), rowOptions); - UpdateCellBoundsPercentages(columnSizes, columnTotal, area.Width(), columnOptions); - rowExtending = UpdateCellBoundsOffsets(rowOffsets, rowSizes, area.Height()); - columnExtending = UpdateCellBoundsOffsets(columnOffsets, columnSizes, area.Width()); - - for (vint i = 0; i < rows; i++) - { - for (vint j = 0; j < columns; j++) - { - vint index = GetSiteIndex(rows, columns, i, j); - cellBounds[index] = Rect(Point(columnOffsets[j], rowOffsets[i]), Size(columnSizes[j], rowSizes[i])); - } - } - } - } - - void GuiTableComposition::UpdateTableContentMinSize() - { - Array rowSizes, columnSizes; - rowSizes.Resize(rows); - columnSizes.Resize(columns); - { - vint rowTotal = (rows - 1) * cellPadding; - vint columnTotal = (columns - 1) * cellPadding; - vint rowTotalWithPercentage = rowTotal; - vint columnTotalWithPercentage = columnTotal; - - UpdateCellBoundsInternal( - rowSizes, - rowTotal, - rowTotalWithPercentage, - rowOptions, - &GuiTableComposition::rows, - &GuiTableComposition::columns, - &Y, - &RL, - &RS, - &First, - &Second, - 2 - ); - UpdateCellBoundsInternal( - columnSizes, - columnTotal, - columnTotalWithPercentage, - columnOptions, - &GuiTableComposition::columns, - &GuiTableComposition::rows, - &X, - &CL, - &CS, - &Second, - &First, - 2 - ); - tableContentMinSize = Size(columnTotalWithPercentage, rowTotalWithPercentage); - } - if (previousContentMinSize != tableContentMinSize) - { - previousContentMinSize = tableContentMinSize; - UpdateCellBoundsInternal(); - InvokeOnCompositionStateChanged(); - } - } - - void GuiTableComposition::OnRenderContextChanged() - { - if(GetRenderTarget()) - { - UpdateTableContentMinSize(); - } - } - - GuiTableComposition::GuiTableComposition() - :rows(0) - , columns(0) - , cellPadding(0) - , borderVisible(true) - , rowExtending(0) - , columnExtending(0) - { - ConfigChanged.SetAssociatedComposition(this); - SetRowsAndColumns(1, 1); - } - - GuiTableComposition::~GuiTableComposition() - { - } - - vint GuiTableComposition::GetRows() - { - return rows; - } - - vint GuiTableComposition::GetColumns() - { - return columns; - } - - bool GuiTableComposition::SetRowsAndColumns(vint _rows, vint _columns) - { - if (_rows <= 0 || _columns <= 0) return false; - rowOptions.Resize(_rows); - columnOptions.Resize(_columns); - cellCompositions.Resize(_rows*_columns); - cellBounds.Resize(_rows*_columns); - for (vint i = 0; i < _rows*_columns; i++) - { - cellCompositions[i] = 0; - cellBounds[i] = Rect(); - } - rows = _rows; - columns = _columns; - vint childCount = Children().Count(); - for (vint i = 0; i < childCount; i++) - { - GuiCellComposition* cell = dynamic_cast(Children().Get(i)); - if (cell) - { - cell->OnTableRowsAndColumnsChanged(); - } - } - ConfigChanged.Execute(GuiEventArgs(this)); - UpdateCellBounds(); - InvokeOnCompositionStateChanged(); - return true; - } - - GuiCellComposition* GuiTableComposition::GetSitedCell(vint _row, vint _column) - { - return cellCompositions[GetSiteIndex(rows, columns, _row, _column)]; - } - - GuiCellOption GuiTableComposition::GetRowOption(vint _row) - { - return rowOptions[_row]; - } - - void GuiTableComposition::SetRowOption(vint _row, GuiCellOption option) - { - rowOptions[_row] = option; - UpdateCellBounds(); - InvokeOnCompositionStateChanged(); - ConfigChanged.Execute(GuiEventArgs(this)); - } - - GuiCellOption GuiTableComposition::GetColumnOption(vint _column) - { - return columnOptions[_column]; - } - - void GuiTableComposition::SetColumnOption(vint _column, GuiCellOption option) - { - columnOptions[_column] = option; - UpdateCellBounds(); - InvokeOnCompositionStateChanged(); - ConfigChanged.Execute(GuiEventArgs(this)); - } - - vint GuiTableComposition::GetCellPadding() - { - return cellPadding; - } - - void GuiTableComposition::SetCellPadding(vint value) - { - if (value < 0) value = 0; - cellPadding = value; - UpdateCellBounds(); - InvokeOnCompositionStateChanged(); - } - - bool GuiTableComposition::GetBorderVisible() - { - return borderVisible; - } - - void GuiTableComposition::SetBorderVisible(bool value) - { - if (borderVisible != value) - { - borderVisible = value; - UpdateCellBounds(); - InvokeOnCompositionStateChanged(); - } - } - - Rect GuiTableComposition::GetCellArea() - { - Rect bounds(Point(0, 0), GuiBoundsComposition::GetBounds().GetSize()); - vint borderThickness = borderVisible ? cellPadding : 0; - bounds.x1 += margin.left + internalMargin.left + borderThickness; - bounds.y1 += margin.top + internalMargin.top + borderThickness; - bounds.x2 -= margin.right + internalMargin.right + borderThickness; - bounds.y2 -= margin.bottom + internalMargin.bottom + borderThickness; - if (bounds.x2 < bounds.x1) bounds.x2 = bounds.x1; - if (bounds.y2 < bounds.y1) bounds.y2 = bounds.y1; - return bounds; - } - - void GuiTableComposition::UpdateCellBounds() - { - UpdateCellBoundsInternal(); - UpdateTableContentMinSize(); - } - - void GuiTableComposition::ForceCalculateSizeImmediately() - { - GuiBoundsComposition::ForceCalculateSizeImmediately(); - UpdateCellBounds(); - UpdateCellBounds(); - } - - Size GuiTableComposition::GetMinPreferredClientSize() - { - vint offset = (borderVisible ? 2 * cellPadding : 0); - return Size(tableContentMinSize.x + offset, tableContentMinSize.y + offset); - } - - Rect GuiTableComposition::GetBounds() - { - Rect result; - if (!IsAlignedToParent() && GetMinSizeLimitation() != GuiGraphicsComposition::NoLimit) - { - result = Rect(compositionBounds.LeftTop(), compositionBounds.GetSize() - Size(columnExtending, rowExtending)); - } - else - { - result = GuiBoundsComposition::GetBounds(); - } - - bool cellMinSizeModified = false; - SortedList cells; - FOREACH(GuiCellComposition*, cell, cellCompositions) - { - if (cell && !cells.Contains(cell)) - { - cells.Add(cell); - Size newSize = cell->GetPreferredBounds().GetSize(); - if (cell->lastPreferredSize != newSize) - { - cell->lastPreferredSize = newSize; - cellMinSizeModified = true; - } - } - } - - if (previousContentBounds != result || cellMinSizeModified) - { - previousContentBounds = result; - UpdateCellBounds(); - InvokeOnCompositionStateChanged(); - } - return result; - } - -/*********************************************************************** -GuiCellComposition -***********************************************************************/ - - void GuiCellComposition::ClearSitedCells(GuiTableComposition* table) - { - if (row != -1 && column != -1) - { - for (vint r = 0; r < rowSpan; r++) - { - for (vint c = 0; c < columnSpan; c++) - { - table->SetSitedCell(row + r, column + c, 0); - } - } - } - } - - void GuiCellComposition::SetSitedCells(GuiTableComposition* table) - { - for (vint r = 0; r < rowSpan; r++) - { - for (vint c = 0; c < columnSpan; c++) - { - table->SetSitedCell(row + r, column + c, this); - } - } - } - - void GuiCellComposition::ResetSiteInternal() - { - row = -1; - column = -1; - rowSpan = 1; - columnSpan = 1; - } - - bool GuiCellComposition::SetSiteInternal(vint _row, vint _column, vint _rowSpan, vint _columnSpan) - { - if (tableParent) - { - if (_row < 0 || _row >= tableParent->rows || _column < 0 || _column >= tableParent->columns) return false; - if (_rowSpan<1 || _row + _rowSpan>tableParent->rows || _columnSpan<1 || _column + _columnSpan>tableParent->columns) return false; - - for (vint r = 0; r < _rowSpan; r++) - { - for (vint c = 0; c < _columnSpan; c++) - { - GuiCellComposition* cell = tableParent->GetSitedCell(_row + r, _column + c); - if (cell && cell != this) - { - return false; - } - } - } - ClearSitedCells(tableParent); - } - - row = _row; - column = _column; - rowSpan = _rowSpan; - columnSpan = _columnSpan; - - if (tableParent) - { - SetSitedCells(tableParent); - } - return true; - } - - void GuiCellComposition::OnParentChanged(GuiGraphicsComposition* oldParent, GuiGraphicsComposition* newParent) - { - GuiGraphicsSite::OnParentChanged(oldParent, newParent); - if (tableParent) - { - ClearSitedCells(tableParent); - } - tableParent = dynamic_cast(newParent); - if (!tableParent || !SetSiteInternal(row, column, rowSpan, columnSpan)) - { - ResetSiteInternal(); - } - if (tableParent) - { - if (row != -1 && column != -1) - { - SetSiteInternal(row, column, rowSpan, columnSpan); - } - tableParent->UpdateCellBounds(); - } - } - - void GuiCellComposition::OnTableRowsAndColumnsChanged() - { - if(!SetSiteInternal(row, column, rowSpan, columnSpan)) - { - ResetSiteInternal(); - } - } - - GuiCellComposition::GuiCellComposition() - :row(-1) - ,column(-1) - ,rowSpan(1) - ,columnSpan(1) - ,tableParent(0) - { - SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); - } - - GuiCellComposition::~GuiCellComposition() - { - } - - GuiTableComposition* GuiCellComposition::GetTableParent() - { - return tableParent; - } - - vint GuiCellComposition::GetRow() - { - return row; - } - - vint GuiCellComposition::GetRowSpan() - { - return rowSpan; - } - - vint GuiCellComposition::GetColumn() - { - return column; - } - - vint GuiCellComposition::GetColumnSpan() - { - return columnSpan; - } - - bool GuiCellComposition::SetSite(vint _row, vint _column, vint _rowSpan, vint _columnSpan) - { - if(SetSiteInternal(_row, _column, _rowSpan, _columnSpan)) - { - if (tableParent) - { - tableParent->UpdateCellBounds(); - } - InvokeOnCompositionStateChanged(); - return true; - } - else - { - return false; - } - } - - Rect GuiCellComposition::GetBounds() - { - Rect result; - if(tableParent && row!=-1 && column!=-1) - { - Rect bounds1, bounds2; - { - vint index=tableParent->GetSiteIndex(tableParent->rows, tableParent->columns, row, column); - bounds1=tableParent->cellBounds[index]; - } - { - vint index=tableParent->GetSiteIndex(tableParent->rows, tableParent->columns, row+rowSpan-1, column+columnSpan-1); - bounds2=tableParent->cellBounds[index]; - if(tableParent->GetMinSizeLimitation()==GuiGraphicsComposition::NoLimit) - { - if(row+rowSpan==tableParent->rows) - { - bounds2.y2+=tableParent->rowExtending; - } - if(column+columnSpan==tableParent->columns) - { - bounds2.x2+=tableParent->columnExtending; - } - } - } - vint offset = tableParent->borderVisible ? tableParent->cellPadding : 0; - result = Rect(bounds1.x1 + offset, bounds1.y1 + offset, bounds2.x2 + offset, bounds2.y2 + offset); - } - else - { - result = Rect(); - } - UpdatePreviousBounds(result); - return result; - } - -/*********************************************************************** -GuiTableSplitterCompositionBase -***********************************************************************/ - - void GuiTableSplitterCompositionBase::OnParentChanged(GuiGraphicsComposition* oldParent, GuiGraphicsComposition* newParent) - { - GuiGraphicsSite::OnParentChanged(oldParent, newParent); - tableParent = dynamic_cast(newParent); - } - - void GuiTableSplitterCompositionBase::OnLeftButtonDown(GuiGraphicsComposition* sender, GuiMouseEventArgs& arguments) - { - dragging = true; - draggingPoint = Point(arguments.x, arguments.y); - } - - void GuiTableSplitterCompositionBase::OnLeftButtonUp(GuiGraphicsComposition* sender, GuiMouseEventArgs& arguments) - { - dragging = false; - } - - void GuiTableSplitterCompositionBase::OnMouseMoveHelper( - vint cellsBefore, - vint GuiTableComposition::* cells, - collections::Array& cellSizes, - vint offset, - GuiCellOption(GuiTableComposition::*getOption)(vint), - void(GuiTableComposition::*setOption)(vint, GuiCellOption) - ) - { - if (dragging) - { - if (tableParent) - { - if (0 < cellsBefore && cellsBefore < tableParent->*cells) - { - auto o1 = (tableParent->*getOption)(cellsBefore - 1); - auto o2 = (tableParent->*getOption)(cellsBefore); - - vint indexStart = -1; - vint indexEnd = -1; - vint indexStep = -1; - vint max = 0; - - if (offset < 0) - { - indexStart = cellsBefore - 1; - indexEnd = -1; - indexStep = -1; - } - else if (offset > 0) - { - indexStart = cellsBefore; - indexEnd = tableParent->*cells; - indexStep = 1; - } - else - { - return; - } - - { - auto o = (tableParent->*getOption)(indexStart); - if (o.composeType == GuiCellOption::Absolute) - { - max = o.absolute - 1; - } - else - { - for (vint i = indexStart; i != indexEnd; i += indexStep) - { - o = (tableParent->*getOption)(i); - if (o.composeType == GuiCellOption::Absolute) - { - break; - } - else if (o.composeType == GuiCellOption::Percentage) - { - max += cellSizes[i] - 1; - } - } - } - - if (max <= 0) - { - return; - } - } - - if (offset < 0) - { - if (max < -offset) - { - offset = -max; - } - } - else - { - if (max < offset) - { - offset = max; - } - } - - if (o1.composeType == GuiCellOption::Absolute) - { - o1.absolute += offset; - (tableParent->*setOption)(cellsBefore - 1, o1); - } - if (o2.composeType == GuiCellOption::Absolute) - { - o2.absolute -= offset; - (tableParent->*setOption)(cellsBefore, o2); - } - tableParent->ForceCalculateSizeImmediately(); - } - } - } - } - - Rect GuiTableSplitterCompositionBase::GetBoundsHelper( - vint cellsBefore, - vint GuiTableComposition::* cells, - vint(Rect::* dimSize)()const, - collections::Array& cellOffsets, - vint Rect::* dimU1, - vint Rect::* dimU2, - vint Rect::* dimV1, - vint Rect::* dimV2 - ) - { - Rect result(0, 0, 0, 0); - if (tableParent) - { - if (0 < cellsBefore && cellsBefore < tableParent->*cells) - { - vint offset = tableParent->borderVisible ? tableParent->cellPadding : 0; - result.*dimU1 = offset; - result.*dimU2 = offset + (tableParent->GetCellArea().*dimSize)(); - result.*dimV1 = offset + cellOffsets[cellsBefore] - tableParent->cellPadding; - result.*dimV2 = (result.*dimV1) + tableParent->cellPadding; - } - } - UpdatePreviousBounds(result); - return result; - } - - GuiTableSplitterCompositionBase::GuiTableSplitterCompositionBase() - :tableParent(0) - , dragging(false) - { - SetAssociatedCursor(GetCurrentController()->ResourceService()->GetSystemCursor(INativeCursor::SizeNS)); - GetEventReceiver()->leftButtonDown.AttachMethod(this, &GuiTableSplitterCompositionBase::OnLeftButtonDown); - GetEventReceiver()->leftButtonUp.AttachMethod(this, &GuiTableSplitterCompositionBase::OnLeftButtonUp); - } - - GuiTableSplitterCompositionBase::~GuiTableSplitterCompositionBase() - { - } - - GuiTableComposition* GuiTableSplitterCompositionBase::GetTableParent() - { - return tableParent; - } - -/*********************************************************************** -GuiRowSplitterComposition -***********************************************************************/ - - void GuiRowSplitterComposition::OnMouseMove(GuiGraphicsComposition* sender, GuiMouseEventArgs& arguments) - { - OnMouseMoveHelper( - rowsToTheTop, - &GuiTableComposition::rows, - tableParent->rowSizes, - arguments.y - draggingPoint.y, - &GuiTableComposition::GetRowOption, - &GuiTableComposition::SetRowOption - ); - } - - GuiRowSplitterComposition::GuiRowSplitterComposition() - :rowsToTheTop(0) - { - SetAssociatedCursor(GetCurrentController()->ResourceService()->GetSystemCursor(INativeCursor::SizeNS)); - GetEventReceiver()->mouseMove.AttachMethod(this, &GuiRowSplitterComposition::OnMouseMove); - } - - GuiRowSplitterComposition::~GuiRowSplitterComposition() - { - } - - vint GuiRowSplitterComposition::GetRowsToTheTop() - { - return rowsToTheTop; - } - - void GuiRowSplitterComposition::SetRowsToTheTop(vint value) - { - rowsToTheTop = value; - InvokeOnCompositionStateChanged(); - } - - Rect GuiRowSplitterComposition::GetBounds() - { - return GetBoundsHelper( - rowsToTheTop, - &GuiTableComposition::rows, - &Rect::Width, - tableParent->rowOffsets, - &Rect::x1, - &Rect::x2, - &Rect::y1, - &Rect::y2 - ); - } - -/*********************************************************************** -GuiColumnSplitterComposition -***********************************************************************/ - - void GuiColumnSplitterComposition::OnMouseMove(GuiGraphicsComposition* sender, GuiMouseEventArgs& arguments) - { - OnMouseMoveHelper( - columnsToTheLeft, - &GuiTableComposition::columns, - tableParent->columnSizes, - arguments.x - draggingPoint.x, - &GuiTableComposition::GetColumnOption, - &GuiTableComposition::SetColumnOption - ); - } - - GuiColumnSplitterComposition::GuiColumnSplitterComposition() - :columnsToTheLeft(0) - { - SetAssociatedCursor(GetCurrentController()->ResourceService()->GetSystemCursor(INativeCursor::SizeWE)); - GetEventReceiver()->mouseMove.AttachMethod(this, &GuiColumnSplitterComposition::OnMouseMove); - } - - GuiColumnSplitterComposition::~GuiColumnSplitterComposition() - { - } - - vint GuiColumnSplitterComposition::GetColumnsToTheLeft() - { - return columnsToTheLeft; - } - - void GuiColumnSplitterComposition::SetColumnsToTheLeft(vint value) - { - columnsToTheLeft = value; - InvokeOnCompositionStateChanged(); - } - - Rect GuiColumnSplitterComposition::GetBounds() - { - return GetBoundsHelper( - columnsToTheLeft, - &GuiTableComposition::columns, - &Rect::Height, - tableParent->columnOffsets, - &Rect::y1, - &Rect::y2, - &Rect::x1, - &Rect::x2 - ); - } - } - } -} - -/*********************************************************************** -GRAPHICSELEMENT\GUIGRAPHICSDOCUMENTELEMENT.CPP -***********************************************************************/ - -namespace vl -{ - using namespace collections; - - namespace presentation - { - namespace elements - { - -/*********************************************************************** -SetPropertiesVisitor -***********************************************************************/ - - namespace visitors - { - class SetPropertiesVisitor : public Object, public DocumentRun::IVisitor - { - typedef GuiDocumentElement::GuiDocumentElementRenderer Renderer; - typedef DocumentModel::ResolvedStyle ResolvedStyle; - public: - vint start; - vint length; - vint selectionBegin; - vint selectionEnd; - List styles; - - DocumentModel* model; - Renderer* renderer; - Ptr cache; - IGuiGraphicsParagraph* paragraph; - - SetPropertiesVisitor(DocumentModel* _model, Renderer* _renderer, Ptr _cache, vint _selectionBegin, vint _selectionEnd) - :start(0) - ,length(0) - ,model(_model) - ,renderer(_renderer) - ,cache(_cache) - ,paragraph(_cache->graphicsParagraph.Obj()) - ,selectionBegin(_selectionBegin) - ,selectionEnd(_selectionEnd) - { - ResolvedStyle style; - style=model->GetStyle(DocumentModel::DefaultStyleName, style); - styles.Add(style); - } - - void VisitContainer(DocumentContainerRun* run) - { - FOREACH(Ptr, subRun, run->runs) - { - subRun->Accept(this); - } - } - - void ApplyStyle(vint start, vint length, const ResolvedStyle& style) - { - paragraph->SetFont(start, length, style.style.fontFamily); - paragraph->SetSize(start, length, style.style.size); - paragraph->SetStyle(start, length, - (IGuiGraphicsParagraph::TextStyle) - ( (style.style.bold?IGuiGraphicsParagraph::Bold:0) - | (style.style.italic?IGuiGraphicsParagraph::Italic:0) - | (style.style.underline?IGuiGraphicsParagraph::Underline:0) - | (style.style.strikeline?IGuiGraphicsParagraph::Strikeline:0) - )); - } - - void ApplyColor(vint start, vint length, const ResolvedStyle& style) - { - paragraph->SetColor(start, length, style.color); - paragraph->SetBackgroundColor(start, length, style.backgroundColor); - } - - void Visit(DocumentTextRun* run)override - { - length=run->GetRepresentationText().Length(); - if(length>0) - { - ResolvedStyle style=styles[styles.Count()-1]; - ApplyStyle(start, length, style); - ApplyColor(start, length, style); - - vint styleStart=start; - vint styleEnd=styleStart+length; - if(styleStartselectionBegin?styleStart:selectionBegin; - vint s3=selectionEndGetStyle(DocumentModel::SelectionStyleName, style); - ApplyColor(s2, s3-s2, selectionStyle); - } - } - } - start+=length; - } - - void Visit(DocumentStylePropertiesRun* run)override - { - ResolvedStyle style=styles[styles.Count()-1]; - style=model->GetStyle(run->style, style); - styles.Add(style); - VisitContainer(run); - styles.RemoveAt(styles.Count()-1); - } - - void Visit(DocumentStyleApplicationRun* run)override - { - ResolvedStyle style=styles[styles.Count()-1]; - style=model->GetStyle(run->styleName, style); - styles.Add(style); - VisitContainer(run); - styles.RemoveAt(styles.Count()-1); - } - - void Visit(DocumentHyperlinkRun* run)override - { - ResolvedStyle style=styles[styles.Count()-1]; - style=model->GetStyle(run->styleName, style); - styles.Add(style); - VisitContainer(run); - styles.RemoveAt(styles.Count()-1); - } - - void Visit(DocumentImageRun* run)override - { - length=run->GetRepresentationText().Length(); - - Ptr element=GuiImageFrameElement::Create(); - element->SetImage(run->image, run->frameIndex); - element->SetStretch(true); - - IGuiGraphicsParagraph::InlineObjectProperties properties; - properties.size=run->size; - properties.baseline=run->baseline; - properties.breakCondition=IGuiGraphicsParagraph::Alone; - properties.backgroundImage = element; - - paragraph->SetInlineObject(start, length, properties); - - if(startGetStyle(DocumentModel::SelectionStyleName, style); - ApplyColor(start, length, selectionStyle); - } - start+=length; - } - - void Visit(DocumentEmbeddedObjectRun* run)override - { - length=run->GetRepresentationText().Length(); - - IGuiGraphicsParagraph::InlineObjectProperties properties; - properties.breakCondition=IGuiGraphicsParagraph::Alone; - - if (run->name != L"") - { - vint index = renderer->nameCallbackIdMap.Keys().IndexOf(run->name); - if (index != -1) - { - auto id = renderer->nameCallbackIdMap.Values()[index]; - index = cache->embeddedObjects.Keys().IndexOf(id); - if (index != -1) - { - auto eo = cache->embeddedObjects.Values()[index]; - if (eo->start == start) - { - properties.size = eo->size; - properties.callbackId = id; - } - } - } - else - { - auto eo = MakePtr(); - eo->name = run->name; - eo->size = Size(0, 0); - eo->start = start; - - vint id = -1; - vint count = renderer->freeCallbackIds.Count(); - if (count > 0) - { - id = renderer->freeCallbackIds[count - 1]; - renderer->freeCallbackIds.RemoveAt(count - 1); - } - else - { - id = renderer->usedCallbackIds++; - } - - renderer->nameCallbackIdMap.Add(eo->name, id); - cache->embeddedObjects.Add(id, eo); - properties.callbackId = id; - } - } - - paragraph->SetInlineObject(start, length, properties); - - if(startGetStyle(DocumentModel::SelectionStyleName, style); - ApplyColor(start, length, selectionStyle); - } - start+=length; - } - - void Visit(DocumentParagraphRun* run)override - { - VisitContainer(run); - } - - static vint SetProperty(DocumentModel* model, Renderer* renderer, Ptr cache, Ptr run, vint selectionBegin, vint selectionEnd) - { - SetPropertiesVisitor visitor(model, renderer, cache, selectionBegin, selectionEnd); - run->Accept(&visitor); - return visitor.length; - } - }; - } - using namespace visitors; - -/*********************************************************************** -GuiDocumentElement::GuiDocumentElementRenderer -***********************************************************************/ - - Size GuiDocumentElement::GuiDocumentElementRenderer::OnRenderInlineObject(vint callbackId, Rect location) - { - if (element->callback) - { - auto cache = paragraphCaches[renderingParagraph]; - auto relativeLocation = Rect(Point(location.x1 + renderingParagraphOffset.x, location.y1 + renderingParagraphOffset.y), location.GetSize()); - auto eo = cache->embeddedObjects[callbackId]; - auto size = element->callback->OnRenderEmbeddedObject(eo->name, relativeLocation); - eo->resized = eo->size != size; - eo->size = size; - return eo->size; - } - else - { - return Size(); - } - } - - void GuiDocumentElement::GuiDocumentElementRenderer::InitializeInternal() - { - } - - void GuiDocumentElement::GuiDocumentElementRenderer::FinalizeInternal() - { - } - - void GuiDocumentElement::GuiDocumentElementRenderer::RenderTargetChangedInternal(IGuiGraphicsRenderTarget* oldRenderTarget, IGuiGraphicsRenderTarget* newRenderTarget) - { - for(vint i=0;igraphicsParagraph=0; - } - } - } - - Ptr GuiDocumentElement::GuiDocumentElementRenderer::EnsureAndGetCache(vint paragraphIndex, bool createParagraph) - { - if(paragraphIndex<0 || paragraphIndex>=paragraphCaches.Count()) return 0; - Ptr paragraph=element->document->paragraphs[paragraphIndex]; - Ptr cache=paragraphCaches[paragraphIndex]; - if(!cache) - { - cache=new ParagraphCache; - cache->fullText=paragraph->GetText(false); - paragraphCaches[paragraphIndex]=cache; - } - - if(createParagraph) - { - if(!cache->graphicsParagraph) - { - cache->graphicsParagraph=layoutProvider->CreateParagraph(cache->fullText, renderTarget, this); - cache->graphicsParagraph->SetParagraphAlignment(paragraph->alignment ? paragraph->alignment.Value() : Alignment::Left); - SetPropertiesVisitor::SetProperty(element->document.Obj(), this, cache, paragraph, cache->selectionBegin, cache->selectionEnd); - } - if(cache->graphicsParagraph->GetMaxWidth()!=lastMaxWidth) - { - cache->graphicsParagraph->SetMaxWidth(lastMaxWidth); - } - - vint paragraphHeight=paragraphHeights[paragraphIndex]; - vint height=cache->graphicsParagraph->GetHeight(); - if(paragraphHeight!=height) - { - cachedTotalHeight+=height-paragraphHeight; - paragraphHeight=height; - paragraphHeights[paragraphIndex]=paragraphHeight; - minSize=Size(0, cachedTotalHeight); - } - } - - return cache; - } - - bool GuiDocumentElement::GuiDocumentElementRenderer::GetParagraphIndexFromPoint(Point point, vint& top, vint& index) - { - vint y=0; - for(vint i=0;iGetLayoutProvider()) - ,lastCaret(-1, -1) - ,lastCaretFrontSide(false) - { - } - - void GuiDocumentElement::GuiDocumentElementRenderer::Render(Rect bounds) - { - if (element->callback) - { - element->callback->OnStartRender(); - } - renderTarget->PushClipper(bounds); - if(!renderTarget->IsClipperCoverWholeTarget()) - { - vint maxWidth=bounds.Width(); - Rect clipper=renderTarget->GetClipper(); - vint cx=bounds.Left(); - vint cy=bounds.Top(); - vint y1=clipper.Top()-bounds.Top(); - vint y2=y1+clipper.Height(); - vint y=0; - - lastMaxWidth=maxWidth; - - for(vint i=0;i=y2) - { - break; - } - else - { - Ptr paragraph=element->document->paragraphs[i]; - Ptr cache=paragraphCaches[i]; - bool created=cache && cache->graphicsParagraph; - cache=EnsureAndGetCache(i, true); - if(!created && i==lastCaret.row && element->caretVisible) - { - cache->graphicsParagraph->OpenCaret(lastCaret.column, lastCaretColor, lastCaretFrontSide); - } - - paragraphHeight=cache->graphicsParagraph->GetHeight(); - - renderingParagraph = i; - renderingParagraphOffset = Point(cx - bounds.x1, cy + y - bounds.y1); - cache->graphicsParagraph->Render(Rect(Point(cx, cy+y), Size(maxWidth, paragraphHeight))); - renderingParagraph = -1; - - bool resized = false; - for (vint j = 0; j < cache->embeddedObjects.Count(); j++) - { - auto eo = cache->embeddedObjects.Values()[j]; - if (eo->resized) - { - eo->resized = false; - resized = true; - } - } - - if (resized) - { - cache->graphicsParagraph = 0; - } - } - - y+=paragraphHeight+paragraphDistance; - } - } - renderTarget->PopClipper(); - if (element->callback) - { - element->callback->OnFinishRender(); - } - } - - void GuiDocumentElement::GuiDocumentElementRenderer::OnElementStateChanged() - { - if (element->document && element->document->paragraphs.Count() > 0) - { - vint defaultSize = GetCurrentController()->ResourceService()->GetDefaultFont().size; - paragraphDistance = defaultSize; - vint defaultHeight = defaultSize; - - paragraphCaches.Resize(element->document->paragraphs.Count()); - paragraphHeights.Resize(element->document->paragraphs.Count()); - - for (vint i = 0; i < paragraphCaches.Count(); i++) - { - paragraphCaches[i] = 0; - } - for (vint i = 0; i < paragraphHeights.Count(); i++) - { - paragraphHeights[i] = defaultHeight; - } - - cachedTotalHeight = paragraphHeights.Count() * (defaultHeight + paragraphDistance); - if (paragraphHeights.Count()>0) - { - cachedTotalHeight -= paragraphDistance; - } - minSize = Size(0, cachedTotalHeight); - } - else - { - paragraphCaches.Resize(0); - paragraphHeights.Resize(0); - cachedTotalHeight = 0; - minSize = Size(0, 0); - } - - nameCallbackIdMap.Clear(); - freeCallbackIds.Clear(); - usedCallbackIds = 0; - } - - void GuiDocumentElement::GuiDocumentElementRenderer::NotifyParagraphUpdated(vint index, vint oldCount, vint newCount, bool updatedText) - { - if (0 <= index && index < paragraphCaches.Count() && 0 <= oldCount && index + oldCount <= paragraphCaches.Count() && 0 <= newCount) - { - vint paragraphCount = element->document->paragraphs.Count(); - CHECK_ERROR(updatedText || oldCount == newCount, L"GuiDocumentlement::GuiDocumentElementRenderer::NotifyParagraphUpdated(vint, vint, vint, bool)#Illegal values of oldCount and newCount."); - CHECK_ERROR(paragraphCount - paragraphCaches.Count() == newCount - oldCount, L"GuiDocumentElement::GuiDocumentElementRenderer::NotifyParagraphUpdated(vint, vint, vint, bool)#Illegal values of oldCount and newCount."); - - ParagraphCacheArray oldCaches; - CopyFrom(oldCaches, paragraphCaches); - paragraphCaches.Resize(paragraphCount); - - ParagraphHeightArray oldHeights; - CopyFrom(oldHeights, paragraphHeights); - paragraphHeights.Resize(paragraphCount); - - vint defaultHeight = GetCurrentController()->ResourceService()->GetDefaultFont().size; - cachedTotalHeight = 0; - - for (vint i = 0; i < paragraphCount; i++) - { - if (i < index) - { - paragraphCaches[i] = oldCaches[i]; - paragraphHeights[i] = oldHeights[i]; - } - else if (i < index + newCount) - { - paragraphCaches[i] = 0; - paragraphHeights[i] = defaultHeight; - if (!updatedText && i < index + oldCount) - { - auto cache = oldCaches[i]; - if(cache) - { - cache->graphicsParagraph = 0; - } - paragraphCaches[i] = cache; - paragraphHeights[i] = oldHeights[i]; - } - } - else - { - paragraphCaches[i] = oldCaches[i - (newCount - oldCount)]; - paragraphHeights[i] = oldHeights[i - (newCount - oldCount)]; - } - cachedTotalHeight += paragraphHeights[i] + paragraphDistance; - } - if (paragraphCount > 0) - { - cachedTotalHeight -= paragraphDistance; - } - - if (updatedText) - { - vint count = oldCount < newCount ? oldCount : newCount; - for (vint i = 0; i < count; i++) - { - if (auto cache = oldCaches[index + i]) - { - for (vint j = 0; j < cache->embeddedObjects.Count(); j++) - { - auto id = cache->embeddedObjects.Keys()[j]; - auto name = cache->embeddedObjects.Values()[j]->name; - nameCallbackIdMap.Remove(name); - freeCallbackIds.Add(id); - } - } - } - } - } - } - - Ptr GuiDocumentElement::GuiDocumentElementRenderer::GetHyperlinkFromPoint(Point point) - { - vint top=0; - vint index=-1; - if(GetParagraphIndexFromPoint(point, top, index)) - { - Ptr cache=EnsureAndGetCache(index, true); - Point paragraphPoint(point.x, point.y-top); - - vint start=-1; - vint length=0; - if(cache->graphicsParagraph->GetInlineObjectFromPoint(paragraphPoint, start, length)) - { - return element->document->GetHyperlink(index, start, start+length); - } - - vint caret=cache->graphicsParagraph->GetCaretFromPoint(paragraphPoint); - return element->document->GetHyperlink(index, caret, caret); - } - return 0; - } - - void GuiDocumentElement::GuiDocumentElementRenderer::OpenCaret(TextPos caret, Color color, bool frontSide) - { - CloseCaret(caret); - lastCaret=caret; - lastCaretColor=color; - lastCaretFrontSide=frontSide; - - Ptr cache=paragraphCaches[lastCaret.row]; - if(cache && cache->graphicsParagraph) - { - cache->graphicsParagraph->OpenCaret(lastCaret.column, lastCaretColor, lastCaretFrontSide); - } - } - - void GuiDocumentElement::GuiDocumentElementRenderer::CloseCaret(TextPos caret) - { - if(lastCaret!=TextPos(-1, -1)) - { - if(0<=lastCaret.row && lastCaret.row cache=paragraphCaches[lastCaret.row]; - if(cache && cache->graphicsParagraph) - { - cache->graphicsParagraph->CloseCaret(); - } - } - } - lastCaret=caret; - } - - void GuiDocumentElement::GuiDocumentElementRenderer::SetSelection(TextPos begin, TextPos end) - { - if(begin>end) - { - TextPos t=begin; - begin=end; - end=t; - } - if(begin==end) - { - begin=TextPos(-1, -1); - end=TextPos(-1, -1); - } - - for(vint i=0;i cache=EnsureAndGetCache(i, false); - vint newBegin=i==begin.row?begin.column:0; - vint newEnd=i==end.row?end.column:cache->fullText.Length(); - - if(cache->selectionBegin!=newBegin || cache->selectionEnd!=newEnd) - { - cache->selectionBegin=newBegin; - cache->selectionEnd=newEnd; - NotifyParagraphUpdated(i, 1, 1, false); - } - } - else - { - Ptr cache=paragraphCaches[i]; - if(cache) - { - if(cache->selectionBegin!=-1 || cache->selectionEnd!=-1) - { - cache->selectionBegin=-1; - cache->selectionEnd=-1; - NotifyParagraphUpdated(i, 1, 1, false); - } - } - } - } - } - - TextPos GuiDocumentElement::GuiDocumentElementRenderer::CalculateCaret(TextPos comparingCaret, IGuiGraphicsParagraph::CaretRelativePosition position, bool& preferFrontSide) - { - Ptr cache=EnsureAndGetCache(comparingCaret.row, true); - if(cache) - { - switch(position) - { - case IGuiGraphicsParagraph::CaretFirst: - { - preferFrontSide=false; - vint caret=cache->graphicsParagraph->GetCaret(0, IGuiGraphicsParagraph::CaretFirst, preferFrontSide); - return TextPos(comparingCaret.row, caret); - } - case IGuiGraphicsParagraph::CaretLast: - { - preferFrontSide=true; - vint caret=cache->graphicsParagraph->GetCaret(0, IGuiGraphicsParagraph::CaretLast, preferFrontSide); - return TextPos(comparingCaret.row, caret); - } - case IGuiGraphicsParagraph::CaretLineFirst: - { - preferFrontSide=false; - vint caret=cache->graphicsParagraph->GetCaret(comparingCaret.column, IGuiGraphicsParagraph::CaretLineFirst, preferFrontSide); - return TextPos(comparingCaret.row, caret); - } - case IGuiGraphicsParagraph::CaretLineLast: - { - preferFrontSide=true; - vint caret=cache->graphicsParagraph->GetCaret(comparingCaret.column, IGuiGraphicsParagraph::CaretLineLast, preferFrontSide); - return TextPos(comparingCaret.row, caret); - } - case IGuiGraphicsParagraph::CaretMoveUp: - { - vint caret=cache->graphicsParagraph->GetCaret(comparingCaret.column, IGuiGraphicsParagraph::CaretMoveUp, preferFrontSide); - if(caret==comparingCaret.column && comparingCaret.row>0) - { - Rect caretBounds=cache->graphicsParagraph->GetCaretBounds(comparingCaret.column, preferFrontSide); - Ptr anotherCache=EnsureAndGetCache(comparingCaret.row-1, true); - vint height=anotherCache->graphicsParagraph->GetHeight(); - caret=anotherCache->graphicsParagraph->GetCaretFromPoint(Point(caretBounds.x1, height)); - return TextPos(comparingCaret.row-1, caret); - } - else - { - return TextPos(comparingCaret.row, caret); - } - } - case IGuiGraphicsParagraph::CaretMoveDown: - { - vint caret=cache->graphicsParagraph->GetCaret(comparingCaret.column, IGuiGraphicsParagraph::CaretMoveDown, preferFrontSide); - if(caret==comparingCaret.column && comparingCaret.rowgraphicsParagraph->GetCaretBounds(comparingCaret.column, preferFrontSide); - Ptr anotherCache=EnsureAndGetCache(comparingCaret.row+1, true); - caret=anotherCache->graphicsParagraph->GetCaretFromPoint(Point(caretBounds.x1, 0)); - return TextPos(comparingCaret.row+1, caret); - } - else - { - return TextPos(comparingCaret.row, caret); - } - } - case IGuiGraphicsParagraph::CaretMoveLeft: - { - preferFrontSide=false; - vint caret=cache->graphicsParagraph->GetCaret(comparingCaret.column, IGuiGraphicsParagraph::CaretMoveLeft, preferFrontSide); - if(caret==comparingCaret.column && comparingCaret.row>0) - { - Ptr anotherCache=EnsureAndGetCache(comparingCaret.row-1, true); - caret=anotherCache->graphicsParagraph->GetCaret(0, IGuiGraphicsParagraph::CaretLast, preferFrontSide); - return TextPos(comparingCaret.row-1, caret); - } - else - { - return TextPos(comparingCaret.row, caret); - } - } - case IGuiGraphicsParagraph::CaretMoveRight: - { - preferFrontSide=true; - vint caret=cache->graphicsParagraph->GetCaret(comparingCaret.column, IGuiGraphicsParagraph::CaretMoveRight, preferFrontSide); - if(caret==comparingCaret.column && comparingCaret.row anotherCache=EnsureAndGetCache(comparingCaret.row+1, true); - caret=anotherCache->graphicsParagraph->GetCaret(0, IGuiGraphicsParagraph::CaretFirst, preferFrontSide); - return TextPos(comparingCaret.row+1, caret); - } - else - { - return TextPos(comparingCaret.row, caret); - } - } - } - } - return comparingCaret; - } - - TextPos GuiDocumentElement::GuiDocumentElementRenderer::CalculateCaretFromPoint(Point point) - { - vint top=0; - vint index=-1; - if(GetParagraphIndexFromPoint(point, top, index)) - { - Ptr cache=EnsureAndGetCache(index, true); - Point paragraphPoint(point.x, point.y-top); - vint caret=cache->graphicsParagraph->GetCaretFromPoint(paragraphPoint); - return TextPos(index, caret); - } - return TextPos(-1, -1); - } - - Rect GuiDocumentElement::GuiDocumentElementRenderer::GetCaretBounds(TextPos caret, bool frontSide) - { - Ptr cache=EnsureAndGetCache(caret.row, true); - if(cache) - { - Rect bounds=cache->graphicsParagraph->GetCaretBounds(caret.column, frontSide); - if(bounds!=Rect()) - { - vint y=0; - for(vint i=0;i(); - if (elementRenderer) - { - elementRenderer->SetSelection(caretBegin, caretEnd); - if (caretVisible) - { - elementRenderer->OpenCaret(caretEnd, caretColor, caretFrontSide); - } - else - { - elementRenderer->CloseCaret(caretEnd); - } - InvokeOnCompositionStateChanged(); - } - } - - GuiDocumentElement::GuiDocumentElement() - :caretVisible(false) - ,caretFrontSide(false) - { - } - - GuiDocumentElement::ICallback* GuiDocumentElement::GetCallback() - { - return callback; - } - - void GuiDocumentElement::SetCallback(ICallback* value) - { - callback = value; - } - - Ptr GuiDocumentElement::GetDocument() - { - return document; - } - - void GuiDocumentElement::SetDocument(Ptr value) - { - document=value; - InvokeOnElementStateChanged(); - SetCaret(TextPos(), TextPos(), false); - } - - TextPos GuiDocumentElement::GetCaretBegin() - { - return caretBegin; - } - - TextPos GuiDocumentElement::GetCaretEnd() - { - return caretEnd; - } - - bool GuiDocumentElement::IsCaretEndPreferFrontSide() - { - return caretFrontSide; - } - - void GuiDocumentElement::SetCaret(TextPos begin, TextPos end, bool frontSide) - { - caretBegin=begin; - caretEnd=end; - if(caretBegincaretEnd) - { - caretFrontSide=false; - } - else - { - caretFrontSide=frontSide; - } - UpdateCaret(); - } - - bool GuiDocumentElement::GetCaretVisible() - { - return caretVisible; - } - - void GuiDocumentElement::SetCaretVisible(bool value) - { - caretVisible=value; - UpdateCaret(); - } - - Color GuiDocumentElement::GetCaretColor() - { - return caretColor; - } - - void GuiDocumentElement::SetCaretColor(Color value) - { - caretColor=value; - UpdateCaret(); - } - - TextPos GuiDocumentElement::CalculateCaret(TextPos comparingCaret, IGuiGraphicsParagraph::CaretRelativePosition position, bool& preferFrontSide) - { - Ptr elementRenderer=renderer.Cast(); - if(elementRenderer) - { - TextPos caret=elementRenderer->CalculateCaret(comparingCaret, position, preferFrontSide); - return caret.column==-1?comparingCaret:caret; - } - else - { - return comparingCaret; - } - } - - TextPos GuiDocumentElement::CalculateCaretFromPoint(Point point) - { - Ptr elementRenderer=renderer.Cast(); - if(elementRenderer) - { - return elementRenderer->CalculateCaretFromPoint(point); - } - else - { - return TextPos(0, 0); - } - } - - Rect GuiDocumentElement::GetCaretBounds(TextPos caret, bool frontSide) - { - Ptr elementRenderer=renderer.Cast(); - if(elementRenderer) - { - return elementRenderer->GetCaretBounds(caret, frontSide); - } - else - { - return Rect(); - } - } - - void GuiDocumentElement::NotifyParagraphUpdated(vint index, vint oldCount, vint newCount, bool updatedText) - { - auto elementRenderer = renderer.Cast(); - if (elementRenderer) - { - elementRenderer->NotifyParagraphUpdated(index, oldCount, newCount, updatedText); - InvokeOnCompositionStateChanged(); - } - } - - void GuiDocumentElement::EditRun(TextPos begin, TextPos end, Ptr model, bool copy) - { - auto elementRenderer = renderer.Cast(); - if (elementRenderer) - { - if (begin > end) - { - TextPos temp = begin; - begin = end; - end = temp; - } - - vint newRows = document->EditRun(begin, end, model, copy); - if (newRows != -1) - { - elementRenderer->NotifyParagraphUpdated(begin.row, end.row - begin.row + 1, newRows, true); - } - InvokeOnCompositionStateChanged(); - } - } - - void GuiDocumentElement::EditText(TextPos begin, TextPos end, bool frontSide, const collections::Array& text) - { - auto elementRenderer = renderer.Cast(); - if (elementRenderer) - { - if (begin > end) - { - TextPos temp = begin; - begin = end; - end = temp; - } - - vint newRows = document->EditText(begin, end, frontSide, text); - if (newRows != -1) - { - elementRenderer->NotifyParagraphUpdated(begin.row, end.row - begin.row + 1, newRows, true); - } - InvokeOnCompositionStateChanged(); - } - } - - void GuiDocumentElement::EditStyle(TextPos begin, TextPos end, Ptr style) - { - auto elementRenderer = renderer.Cast(); - if (elementRenderer) - { - if (begin > end) - { - TextPos temp = begin; - begin = end; - end = temp; - } - - if (document->EditStyle(begin, end, style)) - { - elementRenderer->NotifyParagraphUpdated(begin.row, end.row - begin.row + 1, end.row - begin.row + 1, false); - } - InvokeOnCompositionStateChanged(); - } - } - - void GuiDocumentElement::EditImage(TextPos begin, TextPos end, Ptr image) - { - auto elementRenderer = renderer.Cast(); - if (elementRenderer) - { - if (begin > end) - { - TextPos temp = begin; - begin = end; - end = temp; - } - - if (document->EditImage(begin, end, image)) - { - elementRenderer->NotifyParagraphUpdated(begin.row, end.row - begin.row + 1, 1, true); - } - InvokeOnCompositionStateChanged(); - } - } - - void GuiDocumentElement::EditHyperlink(vint paragraphIndex, vint begin, vint end, const WString& reference, const WString& normalStyleName, const WString& activeStyleName) - { - auto elementRenderer = renderer.Cast(); - if (elementRenderer) - { - if (begin > end) - { - vint temp = begin; - begin = end; - end = temp; - } - - if (document->EditHyperlink(paragraphIndex, begin, end, reference, normalStyleName, activeStyleName)) - { - elementRenderer->NotifyParagraphUpdated(paragraphIndex, 1, 1, false); - } - InvokeOnCompositionStateChanged(); - } - } - - void GuiDocumentElement::RemoveHyperlink(vint paragraphIndex, vint begin, vint end) - { - auto elementRenderer = renderer.Cast(); - if (elementRenderer) - { - if (begin > end) - { - vint temp = begin; - begin = end; - end = temp; - } - - if (document->RemoveHyperlink(paragraphIndex, begin, end)) - { - elementRenderer->NotifyParagraphUpdated(paragraphIndex, 1, 1, false); - } - InvokeOnCompositionStateChanged(); - } - } - - void GuiDocumentElement::EditStyleName(TextPos begin, TextPos end, const WString& styleName) - { - auto elementRenderer = renderer.Cast(); - if (elementRenderer) - { - if (begin > end) - { - TextPos temp = begin; - begin = end; - end = temp; - } - - if (document->EditStyleName(begin, end, styleName)) - { - elementRenderer->NotifyParagraphUpdated(begin.row, end.row - begin.row + 1, end.row - begin.row + 1, false); - } - InvokeOnCompositionStateChanged(); - } - } - - void GuiDocumentElement::RemoveStyleName(TextPos begin, TextPos end) - { - auto elementRenderer = renderer.Cast(); - if (elementRenderer) - { - if (begin > end) - { - TextPos temp = begin; - begin = end; - end = temp; - } - - if (document->RemoveStyleName(begin, end)) - { - elementRenderer->NotifyParagraphUpdated(begin.row, end.row - begin.row + 1, end.row - begin.row + 1, false); - } - InvokeOnCompositionStateChanged(); - } - } - - void GuiDocumentElement::RenameStyle(const WString& oldStyleName, const WString& newStyleName) - { - auto elementRenderer = renderer.Cast(); - if (elementRenderer) - { - document->RenameStyle(oldStyleName, newStyleName); - } - } - - void GuiDocumentElement::ClearStyle(TextPos begin, TextPos end) - { - auto elementRenderer = renderer.Cast(); - if (elementRenderer) - { - if (begin > end) - { - TextPos temp = begin; - begin = end; - end = temp; - } - - if (document->ClearStyle(begin, end)) - { - elementRenderer->NotifyParagraphUpdated(begin.row, end.row - begin.row + 1, end.row - begin.row + 1, false); - } - InvokeOnCompositionStateChanged(); - } - } - - Ptr GuiDocumentElement::SummarizeStyle(TextPos begin, TextPos end) - { - auto elementRenderer = renderer.Cast(); - if (elementRenderer) - { - if (begin > end) - { - TextPos temp = begin; - begin = end; - end = temp; - } - - return document->SummarizeStyle(begin, end); - } - return nullptr; - } - - void GuiDocumentElement::SetParagraphAlignment(TextPos begin, TextPos end, const collections::Array>& alignments) - { - auto elementRenderer = renderer.Cast(); - if (elementRenderer) - { - vint first = begin.row; - vint last = end.row; - if (first > last) - { - vint temp = first; - first = last; - last = temp; - } - - if (0 <= first && first < document->paragraphs.Count() && 0 <= last && last < document->paragraphs.Count() && last - first + 1 == alignments.Count()) - { - for (vint i = first; i <= last; i++) - { - document->paragraphs[i]->alignment = alignments[i - first]; - } - elementRenderer->NotifyParagraphUpdated(first, alignments.Count(), alignments.Count(), false); - } - InvokeOnCompositionStateChanged(); - } - } - - Nullable GuiDocumentElement::SummarizeParagraphAlignment(TextPos begin, TextPos end) - { - auto elementRenderer = renderer.Cast(); - if (elementRenderer) - { - if (begin > end) - { - TextPos temp = begin; - begin = end; - end = temp; - } - - return document->SummarizeParagraphAlignment(begin, end); - } - return {}; - } - - Ptr GuiDocumentElement::GetHyperlinkFromPoint(Point point) - { - auto elementRenderer=renderer.Cast(); - if(elementRenderer) - { - return elementRenderer->GetHyperlinkFromPoint(point); - } - return nullptr; - } - } - } -} - -/*********************************************************************** -GRAPHICSELEMENT\GUIGRAPHICSELEMENT.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace elements - { - using namespace collections; - -/*********************************************************************** -GuiSolidBorderElement -***********************************************************************/ - - GuiSolidBorderElement::GuiSolidBorderElement() - :color(0, 0, 0) - ,shape(ElementShape::Rectangle) - { - } - - Color GuiSolidBorderElement::GetColor() - { - return color; - } - - void GuiSolidBorderElement::SetColor(Color value) - { - if(color!=value) - { - color=value; - InvokeOnElementStateChanged(); - } - } - - ElementShape GuiSolidBorderElement::GetShape() - { - return shape; - } - - void GuiSolidBorderElement::SetShape(ElementShape value) - { - shape=value; - } - -/*********************************************************************** -GuiRoundBorderElement -***********************************************************************/ - - GuiRoundBorderElement::GuiRoundBorderElement() - :color(0, 0, 0) - ,radius(10) - { - } - - Color GuiRoundBorderElement::GetColor() - { - return color; - } - - void GuiRoundBorderElement::SetColor(Color value) - { - if(color!=value) - { - color=value; - InvokeOnElementStateChanged(); - } - } - - vint GuiRoundBorderElement::GetRadius() - { - return radius; - } - - void GuiRoundBorderElement::SetRadius(vint value) - { - if(radius!=value) - { - radius=value; - InvokeOnElementStateChanged(); - } - } - -/*********************************************************************** -Gui3DBorderElement -***********************************************************************/ - - Gui3DBorderElement::Gui3DBorderElement() - { - } - - Color Gui3DBorderElement::GetColor1() - { - return color1; - } - - void Gui3DBorderElement::SetColor1(Color value) - { - SetColors(value, color2); - } - - Color Gui3DBorderElement::GetColor2() - { - return color2; - } - - void Gui3DBorderElement::SetColor2(Color value) - { - SetColors(color1, value); - } - - void Gui3DBorderElement::SetColors(Color value1, Color value2) - { - if(color1!=value1 || color2!=value2) - { - color1=value1; - color2=value2; - InvokeOnElementStateChanged(); - } - } - -/*********************************************************************** -Gui3DSplitterElement -***********************************************************************/ - - Gui3DSplitterElement::Gui3DSplitterElement() - :direction(Horizontal) - { - } - - Color Gui3DSplitterElement::GetColor1() - { - return color1; - } - - void Gui3DSplitterElement::SetColor1(Color value) - { - SetColors(value, color2); - } - - Color Gui3DSplitterElement::GetColor2() - { - return color2; - } - - void Gui3DSplitterElement::SetColor2(Color value) - { - SetColors(color1, value); - } - - void Gui3DSplitterElement::SetColors(Color value1, Color value2) - { - if(color1!=value1 || color2!=value2) - { - color1=value1; - color2=value2; - InvokeOnElementStateChanged(); - } - } - - Gui3DSplitterElement::Direction Gui3DSplitterElement::GetDirection() - { - return direction; - } - - void Gui3DSplitterElement::SetDirection(Direction value) - { - if(direction!=value) - { - direction=value; - InvokeOnElementStateChanged(); - } - } - -/*********************************************************************** -GuiSolidBackgroundElement -***********************************************************************/ - - GuiSolidBackgroundElement::GuiSolidBackgroundElement() - :color(255, 255, 255) - ,shape(ElementShape::Rectangle) - { - } - - Color GuiSolidBackgroundElement::GetColor() - { - return color; - } - - void GuiSolidBackgroundElement::SetColor(Color value) - { - if(color!=value) - { - color=value; - InvokeOnElementStateChanged(); - } - } - - ElementShape GuiSolidBackgroundElement::GetShape() - { - return shape; - } - - void GuiSolidBackgroundElement::SetShape(ElementShape value) - { - shape=value; - } - -/*********************************************************************** -GuiGradientBackgroundElement -***********************************************************************/ - - GuiGradientBackgroundElement::GuiGradientBackgroundElement() - :direction(Horizontal) - ,shape(ElementShape::Rectangle) - { - } - - Color GuiGradientBackgroundElement::GetColor1() - { - return color1; - } - - void GuiGradientBackgroundElement::SetColor1(Color value) - { - SetColors(value, color2); - } - - Color GuiGradientBackgroundElement::GetColor2() - { - return color2; - } - - void GuiGradientBackgroundElement::SetColor2(Color value) - { - SetColors(color1, value); - } - - void GuiGradientBackgroundElement::SetColors(Color value1, Color value2) - { - if(color1!=value1 || color2!=value2) - { - color1=value1; - color2=value2; - InvokeOnElementStateChanged(); - } - } - - GuiGradientBackgroundElement::Direction GuiGradientBackgroundElement::GetDirection() - { - return direction; - } - - void GuiGradientBackgroundElement::SetDirection(Direction value) - { - if(direction!=value) - { - direction=value; - InvokeOnElementStateChanged(); - } - } - - ElementShape GuiGradientBackgroundElement::GetShape() - { - return shape; - } - - void GuiGradientBackgroundElement::SetShape(ElementShape value) - { - shape=value; - } - -/*********************************************************************** -GuiSolidLabelElement -***********************************************************************/ - - GuiSolidLabelElement::GuiSolidLabelElement() - :color(0, 0, 0) - ,hAlignment(Alignment::Left) - ,vAlignment(Alignment::Top) - ,wrapLine(false) - ,ellipse(false) - ,multiline(false) - ,wrapLineHeightCalculation(false) - { - fontProperties.fontFamily=L"Lucida Console"; - fontProperties.size=12; - } - - Color GuiSolidLabelElement::GetColor() - { - return color; - } - - void GuiSolidLabelElement::SetColor(Color value) - { - if(color!=value) - { - color=value; - InvokeOnElementStateChanged(); - } - } - - const FontProperties& GuiSolidLabelElement::GetFont() - { - return fontProperties; - } - - void GuiSolidLabelElement::SetFont(const FontProperties& value) - { - if(fontProperties!=value) - { - fontProperties=value; - InvokeOnElementStateChanged(); - } - } - - const WString& GuiSolidLabelElement::GetText() - { - return text; - } - - void GuiSolidLabelElement::SetText(const WString& value) - { - if(text!=value) - { - text=value; - InvokeOnElementStateChanged(); - } - } - - Alignment GuiSolidLabelElement::GetHorizontalAlignment() - { - return hAlignment; - } - - Alignment GuiSolidLabelElement::GetVerticalAlignment() - { - return vAlignment; - } - - void GuiSolidLabelElement::SetHorizontalAlignment(Alignment value) - { - SetAlignments(value, vAlignment); - } - - void GuiSolidLabelElement::SetVerticalAlignment(Alignment value) - { - SetAlignments(hAlignment, value); - } - - void GuiSolidLabelElement::SetAlignments(Alignment horizontal, Alignment vertical) - { - if(hAlignment!=horizontal || vAlignment!=vertical) - { - hAlignment=horizontal; - vAlignment=vertical; - InvokeOnElementStateChanged(); - } - } - - bool GuiSolidLabelElement::GetWrapLine() - { - return wrapLine; - } - - void GuiSolidLabelElement::SetWrapLine(bool value) - { - if(wrapLine!=value) - { - wrapLine=value; - InvokeOnElementStateChanged(); - } - } - - bool GuiSolidLabelElement::GetEllipse() - { - return ellipse; - } - - void GuiSolidLabelElement::SetEllipse(bool value) - { - if(ellipse!=value) - { - ellipse=value; - InvokeOnElementStateChanged(); - } - } - - bool GuiSolidLabelElement::GetMultiline() - { - return multiline; - } - - void GuiSolidLabelElement::SetMultiline(bool value) - { - if(multiline!=value) - { - multiline=value; - InvokeOnElementStateChanged(); - } - } - - bool GuiSolidLabelElement::GetWrapLineHeightCalculation() - { - return wrapLineHeightCalculation; - } - - void GuiSolidLabelElement::SetWrapLineHeightCalculation(bool value) - { - if(wrapLineHeightCalculation!=value) - { - wrapLineHeightCalculation=value; - InvokeOnElementStateChanged(); - } - } - -/*********************************************************************** -GuiImageFrameElement -***********************************************************************/ - - GuiImageFrameElement::GuiImageFrameElement() - :frameIndex(0) - ,hAlignment(Alignment::Left) - ,vAlignment(Alignment::Top) - ,stretch(false) - ,enabled(true) - { - } - - Ptr GuiImageFrameElement::GetImage() - { - return image; - } - - vint GuiImageFrameElement::GetFrameIndex() - { - return frameIndex; - } - - void GuiImageFrameElement::SetImage(Ptr value) - { - SetImage(value, frameIndex); - } - - void GuiImageFrameElement::SetFrameIndex(vint value) - { - SetImage(image, value); - } - - void GuiImageFrameElement::SetImage(Ptr _image, vint _frameIndex) - { - if(image!=_image || frameIndex!=_frameIndex) - { - if(!_image) - { - image=0; - frameIndex=0; - } - else if(0<=_frameIndex && _frameIndex<_image->GetFrameCount()) - { - image=_image; - frameIndex=_frameIndex; - } - InvokeOnElementStateChanged(); - } - } - - Alignment GuiImageFrameElement::GetHorizontalAlignment() - { - return hAlignment; - } - - Alignment GuiImageFrameElement::GetVerticalAlignment() - { - return vAlignment; - } - - void GuiImageFrameElement::SetHorizontalAlignment(Alignment value) - { - SetAlignments(value, vAlignment); - } - - void GuiImageFrameElement::SetVerticalAlignment(Alignment value) - { - SetAlignments(hAlignment, value); - } - - void GuiImageFrameElement::SetAlignments(Alignment horizontal, Alignment vertical) - { - if(hAlignment!=horizontal || vAlignment!=vertical) - { - hAlignment=horizontal; - vAlignment=vertical; - InvokeOnElementStateChanged(); - } - } - - bool GuiImageFrameElement::GetStretch() - { - return stretch; - } - - void GuiImageFrameElement::SetStretch(bool value) - { - if(stretch!=value) - { - stretch=value; - InvokeOnElementStateChanged(); - } - } - - bool GuiImageFrameElement::GetEnabled() - { - return enabled; - } - - void GuiImageFrameElement::SetEnabled(bool value) - { - if(enabled!=value) - { - enabled=value; - InvokeOnElementStateChanged(); - } - } - -/*********************************************************************** -GuiPolygonElement -***********************************************************************/ - - GuiPolygonElement::GuiPolygonElement() - { - } - - Size GuiPolygonElement::GetSize() - { - return size; - } - - void GuiPolygonElement::SetSize(Size value) - { - if(size!=value) - { - size=value; - InvokeOnElementStateChanged(); - } - } - - const Point& GuiPolygonElement::GetPoint(vint index) - { - return points[index]; - } - - vint GuiPolygonElement::GetPointCount() - { - return points.Count(); - } - - void GuiPolygonElement::SetPoints(const Point* p, vint count) - { - points.Resize(count); - if(count>0) - { - memcpy(&points[0], p, sizeof(*p)*count); - } - InvokeOnElementStateChanged(); - } - - const GuiPolygonElement::PointArray& GuiPolygonElement::GetPointsArray() - { - return points; - } - - void GuiPolygonElement::SetPointsArray(const PointArray& value) - { - CopyFrom(points, value); - } - - Color GuiPolygonElement::GetBorderColor() - { - return borderColor; - } - - void GuiPolygonElement::SetBorderColor(Color value) - { - if(borderColor!=value) - { - borderColor=value; - InvokeOnElementStateChanged(); - } - } - - Color GuiPolygonElement::GetBackgroundColor() - { - return backgroundColor; - } - - void GuiPolygonElement::SetBackgroundColor(Color value) - { - if(backgroundColor!=value) - { - backgroundColor=value; - InvokeOnElementStateChanged(); - } - } - } - } -} - -/*********************************************************************** -GRAPHICSELEMENT\GUIGRAPHICSHOST.CPP +.\GRAPHICSELEMENT\GUIGRAPHICSHOST.CPP ***********************************************************************/ namespace vl @@ -37209,4284 +24178,6314 @@ GuiShortcutKeyManager } /*********************************************************************** -GRAPHICSELEMENT\GUIGRAPHICSRESOURCEMANAGER.CPP +.\CONTROLS\LISTCONTROLPACKAGE\GUIBINDABLELISTCONTROLS.CPP ***********************************************************************/ namespace vl { namespace presentation { - namespace elements + namespace controls { using namespace collections; + using namespace list; + using namespace tree; + using namespace reflection::description; + using namespace templates; /*********************************************************************** -GuiGraphicsResourceManager +GuiBindableTextList::ItemSource ***********************************************************************/ - GuiGraphicsResourceManager::GuiGraphicsResourceManager() + GuiBindableTextList::ItemSource::ItemSource() { } - GuiGraphicsResourceManager::~GuiGraphicsResourceManager() + GuiBindableTextList::ItemSource::~ItemSource() { + SetItemSource(nullptr); } - bool GuiGraphicsResourceManager::RegisterElementFactory(IGuiGraphicsElementFactory* factory) + Ptr GuiBindableTextList::ItemSource::GetItemSource() { - if(elementFactories.Keys().Contains(factory->GetElementTypeName())) + return itemSource; + } + + void GuiBindableTextList::ItemSource::SetItemSource(Ptr _itemSource) + { + vint oldCount = 0; + if (itemSource) { - return false; + oldCount = itemSource->GetCount(); } - else + if (itemChangedEventHandler) { - elementFactories.Add(factory->GetElementTypeName(), factory); - return true; + auto ol = itemSource.Cast(); + ol->ItemChanged.Remove(itemChangedEventHandler); } - } - bool GuiGraphicsResourceManager::RegisterRendererFactory(const WString& elementTypeName, IGuiGraphicsRendererFactory* factory) - { - if(rendererFactories.Keys().Contains(elementTypeName)) + itemSource = nullptr; + itemChangedEventHandler = nullptr; + + if (_itemSource) { - return false; - } - else - { - rendererFactories.Add(elementTypeName, factory); - return true; - } - } - - IGuiGraphicsElementFactory* GuiGraphicsResourceManager::GetElementFactory(const WString& elementTypeName) - { - vint index=elementFactories.Keys().IndexOf(elementTypeName); - return index==-1?0:elementFactories.Values().Get(index).Obj(); - } - - IGuiGraphicsRendererFactory* GuiGraphicsResourceManager::GetRendererFactory(const WString& elementTypeName) - { - vint index=rendererFactories.Keys().IndexOf(elementTypeName); - return index==-1?0:rendererFactories.Values().Get(index).Obj(); - } - - GuiGraphicsResourceManager* guiGraphicsResourceManager=0; - - GuiGraphicsResourceManager* GetGuiGraphicsResourceManager() - { - return guiGraphicsResourceManager; - } - - void SetGuiGraphicsResourceManager(GuiGraphicsResourceManager* resourceManager) - { - guiGraphicsResourceManager=resourceManager; - } - - bool RegisterFactories(IGuiGraphicsElementFactory* elementFactory, IGuiGraphicsRendererFactory* rendererFactory) - { - if(guiGraphicsResourceManager && elementFactory && rendererFactory) - { - if(guiGraphicsResourceManager->RegisterElementFactory(elementFactory)) + if (auto ol = _itemSource.Cast()) { - if(guiGraphicsResourceManager->RegisterRendererFactory(elementFactory->GetElementTypeName(), rendererFactory)) + itemSource = ol; + itemChangedEventHandler = ol->ItemChanged.Add([this](vint start, vint oldCount, vint newCount) { - return true; - } + InvokeOnItemModified(start, oldCount, newCount); + }); + } + else if (auto rl = _itemSource.Cast()) + { + itemSource = rl; + } + else + { + itemSource = IValueList::Create(GetLazyList(_itemSource)); + } + } + + InvokeOnItemModified(0, oldCount, itemSource ? itemSource->GetCount() : 0); + } + + description::Value GuiBindableTextList::ItemSource::Get(vint index) + { + if (!itemSource) return Value(); + return itemSource->Get(index); + } + + void GuiBindableTextList::ItemSource::UpdateBindingProperties() + { + InvokeOnItemModified(0, Count(), Count()); + } + + // ===================== GuiListControl::IItemProvider ===================== + + vint GuiBindableTextList::ItemSource::Count() + { + if (!itemSource) return 0; + return itemSource->GetCount(); + } + + WString GuiBindableTextList::ItemSource::GetTextValue(vint itemIndex) + { + if (itemSource) + { + if (0 <= itemIndex && itemIndex < itemSource->GetCount()) + { + return ReadProperty(itemSource->Get(itemIndex), textProperty); + } + } + return L""; + } + + IDescriptable* GuiBindableTextList::ItemSource::RequestView(const WString& identifier) + { + if (identifier == ITextItemView::Identifier) + { + return (ITextItemView*)this; + } + else + { + return 0; + } + } + + // ===================== GuiListControl::IItemBindingView ===================== + + description::Value GuiBindableTextList::ItemSource::GetBindingValue(vint itemIndex) + { + if (itemSource) + { + if (0 <= itemIndex && itemIndex < itemSource->GetCount()) + { + return itemSource->Get(itemIndex); + } + } + return Value(); + } + + // ===================== list::TextItemStyleProvider::ITextItemView ===================== + + bool GuiBindableTextList::ItemSource::GetChecked(vint itemIndex) + { + if (itemSource) + { + if (0 <= itemIndex && itemIndex < itemSource->GetCount()) + { + return ReadProperty(itemSource->Get(itemIndex), checkedProperty); } } return false; } - } - } -} - -/*********************************************************************** -GRAPHICSELEMENT\GUIGRAPHICSTEXTELEMENT.CPP -***********************************************************************/ - -namespace vl -{ - using namespace collections; - - namespace presentation - { - namespace elements - { - namespace text + + void GuiBindableTextList::ItemSource::SetChecked(vint itemIndex, bool value) { + if (itemSource) + { + if (0 <= itemIndex && itemIndex < itemSource->GetCount()) + { + auto thisValue = itemSource->Get(itemIndex); + WriteProperty(thisValue, checkedProperty, value); + InvokeOnItemModified(itemIndex, 1, 1); + } + } + } /*********************************************************************** -text::TextLine +GuiBindableTextList ***********************************************************************/ - TextLine::TextLine() - :text(0) - ,att(0) - ,availableOffsetCount(0) - ,bufferLength(0) - ,dataLength(0) - ,lexerFinalState(-1) - ,contextFinalState(-1) + GuiBindableTextList::GuiBindableTextList(IStyleProvider* _styleProvider) + :GuiVirtualTextList(_styleProvider, new ItemSource) + { + itemSource = dynamic_cast(GetItemProvider()); + + TextPropertyChanged.SetAssociatedComposition(boundsComposition); + TextPropertyChanged.SetAssociatedComposition(boundsComposition); + } + + GuiBindableTextList::~GuiBindableTextList() + { + } + + Ptr GuiBindableTextList::GetItemSource() + { + return itemSource->GetItemSource(); + } + + void GuiBindableTextList::SetItemSource(Ptr _itemSource) + { + itemSource->SetItemSource(_itemSource); + } + + ItemProperty GuiBindableTextList::GetTextProperty() + { + return itemSource->textProperty; + } + + void GuiBindableTextList::SetTextProperty(const ItemProperty& value) + { + if (itemSource->textProperty != value) { + itemSource->textProperty = value; + itemSource->UpdateBindingProperties(); + TextPropertyChanged.Execute(GetNotifyEventArguments()); + } + } + + WritableItemProperty GuiBindableTextList::GetCheckedProperty() + { + return itemSource->checkedProperty; + } + + void GuiBindableTextList::SetCheckedProperty(const WritableItemProperty& value) + { + if (itemSource->checkedProperty != value) + { + itemSource->checkedProperty = value; + itemSource->UpdateBindingProperties(); + CheckedPropertyChanged.Execute(GetNotifyEventArguments()); + } + } + + description::Value GuiBindableTextList::GetSelectedItem() + { + vint index = GetSelectedItemIndex(); + if (index == -1) return Value(); + return itemSource->Get(index); + } + +/*********************************************************************** +GuiBindableListView::ItemSource +***********************************************************************/ + + GuiBindableListView::ItemSource::ItemSource() + :columns(this) + , dataColumns(this) + { + } + + GuiBindableListView::ItemSource::~ItemSource() + { + SetItemSource(nullptr); + } + + Ptr GuiBindableListView::ItemSource::GetItemSource() + { + return itemSource; + } + + void GuiBindableListView::ItemSource::SetItemSource(Ptr _itemSource) + { + vint oldCount = 0; + if (itemSource) + { + oldCount = itemSource->GetCount(); + } + if (itemChangedEventHandler) + { + auto ol = itemSource.Cast(); + ol->ItemChanged.Remove(itemChangedEventHandler); } - TextLine::~TextLine() - { - } + itemSource = nullptr; + itemChangedEventHandler = nullptr; - vint TextLine::CalculateBufferLength(vint dataLength) + if (_itemSource) { - if(dataLength<1)dataLength=1; - vint bufferLength=dataLength-dataLength%BlockSize; - if(bufferLength()) { - bufferLength+=BlockSize; + itemSource = ol; + itemChangedEventHandler = ol->ItemChanged.Add([this](vint start, vint oldCount, vint newCount) + { + InvokeOnItemModified(start, oldCount, newCount); + }); } - return bufferLength; - } - - void TextLine::Initialize() - { - Finalize(); - text=new wchar_t[BlockSize]; - att=new CharAtt[BlockSize]; - bufferLength=BlockSize; - - memset(text, 0, sizeof(wchar_t)*bufferLength); - memset(att, 0, sizeof(CharAtt)*bufferLength); - } - - void TextLine::Finalize() - { - if(text) + else if (auto rl = _itemSource.Cast()) { - delete[] text; - text=0; - } - if(att) - { - delete[] att; - att=0; - } - availableOffsetCount=0; - bufferLength=0; - dataLength=0; - } - - bool TextLine::IsReady() - { - return text && att; - } - - bool TextLine::Modify(vint start, vint count, const wchar_t* input, vint inputCount) - { - if(!text || !att || start<0 || count<0 || start+count>dataLength || inputCount<0) return false; - - vint newDataLength=dataLength-count+inputCount; - vint newBufferLength=CalculateBufferLength(newDataLength); - if(newBufferLength!=bufferLength) - { - wchar_t* newText=new wchar_t[newBufferLength]; - memcpy(newText, text, start*sizeof(wchar_t)); - memcpy(newText+start, input, inputCount*sizeof(wchar_t)); - memcpy(newText+start+inputCount, text+start+count, (dataLength-start-count)*sizeof(wchar_t)); - - CharAtt* newAtt=new CharAtt[newBufferLength]; - memcpy(newAtt, att, start*sizeof(CharAtt)); - memset(newAtt+start, 0, inputCount*sizeof(CharAtt)); - memcpy(newAtt+start+inputCount, att+start+count, (dataLength-start-count)*sizeof(CharAtt)); - - delete[] text; - delete[] att; - text=newText; - att=newAtt; + itemSource = rl; } else { - memmove(text+start+inputCount, text+start+count, (dataLength-start-count)*sizeof(wchar_t)); - memmove(att+start+inputCount, att+start+count, (dataLength-start-count)*sizeof(CharAtt)); - memcpy(text+start, input, inputCount*sizeof(wchar_t)); - memset(att+start, 0, inputCount*sizeof(CharAtt)); - } - dataLength=newDataLength; - bufferLength=newBufferLength; - if(availableOffsetCount>start) - { - availableOffsetCount=start; - } - - return true; - } - - TextLine TextLine::Split(vint index) - { - if(index<0 || index>dataLength) return TextLine(); - vint count=dataLength-index; - TextLine line; - line.Initialize(); - line.Modify(0, 0, text+index, count); - memcpy(line.att, att+index, count*sizeof(CharAtt)); - Modify(index, count, L"", 0); - return line; - } - - void TextLine::AppendAndFinalize(TextLine& line) - { - vint oldDataLength=dataLength; - Modify(oldDataLength, 0, line.text, line.dataLength); - memcpy(att+oldDataLength, line.att, line.dataLength*sizeof(CharAtt)); - line.Finalize(); - } - -/*********************************************************************** -text::CharMeasurer -***********************************************************************/ - - CharMeasurer::CharMeasurer(vint _rowHeight) - :oldRenderTarget(0) - ,rowHeight(_rowHeight) - { - memset(widths, 0, sizeof(widths)); - } - - CharMeasurer::~CharMeasurer() - { - } - - void CharMeasurer::SetRenderTarget(IGuiGraphicsRenderTarget* value) - { - if(oldRenderTarget!=value) - { - oldRenderTarget=value; - rowHeight=GetRowHeightInternal(oldRenderTarget); - memset(widths, 0, sizeof(widths)); + itemSource = IValueList::Create(GetLazyList(_itemSource)); } } - vint CharMeasurer::MeasureWidth(wchar_t character) - { - vint w=widths[character]; - if(w==0) - { - widths[character]=w=MeasureWidthInternal(character, oldRenderTarget); - } - return w; - } - - vint CharMeasurer::GetRowHeight() - { - return rowHeight; - } - -/*********************************************************************** -text::TextLines -***********************************************************************/ - - TextLines::TextLines(GuiColorizedTextElement* _ownerElement) - :ownerElement(_ownerElement) - ,charMeasurer(0) - ,renderTarget(0) - ,tabWidth(1) - ,tabSpaceCount(4) - ,passwordChar(L'\0') - { - TextLine line; - line.Initialize(); - lines.Add(line); - } - - TextLines::~TextLines() - { - RemoveLines(0, lines.Count()); - } - - //-------------------------------------------------------- - - vint TextLines::GetCount() - { - return lines.Count(); - } - - TextLine& TextLines::GetLine(vint row) - { - return lines[row]; - } - - CharMeasurer* TextLines::GetCharMeasurer() - { - return charMeasurer; - } - - void TextLines::SetCharMeasurer(CharMeasurer* value) - { - charMeasurer=value; - if(charMeasurer) charMeasurer->SetRenderTarget(renderTarget); - ClearMeasurement(); - } - - IGuiGraphicsRenderTarget* TextLines::GetRenderTarget() - { - return renderTarget; - } - - void TextLines::SetRenderTarget(IGuiGraphicsRenderTarget* value) - { - renderTarget=value; - if(charMeasurer) charMeasurer->SetRenderTarget(renderTarget); - ClearMeasurement(); - } - - WString TextLines::GetText(TextPos start, TextPos end) - { - if(!IsAvailable(start) || !IsAvailable(end) || start>end) return L""; - - if(start.row==end.row) - { - return WString(lines[start.row].text+start.column, end.column-start.column); - } - - vint count=0; - for(vint i=start.row+1;i buffer; - buffer.Resize(count+(end.row-start.row)*2); - wchar_t* writing=&buffer[0]; - - for(vint i=start.row;i<=end.row;i++) - { - wchar_t* text=lines[i].text; - vint chars=0; - if(i==start.row) - { - text+=start.column; - chars=lines[i].dataLength-start.column; - } - else if(i==end.row) - { - chars=end.column; - } - else - { - chars=lines[i].dataLength; - } - - if(i!=start.row) - { - *writing++=L'\r'; - *writing++=L'\n'; - } - memcpy(writing, text, chars*sizeof(wchar_t)); - writing+=chars; - } - return WString(&buffer[0], buffer.Count()); - } - - WString TextLines::GetText() - { - return GetText(TextPos(0, 0), TextPos(lines.Count()-1, lines[lines.Count()-1].dataLength)); - } - - void TextLines::SetText(const WString& value) - { - Modify(TextPos(0, 0), TextPos(lines.Count()-1, lines[lines.Count()-1].dataLength), value); - } - - //-------------------------------------------------------- - - bool TextLines::RemoveLines(vint start, vint count) - { - if(start<0 || count<0 || start+count>lines.Count()) return false; - for(vint i=start+count-1;i>=start;i--) - { - lines[i].Finalize(); - } - lines.RemoveRange(start, count); - return true; - } - - bool TextLines::IsAvailable(TextPos pos) - { - return 0<=pos.row && pos.row=lines.Count()) - { - return TextPos(lines.Count()-1, lines[lines.Count()-1].dataLength); - } - else - { - TextLine& line=lines[pos.row]; - if(pos.column<0) - { - return TextPos(pos.row, 0); - } - else if(pos.column>line.dataLength) - { - return TextPos(pos.row, line.dataLength); - } - else - { - return pos; - } - } - } - - TextPos TextLines::Modify(TextPos start, TextPos end, const wchar_t** inputs, vint* inputCounts, vint rows) - { - if(!IsAvailable(start) || !IsAvailable(end) || start>end) return TextPos(-1, -1); - if (ownerElement) - { - ownerElement->InvokeOnElementStateChanged(); - } - - if(rows==1) - { - if(start.row==end.row) - { - lines[start.row].Modify(start.column, end.column-start.column, inputs[0], inputCounts[0]); - } - else - { - if(end.row-start.row>1) - { - RemoveLines(start.row+1, end.row-start.row-1); - } - vint modifyCount=lines[start.row].dataLength-start.column+end.column; - lines[start.row].AppendAndFinalize(lines[start.row+1]); - lines.RemoveAt(start.row+1); - lines[start.row].Modify(start.column, modifyCount, inputs[0], inputCounts[0]); - } - return TextPos(start.row, start.column+inputCounts[0]); - } - - if(start.row==end.row) - { - TextLine newLine=lines[start.row].Split(end.column); - lines.Insert(start.row+1, newLine); - end=TextPos(start.row+1, 0); - } - - vint oldMiddleLines=end.row-start.row-1; - vint newMiddleLines=rows-2; - if(oldMiddleLinesnewMiddleLines) - { - RemoveLines(start.row+newMiddleLines+1, oldMiddleLines-newMiddleLines); - } - end.row+=newMiddleLines-oldMiddleLines; - - lines[start.row].Modify(start.column, lines[start.row].dataLength-start.column, inputs[0], inputCounts[0]); - lines[end.row].Modify(0, end.column, inputs[rows-1], inputCounts[rows-1]); - for(vint i=1;i inputs; - List inputCounts; - const wchar_t* previous=input; - const wchar_t* current=input; - - while(true) - { - if(current==input+inputCount) - { - inputs.Add(previous); - inputCounts.Add(current-previous); - break; - } - else if(*current==L'\r' || *current==L'\n') - { - inputs.Add(previous); - inputCounts.Add(current-previous); - previous=current+(current[1]==L'\n'?2:1); - current=previous; - } - else - { - current++; - } - } - - return Modify(start, end, &inputs[0], &inputCounts[0], inputs.Count()); - } - - TextPos TextLines::Modify(TextPos start, TextPos end, const wchar_t* input) - { - return Modify(start, end, input, wcslen(input)); - } - - TextPos TextLines::Modify(TextPos start, TextPos end, const WString& input) - { - return Modify(start, end, input.Buffer(), input.Length()); - } - - void TextLines::Clear() - { - RemoveLines(0, lines.Count()); - TextLine line; - line.Initialize(); - lines.Add(line); - if (ownerElement) - { - ownerElement->InvokeOnElementStateChanged(); - } - } - - //-------------------------------------------------------- - - void TextLines::ClearMeasurement() - { - for(vint i=0;iMeasureWidth(L' '); - } - if(tabWidth==0) - { - tabWidth=1; - } - if (ownerElement) - { - ownerElement->InvokeOnElementStateChanged(); - } - } - - vint TextLines::GetTabSpaceCount() - { - return tabSpaceCount; - } - - void TextLines::SetTabSpaceCount(vint value) - { - if(value<1) value=1; - if(tabSpaceCount!=value) - { - tabSpaceCount=value; - ClearMeasurement(); - } - } - - void TextLines::MeasureRow(vint row) - { - TextLine& line=lines[row]; - vint offset=0; - if(line.availableOffsetCount) - { - offset=line.att[line.availableOffsetCount-1].rightOffset; - } - for(vint i=line.availableOffsetCount;iMeasureWidth(passwordChar); - } - else if(c==L'\t') - { - width=tabWidth-offset%tabWidth; - } - else - { - width=charMeasurer->MeasureWidth(line.text[i]); - } - offset+=width; - att.rightOffset=(int)offset; - } - line.availableOffsetCount=line.dataLength; - } - - vint TextLines::GetRowWidth(vint row) - { - if(row<0 || row>=lines.Count()) return -1; - TextLine& line=lines[row]; - if(line.dataLength==0) - { - return 0; - } - else - { - MeasureRow(row); - return line.att[line.dataLength-1].rightOffset; - } - } - - vint TextLines::GetRowHeight() - { - return charMeasurer->GetRowHeight(); - } - - vint TextLines::GetMaxWidth() - { - vint width=0; - for(vint i=0;iGetRowHeight(); - } - - TextPos TextLines::GetTextPosFromPoint(Point point) - { - vint h=charMeasurer->GetRowHeight(); - if(point.y<0) - { - point.y=0; - } - else if(point.y>=h*lines.Count()) - { - point.y=h*lines.Count()-1; - } - - vint row=point.y/h; - if(point.x<0) - { - return TextPos(row, 0); - } - else if(point.x>=GetRowWidth(row)) - { - return TextPos(row, lines[row].dataLength); - } - TextLine& line=lines[row]; - - vint i1=0, i2=line.dataLength; - vint p1=0, p2=line.att[line.dataLength-1].rightOffset; - while(i2-i1>1) - { - vint i=(i1+i2)/2; - vint p=i==0?0:line.att[i-1].rightOffset; - if(point.xGetRowHeight(); - if(pos.column==0) - { - return Point(0, y); - } - else - { - MeasureRow(pos.row); - TextLine& line=lines[pos.row]; - return Point(line.att[pos.column-1].rightOffset, y); - } - } - else - { - return Point(-1, -1); - } - } - - Rect TextLines::GetRectFromTextPos(TextPos pos) - { - Point point=GetPointFromTextPos(pos); - if(point==Point(-1, -1)) - { - return Rect(-1, -1, -1, -1); - } - else - { - vint h=charMeasurer->GetRowHeight(); - TextLine& line=lines[pos.row]; - if(pos.column==line.dataLength) - { - return Rect(point, Size(h/2, h)); - } - else - { - return Rect(point, Size(line.att[pos.column].rightOffset-point.x, h)); - } - } - } - - //-------------------------------------------------------- - - wchar_t TextLines::GetPasswordChar() - { - return passwordChar; - } - - void TextLines::SetPasswordChar(wchar_t value) - { - passwordChar=value; - ClearMeasurement(); - } + InvokeOnItemModified(0, oldCount, itemSource ? itemSource->GetCount() : 0); } - using namespace text; - -/*********************************************************************** -GuiColorizedTextElement -***********************************************************************/ - - GuiColorizedTextElement::GuiColorizedTextElement() - :callback(0) - ,isVisuallyEnabled(true) - ,isFocused(false) - ,caretVisible(false) - ,lines(this) + description::Value GuiBindableListView::ItemSource::Get(vint index) { + if (!itemSource) return Value(); + return itemSource->Get(index); } - text::TextLines& GuiColorizedTextElement::GetLines() + void GuiBindableListView::ItemSource::UpdateBindingProperties() { - return lines; + InvokeOnItemModified(0, Count(), Count()); } - GuiColorizedTextElement::ICallback* GuiColorizedTextElement::GetCallback() + bool GuiBindableListView::ItemSource::NotifyUpdate(vint start, vint count) { - return callback; - } - - void GuiColorizedTextElement::SetCallback(ICallback* value) - { - callback=value; - if(!callback) + if (!itemSource) return false; + if (start<0 || start >= itemSource->GetCount() || count <= 0 || start + count > itemSource->GetCount()) { - lines.SetCharMeasurer(0); - } - } - - const GuiColorizedTextElement::ColorArray& GuiColorizedTextElement::GetColors() - { - return colors; - } - - void GuiColorizedTextElement::SetColors(const ColorArray& value) - { - CopyFrom(colors, value); - if(callback) callback->ColorChanged(); - InvokeOnElementStateChanged(); - } - - void GuiColorizedTextElement::ResetTextColorIndex(vint index) - { - vint lineCount = lines.GetCount(); - for (vint i = 0; i < lineCount; i++) - { - auto& line = lines.GetLine(i); - line.lexerFinalState = -1; - line.contextFinalState = -1; - for (vint j = 0; j < line.dataLength; j++) - { - line.att[j].colorIndex = (vuint32_t)index; - } - } - } - - const FontProperties& GuiColorizedTextElement::GetFont() - { - return font; - } - - void GuiColorizedTextElement::SetFont(const FontProperties& value) - { - if(font!=value) - { - font=value; - if(callback) - { - callback->FontChanged(); - } - InvokeOnElementStateChanged(); - } - } - - wchar_t GuiColorizedTextElement::GetPasswordChar() - { - return lines.GetPasswordChar(); - } - - void GuiColorizedTextElement::SetPasswordChar(wchar_t value) - { - if(lines.GetPasswordChar()!=value) - { - lines.SetPasswordChar(value); - InvokeOnElementStateChanged(); - } - } - - Point GuiColorizedTextElement::GetViewPosition() - { - return viewPosition; - } - - void GuiColorizedTextElement::SetViewPosition(Point value) - { - if(viewPosition!=value) - { - viewPosition=value; - InvokeOnElementStateChanged(); - } - } - - bool GuiColorizedTextElement::GetVisuallyEnabled() - { - return isVisuallyEnabled; - } - - void GuiColorizedTextElement::SetVisuallyEnabled(bool value) - { - if(isVisuallyEnabled!=value) - { - isVisuallyEnabled=value; - InvokeOnElementStateChanged(); - } - } - - bool GuiColorizedTextElement::GetFocused() - { - return isFocused; - } - - void GuiColorizedTextElement::SetFocused(bool value) - { - if(isFocused!=value) - { - isFocused=value; - InvokeOnElementStateChanged(); - } - } - - TextPos GuiColorizedTextElement::GetCaretBegin() - { - return caretBegin; - } - - void GuiColorizedTextElement::SetCaretBegin(TextPos value) - { - caretBegin=value; - InvokeOnElementStateChanged(); - } - - TextPos GuiColorizedTextElement::GetCaretEnd() - { - return caretEnd; - } - - void GuiColorizedTextElement::SetCaretEnd(TextPos value) - { - caretEnd=value; - InvokeOnElementStateChanged(); - } - - bool GuiColorizedTextElement::GetCaretVisible() - { - return caretVisible; - } - - void GuiColorizedTextElement::SetCaretVisible(bool value) - { - caretVisible=value; - InvokeOnElementStateChanged(); - } - - Color GuiColorizedTextElement::GetCaretColor() - { - return caretColor; - } - - void GuiColorizedTextElement::SetCaretColor(Color value) - { - if(caretColor!=value) - { - caretColor=value; - InvokeOnElementStateChanged(); - } - } - } - } -} - -/*********************************************************************** -NATIVEWINDOW\GUINATIVEWINDOW.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - -/*********************************************************************** -INativeWindowListener -***********************************************************************/ - - INativeWindowListener::HitTestResult INativeWindowListener::HitTest(Point location) - { - return INativeWindowListener::NoDecision; - } - - void INativeWindowListener::Moving(Rect& bounds, bool fixSizeOnly) - { - } - - void INativeWindowListener::Moved() - { - } - - void INativeWindowListener::Enabled() - { - } - - void INativeWindowListener::Disabled() - { - } - - void INativeWindowListener::GotFocus() - { - } - - void INativeWindowListener::LostFocus() - { - } - - void INativeWindowListener::Activated() - { - } - - void INativeWindowListener::Deactivated() - { - } - - void INativeWindowListener::Opened() - { - } - - void INativeWindowListener::Closing(bool& cancel) - { - } - - void INativeWindowListener::Closed() - { - } - - void INativeWindowListener::Paint() - { - } - - void INativeWindowListener::Destroying() - { - } - - void INativeWindowListener::Destroyed() - { - } - - void INativeWindowListener::LeftButtonDown(const NativeWindowMouseInfo& info) - { - } - - void INativeWindowListener::LeftButtonUp(const NativeWindowMouseInfo& info) - { - } - - void INativeWindowListener::LeftButtonDoubleClick(const NativeWindowMouseInfo& info) - { - } - - void INativeWindowListener::RightButtonDown(const NativeWindowMouseInfo& info) - { - } - - void INativeWindowListener::RightButtonUp(const NativeWindowMouseInfo& info) - { - } - - void INativeWindowListener::RightButtonDoubleClick(const NativeWindowMouseInfo& info) - { - } - - void INativeWindowListener::MiddleButtonDown(const NativeWindowMouseInfo& info) - { - } - - void INativeWindowListener::MiddleButtonUp(const NativeWindowMouseInfo& info) - { - } - - void INativeWindowListener::MiddleButtonDoubleClick(const NativeWindowMouseInfo& info) - { - } - - void INativeWindowListener::HorizontalWheel(const NativeWindowMouseInfo& info) - { - } - - void INativeWindowListener::VerticalWheel(const NativeWindowMouseInfo& info) - { - } - - void INativeWindowListener::MouseMoving(const NativeWindowMouseInfo& info) - { - } - - void INativeWindowListener::MouseEntered() - { - } - - void INativeWindowListener::MouseLeaved() - { - } - - void INativeWindowListener::KeyDown(const NativeWindowKeyInfo& info) - { - } - - void INativeWindowListener::KeyUp(const NativeWindowKeyInfo& info) - { - } - - void INativeWindowListener::SysKeyDown(const NativeWindowKeyInfo& info) - { - } - - void INativeWindowListener::SysKeyUp(const NativeWindowKeyInfo& info) - { - } - - void INativeWindowListener::Char(const NativeWindowCharInfo& info) - { - } - -/*********************************************************************** -INativeControllerListener -***********************************************************************/ - - void INativeControllerListener::LeftButtonDown(Point position) - { - } - - void INativeControllerListener::LeftButtonUp(Point position) - { - } - - void INativeControllerListener::RightButtonDown(Point position) - { - } - - void INativeControllerListener::RightButtonUp(Point position) - { - } - - void INativeControllerListener::MouseMoving(Point position) - { - } - - void INativeControllerListener::GlobalTimer() - { - } - - void INativeControllerListener::ClipboardUpdated() - { - } - - void INativeControllerListener::NativeWindowCreated(INativeWindow* window) - { - } - - void INativeControllerListener::NativeWindowDestroying(INativeWindow* window) - { - } - -/*********************************************************************** -Native Window Provider -***********************************************************************/ - - INativeController* currentController=0; - - INativeController* GetCurrentController() - { - return currentController; - } - - void SetCurrentController(INativeController* controller) - { - currentController=controller; - } - } -} - -/*********************************************************************** -RESOURCES\GUIDOCUMENT.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - using namespace collections; - using namespace parsing::tabling; - using namespace parsing::xml; - using namespace regex; - -/*********************************************************************** -DocumentFontSize -***********************************************************************/ - - DocumentFontSize DocumentFontSize::Parse(const WString& value) - { - if (value.Length() > 0 && value[value.Length() - 1] == L'x') - { - return DocumentFontSize(wtof(value.Left(value.Length() - 1)), true); - } - else - { - return DocumentFontSize(wtof(value), false); - } - } - - WString DocumentFontSize::ToString()const - { - return ftow(size) + (relative ? L"x" : L""); - } - -/*********************************************************************** -DocumentImageRun -***********************************************************************/ - - const wchar_t* DocumentImageRun::RepresentationText=L"[Image]"; - const wchar_t* DocumentEmbeddedObjectRun::RepresentationText=L"[EmbeddedObject]"; - -/*********************************************************************** -ExtractTextVisitor -***********************************************************************/ - - namespace document_operation_visitors - { - class ExtractTextVisitor : public Object, public DocumentRun::IVisitor - { - public: - stream::TextWriter& writer; - bool skipNonTextContent; - - ExtractTextVisitor(stream::TextWriter& _writer, bool _skipNonTextContent) - :writer(_writer) - ,skipNonTextContent(_skipNonTextContent) - { - } - - void VisitContainer(DocumentContainerRun* run) - { - FOREACH(Ptr, subRun, run->runs) - { - subRun->Accept(this); - } - } - - void VisitContent(DocumentContentRun* run) - { - writer.WriteString(run->GetRepresentationText()); - } - - void Visit(DocumentTextRun* run)override - { - VisitContent(run); - } - - void Visit(DocumentStylePropertiesRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentStyleApplicationRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentHyperlinkRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentImageRun* run)override - { - if(!skipNonTextContent) - { - VisitContent(run); - } - } - - void Visit(DocumentEmbeddedObjectRun* run)override - { - if(!skipNonTextContent) - { - VisitContent(run); - } - } - - void Visit(DocumentParagraphRun* run)override - { - VisitContainer(run); - } - }; - } - using namespace document_operation_visitors; - -/*********************************************************************** -DocumentParagraphRun -***********************************************************************/ - - WString DocumentParagraphRun::GetText(bool skipNonTextContent) - { - stream::MemoryStream memoryStream; - { - stream::StreamWriter writer(memoryStream); - GetText(writer, skipNonTextContent); - } - - memoryStream.SeekFromBegin(0); - stream::StreamReader reader(memoryStream); - return reader.ReadToEnd(); - } - - void DocumentParagraphRun::GetText(stream::TextWriter& writer, bool skipNonTextContent) - { - ExtractTextVisitor visitor(writer, skipNonTextContent); - Accept(&visitor); - } - -/*********************************************************************** -DocumentModel -***********************************************************************/ - - const wchar_t* DocumentModel::DefaultStyleName = L"#Default"; - const wchar_t* DocumentModel::SelectionStyleName = L"#Selection"; - const wchar_t* DocumentModel::ContextStyleName = L"#Context"; - const wchar_t* DocumentModel::NormalLinkStyleName = L"#NormalLink"; - const wchar_t* DocumentModel::ActiveLinkStyleName = L"#ActiveLink"; - - DocumentModel::DocumentModel() - { - { - FontProperties font=GetCurrentController()->ResourceService()->GetDefaultFont(); - Ptr sp=new DocumentStyleProperties; - sp->face=font.fontFamily; - sp->size=DocumentFontSize(font.size, false); - sp->color=Color(); - sp->backgroundColor=Color(0, 0, 0, 0); - sp->bold=font.bold; - sp->italic=font.italic; - sp->underline=font.underline; - sp->strikeline=font.strikeline; - sp->antialias=font.antialias; - sp->verticalAntialias=font.verticalAntialias; - - Ptr style=new DocumentStyle; - style->styles=sp; - styles.Add(L"#Default", style); - } - { - Ptr sp=new DocumentStyleProperties; - sp->color=Color(255, 255, 255); - sp->backgroundColor=Color(51, 153, 255); - - Ptr style=new DocumentStyle; - style->styles=sp; - styles.Add(L"#Selection", style); - } - { - Ptr sp=new DocumentStyleProperties; - - Ptr style=new DocumentStyle; - style->styles=sp; - styles.Add(L"#Context", style); - } - { - Ptr sp=new DocumentStyleProperties; - sp->color=Color(0, 0, 255); - sp->underline=true; - - Ptr style=new DocumentStyle; - style->parentStyleName=L"#Context"; - style->styles=sp; - styles.Add(L"#NormalLink", style); - } - { - Ptr sp=new DocumentStyleProperties; - sp->color=Color(255, 128, 0); - sp->underline=true; - - Ptr style=new DocumentStyle; - style->parentStyleName=L"#Context"; - style->styles=sp; - styles.Add(L"#ActiveLink", style); - } - } - - void DocumentModel::MergeStyle(Ptr style, Ptr parent) - { - if(!style->face && parent->face) style->face =parent->face; - if(!style->size && parent->size) style->size =parent->size; - if(!style->color && parent->color) style->color =parent->color; - if(!style->backgroundColor && parent->backgroundColor) style->backgroundColor =parent->backgroundColor; - if(!style->bold && parent->bold) style->bold =parent->bold; - if(!style->italic && parent->italic) style->italic =parent->italic; - if(!style->underline && parent->underline) style->underline =parent->underline; - if(!style->strikeline && parent->strikeline) style->strikeline =parent->strikeline; - if(!style->antialias && parent->antialias) style->antialias =parent->antialias; - if(!style->verticalAntialias && parent->verticalAntialias) style->verticalAntialias =parent->verticalAntialias; - } - - void DocumentModel::MergeBaselineStyle(Ptr style, const WString& styleName) - { - auto indexDst = styles.Keys().IndexOf(styleName); - Ptr sp = new DocumentStyleProperties; - MergeStyle(sp, style); - if (indexDst != -1) - { - MergeStyle(sp, styles.Values()[indexDst]->styles); - } - - if (indexDst == -1) - { - auto style = new DocumentStyle; - style->styles = sp; - styles.Add(styleName, style); - } - else - { - styles.Values()[indexDst]->styles = sp; - } - - FOREACH(Ptr, style, styles.Values()) - { - style->resolvedStyles = nullptr; - } - } - - void DocumentModel::MergeBaselineStyle(Ptr baselineDocument, const WString& styleName) - { - auto indexSrc = baselineDocument->styles.Keys().IndexOf(styleName + L"-Override"); - if (indexSrc == -1) - { - return; - } - - auto csp = baselineDocument->styles.Values()[indexSrc]->styles; - MergeBaselineStyle(csp, styleName); - } - - void DocumentModel::MergeBaselineStyles(Ptr baselineDocument) - { - MergeBaselineStyle(baselineDocument, DefaultStyleName); - MergeBaselineStyle(baselineDocument, SelectionStyleName); - MergeBaselineStyle(baselineDocument, ContextStyleName); - MergeBaselineStyle(baselineDocument, NormalLinkStyleName); - MergeBaselineStyle(baselineDocument, ActiveLinkStyleName); - } - - void DocumentModel::MergeDefaultFont(const FontProperties& defaultFont) - { - Ptr style = new DocumentStyleProperties; - - style->face =defaultFont.fontFamily; - style->size =DocumentFontSize(defaultFont.size, false); - style->bold =defaultFont.bold; - style->italic =defaultFont.italic; - style->underline =defaultFont.underline; - style->strikeline =defaultFont.strikeline; - style->antialias =defaultFont.antialias; - style->verticalAntialias =defaultFont.verticalAntialias; - - MergeBaselineStyle(style, DefaultStyleName); - } - - DocumentModel::ResolvedStyle DocumentModel::GetStyle(Ptr sp, const ResolvedStyle& context) - { - FontProperties font; - font.fontFamily =sp->face ?sp->face.Value() :context.style.fontFamily; - font.bold =sp->bold ?sp->bold.Value() :context.style.bold; - font.italic =sp->italic ?sp->italic.Value() :context.style.italic; - font.underline =sp->underline ?sp->underline.Value() :context.style.underline; - font.strikeline =sp->strikeline ?sp->strikeline.Value() :context.style.strikeline; - font.antialias =sp->antialias ?sp->antialias.Value() :context.style.antialias; - font.verticalAntialias =sp->verticalAntialias ?sp->verticalAntialias.Value() :context.style.verticalAntialias; - Color color =sp->color ?sp->color.Value() :context.color; - Color backgroundColor =sp->backgroundColor ?sp->backgroundColor.Value() :context.backgroundColor; - - if (sp->size) - { - font.size = (vint)(sp->size.Value().relative ? context.style.size * sp->size.Value().size : sp->size.Value().size); - } - else - { - font.size = context.style.size; - } - return ResolvedStyle(font, color, backgroundColor); - } - - DocumentModel::ResolvedStyle DocumentModel::GetStyle(const WString& styleName, const ResolvedStyle& context) - { - Ptr selectedStyle; - { - vint index=styles.Keys().IndexOf(styleName); - if(index!=-1) - { - selectedStyle=styles.Values()[index]; + return false; } else { - selectedStyle=styles[L"#Default"]; + InvokeOnItemModified(start, count, count); + return true; } } - if(!selectedStyle->resolvedStyles) + list::ListViewDataColumns& GuiBindableListView::ItemSource::GetDataColumns() { - Ptr sp = new DocumentStyleProperties; - selectedStyle->resolvedStyles = sp; + return dataColumns; + } - Ptr currentStyle; - WString currentName = styleName; - while(true) + list::ListViewColumns& GuiBindableListView::ItemSource::GetColumns() + { + return columns; + } + + // ===================== list::IListViewItemProvider ===================== + + void GuiBindableListView::ItemSource::NotifyAllItemsUpdate() + { + NotifyUpdate(0, Count()); + } + + void GuiBindableListView::ItemSource::NotifyAllColumnsUpdate() + { + for (vint i = 0; i < columnItemViewCallbacks.Count(); i++) { - vint index = styles.Keys().IndexOf(currentName); - if (index == -1) break; - currentStyle = styles.Values().Get(index); - currentName = currentStyle->parentStyleName; - MergeStyle(sp, currentStyle->styles); + columnItemViewCallbacks[i]->OnColumnChanged(); } } - Ptr sp=selectedStyle->resolvedStyles; - return GetStyle(sp, context); - } + // ===================== GuiListControl::IItemProvider ===================== - WString DocumentModel::GetText(bool skipNonTextContent) - { - stream::MemoryStream memoryStream; + vint GuiBindableListView::ItemSource::Count() { - stream::StreamWriter writer(memoryStream); - GetText(writer, skipNonTextContent); + if (!itemSource) return 0; + return itemSource->GetCount(); } - memoryStream.SeekFromBegin(0); - stream::StreamReader reader(memoryStream); - return reader.ReadToEnd(); - } - - void DocumentModel::GetText(stream::TextWriter& writer, bool skipNonTextContent) - { - for(vint i=0;i paragraph=paragraphs[i]; - paragraph->GetText(writer, skipNonTextContent); - if(i CreateContainer() = 0; - - AddContainerVisitor(RunRangeMap& _runRanges, vint _start, vint _end) - :runRanges(_runRanges) - , start(_start) - , end(_end) - , insertStyle(false) + if (itemSource) { - } - - void VisitContainer(DocumentContainerRun* run) - { - for (vint i = run->runs.Count() - 1; i >= 0; i--) + if (0 <= itemIndex && itemIndex < itemSource->GetCount()) { - Ptr subRun = run->runs[i]; - RunRange range = runRanges[subRun.Obj()]; - if (range.startGet(itemIndex); + } + } + return Value(); + } + + IDescriptable* GuiBindableListView::ItemSource::RequestView(const WString& identifier) + { + if (identifier == IListViewItemView::Identifier) + { + return (IListViewItemView*)this; + } + else if (identifier == ListViewColumnItemArranger::IColumnItemView::Identifier) + { + return (ListViewColumnItemArranger::IColumnItemView*)this; + } + else + { + return 0; + } + } + + // ===================== list::ListViewItemStyleProvider::IListViewItemView ===================== + + Ptr GuiBindableListView::ItemSource::GetSmallImage(vint itemIndex) + { + if (itemSource) + { + if (0 <= itemIndex && itemIndex < itemSource->GetCount()) + { + return ReadProperty(itemSource->Get(itemIndex), smallImageProperty); + } + } + return nullptr; + } + + Ptr GuiBindableListView::ItemSource::GetLargeImage(vint itemIndex) + { + if (itemSource) + { + if (0 <= itemIndex && itemIndex < itemSource->GetCount()) + { + return ReadProperty(itemSource->Get(itemIndex), largeImageProperty); + } + } + return nullptr; + } + + WString GuiBindableListView::ItemSource::GetText(vint itemIndex) + { + if (itemSource) + { + if (0 <= itemIndex && itemIndex < itemSource->GetCount() && columns.Count()>0) + { + return ReadProperty(itemSource->Get(itemIndex), columns[0]->GetTextProperty()); + } + } + return L""; + } + + WString GuiBindableListView::ItemSource::GetSubItem(vint itemIndex, vint index) + { + if (itemSource) + { + if (0 <= itemIndex && itemIndex < itemSource->GetCount() && 0 <= index && index < columns.Count() - 1) + { + return ReadProperty(itemSource->Get(itemIndex), columns[index + 1]->GetTextProperty()); + } + } + return L""; + } + + vint GuiBindableListView::ItemSource::GetDataColumnCount() + { + return dataColumns.Count(); + } + + vint GuiBindableListView::ItemSource::GetDataColumn(vint index) + { + return dataColumns[index]; + } + + vint GuiBindableListView::ItemSource::GetColumnCount() + { + return columns.Count(); + } + + WString GuiBindableListView::ItemSource::GetColumnText(vint index) + { + if (index < 0 || index >= columns.Count()) + { + return L""; + } + else + { + return columns[index]->GetText(); + } + } + + // ===================== list::ListViewColumnItemArranger::IColumnItemView ===================== + + bool GuiBindableListView::ItemSource::AttachCallback(ListViewColumnItemArranger::IColumnItemViewCallback* value) + { + if(columnItemViewCallbacks.Contains(value)) + { + return false; + } + else + { + columnItemViewCallbacks.Add(value); + return true; + } + } + + bool GuiBindableListView::ItemSource::DetachCallback(ListViewColumnItemArranger::IColumnItemViewCallback* value) + { + vint index = columnItemViewCallbacks.IndexOf(value); + if (index == -1) + { + return false; + } + else + { + columnItemViewCallbacks.Remove(value); + return true; + } + } + + vint GuiBindableListView::ItemSource::GetColumnSize(vint index) + { + if (index < 0 || index >= columns.Count()) + { + return 0; + } + else + { + return columns[index]->GetSize(); + } + } + + void GuiBindableListView::ItemSource::SetColumnSize(vint index, vint value) + { + if (index >= 0 && index < columns.Count()) + { + columns[index]->SetSize(value); + } + } + + GuiMenu* GuiBindableListView::ItemSource::GetDropdownPopup(vint index) + { + if (index < 0 || index >= columns.Count()) + { + return 0; + } + else + { + return columns[index]->GetDropdownPopup(); + } + } + + ColumnSortingState GuiBindableListView::ItemSource::GetSortingState(vint index) + { + if (index < 0 || index >= columns.Count()) + { + return ColumnSortingState::NotSorted; + } + else + { + return columns[index]->GetSortingState(); + } + } + +/*********************************************************************** +GuiBindableListView +***********************************************************************/ + + GuiBindableListView::GuiBindableListView(IStyleProvider* _styleProvider) + :GuiVirtualListView(_styleProvider, new ItemSource) + { + itemSource = dynamic_cast(GetItemProvider()); + + LargeImagePropertyChanged.SetAssociatedComposition(boundsComposition); + SmallImagePropertyChanged.SetAssociatedComposition(boundsComposition); + } + + GuiBindableListView::~GuiBindableListView() + { + } + + list::ListViewDataColumns& GuiBindableListView::GetDataColumns() + { + return itemSource->GetDataColumns(); + } + + list::ListViewColumns& GuiBindableListView::GetColumns() + { + return itemSource->GetColumns(); + } + + Ptr GuiBindableListView::GetItemSource() + { + return itemSource->GetItemSource(); + } + + void GuiBindableListView::SetItemSource(Ptr _itemSource) + { + itemSource->SetItemSource(_itemSource); + } + + ItemProperty> GuiBindableListView::GetLargeImageProperty() + { + return itemSource->largeImageProperty; + } + + void GuiBindableListView::SetLargeImageProperty(const ItemProperty>& value) + { + if (itemSource->largeImageProperty != value) + { + itemSource->largeImageProperty = value; + itemSource->UpdateBindingProperties(); + LargeImagePropertyChanged.Execute(GetNotifyEventArguments()); + } + } + + ItemProperty> GuiBindableListView::GetSmallImageProperty() + { + return itemSource->smallImageProperty; + } + + void GuiBindableListView::SetSmallImageProperty(const ItemProperty>& value) + { + if (itemSource->smallImageProperty != value) + { + itemSource->smallImageProperty = value; + itemSource->UpdateBindingProperties(); + SmallImagePropertyChanged.Execute(GetNotifyEventArguments()); + } + } + + description::Value GuiBindableListView::GetSelectedItem() + { + vint index = GetSelectedItemIndex(); + if (index == -1) return Value(); + return itemSource->Get(index); + } + +/*********************************************************************** +GuiBindableTreeView::ItemSourceNode +***********************************************************************/ + + void GuiBindableTreeView::ItemSourceNode::PrepareChildren() + { + if (!childrenVirtualList) + { + if (auto value = ReadProperty(itemSource, rootProvider->childrenProperty)) + { + if (auto ol = value.Cast()) { - insertStyle = false; - subRun->Accept(this); - if (insertStyle) + itemChangedEventHandler = ol->ItemChanged.Add([this](vint start, vint oldCount, vint newCount) { - Ptr containerRun = CreateContainer(); - run->runs.RemoveAt(i); - containerRun->runs.Add(subRun); - run->runs.Insert(i, containerRun); - } - } - } - insertStyle = false; - } - - void Visit(DocumentTextRun* run)override - { - insertStyle = true; - } - - void Visit(DocumentStylePropertiesRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentStyleApplicationRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentHyperlinkRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentImageRun* run)override - { - insertStyle = false; - } - - void Visit(DocumentEmbeddedObjectRun* run)override - { - insertStyle = false; - } - - void Visit(DocumentParagraphRun* run)override - { - VisitContainer(run); - } - }; - - class AddStyleVisitor : public AddContainerVisitor - { - public: - Ptr style; - - Ptr CreateContainer()override - { - Ptr containerRun = new DocumentStylePropertiesRun; - containerRun->style = CopyStyle(style); - return containerRun; - } - - AddStyleVisitor(RunRangeMap& _runRanges, vint _start, vint _end, Ptr _style) - :AddContainerVisitor(_runRanges, _start, _end) - , style(_style) - { - } - }; - - class AddHyperlinkVisitor : public AddContainerVisitor - { - public: - WString reference; - WString normalStyleName; - WString activeStyleName; - - Ptr CreateContainer()override - { - Ptr containerRun = new DocumentHyperlinkRun; - containerRun->reference = reference; - containerRun->normalStyleName = normalStyleName; - containerRun->activeStyleName = activeStyleName; - containerRun->styleName = normalStyleName; - return containerRun; - } - - AddHyperlinkVisitor(RunRangeMap& _runRanges, vint _start, vint _end, const WString& _reference, const WString& _normalStyleName, const WString& _activeStyleName) - :AddContainerVisitor(_runRanges, _start, _end) - , reference(_reference) - , normalStyleName(_normalStyleName) - , activeStyleName(_activeStyleName) - { - } - }; - - class AddStyleNameVisitor : public AddContainerVisitor - { - public: - WString styleName; - - Ptr CreateContainer()override - { - Ptr containerRun = new DocumentStyleApplicationRun; - containerRun->styleName = styleName; - return containerRun; - } - - AddStyleNameVisitor(RunRangeMap& _runRanges, vint _start, vint _end, const WString& _styleName) - :AddContainerVisitor(_runRanges, _start, _end) - , styleName(_styleName) - { - } - }; - } - using namespace document_operation_visitors; - - namespace document_editor - { - void AddStyle(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end, Ptr style) - { - AddStyleVisitor visitor(runRanges, start, end, style); - run->Accept(&visitor); - } - - void AddHyperlink(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end, const WString& reference, const WString& normalStyleName, const WString& activeStyleName) - { - AddHyperlinkVisitor visitor(runRanges, start, end, reference, normalStyleName, activeStyleName); - run->Accept(&visitor); - } - - void AddStyleName(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end, const WString& styleName) - { - AddStyleNameVisitor visitor(runRanges, start, end, styleName); - run->Accept(&visitor); - } - } - } -} - -/*********************************************************************** -RESOURCES\GUIDOCUMENTEDITOR_CLEARUNNECESSARYRUN.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - using namespace collections; - using namespace document_editor; - -/*********************************************************************** -Clear all runs that have an empty length -***********************************************************************/ - - namespace document_operation_visitors - { - class ClearRunVisitor : public Object, public DocumentRun::IVisitor - { - public: - vint start; - - ClearRunVisitor() - :start(0) - { - } - - void VisitContainer(DocumentContainerRun* run) - { - for (vint i = run->runs.Count() - 1; i >= 0; i--) - { - vint oldStart = start; - run->runs[i]->Accept(this); - if (oldStart == start) - { - run->runs.RemoveAt(i); - } - } - } - - void VisitContent(DocumentContentRun* run) - { - start += run->GetRepresentationText().Length(); - } - - void Visit(DocumentTextRun* run)override - { - VisitContent(run); - } - - void Visit(DocumentStylePropertiesRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentStyleApplicationRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentHyperlinkRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentImageRun* run)override - { - VisitContent(run); - } - - void Visit(DocumentEmbeddedObjectRun* run)override - { - VisitContent(run); - } - - void Visit(DocumentParagraphRun* run)override - { - VisitContainer(run); - } - }; - } - using namespace document_operation_visitors; - -/*********************************************************************** -Ensure DocumentStylePropertiesRun doesn't have a child which is another DocumentStylePropertiesRun -Remove DocumentStylePropertiesRun's property if it set a value but doesn't change the output -Remove DocumentStylePropertiesRun if it is empty or contains no text run -***********************************************************************/ - - namespace document_operation_visitors - { - class CompressStyleRunVisitor : public Object, public DocumentRun::IVisitor - { - public: - DocumentModel* model; - List resolvedStyles; - List> replacedRuns; - - CompressStyleRunVisitor(DocumentModel* _model) - :model(_model) - { - DocumentModel::ResolvedStyle resolvedStyle; - resolvedStyle = model->GetStyle(DocumentModel::DefaultStyleName, resolvedStyle); - resolvedStyles.Add(resolvedStyle); - } - - const DocumentModel::ResolvedStyle& GetCurrentResolvedStyle() - { - return resolvedStyles[resolvedStyles.Count() - 1]; - } - - void VisitContainer(DocumentContainerRun* run) - { - for (vint i = 0; i < run->runs.Count(); i++) - { - Ptr subRun = run->runs[i]; - replacedRuns.Clear(); - subRun->Accept(this); - if (replacedRuns.Count() > 0) - { - run->runs.RemoveAt(i); - for (vint j = 0; j < replacedRuns.Count(); j++) - { - run->runs.Insert(i + j, replacedRuns[j]); - } - i--; - } - } - } - - void Visit(DocumentTextRun* run)override - { - } - - bool OnlyImageOrObject(DocumentContainerRun* run) - { - bool onlyImageOrObject = true; - FOREACH(Ptr, subRun, run->runs) - { - if (!subRun.Cast() && !subRun.Cast()) - { - onlyImageOrObject = false; - break; - } - } - return onlyImageOrObject; - } - - void Visit(DocumentStylePropertiesRun* run)override - { - if (OnlyImageOrObject(run)) - { - CopyFrom(replacedRuns, run->runs); - return; - } - - const DocumentModel::ResolvedStyle& currentResolvedStyle = GetCurrentResolvedStyle(); - DocumentModel::ResolvedStyle resolvedStyle = model->GetStyle(run->style, currentResolvedStyle); - - if (currentResolvedStyle.style.fontFamily == resolvedStyle.style.fontFamily) run->style->face = Nullable(); - if (currentResolvedStyle.style.size == resolvedStyle.style.size) run->style->size = Nullable(); - if (currentResolvedStyle.color == resolvedStyle.color) run->style->color = Nullable(); - if (currentResolvedStyle.backgroundColor == resolvedStyle.backgroundColor) run->style->backgroundColor = Nullable(); - if (currentResolvedStyle.style.bold == resolvedStyle.style.bold) run->style->bold = Nullable(); - if (currentResolvedStyle.style.italic == resolvedStyle.style.italic) run->style->italic = Nullable(); - if (currentResolvedStyle.style.underline == resolvedStyle.style.underline) run->style->underline = Nullable(); - if (currentResolvedStyle.style.strikeline == resolvedStyle.style.strikeline) run->style->strikeline = Nullable(); - if (currentResolvedStyle.style.antialias == resolvedStyle.style.antialias) run->style->antialias = Nullable(); - if (currentResolvedStyle.style.verticalAntialias == resolvedStyle.style.verticalAntialias) run->style->verticalAntialias = Nullable(); - - if (run->style->face) goto CONTINUE_PROCESSING; - if (run->style->size) goto CONTINUE_PROCESSING; - if (run->style->color) goto CONTINUE_PROCESSING; - if (run->style->backgroundColor) goto CONTINUE_PROCESSING; - if (run->style->bold) goto CONTINUE_PROCESSING; - if (run->style->italic) goto CONTINUE_PROCESSING; - if (run->style->underline) goto CONTINUE_PROCESSING; - if (run->style->strikeline) goto CONTINUE_PROCESSING; - if (run->style->antialias) goto CONTINUE_PROCESSING; - if (run->style->verticalAntialias) goto CONTINUE_PROCESSING; - CopyFrom(replacedRuns, run->runs); - return; - - CONTINUE_PROCESSING: - if (From(run->runs).Cast().First(nullptr) != nullptr) - { - FOREACH(Ptr, subRun, run->runs) - { - if (auto styleRun = subRun.Cast()) - { - DocumentModel::MergeStyle(styleRun->style, run->style); - replacedRuns.Add(styleRun); - } - else - { - auto parentRun = CopyRun(run).Cast(); - parentRun->runs.Add(subRun); - replacedRuns.Add(parentRun); - } - } - return; - } - - resolvedStyles.Add(resolvedStyle); - VisitContainer(run); - resolvedStyles.RemoveAt(resolvedStyles.Count() - 1); - } - - void Visit(DocumentStyleApplicationRun* run)override - { - if (OnlyImageOrObject(run)) - { - CopyFrom(replacedRuns, run->runs); - return; - } - - const DocumentModel::ResolvedStyle& currentResolvedStyle = GetCurrentResolvedStyle(); - DocumentModel::ResolvedStyle resolvedStyle = model->GetStyle(run->styleName, currentResolvedStyle); - resolvedStyles.Add(resolvedStyle); - VisitContainer(run); - resolvedStyles.RemoveAt(resolvedStyles.Count() - 1); - } - - void Visit(DocumentHyperlinkRun* run)override - { - const DocumentModel::ResolvedStyle& currentResolvedStyle = GetCurrentResolvedStyle(); - DocumentModel::ResolvedStyle resolvedStyle = model->GetStyle(run->styleName, currentResolvedStyle); - resolvedStyles.Add(resolvedStyle); - VisitContainer(run); - resolvedStyles.RemoveAt(resolvedStyles.Count() - 1); - } - - void Visit(DocumentImageRun* run)override - { - } - - void Visit(DocumentEmbeddedObjectRun* run)override - { - } - - void Visit(DocumentParagraphRun* run)override - { - VisitContainer(run); - } - }; - } - using namespace document_operation_visitors; - -/*********************************************************************** -Merge sibling runs if they are exactly the same -***********************************************************************/ - - namespace document_operation_visitors - { - class MergeSiblingRunVisitor : public Object, public DocumentRun::IVisitor - { - public: - Ptr nextRun; - Ptr replacedRun; - - void Visit(DocumentTextRun* run)override - { - if (auto sibilingRun = nextRun.Cast()) - { - run->text += sibilingRun->text; - replacedRun = run; - } - } - - void Visit(DocumentStylePropertiesRun* run)override - { - if (auto sibilingRun = nextRun.Cast()) - { - if (run->style->face != sibilingRun->style->face) return; - if (run->style->size != sibilingRun->style->size) return; - if (run->style->color != sibilingRun->style->color) return; - if (run->style->backgroundColor != sibilingRun->style->backgroundColor) return; - if (run->style->bold != sibilingRun->style->bold) return; - if (run->style->italic != sibilingRun->style->italic) return; - if (run->style->underline != sibilingRun->style->underline) return; - if (run->style->strikeline != sibilingRun->style->strikeline) return; - if (run->style->antialias != sibilingRun->style->antialias) return; - if (run->style->verticalAntialias != sibilingRun->style->verticalAntialias) return; - - CopyFrom(run->runs, sibilingRun->runs, true); - replacedRun = run; - } - } - - void Visit(DocumentStyleApplicationRun* run)override - { - if (auto sibilingRun = nextRun.Cast()) - { - if (run->styleName == sibilingRun->styleName) - { - CopyFrom(run->runs, sibilingRun->runs, true); - replacedRun = run; - } - } - } - - void Visit(DocumentHyperlinkRun* run)override - { - if (auto sibilingRun = nextRun.Cast()) - { - if (run->styleName == sibilingRun->styleName && - run->normalStyleName == sibilingRun->normalStyleName && - run->activeStyleName == sibilingRun->activeStyleName && - run->reference == sibilingRun->reference) - { - CopyFrom(run->runs, sibilingRun->runs, true); - replacedRun = run; - } - } - } - - void Visit(DocumentImageRun* run)override - { - } - - void Visit(DocumentEmbeddedObjectRun* run)override - { - } - - void Visit(DocumentParagraphRun* run)override - { - } - }; - - class MergeSiblingRunRecursivelyVisitor : public Object, public DocumentRun::IVisitor - { - public: - Ptr replacedRun; - Ptr nextRun; - - void VisitContainer(DocumentContainerRun* run) - { - for (vint i = 0; i < run->runs.Count() - 1; i++) - { - auto currentRun = run->runs[i]; - auto nextRun = run->runs[i + 1]; - - MergeSiblingRunVisitor visitor; - visitor.nextRun = nextRun; - currentRun->Accept(&visitor); - - if (visitor.replacedRun) - { - run->runs.RemoveAt(i + 1); - run->runs[i] = visitor.replacedRun; - i--; - } - } - - for (vint i = 0; i < run->runs.Count() - 1; i++) - { - run->runs[i]->Accept(this); - } - } - - void Visit(DocumentTextRun* run)override - { - } - - void Visit(DocumentStylePropertiesRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentStyleApplicationRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentHyperlinkRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentImageRun* run)override - { - } - - void Visit(DocumentEmbeddedObjectRun* run)override - { - } - - void Visit(DocumentParagraphRun* run)override - { - VisitContainer(run); - } - }; - } - using namespace document_operation_visitors; - - namespace document_editor - { - void ClearUnnecessaryRun(DocumentParagraphRun* run, DocumentModel* model) - { - { - ClearRunVisitor visitor; - run->Accept(&visitor); - } - { - CompressStyleRunVisitor visitor(model); - run->Accept(&visitor); - } - { - MergeSiblingRunRecursivelyVisitor visitor; - run->Accept(&visitor); - } - } - } - } -} - -/*********************************************************************** -RESOURCES\GUIDOCUMENTEDITOR_CLONERUN.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - using namespace collections; - using namespace document_editor; - -/*********************************************************************** -Clone the current run without its children -If clonedRun field is assigned then it will be added to the cloned container run -***********************************************************************/ - - namespace document_operation_visitors - { - class CloneRunVisitor : public Object, public DocumentRun::IVisitor - { - public: - Ptr clonedRun; - - CloneRunVisitor(Ptr subRun) - :clonedRun(subRun) - { - } - - void VisitContainer(Ptr cloned) - { - if (clonedRun) - { - cloned->runs.Add(clonedRun); - } - clonedRun = cloned; - } - - void Visit(DocumentTextRun* run)override - { - Ptr cloned = new DocumentTextRun; - cloned->text = run->text; - clonedRun = cloned; - } - - void Visit(DocumentStylePropertiesRun* run)override - { - Ptr cloned = new DocumentStylePropertiesRun; - cloned->style = CopyStyle(run->style); - VisitContainer(cloned); - } - - void Visit(DocumentStyleApplicationRun* run)override - { - Ptr cloned = new DocumentStyleApplicationRun; - cloned->styleName = run->styleName; - - VisitContainer(cloned); - } - - void Visit(DocumentHyperlinkRun* run)override - { - Ptr cloned = new DocumentHyperlinkRun; - cloned->styleName = run->styleName; - cloned->normalStyleName = run->normalStyleName; - cloned->activeStyleName = run->activeStyleName; - cloned->reference = run->reference; - - VisitContainer(cloned); - } - - void Visit(DocumentImageRun* run)override - { - Ptr cloned = new DocumentImageRun; - cloned->size = run->size; - cloned->baseline = run->baseline; - cloned->image = run->image; - cloned->frameIndex = run->frameIndex; - cloned->source = run->source; - clonedRun = cloned; - } - - void Visit(DocumentEmbeddedObjectRun* run)override - { - Ptr cloned = new DocumentEmbeddedObjectRun; - cloned->name = run->name; - clonedRun = cloned; - } - - void Visit(DocumentParagraphRun* run)override - { - Ptr cloned = new DocumentParagraphRun; - cloned->alignment = run->alignment; - - VisitContainer(cloned); - } - }; - } - using namespace document_operation_visitors; - -/*********************************************************************** -Clone the current run with its children -***********************************************************************/ - - namespace document_operation_visitors - { - class CloneRunRecursivelyVisitor : public Object, public DocumentRun::IVisitor - { - public: - Ptr clonedRun; - RunRangeMap& runRanges; - vint start; - vint end; - bool deepCopy; - - CloneRunRecursivelyVisitor(RunRangeMap& _runRanges, vint _start, vint _end, bool _deepCopy) - :runRanges(_runRanges) - , start(_start) - , end(_end) - , deepCopy(_deepCopy) - { - } - - void VisitContainer(DocumentContainerRun* run) - { - clonedRun = 0; - RunRange range = runRanges[run]; - if (range.start <= end && start <= range.end) - { - if (start <= range.start && range.end <= end && !deepCopy) - { - clonedRun = run; - } - else - { - Ptr containerRun = CopyRun(run).Cast(); - FOREACH(Ptr, subRun, run->runs) - { - subRun->Accept(this); - if (clonedRun) + callback->OnBeforeItemModified(this, start, oldCount, newCount); + children.RemoveRange(start, oldCount); + for (vint i = 0; i < newCount; i++) { - containerRun->runs.Add(clonedRun); + Value value = childrenVirtualList->Get(start + i); + auto node = new ItemSourceNode(value, this); + children.Insert(start + i, node); } - } - clonedRun = containerRun; + callback->OnAfterItemModified(this, start, oldCount, newCount); + }); + childrenVirtualList = ol; } - } - } - - void Visit(DocumentTextRun* run)override - { - clonedRun = 0; - RunRange range = runRanges[run]; - if (range.start()) { - if (deepCopy) - { - clonedRun = CopyRun(run); - } - else - { - clonedRun = run; - } + childrenVirtualList = rl; } else { - Ptr textRun = new DocumentTextRun; - vint copyStart = start>range.start ? start : range.start; - vint copyEnd = endtext = run->text.Sub(copyStart - range.start, copyEnd - copyStart); - } - clonedRun = textRun; + childrenVirtualList = IValueList::Create(GetLazyList(value)); } } - } - void Visit(DocumentStylePropertiesRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentStyleApplicationRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentHyperlinkRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentImageRun* run)override - { - clonedRun = 0; - RunRange range = runRanges[run]; - if (range.startGetCount(); + for (vint i = 0; i < count; i++) { - if (deepCopy) - { - clonedRun = CopyRun(run); - } - else - { - clonedRun = run; - } + Value value = childrenVirtualList->Get(i); + auto node = new ItemSourceNode(value, this); + children.Add(node); } } - - void Visit(DocumentParagraphRun* run)override - { - VisitContainer(run); - } - }; - } - using namespace document_operation_visitors; - - namespace document_editor - { - Ptr CopyStyle(Ptr style) - { - Ptr newStyle = new DocumentStyleProperties; - - newStyle->face = style->face; - newStyle->size = style->size; - newStyle->color = style->color; - newStyle->backgroundColor = style->backgroundColor; - newStyle->bold = style->bold; - newStyle->italic = style->italic; - newStyle->underline = style->underline; - newStyle->strikeline = style->strikeline; - newStyle->antialias = style->antialias; - newStyle->verticalAntialias = style->verticalAntialias; - - return newStyle; } - Ptr CopyRun(DocumentRun* run) + void GuiBindableTreeView::ItemSourceNode::UnprepareChildren() { - CloneRunVisitor visitor(0); - run->Accept(&visitor); - return visitor.clonedRun; + if (itemChangedEventHandler) + { + auto ol = childrenVirtualList.Cast(); + ol->ItemChanged.Remove(itemChangedEventHandler); + itemChangedEventHandler = nullptr; + } + childrenVirtualList = nullptr; + FOREACH(Ptr, node, children) + { + node->UnprepareChildren(); + } + children.Clear(); } - Ptr CopyStyledText(List& styleRuns, const WString& text) + GuiBindableTreeView::ItemSourceNode::ItemSourceNode(const description::Value& _itemSource, ItemSourceNode* _parent) + :itemSource(_itemSource) + , rootProvider(_parent->rootProvider) + , parent(_parent) + , callback(_parent->callback) { - Ptr textRun = new DocumentTextRun; - textRun->text = text; - - CloneRunVisitor visitor(textRun); - for (vint i = styleRuns.Count() - 1; i >= 0; i--) - { - styleRuns[i]->Accept(&visitor); - } - - return visitor.clonedRun; } - Ptr CopyRunRecursively(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end, bool deepCopy) + GuiBindableTreeView::ItemSourceNode::ItemSourceNode(ItemSource* _rootProvider) + :rootProvider(_rootProvider) + , parent(nullptr) + , callback(_rootProvider) { - CloneRunRecursivelyVisitor visitor(runRanges, start, end, deepCopy); - run->Accept(&visitor); - return visitor.clonedRun; - } - } - } -} - -/*********************************************************************** -RESOURCES\GUIDOCUMENTEDITOR_COLLECTSTYLE.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - using namespace collections; - -/*********************************************************************** -Search all used style names -***********************************************************************/ - - namespace document_operation_visitors - { - class CollectStyleNameVisitor : public Object, public DocumentRun::IVisitor - { - public: - List& styleNames; - - CollectStyleNameVisitor(List& _styleNames) - :styleNames(_styleNames) - { - } - - void VisitContainer(DocumentContainerRun* run) - { - FOREACH(Ptr, subRun, run->runs) - { - subRun->Accept(this); - } - } - - void Visit(DocumentTextRun* run)override - { - } - - void Visit(DocumentStylePropertiesRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentStyleApplicationRun* run)override - { - if (!styleNames.Contains(run->styleName)) - { - styleNames.Add(run->styleName); - } - VisitContainer(run); - } - - void Visit(DocumentHyperlinkRun* run)override - { - if (!styleNames.Contains(run->normalStyleName)) - { - styleNames.Add(run->normalStyleName); - } - if (!styleNames.Contains(run->activeStyleName)) - { - styleNames.Add(run->activeStyleName); - } - VisitContainer(run); - } - - void Visit(DocumentImageRun* run)override - { - } - - void Visit(DocumentEmbeddedObjectRun* run)override - { - } - - void Visit(DocumentParagraphRun* run)override - { - VisitContainer(run); - } - }; - } - using namespace document_operation_visitors; - - namespace document_editor - { - void CollectStyleName(DocumentParagraphRun* run, List& styleNames) - { - CollectStyleNameVisitor visitor(styleNames); - run->Accept(&visitor); - } - } - } -} - -/*********************************************************************** -RESOURCES\GUIDOCUMENTEDITOR_CUTRUN.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - using namespace collections; - using namespace document_editor; - -/*********************************************************************** -Cut all runs into pieces so that a run either completely outside or inside the specified range -If a run decides that itself should be cut, then leftRun and rightRun contains new run that will be inserted before and after it -***********************************************************************/ - - namespace document_operation_visitors - { - class CutRunVisitor : public Object, public DocumentRun::IVisitor - { - public: - RunRangeMap& runRanges; - vint position; - Ptr leftRun; - Ptr rightRun; - - CutRunVisitor(RunRangeMap& _runRanges, vint _position) - :runRanges(_runRanges) - , position(_position) - { - } - - void VisitContainer(DocumentContainerRun* run) - { - vint leftCount = 0; - Ptr selectedRun; - - FOREACH(Ptr, subRun, run->runs) - { - RunRange range = runRanges[subRun.Obj()]; - if (range.startAccept(this); - if (leftRun && rightRun) - { - run->runs.RemoveAt(leftCount - 1); - run->runs.Insert(leftCount - 1, leftRun); - run->runs.Insert(leftCount, rightRun); - } - } - - Ptr leftContainer = CopyRun(run).Cast(); - Ptr rightContainer = CopyRun(run).Cast(); - for (vint i = 0; iruns.Count(); i++) - { - (iruns.Add(run->runs[i]); - } - leftRun = leftContainer; - rightRun = rightContainer; - } - - void Visit(DocumentTextRun* run)override - { - RunRange range = runRanges[run]; - - Ptr leftText = new DocumentTextRun; - leftText->text = run->text.Sub(0, position - range.start); - - Ptr rightText = new DocumentTextRun; - rightText->text = run->text.Sub(position - range.start, range.end - position); - - leftRun = leftText; - rightRun = rightText; - } - - void Visit(DocumentStylePropertiesRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentStyleApplicationRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentHyperlinkRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentImageRun* run)override - { - leftRun = 0; - rightRun = 0; - } - - void Visit(DocumentEmbeddedObjectRun* run)override - { - leftRun = 0; - rightRun = 0; - } - - void Visit(DocumentParagraphRun* run)override - { - VisitContainer(run); - } - }; - } - using namespace document_operation_visitors; - - namespace document_editor - { - void CutRun(DocumentParagraphRun* run, RunRangeMap& runRanges, vint position, Ptr& leftRun, Ptr& rightRun) - { - CutRunVisitor visitor(runRanges, position); - run->Accept(&visitor); - leftRun = visitor.leftRun; - rightRun = visitor.rightRun; - } - } - } -} - -/*********************************************************************** -RESOURCES\GUIDOCUMENTEDITOR_GETRUNRANGE.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - using namespace collections; - -/*********************************************************************** -Calculate range informations for each run object -***********************************************************************/ - - namespace document_operation_visitors - { - class GetRunRangeVisitor : public Object, public DocumentRun::IVisitor - { - public: - RunRangeMap& runRanges; - vint start; - - GetRunRangeVisitor(RunRangeMap& _runRanges) - :runRanges(_runRanges) - , start(0) - { - } - - void VisitContainer(DocumentContainerRun* run) - { - RunRange range; - range.start = start; - FOREACH(Ptr, subRun, run->runs) - { - subRun->Accept(this); - } - range.end = start; - runRanges.Add(run, range); - } - - void VisitContent(DocumentContentRun* run) - { - RunRange range; - range.start = start; - start += run->GetRepresentationText().Length(); - range.end = start; - runRanges.Add(run, range); - } - - void Visit(DocumentTextRun* run)override - { - VisitContent(run); - } - - void Visit(DocumentStylePropertiesRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentStyleApplicationRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentHyperlinkRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentImageRun* run)override - { - VisitContent(run); - } - - void Visit(DocumentEmbeddedObjectRun* run)override - { - VisitContent(run); - } - - void Visit(DocumentParagraphRun* run)override - { - VisitContainer(run); - } - }; - } - using namespace document_operation_visitors; - - namespace document_editor - { - void GetRunRange(DocumentParagraphRun* run, RunRangeMap& runRanges) - { - GetRunRangeVisitor visitor(runRanges); - run->Accept(&visitor); - } - } - } -} - -/*********************************************************************** -RESOURCES\GUIDOCUMENTEDITOR_LOCALEHYPERLINK.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - using namespace collections; - -/*********************************************************************** -Get the hyperlink run that contains the specified position -***********************************************************************/ - - namespace document_operation_visitors - { - class LocateHyperlinkVisitor : public Object, public DocumentRun::IVisitor - { - public: - Ptr package; - RunRangeMap& runRanges; - vint start; - vint end; - - LocateHyperlinkVisitor(RunRangeMap& _runRanges, Ptr _package, vint _start, vint _end) - :runRanges(_runRanges) - , package(_package) - , start(_start) - , end(_end) - { - } - - void VisitContainer(DocumentContainerRun* run) - { - Ptr selectedRun; - FOREACH(Ptr, subRun, run->runs) - { - RunRange range = runRanges[subRun.Obj()]; - if (range.start <= start && end <= range.end) - { - subRun->Accept(this); - break; - } - } - } - - void Visit(DocumentTextRun* run)override - { - } - - void Visit(DocumentStylePropertiesRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentStyleApplicationRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentHyperlinkRun* run)override - { - package->hyperlinks.Add(run); - } - - void Visit(DocumentImageRun* run)override - { - } - - void Visit(DocumentEmbeddedObjectRun* run)override - { - } - - void Visit(DocumentParagraphRun* run)override - { - VisitContainer(run); - } - }; - } - using namespace document_operation_visitors; - - namespace document_editor - { - Ptr LocateHyperlink(DocumentParagraphRun* run, RunRangeMap& runRanges, vint row, vint start, vint end) - { - auto package = MakePtr(); - package->row = row; - { - LocateHyperlinkVisitor visitor(runRanges, package, start, end); - run->Accept(&visitor); - } - - Ptr startRun, endRun; - FOREACH(Ptr, run, package->hyperlinks) - { - auto range = runRanges[run.Obj()]; - if (package->start == -1 || range.start < package->start) - { - package->start = range.start; - startRun = run; - } - if (package->end == -1 || range.end > package->end) - { - package->end = range.end; - endRun = run; - } - } - - while (startRun) - { - vint pos = runRanges[startRun.Obj()].start; - if (pos == 0) break; - - auto newPackage = MakePtr(); - LocateHyperlinkVisitor visitor(runRanges, newPackage, pos - 1, pos); - run->Accept(&visitor); - if (newPackage->hyperlinks.Count() == 0) break; - - auto newRun = newPackage->hyperlinks[0]; - if (startRun->reference != newRun->reference) break; - - auto range = runRanges[newRun.Obj()]; - package->hyperlinks.Add(newRun); - package->start = range.start; - startRun = newRun; - } - - vint length = runRanges[run].end; - while (endRun) - { - vint pos = runRanges[endRun.Obj()].end; - if (pos == length) break; - - auto newPackage = MakePtr(); - LocateHyperlinkVisitor visitor(runRanges, newPackage, pos, pos + 1); - run->Accept(&visitor); - if (newPackage->hyperlinks.Count() == 0) break; - - auto newRun = newPackage->hyperlinks[0]; - if (endRun->reference != newRun->reference) break; - - auto range = runRanges[newRun.Obj()]; - package->hyperlinks.Add(newRun); - package->end = range.end; - endRun = newRun; - } - - return package; - } - } - } -} - -/*********************************************************************** -RESOURCES\GUIDOCUMENTEDITOR_LOCALESTYLE.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - using namespace collections; - -/*********************************************************************** -Get all container runs that contain the specified position from top to bottom -***********************************************************************/ - - namespace document_operation_visitors - { - class LocateStyleVisitor : public Object, public DocumentRun::IVisitor - { - public: - List& locatedRuns; - RunRangeMap& runRanges; - vint position; - bool frontSide; - - LocateStyleVisitor(List& _locatedRuns, RunRangeMap& _runRanges, vint _position, bool _frontSide) - :locatedRuns(_locatedRuns) - , runRanges(_runRanges) - , position(_position) - , frontSide(_frontSide) - { - } - - void VisitContainer(DocumentContainerRun* run) - { - locatedRuns.Add(run); - Ptr selectedRun; - FOREACH(Ptr, subRun, run->runs) - { - RunRange range = runRanges[subRun.Obj()]; - if (position == range.start) - { - if (!frontSide) - { - selectedRun = subRun; - break; - } - } - else if (position == range.end) - { - if (frontSide) - { - selectedRun = subRun; - break; - } - } - else if (range.startAccept(this); - } - } - - void Visit(DocumentTextRun* run)override - { - } - - void Visit(DocumentStylePropertiesRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentStyleApplicationRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentHyperlinkRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentImageRun* run)override - { - } - - void Visit(DocumentEmbeddedObjectRun* run)override - { - } - - void Visit(DocumentParagraphRun* run)override - { - VisitContainer(run); - } - }; - } - using namespace document_operation_visitors; - - namespace document_editor - { - void LocateStyle(DocumentParagraphRun* run, RunRangeMap& runRanges, vint position, bool frontSide, List& locatedRuns) - { - LocateStyleVisitor visitor(locatedRuns, runRanges, position, frontSide); - run->Accept(&visitor); - } - } - } -} - -/*********************************************************************** -RESOURCES\GUIDOCUMENTEDITOR_REMOVECONTAINER.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - using namespace collections; - -/*********************************************************************** -Remove some containers that intersect with the specified range -If a run decides that itself should be removed, then replacedRuns contains all runs to replace itself -RemoveHyperlinkVisitor : Remove all hyperlinks that intersect with the specified range -RemoveStyleNameVisitor : Remove all style names that intersect with the specified range -ClearStyleVisitor : Remove all styles that intersect with the specified range -***********************************************************************/ - - namespace document_operation_visitors - { - class RemoveContainerVisitor : public Object, public DocumentRun::IVisitor - { - public: - RunRangeMap& runRanges; - vint start; - vint end; - List> replacedRuns; - - RemoveContainerVisitor(RunRangeMap& _runRanges, vint _start, vint _end) - :runRanges(_runRanges) - , start(_start) - , end(_end) - { - } - - void VisitContainer(DocumentContainerRun* run) - { - for (vint i = run->runs.Count() - 1; i >= 0; i--) - { - Ptr subRun = run->runs[i]; - RunRange range = runRanges[subRun.Obj()]; - if (range.startAccept(this); - if (replacedRuns.Count() != 1 || replacedRuns[0] != subRun) - { - run->runs.RemoveAt(i); - for (vint j = 0; jruns.Insert(i + j, replacedRuns[j]); - } - i += replacedRuns.Count(); - } - } - } - replacedRuns.Clear(); - replacedRuns.Add(run); - } - - void VisitContent(DocumentContentRun* run) - { - replacedRuns.Add(run); - } - - void RemoveContainer(DocumentContainerRun* run) - { - CopyFrom(replacedRuns, run->runs); - } - - void Visit(DocumentTextRun* run)override - { - VisitContent(run); - } - - void Visit(DocumentStylePropertiesRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentStyleApplicationRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentHyperlinkRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentImageRun* run)override - { - VisitContent(run); - } - - void Visit(DocumentEmbeddedObjectRun* run)override - { - VisitContent(run); - } - - void Visit(DocumentParagraphRun* run)override - { - VisitContainer(run); - } - }; - - class RemoveHyperlinkVisitor : public RemoveContainerVisitor - { - public: - RemoveHyperlinkVisitor(RunRangeMap& _runRanges, vint _start, vint _end) - :RemoveContainerVisitor(_runRanges, _start, _end) - { - } - - void Visit(DocumentHyperlinkRun* run)override - { - RemoveContainer(run); - } - }; - - class RemoveStyleNameVisitor : public RemoveContainerVisitor - { - public: - RemoveStyleNameVisitor(RunRangeMap& _runRanges, vint _start, vint _end) - :RemoveContainerVisitor(_runRanges, _start, _end) - { - } - - void Visit(DocumentStyleApplicationRun* run)override - { - RemoveContainer(run); - } - }; - - class ClearStyleVisitor : public RemoveContainerVisitor - { - public: - ClearStyleVisitor(RunRangeMap& _runRanges, vint _start, vint _end) - :RemoveContainerVisitor(_runRanges, _start, _end) - { - } - - void Visit(DocumentStylePropertiesRun* run)override - { - RemoveContainer(run); - } - - void Visit(DocumentStyleApplicationRun* run)override - { - RemoveContainer(run); - } - }; - } - using namespace document_operation_visitors; - - namespace document_editor - { - void RemoveHyperlink(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end) - { - RemoveHyperlinkVisitor visitor(runRanges, start, end); - run->Accept(&visitor); } - void RemoveStyleName(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end) + GuiBindableTreeView::ItemSourceNode::~ItemSourceNode() { - RemoveStyleNameVisitor visitor(runRanges, start, end); - run->Accept(&visitor); + SetItemSource(Value()); } - void ClearStyle(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end) + description::Value GuiBindableTreeView::ItemSourceNode::GetItemSource() { - ClearStyleVisitor visitor(runRanges, start, end); - run->Accept(&visitor); + return itemSource; } - } - } -} -/*********************************************************************** -RESOURCES\GUIDOCUMENTEDITOR_REMOVERUN.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - using namespace collections; - -/*********************************************************************** -Remove text run contents with the specified range, or other content runs that intersect with the range -If a run decides that itself should be removed, then replacedRuns contains all runs to replace itself -***********************************************************************/ - - namespace document_operation_visitors - { - class RemoveRunVisitor : public Object, public DocumentRun::IVisitor + void GuiBindableTreeView::ItemSourceNode::SetItemSource(const description::Value& _itemSource) { - public: - RunRangeMap& runRanges; - vint start; - vint end; - List> replacedRuns; + vint oldCount = GetChildCount(); + UnprepareChildren(); + itemSource = _itemSource; + vint newCount = GetChildCount(); + callback->OnBeforeItemModified(this, 0, oldCount, newCount); + callback->OnAfterItemModified(this, 0, oldCount, newCount); + } - RemoveRunVisitor(RunRangeMap& _runRanges, vint _start, vint _end) - :runRanges(_runRanges) - , start(_start) - , end(_end) - { - } + bool GuiBindableTreeView::ItemSourceNode::GetExpanding() + { + return this == rootProvider->rootNode.Obj() ? true : expanding; + } - void VisitContainer(DocumentContainerRun* run) + void GuiBindableTreeView::ItemSourceNode::SetExpanding(bool value) + { + if (this != rootProvider->rootNode.Obj() && expanding != value) { - if (start == end) return; - for (vint i = run->runs.Count() - 1; i >= 0; i--) + expanding = value; + if (expanding) { - Ptr subRun = run->runs[i]; - RunRange range = runRanges[subRun.Obj()]; - - if (range.start <= end && start <= range.end) - { - subRun->Accept(this); - if (replacedRuns.Count() == 0 || subRun != replacedRuns[0]) - { - run->runs.RemoveAt(i); - for (vint j = 0; jruns.Insert(i + j, replacedRuns[j]); - } - } - } - } - replacedRuns.Clear(); - replacedRuns.Add(run); - } - - void Visit(DocumentTextRun* run)override - { - replacedRuns.Clear(); - RunRange range = runRanges[run]; - - if (start <= range.start) - { - if (endtext = run->text.Sub(end - range.start, range.end - end); - replacedRuns.Add(run); - } + callback->OnItemExpanded(this); } else { - if (endtext = run->text.Sub(0, start - range.start); - secondRun->text = run->text.Sub(end - range.start, range.end - end); - - replacedRuns.Add(firstRun); - replacedRuns.Add(secondRun); - } - else - { - run->text = run->text.Sub(0, start - range.start); - replacedRuns.Add(run); - } - } - } - - void Visit(DocumentStylePropertiesRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentStyleApplicationRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentHyperlinkRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentImageRun* run)override - { - replacedRuns.Clear(); - } - - void Visit(DocumentEmbeddedObjectRun* run)override - { - replacedRuns.Clear(); - } - - void Visit(DocumentParagraphRun* run)override - { - VisitContainer(run); - } - }; - } - using namespace document_operation_visitors; - - namespace document_editor - { - void RemoveRun(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end) - { - RemoveRunVisitor visitor(runRanges, start, end); - run->Accept(&visitor); - } - } - } -} - -/*********************************************************************** -RESOURCES\GUIDOCUMENTEDITOR_REPLACESTYLENAME.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - using namespace collections; - -/*********************************************************************** -Replace a style name with another one -***********************************************************************/ - - namespace document_operation_visitors - { - class ReplaceStyleNameVisitor : public Object, public DocumentRun::IVisitor - { - public: - WString oldStyleName; - WString newStyleName; - - ReplaceStyleNameVisitor(const WString& _oldStyleName, const WString& _newStyleName) - :oldStyleName(_oldStyleName) - , newStyleName(_newStyleName) - { - } - - void VisitContainer(DocumentContainerRun* run) - { - FOREACH(Ptr, subRun, run->runs) - { - subRun->Accept(this); - } - } - - void Visit(DocumentTextRun* run)override - { - } - - void Visit(DocumentStylePropertiesRun* run)override - { - VisitContainer(run); - } - - void Visit(DocumentStyleApplicationRun* run)override - { - if (run->styleName == oldStyleName) run->styleName = newStyleName; - VisitContainer(run); - } - - void Visit(DocumentHyperlinkRun* run)override - { - if (run->styleName == oldStyleName) run->styleName = newStyleName; - if (run->normalStyleName == oldStyleName) run->normalStyleName = newStyleName; - if (run->activeStyleName == oldStyleName) run->activeStyleName = newStyleName; - VisitContainer(run); - } - - void Visit(DocumentImageRun* run)override - { - } - - void Visit(DocumentEmbeddedObjectRun* run)override - { - } - - void Visit(DocumentParagraphRun* run)override - { - VisitContainer(run); - } - }; - } - using namespace document_operation_visitors; - - namespace document_editor - { - void ReplaceStyleName(DocumentParagraphRun* run, const WString& oldStyleName, const WString& newStyleName) - { - ReplaceStyleNameVisitor visitor(oldStyleName, newStyleName); - run->Accept(&visitor); - } - } - } -} - -/*********************************************************************** -RESOURCES\GUIDOCUMENTEDITOR_SUMMERIZESTYLE.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - using namespace collections; - -/*********************************************************************** -Calculate if all text in the specified range has some common styles -***********************************************************************/ - - namespace document_operation_visitors - { - class SummerizeStyleVisitor : public Object, public DocumentRun::IVisitor - { - public: - RunRangeMap& runRanges; - DocumentModel* model; - vint start; - vint end; - Ptr style; - List resolvedStyles; - - SummerizeStyleVisitor(RunRangeMap& _runRanges, DocumentModel* _model, vint _start, vint _end) - :runRanges(_runRanges) - , model(_model) - , start(_start) - , end(_end) - { - DocumentModel::ResolvedStyle resolvedStyle; - resolvedStyle = model->GetStyle(DocumentModel::DefaultStyleName, resolvedStyle); - resolvedStyles.Add(resolvedStyle); - } - - const DocumentModel::ResolvedStyle& GetCurrentResolvedStyle() - { - return resolvedStyles[resolvedStyles.Count() - 1]; - } - - // --------------------------------------------------------- - - template - void SetStyleItem(Nullable DocumentStyleProperties::* dstField, T FontProperties::* srcField) - { - const DocumentModel::ResolvedStyle& src = GetCurrentResolvedStyle(); - if (style.Obj()->*dstField && (style.Obj()->*dstField).Value() != src.style.*srcField) - { - style.Obj()->*dstField = Nullable(); - } - } - - template - void SetStyleItem(Nullable DocumentStyleProperties::* dstField, T DocumentModel::ResolvedStyle::* srcField) - { - const DocumentModel::ResolvedStyle& src = GetCurrentResolvedStyle(); - if (style.Obj()->*dstField && (style.Obj()->*dstField).Value() != src.*srcField) - { - style.Obj()->*dstField = Nullable(); - } - } - - void SetStyleItem(Nullable DocumentStyleProperties::* dstField, vint FontProperties::* srcField) - { - const DocumentModel::ResolvedStyle& src = GetCurrentResolvedStyle(); - if (style.Obj()->*dstField) - { - auto dfs = (style.Obj()->*dstField).Value(); - if (dfs.relative || dfs.size != src.style.*srcField) - { - style.Obj()->*dstField = Nullable(); - } - } - } - - // --------------------------------------------------------- - - template - void OverrideStyleItem(Nullable DocumentStyleProperties::* dstField, T FontProperties::* srcField) - { - const DocumentModel::ResolvedStyle& src = GetCurrentResolvedStyle(); - style.Obj()->*dstField = src.style.*srcField; - } - - template - void OverrideStyleItem(Nullable DocumentStyleProperties::* dstField, T DocumentModel::ResolvedStyle::* srcField) - { - const DocumentModel::ResolvedStyle& src = GetCurrentResolvedStyle(); - style.Obj()->*dstField = src.*srcField; - } - - void OverrideStyleItem(Nullable DocumentStyleProperties::* dstField, vint FontProperties::* srcField) - { - const DocumentModel::ResolvedStyle& src = GetCurrentResolvedStyle(); - style.Obj()->*dstField = DocumentFontSize(src.style.*srcField, false); - } - - // --------------------------------------------------------- - - void VisitContainer(DocumentContainerRun* run) - { - for (vint i = run->runs.Count() - 1; i >= 0; i--) - { - Ptr subRun = run->runs[i]; - RunRange range = runRanges[subRun.Obj()]; - if (range.startAccept(this); - } - } - } - - void Visit(DocumentTextRun* run)override - { - const DocumentModel::ResolvedStyle& currentResolvedStyle = GetCurrentResolvedStyle(); - if (style) - { - SetStyleItem(&DocumentStyleProperties::face, &FontProperties::fontFamily); - SetStyleItem(&DocumentStyleProperties::size, &FontProperties::size); - SetStyleItem(&DocumentStyleProperties::color, &DocumentModel::ResolvedStyle::color); - SetStyleItem(&DocumentStyleProperties::backgroundColor, &DocumentModel::ResolvedStyle::backgroundColor); - SetStyleItem(&DocumentStyleProperties::bold, &FontProperties::bold); - SetStyleItem(&DocumentStyleProperties::italic, &FontProperties::italic); - SetStyleItem(&DocumentStyleProperties::underline, &FontProperties::underline); - SetStyleItem(&DocumentStyleProperties::strikeline, &FontProperties::strikeline); - SetStyleItem(&DocumentStyleProperties::antialias, &FontProperties::antialias); - SetStyleItem(&DocumentStyleProperties::verticalAntialias, &FontProperties::verticalAntialias); - } - else - { - style = new DocumentStyleProperties; - OverrideStyleItem(&DocumentStyleProperties::face, &FontProperties::fontFamily); - OverrideStyleItem(&DocumentStyleProperties::size, &FontProperties::size); - OverrideStyleItem(&DocumentStyleProperties::color, &DocumentModel::ResolvedStyle::color); - OverrideStyleItem(&DocumentStyleProperties::backgroundColor, &DocumentModel::ResolvedStyle::backgroundColor); - OverrideStyleItem(&DocumentStyleProperties::bold, &FontProperties::bold); - OverrideStyleItem(&DocumentStyleProperties::italic, &FontProperties::italic); - OverrideStyleItem(&DocumentStyleProperties::underline, &FontProperties::underline); - OverrideStyleItem(&DocumentStyleProperties::strikeline, &FontProperties::strikeline); - OverrideStyleItem(&DocumentStyleProperties::antialias, &FontProperties::antialias); - OverrideStyleItem(&DocumentStyleProperties::verticalAntialias, &FontProperties::verticalAntialias); - } - } - - void Visit(DocumentStylePropertiesRun* run)override - { - const DocumentModel::ResolvedStyle& currentResolvedStyle = GetCurrentResolvedStyle(); - DocumentModel::ResolvedStyle resolvedStyle = model->GetStyle(run->style, currentResolvedStyle); - resolvedStyles.Add(resolvedStyle); - VisitContainer(run); - resolvedStyles.RemoveAt(resolvedStyles.Count() - 1); - } - - void Visit(DocumentStyleApplicationRun* run)override - { - const DocumentModel::ResolvedStyle& currentResolvedStyle = GetCurrentResolvedStyle(); - DocumentModel::ResolvedStyle resolvedStyle = model->GetStyle(run->styleName, currentResolvedStyle); - resolvedStyles.Add(resolvedStyle); - VisitContainer(run); - resolvedStyles.RemoveAt(resolvedStyles.Count() - 1); - } - - void Visit(DocumentHyperlinkRun* run)override - { - const DocumentModel::ResolvedStyle& currentResolvedStyle = GetCurrentResolvedStyle(); - DocumentModel::ResolvedStyle resolvedStyle = model->GetStyle(run->styleName, currentResolvedStyle); - resolvedStyles.Add(resolvedStyle); - VisitContainer(run); - resolvedStyles.RemoveAt(resolvedStyles.Count() - 1); - } - - void Visit(DocumentImageRun* run)override - { - } - - void Visit(DocumentEmbeddedObjectRun* run)override - { - } - - void Visit(DocumentParagraphRun* run)override - { - VisitContainer(run); - } - }; - } - using namespace document_operation_visitors; - - namespace document_editor - { - Ptr SummerizeStyle(DocumentParagraphRun* run, RunRangeMap& runRanges, DocumentModel* model, vint start, vint end) - { - SummerizeStyleVisitor visitor(runRanges, model, start, end); - run->Accept(&visitor); - return visitor.style; - } - - template - void AggregateStyleItem(Ptr& dst, Ptr src, Nullable DocumentStyleProperties::* field) - { - if (dst.Obj()->*field && (!(src.Obj()->*field) || (dst.Obj()->*field).Value() != (src.Obj()->*field).Value())) - { - dst.Obj()->*field = Nullable(); - } - } - - void AggregateStyle(Ptr& dst, Ptr src) - { - AggregateStyleItem(dst, src, &DocumentStyleProperties::face); - AggregateStyleItem(dst, src, &DocumentStyleProperties::size); - AggregateStyleItem(dst, src, &DocumentStyleProperties::color); - AggregateStyleItem(dst, src, &DocumentStyleProperties::backgroundColor); - AggregateStyleItem(dst, src, &DocumentStyleProperties::bold); - AggregateStyleItem(dst, src, &DocumentStyleProperties::italic); - AggregateStyleItem(dst, src, &DocumentStyleProperties::underline); - AggregateStyleItem(dst, src, &DocumentStyleProperties::strikeline); - AggregateStyleItem(dst, src, &DocumentStyleProperties::antialias); - AggregateStyleItem(dst, src, &DocumentStyleProperties::verticalAntialias); - } - } - } -} - -/*********************************************************************** -RESOURCES\GUIDOCUMENT_EDIT.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - using namespace collections; - using namespace document_editor; - -/*********************************************************************** -DocumentModel::EditRangeOperations -***********************************************************************/ - - bool DocumentModel::CheckEditRange(TextPos begin, TextPos end, RunRangeMap& relatedRanges) - { - // check caret range - if(begin>end) return false; - if(begin.row<0 || begin.row>=paragraphs.Count()) return false; - if(end.row<0 || end.row>=paragraphs.Count()) return false; - - // determine run ranges - GetRunRange(paragraphs[begin.row].Obj(), relatedRanges); - if(begin.row!=end.row) - { - GetRunRange(paragraphs[end.row].Obj(), relatedRanges); - } - - // check caret range - RunRange beginRange=relatedRanges[paragraphs[begin.row].Obj()]; - RunRange endRange=relatedRanges[paragraphs[end.row].Obj()]; - if(begin.column<0 || begin.column>beginRange.end) return false; - if(end.column<0 || end.column>endRange.end) return false; - - return true; - } - - Ptr DocumentModel::CopyDocument(TextPos begin, TextPos end, bool deepCopy) - { - // check caret range - RunRangeMap runRanges; - if(!CheckEditRange(begin, end, runRanges)) return nullptr; - - // get ranges - for(vint i=begin.row+1;i newDocument=new DocumentModel; - - // copy paragraphs - if(begin.row==end.row) - { - newDocument->paragraphs.Add(CopyRunRecursively(paragraphs[begin.row].Obj(), runRanges, begin.column, end.column, deepCopy).Cast()); - } - else - { - for(vint i=begin.row;i<=end.row;i++) - { - Ptr paragraph=paragraphs[i]; - RunRange range=runRanges[paragraph.Obj()]; - if(i==begin.row) - { - newDocument->paragraphs.Add(CopyRunRecursively(paragraph.Obj(), runRanges, begin.column, range.end, deepCopy).Cast()); - } - else if(i==end.row) - { - newDocument->paragraphs.Add(CopyRunRecursively(paragraph.Obj(), runRanges, range.start, end.column, deepCopy).Cast()); - } - else if(deepCopy) - { - newDocument->paragraphs.Add(CopyRunRecursively(paragraph.Obj(), runRanges, range.start, range.end, deepCopy).Cast()); - } - else - { - newDocument->paragraphs.Add(paragraph); + callback->OnItemCollapsed(this); } } } - // copy styles - List styleNames; - FOREACH(Ptr, paragraph, newDocument->paragraphs) + vint GuiBindableTreeView::ItemSourceNode::CalculateTotalVisibleNodes() { - CollectStyleName(paragraph.Obj(), styleNames); - } - - for(vint i=0;istyles.Keys().Contains(styleName)) + if (!GetExpanding()) { - Ptr style=styles[styleName]; - if(deepCopy) - { - Ptr newStyle=new DocumentStyle; - newStyle->parentStyleName=style->parentStyleName; - newStyle->styles=CopyStyle(style->styles); - newStyle->resolvedStyles=CopyStyle(style->resolvedStyles); - newDocument->styles.Add(styleName, newStyle); - } - else - { - newDocument->styles.Add(styleName, style); - } - - if(!styleNames.Contains(style->parentStyleName)) - { - styleNames.Add(style->parentStyleName); - } - } - } - - return newDocument; - } - - Ptr DocumentModel::CopyDocument() - { - // determine run ranges - RunRangeMap runRanges; - vint lastParagraphIndex = paragraphs.Count() - 1; - GetRunRange(paragraphs[lastParagraphIndex].Obj(), runRanges); - - TextPos begin(0, 0); - TextPos end(lastParagraphIndex, runRanges[paragraphs[lastParagraphIndex].Obj()].end); - return CopyDocument(begin, end, true); - } - - bool DocumentModel::CutParagraph(TextPos position) - { - if(position.row<0 || position.row>=paragraphs.Count()) return false; - - Ptr paragraph=paragraphs[position.row]; - RunRangeMap runRanges; - Ptr leftRun, rightRun; - - GetRunRange(paragraph.Obj(), runRanges); - CutRun(paragraph.Obj(), runRanges, position.column, leftRun, rightRun); - - CopyFrom(paragraph->runs, leftRun.Cast()->runs); - CopyFrom(paragraph->runs, rightRun.Cast()->runs, true); - - return true; - } - - bool DocumentModel::CutEditRange(TextPos begin, TextPos end) - { - // check caret range - if(begin>end) return false; - if(begin.row<0 || begin.row>=paragraphs.Count()) return false; - if(end.row<0 || end.row>=paragraphs.Count()) return false; - - // cut paragraphs - CutParagraph(begin); - if(begin!=end) - { - CutParagraph(end); - } - return true; - } - - bool DocumentModel::EditContainer(TextPos begin, TextPos end, const Func& editor) - { - if(begin==end) return false; - - // cut paragraphs - if(!CutEditRange(begin, end)) return false; - - // check caret range - RunRangeMap runRanges; - if(!CheckEditRange(begin, end, runRanges)) return false; - - // edit container - if(begin.row==end.row) - { - editor(paragraphs[begin.row].Obj(), runRanges, begin.column, end.column); - } - else - { - for(vint i=begin.row;i<=end.row;i++) - { - Ptr paragraph=paragraphs[i]; - if(begin.row replaceToModel, bool copy) - { - // check caret range - RunRangeMap runRanges; - if(!CheckEditRange(begin, end, runRanges)) return -1; - - auto model = replaceToModel; - if (copy) - { - model = replaceToModel->CopyDocument(); - } - - // calculate new names for the model's styles to prevent conflicting - List oldNames, newNames; - CopyFrom(oldNames, model->styles.Keys()); - CopyFrom(newNames, model->styles.Keys()); - for(vint i=0;istyles.Keys().Contains(newName)) - { - newNames[i]=newName; - break; - } - } - } - } - - // rename model's styles - typedef Pair NamePair; - FOREACH(NamePair, name, From(oldNames).Pairwise(newNames)) - { - model->RenameStyle(name.key, name.value); - } - FOREACH(WString, name, newNames) - { - if((name.Length()==0 || name[0]!=L'#') && !styles.Keys().Contains(name)) - { - styles.Add(name, model->styles[name]); - } - } - - // edit runs - Array> runs; - CopyFrom(runs, model->paragraphs); - return EditRunNoCopy(begin, end, runs); - } - - vint DocumentModel::EditRunNoCopy(TextPos begin, TextPos end, const collections::Array>& runs) - { - // check caret range - RunRangeMap runRanges; - if(!CheckEditRange(begin, end, runRanges)) return -1; - - // remove unnecessary paragraphs - if(begin.row!=end.row) - { - for(vint i=end.row-1;i>begin.row;i--) - { - paragraphs.RemoveAt(i); - } - end.row=begin.row+1; - } - - // remove unnecessary runs and ensure begin.row!=end.row - if(begin.row==end.row) - { - RemoveRun(paragraphs[begin.row].Obj(), runRanges, begin.column, end.column); - - Ptr leftRun, rightRun; - runRanges.Clear(); - GetRunRange(paragraphs[begin.row].Obj(), runRanges); - CutRun(paragraphs[begin.row].Obj(), runRanges, begin.column, leftRun, rightRun); - - paragraphs.RemoveAt(begin.row); - paragraphs.Insert(begin.row, leftRun.Cast()); - paragraphs.Insert(begin.row+1, rightRun.Cast()); - end.row=begin.row+1; - } - else - { - RemoveRun(paragraphs[begin.row].Obj(), runRanges, begin.column, runRanges[paragraphs[begin.row].Obj()].end); - RemoveRun(paragraphs[end.row].Obj(), runRanges, 0, end.column); - } - - // insert new paragraphs - Ptr beginParagraph=paragraphs[begin.row]; - Ptr endParagraph=paragraphs[end.row]; - if(runs.Count()==0) - { - CopyFrom(beginParagraph->runs, endParagraph->runs, true); - paragraphs.RemoveAt(end.row); - } - else if(runs.Count()==1) - { - CopyFrom(beginParagraph->runs, runs[0]->runs, true); - CopyFrom(beginParagraph->runs, endParagraph->runs, true); - paragraphs.RemoveAt(end.row); - } - else - { - Ptr newBeginRuns=runs[0]; - CopyFrom(beginParagraph->runs, newBeginRuns->runs, true); - - Ptr newEndRuns=runs[runs.Count()-1]; - if (newEndRuns->alignment) - { - endParagraph->alignment = newEndRuns->alignment; - } - for(vint i=0;iruns.Count();i++) - { - endParagraph->runs.Insert(i, newEndRuns->runs[i]); + return 1; } - for(vint i=1;i, child, children) { - paragraphs.Insert(begin.row+i, runs[i]); + count += child->CalculateTotalVisibleNodes(); } + return count; } - // clear unnecessary runs - vint rows=runs.Count()==0?1:runs.Count(); - for(vint i=0;i& text) - { - // check caret range - RunRangeMap runRanges; - if(!CheckEditRange(begin, end, runRanges)) return -1; - - // calcuate the position to get the text style - TextPos stylePosition; - if(frontSide) + tree::INodeProvider* GuiBindableTreeView::ItemSourceNode::GetParent() { - stylePosition=begin; - if(stylePosition.column==0) + return parent; + } + + tree::INodeProvider* GuiBindableTreeView::ItemSourceNode::GetChild(vint index) + { + PrepareChildren(); + if (0 <= index && index < children.Count()) { - frontSide=false; + return children[index].Obj(); } - } - else - { - stylePosition=end; - if(stylePosition.column==runRanges[paragraphs[end.row].Obj()].end) - { - frontSide=true; - } - } - - // copy runs that contains the target style for new text - List styleRuns; - LocateStyle(paragraphs[stylePosition.row].Obj(), runRanges, stylePosition.column, frontSide, styleRuns); - - // create paragraphs - Array> runs(text.Count()); - for(vint i=0;i paragraph=CopyStyledText(styleRuns, text[i]); - runs[i]=paragraph.Cast(); - } - - // replace the paragraphs - return EditRunNoCopy(begin, end, runs); - } - -/*********************************************************************** -DocumentModel::EditStyle -***********************************************************************/ - - bool DocumentModel::EditStyle(TextPos begin, TextPos end, Ptr style) - { - return EditContainer(begin, end, [=](DocumentParagraphRun* paragraph, RunRangeMap& runRanges, vint start, vint end) - { - AddStyle(paragraph, runRanges, start, end, style); - }); - } - -/*********************************************************************** -DocumentModel::EditImage -***********************************************************************/ - - Ptr DocumentModel::EditImage(TextPos begin, TextPos end, Ptr image) - { - Ptr imageRun=new DocumentImageRun; - imageRun->size=image->GetImage()->GetFrame(image->GetFrameIndex())->GetSize(); - imageRun->baseline=imageRun->size.y; - imageRun->image=image->GetImage(); - imageRun->frameIndex=image->GetFrameIndex(); - - Ptr paragraph=new DocumentParagraphRun; - paragraph->runs.Add(imageRun); - - Array> runs(1); - runs[0]=paragraph; - if(EditRunNoCopy(begin, end, runs)) - { - return imageRun; - } - else - { return 0; } - } + + void GuiBindableTreeView::ItemSourceNode::Increase() + { + } + + void GuiBindableTreeView::ItemSourceNode::Release() + { + } /*********************************************************************** -DocumentModel::EditHyperlink +GuiBindableTreeView::ItemSource ***********************************************************************/ - bool DocumentModel::EditHyperlink(vint paragraphIndex, vint begin, vint end, const WString& reference, const WString& normalStyleName, const WString& activeStyleName) - { - auto package = GetHyperlink(paragraphIndex, begin, end); - if (package->hyperlinks.Count() > 0) + GuiBindableTreeView::ItemSource::ItemSource() { - FOREACH(Ptr, run, package->hyperlinks) + rootNode = new ItemSourceNode(this); + } + + GuiBindableTreeView::ItemSource::~ItemSource() + { + } + + description::Value GuiBindableTreeView::ItemSource::GetItemSource() + { + return rootNode->GetItemSource(); + } + + void GuiBindableTreeView::ItemSource::SetItemSource(const description::Value& _itemSource) + { + rootNode->SetItemSource(_itemSource); + } + + void GuiBindableTreeView::ItemSource::UpdateBindingProperties(bool updateChildrenProperty) + { + vint oldCount = rootNode->GetChildCount(); + if (updateChildrenProperty) { - run->reference = reference; - run->normalStyleName = normalStyleName; - run->activeStyleName = activeStyleName; - run->styleName = normalStyleName; + rootNode->UnprepareChildren(); } - return true; + vint newCount = rootNode->GetChildCount(); + OnBeforeItemModified(rootNode.Obj(), 0, oldCount, newCount); + OnAfterItemModified(rootNode.Obj(), 0, oldCount, newCount); } - else if (RemoveHyperlink(paragraphIndex, begin, end)) + + // ===================== tree::INodeRootProvider ===================== + + tree::INodeProvider* GuiBindableTreeView::ItemSource::GetRootNode() { - CutEditRange(TextPos(paragraphIndex, begin), TextPos(paragraphIndex, end)); - - RunRangeMap runRanges; - Ptr paragraph = paragraphs[paragraphIndex]; - GetRunRange(paragraph.Obj(), runRanges); - AddHyperlink(paragraph.Obj(), runRanges, begin, end, reference, normalStyleName, activeStyleName); - - ClearUnnecessaryRun(paragraph.Obj(), this); - return true; + return rootNode.Obj(); } - return false; - } - bool DocumentModel::RemoveHyperlink(vint paragraphIndex, vint begin, vint end) - { - RunRangeMap runRanges; - if (!CheckEditRange(TextPos(paragraphIndex, begin), TextPos(paragraphIndex, end), runRanges)) return 0; - - auto paragraph = paragraphs[paragraphIndex]; - auto package = LocateHyperlink(paragraph.Obj(), runRanges, paragraphIndex, begin, end); - document_editor::RemoveHyperlink(paragraph.Obj(), runRanges, package->start, package->end); - ClearUnnecessaryRun(paragraph.Obj(), this); - return true; - } - - Ptr DocumentModel::GetHyperlink(vint paragraphIndex, vint begin, vint end) - { - RunRangeMap runRanges; - if (!CheckEditRange(TextPos(paragraphIndex, begin), TextPos(paragraphIndex, end), runRanges)) return 0; - - auto paragraph = paragraphs[paragraphIndex]; - return LocateHyperlink(paragraph.Obj(), runRanges, paragraphIndex, begin, end); - } - -/*********************************************************************** -DocumentModel::EditStyleName -***********************************************************************/ - - bool DocumentModel::EditStyleName(TextPos begin, TextPos end, const WString& styleName) - { - return EditContainer(begin, end, [=](DocumentParagraphRun* paragraph, RunRangeMap& runRanges, vint start, vint end) + WString GuiBindableTreeView::ItemSource::GetTextValue(tree::INodeProvider* node) { - AddStyleName(paragraph, runRanges, start, end, styleName); - }); - } + return ReadProperty(GetBindingValue(node), textProperty); + } - bool DocumentModel::RemoveStyleName(TextPos begin, TextPos end) - { - return EditContainer(begin, end, [=](DocumentParagraphRun* paragraph, RunRangeMap& runRanges, vint start, vint end) + description::Value GuiBindableTreeView::ItemSource::GetBindingValue(tree::INodeProvider* node) { - document_editor::RemoveStyleName(paragraph, runRanges, start, end); - }); - } - - bool DocumentModel::RenameStyle(const WString& oldStyleName, const WString& newStyleName) - { - vint index=styles.Keys().IndexOf(oldStyleName); - if(index==-1) return false; - if(styles.Keys().Contains(newStyleName)) return false; - - Ptr style=styles.Values()[index]; - styles.Remove(oldStyleName); - styles.Add(newStyleName, style); - - FOREACH(Ptr, subStyle, styles.Values()) - { - if(subStyle->parentStyleName==oldStyleName) + if (auto itemSourceNode = dynamic_cast(node)) { - subStyle->parentStyleName=newStyleName; + return itemSourceNode->GetItemSource(); } + return Value(); } - FOREACH(Ptr, paragraph, paragraphs) + IDescriptable* GuiBindableTreeView::ItemSource::RequestView(const WString& identifier) { - ReplaceStyleName(paragraph.Obj(), oldStyleName, newStyleName); - } - return true; - } - -/*********************************************************************** -DocumentModel::ClearStyle -***********************************************************************/ - - bool DocumentModel::ClearStyle(TextPos begin, TextPos end) - { - return EditContainer(begin, end, [=](DocumentParagraphRun* paragraph, RunRangeMap& runRanges, vint start, vint end) - { - document_editor::ClearStyle(paragraph, runRanges, start, end); - }); - } - -/*********************************************************************** -DocumentModel::ClearStyle -***********************************************************************/ - - Ptr DocumentModel::SummarizeStyle(TextPos begin, TextPos end) - { - Ptr style; - RunRangeMap runRanges; - - if(begin==end) goto END_OF_SUMMERIZING; - - // check caret range - if(!CheckEditRange(begin, end, runRanges)) return nullptr; - - // summerize container - if(begin.row==end.row) - { - style=SummerizeStyle(paragraphs[begin.row].Obj(), runRanges, this, begin.column, end.column); - } - else - { - for(vint i=begin.row;i<=end.row;i++) + if(identifier==ITreeViewItemView::Identifier) { - Ptr paragraph=paragraphs[i]; - if(begin.row paragraphStyle; - if(i==begin.row) - { - paragraphStyle=SummerizeStyle(paragraph.Obj(), runRanges, this, begin.column, range.end); - } - else if(i==end.row) - { - paragraphStyle=SummerizeStyle(paragraph.Obj(), runRanges, this, range.start, end.column); - } - else - { - paragraphStyle=SummerizeStyle(paragraph.Obj(), runRanges, this, range.start, range.end); - } - - if(!style) - { - style=paragraphStyle; - } - else if(paragraphStyle) - { - AggregateStyle(style, paragraphStyle); - } - } - } - - END_OF_SUMMERIZING: - if(!style) - { - style=new DocumentStyleProperties; - } - return style; - } - - Nullable DocumentModel::SummarizeParagraphAlignment(TextPos begin, TextPos end) - { - bool left = false; - bool center = false; - bool right = false; - - RunRangeMap runRanges; - if (!CheckEditRange(begin, end, runRanges)) return {}; - - for (vint i = begin.row; i <= end.row; i++) - { - auto paragraph = paragraphs[i]; - if (paragraph->alignment) - { - switch (paragraph->alignment.Value()) - { - case Alignment::Left: - left = true; - break; - case Alignment::Center: - center = true; - break; - case Alignment::Right: - right = true; - break; - } + return (ITreeViewItemView*)this; } else { - left = true; + return 0; } } - if (left && !center && !right) return Alignment::Left; - if (!left && center && !right) return Alignment::Center; - if (!left && !center && right) return Alignment::Right; - return {}; + // ===================== tree::ITreeViewItemView ===================== + + Ptr GuiBindableTreeView::ItemSource::GetNodeImage(tree::INodeProvider* node) + { + if (auto itemSourceNode = dynamic_cast(node)) + { + return ReadProperty(itemSourceNode->GetItemSource(), imageProperty); + } + return nullptr; + } + +/*********************************************************************** +GuiBindableTreeView +***********************************************************************/ + + GuiBindableTreeView::GuiBindableTreeView(IStyleProvider* _styleProvider) + :GuiVirtualTreeView(_styleProvider, new ItemSource) + { + itemSource = dynamic_cast(GetNodeRootProvider()); + + TextPropertyChanged.SetAssociatedComposition(boundsComposition); + ImagePropertyChanged.SetAssociatedComposition(boundsComposition); + ChildrenPropertyChanged.SetAssociatedComposition(boundsComposition); + } + + GuiBindableTreeView::~GuiBindableTreeView() + { + } + + description::Value GuiBindableTreeView::GetItemSource() + { + return itemSource->GetItemSource(); + } + + void GuiBindableTreeView::SetItemSource(description::Value _itemSource) + { + itemSource->SetItemSource(_itemSource); + } + + ItemProperty GuiBindableTreeView::GetTextProperty() + { + return itemSource->textProperty; + } + + void GuiBindableTreeView::SetTextProperty(const ItemProperty& value) + { + if (itemSource->textProperty != value) + { + itemSource->textProperty = value; + itemSource->UpdateBindingProperties(false); + TextPropertyChanged.Execute(GetNotifyEventArguments()); + } + } + + ItemProperty> GuiBindableTreeView::GetImageProperty() + { + return itemSource->imageProperty; + } + + void GuiBindableTreeView::SetImageProperty(const ItemProperty>& value) + { + if (itemSource->imageProperty != value) + { + itemSource->imageProperty = value; + itemSource->UpdateBindingProperties(false); + ImagePropertyChanged.Execute(GetNotifyEventArguments()); + } + } + + ItemProperty> GuiBindableTreeView::GetChildrenProperty() + { + return itemSource->childrenProperty; + } + + void GuiBindableTreeView::SetChildrenProperty(const ItemProperty>& value) + { + if (itemSource->childrenProperty != value) + { + itemSource->childrenProperty = value; + itemSource->UpdateBindingProperties(true); + ChildrenPropertyChanged.Execute(GetNotifyEventArguments()); + } + } + + description::Value GuiBindableTreeView::GetSelectedItem() + { + vint index = GetSelectedItemIndex(); + if (index == -1) return Value(); + + Value result; + if (auto node = nodeItemView->RequestNode(index)) + { + if (auto itemSourceNode = dynamic_cast(node)) + { + result = itemSourceNode->GetItemSource(); + } + nodeItemView->ReleaseNode(node); + } + return result; + } + } + } +} + + +/*********************************************************************** +.\CONTROLS\LISTCONTROLPACKAGE\GUIDATAGRIDCONTROLS.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace controls + { + namespace list + { + using namespace compositions; + using namespace collections; + using namespace description; + using namespace templates; + + const wchar_t* const IDataGridView::Identifier = L"vl::presentation::controls::list::IDataGridView"; + +/*********************************************************************** +DefaultDataGridItemTemplate +***********************************************************************/ + + IDataVisualizerFactory* DefaultDataGridItemTemplate::GetDataVisualizerFactory(vint row, vint column) + { + if (auto dataGrid = dynamic_cast(listControl)) + { + if (auto factory = dataGrid->dataGridView->GetCellDataVisualizerFactory(row, column)) + { + return factory; + } + + if (column == 0) + { + return dataGrid->defaultMainColumnVisualizerFactory.Obj(); + } + else + { + return dataGrid->defaultSubColumnVisualizerFactory.Obj(); + } + + } + + return nullptr; + } + + IDataEditorFactory* DefaultDataGridItemTemplate::GetDataEditorFactory(vint row, vint column) + { + if (auto dataGrid = dynamic_cast(listControl)) + { + return dataGrid->dataGridView->GetCellDataEditorFactory(row, column); + } + return nullptr; + } + + vint DefaultDataGridItemTemplate::GetCellColumnIndex(compositions::GuiGraphicsComposition* composition) + { + for (vint i = 0; i < textTable->GetColumns(); i++) + { + auto cell = textTable->GetSitedCell(0, i); + if (composition == cell) + { + return i; + } + } + return -1; + } + + void DefaultDataGridItemTemplate::OnCellButtonUp(compositions::GuiGraphicsComposition* sender, bool openEditor) + { + if (auto dataGrid = dynamic_cast(listControl)) + { + vint index = GetCellColumnIndex(sender); + if (index != -1) + { + if (currentEditor && dataGrid->GetSelectedCell().column == index) + { + return; + } + + vint currentRow = GetIndex(); + dataGrid->StartEdit(currentRow, index); + } + } + } + + bool DefaultDataGridItemTemplate::IsInEditor(compositions::GuiMouseEventArgs& arguments) + { + if (auto dataGrid = dynamic_cast(listControl)) + { + if (!dataGrid->currentEditor) return false; + auto editorComposition = dataGrid->currentEditor->GetTemplate(); + auto currentComposition = arguments.eventSource; + + while (currentComposition) + { + if (currentComposition == editorComposition) + { + arguments.handled = true; + return true; + } + else if (currentComposition == this) + { + break; + } + else + { + currentComposition = currentComposition->GetParent(); + } + } + + } + return false; + } + + void DefaultDataGridItemTemplate::OnCellButtonDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) + { + IsInEditor(arguments); + } + + void DefaultDataGridItemTemplate::OnCellLeftButtonUp(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) + { + if (auto dataGrid = dynamic_cast(listControl)) + { + if (!IsInEditor(arguments)) + { + if (dataGrid->GetVisuallyEnabled()) + { + OnCellButtonUp(sender, true); + } + } + } + } + + void DefaultDataGridItemTemplate::OnCellRightButtonUp(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) + { + if (auto dataGrid = dynamic_cast(listControl)) + { + if (!IsInEditor(arguments)) + { + if (dataGrid->GetVisuallyEnabled()) + { + OnCellButtonUp(sender, false); + } + } + } + } + + void DefaultDataGridItemTemplate::OnColumnChanged() + { + UpdateSubItemSize(); + } + + void DefaultDataGridItemTemplate::OnInitialize() + { + DefaultListViewItemTemplate::OnInitialize(); + { + textTable = new GuiTableComposition; + textTable->SetAlignmentToParent(Margin(0, 0, 0, 0)); + textTable->SetRowsAndColumns(1, 1); + textTable->SetRowOption(0, GuiCellOption::MinSizeOption()); + textTable->SetColumnOption(0, GuiCellOption::AbsoluteOption(0)); + AddChild(textTable); + } + + if (auto dataGrid = dynamic_cast(listControl)) + { + vint columnCount = dataGrid->listViewItemView->GetColumnCount(); + vint itemIndex = GetIndex(); + + dataVisualizers.Resize(columnCount); + for (vint i = 0; i < dataVisualizers.Count(); i++) + { + auto factory = GetDataVisualizerFactory(itemIndex, i); + dataVisualizers[i] = factory->CreateVisualizer(dataGrid); + } + + textTable->SetRowsAndColumns(1, columnCount); + for (vint i = 0; i < columnCount; i++) + { + auto cell = new GuiCellComposition; + textTable->AddChild(cell); + cell->SetSite(0, i, 1, 1); + cell->GetEventReceiver()->leftButtonDown.AttachMethod(this, &DefaultDataGridItemTemplate::OnCellButtonDown); + cell->GetEventReceiver()->rightButtonDown.AttachMethod(this, &DefaultDataGridItemTemplate::OnCellButtonDown); + cell->GetEventReceiver()->leftButtonUp.AttachMethod(this, &DefaultDataGridItemTemplate::OnCellLeftButtonUp); + cell->GetEventReceiver()->rightButtonUp.AttachMethod(this, &DefaultDataGridItemTemplate::OnCellRightButtonUp); + + auto composition = dataVisualizers[i]->GetTemplate(); + composition->SetAlignmentToParent(Margin(0, 0, 0, 0)); + cell->AddChild(composition); + } + + for (vint i = 0; i < dataVisualizers.Count(); i++) + { + dataVisualizers[i]->BeforeVisualizeCell(dataGrid->GetItemProvider(), itemIndex, i); + } + + GridPos selectedCell = dataGrid->GetSelectedCell(); + if (selectedCell.row == itemIndex) + { + NotifySelectCell(selectedCell.column); + } + else + { + NotifySelectCell(-1); + } + UpdateSubItemSize(); + } + + SelectedChanged.AttachMethod(this, &DefaultDataGridItemTemplate::OnSelectedChanged); + FontChanged.AttachMethod(this, &DefaultDataGridItemTemplate::OnFontChanged); + + SelectedChanged.Execute(compositions::GuiEventArgs(this)); + FontChanged.Execute(compositions::GuiEventArgs(this)); + } + + void DefaultDataGridItemTemplate::OnSelectedChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + if (!GetSelected()) + { + NotifySelectCell(-1); + } + } + + void DefaultDataGridItemTemplate::OnFontChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + FOREACH(Ptr, visualizer, dataVisualizers) + { + visualizer->GetTemplate()->SetFont(GetFont()); + } + if (currentEditor) + { + currentEditor->GetTemplate()->SetFont(GetFont()); + } + } + + DefaultDataGridItemTemplate::DefaultDataGridItemTemplate() + { + } + + DefaultDataGridItemTemplate::~DefaultDataGridItemTemplate() + { + FOREACH(Ptr, visualizer, dataVisualizers) + { + visualizer->NotifyDeletedTemplate(); + } + if (currentEditor) + { + currentEditor->NotifyDeletedTemplate(); + } + } + + void DefaultDataGridItemTemplate::UpdateSubItemSize() + { + if (auto dataGrid = dynamic_cast(listControl)) + { + vint columnCount = dataGrid->listViewItemView->GetColumnCount(); + if (columnCount > textTable->GetColumns()) + { + columnCount = textTable->GetColumns(); + } + for (vint i = 0; i < columnCount; i++) + { + textTable->SetColumnOption(i, GuiCellOption::AbsoluteOption(dataGrid->columnItemView->GetColumnSize(i))); + } + textTable->UpdateCellBounds(); + } + } + + bool DefaultDataGridItemTemplate::IsEditorOpened() + { + return currentEditor != nullptr; + } + + void DefaultDataGridItemTemplate::NotifyOpenEditor(vint column, IDataEditor* editor) + { + currentEditor = editor; + if (currentEditor) + { + auto cell = textTable->GetSitedCell(0, column); + auto* editorBounds = currentEditor->GetTemplate(); + if (editorBounds->GetParent() && editorBounds->GetParent() != cell) + { + editorBounds->GetParent()->RemoveChild(editorBounds); + } + editorBounds->SetAlignmentToParent(Margin(0, 0, 0, 0)); + cell->AddChild(editorBounds); + if (auto focusControl = currentEditor->GetTemplate()->GetFocusControl()) + { + focusControl->SetFocus(); + } + } + } + + void DefaultDataGridItemTemplate::NotifyCloseEditor() + { + if (currentEditor) + { + auto composition = currentEditor->GetTemplate(); + if (composition->GetParent()) + { + composition->GetParent()->RemoveChild(composition); + } + currentEditor = nullptr; + } + } + + void DefaultDataGridItemTemplate::NotifySelectCell(vint column) + { + for (vint i = 0; i < dataVisualizers.Count(); i++) + { + dataVisualizers[i]->SetSelected(i == column); + } + } + + void DefaultDataGridItemTemplate::NotifyCellEdited() + { + for (vint i = 0; i < dataVisualizers.Count(); i++) + { + dataVisualizers[i]->BeforeVisualizeCell(listControl->GetItemProvider(), GetIndex(), i); + } + } + } + +/*********************************************************************** +GuiVirtualDataGrid (Editor) +***********************************************************************/ + + using namespace list; + + void GuiVirtualDataGrid::OnItemModified(vint start, vint count, vint newCount) + { + GuiVirtualListView::OnItemModified(start, count, newCount); + if(!GetItemProvider()->IsEditing()) + { + StopEdit(false); + } + } + + void GuiVirtualDataGrid::OnStyleUninstalled(ItemStyle* style) + { + GuiVirtualListView::OnStyleUninstalled(style); + if (auto itemStyle = dynamic_cast(style)) + { + if (itemStyle->IsEditorOpened()) + { + itemStyle->NotifyCloseEditor(); + currentEditor = nullptr; + currentEditorPos = { -1,-1 }; + } + } + } + + void GuiVirtualDataGrid::NotifyCloseEditor() + { + if (currentEditorPos.row != -1 && GetArranger()) + { + auto style = GetArranger()->GetVisibleStyle(currentEditorPos.row); + if (auto itemStyle = dynamic_cast(style)) + { + itemStyle->NotifyCloseEditor(); + } + } + } + + void GuiVirtualDataGrid::NotifySelectCell(vint row, vint column) + { + selectedCell = { row, column }; + SelectedCellChanged.Execute(GetNotifyEventArguments()); + + auto style = GetArranger()->GetVisibleStyle(row); + if (auto itemStyle = dynamic_cast(style)) + { + itemStyle->NotifySelectCell(column); + } + } + + bool GuiVirtualDataGrid::StartEdit(vint row, vint column) + { + StopEdit(true); + NotifySelectCell(row, column); + + auto style = GetArranger()->GetVisibleStyle(row); + if (auto itemStyle = dynamic_cast(style)) + { + if (auto factory = dataGridView->GetCellDataEditorFactory(row, column)) + { + currentEditorOpeningEditor = true; + currentEditorPos = { row,column }; + currentEditor = factory->CreateEditor(this); + currentEditor->BeforeEditCell(GetItemProvider(), row, column); + itemStyle->NotifyOpenEditor(column, currentEditor.Obj()); + currentEditorOpeningEditor = false; + return true; + } + } + return false; + } + + void GuiVirtualDataGrid::StopEdit(bool forOpenNewEditor) + { + if (GetItemProvider()->IsEditing()) + { + NotifyCloseEditor(); + } + else + { + if (currentEditorPos != GridPos{-1, -1}) + { + if (currentEditor) + { + NotifyCloseEditor(); + } + if (!forOpenNewEditor) + { + NotifySelectCell(-1, -1); + } + } + } + currentEditor = nullptr; + currentEditorPos = { -1,-1 }; + } + +/*********************************************************************** +GuiVirtualDataGrid (IDataGridContext) +***********************************************************************/ + + GuiListViewBase::IStyleProvider* GuiVirtualDataGrid::GetListViewStyleProvider() + { + return GuiVirtualListView::GetListViewStyleProvider(); + } + + description::Value GuiVirtualDataGrid::GetViewModelContext() + { + return dataGridView->GetViewModelContext(); + } + + void GuiVirtualDataGrid::RequestSaveData() + { + if (currentEditor && !currentEditorOpeningEditor) + { + GuiControl* focusedControl = nullptr; + if (auto controlHost = GetRelatedControlHost()) + { + if (auto graphicsHost = controlHost->GetGraphicsHost()) + { + if (auto focusComposition = graphicsHost->GetFocusedComposition()) + { + focusedControl = focusComposition->GetRelatedControl(); + } + } + } + + GetItemProvider()->PushEditing(); + dataGridView->SetBindingCellValue(currentEditorPos.row, currentEditorPos.column, currentEditor->GetTemplate()->GetCellValue()); + GetItemProvider()->PopEditing(); + + auto style = GetArranger()->GetVisibleStyle(currentEditorPos.row); + if (auto itemStyle = dynamic_cast(style)) + { + itemStyle->NotifyCellEdited(); + } + + if (currentEditor && focusedControl) + { + focusedControl->SetFocus(); + } + } + } + +/*********************************************************************** +GuiVirtualDataGrid +***********************************************************************/ + + void GuiVirtualDataGrid::OnColumnClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiItemEventArgs& arguments) + { + if(dataGridView->IsColumnSortable(arguments.itemIndex)) + { + switch(columnItemView->GetSortingState(arguments.itemIndex)) + { + case ColumnSortingState::NotSorted: + dataGridView->SortByColumn(arguments.itemIndex, true); + break; + case ColumnSortingState::Ascending: + dataGridView->SortByColumn(arguments.itemIndex, false); + break; + case ColumnSortingState::Descending: + dataGridView->SortByColumn(-1, false); + break; + } + } + } + + GuiVirtualDataGrid::GuiVirtualDataGrid(IStyleProvider* _styleProvider, GuiListControl::IItemProvider* _itemProvider) + :GuiVirtualListView(_styleProvider, _itemProvider) + { + listViewItemView = dynamic_cast(_itemProvider->RequestView(IListViewItemView::Identifier)); + columnItemView = dynamic_cast(_itemProvider->RequestView(ListViewColumnItemArranger::IColumnItemView::Identifier)); + dataGridView = dynamic_cast(_itemProvider->RequestView(IDataGridView::Identifier)); + + { + auto mainProperty = [](const Value&) { return new MainColumnVisualizerTemplate; }; + auto subProperty = [](const Value&) { return new SubColumnVisualizerTemplate; }; + auto cellBorderProperty = [](const Value&) { return new CellBorderVisualizerTemplate; }; + + auto mainFactory = MakePtr(mainProperty); + auto subFactory = MakePtr(subProperty); + defaultMainColumnVisualizerFactory = MakePtr(cellBorderProperty, mainFactory); + defaultSubColumnVisualizerFactory = MakePtr(cellBorderProperty, subFactory); + } + + CHECK_ERROR(listViewItemView != nullptr, L"GuiVirtualDataGrid::GuiVirtualDataGrid(IStyleProvider*, GuiListControl::IItemProvider*)#Missing IListViewItemView from item provider."); + CHECK_ERROR(columnItemView != nullptr, L"GuiVirtualDataGrid::GuiVirtualDataGrid(IStyleProvider*, GuiListControl::IItemProvider*)#Missing ListViewColumnItemArranger::IColumnItemView from item provider."); + CHECK_ERROR(dataGridView != nullptr, L"GuiVirtualDataGrid::GuiVirtualDataGrid(IStyleProvider*, GuiListControl::IItemProvider*)#Missing IDataGridView from item provider."); + + SetViewToDefault(); + ColumnClicked.AttachMethod(this, &GuiVirtualDataGrid::OnColumnClicked); + SelectedCellChanged.SetAssociatedComposition(GetBoundsComposition()); + } + + GuiVirtualDataGrid::~GuiVirtualDataGrid() + { + } + + GuiListControl::IItemProvider* GuiVirtualDataGrid::GetItemProvider() + { + return GuiVirtualListView::GetItemProvider(); + } + + void GuiVirtualDataGrid::SetViewToDefault() + { + SetStyleAndArranger( + [](const Value&) { return new list::DefaultDataGridItemTemplate; }, + new list::ListViewColumnItemArranger + ); + } + + GridPos GuiVirtualDataGrid::GetSelectedCell() + { + return selectedCell; + } + + void GuiVirtualDataGrid::SetSelectedCell(const GridPos& value) + { + if (selectedCell == value) + { + return; + } + + bool validPos = 0 <= value.row && value.row < GetItemProvider()->Count() && 0 <= value.column && value.column < listViewItemView->GetColumnCount(); + StopEdit(true); + + if (validPos) + { + NotifySelectCell(value.row, value.column); + } + else + { + NotifySelectCell(-1, -1); + } + + if (validPos) + { + EnsureItemVisible(value.row); + ClearSelection(); + SetSelected(value.row, true); + StartEdit(value.row, value.column); + } + else + { + ClearSelection(); + } + } } } } /*********************************************************************** -RESOURCES\GUIDOCUMENT_LOAD.CPP +.\CONTROLS\LISTCONTROLPACKAGE\GUIDATAGRIDEXTENSIONS.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace controls + { + namespace list + { + using namespace compositions; + using namespace elements; + using namespace theme; + using namespace templates; + +/*********************************************************************** +DataVisualizerBase +***********************************************************************/ + + DataVisualizerBase::DataVisualizerBase() + { + } + + DataVisualizerBase::~DataVisualizerBase() + { + if (visualizerTemplate) + { + SafeDeleteComposition(visualizerTemplate); + } + } + + IDataVisualizerFactory* DataVisualizerBase::GetFactory() + { + return factory; + } + + templates::GuiGridVisualizerTemplate* DataVisualizerBase::GetTemplate() + { + return visualizerTemplate; + } + + void DataVisualizerBase::NotifyDeletedTemplate() + { + visualizerTemplate = nullptr; + } + + void DataVisualizerBase::BeforeVisualizeCell(GuiListControl::IItemProvider* itemProvider, vint row, vint column) + { + if (auto listViewItemView = dynamic_cast(dataGridContext->GetItemProvider()->RequestView(IListViewItemView::Identifier))) + { + auto styleProvider = dataGridContext->GetListViewStyleProvider(); + visualizerTemplate->SetPrimaryTextColor(styleProvider->GetPrimaryTextColor()); + visualizerTemplate->SetSecondaryTextColor(styleProvider->GetSecondaryTextColor()); + visualizerTemplate->SetItemSeparatorColor(styleProvider->GetItemSeparatorColor()); + + visualizerTemplate->SetLargeImage(listViewItemView->GetLargeImage(row)); + visualizerTemplate->SetSmallImage(listViewItemView->GetSmallImage(row)); + visualizerTemplate->SetText(column == 0 ? listViewItemView->GetText(row) : listViewItemView->GetSubItem(row, column - 1)); + } + if (auto dataGridView = dynamic_cast(dataGridContext->GetItemProvider()->RequestView(IDataGridView::Identifier))) + { + visualizerTemplate->SetRowValue(itemProvider->GetBindingValue(row)); + visualizerTemplate->SetCellValue(dataGridView->GetBindingCellValue(row, column)); + } + } + + void DataVisualizerBase::SetSelected(bool value) + { + if (visualizerTemplate) + { + visualizerTemplate->SetSelected(value); + } + } + +/*********************************************************************** +DataVisualizerFactory +***********************************************************************/ + + DataVisualizerFactory::ItemTemplate* DataVisualizerFactory::CreateItemTemplate(controls::list::IDataGridContext* dataGridContext) + { + ItemTemplate* itemTemplate = templateFactory(dataGridContext->GetViewModelContext()); + CHECK_ERROR(itemTemplate, L"DataVisualizerFactory::CreateItemTemplate(IDataGridContext*)#An instance of GuiGridEditorTemplate is expected."); + if (decoratedFactory) + { + auto childTemplate = decoratedFactory->CreateItemTemplate(dataGridContext); + childTemplate->SetAlignmentToParent(Margin(0, 0, 0, 0)); + itemTemplate->GetContainerComposition()->AddChild(childTemplate); + +#define FORWARD_EVENT(NAME)\ + itemTemplate->NAME##Changed.AttachLambda([=](GuiGraphicsComposition* sender, GuiEventArgs& arguments)\ + {\ + childTemplate->Set##NAME(itemTemplate->Get##NAME());\ + });\ + +#define FORWARD_EVENT_IMPL(CLASS, TYPE, NAME) FORWARD_EVENT(NAME) + + GuiTemplate_PROPERTIES(FORWARD_EVENT_IMPL) + GuiControlTemplate_PROPERTIES(FORWARD_EVENT_IMPL) + GuiGridCellTemplate_PROPERTIES(FORWARD_EVENT_IMPL) + GuiGridVisualizerTemplate_PROPERTIES(FORWARD_EVENT_IMPL) + +#undef FORWARD_EVENT_IMPL +#undef FORWARD_EVENT + } + return itemTemplate; + } + + DataVisualizerFactory::DataVisualizerFactory(TemplateProperty _templateFactory, Ptr _decoratedFactory) + :templateFactory(_templateFactory) + , decoratedFactory(_decoratedFactory) + { + } + + DataVisualizerFactory::~DataVisualizerFactory() + { + } + + Ptr DataVisualizerFactory::CreateVisualizer(controls::list::IDataGridContext* dataGridContext) + { + auto dataVisualizer = MakePtr(); + dataVisualizer->factory = this; + dataVisualizer->dataGridContext = dataGridContext; + dataVisualizer->visualizerTemplate = CreateItemTemplate(dataGridContext); + + return dataVisualizer; + } + +/*********************************************************************** +DataEditorBase +***********************************************************************/ + + void DataEditorBase::OnCellValueChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + dataGridContext->RequestSaveData(); + } + + DataEditorBase::DataEditorBase() + { + } + + DataEditorBase::~DataEditorBase() + { + if (editorTemplate) + { + SafeDeleteComposition(editorTemplate); + } + } + + IDataEditorFactory* DataEditorBase::GetFactory() + { + return factory; + } + + templates::GuiGridEditorTemplate* DataEditorBase::GetTemplate() + { + return editorTemplate; + } + + void DataEditorBase::NotifyDeletedTemplate() + { + editorTemplate = nullptr; + } + + void DataEditorBase::BeforeEditCell(GuiListControl::IItemProvider* itemProvider, vint row, vint column) + { + if (auto listViewItemView = dynamic_cast(dataGridContext->GetItemProvider()->RequestView(IListViewItemView::Identifier))) + { + auto styleProvider = dataGridContext->GetListViewStyleProvider(); + editorTemplate->SetPrimaryTextColor(styleProvider->GetPrimaryTextColor()); + editorTemplate->SetSecondaryTextColor(styleProvider->GetSecondaryTextColor()); + editorTemplate->SetItemSeparatorColor(styleProvider->GetItemSeparatorColor()); + + editorTemplate->SetLargeImage(listViewItemView->GetLargeImage(row)); + editorTemplate->SetSmallImage(listViewItemView->GetSmallImage(row)); + editorTemplate->SetText(column == 0 ? listViewItemView->GetText(row) : listViewItemView->GetSubItem(row, column - 1)); + } + if (auto dataGridView = dynamic_cast(dataGridContext->GetItemProvider()->RequestView(IDataGridView::Identifier))) + { + editorTemplate->SetRowValue(itemProvider->GetBindingValue(row)); + editorTemplate->SetCellValue(dataGridView->GetBindingCellValue(row, column)); + } + editorTemplate->CellValueChanged.AttachMethod(this, &DataEditorBase::OnCellValueChanged); + } + + bool DataEditorBase::GetCellValueSaved() + { + if (editorTemplate) + { + return editorTemplate->GetCellValueSaved(); + } + return true; + } + +/*********************************************************************** +DataEditorFactory +***********************************************************************/ + + DataEditorFactory::DataEditorFactory(TemplateProperty _templateFactory) + :templateFactory(_templateFactory) + { + } + + DataEditorFactory::~DataEditorFactory() + { + } + + Ptr DataEditorFactory::CreateEditor(controls::list::IDataGridContext* dataGridContext) + { + auto editor = MakePtr(); + editor->factory = this; + editor->dataGridContext = dataGridContext; + + ItemTemplate* itemTemplate = templateFactory(dataGridContext->GetViewModelContext()); + CHECK_ERROR(itemTemplate, L"DataEditorFactory::CreateEditor(IDataGridContext*)#An instance of GuiGridEditorTemplate is expected."); + editor->editorTemplate = itemTemplate; + return editor; + } + +/*********************************************************************** +MainColumnVisualizerTemplate +***********************************************************************/ + + void MainColumnVisualizerTemplate::OnTextChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + text->SetText(GetText()); + } + + void MainColumnVisualizerTemplate::OnFontChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + text->SetFont(GetFont()); + } + + void MainColumnVisualizerTemplate::OnTextColorChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + text->SetColor(GetPrimaryTextColor()); + } + + void MainColumnVisualizerTemplate::OnSmallImageChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + auto imageData = GetSmallImage(); + if (imageData) + { + image->SetImage(imageData->GetImage(), imageData->GetFrameIndex()); + } + else + { + image->SetImage(nullptr); + } + } + + MainColumnVisualizerTemplate::MainColumnVisualizerTemplate() + { + GuiTableComposition* table = new GuiTableComposition; + table->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + table->SetRowsAndColumns(3, 2); + table->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); + table->SetRowOption(1, GuiCellOption::MinSizeOption()); + table->SetRowOption(2, GuiCellOption::PercentageOption(0.5)); + table->SetColumnOption(0, GuiCellOption::MinSizeOption()); + table->SetColumnOption(1, GuiCellOption::PercentageOption(1.0)); + table->SetCellPadding(2); + { + GuiCellComposition* cell = new GuiCellComposition; + table->AddChild(cell); + cell->SetSite(1, 0, 1, 1); + cell->SetPreferredMinSize(Size(16, 16)); + + image = GuiImageFrameElement::Create(); + image->SetStretch(true); + cell->SetOwnedElement(image); + } + { + GuiCellComposition* cell = new GuiCellComposition; + table->AddChild(cell); + cell->SetSite(0, 1, 3, 1); + cell->SetMargin(Margin(0, 0, 8, 0)); + + text = GuiSolidLabelElement::Create(); + text->SetAlignments(Alignment::Left, Alignment::Center); + text->SetEllipse(true); + cell->SetOwnedElement(text); + } + table->SetAlignmentToParent(Margin(0, 0, 0, 0)); + + SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + AddChild(table); + + TextChanged.AttachMethod(this, &MainColumnVisualizerTemplate::OnTextChanged); + FontChanged.AttachMethod(this, &MainColumnVisualizerTemplate::OnFontChanged); + PrimaryTextColorChanged.AttachMethod(this, &MainColumnVisualizerTemplate::OnTextColorChanged); + SmallImageChanged.AttachMethod(this, &MainColumnVisualizerTemplate::OnSmallImageChanged); + + TextChanged.Execute(compositions::GuiEventArgs(this)); + FontChanged.Execute(compositions::GuiEventArgs(this)); + PrimaryTextColorChanged.Execute(compositions::GuiEventArgs(this)); + SmallImageChanged.Execute(compositions::GuiEventArgs(this)); + } + + MainColumnVisualizerTemplate::~MainColumnVisualizerTemplate() + { + } + +/*********************************************************************** +SubColumnVisualizerTemplate +***********************************************************************/ + + void SubColumnVisualizerTemplate::OnTextChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + text->SetText(GetText()); + } + + void SubColumnVisualizerTemplate::OnFontChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + text->SetFont(GetFont()); + } + + void SubColumnVisualizerTemplate::OnTextColorChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + text->SetColor(GetSecondaryTextColor()); + } + + void SubColumnVisualizerTemplate::Initialize(bool fixTextColor) + { + text = GuiSolidLabelElement::Create(); + text->SetVerticalAlignment(Alignment::Center); + + SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + SetMargin(Margin(8, 0, 8, 0)); + SetOwnedElement(text); + + TextChanged.AttachMethod(this, &SubColumnVisualizerTemplate::OnTextChanged); + FontChanged.AttachMethod(this, &SubColumnVisualizerTemplate::OnFontChanged); + if (!fixTextColor) + { + SecondaryTextColorChanged.AttachMethod(this, &SubColumnVisualizerTemplate::OnTextColorChanged); + } + + TextChanged.Execute(compositions::GuiEventArgs(this)); + FontChanged.Execute(compositions::GuiEventArgs(this)); + if (!fixTextColor) + { + SecondaryTextColorChanged.Execute(compositions::GuiEventArgs(this)); + } + } + + SubColumnVisualizerTemplate::SubColumnVisualizerTemplate(bool fixTextColor) + { + Initialize(fixTextColor); + } + + SubColumnVisualizerTemplate::SubColumnVisualizerTemplate() + { + Initialize(false); + } + + SubColumnVisualizerTemplate::~SubColumnVisualizerTemplate() + { + } + +/*********************************************************************** +HyperlinkVisualizerTemplate +***********************************************************************/ + + void HyperlinkVisualizerTemplate::label_MouseEnter(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + FontProperties font = text->GetFont(); + font.underline = true; + text->SetFont(font); + } + + void HyperlinkVisualizerTemplate::label_MouseLeave(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + FontProperties font = text->GetFont(); + font.underline = false; + text->SetFont(font); + } + + HyperlinkVisualizerTemplate::HyperlinkVisualizerTemplate() + :SubColumnVisualizerTemplate(true) + { + text->SetColor(Color(0, 0, 255)); + text->SetEllipse(true); + GetEventReceiver()->mouseEnter.AttachMethod(this, &HyperlinkVisualizerTemplate::label_MouseEnter); + GetEventReceiver()->mouseLeave.AttachMethod(this, &HyperlinkVisualizerTemplate::label_MouseLeave); + SetAssociatedCursor(GetCurrentController()->ResourceService()->GetSystemCursor(INativeCursor::Hand)); + } + + HyperlinkVisualizerTemplate::~HyperlinkVisualizerTemplate() + { + } + +/*********************************************************************** +CellBorderVisualizerTemplate +***********************************************************************/ + + void CellBorderVisualizerTemplate::OnItemSeparatorColorChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + border1->SetColor(GetItemSeparatorColor()); + border2->SetColor(GetItemSeparatorColor()); + } + + CellBorderVisualizerTemplate::CellBorderVisualizerTemplate() + { + GuiBoundsComposition* bounds1 = nullptr; + GuiBoundsComposition* bounds2 = nullptr; + { + border1 = GuiSolidBorderElement::Create(); + + bounds1 = new GuiBoundsComposition; + bounds1->SetOwnedElement(border1); + bounds1->SetAlignmentToParent(Margin(-1, 0, 0, 0)); + } + { + border2 = GuiSolidBorderElement::Create(); + + bounds2 = new GuiBoundsComposition; + bounds2->SetOwnedElement(border2); + bounds2->SetAlignmentToParent(Margin(0, -1, 0, 0)); + } + + SetAlignmentToParent(Margin(0, 0, 1, 1)); + SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + AddChild(bounds1); + AddChild(bounds2); + + ItemSeparatorColorChanged.AttachMethod(this, &CellBorderVisualizerTemplate::OnItemSeparatorColorChanged); + + ItemSeparatorColorChanged.Execute(compositions::GuiEventArgs(this)); + } + + CellBorderVisualizerTemplate::~CellBorderVisualizerTemplate() + { + } + } + } + } +} + +/*********************************************************************** +.\CONTROLS\STYLES\GUITHEMESTYLEFACTORY.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace theme + { + using namespace collections; + using namespace controls; + using namespace templates; + + class Theme : public Object, public virtual theme::ITheme + { + public: + Dictionary> templates; + ThemeTemplates* first = nullptr; + ThemeTemplates* last = nullptr; + + bool RegisterTheme(const WString& name, Ptr theme) + { + CHECK_ERROR(theme->previous == nullptr, L"vl::presentation::theme::RegisterTheme(const WString&, Ptr)#Theme object has been registered"); + CHECK_ERROR(theme->next == nullptr, L"vl::presentation::theme::RegisterTheme(const WString&, Ptr)#Theme object has been registered"); + + if (templates.Keys().Contains(name)) + { + return false; + } + templates.Add(name, theme); + + if (last) + { + last->next = theme.Obj(); + } + theme->previous = last; + last = theme.Obj(); + + return true; + } + + Ptr UnregisterTheme(const WString& name) + { + vint index = templates.Keys().IndexOf(name); + if (index == -1) + { + return nullptr; + } + + auto themeTemplates = templates.Values().Get(index); + + if (themeTemplates->previous) + { + themeTemplates->previous->next = themeTemplates->next; + } + else + { + first = themeTemplates->next; + } + + if (themeTemplates->next) + { + themeTemplates->next->previous = themeTemplates->previous; + + } + else + { + last = themeTemplates->previous; + } + + templates.Remove(name); + return themeTemplates; + } + +#define SP(TYPE, NAME)\ + auto current = last;\ + while (current) \ + {\ + if (current->NAME)\ + {\ + return new TYPE##_StyleProvider([=](auto _)\ + {\ + return current->NAME(description::Value());\ + });\ + }\ + current = current->previous;\ + }\ + throw Exception(L"Control template for \"" L ## #NAME L"\" is not defined.");\ + + GuiWindow::IStyleController* CreateWindowStyle()override + { + SP(GuiWindowTemplate, window); + } + + GuiCustomControl::IStyleController* CreateCustomControlStyle()override + { + SP(GuiControlTemplate, customControl); + } + + GuiTooltip::IStyleController* CreateTooltipStyle()override + { + SP(GuiWindowTemplate, tooltip); + } + + GuiLabel::IStyleController* CreateLabelStyle()override + { + SP(GuiLabelTemplate, label); + } + + GuiLabel::IStyleController* CreateShortcutKeyStyle()override + { + SP(GuiLabelTemplate, shortcutKey); + } + + GuiScrollContainer::IStyleProvider* CreateScrollContainerStyle()override + { + SP(GuiScrollViewTemplate, scrollView); + } + + GuiControl::IStyleController* CreateGroupBoxStyle()override + { + SP(GuiControlTemplate, groupBox); + } + + GuiTab::IStyleController* CreateTabStyle()override + { + SP(GuiTabTemplate, tab); + } + + GuiComboBoxListControl::IStyleController* CreateComboBoxStyle()override + { + SP(GuiComboBoxTemplate, comboBox); + } + + GuiScrollView::IStyleProvider* CreateMultilineTextBoxStyle()override + { + SP(GuiMultilineTextBoxTemplate, multilineTextBox); + } + + GuiSinglelineTextBox::IStyleProvider* CreateTextBoxStyle()override + { + SP(GuiSinglelineTextBoxTemplate, singlelineTextBox); + } + + GuiDocumentViewer::IStyleProvider* CreateDocumentViewerStyle()override + { + SP(GuiDocumentViewerTemplate, documentViewer); + } + + GuiDocumentLabel::IStyleController* CreateDocumentLabelStyle()override + { + SP(GuiDocumentLabelTemplate, documentLabel); + } + + GuiDocumentLabel::IStyleController* CreateDocumentTextBoxStyle()override + { + SP(GuiDocumentLabelTemplate, documentTextBox); + } + + GuiListView::IStyleProvider* CreateListViewStyle()override + { + SP(GuiListViewTemplate, listView); + } + + GuiTreeView::IStyleProvider* CreateTreeViewStyle()override + { + SP(GuiTreeViewTemplate, treeView); + } + + GuiSelectableButton::IStyleController* CreateListItemBackgroundStyle()override + { + SP(GuiSelectableButtonTemplate, listItemBackground); + } + + GuiSelectableButton::IStyleController* CreateTreeItemExpanderStyle()override + { + SP(GuiSelectableButtonTemplate, treeItemExpander); + } + + GuiToolstripMenu::IStyleController* CreateMenuStyle()override + { + SP(GuiMenuTemplate, menu); + } + + GuiToolstripMenuBar::IStyleController* CreateMenuBarStyle()override + { + SP(GuiControlTemplate, menuBar); + } + + GuiControl::IStyleController* CreateMenuSplitterStyle()override + { + SP(GuiControlTemplate, menuSplitter); + } + + GuiToolstripButton::IStyleController* CreateMenuBarButtonStyle()override + { + SP(GuiToolstripButtonTemplate, menuBarButton); + } + + GuiToolstripButton::IStyleController* CreateMenuItemButtonStyle()override + { + SP(GuiToolstripButtonTemplate, menuItemButton); + } + + GuiToolstripToolBar::IStyleController* CreateToolBarStyle()override + { + SP(GuiControlTemplate, toolBar); + } + + GuiToolstripButton::IStyleController* CreateToolBarButtonStyle()override + { + SP(GuiToolstripButtonTemplate, toolBarButton); + } + + GuiToolstripButton::IStyleController* CreateToolBarDropdownButtonStyle()override + { + SP(GuiToolstripButtonTemplate, toolBarDropdownButton); + } + + GuiToolstripButton::IStyleController* CreateToolBarSplitButtonStyle()override + { + SP(GuiToolstripButtonTemplate, toolBarSplitButton); + } + + GuiControl::IStyleController* CreateToolBarSplitterStyle()override + { + SP(GuiControlTemplate, toolBarSplitter); + } + + GuiButton::IStyleController* CreateButtonStyle()override + { + SP(GuiButtonTemplate, button); + } + + GuiSelectableButton::IStyleController* CreateCheckBoxStyle()override + { + SP(GuiSelectableButtonTemplate, checkBox); + } + + GuiSelectableButton::IStyleController* CreateRadioButtonStyle()override + { + SP(GuiSelectableButtonTemplate, radioButton); + } + + GuiDatePicker::IStyleProvider* CreateDatePickerStyle()override + { + SP(GuiDatePickerTemplate, datePicker); + } + + GuiScroll::IStyleController* CreateHScrollStyle()override + { + SP(GuiScrollTemplate, hScroll); + } + + GuiScroll::IStyleController* CreateVScrollStyle()override + { + SP(GuiScrollTemplate, vScroll); + } + + GuiScroll::IStyleController* CreateHTrackerStyle()override + { + SP(GuiScrollTemplate, hTracker); + } + + GuiScroll::IStyleController* CreateVTrackerStyle()override + { + SP(GuiScrollTemplate, vTracker); + } + + GuiScroll::IStyleController* CreateProgressBarStyle()override + { + SP(GuiScrollTemplate, progressBar); + } + + GuiVirtualTextList::IStyleProvider* CreateTextListStyle()override + { + SP(GuiTextListTemplate, textList); + } + + GuiSelectableButton::IStyleController* CreateCheckTextListItemStyle()override + { + SP(GuiSelectableButtonTemplate, listItemBackground); + } + + GuiSelectableButton::IStyleController* CreateRadioTextListItemStyle()override + { + SP(GuiSelectableButtonTemplate, treeItemExpander); + } + +#undef SP + }; + + ThemeTemplates::~ThemeTemplates() + { + FinalizeAggregation(); + } + + Theme* currentTheme = nullptr; + + ITheme* GetCurrentTheme() + { + return currentTheme; + } + + void InitializeTheme() + { + CHECK_ERROR(currentTheme == nullptr, L"vl::presentation::theme::InitializeTheme()#Theme has already been initialized"); + currentTheme = new Theme; + } + + void FinalizeTheme() + { + CHECK_ERROR(currentTheme != nullptr, L"vl::presentation::theme::FinalizeTheme()#Theme has not been initialized"); + delete currentTheme; + currentTheme = nullptr; + } + + bool RegisterTheme(const WString& name, Ptr theme) + { + CHECK_ERROR(currentTheme != nullptr, L"vl::presentation::theme::RegisterTheme(const WString&, Ptr)#Theme has already been initialized"); + return currentTheme->RegisterTheme(name, theme); + } + + Ptr UnregisterTheme(const WString& name) + { + CHECK_ERROR(currentTheme != nullptr, L"vl::presentation::theme::UnregisterTheme(const WString&)#Theme has already been initialized"); + return currentTheme->UnregisterTheme(name); + } + + namespace g + { + controls::GuiWindow* NewWindow() + { + return new controls::GuiWindow(GetCurrentTheme()->CreateWindowStyle()); + } + + controls::GuiCustomControl* NewCustomControl() + { + return new controls::GuiCustomControl(GetCurrentTheme()->CreateCustomControlStyle()); + } + + controls::GuiLabel* NewLabel() + { + return new controls::GuiLabel(GetCurrentTheme()->CreateLabelStyle()); + } + + controls::GuiScrollContainer* NewScrollContainer() + { + return new controls::GuiScrollContainer(GetCurrentTheme()->CreateScrollContainerStyle()); + } + + controls::GuiControl* NewGroupBox() + { + return new controls::GuiControl(GetCurrentTheme()->CreateGroupBoxStyle()); + } + + controls::GuiTab* NewTab() + { + return new controls::GuiTab(GetCurrentTheme()->CreateTabStyle()); + } + + controls::GuiTabPage* NewTabPage() + { + return new controls::GuiTabPage(GetCurrentTheme()->CreateCustomControlStyle()); + } + + controls::GuiComboBoxListControl* NewComboBox(controls::GuiSelectableListControl* containedListControl) + { + return new controls::GuiComboBoxListControl(GetCurrentTheme()->CreateComboBoxStyle(), containedListControl); + } + + controls::GuiMultilineTextBox* NewMultilineTextBox() + { + return new controls::GuiMultilineTextBox(GetCurrentTheme()->CreateMultilineTextBoxStyle()); + } + + controls::GuiSinglelineTextBox* NewTextBox() + { + return new controls::GuiSinglelineTextBox(GetCurrentTheme()->CreateTextBoxStyle()); + } + + controls::GuiDocumentViewer* NewDocumentViewer() + { + return new controls::GuiDocumentViewer(GetCurrentTheme()->CreateDocumentViewerStyle()); + } + + controls::GuiDocumentLabel* NewDocumentLabel() + { + return new controls::GuiDocumentLabel(GetCurrentTheme()->CreateDocumentLabelStyle()); + } + + controls::GuiDocumentLabel* NewDocumentTextBox() + { + return new controls::GuiDocumentLabel(GetCurrentTheme()->CreateDocumentTextBoxStyle()); + } + + controls::GuiListView* NewListView() + { + controls::GuiListView* listview=new controls::GuiListView(GetCurrentTheme()->CreateListViewStyle()); + return listview; + } + + controls::GuiTreeView* NewTreeView() + { + return new controls::GuiTreeView(GetCurrentTheme()->CreateTreeViewStyle()); + } + + controls::GuiToolstripMenu* NewMenu(controls::GuiControl* owner) + { + return new controls::GuiToolstripMenu(GetCurrentTheme()->CreateMenuStyle(), owner); + } + + controls::GuiToolstripMenuBar* NewMenuBar() + { + return new controls::GuiToolstripMenuBar(GetCurrentTheme()->CreateMenuBarStyle()); + } + + controls::GuiControl* NewMenuSplitter() + { + return new controls::GuiControl(GetCurrentTheme()->CreateMenuSplitterStyle()); + } + + controls::GuiToolstripButton* NewMenuBarButton() + { + return new controls::GuiToolstripButton(GetCurrentTheme()->CreateMenuBarButtonStyle()); + } + + controls::GuiToolstripButton* NewMenuItemButton() + { + return new controls::GuiToolstripButton(GetCurrentTheme()->CreateMenuItemButtonStyle()); + } + + controls::GuiToolstripToolBar* NewToolBar() + { + return new controls::GuiToolstripToolBar(GetCurrentTheme()->CreateToolBarStyle()); + } + + controls::GuiToolstripButton* NewToolBarButton() + { + return new controls::GuiToolstripButton(GetCurrentTheme()->CreateToolBarButtonStyle()); + } + + controls::GuiToolstripButton* NewToolBarDropdownButton() + { + return new controls::GuiToolstripButton(GetCurrentTheme()->CreateToolBarDropdownButtonStyle()); + } + + controls::GuiToolstripButton* NewToolBarSplitButton() + { + return new controls::GuiToolstripButton(GetCurrentTheme()->CreateToolBarSplitButtonStyle()); + } + + controls::GuiControl* NewToolBarSplitter() + { + return new controls::GuiControl(GetCurrentTheme()->CreateToolBarSplitterStyle()); + } + + controls::GuiButton* NewButton() + { + return new controls::GuiButton(GetCurrentTheme()->CreateButtonStyle()); + } + + controls::GuiSelectableButton* NewCheckBox() + { + return new controls::GuiSelectableButton(GetCurrentTheme()->CreateCheckBoxStyle()); + } + + controls::GuiSelectableButton* NewRadioButton() + { + return new controls::GuiSelectableButton(GetCurrentTheme()->CreateRadioButtonStyle()); + } + + controls::GuiDatePicker* NewDatePicker() + { + return new controls::GuiDatePicker(GetCurrentTheme()->CreateDatePickerStyle()); + } + + controls::GuiDateComboBox* NewDateComboBox() + { + return new controls::GuiDateComboBox(GetCurrentTheme()->CreateComboBoxStyle(), NewDatePicker()); + } + + controls::GuiScroll* NewHScroll() + { + return new controls::GuiScroll(GetCurrentTheme()->CreateHScrollStyle()); + } + + controls::GuiScroll* NewVScroll() + { + return new controls::GuiScroll(GetCurrentTheme()->CreateVScrollStyle()); + } + + controls::GuiScroll* NewHTracker() + { + controls::GuiScroll* scroll=new controls::GuiScroll(GetCurrentTheme()->CreateHTrackerStyle()); + scroll->SetPageSize(0); + return scroll; + } + + controls::GuiScroll* NewVTracker() + { + controls::GuiScroll* scroll=new controls::GuiScroll(GetCurrentTheme()->CreateVTrackerStyle()); + scroll->SetPageSize(0); + return scroll; + } + + controls::GuiScroll* NewProgressBar() + { + controls::GuiScroll* scroll=new controls::GuiScroll(GetCurrentTheme()->CreateProgressBarStyle()); + scroll->SetPageSize(0); + return scroll; + } + + controls::GuiTextList* NewTextList() + { + return new controls::GuiTextList(GetCurrentTheme()->CreateTextListStyle()); + } + } + } + } +} + +/*********************************************************************** +.\CONTROLS\TEMPLATES\GUICONTROLTEMPLATESTYLES.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace templates + { + using namespace compositions; + using namespace elements; + using namespace controls; + using namespace controls::list; + using namespace reflection::description; + using namespace collections; + +#define GET_FACTORY_FROM_TEMPLATE(TEMPLATE, PROPERTY)\ + return new TEMPLATE##_StyleProvider(controlTemplate->Get##PROPERTY());\ + +#define GET_FACTORY_FROM_TEMPLATE_OPT(TEMPLATE, PROPERTY)\ + if (!controlTemplate->Get##PROPERTY())\ + {\ + return nullptr;\ + }\ + GET_FACTORY_FROM_TEMPLATE(TEMPLATE, PROPERTY)\ + +/*********************************************************************** +GuiControlTemplate_StyleProvider +***********************************************************************/ + + GuiControlTemplate_StyleProvider::GuiControlTemplate_StyleProvider(TemplateProperty factory, description::Value viewModel) + :associatedStyleController(0) + , controlTemplate(factory(viewModel)) + { + CHECK_ERROR(controlTemplate, L"GuiControlTemplate_StyleProvider::GuiControlTemplate_StyleProvider()#An instance of GuiControlTemplate is expected."); + } + + GuiControlTemplate_StyleProvider::~GuiControlTemplate_StyleProvider() + { + } + + compositions::GuiBoundsComposition* GuiControlTemplate_StyleProvider::GetBoundsComposition() + { + return controlTemplate; + } + + compositions::GuiGraphicsComposition* GuiControlTemplate_StyleProvider::GetContainerComposition() + { + return controlTemplate->GetContainerComposition(); + } + + void GuiControlTemplate_StyleProvider::AssociateStyleController(controls::GuiControl::IStyleController* controller) + { + associatedStyleController = controller; + } + + void GuiControlTemplate_StyleProvider::SetFocusableComposition(compositions::GuiGraphicsComposition* value) + { + controlTemplate->SetFocusableComposition(value); + } + + void GuiControlTemplate_StyleProvider::SetText(const WString& value) + { + controlTemplate->SetText(value); + } + + void GuiControlTemplate_StyleProvider::SetFont(const FontProperties& value) + { + controlTemplate->SetFont(value); + } + + void GuiControlTemplate_StyleProvider::SetVisuallyEnabled(bool value) + { + controlTemplate->SetVisuallyEnabled(value); + } + +/*********************************************************************** +GuiLabelTemplate_StyleProvider +***********************************************************************/ + + GuiLabelTemplate_StyleProvider::GuiLabelTemplate_StyleProvider(TemplateProperty factory) + :GuiControlTemplate_StyleProvider(factory) + { + if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + { + CHECK_FAIL(L"GuiLabelTemplate_StyleProvider::GuiLabelTemplate_StyleProvider()#An instance of GuiLabelTemplate is expected."); + } + } + + GuiLabelTemplate_StyleProvider::~GuiLabelTemplate_StyleProvider() + { + } + + Color GuiLabelTemplate_StyleProvider::GetDefaultTextColor() + { + return controlTemplate->GetDefaultTextColor(); + } + + void GuiLabelTemplate_StyleProvider::SetTextColor(Color value) + { + controlTemplate->SetTextColor(value); + } + +/*********************************************************************** +GuiSinglelineTextBoxTemplate_StyleProvider +***********************************************************************/ + + GuiSinglelineTextBoxTemplate_StyleProvider::GuiSinglelineTextBoxTemplate_StyleProvider(TemplateProperty factory) + :GuiControlTemplate_StyleProvider(factory) + { + if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + { + CHECK_FAIL(L"GuiSinglelineTextBoxTemplate_StyleProvider::GuiSinglelineTextBoxTemplate_StyleProvider()#An instance of GuiSinglelineTextBoxTemplate is expected."); + } + } + + GuiSinglelineTextBoxTemplate_StyleProvider::~GuiSinglelineTextBoxTemplate_StyleProvider() + { + } + + void GuiSinglelineTextBoxTemplate_StyleProvider::SetFocusableComposition(compositions::GuiGraphicsComposition* value) + { + GuiControlTemplate_StyleProvider::SetFocusableComposition(value); + if (auto style = dynamic_cast(associatedStyleController)) + { + auto element = style->GetTextElement(); + Array colors(1); + colors[0] = controlTemplate->GetTextColor(); + element->SetColors(colors); + element->SetCaretColor(controlTemplate->GetCaretColor()); + } + } + + compositions::GuiGraphicsComposition* GuiSinglelineTextBoxTemplate_StyleProvider::InstallBackground(compositions::GuiBoundsComposition* boundsComposition) + { + controlTemplate->SetAlignmentToParent(Margin(0, 0, 0, 0)); + boundsComposition->AddChild(controlTemplate); + return controlTemplate->GetContainerComposition(); + } + +/*********************************************************************** +GuiDocumentLabelTemplate_StyleProvider +***********************************************************************/ + + GuiDocumentLabelTemplate_StyleProvider::GuiDocumentLabelTemplate_StyleProvider(TemplateProperty factory) + :GuiControlTemplate_StyleProvider(factory) + { + if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + { + CHECK_FAIL(L"GuiDocumentLabelTemplate_StyleProvider::GuiDocumentLabelTemplate_StyleProvider()#An instance of GuiDocumentLabelTemplate is expected."); + } + } + + GuiDocumentLabelTemplate_StyleProvider::~GuiDocumentLabelTemplate_StyleProvider() + { + } + + Ptr GuiDocumentLabelTemplate_StyleProvider::GetBaselineDocument() + { + return controlTemplate->GetBaselineDocument(); + } + + Color GuiDocumentLabelTemplate_StyleProvider::GetCaretColor() + { + return controlTemplate->GetCaretColor(); + } + +/*********************************************************************** +GuiMenuTemplate_StyleProvider +***********************************************************************/ + + GuiMenuTemplate_StyleProvider::GuiMenuTemplate_StyleProvider(TemplateProperty factory) + :GuiControlTemplate_StyleProvider(factory) + { + } + + GuiMenuTemplate_StyleProvider::~GuiMenuTemplate_StyleProvider() + { + } + +/*********************************************************************** +GuiWindowTemplate_StyleProvider +***********************************************************************/ + + GuiWindowTemplate_StyleProvider::GuiWindowTemplate_StyleProvider(TemplateProperty factory) + :GuiControlTemplate_StyleProvider(factory) + , window(0) + { + if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + { + CHECK_FAIL(L"GuiWindowTemplate_StyleProvider::GuiWindowTemplate_StyleProvider()#An instance of GuiWindowTemplate is expected."); + } + } + + GuiWindowTemplate_StyleProvider::~GuiWindowTemplate_StyleProvider() + { + } + + void GuiWindowTemplate_StyleProvider::AttachWindow(GuiWindow* _window) + { + window = _window; + } + + void GuiWindowTemplate_StyleProvider::InitializeNativeWindowProperties() + { + if (window && window->GetNativeWindow()) + { + window->GetNativeWindow()->EnableCustomFrameMode(); + window->GetNativeWindow()->SetBorder(false); + } + } + + void GuiWindowTemplate_StyleProvider::SetSizeState(INativeWindow::WindowSizeState value) + { + controlTemplate->SetMaximized(value == INativeWindow::Maximized); + } + +#define WINDOW_TEMPLATE_GET(PROPERTY)\ + switch (controlTemplate->Get##PROPERTY##Option())\ + {\ + case BoolOption::AlwaysTrue: return true;\ + case BoolOption::AlwaysFalse: return false;\ + default: return controlTemplate->Get##PROPERTY();\ + }\ + +#define WINDOW_TEMPLATE_SET(PROPERTY)\ + if (controlTemplate->Get##PROPERTY##Option() == BoolOption::Customizable)\ + {\ + controlTemplate->Set##PROPERTY(visible);\ + if (!controlTemplate->GetCustomizedBorder() && window && window->GetNativeWindow())\ + {\ + window->GetNativeWindow()->Set##PROPERTY(visible);\ + }\ + }\ + + bool GuiWindowTemplate_StyleProvider::GetMaximizedBox() + { + WINDOW_TEMPLATE_GET(MaximizedBox); + } + + void GuiWindowTemplate_StyleProvider::SetMaximizedBox(bool visible) + { + WINDOW_TEMPLATE_SET(MaximizedBox); + } + + bool GuiWindowTemplate_StyleProvider::GetMinimizedBox() + { + WINDOW_TEMPLATE_GET(MinimizedBox); + } + + void GuiWindowTemplate_StyleProvider::SetMinimizedBox(bool visible) + { + WINDOW_TEMPLATE_SET(MinimizedBox); + } + + bool GuiWindowTemplate_StyleProvider::GetBorder() + { + WINDOW_TEMPLATE_GET(Border); + } + + void GuiWindowTemplate_StyleProvider::SetBorder(bool visible) + { + WINDOW_TEMPLATE_SET(Border); + } + + bool GuiWindowTemplate_StyleProvider::GetSizeBox() + { + WINDOW_TEMPLATE_GET(SizeBox); + } + + void GuiWindowTemplate_StyleProvider::SetSizeBox(bool visible) + { + WINDOW_TEMPLATE_SET(SizeBox); + } + + bool GuiWindowTemplate_StyleProvider::GetIconVisible() + { + WINDOW_TEMPLATE_GET(IconVisible); + } + + void GuiWindowTemplate_StyleProvider::SetIconVisible(bool visible) + { + WINDOW_TEMPLATE_SET(IconVisible); + } + + bool GuiWindowTemplate_StyleProvider::GetTitleBar() + { + WINDOW_TEMPLATE_GET(TitleBar); + } + + void GuiWindowTemplate_StyleProvider::SetTitleBar(bool visible) + { + WINDOW_TEMPLATE_SET(TitleBar); + } + + controls::GuiWindow::IStyleController* GuiWindowTemplate_StyleProvider::CreateTooltipStyle() + { + GET_FACTORY_FROM_TEMPLATE_OPT(GuiWindowTemplate, TooltipTemplate); + } + + controls::GuiLabel::IStyleController* GuiWindowTemplate_StyleProvider::CreateShortcutKeyStyle() + { + GET_FACTORY_FROM_TEMPLATE_OPT(GuiLabelTemplate, ShortcutKeyTemplate); + } + +#undef WINDOW_TEMPLATE_GET +#undef WINDOW_TEMPLATE_SET + +/*********************************************************************** +GuiButtonTemplate_StyleProvider +***********************************************************************/ + + GuiButtonTemplate_StyleProvider::GuiButtonTemplate_StyleProvider(TemplateProperty factory) + :GuiControlTemplate_StyleProvider(factory) + { + if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + { + CHECK_FAIL(L"GuiButtonTemplate_StyleProvider::GuiButtonTemplate_StyleProvider()#An instance of GuiButtonTemplate is expected."); + } + } + + GuiButtonTemplate_StyleProvider::~GuiButtonTemplate_StyleProvider() + { + } + + void GuiButtonTemplate_StyleProvider::Transfer(controls::ButtonState value) + { + controlTemplate->SetState(value); + } + +/*********************************************************************** +GuiSelectableButtonTemplate_StyleProvider +***********************************************************************/ + + GuiSelectableButtonTemplate_StyleProvider::GuiSelectableButtonTemplate_StyleProvider(TemplateProperty factory) + :GuiButtonTemplate_StyleProvider(factory) + { + if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + { + CHECK_FAIL(L"GuiButtonTemplate_StyleProvider::GuiButtonTemplate_StyleProvider()#An instance of GuiSelectableButtonTemplate is expected."); + } + } + + GuiSelectableButtonTemplate_StyleProvider::~GuiSelectableButtonTemplate_StyleProvider() + { + } + + void GuiSelectableButtonTemplate_StyleProvider::SetSelected(bool value) + { + controlTemplate->SetSelected(value); + } + +/*********************************************************************** +GuiToolstripButtonTemplate_StyleProvider +***********************************************************************/ + + GuiToolstripButtonTemplate_StyleProvider::GuiToolstripButtonTemplate_StyleProvider(TemplateProperty factory) + :GuiSelectableButtonTemplate_StyleProvider(factory) + { + if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + { + CHECK_FAIL(L"GuiButtonTemplate_StyleProvider::GuiButtonTemplate_StyleProvider()#An instance of GuiToolstripButtonTemplate is expected."); + } + } + + GuiToolstripButtonTemplate_StyleProvider::~GuiToolstripButtonTemplate_StyleProvider() + { + } + + controls::GuiMenu::IStyleController* GuiToolstripButtonTemplate_StyleProvider::CreateSubMenuStyleController() + { + GET_FACTORY_FROM_TEMPLATE(GuiMenuTemplate, SubMenuTemplate); + } + + void GuiToolstripButtonTemplate_StyleProvider::SetSubMenuExisting(bool value) + { + controlTemplate->SetSubMenuExisting(value); + } + + void GuiToolstripButtonTemplate_StyleProvider::SetSubMenuOpening(bool value) + { + controlTemplate->SetSubMenuOpening(value); + } + + controls::GuiButton* GuiToolstripButtonTemplate_StyleProvider::GetSubMenuHost() + { + return controlTemplate->GetSubMenuHost(); + } + + void GuiToolstripButtonTemplate_StyleProvider::SetImage(Ptr value) + { + controlTemplate->SetImage(value); + } + + void GuiToolstripButtonTemplate_StyleProvider::SetShortcutText(const WString& value) + { + controlTemplate->SetShortcutText(value); + } + +/*********************************************************************** +GuiListViewColumnHeaderTemplate_StyleProvider +***********************************************************************/ + + GuiListViewColumnHeaderTemplate_StyleProvider::GuiListViewColumnHeaderTemplate_StyleProvider(TemplateProperty factory) + :GuiToolstripButtonTemplate_StyleProvider(factory) + { + if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + { + CHECK_FAIL(L"GuiListViewColumnHeaderTemplate_StyleProvider::GuiListViewColumnHeaderTemplate_StyleProvider()#An instance of GuiListViewColumnHeaderTemplate is expected."); + } + } + + GuiListViewColumnHeaderTemplate_StyleProvider::~GuiListViewColumnHeaderTemplate_StyleProvider() + { + } + + void GuiListViewColumnHeaderTemplate_StyleProvider::SetColumnSortingState(controls::ColumnSortingState value) + { + controlTemplate->SetSortingState(value); + } + +/*********************************************************************** +GuiComboBoxTemplate_StyleProvider +***********************************************************************/ + + GuiComboBoxTemplate_StyleProvider::GuiComboBoxTemplate_StyleProvider(TemplateProperty factory) + :GuiToolstripButtonTemplate_StyleProvider(factory) + { + if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + { + CHECK_FAIL(L"GuiComboBoxTemplate_StyleProvider::GuiComboBoxTemplate_StyleProvider()#An instance of GuiComboBoxTemplate is expected."); + } + } + + GuiComboBoxTemplate_StyleProvider::~GuiComboBoxTemplate_StyleProvider() + { + } + + void GuiComboBoxTemplate_StyleProvider::SetCommandExecutor(controls::IComboBoxCommandExecutor* value) + { + controlTemplate->SetCommands(value); + } + + void GuiComboBoxTemplate_StyleProvider::OnItemSelected() + { + } + + void GuiComboBoxTemplate_StyleProvider::SetTextVisible(bool value) + { + controlTemplate->SetTextVisible(value); + } + +/*********************************************************************** +GuiScrollTemplate_StyleProvider +***********************************************************************/ + + GuiScrollTemplate_StyleProvider::GuiScrollTemplate_StyleProvider(TemplateProperty factory) + :GuiControlTemplate_StyleProvider(factory) + { + if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + { + CHECK_FAIL(L"GuiButtonTemplate_StyleProvider::GuiButtonTemplate_StyleProvider()#An instance of GuiScrollTemplate is expected."); + } + } + + GuiScrollTemplate_StyleProvider::~GuiScrollTemplate_StyleProvider() + { + } + + void GuiScrollTemplate_StyleProvider::SetCommandExecutor(controls::IScrollCommandExecutor* value) + { + controlTemplate->SetCommands(value); + } + + void GuiScrollTemplate_StyleProvider::SetTotalSize(vint value) + { + controlTemplate->SetTotalSize(value); + } + + void GuiScrollTemplate_StyleProvider::SetPageSize(vint value) + { + controlTemplate->SetPageSize(value); + } + + void GuiScrollTemplate_StyleProvider::SetPosition(vint value) + { + controlTemplate->SetPosition(value); + } + +/*********************************************************************** +GuiScrollViewTemplate_StyleProvider +***********************************************************************/ + + GuiScrollViewTemplate_StyleProvider::GuiScrollViewTemplate_StyleProvider(TemplateProperty factory) + :GuiControlTemplate_StyleProvider(factory) + { + if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + { + CHECK_FAIL(L"GuiScrollViewTemplate_StyleProvider::GuiScrollViewTemplate_StyleProvider()#An instance of GuiScrollViewTemplate is expected."); + } + } + + GuiScrollViewTemplate_StyleProvider::~GuiScrollViewTemplate_StyleProvider() + { + } + + controls::GuiScroll::IStyleController* GuiScrollViewTemplate_StyleProvider::CreateHorizontalScrollStyle() + { + GET_FACTORY_FROM_TEMPLATE(GuiScrollTemplate, HScrollTemplate); + } + + controls::GuiScroll::IStyleController* GuiScrollViewTemplate_StyleProvider::CreateVerticalScrollStyle() + { + GET_FACTORY_FROM_TEMPLATE(GuiScrollTemplate, VScrollTemplate); + } + + vint GuiScrollViewTemplate_StyleProvider::GetDefaultScrollSize() + { + return controlTemplate->GetDefaultScrollSize(); + } + + compositions::GuiGraphicsComposition* GuiScrollViewTemplate_StyleProvider::InstallBackground(compositions::GuiBoundsComposition* boundsComposition) + { + controlTemplate->SetAlignmentToParent(Margin(0, 0, 0, 0)); + boundsComposition->AddChild(controlTemplate); + return controlTemplate->GetContainerComposition(); + } + +/*********************************************************************** +GuiSinglelineTextBoxTemplate_StyleProvider +***********************************************************************/ + + GuiMultilineTextBoxTemplate_StyleProvider::GuiMultilineTextBoxTemplate_StyleProvider(TemplateProperty factory) + :GuiScrollViewTemplate_StyleProvider(factory) + { + if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + { + CHECK_FAIL(L"GuiMultilineTextBoxTemplate_StyleProvider::GuiMultilineTextBoxTemplate_StyleProvider()#An instance of GuiMultilineTextBoxTemplate is expected."); + } + } + + GuiMultilineTextBoxTemplate_StyleProvider::~GuiMultilineTextBoxTemplate_StyleProvider() + { + } + + void GuiMultilineTextBoxTemplate_StyleProvider::SetFocusableComposition(compositions::GuiGraphicsComposition* value) + { + GuiScrollViewTemplate_StyleProvider::SetFocusableComposition(value); + if (auto style = dynamic_cast(associatedStyleController)) + { + auto element = style->GetTextElement(); + Array colors(1); + colors[0] = controlTemplate->GetTextColor(); + element->SetColors(colors); + element->SetCaretColor(controlTemplate->GetCaretColor()); + } + } + +/*********************************************************************** +GuiDocumentViewerTemplate_StyleProvider +***********************************************************************/ + + GuiDocumentViewerTemplate_StyleProvider::GuiDocumentViewerTemplate_StyleProvider(TemplateProperty factory) + :GuiScrollViewTemplate_StyleProvider(factory) + { + if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + { + CHECK_FAIL(L"GuiDocumentViewerTemplate_StyleProvider::GuiDocumentViewerTemplate_StyleProvider()#An instance of GuiDocumentViewerTemplate is expected."); + } + } + + GuiDocumentViewerTemplate_StyleProvider::~GuiDocumentViewerTemplate_StyleProvider() + { + } + + Ptr GuiDocumentViewerTemplate_StyleProvider::GetBaselineDocument() + { + return controlTemplate->GetBaselineDocument(); + } + + Color GuiDocumentViewerTemplate_StyleProvider::GetCaretColor() + { + return controlTemplate->GetCaretColor(); + } + +/*********************************************************************** +GuiTextListTemplate_StyleProvider +***********************************************************************/ + + GuiTextListTemplate_StyleProvider::GuiTextListTemplate_StyleProvider(TemplateProperty factory) + :GuiScrollViewTemplate_StyleProvider(factory) + { + if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + { + CHECK_FAIL(L"GuiTextListTemplate_StyleProvider::GuiTextListTemplate_StyleProvider()#An instance of GuiTextListTemplate is expected."); + } + } + + GuiTextListTemplate_StyleProvider::~GuiTextListTemplate_StyleProvider() + { + } + + Color GuiTextListTemplate_StyleProvider::GetTextColor() + { + return controlTemplate->GetTextColor(); + } + + controls::GuiSelectableButton::IStyleController* GuiTextListTemplate_StyleProvider::CreateItemBackground() + { + GET_FACTORY_FROM_TEMPLATE_OPT(GuiSelectableButtonTemplate, BackgroundTemplate); + } + + controls::GuiSelectableButton::IStyleController* GuiTextListTemplate_StyleProvider::CreateCheckBulletStyle() + { + GET_FACTORY_FROM_TEMPLATE_OPT(GuiSelectableButtonTemplate, CheckBulletTemplate); + } + + controls::GuiSelectableButton::IStyleController* GuiTextListTemplate_StyleProvider::CreateRadioBulletStyle() + { + GET_FACTORY_FROM_TEMPLATE_OPT(GuiSelectableButtonTemplate, RadioBulletTemplate); + } + +/*********************************************************************** +GuiListViewTemplate_StyleProvider +***********************************************************************/ + + GuiListViewTemplate_StyleProvider::GuiListViewTemplate_StyleProvider(TemplateProperty factory) + :GuiScrollViewTemplate_StyleProvider(factory) + { + if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + { + CHECK_FAIL(L"GuiListViewTemplate_StyleProvider::GuiListViewTemplate_StyleProvider()#An instance of GuiListViewTemplate is expected."); + } + } + + GuiListViewTemplate_StyleProvider::~GuiListViewTemplate_StyleProvider() + { + } + + controls::GuiSelectableButton::IStyleController* GuiListViewTemplate_StyleProvider::CreateItemBackground() + { + GET_FACTORY_FROM_TEMPLATE_OPT(GuiSelectableButtonTemplate, BackgroundTemplate); + } + + controls::GuiListViewColumnHeader::IStyleController* GuiListViewTemplate_StyleProvider::CreateColumnStyle() + { + GET_FACTORY_FROM_TEMPLATE(GuiListViewColumnHeaderTemplate, ColumnHeaderTemplate); + } + + Color GuiListViewTemplate_StyleProvider::GetPrimaryTextColor() + { + return controlTemplate->GetPrimaryTextColor(); + } + + Color GuiListViewTemplate_StyleProvider::GetSecondaryTextColor() + { + return controlTemplate->GetSecondaryTextColor(); + } + + Color GuiListViewTemplate_StyleProvider::GetItemSeparatorColor() + { + return controlTemplate->GetItemSeparatorColor(); + } + +/*********************************************************************** +GuiTreeViewTemplate_StyleProvider +***********************************************************************/ + + GuiTreeViewTemplate_StyleProvider::GuiTreeViewTemplate_StyleProvider(TemplateProperty factory) + :GuiScrollViewTemplate_StyleProvider(factory) + { + if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + { + CHECK_FAIL(L"GuiTreeViewTemplate_StyleProvider::GuiTreeViewTemplate_StyleProvider()#An instance of GuiTreeViewTemplate is expected."); + } + } + + GuiTreeViewTemplate_StyleProvider::~GuiTreeViewTemplate_StyleProvider() + { + } + + controls::GuiSelectableButton::IStyleController* GuiTreeViewTemplate_StyleProvider::CreateItemBackground() + { + GET_FACTORY_FROM_TEMPLATE_OPT(GuiSelectableButtonTemplate, BackgroundTemplate); + } + + controls::GuiSelectableButton::IStyleController* GuiTreeViewTemplate_StyleProvider::CreateItemExpandingDecorator() + { + GET_FACTORY_FROM_TEMPLATE_OPT(GuiSelectableButtonTemplate, ExpandingDecoratorTemplate); + } + + Color GuiTreeViewTemplate_StyleProvider::GetTextColor() + { + return controlTemplate->GetTextColor(); + } + +/*********************************************************************** +GuiTabTemplate_StyleProvider +***********************************************************************/ + + controls::GuiSelectableButton::IStyleController* GuiTabTemplate_StyleProvider::CreateHeaderTemplate() + { + GET_FACTORY_FROM_TEMPLATE(GuiSelectableButtonTemplate, HeaderTemplate); + } + + controls::GuiButton::IStyleController* GuiTabTemplate_StyleProvider::CreateDropdownTemplate() + { + GET_FACTORY_FROM_TEMPLATE(GuiButtonTemplate, DropdownTemplate); + } + + controls::GuiMenu::IStyleController* GuiTabTemplate_StyleProvider::CreateMenuTemplate() + { + GET_FACTORY_FROM_TEMPLATE(GuiMenuTemplate, MenuTemplate); + } + + controls::GuiToolstripButton::IStyleController* GuiTabTemplate_StyleProvider::CreateMenuItemTemplate() + { + GET_FACTORY_FROM_TEMPLATE(GuiToolstripButtonTemplate, MenuItemTemplate); + } + + void GuiTabTemplate_StyleProvider::OnHeaderButtonClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + if(commandExecutor) + { + vint index=headerButtons.IndexOf(dynamic_cast(sender->GetAssociatedControl())); + if(index!=-1) + { + commandExecutor->ShowTab(index); + } + } + } + + void GuiTabTemplate_StyleProvider::OnTabHeaderBoundsChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + vint height=headerOverflowButton->GetBoundsComposition()->GetBounds().Height(); + headerOverflowButton->GetBoundsComposition()->SetBounds(Rect(Point(0, 0), Size(height, 0))); + + UpdateHeaderLayout(); + } + + void GuiTabTemplate_StyleProvider::OnHeaderOverflowButtonClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + headerOverflowMenu->SetClientSize(Size(0, 0)); + headerOverflowMenu->ShowPopup(headerOverflowButton, true); + } + + void GuiTabTemplate_StyleProvider::OnHeaderOverflowMenuButtonClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + vint index=headerOverflowMenu->GetToolstripItems().IndexOf(sender->GetRelatedControl()); + commandExecutor->ShowTab(index); + } + + void GuiTabTemplate_StyleProvider::UpdateHeaderOverflowButtonVisibility() + { + if(tabHeaderComposition->IsStackItemClipped()) + { + tabBoundsComposition->SetColumnOption(1, GuiCellOption::MinSizeOption()); + } + else + { + tabBoundsComposition->SetColumnOption(1, GuiCellOption::AbsoluteOption(0)); + } + tabBoundsComposition->ForceCalculateSizeImmediately(); + } + + void GuiTabTemplate_StyleProvider::UpdateHeaderZOrder() + { + vint itemCount=tabHeaderComposition->GetStackItems().Count(); + vint childCount=tabHeaderComposition->Children().Count(); + for(vint i=0;iGetStackItems().Get(i); + if(headerButtons[i]->GetSelected()) + { + tabHeaderComposition->MoveChild(item, childCount-1); + vint padding = controlTemplate->GetHeaderPadding(); + item->SetExtraMargin(Margin(padding, padding, padding, 0)); + } + else + { + item->SetExtraMargin(Margin(0, 0, 0, 0)); + } + } + if(childCount>1) + { + tabHeaderComposition->MoveChild(tabContentTopLineComposition, childCount-2); + } + } + + void GuiTabTemplate_StyleProvider::UpdateHeaderVisibilityIndex() + { + vint itemCount=tabHeaderComposition->GetStackItems().Count(); + vint selectedItem=-1; + for(vint i=0;iGetSelected()) + { + selectedItem=i; + } + } + + if(selectedItem!=-1) + { + tabHeaderComposition->EnsureVisible(selectedItem); + } + } + + void GuiTabTemplate_StyleProvider::UpdateHeaderLayout() + { + UpdateHeaderZOrder(); + UpdateHeaderVisibilityIndex(); + UpdateHeaderOverflowButtonVisibility(); + } + + void GuiTabTemplate_StyleProvider::Initialize() + { + tabBoundsComposition=new GuiTableComposition; + tabBoundsComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); + tabBoundsComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); + tabBoundsComposition->SetRowsAndColumns(1, 2); + tabBoundsComposition->SetRowOption(0, GuiCellOption::MinSizeOption()); + tabBoundsComposition->SetColumnOption(0, GuiCellOption::PercentageOption(1.0)); + tabBoundsComposition->SetColumnOption(1, GuiCellOption::AbsoluteOption(0)); + controlTemplate->GetHeaderComposition()->AddChild(tabBoundsComposition); + + vint padding = controlTemplate->GetHeaderPadding(); + { + GuiCellComposition* cell=new GuiCellComposition; + tabBoundsComposition->AddChild(cell); + cell->SetSite(0, 0, 1, 1); + + vint padding = controlTemplate->GetHeaderPadding(); + tabHeaderComposition=new GuiStackComposition; + tabHeaderComposition->SetExtraMargin(Margin(padding, padding, padding, 0)); + tabHeaderComposition->SetAlignmentToParent(Margin(0, 0, 1, 0)); + tabHeaderComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + tabHeaderComposition->BoundsChanged.AttachMethod(this, &GuiTabTemplate_StyleProvider::OnTabHeaderBoundsChanged); + cell->AddChild(tabHeaderComposition); + } + { + GuiCellComposition* cell=new GuiCellComposition; + tabBoundsComposition->AddChild(cell); + cell->SetSite(0, 1, 1, 1); + + headerOverflowButton=new GuiButton(CreateDropdownTemplate()); + headerOverflowButton->GetBoundsComposition()->SetAlignmentToParent(Margin(-1, padding, 0, 0)); + headerOverflowButton->Clicked.AttachMethod(this, &GuiTabTemplate_StyleProvider::OnHeaderOverflowButtonClicked); + cell->AddChild(headerOverflowButton->GetBoundsComposition()); + } + + headerOverflowMenu=new GuiToolstripMenu(CreateMenuTemplate(), 0); + headerController=new GuiSelectableButton::MutexGroupController; + } + + GuiTabTemplate_StyleProvider::GuiTabTemplate_StyleProvider(TemplateProperty factory) + :GuiControlTemplate_StyleProvider(factory) + { + if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + { + CHECK_FAIL(L"GuiTabTemplate_StyleProvider::GuiTabTemplate_StyleProvider()#An instance of GuiTabTemplate is expected."); + } + Initialize(); + } + + GuiTabTemplate_StyleProvider::~GuiTabTemplate_StyleProvider() + { + delete headerOverflowMenu; + } + + void GuiTabTemplate_StyleProvider::SetCommandExecutor(controls::ITabCommandExecutor* value) + { + commandExecutor=value; + } + + void GuiTabTemplate_StyleProvider::InsertTab(vint index) + { + GuiSelectableButton* button=new GuiSelectableButton(CreateHeaderTemplate()); + button->SetAutoSelection(false); + button->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); + button->SetGroupController(headerController.Obj()); + button->Clicked.AttachMethod(this, &GuiTabTemplate_StyleProvider::OnHeaderButtonClicked); + + GuiStackItemComposition* item=new GuiStackItemComposition; + item->AddChild(button->GetBoundsComposition()); + tabHeaderComposition->InsertStackItem(index, item); + headerButtons.Insert(index, button); + + GuiToolstripButton* menuItem=new GuiToolstripButton(CreateMenuItemTemplate()); + menuItem->Clicked.AttachMethod(this, &GuiTabTemplate_StyleProvider::OnHeaderOverflowMenuButtonClicked); + headerOverflowMenu->GetToolstripItems().Insert(index, menuItem); + + UpdateHeaderLayout(); + } + + void GuiTabTemplate_StyleProvider::SetTabText(vint index, const WString& value) + { + headerButtons[index]->SetText(value); + headerOverflowMenu->GetToolstripItems().Get(index)->SetText(value); + + UpdateHeaderLayout(); + } + + void GuiTabTemplate_StyleProvider::RemoveTab(vint index) + { + GuiStackItemComposition* item=tabHeaderComposition->GetStackItems().Get(index); + GuiSelectableButton* button=headerButtons[index]; + + tabHeaderComposition->RemoveChild(item); + item->RemoveChild(button->GetBoundsComposition()); + headerButtons.RemoveAt(index); + + headerOverflowMenu->GetToolstripItems().RemoveAt(index); + delete item; + delete button; + + UpdateHeaderLayout(); + } + + void GuiTabTemplate_StyleProvider::SetSelectedTab(vint index) + { + headerButtons[index]->SetSelected(true); + + UpdateHeaderLayout(); + } + + void GuiTabTemplate_StyleProvider::SetTabAlt(vint index, const WString& value) + { + auto button = headerButtons[index]; + button->SetAlt(value); + } + + compositions::IGuiAltAction* GuiTabTemplate_StyleProvider::GetTabAltAction(vint index) + { + return headerButtons[index]->QueryTypedService(); + } + +/*********************************************************************** +GuiDatePickerTemplate_StyleProvider +***********************************************************************/ + + GuiDatePickerTemplate_StyleProvider::GuiDatePickerTemplate_StyleProvider(TemplateProperty factory) + :GuiControlTemplate_StyleProvider(factory) + { + if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + { + CHECK_FAIL(L"GuiDatePickerTemplate_StyleProvider::GuiDatePickerTemplate_StyleProvider()#An instance of GuiDatePickerTemplate is expected."); + } + } + + GuiDatePickerTemplate_StyleProvider::~GuiDatePickerTemplate_StyleProvider() + { + delete controlTemplate; + } + + controls::GuiSelectableButton::IStyleController* GuiDatePickerTemplate_StyleProvider::CreateDateButtonStyle() + { + GET_FACTORY_FROM_TEMPLATE(GuiSelectableButtonTemplate, DateButtonTemplate); + } + + GuiTextListTemplate_StyleProvider* GuiDatePickerTemplate_StyleProvider::CreateTextListStyle() + { + GET_FACTORY_FROM_TEMPLATE(GuiTextListTemplate, DateTextListTemplate); + } + + controls::GuiTextList* GuiDatePickerTemplate_StyleProvider::CreateTextList() + { + auto style = CreateTextListStyle(); + return new GuiTextList(style); + } + + controls::GuiComboBoxListControl::IStyleController* GuiDatePickerTemplate_StyleProvider::CreateComboBoxStyle() + { + GET_FACTORY_FROM_TEMPLATE(GuiComboBoxTemplate, DateComboBoxTemplate); + } + + Color GuiDatePickerTemplate_StyleProvider::GetBackgroundColor() + { + return controlTemplate->GetBackgroundColor(); + } + + Color GuiDatePickerTemplate_StyleProvider::GetPrimaryTextColor() + { + return controlTemplate->GetPrimaryTextColor(); + } + + Color GuiDatePickerTemplate_StyleProvider::GetSecondaryTextColor() + { + return controlTemplate->GetSecondaryTextColor(); + } + +/*********************************************************************** +GuiDateComboBoxTemplate_StyleProvider +***********************************************************************/ + + GuiDateComboBoxTemplate_StyleProvider::GuiDateComboBoxTemplate_StyleProvider(TemplateProperty factory) + :GuiComboBoxTemplate_StyleProvider(factory) + { + if (!(controlTemplate = dynamic_cast(GetBoundsComposition()))) + { + CHECK_FAIL(L"GuiDateComboBoxTemplate_StyleProvider::GuiDateComboBoxTemplate_StyleProvider()#An instance of GuiDateComboBoxTemplate is expected."); + } + } + + GuiDateComboBoxTemplate_StyleProvider::~GuiDateComboBoxTemplate_StyleProvider() + { + } + + controls::GuiDatePicker* GuiDateComboBoxTemplate_StyleProvider::CreateArgument() + { + return new GuiDatePicker(CreateDatePickerStyle()); + } + + controls::GuiDatePicker::IStyleProvider* GuiDateComboBoxTemplate_StyleProvider::CreateDatePickerStyle() + { + GET_FACTORY_FROM_TEMPLATE(GuiDatePickerTemplate, DatePickerTemplate); + } + +/*********************************************************************** +Helper Functions +***********************************************************************/ + + void SplitBySemicolon(const WString& input, collections::List& fragments) + { + const wchar_t* attValue = input.Buffer(); + while(*attValue) + { + // split the value by ';' + const wchar_t* attSemicolon = wcschr(attValue, L';'); + WString pattern; + if(attSemicolon) + { + pattern = WString(attValue, vint(attSemicolon - attValue)); + attValue = attSemicolon + 1; + } + else + { + vint len = wcslen(attValue); + pattern = WString(attValue, len); + attValue += len; + } + + fragments.Add(pattern); + } + } + } + } +} + +#undef GET_FACTORY_FROM_TEMPLATE +#undef GET_FACTORY_FROM_TEMPLATE_OPT + +/*********************************************************************** +.\CONTROLS\STYLES\GUICOMMONSTYLES.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace common_styles + { + using namespace elements; + using namespace compositions; + using namespace controls; + +/*********************************************************************** +CommonScrollStyle +***********************************************************************/ + + void CommonScrollStyle::UpdateHandle() + { + double handlePageSize=(double)pageSize/totalSize; + double handleRatio=(double)position/totalSize; + switch(direction) + { + case Horizontal: + handleComposition->SetWidthRatio(handleRatio); + handleComposition->SetWidthPageSize(handlePageSize); + break; + case Vertical: + handleComposition->SetHeightRatio(handleRatio); + handleComposition->SetHeightPageSize(handlePageSize); + break; + } + } + + void CommonScrollStyle::OnDecreaseButtonClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + if(commandExecutor) + { + commandExecutor->SmallDecrease(); + } + } + + void CommonScrollStyle::OnIncreaseButtonClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + if(commandExecutor) + { + commandExecutor->SmallIncrease(); + } + } + + void CommonScrollStyle::OnHandleMouseDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) + { + if(commandExecutor && handleButton->GetVisuallyEnabled()) + { + draggingHandle=true; + draggingStartLocation=Point(arguments.x, arguments.y); + } + } + + void CommonScrollStyle::OnHandleMouseMove(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) + { + if(draggingHandle) + { + vint totalPixels=0; + vint currentOffset=0; + vint newOffset=0; + switch(direction) + { + case Horizontal: + totalPixels=handleComposition->GetParent()->GetBounds().Width(); + currentOffset=handleComposition->GetBounds().Left(); + newOffset=currentOffset+(arguments.x-draggingStartLocation.x); + break; + case Vertical: + totalPixels=handleComposition->GetParent()->GetBounds().Height(); + currentOffset=handleComposition->GetBounds().Top(); + newOffset=currentOffset+(arguments.y-draggingStartLocation.y); + break; + } + + double ratio=(double)newOffset/totalPixels; + vint newPosition=(vint)(ratio*totalSize); + + vint offset1=(vint)(((double)newPosition/totalSize)*totalPixels); + vint offset2=vint(((double)(newPosition+1)/totalSize)*totalPixels); + vint delta1=abs((int)(offset1-newOffset)); + vint delta2=abs((int)(offset2-newOffset)); + if(delta1SetPosition(newPosition); + } + else + { + commandExecutor->SetPosition(newPosition+1); + } + } + } + + void CommonScrollStyle::OnHandleMouseUp(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) + { + draggingHandle=false; + } + + void CommonScrollStyle::OnBigMoveMouseDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) + { + if(commandExecutor && handleButton->GetVisuallyEnabled()) + { + if(arguments.eventSource==arguments.compositionSource) + { + Rect handleBounds=handleComposition->GetBounds(); + switch(direction) + { + case Horizontal: + if(arguments.xBigDecrease(); + } + else if(arguments.x>=handleBounds.x2) + { + commandExecutor->BigIncrease(); + } + break; + case Vertical: + if(arguments.yBigDecrease(); + } + else if(arguments.y>=handleBounds.y2) + { + commandExecutor->BigIncrease(); + } + break; + } + } + } + } + + void CommonScrollStyle::BuildStyle(vint defaultSize, vint arrowSize) + { + boundsComposition=new GuiBoundsComposition; + containerComposition=InstallBackground(boundsComposition, direction); + { + GuiBoundsComposition* handleBoundsComposition=new GuiBoundsComposition; + containerComposition->AddChild(handleBoundsComposition); + + handleComposition=new GuiPartialViewComposition; + handleBoundsComposition->AddChild(handleComposition); + handleBoundsComposition->GetEventReceiver()->leftButtonDown.AttachMethod(this, &CommonScrollStyle::OnBigMoveMouseDown); + + switch(direction) + { + case Horizontal: + handleBoundsComposition->SetAlignmentToParent(Margin(defaultSize, 0, defaultSize, 0)); + handleComposition->SetPreferredMinSize(Size(defaultSize, 0)); + boundsComposition->SetPreferredMinSize(Size(0, defaultSize)); + break; + case Vertical: + handleBoundsComposition->SetAlignmentToParent(Margin(0, defaultSize, 0, defaultSize)); + handleComposition->SetPreferredMinSize(Size(0, defaultSize)); + boundsComposition->SetPreferredMinSize(Size(defaultSize, 0)); + break; + } + + handleButton=new GuiButton(CreateHandleButtonStyle(direction)); + handleButton->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); + handleComposition->AddChild(handleButton->GetBoundsComposition()); + + handleButton->GetBoundsComposition()->GetEventReceiver()->leftButtonDown.AttachMethod(this, &CommonScrollStyle::OnHandleMouseDown); + handleButton->GetBoundsComposition()->GetEventReceiver()->mouseMove.AttachMethod(this, &CommonScrollStyle::OnHandleMouseMove); + handleButton->GetBoundsComposition()->GetEventReceiver()->leftButtonUp.AttachMethod(this, &CommonScrollStyle::OnHandleMouseUp); + } + { + decreaseButton=new GuiButton(CreateDecreaseButtonStyle(direction)); + decreaseButton->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); + decreaseButton->Clicked.AttachMethod(this, &CommonScrollStyle::OnDecreaseButtonClicked); + + increaseButton=new GuiButton(CreateIncreaseButtonStyle(direction)); + increaseButton->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); + increaseButton->Clicked.AttachMethod(this, &CommonScrollStyle::OnIncreaseButtonClicked); + } + { + GuiSideAlignedComposition* decreaseComposition=new GuiSideAlignedComposition; + decreaseComposition->SetMaxLength(defaultSize); + decreaseComposition->SetMaxRatio(0.5); + decreaseComposition->AddChild(decreaseButton->GetBoundsComposition()); + containerComposition->AddChild(decreaseComposition); + + GuiSideAlignedComposition* increaseComposition=new GuiSideAlignedComposition; + increaseComposition->SetMaxLength(defaultSize); + increaseComposition->SetMaxRatio(0.5); + increaseComposition->AddChild(increaseButton->GetBoundsComposition()); + containerComposition->AddChild(increaseComposition); + + switch(direction) + { + case Horizontal: + { + decreaseComposition->SetDirection(GuiSideAlignedComposition::Left); + increaseComposition->SetDirection(GuiSideAlignedComposition::Right); + } + break; + case Vertical: + { + decreaseComposition->SetDirection(GuiSideAlignedComposition::Top); + increaseComposition->SetDirection(GuiSideAlignedComposition::Bottom); + } + break; + } + } + } + + CommonScrollStyle::CommonScrollStyle(Direction _direction) + :direction(_direction) + ,commandExecutor(0) + ,decreaseButton(0) + ,increaseButton(0) + ,boundsComposition(0) + ,containerComposition(0) + ,totalSize(1) + ,pageSize(1) + ,position(0) + ,draggingHandle(false) + { + } + + CommonScrollStyle::~CommonScrollStyle() + { + } + + compositions::GuiBoundsComposition* CommonScrollStyle::GetBoundsComposition() + { + return boundsComposition; + } + + compositions::GuiGraphicsComposition* CommonScrollStyle::GetContainerComposition() + { + return containerComposition; + } + + void CommonScrollStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) + { + } + + void CommonScrollStyle::SetText(const WString& value) + { + } + + void CommonScrollStyle::SetFont(const FontProperties& value) + { + } + + void CommonScrollStyle::SetVisuallyEnabled(bool value) + { + } + + void CommonScrollStyle::SetCommandExecutor(controls::IScrollCommandExecutor* value) + { + commandExecutor=value; + } + + void CommonScrollStyle::SetTotalSize(vint value) + { + if(totalSize!=value) + { + totalSize=value; + UpdateHandle(); + } + } + + void CommonScrollStyle::SetPageSize(vint value) + { + if(pageSize!=value) + { + pageSize=value; + UpdateHandle(); + } + } + + void CommonScrollStyle::SetPosition(vint value) + { + if(position!=value) + { + position=value; + UpdateHandle(); + } + } + +/*********************************************************************** +CommonTrackStyle +***********************************************************************/ + + void CommonTrackStyle::UpdateHandle() + { + vint maxSize=totalSize-pageSize; + if(maxSize<1) maxSize=1; + double ratio=(double)position/maxSize; + switch(direction) + { + case Horizontal: + handleComposition->SetColumnOption(0, GuiCellOption::PercentageOption(ratio)); + handleComposition->SetColumnOption(2, GuiCellOption::PercentageOption(1-ratio)); + break; + case Vertical: + handleComposition->SetRowOption(0, GuiCellOption::PercentageOption(1-ratio)); + handleComposition->SetRowOption(2, GuiCellOption::PercentageOption(ratio)); + break; + } + handleComposition->UpdateCellBounds(); + } + + void CommonTrackStyle::OnHandleMouseDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) + { + if(commandExecutor && handleButton->GetVisuallyEnabled()) + { + draggingHandle=true; + draggingStartLocation=Point(arguments.x, arguments.y); + } + } + + void CommonTrackStyle::OnHandleMouseMove(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) + { + if(draggingHandle) + { + vint totalPixels=0; + vint currentOffset=0; + vint newOffset=0; + + Rect handleArea=handleComposition->GetBounds(); + Rect handleBounds=handleButton->GetBoundsComposition()->GetParent()->GetBounds(); + switch(direction) + { + case Horizontal: + totalPixels=handleArea.Width()-handleBounds.Width(); + currentOffset=handleBounds.Left(); + newOffset=currentOffset+(arguments.x-draggingStartLocation.x); + break; + case Vertical: + totalPixels=handleArea.Height()-handleBounds.Height(); + currentOffset=handleArea.Height()-handleBounds.Bottom(); + newOffset=currentOffset-(arguments.y-draggingStartLocation.y); + break; + } + + double ratio=(double)newOffset/totalPixels; + vint maxSize=totalSize-pageSize; + if(maxSize<1) maxSize=1; + vint newPosition=(vint)(ratio*maxSize); + + vint offset1=(vint)(((double)newPosition/maxSize)*totalPixels); + vint offset2=vint(((double)(newPosition+1)/maxSize)*totalPixels); + vint delta1=abs((int)(offset1-newOffset)); + vint delta2=abs((int)(offset2-newOffset)); + if(delta1SetPosition(newPosition); + } + else + { + commandExecutor->SetPosition(newPosition+1); + } + } + } + + void CommonTrackStyle::OnHandleMouseUp(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) + { + draggingHandle=false; + } + + void CommonTrackStyle::BuildStyle(vint trackThickness, vint trackPadding, vint handleLong, vint handleShort) + { + boundsComposition=new GuiBoundsComposition; + InstallBackground(boundsComposition, direction); + { + GuiTableComposition* table=new GuiTableComposition; + boundsComposition->AddChild(table); + boundsComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + table->SetAlignmentToParent(Margin(0, 0, 0, 0)); + table->SetRowsAndColumns(3, 3); + table->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + switch(direction) + { + case Horizontal: + table->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); + table->SetRowOption(1, GuiCellOption::AbsoluteOption(handleLong)); + table->SetRowOption(2, GuiCellOption::PercentageOption(0.5)); + table->SetColumnOption(0, GuiCellOption::AbsoluteOption(trackPadding)); + table->SetColumnOption(1, GuiCellOption::PercentageOption(1.0)); + table->SetColumnOption(2, GuiCellOption::AbsoluteOption(trackPadding)); + break; + case Vertical: + table->SetRowOption(0, GuiCellOption::AbsoluteOption(trackPadding)); + table->SetRowOption(1, GuiCellOption::PercentageOption(1.0)); + table->SetRowOption(2, GuiCellOption::AbsoluteOption(trackPadding)); + table->SetColumnOption(0, GuiCellOption::PercentageOption(0.5)); + table->SetColumnOption(1, GuiCellOption::AbsoluteOption(handleLong)); + table->SetColumnOption(2, GuiCellOption::PercentageOption(0.5)); + break; + } + { + GuiCellComposition* contentCell=new GuiCellComposition; + table->AddChild(contentCell); + contentCell->SetSite(1, 1, 1, 1); + { + GuiTableComposition* trackTable=new GuiTableComposition; + trackTable->SetAlignmentToParent(Margin(0, 0, 0, 0)); + contentCell->AddChild(trackTable); + GuiCellComposition* trackCell=new GuiCellComposition; + trackTable->AddChild(trackCell); + + switch(direction) + { + case Horizontal: + trackTable->SetRowsAndColumns(3, 1); + trackTable->SetRowOption(0, GuiCellOption::PercentageOption(0.5)); + trackTable->SetRowOption(1, GuiCellOption::AbsoluteOption(trackThickness)); + trackTable->SetRowOption(2, GuiCellOption::PercentageOption(0.5)); + trackCell->SetSite(1, 0, 1, 1); + break; + case Vertical: + trackTable->SetRowsAndColumns(1, 3); + trackTable->SetColumnOption(0, GuiCellOption::PercentageOption(0.5)); + trackTable->SetColumnOption(1, GuiCellOption::AbsoluteOption(trackThickness)); + trackTable->SetColumnOption(2, GuiCellOption::PercentageOption(0.5)); + trackCell->SetSite(0, 1, 1, 1); + break; + } + InstallTrack(trackCell, direction); + } + { + handleComposition=new GuiTableComposition; + handleComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); + contentCell->AddChild(handleComposition); + GuiCellComposition* handleCell=new GuiCellComposition; + handleComposition->AddChild(handleCell); + + switch(direction) + { + case Horizontal: + handleComposition->SetRowsAndColumns(1, 3); + handleComposition->SetColumnOption(0, GuiCellOption::PercentageOption(0.0)); + handleComposition->SetColumnOption(1, GuiCellOption::AbsoluteOption(handleShort)); + handleComposition->SetColumnOption(2, GuiCellOption::PercentageOption(1.0)); + handleCell->SetSite(0, 1, 1, 1); + break; + case Vertical: + handleComposition->SetRowsAndColumns(3, 1); + handleComposition->SetRowOption(0, GuiCellOption::PercentageOption(1.0)); + handleComposition->SetRowOption(1, GuiCellOption::AbsoluteOption(handleShort)); + handleComposition->SetRowOption(2, GuiCellOption::PercentageOption(0.0)); + handleCell->SetSite(1, 0, 1, 1); + break; + } + + handleButton=new GuiButton(CreateHandleButtonStyle(direction)); + handleButton->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); + handleCell->AddChild(handleButton->GetBoundsComposition()); + + handleButton->GetBoundsComposition()->GetEventReceiver()->leftButtonDown.AttachMethod(this, &CommonTrackStyle::OnHandleMouseDown); + handleButton->GetBoundsComposition()->GetEventReceiver()->mouseMove.AttachMethod(this, &CommonTrackStyle::OnHandleMouseMove); + handleButton->GetBoundsComposition()->GetEventReceiver()->leftButtonUp.AttachMethod(this, &CommonTrackStyle::OnHandleMouseUp); + } + } + } + } + + CommonTrackStyle::CommonTrackStyle(Direction _direction) + :direction(_direction) + ,commandExecutor(0) + ,totalSize(1) + ,pageSize(1) + ,position(0) + ,draggingHandle(false) + { + } + + CommonTrackStyle::~CommonTrackStyle() + { + } + + compositions::GuiBoundsComposition* CommonTrackStyle::GetBoundsComposition() + { + return boundsComposition; + } + + compositions::GuiGraphicsComposition* CommonTrackStyle::GetContainerComposition() + { + return boundsComposition; + } + + void CommonTrackStyle::SetFocusableComposition(compositions::GuiGraphicsComposition* value) + { + } + + void CommonTrackStyle::SetText(const WString& value) + { + } + + void CommonTrackStyle::SetFont(const FontProperties& value) + { + } + + void CommonTrackStyle::SetVisuallyEnabled(bool value) + { + } + + void CommonTrackStyle::SetCommandExecutor(controls::IScrollCommandExecutor* value) + { + commandExecutor=value; + if(value) + { + value->SetPageSize(0); + } + } + + void CommonTrackStyle::SetTotalSize(vint value) + { + if(totalSize!=value) + { + totalSize=value; + UpdateHandle(); + } + } + + void CommonTrackStyle::SetPageSize(vint value) + { + if(pageSize!=value) + { + pageSize=value; + UpdateHandle(); + } + } + + void CommonTrackStyle::SetPosition(vint value) + { + if(position!=value) + { + position=value; + UpdateHandle(); + } + } + +/*********************************************************************** +CommonFragmentBuilder +***********************************************************************/ + + void CommonFragmentBuilder::FillUpArrow(elements::GuiPolygonElement* element) + { + Point points[]={Point(0, 3), Point(3, 0), Point(6, 3)}; + element->SetSize(Size(7, 4)); + element->SetPoints(points, sizeof(points)/sizeof(*points)); + } + + void CommonFragmentBuilder::FillDownArrow(elements::GuiPolygonElement* element) + { + Point points[]={Point(0, 0), Point(3, 3), Point(6, 0)}; + element->SetSize(Size(7, 4)); + element->SetPoints(points, sizeof(points)/sizeof(*points)); + } + + void CommonFragmentBuilder::FillLeftArrow(elements::GuiPolygonElement* element) + { + Point points[]={Point(3, 0), Point(0, 3), Point(3, 6)}; + element->SetSize(Size(4, 7)); + element->SetPoints(points, sizeof(points)/sizeof(*points)); + } + + void CommonFragmentBuilder::FillRightArrow(elements::GuiPolygonElement* element) + { + Point points[]={Point(0, 0), Point(3, 3), Point(0, 6)}; + element->SetSize(Size(4, 7)); + element->SetPoints(points, sizeof(points)/sizeof(*points)); + } + + elements::GuiPolygonElement* CommonFragmentBuilder::BuildUpArrow() + { + GuiPolygonElement* element=GuiPolygonElement::Create(); + FillUpArrow(element); + element->SetBorderColor(Color(0, 0, 0)); + element->SetBackgroundColor(Color(0, 0, 0)); + return element; + } + + elements::GuiPolygonElement* CommonFragmentBuilder::BuildDownArrow() + { + GuiPolygonElement* element=GuiPolygonElement::Create(); + FillDownArrow(element); + element->SetBorderColor(Color(0, 0, 0)); + element->SetBackgroundColor(Color(0, 0, 0)); + return element; + } + + elements::GuiPolygonElement* CommonFragmentBuilder::BuildLeftArrow() + { + GuiPolygonElement* element=GuiPolygonElement::Create(); + FillLeftArrow(element); + element->SetBorderColor(Color(0, 0, 0)); + element->SetBackgroundColor(Color(0, 0, 0)); + return element; + } + + elements::GuiPolygonElement* CommonFragmentBuilder::BuildRightArrow() + { + GuiPolygonElement* element=GuiPolygonElement::Create(); + FillRightArrow(element); + element->SetBorderColor(Color(0, 0, 0)); + element->SetBackgroundColor(Color(0, 0, 0)); + return element; + } + + compositions::GuiBoundsComposition* CommonFragmentBuilder::BuildDockedElementContainer(elements::IGuiGraphicsElement* element) + { + GuiBoundsComposition* composition=new GuiBoundsComposition; + composition->SetOwnedElement(element); + composition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement); + composition->SetAlignmentToParent(Margin(0, 0, 0, 0)); + return composition; + } + + compositions::GuiBoundsComposition* CommonFragmentBuilder::BuildUpArrow(elements::GuiPolygonElement*& elementOut) + { + elementOut=BuildUpArrow(); + return BuildDockedElementContainer(elementOut); + } + + compositions::GuiBoundsComposition* CommonFragmentBuilder::BuildDownArrow(elements::GuiPolygonElement*& elementOut) + { + elementOut=BuildDownArrow(); + return BuildDockedElementContainer(elementOut); + } + + compositions::GuiBoundsComposition* CommonFragmentBuilder::BuildLeftArrow(elements::GuiPolygonElement*& elementOut) + { + elementOut=BuildLeftArrow(); + return BuildDockedElementContainer(elementOut); + } + + compositions::GuiBoundsComposition* CommonFragmentBuilder::BuildRightArrow(elements::GuiPolygonElement*& elementOut) + { + elementOut=BuildRightArrow(); + return BuildDockedElementContainer(elementOut); + } + } + +/*********************************************************************** +Helpers +***********************************************************************/ + + unsigned char IntToColor(vint color) + { + return color<0?0:color>255?255:(unsigned char)color; + } + + Color BlendColor(Color c1, Color c2, vint currentPosition, vint totalLength) + { + return Color( + (unsigned char)IntToColor((c2.r*currentPosition+c1.r*(totalLength-currentPosition))/totalLength), + (unsigned char)IntToColor((c2.g*currentPosition+c1.g*(totalLength-currentPosition))/totalLength), + (unsigned char)IntToColor((c2.b*currentPosition+c1.b*(totalLength-currentPosition))/totalLength), + (unsigned char)IntToColor((c2.a*currentPosition+c1.a*(totalLength-currentPosition))/totalLength) + ); + } + } +} + +/*********************************************************************** +.\CONTROLS\TEXTEDITORPACKAGE\LANGUAGESERVICE\GUILANGUAGEAUTOCOMPLETE.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace controls + { + using namespace elements; + using namespace regex; + using namespace parsing; + using namespace parsing::tabling; + using namespace collections; + +/*********************************************************************** +GuiGrammarAutoComplete +***********************************************************************/ + + void GuiGrammarAutoComplete::Attach(elements::GuiColorizedTextElement* _element, SpinLock& _elementModifyLock, compositions::GuiGraphicsComposition* _ownerComposition, vuint editVersion) + { + GuiTextBoxAutoCompleteBase::Attach(_element, _elementModifyLock, _ownerComposition, editVersion); + RepeatingParsingExecutor::CallbackBase::Attach(_element, _elementModifyLock, _ownerComposition, editVersion); + } + + void GuiGrammarAutoComplete::Detach() + { + GuiTextBoxAutoCompleteBase::Detach(); + RepeatingParsingExecutor::CallbackBase::Detach(); + if(element && elementModifyLock) + { + EnsureAutoCompleteFinished(); + } + } + + void GuiGrammarAutoComplete::TextEditPreview(TextEditPreviewStruct& arguments) + { + GuiTextBoxAutoCompleteBase::TextEditPreview(arguments); + RepeatingParsingExecutor::CallbackBase::TextEditPreview(arguments); + + if(element && elementModifyLock) + { + if(IsListOpening() && arguments.keyInput && arguments.originalText==L"" && arguments.inputText!=L"") + { + WString selectedItem=GetSelectedListItem(); + if(selectedItem!=L"") + { + TextPos begin=GetListStartPosition(); + TextPos end=arguments.originalStart; + WString editingText=element->GetLines().GetText(begin, end); + editingText+=arguments.inputText; + if(grammarParser->GetTable()->GetLexer().Walk().IsClosedToken(editingText)) + { + arguments.originalStart=begin; + arguments.inputText=selectedItem+arguments.inputText; + CloseList(); + } + } + } + } + } + + void GuiGrammarAutoComplete::TextEditNotify(const TextEditNotifyStruct& arguments) + { + GuiTextBoxAutoCompleteBase::TextEditNotify(arguments); + RepeatingParsingExecutor::CallbackBase::TextEditNotify(arguments); + if(element && elementModifyLock) + { + editing=true; + SPIN_LOCK(editTraceLock) + { + editTrace.Add(arguments); + } + } + } + + void GuiGrammarAutoComplete::TextCaretChanged(const TextCaretChangedStruct& arguments) + { + GuiTextBoxAutoCompleteBase::TextCaretChanged(arguments); + RepeatingParsingExecutor::CallbackBase::TextCaretChanged(arguments); + if(element && elementModifyLock) + { + SPIN_LOCK(editTraceLock) + { + // queue a fake TextEditNotifyStruct + // a fake struct can be detected by (trace.originalText==L"" && trace.inputText==L"") + TextEditNotifyStruct trace; + trace.editVersion=arguments.editVersion; + trace.originalStart=arguments.oldBegin; + trace.originalEnd=arguments.oldEnd; + trace.inputStart=arguments.newBegin; + trace.inputEnd=arguments.newEnd; + + // ensure trace.originalStart<=trace.originalEnd + if(trace.originalStart>trace.originalEnd) + { + TextPos temp=trace.originalStart; + trace.originalStart=trace.originalEnd; + trace.originalEnd=temp; + } + // ensure trace.inputStart<=trace.inputEnd + if(trace.inputStart>trace.inputEnd) + { + TextPos temp=trace.inputStart; + trace.inputStart=trace.inputEnd; + trace.inputEnd=temp; + } + editTrace.Add(trace); + } + + SPIN_LOCK(contextLock) + { + if(context.input.node) + { + if(editing) + { + // if the current caret changing is caused by editing + // submit a task with valid editVersion and invalid node and code + RepeatingParsingOutput input; + input.editVersion=context.input.editVersion; + SubmitTask(input); + } + else if(context.input.editVersion == arguments.editVersion) + { + // if the current caret changing is not caused by editing + // submit a task with the previous input + SubmitTask(context.input); + } + } + } + } + } + + void GuiGrammarAutoComplete::TextEditFinished(vuint editVersion) + { + GuiTextBoxAutoCompleteBase::TextEditFinished(editVersion); + RepeatingParsingExecutor::CallbackBase::TextEditFinished(editVersion); + if(element && elementModifyLock) + { + editing=false; + } + } + + void GuiGrammarAutoComplete::OnParsingFinishedAsync(const RepeatingParsingOutput& arguments) + { + if(element && elementModifyLock) + { + GetApplication()->InvokeInMainThread([=]() + { + // submit a task if the RepeatingParsingExecutor notices a new parsing result + SubmitTask(arguments); + }); + } + } + + void GuiGrammarAutoComplete::CollectLeftRecursiveRules() + { + leftRecursiveRules.Clear(); + Ptr parser=parsingExecutor->GetParser(); + Ptr table=parser->GetTable(); + vint stateCount=table->GetStateCount(); + vint tokenCount=table->GetTokenCount(); + for(vint i=0;i bag=table->GetTransitionBag(i, j); + if(bag) + { + FOREACH(Ptr, item, bag->transitionItems) + { + FOREACH(ParsingTable::Instruction, ins, item->instructions) + { + if(ins.instructionType==ParsingTable::Instruction::LeftRecursiveReduce) + { + if(!leftRecursiveRules.Contains(ins.creatorRule)) + { + leftRecursiveRules.Add(ins.creatorRule); + } + } + } + } + } + } + } + } + + vint GuiGrammarAutoComplete::UnsafeGetEditTraceIndex(vuint editVersion) + { + // get the index of the latest TextEditNotifyStruct of a specified edit version + // this function should be called inside SPIN_LOCK(editTraceLock) + // perform a binary search + vint start = 0; + vint end = editTrace.Count() - 1; + while (start <= end) + { + vint middle = (start + end) / 2; + TextEditNotifyStruct& trace = editTrace[middle]; + + if (editVersiontrace.editVersion) + { + start = middle + 1; + } + else + { + // if multiple TextEditNotifyStruct is found, choose the latest one + while (middle < editTrace.Count() - 1) + { + if (editTrace[middle + 1].editVersion == editTrace[middle].editVersion) + { + middle++; + } + else + { + break; + } + } + return middle; + } + } + return -1; + } + + TextPos GuiGrammarAutoComplete::ChooseCorrectTextPos(TextPos pos, const regex::RegexTokens& tokens) + { + Ptr table=grammarParser->GetTable(); + RegexToken lastToken; + lastToken.reading=0; + + FOREACH(RegexToken, token, tokens) + { + // we treat "class| Name" as editing the first token + if(TextPos(token.rowEnd, token.columnEnd+1)>=pos) + { + if(table->GetTableTokenIndex(token.token)!=-1 && lastToken.reading) + { + pos=TextPos(lastToken.rowStart, lastToken.columnStart); + } + break; + } + lastToken=token; + } + return pos; + } + + void GuiGrammarAutoComplete::ExecuteRefresh(AutoCompleteContext& newContext) + { + // process the input of a task is submitted not by text editing + // find the text selection by the edit version of the input + TextPos startPos, endPos; + { + SPIN_LOCK(editTraceLock) + { + vint traceIndex = UnsafeGetEditTraceIndex(newContext.input.editVersion); + if (traceIndex == -1) return; + + TextEditNotifyStruct& trace = editTrace[traceIndex]; + startPos = trace.inputStart; + endPos = trace.inputEnd; + } + + const RegexLexer& lexer = grammarParser->GetTable()->GetLexer(); + RegexTokens tokens = lexer.Parse(newContext.input.code); + startPos = ChooseCorrectTextPos(startPos, tokens); + } + + // locate the deepest node using the text selection + ParsingTextPos start(startPos.row, startPos.column); + ParsingTextPos end(endPos.row, endPos.column); + ParsingTextRange range(start, end); + ParsingTreeNode* found = newContext.input.node->FindDeepestNode(range); + ParsingTreeObject* selectedNode = 0; + + // if the location failed, choose the root node + if (!found || startPos == TextPos(0, 0)) + { + found = newContext.input.node.Obj(); + } + + if (!selectedNode) + { + // from the deepest node, traverse towards the root node + // find the deepest node whose created rule is a left recursive rule and whose parent is not + ParsingTreeObject* lrec = 0; + ParsingTreeNode* current = found; + while (current) + { + ParsingTreeObject* obj = dynamic_cast(current); + if (obj) + { + FOREACH(WString, rule, obj->GetCreatorRules()) + { + if (leftRecursiveRules.Contains(rule)) + { + lrec = obj; + break; + } + } + if (obj && lrec && lrec != obj) + { + selectedNode = lrec; + break; + } + } + current = current->GetParent(); + } + } + + if (!selectedNode) + { + // if there is no left recursive rule that creates the deepest node and all indirect parents + // choose the deepest ParsingTreeObject + ParsingTreeNode* current = found; + while (current) + { + ParsingTreeObject* obj = dynamic_cast(current); + if (obj) + { + selectedNode = obj; + break; + } + current = current->GetParent(); + } + } + + if (selectedNode) + { + // get the code range of the selected node + start = selectedNode->GetCodeRange().start; + end = selectedNode->GetCodeRange().end; + + // get all properties from the selected node + newContext.rule = selectedNode->GetCreatorRules()[selectedNode->GetCreatorRules().Count() - 1]; + newContext.originalRange = selectedNode->GetCodeRange(); + newContext.originalNode = dynamic_cast(selectedNode); + newContext.modifiedNode = newContext.originalNode; + newContext.modifiedEditVersion = newContext.input.editVersion; + + // get the corresponding code of the selected node + if (start.index >= 0 && end.index >= 0) + { + newContext.modifiedCode = newContext.input.code.Sub(start.index, end.index - start.index + 1).Buffer(); + } + } + } + + bool GuiGrammarAutoComplete::NormalizeTextPos(AutoCompleteContext& newContext, elements::text::TextLines& lines, TextPos& pos) + { + // get the start position + TextPos start(newContext.originalRange.start.row, newContext.originalRange.start.column); + + // get the end position of the end of lines + TextPos end + = lines.GetCount() <= 1 + ? TextPos(start.row, start.column + lines.GetLine(0).dataLength) + : TextPos(start.row + lines.GetCount() - 1, lines.GetLine(lines.GetCount() - 1).dataLength) + ; + + if (start <= pos && pos <= end) + { + // if the pos is inside the range + // normalize the pos to a new coordinate that the beginning position of lines is (row=0, column=0) + pos.row -= start.row; + if (pos.row == 0) + { + pos.column -= start.column; + } + return true; + } + else + { + return false; + } + } + + void GuiGrammarAutoComplete::ExecuteEdit(AutoCompleteContext& newContext) + { + // process the input of a task that is submitted by text editing + // this function make an approximiation to the context if the RepeatingParsingExecutor is not fast enough + // copy all TextEditNotifyStruct that is caused by a text editing before (and including) the edit version of the input + List usedTrace; + { + SPIN_LOCK(editTraceLock) + { + CopyFrom( + usedTrace, + From(editTrace) + .Where([&newContext](const TextEditNotifyStruct& value) + { + return (value.originalText != L"" || value.inputText != L"") && value.editVersion > newContext.modifiedEditVersion; + }) + ); + } + } + + // apply all modification to get the new modifiedCode + bool failed = false; + if (usedTrace.Count() > 0) + { + if (usedTrace[0].editVersion != newContext.modifiedEditVersion + 1) + { + // failed if any TextEditNotifyStruct is missing + failed = true; + } + else + { + // initialize a TextLines with the latest modifiedCode + text::TextLines lines(nullptr); + lines.SetText(newContext.modifiedCode); + FOREACH(TextEditNotifyStruct, trace, usedTrace) + { + // apply a modification to lines + TextPos start = trace.originalStart; + TextPos end = trace.originalEnd; + + // only if the modification is meaningful + if (NormalizeTextPos(newContext, lines, start) && NormalizeTextPos(newContext, lines, end)) + { + lines.Modify(start, end, trace.inputText); + } + else + { + // otherwise, failed + failed = true; + break; + } + } + + if (!failed) + { + newContext.modifiedCode = lines.GetText(); + } + } + } + + if (failed) + { + // clear originalNode to notify that the current context goes wrong + newContext.originalNode = 0; + } + + if (usedTrace.Count() > 0) + { + // update the edit version + newContext.modifiedEditVersion = usedTrace[usedTrace.Count() - 1].editVersion; + } + } + + void GuiGrammarAutoComplete::DeleteFutures(collections::List& futures) + { + // delete all futures and clear the list + FOREACH(ParsingState::Future*, future, futures) + { + delete future; + } + futures.Clear(); + } + + regex::RegexToken* GuiGrammarAutoComplete::TraverseTransitions( + parsing::tabling::ParsingState& state, + parsing::tabling::ParsingTransitionCollector& transitionCollector, + TextPos stopPosition, + collections::List& nonRecoveryFutures, + collections::List& recoveryFutures + ) + { + const List& transitions = transitionCollector.GetTransitions(); + for (vint index = 0; index < transitions.Count(); index++) + { + const ParsingState::TransitionResult& transition = transitions[index]; + switch (transition.transitionType) + { + case ParsingState::TransitionResult::AmbiguityBegin: + break; + case ParsingState::TransitionResult::AmbiguityBranch: + // ambiguity branches are not nested + // tokens in different braches are the same + // so we only need to run one branch, and skip the others + index = transitionCollector.GetAmbiguityEndFromBegin(transitionCollector.GetAmbiguityBeginFromBranch(index)); + break; + case ParsingState::TransitionResult::AmbiguityEnd: + break; + case ParsingState::TransitionResult::ExecuteInstructions: + { + // test does the token reach the stop position + if (transition.token) + { + // we treat "A|B" as editing A if token A is endless, otherwise treated as editing B + TextPos tokenEnd(transition.token->rowEnd, transition.token->columnEnd + 1); + + // if the caret is not at the end of the token + if (tokenEnd > stopPosition) + { + // stop the traversing and return the editing token + return transition.token; + } + else if (tokenEnd == stopPosition) + { + // if the caret is at the end of the token, and it is a closed token + // e.g. identifier is not a closed token, string is a closed token + if (!grammarParser->GetTable()->GetLexer().Walk().IsClosedToken(transition.token->reading, transition.token->length)) + { + // stop the traversing and return the editing token + return transition.token; + } + } + } + + // traverse the PDA using the token specified in the current transition + vint tableTokenIndex = transition.tableTokenIndex; + List possibilities; + if (recoveryFutures.Count() > 0) + { + FOREACH(ParsingState::Future*, future, recoveryFutures) + { + state.Explore(tableTokenIndex, future, possibilities); + } + } + else + { + FOREACH(ParsingState::Future*, future, nonRecoveryFutures) + { + state.Explore(tableTokenIndex, future, possibilities); + } + } + + // delete duplicated futures + List selectedPossibilities; + for (vint i = 0; i < possibilities.Count(); i++) + { + ParsingState::Future* candidateFuture = possibilities[i]; + bool duplicated = false; + FOREACH(ParsingState::Future*, future, selectedPossibilities) + { + if ( + candidateFuture->currentState == future->currentState && + candidateFuture->reduceStateCount == future->reduceStateCount && + candidateFuture->shiftStates.Count() == future->shiftStates.Count() + ) + { + bool same = true; + for (vint j = 0; j < future->shiftStates.Count(); j++) + { + if (candidateFuture->shiftStates[i] != future->shiftStates[i]) + { + same = false; + break; + } + } + + if ((duplicated = same)) + { + break; + } + } + } + + if (duplicated) + { + delete candidateFuture; + } + else + { + selectedPossibilities.Add(candidateFuture); + } + } + + // step forward + if (transition.token || transition.tableTokenIndex == ParsingTable::TokenBegin) + { + DeleteFutures(nonRecoveryFutures); + DeleteFutures(recoveryFutures); + CopyFrom(nonRecoveryFutures, selectedPossibilities); + } + else + { + DeleteFutures(recoveryFutures); + CopyFrom(recoveryFutures, selectedPossibilities); + } + } + break; + default:; + } + } + return 0; + } + + regex::RegexToken* GuiGrammarAutoComplete::SearchValidInputToken( + parsing::tabling::ParsingState& state, + parsing::tabling::ParsingTransitionCollector& transitionCollector, + TextPos stopPosition, + AutoCompleteContext& newContext, + collections::SortedList& tableTokenIndices + ) + { + // initialize the PDA state + state.Reset(newContext.rule); + List nonRecoveryFutures, recoveryFutures; + nonRecoveryFutures.Add(state.ExploreCreateRootFuture()); + + // traverse the PDA until it reach the stop position + // nonRecoveryFutures store the state when the last token (existing) is reached + // recoveryFutures store the state when the last token (inserted by error recovery) is reached + RegexToken* token = TraverseTransitions(state, transitionCollector, stopPosition, nonRecoveryFutures, recoveryFutures); + + // explore all possibilities from the last token before the stop position + List possibilities; + for (vint i = 0; i < nonRecoveryFutures.Count(); i++) + { + state.Explore(ParsingTable::NormalReduce, nonRecoveryFutures[i], nonRecoveryFutures); + state.Explore(ParsingTable::LeftRecursiveReduce, nonRecoveryFutures[i], nonRecoveryFutures); + } + FOREACH(ParsingState::Future*, future, nonRecoveryFutures) + { + vint count = state.GetTable()->GetTokenCount(); + for (vint i = ParsingTable::UserTokenStart; i < count; i++) + { + state.Explore(i, future, possibilities); + } + } + + // get all possible tokens that marked using @AutoCompleteCandidate + FOREACH(ParsingState::Future*, future, possibilities) + { + if (!tableTokenIndices.Contains(future->selectedToken)) + { + tableTokenIndices.Add(future->selectedToken); + } + } + + // release all data + DeleteFutures(possibilities); + DeleteFutures(nonRecoveryFutures); + DeleteFutures(recoveryFutures); + + // return the editing token + return token; + } + + TextPos GuiGrammarAutoComplete::GlobalTextPosToModifiedTextPos(AutoCompleteContext& newContext, TextPos pos) + { + pos.row-=newContext.originalRange.start.row; + if(pos.row==0) + { + pos.column-=newContext.originalRange.start.column; + } + return pos; + } + + TextPos GuiGrammarAutoComplete::ModifiedTextPosToGlobalTextPos(AutoCompleteContext& newContext, TextPos pos) + { + if(pos.row==0) + { + pos.column+=newContext.originalRange.start.column; + } + pos.row+=newContext.originalRange.start.row; + return pos; + } + + void GuiGrammarAutoComplete::ExecuteCalculateList(AutoCompleteContext& newContext) + { + // calcuate the content of the auto complete list + // it is sad that, because the parser's algorithm is too complex + // we need to reparse and track the internal state of the PDA(push-down automaton) here. + // initialize the PDA + ParsingState state(newContext.modifiedCode, grammarParser->GetTable()); + state.Reset(newContext.rule); + + // prepare to get all transitions + ParsingTransitionCollector collector; + List> errors; + + // reparse and get all transitions during parsing + if (grammarParser->Parse(state, collector, errors)) + { + // if modifiedNode is not prepared (the task is submitted because of text editing) + // use the transition to build the syntax tree + if (!newContext.modifiedNode) + { + ParsingTreeBuilder builder; + builder.Reset(); + bool succeeded = true; + FOREACH(ParsingState::TransitionResult, transition, collector.GetTransitions()) + { + if (!(succeeded = builder.Run(transition))) + { + break; + } + } + + if (succeeded) + { + Ptr parsedNode = builder.GetNode(); + newContext.modifiedNode = parsedNode.Cast(); + newContext.modifiedNode->InitializeQueryCache(); + } + } + + if (newContext.modifiedNode) + { + // get the latest text editing trace + TextEditNotifyStruct trace; + SPIN_LOCK(editTraceLock) + { + vint index = UnsafeGetEditTraceIndex(newContext.modifiedEditVersion); + if (index == -1) + { + return; + } + else + { + trace = editTrace[index]; + } + } + + // calculate the stop position for PDA traversing + TextPos stopPosition = GlobalTextPosToModifiedTextPos(newContext, trace.inputStart); + + // find all possible token before the current caret using the PDA + Ptr autoComplete = new AutoCompleteData; + SortedList tableTokenIndices; + RegexToken* editingToken = SearchValidInputToken(state, collector, stopPosition, newContext, tableTokenIndices); + + // collect all auto complete types + { + // collect all keywords that can be put into the auto complete list + FOREACH(vint, token, tableTokenIndices) + { + vint regexToken = token - ParsingTable::UserTokenStart; + if (regexToken >= 0) + { + autoComplete->candidates.Add(regexToken); + if (parsingExecutor->GetTokenMetaData(regexToken).isCandidate) + { + autoComplete->shownCandidates.Add(regexToken); + } + } + } + + // calculate the arranged stopPosition + if (editingToken) + { + TextPos tokenPos(editingToken->rowStart, editingToken->columnStart); + if (tokenPos < stopPosition) + { + stopPosition = tokenPos; + } + } + + // calculate the start/end position for PDA traversing + TextPos startPos, endPos; + { + startPos = ModifiedTextPosToGlobalTextPos(newContext, stopPosition); + autoComplete->startPosition = startPos; + endPos = trace.inputEnd; + if (newContext.modifiedNode != newContext.originalNode) + { + startPos = GlobalTextPosToModifiedTextPos(newContext, startPos); + endPos = GlobalTextPosToModifiedTextPos(newContext, endPos); + } + if (startPos0) + { + endPos.column--; + } + } + + // calculate the auto complete type + if (editingToken && parsingExecutor->GetTokenMetaData(editingToken->token).hasAutoComplete) + { + ParsingTextRange range(ParsingTextPos(startPos.row, startPos.column), ParsingTextPos(endPos.row, endPos.column)); + AutoCompleteData::RetriveContext(*autoComplete.Obj(), range, newContext.modifiedNode.Obj(), parsingExecutor.Obj()); + } + } + newContext.autoComplete = autoComplete; + } + } + } + + void GuiGrammarAutoComplete::Execute(const RepeatingParsingOutput& input) + { + SPIN_LOCK(contextLock) + { + if(input.editVersionInvokeInMainThread([=]() + { + PostList(newContext, byGlobalCorrection); + }); + } + } + + void GuiGrammarAutoComplete::PostList(const AutoCompleteContext& newContext, bool byGlobalCorrection) + { + bool openList = true; // true: make the list visible + bool keepListState = false; // true: don't change the list visibility + Ptr autoComplete = newContext.autoComplete; + + // if failed to get the auto complete list, close + if (!autoComplete) + { + openList = false; + } + if (openList) + { + if (autoComplete->shownCandidates.Count() + autoComplete->candidateItems.Count() == 0) + { + openList = false; + } + } + + TextPos startPosition, endPosition; + WString editingText; + if (openList) + { + SPIN_LOCK(editTraceLock) + { + // if the edit version is invalid, cancel + vint traceIndex = UnsafeGetEditTraceIndex(newContext.modifiedEditVersion); + if (traceIndex == -1) + { + return; + } + // an edit version has two trace at most, for text change and caret change, here we peak the text change + if (traceIndex > 0 && editTrace[traceIndex - 1].editVersion == context.modifiedEditVersion) + { + traceIndex--; + } + // if the edit version is not created by keyboard input, close + if (traceIndex >= 0) + { + TextEditNotifyStruct& trace = editTrace[traceIndex]; + if (!trace.keyInput) + { + openList = false; + } + } + + // scan all traces from the calculation's edit version until now + if (openList) + { + keepListState = true; + startPosition = autoComplete->startPosition; + endPosition = editTrace[editTrace.Count() - 1].inputEnd; + for (vint i = traceIndex; i < editTrace.Count(); i++) + { + TextEditNotifyStruct& trace = editTrace[i]; + // if there are no text change trace until now, don't change the list + if (trace.originalText != L"" || trace.inputText != L"") + { + keepListState = false; + } + // if the edit position goes before the start position of the auto complete, refresh + if (trace.inputEnd <= startPosition) + { + openList = false; + break; + } + } + } + + if (traceIndex > 0) + { + editTrace.RemoveRange(0, traceIndex); + } + } + } + + // if there is a global correction send to the UI thread but the list is not opening, cancel + if (byGlobalCorrection && !IsListOpening()) + { + return; + } + + // if the input text from the start position to the current position crosses a token, close + if (openList && element) + { + editingText = element->GetLines().GetText(startPosition, endPosition); + if (grammarParser->GetTable()->GetLexer().Walk().IsClosedToken(editingText)) + { + openList = false; + } + } + + // calculate the content of the list + if (autoComplete && ((!keepListState && openList) || IsListOpening())) + { + SortedList itemKeys; + List itemValues; + + // copy all candidate keywords + FOREACH(vint, token, autoComplete->shownCandidates) + { + WString literal = parsingExecutor->GetTokenMetaData(token).unescapedRegexText; + if (literal != L"" && !itemKeys.Contains(literal)) + { + ParsingCandidateItem item; + item.name = literal; + item.semanticId = -1; + itemValues.Insert(itemKeys.Add(literal), item); + } + } + + // copy all candidate symbols + if (autoComplete->acceptableSemanticIds) + { + FOREACH(ParsingCandidateItem, item, autoComplete->candidateItems) + { + if (autoComplete->acceptableSemanticIds->Contains(item.semanticId)) + { + // add all acceptable display of a symbol + // because a symbol can has multiple representation in different places + if (item.name != L"" && !itemKeys.Contains(item.name)) + { + itemValues.Insert(itemKeys.Add(item.name), item); + } + } + } + } + + // fill the list + List candidateItems; + for (vint i = 0; i < itemValues.Count(); i++) + { + auto& item = itemValues[i]; + if (item.tag.IsNull()) + { + if (auto analyzer = parsingExecutor->GetAnalyzer()) + { + item.tag = analyzer->CreateTagForCandidateItem(item); + } + } + + GuiTextBoxAutoCompleteBase::AutoCompleteItem candidateItem; + candidateItem.text = item.name; + candidateItem.tag = item.tag; + candidateItems.Add(candidateItem); + } + SetListContent(candidateItems); + } + + // set the list state + if (!keepListState) + { + if (openList) + { + OpenList(startPosition); + } + else + { + CloseList(); + } + } + + if (IsListOpening()) + { + HighlightList(editingText); + } + } + + void GuiGrammarAutoComplete::Initialize() + { + grammarParser=CreateAutoRecoverParser(parsingExecutor->GetParser()->GetTable()); + CollectLeftRecursiveRules(); + parsingExecutor->AttachCallback(this); + } + + void GuiGrammarAutoComplete::OnContextFinishedAsync(AutoCompleteContext& context) + { + if (auto analyzer = parsingExecutor->GetAnalyzer()) + { + if (context.autoComplete && context.autoComplete->acceptableSemanticIds) + { + analyzer->GetCandidateItemsAsync(*context.autoComplete.Obj(), context, context.autoComplete->candidateItems); + } + } + } + + void GuiGrammarAutoComplete::EnsureAutoCompleteFinished() + { + parsingExecutor->EnsureTaskFinished(); + SPIN_LOCK(contextLock) + { + context = AutoCompleteContext(); + } + } + + GuiGrammarAutoComplete::GuiGrammarAutoComplete(Ptr _parsingExecutor) + :RepeatingParsingExecutor::CallbackBase(_parsingExecutor) + ,editing(false) + { + Initialize(); + } + + GuiGrammarAutoComplete::GuiGrammarAutoComplete(Ptr _grammarParser, const WString& _grammarRule) + :RepeatingParsingExecutor::CallbackBase(new RepeatingParsingExecutor(_grammarParser, _grammarRule)) + ,editing(false) + { + Initialize(); + } + + GuiGrammarAutoComplete::~GuiGrammarAutoComplete() + { + EnsureAutoCompleteFinished(); + parsingExecutor->DetachCallback(this); + } + + Ptr GuiGrammarAutoComplete::GetParsingExecutor() + { + return parsingExecutor; + } + } + } +} + +/*********************************************************************** +.\CONTROLS\TEXTEDITORPACKAGE\LANGUAGESERVICE\GUILANGUAGEOPERATIONS.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace controls + { + using namespace collections; + using namespace parsing; + using namespace parsing::tabling; + using namespace regex_internal; + +/*********************************************************************** +ParsingContext +***********************************************************************/ + + bool ParsingTokenContext::RetriveContext(ParsingTokenContext& output, parsing::ParsingTreeNode* foundNode, RepeatingParsingExecutor* executor) + { + ParsingTreeToken* foundToken=dynamic_cast(foundNode); + if(!foundToken) return false; + ParsingTreeObject* tokenParent=dynamic_cast(foundNode->GetParent()); + if(!tokenParent) return false; + vint index=tokenParent->GetMembers().Values().IndexOf(foundNode); + if(index==-1) return false; + + WString type=tokenParent->GetType(); + WString field=tokenParent->GetMembers().Keys().Get(index); + const RepeatingParsingExecutor::FieldMetaData& md=executor->GetFieldMetaData(type, field); + + output.foundToken=foundToken; + output.tokenParent=tokenParent; + output.type=type; + output.field=field; + output.acceptableSemanticIds=md.semantics; + return true; + } + + bool ParsingTokenContext::RetriveContext(ParsingTokenContext& output, parsing::ParsingTextPos pos, parsing::ParsingTreeObject* rootNode, RepeatingParsingExecutor* executor) + { + ParsingTreeNode* foundNode=rootNode->FindDeepestNode(pos); + if(!foundNode) return false; + return RetriveContext(output, foundNode, executor); + } + + bool ParsingTokenContext::RetriveContext(ParsingTokenContext& output, parsing::ParsingTextRange range, ParsingTreeObject* rootNode, RepeatingParsingExecutor* executor) + { + ParsingTreeNode* foundNode=rootNode->FindDeepestNode(range); + if(!foundNode) return false; + return RetriveContext(output, foundNode, executor); + } + +/*********************************************************************** +RepeatingParsingExecutor::IParsingAnalyzer +***********************************************************************/ + + parsing::ParsingTreeNode* RepeatingParsingExecutor::IParsingAnalyzer::ToParent(parsing::ParsingTreeNode* node, const RepeatingPartialParsingOutput* output) + { + if (!output || !output->modifiedNode) return node; + return node == output->modifiedNode.Obj() + ? output->originalNode.Obj() + : node; + } + + parsing::ParsingTreeObject* RepeatingParsingExecutor::IParsingAnalyzer::ToChild(parsing::ParsingTreeObject* node, const RepeatingPartialParsingOutput* output) + { + if (!output || !output->modifiedNode) return node; + return node == output->originalNode.Obj() + ? output->modifiedNode.Obj() + : node; + } + + Ptr RepeatingParsingExecutor::IParsingAnalyzer::ToChild(Ptr node, const RepeatingPartialParsingOutput* output) + { + if (!output) return node; + return node == output->originalNode + ? output->modifiedNode.Cast() + : node; + } + + parsing::ParsingTreeNode* RepeatingParsingExecutor::IParsingAnalyzer::GetParent(parsing::ParsingTreeNode* node, const RepeatingPartialParsingOutput* output) + { + return ToParent(node, output)->GetParent(); + } + + Ptr RepeatingParsingExecutor::IParsingAnalyzer::GetMember(parsing::ParsingTreeObject* node, const WString& name, const RepeatingPartialParsingOutput* output) + { + return ToChild(ToChild(node, output)->GetMember(name), output); + } + + Ptr RepeatingParsingExecutor::IParsingAnalyzer::GetItem(parsing::ParsingTreeArray* node, vint index, const RepeatingPartialParsingOutput* output) + { + return ToChild(node->GetItem(index), output); + } + +/*********************************************************************** +RepeatingParsingExecutor::CallbackBase +***********************************************************************/ + + RepeatingParsingExecutor::CallbackBase::CallbackBase(Ptr _parsingExecutor) + :parsingExecutor(_parsingExecutor) + ,callbackAutoPushing(false) + ,callbackElement(0) + ,callbackElementModifyLock(0) + { + } + + RepeatingParsingExecutor::CallbackBase::~CallbackBase() + { + } + + void RepeatingParsingExecutor::CallbackBase::RequireAutoSubmitTask(bool enabled) + { + callbackAutoPushing=enabled; + } + + void RepeatingParsingExecutor::CallbackBase::Attach(elements::GuiColorizedTextElement* _element, SpinLock& _elementModifyLock, compositions::GuiGraphicsComposition* _ownerComposition, vuint editVersion) + { + if(_element) + { + SPIN_LOCK(_elementModifyLock) + { + callbackElement=_element; + callbackElementModifyLock=&_elementModifyLock; + } + } + + parsingExecutor->ActivateCallback(this); + if(callbackElement && callbackElementModifyLock && callbackAutoPushing) + { + SPIN_LOCK(*callbackElementModifyLock) + { + RepeatingParsingInput input; + input.editVersion=editVersion; + input.code=callbackElement->GetLines().GetText(); + parsingExecutor->SubmitTask(input); + } + } + } + + void RepeatingParsingExecutor::CallbackBase::Detach() + { + if(callbackElement && callbackElementModifyLock) + { + SPIN_LOCK(*callbackElementModifyLock) + { + callbackElement=0; + callbackElementModifyLock=0; + } + } + + parsingExecutor->DeactivateCallback(this); + } + + void RepeatingParsingExecutor::CallbackBase::TextEditPreview(TextEditPreviewStruct& arguments) + { + } + + void RepeatingParsingExecutor::CallbackBase::TextEditNotify(const TextEditNotifyStruct& arguments) + { + } + + void RepeatingParsingExecutor::CallbackBase::TextCaretChanged(const TextCaretChangedStruct& arguments) + { + } + + void RepeatingParsingExecutor::CallbackBase::TextEditFinished(vuint editVersion) + { + if(callbackElement && callbackElementModifyLock && callbackAutoPushing) + { + SPIN_LOCK(*callbackElementModifyLock) + { + RepeatingParsingInput input; + input.editVersion=editVersion; + input.code=callbackElement->GetLines().GetText(); + parsingExecutor->SubmitTask(input); + } + } + } + +/*********************************************************************** +RepeatingParsingExecutor +***********************************************************************/ + + void RepeatingParsingExecutor::Execute(const RepeatingParsingInput& input) + { + List> errors; + Ptr node=grammarParser->Parse(input.code, grammarRule, errors).Cast(); + if(node) + { + node->InitializeQueryCache(); + } + + RepeatingParsingOutput result; + result.node=node; + result.editVersion=input.editVersion; + result.code=input.code; + if(node) + { + OnContextFinishedAsync(result); + FOREACH(ICallback*, callback, callbacks) + { + callback->OnParsingFinishedAsync(result); + } + } + } + + void RepeatingParsingExecutor::PrepareMetaData() + { + Ptr table=grammarParser->GetTable(); + tokenIndexMap.Clear(); + semanticIndexMap.Clear(); + tokenMetaDatas.Clear(); + fieldMetaDatas.Clear(); + + Dictionary> tokenColorAtts, tokenContextColorAtts, tokenCandidateAtts, tokenAutoCompleteAtts; + Dictionary> fieldColorAtts, fieldSemanticAtts; + + { + vint tokenCount=table->GetTokenCount(); + for(vint token=ParsingTable::UserTokenStart;tokenGetTokenInfo(token); + vint tokenIndex=token-ParsingTable::UserTokenStart; + tokenIndexMap.Add(tokenInfo.name, tokenIndex); + + if(Ptr att=GetColorAttribute(tokenInfo.attributeIndex)) + { + tokenColorAtts.Add(tokenIndex, att); + } + if(Ptr att=GetContextColorAttribute(tokenInfo.attributeIndex)) + { + tokenContextColorAtts.Add(tokenIndex, att); + } + if(Ptr att=GetCandidateAttribute(tokenInfo.attributeIndex)) + { + tokenCandidateAtts.Add(tokenIndex, att); + } + if(Ptr att=GetAutoCompleteAttribute(tokenInfo.attributeIndex)) + { + tokenAutoCompleteAtts.Add(tokenIndex, att); + } + } + } + { + vint fieldCount=table->GetTreeFieldInfoCount(); + for(vint field=0;fieldGetTreeFieldInfo(field); + FieldDesc fieldDesc(fieldInfo.type, fieldInfo.field); + + if(Ptr att=GetColorAttribute(fieldInfo.attributeIndex)) + { + fieldColorAtts.Add(fieldDesc, att); + } + if(Ptr att=GetSemanticAttribute(fieldInfo.attributeIndex)) + { + fieldSemanticAtts.Add(fieldDesc, att); + } + } + } + + FOREACH(Ptr, att, + From(tokenColorAtts.Values()) + .Concat(tokenContextColorAtts.Values()) + .Concat(fieldColorAtts.Values()) + .Concat(fieldSemanticAtts.Values()) + ) + { + FOREACH(WString, argument, att->arguments) + { + if(!semanticIndexMap.Contains(argument)) + { + semanticIndexMap.Add(argument); + } + } + } + + vint index=0; + FOREACH(vint, tokenIndex, tokenIndexMap.Values()) + { + TokenMetaData md; + md.tableTokenIndex=tokenIndex+ParsingTable::UserTokenStart; + md.lexerTokenIndex=tokenIndex; + md.defaultColorIndex=-1; + md.hasContextColor=false; + md.hasAutoComplete=false; + md.isCandidate=false; + + if((index=tokenColorAtts.Keys().IndexOf(tokenIndex))!=-1) + { + md.defaultColorIndex=semanticIndexMap.IndexOf(tokenColorAtts.Values()[index]->arguments[0]); + } + md.hasContextColor=tokenContextColorAtts.Keys().Contains(tokenIndex); + md.hasAutoComplete=tokenAutoCompleteAtts.Keys().Contains(tokenIndex); + if((md.isCandidate=tokenCandidateAtts.Keys().Contains(tokenIndex))) + { + const ParsingTable::TokenInfo& tokenInfo=table->GetTokenInfo(md.tableTokenIndex); + if(IsRegexEscapedLiteralString(tokenInfo.regex)) + { + md.unescapedRegexText=UnescapeTextForRegex(tokenInfo.regex); + } + else + { + md.isCandidate=false; + } + } + + tokenMetaDatas.Add(tokenIndex, md); + } + { + vint fieldCount=table->GetTreeFieldInfoCount(); + for(vint field=0;fieldGetTreeFieldInfo(field); + FieldDesc fieldDesc(fieldInfo.type, fieldInfo.field); + + FieldMetaData md; + md.colorIndex=-1; + + if((index=fieldColorAtts.Keys().IndexOf(fieldDesc))!=-1) + { + md.colorIndex=semanticIndexMap.IndexOf(fieldColorAtts.Values()[index]->arguments[0]); + } + if((index=fieldSemanticAtts.Keys().IndexOf(fieldDesc))!=-1) + { + md.semantics=new List; + FOREACH(WString, argument, fieldSemanticAtts.Values()[index]->arguments) + { + md.semantics->Add(semanticIndexMap.IndexOf(argument)); + } + } + + fieldMetaDatas.Add(fieldDesc, md); + } + } + } + + void RepeatingParsingExecutor::OnContextFinishedAsync(RepeatingParsingOutput& context) + { + if(analyzer) + { + context.cache = analyzer->CreateCacheAsync(context); + } + } + + RepeatingParsingExecutor::RepeatingParsingExecutor(Ptr _grammarParser, const WString& _grammarRule, Ptr _analyzer) + :grammarParser(_grammarParser) + ,grammarRule(_grammarRule) + ,analyzer(_analyzer) + ,autoPushingCallback(0) + { + PrepareMetaData(); + if (analyzer) + { + analyzer->Attach(this); + } + } + + RepeatingParsingExecutor::~RepeatingParsingExecutor() + { + EnsureTaskFinished(); + if (analyzer) + { + analyzer->Detach(this); + } + } + + Ptr RepeatingParsingExecutor::GetParser() + { + return grammarParser; + } + + bool RepeatingParsingExecutor::AttachCallback(ICallback* value) + { + if(!value) return false; + if(callbacks.Contains(value)) return false; + callbacks.Add(value); + return true; + } + + bool RepeatingParsingExecutor::DetachCallback(ICallback* value) + { + if(!value) return false; + if(!callbacks.Contains(value)) return false; + DeactivateCallback(value); + callbacks.Remove(value); + return true; + } + + bool RepeatingParsingExecutor::ActivateCallback(ICallback* value) + { + if(!value) return false; + if(!callbacks.Contains(value)) return false; + if(activatedCallbacks.Contains(value)) return false; + activatedCallbacks.Add(value); + + if(!autoPushingCallback) + { + autoPushingCallback=value; + autoPushingCallback->RequireAutoSubmitTask(true); + } + return true; + } + + bool RepeatingParsingExecutor::DeactivateCallback(ICallback* value) + { + if(!value) return false; + if(!callbacks.Contains(value)) return false; + if(!activatedCallbacks.Contains(value)) return false; + + if(autoPushingCallback==value) + { + autoPushingCallback->RequireAutoSubmitTask(false); + autoPushingCallback=0; + } + activatedCallbacks.Remove(value); + if(!autoPushingCallback && activatedCallbacks.Count()>0) + { + autoPushingCallback=activatedCallbacks[0]; + autoPushingCallback->RequireAutoSubmitTask(true); + } + return true; + } + + Ptr RepeatingParsingExecutor::GetAnalyzer() + { + return analyzer; + } + + vint RepeatingParsingExecutor::GetTokenIndex(const WString& tokenName) + { + vint index=tokenIndexMap.Keys().IndexOf(tokenName); + return index==-1?-1:tokenIndexMap.Values()[index]; + } + + vint RepeatingParsingExecutor::GetSemanticId(const WString& name) + { + return semanticIndexMap.IndexOf(name); + } + + WString RepeatingParsingExecutor::GetSemanticName(vint id) + { + return 0<=id&&id RepeatingParsingExecutor::GetAttribute(vint index, const WString& name, vint argumentCount) + { + if(index!=-1) + { + Ptr att=grammarParser->GetTable()->GetAttributeInfo(index)->FindFirst(name); + if(att && (argumentCount==-1 || att->arguments.Count()==argumentCount)) + { + return att; + } + } + return 0; + } + + Ptr RepeatingParsingExecutor::GetColorAttribute(vint index) + { + return GetAttribute(index, L"Color", 1); + } + + Ptr RepeatingParsingExecutor::GetContextColorAttribute(vint index) + { + return GetAttribute(index, L"ContextColor", 0); + } + + Ptr RepeatingParsingExecutor::GetSemanticAttribute(vint index) + { + return GetAttribute(index, L"Semantic", -1); + } + + Ptr RepeatingParsingExecutor::GetCandidateAttribute(vint index) + { + return GetAttribute(index, L"Candidate", 0); + } + + Ptr RepeatingParsingExecutor::GetAutoCompleteAttribute(vint index) + { + return GetAttribute(index, L"AutoComplete", 0); + } + } + } +} + +/*********************************************************************** +.\CONTROLS\TEXTEDITORPACKAGE\LANGUAGESERVICE\GUILANGUAGECOLORIZER.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace controls + { + using namespace elements; + using namespace parsing; + using namespace parsing::tabling; + using namespace collections; + using namespace theme; + +/*********************************************************************** +GuiGrammarColorizer +***********************************************************************/ + + void GuiGrammarColorizer::OnParsingFinishedAsync(const RepeatingParsingOutput& output) + { + SPIN_LOCK(contextLock) + { + context=output; + OnContextFinishedAsync(context); + } + RestartColorizer(); + } + + void GuiGrammarColorizer::OnContextFinishedAsync(const RepeatingParsingOutput& context) + { + } + + void GuiGrammarColorizer::Attach(elements::GuiColorizedTextElement* _element, SpinLock& _elementModifyLock, compositions::GuiGraphicsComposition* _ownerComposition, vuint editVersion) + { + GuiTextBoxRegexColorizer::Attach(_element, _elementModifyLock, _ownerComposition, editVersion); + RepeatingParsingExecutor::CallbackBase::Attach(_element, _elementModifyLock, _ownerComposition, editVersion); + } + + void GuiGrammarColorizer::Detach() + { + GuiTextBoxRegexColorizer::Detach(); + RepeatingParsingExecutor::CallbackBase::Detach(); + if(element && elementModifyLock) + { + parsingExecutor->EnsureTaskFinished(); + StopColorizer(false); + } + } + + void GuiGrammarColorizer::TextEditPreview(TextEditPreviewStruct& arguments) + { + GuiTextBoxRegexColorizer::TextEditPreview(arguments); + RepeatingParsingExecutor::CallbackBase::TextEditPreview(arguments); + } + + void GuiGrammarColorizer::TextEditNotify(const TextEditNotifyStruct& arguments) + { + GuiTextBoxRegexColorizer::TextEditNotify(arguments); + RepeatingParsingExecutor::CallbackBase::TextEditNotify(arguments); + } + + void GuiGrammarColorizer::TextCaretChanged(const TextCaretChangedStruct& arguments) + { + GuiTextBoxRegexColorizer::TextCaretChanged(arguments); + RepeatingParsingExecutor::CallbackBase::TextCaretChanged(arguments); + } + + void GuiGrammarColorizer::TextEditFinished(vuint editVersion) + { + GuiTextBoxRegexColorizer::TextEditFinished(editVersion); + RepeatingParsingExecutor::CallbackBase::TextEditFinished(editVersion); + } + + void GuiGrammarColorizer::OnSemanticColorize(SemanticColorizeContext& context, const RepeatingParsingOutput& input) + { + if (auto analyzer = parsingExecutor->GetAnalyzer()) + { + auto semanticId = analyzer->GetSemanticIdForTokenAsync(context, input); + if(semanticId!=-1) + { + context.semanticId=semanticId; + } + } + } + + void GuiGrammarColorizer::EnsureColorizerFinished() + { + parsingExecutor->EnsureTaskFinished(); + StopColorizerForever(); + SPIN_LOCK(contextLock) + { + context=RepeatingParsingOutput(); + } + } + + GuiGrammarColorizer::GuiGrammarColorizer(Ptr _parsingExecutor) + :RepeatingParsingExecutor::CallbackBase(_parsingExecutor) + { + parsingExecutor->AttachCallback(this); + BeginSetColors(); + } + + GuiGrammarColorizer::GuiGrammarColorizer(Ptr _grammarParser, const WString& _grammarRule) + :RepeatingParsingExecutor::CallbackBase(new RepeatingParsingExecutor(_grammarParser, _grammarRule)) + { + parsingExecutor->AttachCallback(this); + BeginSetColors(); + } + + GuiGrammarColorizer::~GuiGrammarColorizer() + { + EnsureColorizerFinished(); + parsingExecutor->DetachCallback(this); + } + + void GuiGrammarColorizer::BeginSetColors() + { + ClearTokens(); + colorSettings.Clear(); + + text::ColorEntry entry; + { + entry.normal.text = Color(0, 0, 0); + entry.normal.background = Color(0, 0, 0, 0); + entry.selectedFocused.text = Color(255, 255, 255); + entry.selectedFocused.background = Color(51, 153, 255); + entry.selectedUnfocused.text = Color(255, 255, 255); + entry.selectedUnfocused.background = Color(51, 153, 255); + } + + SetDefaultColor(entry); + colorSettings.Add(L"Default", entry); + } + + const collections::SortedList& GuiGrammarColorizer::GetColorNames() + { + return colorSettings.Keys(); + } + + GuiGrammarColorizer::ColorEntry GuiGrammarColorizer::GetColor(const WString& name) + { + vint index=colorSettings.Keys().IndexOf(name); + return index==-1?GetDefaultColor():colorSettings.Values().Get(index); + } + + void GuiGrammarColorizer::SetColor(const WString& name, const ColorEntry& entry) + { + colorSettings.Set(name, entry); + } + + void GuiGrammarColorizer::SetColor(const WString& name, const Color& color) + { + text::ColorEntry entry=GetDefaultColor(); + entry.normal.text=color; + SetColor(name, entry); + } + + void GuiGrammarColorizer::EndSetColors() + { + SortedList tokenColors; + Ptr table=parsingExecutor->GetParser()->GetTable(); + semanticColorMap.Clear(); + + vint tokenCount=table->GetTokenCount(); + for(vint token=ParsingTable::UserTokenStart;tokenGetTokenInfo(token); + const RepeatingParsingExecutor::TokenMetaData& md=parsingExecutor->GetTokenMetaData(token-ParsingTable::UserTokenStart); + if(md.defaultColorIndex==-1) + { + AddToken(tokenInfo.regex, GetDefaultColor()); + } + else + { + WString name=parsingExecutor->GetSemanticName(md.defaultColorIndex); + vint color=AddToken(tokenInfo.regex, GetColor(name)); + semanticColorMap.Set(md.defaultColorIndex, color); + tokenColors.Add(name); + } + } + + FOREACH_INDEXER(WString, color, index, colorSettings.Keys()) + { + if(!tokenColors.Contains(color)) + { + vint semanticId=parsingExecutor->GetSemanticId(color); + if(semanticId!=-1) + { + vint tokenId=AddExtraToken(colorSettings.Values().Get(index)); + vint color=tokenId+tokenCount-ParsingTable::UserTokenStart; + semanticColorMap.Set(semanticId, color); + } + } + } + Setup(); + } + + void GuiGrammarColorizer::ColorizeTokenContextSensitive(vint lineIndex, const wchar_t* text, vint start, vint length, vint& token, vint& contextState) + { + SPIN_LOCK(contextLock) + { + ParsingTreeObject* node=context.node.Obj(); + if(node && token!=-1 && parsingExecutor->GetTokenMetaData(token).hasContextColor) + { + ParsingTextPos pos(lineIndex, start); + SemanticColorizeContext scContext; + if(SemanticColorizeContext::RetriveContext(scContext, pos, node, parsingExecutor.Obj())) + { + const RepeatingParsingExecutor::FieldMetaData& md=parsingExecutor->GetFieldMetaData(scContext.type, scContext.field); + vint semantic=md.colorIndex; + scContext.semanticId=-1; + + if(scContext.acceptableSemanticIds) + { + OnSemanticColorize(scContext, context); + if(md.semantics->Contains(scContext.semanticId)) + { + semantic=scContext.semanticId; + } + } + + if(semantic!=-1) + { + vint index=semanticColorMap.Keys().IndexOf(semantic); + if(index!=-1) + { + token=semanticColorMap.Values()[index]; + } + } + } + } + } + } + + Ptr GuiGrammarColorizer::GetParsingExecutor() + { + return parsingExecutor; + } + } + } +} + +/*********************************************************************** +.\CONTROLS\TOOLSTRIPPACKAGE\GUITOOLSTRIPCOMMAND.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace controls + { + using namespace collections; + using namespace compositions; + using namespace regex; + using namespace parsing; + +/*********************************************************************** +GuiToolstripCommand +***********************************************************************/ + + void GuiToolstripCommand::OnShortcutKeyItemExecuted(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + Executed.ExecuteWithNewSender(arguments, sender); + } + + void GuiToolstripCommand::OnRenderTargetChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) + { + UpdateShortcutOwner(); + } + + void GuiToolstripCommand::InvokeDescriptionChanged() + { + GuiEventArgs arguments; + DescriptionChanged.Execute(arguments); + } + + void GuiToolstripCommand::ReplaceShortcut(compositions::IGuiShortcutKeyItem* value, Ptr builder) + { + if (shortcutKeyItem != value) + { + if (shortcutKeyItem) + { + shortcutKeyItem->Executed.Detach(shortcutKeyItemExecutedHandler); + if (shortcutBuilder) + { + auto manager = dynamic_cast(shortcutOwner->GetShortcutKeyManager()); + if (manager) + { + manager->DestroyShortcut(shortcutBuilder->ctrl, shortcutBuilder->shift, shortcutBuilder->alt, shortcutBuilder->key); + } + } + } + shortcutKeyItem = nullptr; + shortcutKeyItemExecutedHandler = nullptr; + shortcutBuilder = value ? builder : nullptr; + if (value) + { + shortcutKeyItem = value; + shortcutKeyItemExecutedHandler = shortcutKeyItem->Executed.AttachMethod(this, &GuiToolstripCommand::OnShortcutKeyItemExecuted); + } + InvokeDescriptionChanged(); + } + } + + void GuiToolstripCommand::BuildShortcut(const WString& builderText) + { + List> errors; + if (auto parser = GetParserManager()->GetParser(L"SHORTCUT")) + { + if (Ptr builder = parser->ParseInternal(builderText, errors)) + { + if (shortcutOwner) + { + if (!shortcutOwner->GetShortcutKeyManager()) + { + shortcutOwner->SetShortcutKeyManager(new GuiShortcutKeyManager); + } + if (auto manager = dynamic_cast(shortcutOwner->GetShortcutKeyManager())) + { + IGuiShortcutKeyItem* item = manager->TryGetShortcut(builder->ctrl, builder->shift, builder->alt, builder->key); + if (!item) + { + item = manager->CreateShortcut(builder->ctrl, builder->shift, builder->alt, builder->key); + if (item) + { + ReplaceShortcut(item, builder); + } + } + } + } + else + { + shortcutBuilder = builder; + } + } + } + } + + void GuiToolstripCommand::UpdateShortcutOwner() + { + GuiControlHost* host = nullptr; + if (auto control = dynamic_cast(attachedRootObject)) + { + host = control->GetRelatedControlHost(); + } + else if (auto composition = dynamic_cast(attachedRootObject)) + { + host = composition->GetRelatedControlHost(); + } + + if (shortcutOwner != host) + { + if (shortcutOwner) + { + ReplaceShortcut(nullptr, nullptr); + shortcutOwner = nullptr; + } + shortcutOwner = host; + if (shortcutBuilder && !shortcutKeyItem) + { + BuildShortcut(shortcutBuilder->text); + } + } + } + + GuiToolstripCommand::GuiToolstripCommand() + { + } + + GuiToolstripCommand::~GuiToolstripCommand() + { + } + + void GuiToolstripCommand::Attach(GuiInstanceRootObject* rootObject) + { + GuiGraphicsComposition* rootComposition = nullptr; + + if (attachedRootObject != rootObject) + { + if (attachedRootObject) + { + if (auto control = dynamic_cast(attachedRootObject)) + { + control->RenderTargetChanged.Detach(renderTargetChangedHandler); + } + else if (auto composition = dynamic_cast(attachedRootObject)) + { + composition->GetEventReceiver()->renderTargetChanged.Detach(renderTargetChangedHandler); + } + renderTargetChangedHandler = nullptr; + } + + attachedRootObject = rootObject; + if (attachedRootObject) + { + if (auto control = dynamic_cast(attachedRootObject)) + { + renderTargetChangedHandler = control->RenderTargetChanged.AttachMethod(this, &GuiToolstripCommand::OnRenderTargetChanged); + } + else if (auto composition = dynamic_cast(attachedRootObject)) + { + renderTargetChangedHandler = composition->GetEventReceiver()->renderTargetChanged.AttachMethod(this, &GuiToolstripCommand::OnRenderTargetChanged); + } + } + UpdateShortcutOwner(); + } + } + + void GuiToolstripCommand::Detach(GuiInstanceRootObject* rootObject) + { + Attach(nullptr); + } + + Ptr GuiToolstripCommand::GetImage() + { + return image; + } + + void GuiToolstripCommand::SetImage(Ptr value) + { + if(image!=value) + { + image=value; + InvokeDescriptionChanged(); + } + } + + const WString& GuiToolstripCommand::GetText() + { + return text; + } + + void GuiToolstripCommand::SetText(const WString& value) + { + if(text!=value) + { + text=value; + InvokeDescriptionChanged(); + } + } + + compositions::IGuiShortcutKeyItem* GuiToolstripCommand::GetShortcut() + { + return shortcutKeyItem; + } + + void GuiToolstripCommand::SetShortcut(compositions::IGuiShortcutKeyItem* value) + { + ReplaceShortcut(value, 0); + } + + WString GuiToolstripCommand::GetShortcutBuilder() + { + return shortcutBuilder ? shortcutBuilder->text : L""; + } + + void GuiToolstripCommand::SetShortcutBuilder(const WString& value) + { + BuildShortcut(value); + } + + bool GuiToolstripCommand::GetEnabled() + { + return enabled; + } + + void GuiToolstripCommand::SetEnabled(bool value) + { + if(enabled!=value) + { + enabled=value; + InvokeDescriptionChanged(); + } + } + + bool GuiToolstripCommand::GetSelected() + { + return selected; + } + + void GuiToolstripCommand::SetSelected(bool value) + { + if(selected!=value) + { + selected=value; + InvokeDescriptionChanged(); + } + } + +/*********************************************************************** +GuiToolstripCommand::ShortcutBuilder Parser +***********************************************************************/ + + class GuiToolstripCommandShortcutParser : public Object, public IGuiParser + { + typedef GuiToolstripCommand::ShortcutBuilder ShortcutBuilder; + public: + Regex regexShortcut; + + GuiToolstripCommandShortcutParser() + :regexShortcut(L"((Ctrl)/+|(Shift)/+|(Alt)/+)*(/.+)") + { + } + + Ptr ParseInternal(const WString& text, collections::List>& errors)override + { + Ptr match=regexShortcut.MatchHead(text); + if (match && match->Result().Length() != text.Length()) + { + errors.Add(new ParsingError(L"Failed to parse a shortcut \"" + text + L"\".")); + return 0; + } + + Ptr builder = new ShortcutBuilder; + builder->text = text; + builder->ctrl = match->Groups().Contains(L"ctrl"); + builder->shift = match->Groups().Contains(L"shift"); + builder->alt = match->Groups().Contains(L"alt"); + + WString name = match->Groups()[L"key"][0].Value(); + builder->key = GetCurrentController()->InputService()->GetKey(name); + + return builder->key == -1 ? nullptr : builder; + } + }; + +/*********************************************************************** +GuiToolstripCommandPlugin +***********************************************************************/ + + class GuiToolstripCommandPlugin : public Object, public IGuiPlugin + { + public: + + GUI_PLUGIN_NAME(GacUI_Compiler_ShortcutParser) + { + GUI_PLUGIN_DEPEND(GacUI_Parser); + } + + void Load()override + { + IGuiParserManager* manager=GetParserManager(); + manager->SetParser(L"SHORTCUT", new GuiToolstripCommandShortcutParser); + } + + void Unload()override + { + } + }; + GUI_REGISTER_PLUGIN(GuiToolstripCommandPlugin) + } + } +} + +/*********************************************************************** +.\RESOURCES\GUIDOCUMENT_LOAD.CPP ***********************************************************************/ namespace vl @@ -41990,349 +30989,7 @@ DocumentModel } /*********************************************************************** -RESOURCES\GUIDOCUMENT_SAVE.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - using namespace collections; - using namespace parsing::xml; - -/*********************************************************************** -document_operation_visitors::SerializeRunVisitor -***********************************************************************/ - - namespace document_operation_visitors - { - class SerializeRunVisitor : public Object, public DocumentRun::IVisitor - { - protected: - DocumentModel* model; - Ptr parent; - - public: - SerializeRunVisitor(DocumentModel* _model, Ptr _parent) - :model(_model) - , parent(_parent) - { - } - - void VisitContainer(Ptr replacedParent, DocumentContainerRun* run) - { - if (replacedParent) - { - parent->subNodes.Add(replacedParent); - Ptr oldParent = parent; - parent = replacedParent; - FOREACH(Ptr, subRun, run->runs) - { - subRun->Accept(this); - } - parent = oldParent; - } - else - { - FOREACH(Ptr, subRun, run->runs) - { - subRun->Accept(this); - } - } - } - - void Visit(DocumentTextRun* run)override - { - if (run->text != L"") - { - auto writer = XmlElementWriter(parent).Element(L"nop"); - auto begin = run->text.Buffer(); - auto reading = begin; - auto last = reading; - while (true) - { - const wchar_t* tag = nullptr; - auto c = *reading; - switch (c) - { - case L'\n': - tag = L"br"; - break; - case L' ': - tag = L"sp"; - break; - case L'\t': - tag = L"tab"; - break; - } - - if (tag || c == 0) - { - if (reading > last) - { - auto end = reading[-1] == L'\r' ? reading - 1 : reading; - if (end > last) - { - writer.Text(run->text.Sub(last - begin, end - last)); - } - last = reading; - } - } - - if (tag) - { - writer.Element(tag); - } - else if (c == 0) - { - break; - } - reading++; - } - } - } - - void Visit(DocumentStylePropertiesRun* run)override - { - Ptr sp = run->style; - Ptr oldParent = parent; - if (sp->face || sp->size || sp->color) - { - Ptr element = new XmlElement; - element->name.value = L"font"; - parent->subNodes.Add(element); - - XmlElementWriter writer(element); - if (sp->face) - { - writer.Attribute(L"face", sp->face.Value()); - } - if (sp->size) - { - writer.Attribute(L"size", sp->size.Value().ToString()); - } - if (sp->color) - { - writer.Attribute(L"color", sp->color.Value().ToString()); - } - if (sp->backgroundColor) - { - writer.Attribute(L"bkcolor", sp->backgroundColor.Value().ToString()); - } - parent = element; - } - if (sp->bold) - { - Ptr element = new XmlElement; - element->name.value = sp->bold.Value() ? L"b" : L"b-"; - parent->subNodes.Add(element); - parent = element; - } - if (sp->italic) - { - Ptr element = new XmlElement; - element->name.value = sp->italic.Value() ? L"i" : L"i-"; - parent->subNodes.Add(element); - parent = element; - } - if (sp->underline) - { - Ptr element = new XmlElement; - element->name.value = sp->underline.Value() ? L"u" : L"u-"; - parent->subNodes.Add(element); - parent = element; - } - if (sp->strikeline) - { - Ptr element = new XmlElement; - element->name.value = sp->strikeline.Value() ? L"s" : L"s-"; - parent->subNodes.Add(element); - parent = element; - } - if (sp->antialias || sp->verticalAntialias) - { - bool ha = sp->antialias ? sp->antialias.Value() : true; - bool va = sp->verticalAntialias ? sp->verticalAntialias.Value() : false; - if (!ha) - { - Ptr element = new XmlElement; - element->name.value = L"ha"; - parent->subNodes.Add(element); - parent = element; - } - else if (!va) - { - Ptr element = new XmlElement; - element->name.value = L"va"; - parent->subNodes.Add(element); - parent = element; - } - else - { - Ptr element = new XmlElement; - element->name.value = L"na"; - parent->subNodes.Add(element); - parent = element; - } - } - VisitContainer(0, run); - parent = oldParent; - } - - void Visit(DocumentStyleApplicationRun* run)override - { - Ptr element = new XmlElement; - element->name.value = L"div"; - XmlElementWriter(element).Attribute(L"style", run->styleName); - VisitContainer(element, run); - } - - void Visit(DocumentHyperlinkRun* run)override - { - Ptr element = new XmlElement; - element->name.value = L"a"; - XmlElementWriter writer(element); - if (run->normalStyleName != L"#NormalLink") - { - writer.Attribute(L"normal", run->normalStyleName); - } - if (run->activeStyleName != L"#ActiveLink") - { - writer.Attribute(L"active", run->activeStyleName); - } - if (run->reference != L"") - { - writer.Attribute(L"href", run->reference); - } - VisitContainer(element, run); - } - - void Visit(DocumentImageRun* run)override - { - XmlElementWriter writer(parent); - writer - .Element(L"img") - .Attribute(L"width", itow(run->size.x)) - .Attribute(L"height", itow(run->size.y)) - .Attribute(L"baseline", itow(run->baseline)) - .Attribute(L"frameIndex", itow(run->frameIndex)) - .Attribute(L"source", run->source) - ; - } - - void Visit(DocumentEmbeddedObjectRun* run)override - { - XmlElementWriter writer(parent); - writer - .Element(L"object") - .Attribute(L"name", run->name) - ; - } - - void Visit(DocumentParagraphRun* run)override - { - Ptr element = new XmlElement; - element->name.value = L"p"; - - XmlElementWriter writer(element); - if (run->alignment) - { - switch (run->alignment.Value()) - { - case Alignment::Left: - writer.Attribute(L"align", L"Left"); - break; - case Alignment::Center: - writer.Attribute(L"align", L"Center"); - break; - case Alignment::Right: - writer.Attribute(L"align", L"Right"); - break; - } - } - VisitContainer(element, run); - } - }; - } - using namespace document_operation_visitors; - -/*********************************************************************** -DocumentModel -***********************************************************************/ - - Ptr DocumentModel::SaveToXml() - { - Ptr xml=new XmlDocument; - Ptr doc=new XmlElement; - doc->name.value=L"Doc"; - xml->rootElement=doc; - { - Ptr content=new XmlElement; - content->name.value=L"Content"; - doc->subNodes.Add(content); - - FOREACH(Ptr, p, paragraphs) - { - SerializeRunVisitor visitor(this, content); - p->Accept(&visitor); - } - } - { - Ptr stylesElement=new XmlElement; - stylesElement->name.value=L"Styles"; - doc->subNodes.Add(stylesElement); - - for(vint i=0;i0 && name[0] == L'#' && (name.Length() <= 9 || name.Right(9) != L"-Override")) continue; - - Ptr style=styles.Values().Get(i); - Ptr sp=style->styles; - Ptr styleElement=new XmlElement; - styleElement->name.value=L"Style"; - stylesElement->subNodes.Add(styleElement); - - XmlElementWriter(styleElement).Attribute(L"name", name); - if(style->parentStyleName!=L"") - { - XmlElementWriter(styleElement).Attribute(L"parent", style->parentStyleName); - } - - if(sp->face) XmlElementWriter(styleElement).Element(L"face").Text( sp->face.Value() ); - if(sp->size) XmlElementWriter(styleElement).Element(L"size").Text( sp->size.Value().ToString() ); - if(sp->color) XmlElementWriter(styleElement).Element(L"color").Text( sp->color.Value().ToString() ); - if(sp->backgroundColor) XmlElementWriter(styleElement).Element(L"bkcolor").Text( sp->backgroundColor.Value().ToString() ); - if(sp->bold) XmlElementWriter(styleElement).Element(L"b").Text( sp->bold.Value()?L"true":L"false" ); - if(sp->italic) XmlElementWriter(styleElement).Element(L"i").Text( sp->italic.Value()?L"true":L"false" ); - if(sp->underline) XmlElementWriter(styleElement).Element(L"u").Text( sp->underline.Value()?L"true":L"false" ); - if(sp->strikeline) XmlElementWriter(styleElement).Element(L"s").Text( sp->strikeline.Value()?L"true":L"false" ); - if(sp->antialias && sp->verticalAntialias) - { - bool h=sp->antialias; - bool v=sp->verticalAntialias; - if(!h) - { - XmlElementWriter(styleElement).Element(L"antialias").Text(L"no"); - } - else if(!v) - { - XmlElementWriter(styleElement).Element(L"antialias").Text(L"horizontal"); - } - else - { - XmlElementWriter(styleElement).Element(L"antialias").Text(L"vertical"); - } - } - } - } - return xml; - } - } -} - -/*********************************************************************** -RESOURCES\GUIPARSERMANAGER.CPP +.\RESOURCES\GUIPARSERMANAGER.CPP ***********************************************************************/ namespace vl @@ -42366,11 +31023,8 @@ IGuiParserManager Dictionary> parsers; public: - GuiParserManager() - { - } - - ~GuiParserManager() + + GUI_PLUGIN_NAME(GacUI_Parser) { } @@ -42383,10 +31037,6 @@ IGuiParserManager SetTableParser(L"JSON", L"JSON", &JsonParse); } - void AfterLoad()override - { - } - void Unload()override { parserManager=0; @@ -42438,7 +31088,7 @@ IGuiParserManager } /*********************************************************************** -RESOURCES\GUIRESOURCE.CPP +.\RESOURCES\GUIRESOURCE.CPP ***********************************************************************/ namespace vl @@ -43406,18 +32056,20 @@ GuiResourceFolder bool GuiResourceFolder::AddItem(const WString& name, Ptr item) { - if(item->GetParent()!=0 || items.Keys().Contains(name)) return false; + if (item->GetParent() != 0 || items.Keys().Contains(name)) return false; items.Add(name, item); - item->parent=this; - item->name=name; + item->parent = this; + item->name = name; return true; } Ptr GuiResourceFolder::RemoveItem(const WString& name) { - Ptr item=GetItem(name); - if(!item) return 0; + Ptr item = GetItem(name); + if (!item) return 0; items.Remove(name); + item->parent = nullptr; + item->name = L""; return item; } @@ -43439,18 +32091,20 @@ GuiResourceFolder bool GuiResourceFolder::AddFolder(const WString& name, Ptr folder) { - if(folder->GetParent()!=0 || folders.Keys().Contains(name)) return false; + if (folder->GetParent() != 0 || folders.Keys().Contains(name)) return false; folders.Add(name, folder); - folder->parent=this; - folder->name=name; + folder->parent = this; + folder->name = name; return true; } Ptr GuiResourceFolder::RemoveFolder(const WString& name) { - Ptr folder=GetFolder(name); - if(!folder) return 0; + Ptr folder = GetFolder(name); + if (!folder) return 0; folders.Remove(name); + folder->parent = nullptr; + folder->name = L""; return folder; } @@ -43926,11 +32580,8 @@ IGuiResourceResolverManager ResolverGroup perPassResolvers; public: - GuiResourceResolverManager() - { - } - - ~GuiResourceResolverManager() + + GUI_PLUGIN_NAME(GacUI_Res_ResourceResolver) { } @@ -43944,10 +32595,6 @@ IGuiResourceResolverManager SetPathResolverFactory(new GuiResourcePathResResolver::Factory); } - void AfterLoad()override - { - } - void Unload()override { delete globalStringKeyManager; @@ -44055,146 +32702,114 @@ IGuiResourceResolverManager } }; GUI_REGISTER_PLUGIN(GuiResourceResolverManager) - } -} /*********************************************************************** -RESOURCES\GUIRESOURCEMANAGER.CPP +Helpers ***********************************************************************/ -namespace vl -{ - namespace presentation - { - using namespace collections; - using namespace stream; - using namespace reflection::description; - using namespace controls; - -/*********************************************************************** -Class Name Record (ClassNameRecord) -***********************************************************************/ - - class GuiResourceClassNameRecordTypeResolver - : public Object - , public IGuiResourceTypeResolver - , private IGuiResourceTypeResolver_DirectLoadStream + vint CopyStream(stream::IStream& inputStream, stream::IStream& outputStream) { - public: - WString GetType()override + vint totalSize = 0; + while (true) { - return L"ClassNameRecord"; - } - - bool XmlSerializable()override - { - return false; - } - - bool StreamSerializable()override - { - return true; - } - - IGuiResourceTypeResolver_DirectLoadStream* DirectLoadStream()override - { - return this; - } - - void SerializePrecompiled(Ptr resource, Ptr content, stream::IStream& stream)override - { - if (auto obj = content.Cast()) + char buffer[1024]; + vint copied = inputStream.Read(buffer, (vint)sizeof(buffer)); + if (copied == 0) { - internal::ContextFreeWriter writer(stream); - writer << obj->classNames; + break; } + totalSize += outputStream.Write(buffer, copied); } - - Ptr ResolveResourcePrecompiled(Ptr resource, stream::IStream& stream, GuiResourceError::List& errors)override - { - internal::ContextFreeReader reader(stream); - - auto obj = MakePtr(); - reader << obj->classNames; - return obj; - } - }; - -/*********************************************************************** -IGuiInstanceResourceManager -***********************************************************************/ - - IGuiResourceManager* resourceManager = 0; - - IGuiResourceManager* GetResourceManager() - { - return resourceManager; + return totalSize; } - class GuiResourceManager : public Object, public IGuiResourceManager, public IGuiPlugin + const vint CompressionFragmentSize = 1048576; + + void CompressStream(stream::IStream& inputStream, stream::IStream& outputStream) { - protected: - typedef Dictionary> ResourceMap; - - ResourceMap resources; - ResourceMap instanceResources; - - public: - GuiResourceManager() + Array buffer(CompressionFragmentSize); + while (true) { - } + vint size = inputStream.Read(&buffer[0], buffer.Count()); + if (size == 0) break; - void Load()override - { - resourceManager = this; - } - - void AfterLoad()override - { - IGuiResourceResolverManager* manager = GetResourceResolverManager(); - manager->SetTypeResolver(new GuiResourceClassNameRecordTypeResolver); - } - - void Unload()override - { - resourceManager = nullptr; - } - - bool SetResource(const WString& name, Ptr resource, GuiResourceUsage usage)override - { - vint index = resources.Keys().IndexOf(name); - if (index != -1) return false; - - resource->Initialize(usage); - resources.Add(name, resource); - - auto record = resource->GetValueByPath(L"Precompiled/ClassNameRecord").Cast(); - FOREACH(WString, className, record->classNames) + MemoryStream compressedStream; { - instanceResources.Add(className, resource); + LzwEncoder encoder; + EncoderStream encoderStream(compressedStream, encoder); + encoderStream.Write(&buffer[0], size); } - return true; - } - Ptr GetResource(const WString& name)override - { - vint index = resources.Keys().IndexOf(name); - return index == -1 ? nullptr : resources.Values()[index]; + compressedStream.SeekFromBegin(0); + { + { + vint32_t bufferSize = (vint32_t)size; + outputStream.Write(&bufferSize, (vint)sizeof(bufferSize)); + } + { + vint32_t compressedSize = (vint32_t)compressedStream.Size(); + outputStream.Write(&compressedSize, (vint)sizeof(compressedSize)); + } + CopyStream(compressedStream, outputStream); + } } + } - Ptr GetResourceFromClassName(const WString& classFullName)override + void DecompressStream(stream::IStream& inputStream, stream::IStream& outputStream) + { + vint totalSize = 0; + vint totalWritten = 0; + while (true) { - vint index = instanceResources.Keys().IndexOf(classFullName); - if (index == -1) return nullptr; - return instanceResources.Values()[index]; + vint32_t bufferSize = 0; + if (inputStream.Read(&bufferSize, (vint)sizeof(bufferSize)) != sizeof(bufferSize)) + { + break; + } + + vint32_t compressedSize = 0; + CHECK_ERROR(inputStream.Read(&compressedSize, (vint)sizeof(compressedSize)) == sizeof(compressedSize), L"vl::presentation::DecompressStream(MemoryStream&, MemoryStream&)#Incomplete input"); + + Array buffer(compressedSize); + CHECK_ERROR(inputStream.Read(&buffer[0], compressedSize) == compressedSize, L"vl::presentation::DecompressStream(MemoryStream&, MemoryStream&)#Incomplete input"); + + MemoryWrapperStream compressedStream(&buffer[0], compressedSize); + LzwDecoder decoder; + DecoderStream decoderStream(compressedStream, decoder); + totalWritten += CopyStream(decoderStream, outputStream); + totalSize += bufferSize; } - }; - GUI_REGISTER_PLUGIN(GuiResourceManager) + CHECK_ERROR(outputStream.Size() == totalSize, L"vl::presentation::DecompressStream(MemoryStream&, MemoryStream&)#Incomplete input"); + } + + void DecompressStream(const char** buffer, bool decompress, vint rows, vint block, vint remain, stream::IStream& outputStream) + { + if (decompress) + { + MemoryStream compressedStream; + for (vint i = 0; i < rows; i++) + { + vint size = i == rows - 1 ? remain : block; + compressedStream.Write((void*)buffer[i], size); + } + compressedStream.SeekFromBegin(0); + DecompressStream(compressedStream, outputStream); + } + else + { + for (vint i = 0; i < rows; i++) + { + vint size = i == rows - 1 ? remain : block; + outputStream.Write((void*)buffer[i], size); + } + } + } } } + /*********************************************************************** -RESOURCES\GUIRESOURCETYPERESOLVERS.CPP +.\RESOURCES\GUIRESOURCETYPERESOLVERS.CPP ***********************************************************************/ namespace vl @@ -44557,14 +33172,16 @@ Doc Type Resolver (Doc) Type Resolver Plugin ***********************************************************************/ - class GuiResourceTypeResolverPlugin : public Object, public IGuiPlugin + class GuiResourceTypeResolversPlugin : public Object, public IGuiPlugin { public: - void Load()override + + GUI_PLUGIN_NAME(GacUI_Res_TypeResolvers) { + GUI_PLUGIN_DEPEND(GacUI_Res_ResourceResolver); } - void AfterLoad()override + void Load()override { IGuiResourceResolverManager* manager=GetResourceResolverManager(); manager->SetTypeResolver(new GuiResourceImageTypeResolver); @@ -44577,6 +33194,3060 @@ Type Resolver Plugin { } }; - GUI_REGISTER_PLUGIN(GuiResourceTypeResolverPlugin) + GUI_REGISTER_PLUGIN(GuiResourceTypeResolversPlugin) + } +} + + +/*********************************************************************** +.\GACUIREFLECTIONHELPER.CPP +***********************************************************************/ + +namespace vl +{ + namespace reflection + { + namespace description + { + using namespace parsing; + using namespace parsing::tabling; + using namespace parsing::xml; + using namespace stream; + using namespace collections; + using namespace presentation; + using namespace presentation::elements; + using namespace presentation::compositions; + using namespace presentation::controls; + using namespace presentation::theme; + using namespace presentation::templates; + +/*********************************************************************** +Serialization (Color) +***********************************************************************/ + + Color TypedValueSerializerProvider::GetDefaultValue() + { + return Color(); + } + + bool TypedValueSerializerProvider::Serialize(const Color& input, WString& output) + { + output = input.ToString(); + return true; + } + + bool TypedValueSerializerProvider::Deserialize(const WString& input, Color& output) + { + output = Color::Parse(input); + return true; + } + + IBoxedValue::CompareResult TypedValueSerializerProvider::Compare(const presentation::Color& a, const presentation::Color& b) + { + return TypedValueSerializerProvider::Compare(a.value, b.value); + } + +/*********************************************************************** +Serialization (DocumentFontSize) +***********************************************************************/ + + DocumentFontSize TypedValueSerializerProvider::GetDefaultValue() + { + return DocumentFontSize(); + } + + bool TypedValueSerializerProvider::Serialize(const DocumentFontSize& input, WString& output) + { + output = input.ToString(); + return true; + } + + bool TypedValueSerializerProvider::Deserialize(const WString& input, DocumentFontSize& output) + { + output = DocumentFontSize::Parse(input); + return true; + } + + IBoxedValue::CompareResult TypedValueSerializerProvider::Compare(const presentation::DocumentFontSize& a, const presentation::DocumentFontSize& b) + { + return TypedValueSerializerProvider::Compare(a.ToString(), b.ToString()); + } + +/*********************************************************************** +Serialization (GlobalStringKey) +***********************************************************************/ + + GlobalStringKey TypedValueSerializerProvider::GetDefaultValue() + { + return GlobalStringKey(); + } + + bool TypedValueSerializerProvider::Serialize(const GlobalStringKey& input, WString& output) + { + output = input.ToString(); + return true; + } + + bool TypedValueSerializerProvider::Deserialize(const WString& input, GlobalStringKey& output) + { + output = GlobalStringKey::Get(input); + return true; + } + + IBoxedValue::CompareResult TypedValueSerializerProvider::Compare(const presentation::GlobalStringKey& a, const presentation::GlobalStringKey& b) + { + return TypedValueSerializerProvider::Compare(a.ToString(), b.ToString()); + } + +/*********************************************************************** +External Functions (Basic) +***********************************************************************/ + + GuiGraphicsAnimationManager* GuiControlHost_GetAnimationManager(GuiControlHost* thisObject) + { + return thisObject->GetGraphicsHost()->GetAnimationManager(); + } + + Ptr INativeImage_Constructor(const WString& path) + { + return GetCurrentController()->ImageService()->CreateImageFromFile(path); + } + + INativeCursor* INativeCursor_Constructor1() + { + return GetCurrentController()->ResourceService()->GetDefaultSystemCursor(); + } + + INativeCursor* INativeCursor_Constructor2(INativeCursor::SystemCursorType type) + { + return GetCurrentController()->ResourceService()->GetSystemCursor(type); + } + +/*********************************************************************** +External Functions (Elements) +***********************************************************************/ + + text::TextLines* GuiColorizedTextElement_GetLines(GuiColorizedTextElement* thisObject) + { + return &thisObject->GetLines(); + } + +/*********************************************************************** +External Functions (Compositions) +***********************************************************************/ + + void GuiTableComposition_SetRows(GuiTableComposition* thisObject, vint value) + { + vint columns = thisObject->GetColumns(); + if (columns <= 0) columns = 1; + thisObject->SetRowsAndColumns(value, columns); + } + + void GuiTableComposition_SetColumns(GuiTableComposition* thisObject, vint value) + { + vint row = thisObject->GetRows(); + if (row <= 0) row = 1; + thisObject->SetRowsAndColumns(row, value); + } + + void IGuiAltActionHost_CollectAltActions(IGuiAltActionHost* host, List& actions) + { + Group group; + host->CollectAltActions(group); + for (vint i = 0; i < group.Count(); i++) + { + CopyFrom(actions, group.GetByIndex(i), true); + } + } + } + } +} + +/*********************************************************************** +.\RESOURCES\GUIRESOURCEMANAGER.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + using namespace collections; + using namespace stream; + using namespace reflection::description; + using namespace controls; + +/*********************************************************************** +Class Name Record (ClassNameRecord) +***********************************************************************/ + + class GuiResourceClassNameRecordTypeResolver + : public Object + , public IGuiResourceTypeResolver + , private IGuiResourceTypeResolver_DirectLoadStream + { + public: + WString GetType()override + { + return L"ClassNameRecord"; + } + + bool XmlSerializable()override + { + return false; + } + + bool StreamSerializable()override + { + return true; + } + + IGuiResourceTypeResolver_DirectLoadStream* DirectLoadStream()override + { + return this; + } + + void SerializePrecompiled(Ptr resource, Ptr content, stream::IStream& stream)override + { + if (auto obj = content.Cast()) + { + internal::ContextFreeWriter writer(stream); + writer << obj->classNames; + } + } + + Ptr ResolveResourcePrecompiled(Ptr resource, stream::IStream& stream, GuiResourceError::List& errors)override + { + internal::ContextFreeReader reader(stream); + + auto obj = MakePtr(); + reader << obj->classNames; + return obj; + } + }; + +/*********************************************************************** +IGuiInstanceResourceManager +***********************************************************************/ + + IGuiResourceManager* resourceManager = nullptr; + + IGuiResourceManager* GetResourceManager() + { + return resourceManager; + } + + class GuiResourceManager : public Object, public IGuiResourceManager, public IGuiPlugin + { + protected: + typedef Dictionary> ResourceMap; + + ResourceMap resources; + ResourceMap instanceResources; + + public: + + GUI_PLUGIN_NAME(GacUI_Res_Resource) + { + GUI_PLUGIN_DEPEND(GacUI_Res_ResourceResolver); + } + + void Load()override + { + resourceManager = this; + IGuiResourceResolverManager* manager = GetResourceResolverManager(); + manager->SetTypeResolver(new GuiResourceClassNameRecordTypeResolver); + } + + void Unload()override + { + resourceManager = nullptr; + } + + bool SetResource(const WString& name, Ptr resource, GuiResourceUsage usage)override + { + vint index = resources.Keys().IndexOf(name); + if (index != -1) return false; + + resource->Initialize(usage); + resources.Add(name, resource); + + auto record = resource->GetValueByPath(L"Precompiled/ClassNameRecord").Cast(); + FOREACH(WString, className, record->classNames) + { + instanceResources.Add(className, resource); + } + return true; + } + + Ptr GetResource(const WString& name)override + { + vint index = resources.Keys().IndexOf(name); + return index == -1 ? nullptr : resources.Values()[index]; + } + + Ptr GetResourceFromClassName(const WString& classFullName)override + { + vint index = instanceResources.Keys().IndexOf(classFullName); + if (index == -1) return nullptr; + return instanceResources.Values()[index]; + } + }; + GUI_REGISTER_PLUGIN(GuiResourceManager) + } +} + + +/*********************************************************************** +.\RESOURCES\GUIDOCUMENTEDITOR_ADDCONTAINER.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + using namespace collections; + using namespace document_editor; + +/*********************************************************************** +Insert container runs on top of all text ranges that intersect with the specified range +AddStyleVisitor : Apply a style on the specified range +AddHyperlinkVisitor : Apply a hyperlink on the specified range +AddStyleNameVisitor : Apply a style name on the specified range +***********************************************************************/ + + namespace document_operation_visitors + { + class AddContainerVisitor : public Object, public DocumentRun::IVisitor + { + public: + RunRangeMap& runRanges; + vint start; + vint end; + bool insertStyle; + + virtual Ptr CreateContainer() = 0; + + AddContainerVisitor(RunRangeMap& _runRanges, vint _start, vint _end) + :runRanges(_runRanges) + , start(_start) + , end(_end) + , insertStyle(false) + { + } + + void VisitContainer(DocumentContainerRun* run) + { + for (vint i = run->runs.Count() - 1; i >= 0; i--) + { + Ptr subRun = run->runs[i]; + RunRange range = runRanges[subRun.Obj()]; + if (range.startAccept(this); + if (insertStyle) + { + Ptr containerRun = CreateContainer(); + run->runs.RemoveAt(i); + containerRun->runs.Add(subRun); + run->runs.Insert(i, containerRun); + } + } + } + insertStyle = false; + } + + void Visit(DocumentTextRun* run)override + { + insertStyle = true; + } + + void Visit(DocumentStylePropertiesRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentStyleApplicationRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentHyperlinkRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentImageRun* run)override + { + insertStyle = false; + } + + void Visit(DocumentEmbeddedObjectRun* run)override + { + insertStyle = false; + } + + void Visit(DocumentParagraphRun* run)override + { + VisitContainer(run); + } + }; + + class AddStyleVisitor : public AddContainerVisitor + { + public: + Ptr style; + + Ptr CreateContainer()override + { + Ptr containerRun = new DocumentStylePropertiesRun; + containerRun->style = CopyStyle(style); + return containerRun; + } + + AddStyleVisitor(RunRangeMap& _runRanges, vint _start, vint _end, Ptr _style) + :AddContainerVisitor(_runRanges, _start, _end) + , style(_style) + { + } + }; + + class AddHyperlinkVisitor : public AddContainerVisitor + { + public: + WString reference; + WString normalStyleName; + WString activeStyleName; + + Ptr CreateContainer()override + { + Ptr containerRun = new DocumentHyperlinkRun; + containerRun->reference = reference; + containerRun->normalStyleName = normalStyleName; + containerRun->activeStyleName = activeStyleName; + containerRun->styleName = normalStyleName; + return containerRun; + } + + AddHyperlinkVisitor(RunRangeMap& _runRanges, vint _start, vint _end, const WString& _reference, const WString& _normalStyleName, const WString& _activeStyleName) + :AddContainerVisitor(_runRanges, _start, _end) + , reference(_reference) + , normalStyleName(_normalStyleName) + , activeStyleName(_activeStyleName) + { + } + }; + + class AddStyleNameVisitor : public AddContainerVisitor + { + public: + WString styleName; + + Ptr CreateContainer()override + { + Ptr containerRun = new DocumentStyleApplicationRun; + containerRun->styleName = styleName; + return containerRun; + } + + AddStyleNameVisitor(RunRangeMap& _runRanges, vint _start, vint _end, const WString& _styleName) + :AddContainerVisitor(_runRanges, _start, _end) + , styleName(_styleName) + { + } + }; + } + using namespace document_operation_visitors; + + namespace document_editor + { + void AddStyle(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end, Ptr style) + { + AddStyleVisitor visitor(runRanges, start, end, style); + run->Accept(&visitor); + } + + void AddHyperlink(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end, const WString& reference, const WString& normalStyleName, const WString& activeStyleName) + { + AddHyperlinkVisitor visitor(runRanges, start, end, reference, normalStyleName, activeStyleName); + run->Accept(&visitor); + } + + void AddStyleName(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end, const WString& styleName) + { + AddStyleNameVisitor visitor(runRanges, start, end, styleName); + run->Accept(&visitor); + } + } + } +} + +/*********************************************************************** +.\RESOURCES\GUIDOCUMENTEDITOR_CLEARUNNECESSARYRUN.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + using namespace collections; + using namespace document_editor; + +/*********************************************************************** +Clear all runs that have an empty length +***********************************************************************/ + + namespace document_operation_visitors + { + class ClearRunVisitor : public Object, public DocumentRun::IVisitor + { + public: + vint start; + + ClearRunVisitor() + :start(0) + { + } + + void VisitContainer(DocumentContainerRun* run) + { + for (vint i = run->runs.Count() - 1; i >= 0; i--) + { + vint oldStart = start; + run->runs[i]->Accept(this); + if (oldStart == start) + { + run->runs.RemoveAt(i); + } + } + } + + void VisitContent(DocumentContentRun* run) + { + start += run->GetRepresentationText().Length(); + } + + void Visit(DocumentTextRun* run)override + { + VisitContent(run); + } + + void Visit(DocumentStylePropertiesRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentStyleApplicationRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentHyperlinkRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentImageRun* run)override + { + VisitContent(run); + } + + void Visit(DocumentEmbeddedObjectRun* run)override + { + VisitContent(run); + } + + void Visit(DocumentParagraphRun* run)override + { + VisitContainer(run); + } + }; + } + using namespace document_operation_visitors; + +/*********************************************************************** +Ensure DocumentStylePropertiesRun doesn't have a child which is another DocumentStylePropertiesRun +Remove DocumentStylePropertiesRun's property if it set a value but doesn't change the output +Remove DocumentStylePropertiesRun if it is empty or contains no text run +***********************************************************************/ + + namespace document_operation_visitors + { + class CompressStyleRunVisitor : public Object, public DocumentRun::IVisitor + { + public: + DocumentModel* model; + List resolvedStyles; + List> replacedRuns; + + CompressStyleRunVisitor(DocumentModel* _model) + :model(_model) + { + DocumentModel::ResolvedStyle resolvedStyle; + resolvedStyle = model->GetStyle(DocumentModel::DefaultStyleName, resolvedStyle); + resolvedStyles.Add(resolvedStyle); + } + + const DocumentModel::ResolvedStyle& GetCurrentResolvedStyle() + { + return resolvedStyles[resolvedStyles.Count() - 1]; + } + + void VisitContainer(DocumentContainerRun* run) + { + for (vint i = 0; i < run->runs.Count(); i++) + { + Ptr subRun = run->runs[i]; + replacedRuns.Clear(); + subRun->Accept(this); + if (replacedRuns.Count() > 0) + { + run->runs.RemoveAt(i); + for (vint j = 0; j < replacedRuns.Count(); j++) + { + run->runs.Insert(i + j, replacedRuns[j]); + } + i--; + } + } + } + + void Visit(DocumentTextRun* run)override + { + } + + bool OnlyImageOrObject(DocumentContainerRun* run) + { + bool onlyImageOrObject = true; + FOREACH(Ptr, subRun, run->runs) + { + if (!subRun.Cast() && !subRun.Cast()) + { + onlyImageOrObject = false; + break; + } + } + return onlyImageOrObject; + } + + void Visit(DocumentStylePropertiesRun* run)override + { + if (OnlyImageOrObject(run)) + { + CopyFrom(replacedRuns, run->runs); + return; + } + + const DocumentModel::ResolvedStyle& currentResolvedStyle = GetCurrentResolvedStyle(); + DocumentModel::ResolvedStyle resolvedStyle = model->GetStyle(run->style, currentResolvedStyle); + + if (currentResolvedStyle.style.fontFamily == resolvedStyle.style.fontFamily) run->style->face = Nullable(); + if (currentResolvedStyle.style.size == resolvedStyle.style.size) run->style->size = Nullable(); + if (currentResolvedStyle.color == resolvedStyle.color) run->style->color = Nullable(); + if (currentResolvedStyle.backgroundColor == resolvedStyle.backgroundColor) run->style->backgroundColor = Nullable(); + if (currentResolvedStyle.style.bold == resolvedStyle.style.bold) run->style->bold = Nullable(); + if (currentResolvedStyle.style.italic == resolvedStyle.style.italic) run->style->italic = Nullable(); + if (currentResolvedStyle.style.underline == resolvedStyle.style.underline) run->style->underline = Nullable(); + if (currentResolvedStyle.style.strikeline == resolvedStyle.style.strikeline) run->style->strikeline = Nullable(); + if (currentResolvedStyle.style.antialias == resolvedStyle.style.antialias) run->style->antialias = Nullable(); + if (currentResolvedStyle.style.verticalAntialias == resolvedStyle.style.verticalAntialias) run->style->verticalAntialias = Nullable(); + + if (run->style->face) goto CONTINUE_PROCESSING; + if (run->style->size) goto CONTINUE_PROCESSING; + if (run->style->color) goto CONTINUE_PROCESSING; + if (run->style->backgroundColor) goto CONTINUE_PROCESSING; + if (run->style->bold) goto CONTINUE_PROCESSING; + if (run->style->italic) goto CONTINUE_PROCESSING; + if (run->style->underline) goto CONTINUE_PROCESSING; + if (run->style->strikeline) goto CONTINUE_PROCESSING; + if (run->style->antialias) goto CONTINUE_PROCESSING; + if (run->style->verticalAntialias) goto CONTINUE_PROCESSING; + CopyFrom(replacedRuns, run->runs); + return; + + CONTINUE_PROCESSING: + if (From(run->runs).Cast().First(nullptr) != nullptr) + { + FOREACH(Ptr, subRun, run->runs) + { + if (auto styleRun = subRun.Cast()) + { + DocumentModel::MergeStyle(styleRun->style, run->style); + replacedRuns.Add(styleRun); + } + else + { + auto parentRun = CopyRun(run).Cast(); + parentRun->runs.Add(subRun); + replacedRuns.Add(parentRun); + } + } + return; + } + + resolvedStyles.Add(resolvedStyle); + VisitContainer(run); + resolvedStyles.RemoveAt(resolvedStyles.Count() - 1); + } + + void Visit(DocumentStyleApplicationRun* run)override + { + if (OnlyImageOrObject(run)) + { + CopyFrom(replacedRuns, run->runs); + return; + } + + const DocumentModel::ResolvedStyle& currentResolvedStyle = GetCurrentResolvedStyle(); + DocumentModel::ResolvedStyle resolvedStyle = model->GetStyle(run->styleName, currentResolvedStyle); + resolvedStyles.Add(resolvedStyle); + VisitContainer(run); + resolvedStyles.RemoveAt(resolvedStyles.Count() - 1); + } + + void Visit(DocumentHyperlinkRun* run)override + { + const DocumentModel::ResolvedStyle& currentResolvedStyle = GetCurrentResolvedStyle(); + DocumentModel::ResolvedStyle resolvedStyle = model->GetStyle(run->styleName, currentResolvedStyle); + resolvedStyles.Add(resolvedStyle); + VisitContainer(run); + resolvedStyles.RemoveAt(resolvedStyles.Count() - 1); + } + + void Visit(DocumentImageRun* run)override + { + } + + void Visit(DocumentEmbeddedObjectRun* run)override + { + } + + void Visit(DocumentParagraphRun* run)override + { + VisitContainer(run); + } + }; + } + using namespace document_operation_visitors; + +/*********************************************************************** +Merge sibling runs if they are exactly the same +***********************************************************************/ + + namespace document_operation_visitors + { + class MergeSiblingRunVisitor : public Object, public DocumentRun::IVisitor + { + public: + Ptr nextRun; + Ptr replacedRun; + + void Visit(DocumentTextRun* run)override + { + if (auto sibilingRun = nextRun.Cast()) + { + run->text += sibilingRun->text; + replacedRun = run; + } + } + + void Visit(DocumentStylePropertiesRun* run)override + { + if (auto sibilingRun = nextRun.Cast()) + { + if (run->style->face != sibilingRun->style->face) return; + if (run->style->size != sibilingRun->style->size) return; + if (run->style->color != sibilingRun->style->color) return; + if (run->style->backgroundColor != sibilingRun->style->backgroundColor) return; + if (run->style->bold != sibilingRun->style->bold) return; + if (run->style->italic != sibilingRun->style->italic) return; + if (run->style->underline != sibilingRun->style->underline) return; + if (run->style->strikeline != sibilingRun->style->strikeline) return; + if (run->style->antialias != sibilingRun->style->antialias) return; + if (run->style->verticalAntialias != sibilingRun->style->verticalAntialias) return; + + CopyFrom(run->runs, sibilingRun->runs, true); + replacedRun = run; + } + } + + void Visit(DocumentStyleApplicationRun* run)override + { + if (auto sibilingRun = nextRun.Cast()) + { + if (run->styleName == sibilingRun->styleName) + { + CopyFrom(run->runs, sibilingRun->runs, true); + replacedRun = run; + } + } + } + + void Visit(DocumentHyperlinkRun* run)override + { + if (auto sibilingRun = nextRun.Cast()) + { + if (run->styleName == sibilingRun->styleName && + run->normalStyleName == sibilingRun->normalStyleName && + run->activeStyleName == sibilingRun->activeStyleName && + run->reference == sibilingRun->reference) + { + CopyFrom(run->runs, sibilingRun->runs, true); + replacedRun = run; + } + } + } + + void Visit(DocumentImageRun* run)override + { + } + + void Visit(DocumentEmbeddedObjectRun* run)override + { + } + + void Visit(DocumentParagraphRun* run)override + { + } + }; + + class MergeSiblingRunRecursivelyVisitor : public Object, public DocumentRun::IVisitor + { + public: + Ptr replacedRun; + Ptr nextRun; + + void VisitContainer(DocumentContainerRun* run) + { + for (vint i = 0; i < run->runs.Count() - 1; i++) + { + auto currentRun = run->runs[i]; + auto nextRun = run->runs[i + 1]; + + MergeSiblingRunVisitor visitor; + visitor.nextRun = nextRun; + currentRun->Accept(&visitor); + + if (visitor.replacedRun) + { + run->runs.RemoveAt(i + 1); + run->runs[i] = visitor.replacedRun; + i--; + } + } + + for (vint i = 0; i < run->runs.Count() - 1; i++) + { + run->runs[i]->Accept(this); + } + } + + void Visit(DocumentTextRun* run)override + { + } + + void Visit(DocumentStylePropertiesRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentStyleApplicationRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentHyperlinkRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentImageRun* run)override + { + } + + void Visit(DocumentEmbeddedObjectRun* run)override + { + } + + void Visit(DocumentParagraphRun* run)override + { + VisitContainer(run); + } + }; + } + using namespace document_operation_visitors; + + namespace document_editor + { + void ClearUnnecessaryRun(DocumentParagraphRun* run, DocumentModel* model) + { + { + ClearRunVisitor visitor; + run->Accept(&visitor); + } + { + CompressStyleRunVisitor visitor(model); + run->Accept(&visitor); + } + { + MergeSiblingRunRecursivelyVisitor visitor; + run->Accept(&visitor); + } + } + } + } +} + +/*********************************************************************** +.\RESOURCES\GUIDOCUMENTEDITOR_CLONERUN.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + using namespace collections; + using namespace document_editor; + +/*********************************************************************** +Clone the current run without its children +If clonedRun field is assigned then it will be added to the cloned container run +***********************************************************************/ + + namespace document_operation_visitors + { + class CloneRunVisitor : public Object, public DocumentRun::IVisitor + { + public: + Ptr clonedRun; + + CloneRunVisitor(Ptr subRun) + :clonedRun(subRun) + { + } + + void VisitContainer(Ptr cloned) + { + if (clonedRun) + { + cloned->runs.Add(clonedRun); + } + clonedRun = cloned; + } + + void Visit(DocumentTextRun* run)override + { + Ptr cloned = new DocumentTextRun; + cloned->text = run->text; + clonedRun = cloned; + } + + void Visit(DocumentStylePropertiesRun* run)override + { + Ptr cloned = new DocumentStylePropertiesRun; + cloned->style = CopyStyle(run->style); + VisitContainer(cloned); + } + + void Visit(DocumentStyleApplicationRun* run)override + { + Ptr cloned = new DocumentStyleApplicationRun; + cloned->styleName = run->styleName; + + VisitContainer(cloned); + } + + void Visit(DocumentHyperlinkRun* run)override + { + Ptr cloned = new DocumentHyperlinkRun; + cloned->styleName = run->styleName; + cloned->normalStyleName = run->normalStyleName; + cloned->activeStyleName = run->activeStyleName; + cloned->reference = run->reference; + + VisitContainer(cloned); + } + + void Visit(DocumentImageRun* run)override + { + Ptr cloned = new DocumentImageRun; + cloned->size = run->size; + cloned->baseline = run->baseline; + cloned->image = run->image; + cloned->frameIndex = run->frameIndex; + cloned->source = run->source; + clonedRun = cloned; + } + + void Visit(DocumentEmbeddedObjectRun* run)override + { + Ptr cloned = new DocumentEmbeddedObjectRun; + cloned->name = run->name; + clonedRun = cloned; + } + + void Visit(DocumentParagraphRun* run)override + { + Ptr cloned = new DocumentParagraphRun; + cloned->alignment = run->alignment; + + VisitContainer(cloned); + } + }; + } + using namespace document_operation_visitors; + +/*********************************************************************** +Clone the current run with its children +***********************************************************************/ + + namespace document_operation_visitors + { + class CloneRunRecursivelyVisitor : public Object, public DocumentRun::IVisitor + { + public: + Ptr clonedRun; + RunRangeMap& runRanges; + vint start; + vint end; + bool deepCopy; + + CloneRunRecursivelyVisitor(RunRangeMap& _runRanges, vint _start, vint _end, bool _deepCopy) + :runRanges(_runRanges) + , start(_start) + , end(_end) + , deepCopy(_deepCopy) + { + } + + void VisitContainer(DocumentContainerRun* run) + { + clonedRun = 0; + RunRange range = runRanges[run]; + if (range.start <= end && start <= range.end) + { + if (start <= range.start && range.end <= end && !deepCopy) + { + clonedRun = run; + } + else + { + Ptr containerRun = CopyRun(run).Cast(); + FOREACH(Ptr, subRun, run->runs) + { + subRun->Accept(this); + if (clonedRun) + { + containerRun->runs.Add(clonedRun); + } + } + clonedRun = containerRun; + } + } + } + + void Visit(DocumentTextRun* run)override + { + clonedRun = 0; + RunRange range = runRanges[run]; + if (range.start textRun = new DocumentTextRun; + vint copyStart = start>range.start ? start : range.start; + vint copyEnd = endtext = run->text.Sub(copyStart - range.start, copyEnd - copyStart); + } + clonedRun = textRun; + } + } + } + + void Visit(DocumentStylePropertiesRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentStyleApplicationRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentHyperlinkRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentImageRun* run)override + { + clonedRun = 0; + RunRange range = runRanges[run]; + if (range.start CopyStyle(Ptr style) + { + Ptr newStyle = new DocumentStyleProperties; + + newStyle->face = style->face; + newStyle->size = style->size; + newStyle->color = style->color; + newStyle->backgroundColor = style->backgroundColor; + newStyle->bold = style->bold; + newStyle->italic = style->italic; + newStyle->underline = style->underline; + newStyle->strikeline = style->strikeline; + newStyle->antialias = style->antialias; + newStyle->verticalAntialias = style->verticalAntialias; + + return newStyle; + } + + Ptr CopyRun(DocumentRun* run) + { + CloneRunVisitor visitor(0); + run->Accept(&visitor); + return visitor.clonedRun; + } + + Ptr CopyStyledText(List& styleRuns, const WString& text) + { + Ptr textRun = new DocumentTextRun; + textRun->text = text; + + CloneRunVisitor visitor(textRun); + for (vint i = styleRuns.Count() - 1; i >= 0; i--) + { + styleRuns[i]->Accept(&visitor); + } + + return visitor.clonedRun; + } + + Ptr CopyRunRecursively(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end, bool deepCopy) + { + CloneRunRecursivelyVisitor visitor(runRanges, start, end, deepCopy); + run->Accept(&visitor); + return visitor.clonedRun; + } + } + } +} + +/*********************************************************************** +.\RESOURCES\GUIDOCUMENTEDITOR_COLLECTSTYLE.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + using namespace collections; + +/*********************************************************************** +Search all used style names +***********************************************************************/ + + namespace document_operation_visitors + { + class CollectStyleNameVisitor : public Object, public DocumentRun::IVisitor + { + public: + List& styleNames; + + CollectStyleNameVisitor(List& _styleNames) + :styleNames(_styleNames) + { + } + + void VisitContainer(DocumentContainerRun* run) + { + FOREACH(Ptr, subRun, run->runs) + { + subRun->Accept(this); + } + } + + void Visit(DocumentTextRun* run)override + { + } + + void Visit(DocumentStylePropertiesRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentStyleApplicationRun* run)override + { + if (!styleNames.Contains(run->styleName)) + { + styleNames.Add(run->styleName); + } + VisitContainer(run); + } + + void Visit(DocumentHyperlinkRun* run)override + { + if (!styleNames.Contains(run->normalStyleName)) + { + styleNames.Add(run->normalStyleName); + } + if (!styleNames.Contains(run->activeStyleName)) + { + styleNames.Add(run->activeStyleName); + } + VisitContainer(run); + } + + void Visit(DocumentImageRun* run)override + { + } + + void Visit(DocumentEmbeddedObjectRun* run)override + { + } + + void Visit(DocumentParagraphRun* run)override + { + VisitContainer(run); + } + }; + } + using namespace document_operation_visitors; + + namespace document_editor + { + void CollectStyleName(DocumentParagraphRun* run, List& styleNames) + { + CollectStyleNameVisitor visitor(styleNames); + run->Accept(&visitor); + } + } + } +} + +/*********************************************************************** +.\RESOURCES\GUIDOCUMENTEDITOR_CUTRUN.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + using namespace collections; + using namespace document_editor; + +/*********************************************************************** +Cut all runs into pieces so that a run either completely outside or inside the specified range +If a run decides that itself should be cut, then leftRun and rightRun contains new run that will be inserted before and after it +***********************************************************************/ + + namespace document_operation_visitors + { + class CutRunVisitor : public Object, public DocumentRun::IVisitor + { + public: + RunRangeMap& runRanges; + vint position; + Ptr leftRun; + Ptr rightRun; + + CutRunVisitor(RunRangeMap& _runRanges, vint _position) + :runRanges(_runRanges) + , position(_position) + { + } + + void VisitContainer(DocumentContainerRun* run) + { + vint leftCount = 0; + Ptr selectedRun; + + FOREACH(Ptr, subRun, run->runs) + { + RunRange range = runRanges[subRun.Obj()]; + if (range.startAccept(this); + if (leftRun && rightRun) + { + run->runs.RemoveAt(leftCount - 1); + run->runs.Insert(leftCount - 1, leftRun); + run->runs.Insert(leftCount, rightRun); + } + } + + Ptr leftContainer = CopyRun(run).Cast(); + Ptr rightContainer = CopyRun(run).Cast(); + for (vint i = 0; iruns.Count(); i++) + { + (iruns.Add(run->runs[i]); + } + leftRun = leftContainer; + rightRun = rightContainer; + } + + void Visit(DocumentTextRun* run)override + { + RunRange range = runRanges[run]; + + Ptr leftText = new DocumentTextRun; + leftText->text = run->text.Sub(0, position - range.start); + + Ptr rightText = new DocumentTextRun; + rightText->text = run->text.Sub(position - range.start, range.end - position); + + leftRun = leftText; + rightRun = rightText; + } + + void Visit(DocumentStylePropertiesRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentStyleApplicationRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentHyperlinkRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentImageRun* run)override + { + leftRun = 0; + rightRun = 0; + } + + void Visit(DocumentEmbeddedObjectRun* run)override + { + leftRun = 0; + rightRun = 0; + } + + void Visit(DocumentParagraphRun* run)override + { + VisitContainer(run); + } + }; + } + using namespace document_operation_visitors; + + namespace document_editor + { + void CutRun(DocumentParagraphRun* run, RunRangeMap& runRanges, vint position, Ptr& leftRun, Ptr& rightRun) + { + CutRunVisitor visitor(runRanges, position); + run->Accept(&visitor); + leftRun = visitor.leftRun; + rightRun = visitor.rightRun; + } + } + } +} + +/*********************************************************************** +.\RESOURCES\GUIDOCUMENTEDITOR_GETRUNRANGE.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + using namespace collections; + +/*********************************************************************** +Calculate range informations for each run object +***********************************************************************/ + + namespace document_operation_visitors + { + class GetRunRangeVisitor : public Object, public DocumentRun::IVisitor + { + public: + RunRangeMap& runRanges; + vint start; + + GetRunRangeVisitor(RunRangeMap& _runRanges) + :runRanges(_runRanges) + , start(0) + { + } + + void VisitContainer(DocumentContainerRun* run) + { + RunRange range; + range.start = start; + FOREACH(Ptr, subRun, run->runs) + { + subRun->Accept(this); + } + range.end = start; + runRanges.Add(run, range); + } + + void VisitContent(DocumentContentRun* run) + { + RunRange range; + range.start = start; + start += run->GetRepresentationText().Length(); + range.end = start; + runRanges.Add(run, range); + } + + void Visit(DocumentTextRun* run)override + { + VisitContent(run); + } + + void Visit(DocumentStylePropertiesRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentStyleApplicationRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentHyperlinkRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentImageRun* run)override + { + VisitContent(run); + } + + void Visit(DocumentEmbeddedObjectRun* run)override + { + VisitContent(run); + } + + void Visit(DocumentParagraphRun* run)override + { + VisitContainer(run); + } + }; + } + using namespace document_operation_visitors; + + namespace document_editor + { + void GetRunRange(DocumentParagraphRun* run, RunRangeMap& runRanges) + { + GetRunRangeVisitor visitor(runRanges); + run->Accept(&visitor); + } + } + } +} + +/*********************************************************************** +.\RESOURCES\GUIDOCUMENTEDITOR_LOCALEHYPERLINK.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + using namespace collections; + +/*********************************************************************** +Get the hyperlink run that contains the specified position +***********************************************************************/ + + namespace document_operation_visitors + { + class LocateHyperlinkVisitor : public Object, public DocumentRun::IVisitor + { + public: + Ptr package; + RunRangeMap& runRanges; + vint start; + vint end; + + LocateHyperlinkVisitor(RunRangeMap& _runRanges, Ptr _package, vint _start, vint _end) + :runRanges(_runRanges) + , package(_package) + , start(_start) + , end(_end) + { + } + + void VisitContainer(DocumentContainerRun* run) + { + Ptr selectedRun; + FOREACH(Ptr, subRun, run->runs) + { + RunRange range = runRanges[subRun.Obj()]; + if (range.start <= start && end <= range.end) + { + subRun->Accept(this); + break; + } + } + } + + void Visit(DocumentTextRun* run)override + { + } + + void Visit(DocumentStylePropertiesRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentStyleApplicationRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentHyperlinkRun* run)override + { + package->hyperlinks.Add(run); + } + + void Visit(DocumentImageRun* run)override + { + } + + void Visit(DocumentEmbeddedObjectRun* run)override + { + } + + void Visit(DocumentParagraphRun* run)override + { + VisitContainer(run); + } + }; + } + using namespace document_operation_visitors; + + namespace document_editor + { + Ptr LocateHyperlink(DocumentParagraphRun* run, RunRangeMap& runRanges, vint row, vint start, vint end) + { + auto package = MakePtr(); + package->row = row; + { + LocateHyperlinkVisitor visitor(runRanges, package, start, end); + run->Accept(&visitor); + } + + Ptr startRun, endRun; + FOREACH(Ptr, run, package->hyperlinks) + { + auto range = runRanges[run.Obj()]; + if (package->start == -1 || range.start < package->start) + { + package->start = range.start; + startRun = run; + } + if (package->end == -1 || range.end > package->end) + { + package->end = range.end; + endRun = run; + } + } + + while (startRun) + { + vint pos = runRanges[startRun.Obj()].start; + if (pos == 0) break; + + auto newPackage = MakePtr(); + LocateHyperlinkVisitor visitor(runRanges, newPackage, pos - 1, pos); + run->Accept(&visitor); + if (newPackage->hyperlinks.Count() == 0) break; + + auto newRun = newPackage->hyperlinks[0]; + if (startRun->reference != newRun->reference) break; + + auto range = runRanges[newRun.Obj()]; + package->hyperlinks.Add(newRun); + package->start = range.start; + startRun = newRun; + } + + vint length = runRanges[run].end; + while (endRun) + { + vint pos = runRanges[endRun.Obj()].end; + if (pos == length) break; + + auto newPackage = MakePtr(); + LocateHyperlinkVisitor visitor(runRanges, newPackage, pos, pos + 1); + run->Accept(&visitor); + if (newPackage->hyperlinks.Count() == 0) break; + + auto newRun = newPackage->hyperlinks[0]; + if (endRun->reference != newRun->reference) break; + + auto range = runRanges[newRun.Obj()]; + package->hyperlinks.Add(newRun); + package->end = range.end; + endRun = newRun; + } + + return package; + } + } + } +} + +/*********************************************************************** +.\RESOURCES\GUIDOCUMENTEDITOR_LOCALESTYLE.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + using namespace collections; + +/*********************************************************************** +Get all container runs that contain the specified position from top to bottom +***********************************************************************/ + + namespace document_operation_visitors + { + class LocateStyleVisitor : public Object, public DocumentRun::IVisitor + { + public: + List& locatedRuns; + RunRangeMap& runRanges; + vint position; + bool frontSide; + + LocateStyleVisitor(List& _locatedRuns, RunRangeMap& _runRanges, vint _position, bool _frontSide) + :locatedRuns(_locatedRuns) + , runRanges(_runRanges) + , position(_position) + , frontSide(_frontSide) + { + } + + void VisitContainer(DocumentContainerRun* run) + { + locatedRuns.Add(run); + Ptr selectedRun; + FOREACH(Ptr, subRun, run->runs) + { + RunRange range = runRanges[subRun.Obj()]; + if (position == range.start) + { + if (!frontSide) + { + selectedRun = subRun; + break; + } + } + else if (position == range.end) + { + if (frontSide) + { + selectedRun = subRun; + break; + } + } + else if (range.startAccept(this); + } + } + + void Visit(DocumentTextRun* run)override + { + } + + void Visit(DocumentStylePropertiesRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentStyleApplicationRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentHyperlinkRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentImageRun* run)override + { + } + + void Visit(DocumentEmbeddedObjectRun* run)override + { + } + + void Visit(DocumentParagraphRun* run)override + { + VisitContainer(run); + } + }; + } + using namespace document_operation_visitors; + + namespace document_editor + { + void LocateStyle(DocumentParagraphRun* run, RunRangeMap& runRanges, vint position, bool frontSide, List& locatedRuns) + { + LocateStyleVisitor visitor(locatedRuns, runRanges, position, frontSide); + run->Accept(&visitor); + } + } + } +} + +/*********************************************************************** +.\RESOURCES\GUIDOCUMENTEDITOR_REMOVECONTAINER.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + using namespace collections; + +/*********************************************************************** +Remove some containers that intersect with the specified range +If a run decides that itself should be removed, then replacedRuns contains all runs to replace itself +RemoveHyperlinkVisitor : Remove all hyperlinks that intersect with the specified range +RemoveStyleNameVisitor : Remove all style names that intersect with the specified range +ClearStyleVisitor : Remove all styles that intersect with the specified range +***********************************************************************/ + + namespace document_operation_visitors + { + class RemoveContainerVisitor : public Object, public DocumentRun::IVisitor + { + public: + RunRangeMap& runRanges; + vint start; + vint end; + List> replacedRuns; + + RemoveContainerVisitor(RunRangeMap& _runRanges, vint _start, vint _end) + :runRanges(_runRanges) + , start(_start) + , end(_end) + { + } + + void VisitContainer(DocumentContainerRun* run) + { + for (vint i = run->runs.Count() - 1; i >= 0; i--) + { + Ptr subRun = run->runs[i]; + RunRange range = runRanges[subRun.Obj()]; + if (range.startAccept(this); + if (replacedRuns.Count() != 1 || replacedRuns[0] != subRun) + { + run->runs.RemoveAt(i); + for (vint j = 0; jruns.Insert(i + j, replacedRuns[j]); + } + i += replacedRuns.Count(); + } + } + } + replacedRuns.Clear(); + replacedRuns.Add(run); + } + + void VisitContent(DocumentContentRun* run) + { + replacedRuns.Add(run); + } + + void RemoveContainer(DocumentContainerRun* run) + { + CopyFrom(replacedRuns, run->runs); + } + + void Visit(DocumentTextRun* run)override + { + VisitContent(run); + } + + void Visit(DocumentStylePropertiesRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentStyleApplicationRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentHyperlinkRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentImageRun* run)override + { + VisitContent(run); + } + + void Visit(DocumentEmbeddedObjectRun* run)override + { + VisitContent(run); + } + + void Visit(DocumentParagraphRun* run)override + { + VisitContainer(run); + } + }; + + class RemoveHyperlinkVisitor : public RemoveContainerVisitor + { + public: + RemoveHyperlinkVisitor(RunRangeMap& _runRanges, vint _start, vint _end) + :RemoveContainerVisitor(_runRanges, _start, _end) + { + } + + void Visit(DocumentHyperlinkRun* run)override + { + RemoveContainer(run); + } + }; + + class RemoveStyleNameVisitor : public RemoveContainerVisitor + { + public: + RemoveStyleNameVisitor(RunRangeMap& _runRanges, vint _start, vint _end) + :RemoveContainerVisitor(_runRanges, _start, _end) + { + } + + void Visit(DocumentStyleApplicationRun* run)override + { + RemoveContainer(run); + } + }; + + class ClearStyleVisitor : public RemoveContainerVisitor + { + public: + ClearStyleVisitor(RunRangeMap& _runRanges, vint _start, vint _end) + :RemoveContainerVisitor(_runRanges, _start, _end) + { + } + + void Visit(DocumentStylePropertiesRun* run)override + { + RemoveContainer(run); + } + + void Visit(DocumentStyleApplicationRun* run)override + { + RemoveContainer(run); + } + }; + } + using namespace document_operation_visitors; + + namespace document_editor + { + void RemoveHyperlink(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end) + { + RemoveHyperlinkVisitor visitor(runRanges, start, end); + run->Accept(&visitor); + } + + void RemoveStyleName(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end) + { + RemoveStyleNameVisitor visitor(runRanges, start, end); + run->Accept(&visitor); + } + + void ClearStyle(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end) + { + ClearStyleVisitor visitor(runRanges, start, end); + run->Accept(&visitor); + } + } + } +} + +/*********************************************************************** +.\RESOURCES\GUIDOCUMENTEDITOR_REMOVERUN.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + using namespace collections; + +/*********************************************************************** +Remove text run contents with the specified range, or other content runs that intersect with the range +If a run decides that itself should be removed, then replacedRuns contains all runs to replace itself +***********************************************************************/ + + namespace document_operation_visitors + { + class RemoveRunVisitor : public Object, public DocumentRun::IVisitor + { + public: + RunRangeMap& runRanges; + vint start; + vint end; + List> replacedRuns; + + RemoveRunVisitor(RunRangeMap& _runRanges, vint _start, vint _end) + :runRanges(_runRanges) + , start(_start) + , end(_end) + { + } + + void VisitContainer(DocumentContainerRun* run) + { + if (start == end) return; + for (vint i = run->runs.Count() - 1; i >= 0; i--) + { + Ptr subRun = run->runs[i]; + RunRange range = runRanges[subRun.Obj()]; + + if (range.start <= end && start <= range.end) + { + subRun->Accept(this); + if (replacedRuns.Count() == 0 || subRun != replacedRuns[0]) + { + run->runs.RemoveAt(i); + for (vint j = 0; jruns.Insert(i + j, replacedRuns[j]); + } + } + } + } + replacedRuns.Clear(); + replacedRuns.Add(run); + } + + void Visit(DocumentTextRun* run)override + { + replacedRuns.Clear(); + RunRange range = runRanges[run]; + + if (start <= range.start) + { + if (endtext = run->text.Sub(end - range.start, range.end - end); + replacedRuns.Add(run); + } + } + else + { + if (endtext = run->text.Sub(0, start - range.start); + secondRun->text = run->text.Sub(end - range.start, range.end - end); + + replacedRuns.Add(firstRun); + replacedRuns.Add(secondRun); + } + else + { + run->text = run->text.Sub(0, start - range.start); + replacedRuns.Add(run); + } + } + } + + void Visit(DocumentStylePropertiesRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentStyleApplicationRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentHyperlinkRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentImageRun* run)override + { + replacedRuns.Clear(); + } + + void Visit(DocumentEmbeddedObjectRun* run)override + { + replacedRuns.Clear(); + } + + void Visit(DocumentParagraphRun* run)override + { + VisitContainer(run); + } + }; + } + using namespace document_operation_visitors; + + namespace document_editor + { + void RemoveRun(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end) + { + RemoveRunVisitor visitor(runRanges, start, end); + run->Accept(&visitor); + } + } + } +} + +/*********************************************************************** +.\RESOURCES\GUIDOCUMENTEDITOR_REPLACESTYLENAME.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + using namespace collections; + +/*********************************************************************** +Replace a style name with another one +***********************************************************************/ + + namespace document_operation_visitors + { + class ReplaceStyleNameVisitor : public Object, public DocumentRun::IVisitor + { + public: + WString oldStyleName; + WString newStyleName; + + ReplaceStyleNameVisitor(const WString& _oldStyleName, const WString& _newStyleName) + :oldStyleName(_oldStyleName) + , newStyleName(_newStyleName) + { + } + + void VisitContainer(DocumentContainerRun* run) + { + FOREACH(Ptr, subRun, run->runs) + { + subRun->Accept(this); + } + } + + void Visit(DocumentTextRun* run)override + { + } + + void Visit(DocumentStylePropertiesRun* run)override + { + VisitContainer(run); + } + + void Visit(DocumentStyleApplicationRun* run)override + { + if (run->styleName == oldStyleName) run->styleName = newStyleName; + VisitContainer(run); + } + + void Visit(DocumentHyperlinkRun* run)override + { + if (run->styleName == oldStyleName) run->styleName = newStyleName; + if (run->normalStyleName == oldStyleName) run->normalStyleName = newStyleName; + if (run->activeStyleName == oldStyleName) run->activeStyleName = newStyleName; + VisitContainer(run); + } + + void Visit(DocumentImageRun* run)override + { + } + + void Visit(DocumentEmbeddedObjectRun* run)override + { + } + + void Visit(DocumentParagraphRun* run)override + { + VisitContainer(run); + } + }; + } + using namespace document_operation_visitors; + + namespace document_editor + { + void ReplaceStyleName(DocumentParagraphRun* run, const WString& oldStyleName, const WString& newStyleName) + { + ReplaceStyleNameVisitor visitor(oldStyleName, newStyleName); + run->Accept(&visitor); + } + } + } +} + +/*********************************************************************** +.\RESOURCES\GUIDOCUMENTEDITOR_SUMMERIZESTYLE.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + using namespace collections; + +/*********************************************************************** +Calculate if all text in the specified range has some common styles +***********************************************************************/ + + namespace document_operation_visitors + { + class SummerizeStyleVisitor : public Object, public DocumentRun::IVisitor + { + public: + RunRangeMap& runRanges; + DocumentModel* model; + vint start; + vint end; + Ptr style; + List resolvedStyles; + + SummerizeStyleVisitor(RunRangeMap& _runRanges, DocumentModel* _model, vint _start, vint _end) + :runRanges(_runRanges) + , model(_model) + , start(_start) + , end(_end) + { + DocumentModel::ResolvedStyle resolvedStyle; + resolvedStyle = model->GetStyle(DocumentModel::DefaultStyleName, resolvedStyle); + resolvedStyles.Add(resolvedStyle); + } + + const DocumentModel::ResolvedStyle& GetCurrentResolvedStyle() + { + return resolvedStyles[resolvedStyles.Count() - 1]; + } + + // --------------------------------------------------------- + + template + void SetStyleItem(Nullable DocumentStyleProperties::* dstField, T FontProperties::* srcField) + { + const DocumentModel::ResolvedStyle& src = GetCurrentResolvedStyle(); + if (style.Obj()->*dstField && (style.Obj()->*dstField).Value() != src.style.*srcField) + { + style.Obj()->*dstField = Nullable(); + } + } + + template + void SetStyleItem(Nullable DocumentStyleProperties::* dstField, T DocumentModel::ResolvedStyle::* srcField) + { + const DocumentModel::ResolvedStyle& src = GetCurrentResolvedStyle(); + if (style.Obj()->*dstField && (style.Obj()->*dstField).Value() != src.*srcField) + { + style.Obj()->*dstField = Nullable(); + } + } + + void SetStyleItem(Nullable DocumentStyleProperties::* dstField, vint FontProperties::* srcField) + { + const DocumentModel::ResolvedStyle& src = GetCurrentResolvedStyle(); + if (style.Obj()->*dstField) + { + auto dfs = (style.Obj()->*dstField).Value(); + if (dfs.relative || dfs.size != src.style.*srcField) + { + style.Obj()->*dstField = Nullable(); + } + } + } + + // --------------------------------------------------------- + + template + void OverrideStyleItem(Nullable DocumentStyleProperties::* dstField, T FontProperties::* srcField) + { + const DocumentModel::ResolvedStyle& src = GetCurrentResolvedStyle(); + style.Obj()->*dstField = src.style.*srcField; + } + + template + void OverrideStyleItem(Nullable DocumentStyleProperties::* dstField, T DocumentModel::ResolvedStyle::* srcField) + { + const DocumentModel::ResolvedStyle& src = GetCurrentResolvedStyle(); + style.Obj()->*dstField = src.*srcField; + } + + void OverrideStyleItem(Nullable DocumentStyleProperties::* dstField, vint FontProperties::* srcField) + { + const DocumentModel::ResolvedStyle& src = GetCurrentResolvedStyle(); + style.Obj()->*dstField = DocumentFontSize((double)(src.style.*srcField), false); + } + + // --------------------------------------------------------- + + void VisitContainer(DocumentContainerRun* run) + { + for (vint i = run->runs.Count() - 1; i >= 0; i--) + { + Ptr subRun = run->runs[i]; + RunRange range = runRanges[subRun.Obj()]; + if (range.startAccept(this); + } + } + } + + void Visit(DocumentTextRun* run)override + { + const DocumentModel::ResolvedStyle& currentResolvedStyle = GetCurrentResolvedStyle(); + if (style) + { + SetStyleItem(&DocumentStyleProperties::face, &FontProperties::fontFamily); + SetStyleItem(&DocumentStyleProperties::size, &FontProperties::size); + SetStyleItem(&DocumentStyleProperties::color, &DocumentModel::ResolvedStyle::color); + SetStyleItem(&DocumentStyleProperties::backgroundColor, &DocumentModel::ResolvedStyle::backgroundColor); + SetStyleItem(&DocumentStyleProperties::bold, &FontProperties::bold); + SetStyleItem(&DocumentStyleProperties::italic, &FontProperties::italic); + SetStyleItem(&DocumentStyleProperties::underline, &FontProperties::underline); + SetStyleItem(&DocumentStyleProperties::strikeline, &FontProperties::strikeline); + SetStyleItem(&DocumentStyleProperties::antialias, &FontProperties::antialias); + SetStyleItem(&DocumentStyleProperties::verticalAntialias, &FontProperties::verticalAntialias); + } + else + { + style = new DocumentStyleProperties; + OverrideStyleItem(&DocumentStyleProperties::face, &FontProperties::fontFamily); + OverrideStyleItem(&DocumentStyleProperties::size, &FontProperties::size); + OverrideStyleItem(&DocumentStyleProperties::color, &DocumentModel::ResolvedStyle::color); + OverrideStyleItem(&DocumentStyleProperties::backgroundColor, &DocumentModel::ResolvedStyle::backgroundColor); + OverrideStyleItem(&DocumentStyleProperties::bold, &FontProperties::bold); + OverrideStyleItem(&DocumentStyleProperties::italic, &FontProperties::italic); + OverrideStyleItem(&DocumentStyleProperties::underline, &FontProperties::underline); + OverrideStyleItem(&DocumentStyleProperties::strikeline, &FontProperties::strikeline); + OverrideStyleItem(&DocumentStyleProperties::antialias, &FontProperties::antialias); + OverrideStyleItem(&DocumentStyleProperties::verticalAntialias, &FontProperties::verticalAntialias); + } + } + + void Visit(DocumentStylePropertiesRun* run)override + { + const DocumentModel::ResolvedStyle& currentResolvedStyle = GetCurrentResolvedStyle(); + DocumentModel::ResolvedStyle resolvedStyle = model->GetStyle(run->style, currentResolvedStyle); + resolvedStyles.Add(resolvedStyle); + VisitContainer(run); + resolvedStyles.RemoveAt(resolvedStyles.Count() - 1); + } + + void Visit(DocumentStyleApplicationRun* run)override + { + const DocumentModel::ResolvedStyle& currentResolvedStyle = GetCurrentResolvedStyle(); + DocumentModel::ResolvedStyle resolvedStyle = model->GetStyle(run->styleName, currentResolvedStyle); + resolvedStyles.Add(resolvedStyle); + VisitContainer(run); + resolvedStyles.RemoveAt(resolvedStyles.Count() - 1); + } + + void Visit(DocumentHyperlinkRun* run)override + { + const DocumentModel::ResolvedStyle& currentResolvedStyle = GetCurrentResolvedStyle(); + DocumentModel::ResolvedStyle resolvedStyle = model->GetStyle(run->styleName, currentResolvedStyle); + resolvedStyles.Add(resolvedStyle); + VisitContainer(run); + resolvedStyles.RemoveAt(resolvedStyles.Count() - 1); + } + + void Visit(DocumentImageRun* run)override + { + } + + void Visit(DocumentEmbeddedObjectRun* run)override + { + } + + void Visit(DocumentParagraphRun* run)override + { + VisitContainer(run); + } + }; + } + using namespace document_operation_visitors; + + namespace document_editor + { + Ptr SummerizeStyle(DocumentParagraphRun* run, RunRangeMap& runRanges, DocumentModel* model, vint start, vint end) + { + SummerizeStyleVisitor visitor(runRanges, model, start, end); + run->Accept(&visitor); + return visitor.style; + } + + template + void AggregateStyleItem(Ptr& dst, Ptr src, Nullable DocumentStyleProperties::* field) + { + if (dst.Obj()->*field && (!(src.Obj()->*field) || (dst.Obj()->*field).Value() != (src.Obj()->*field).Value())) + { + dst.Obj()->*field = Nullable(); + } + } + + void AggregateStyle(Ptr& dst, Ptr src) + { + AggregateStyleItem(dst, src, &DocumentStyleProperties::face); + AggregateStyleItem(dst, src, &DocumentStyleProperties::size); + AggregateStyleItem(dst, src, &DocumentStyleProperties::color); + AggregateStyleItem(dst, src, &DocumentStyleProperties::backgroundColor); + AggregateStyleItem(dst, src, &DocumentStyleProperties::bold); + AggregateStyleItem(dst, src, &DocumentStyleProperties::italic); + AggregateStyleItem(dst, src, &DocumentStyleProperties::underline); + AggregateStyleItem(dst, src, &DocumentStyleProperties::strikeline); + AggregateStyleItem(dst, src, &DocumentStyleProperties::antialias); + AggregateStyleItem(dst, src, &DocumentStyleProperties::verticalAntialias); + } + } + } +} + +/*********************************************************************** +.\RESOURCES\GUIDOCUMENT_EDIT.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + using namespace collections; + using namespace document_editor; + +/*********************************************************************** +DocumentModel::EditRangeOperations +***********************************************************************/ + + bool DocumentModel::CheckEditRange(TextPos begin, TextPos end, RunRangeMap& relatedRanges) + { + // check caret range + if(begin>end) return false; + if(begin.row<0 || begin.row>=paragraphs.Count()) return false; + if(end.row<0 || end.row>=paragraphs.Count()) return false; + + // determine run ranges + GetRunRange(paragraphs[begin.row].Obj(), relatedRanges); + if(begin.row!=end.row) + { + GetRunRange(paragraphs[end.row].Obj(), relatedRanges); + } + + // check caret range + RunRange beginRange=relatedRanges[paragraphs[begin.row].Obj()]; + RunRange endRange=relatedRanges[paragraphs[end.row].Obj()]; + if(begin.column<0 || begin.column>beginRange.end) return false; + if(end.column<0 || end.column>endRange.end) return false; + + return true; + } + + Ptr DocumentModel::CopyDocument(TextPos begin, TextPos end, bool deepCopy) + { + // check caret range + RunRangeMap runRanges; + if(!CheckEditRange(begin, end, runRanges)) return nullptr; + + // get ranges + for(vint i=begin.row+1;i newDocument=new DocumentModel; + + // copy paragraphs + if(begin.row==end.row) + { + newDocument->paragraphs.Add(CopyRunRecursively(paragraphs[begin.row].Obj(), runRanges, begin.column, end.column, deepCopy).Cast()); + } + else + { + for(vint i=begin.row;i<=end.row;i++) + { + Ptr paragraph=paragraphs[i]; + RunRange range=runRanges[paragraph.Obj()]; + if(i==begin.row) + { + newDocument->paragraphs.Add(CopyRunRecursively(paragraph.Obj(), runRanges, begin.column, range.end, deepCopy).Cast()); + } + else if(i==end.row) + { + newDocument->paragraphs.Add(CopyRunRecursively(paragraph.Obj(), runRanges, range.start, end.column, deepCopy).Cast()); + } + else if(deepCopy) + { + newDocument->paragraphs.Add(CopyRunRecursively(paragraph.Obj(), runRanges, range.start, range.end, deepCopy).Cast()); + } + else + { + newDocument->paragraphs.Add(paragraph); + } + } + } + + // copy styles + List styleNames; + FOREACH(Ptr, paragraph, newDocument->paragraphs) + { + CollectStyleName(paragraph.Obj(), styleNames); + } + + for(vint i=0;istyles.Keys().Contains(styleName)) + { + Ptr style=styles[styleName]; + if(deepCopy) + { + Ptr newStyle=new DocumentStyle; + newStyle->parentStyleName=style->parentStyleName; + newStyle->styles=CopyStyle(style->styles); + newStyle->resolvedStyles=CopyStyle(style->resolvedStyles); + newDocument->styles.Add(styleName, newStyle); + } + else + { + newDocument->styles.Add(styleName, style); + } + + if(!styleNames.Contains(style->parentStyleName)) + { + styleNames.Add(style->parentStyleName); + } + } + } + + return newDocument; + } + + Ptr DocumentModel::CopyDocument() + { + // determine run ranges + RunRangeMap runRanges; + vint lastParagraphIndex = paragraphs.Count() - 1; + GetRunRange(paragraphs[lastParagraphIndex].Obj(), runRanges); + + TextPos begin(0, 0); + TextPos end(lastParagraphIndex, runRanges[paragraphs[lastParagraphIndex].Obj()].end); + return CopyDocument(begin, end, true); + } + + bool DocumentModel::CutParagraph(TextPos position) + { + if(position.row<0 || position.row>=paragraphs.Count()) return false; + + Ptr paragraph=paragraphs[position.row]; + RunRangeMap runRanges; + Ptr leftRun, rightRun; + + GetRunRange(paragraph.Obj(), runRanges); + CutRun(paragraph.Obj(), runRanges, position.column, leftRun, rightRun); + + CopyFrom(paragraph->runs, leftRun.Cast()->runs); + CopyFrom(paragraph->runs, rightRun.Cast()->runs, true); + + return true; + } + + bool DocumentModel::CutEditRange(TextPos begin, TextPos end) + { + // check caret range + if(begin>end) return false; + if(begin.row<0 || begin.row>=paragraphs.Count()) return false; + if(end.row<0 || end.row>=paragraphs.Count()) return false; + + // cut paragraphs + CutParagraph(begin); + if(begin!=end) + { + CutParagraph(end); + } + return true; + } + + bool DocumentModel::EditContainer(TextPos begin, TextPos end, const Func& editor) + { + if(begin==end) return false; + + // cut paragraphs + if(!CutEditRange(begin, end)) return false; + + // check caret range + RunRangeMap runRanges; + if(!CheckEditRange(begin, end, runRanges)) return false; + + // edit container + if(begin.row==end.row) + { + editor(paragraphs[begin.row].Obj(), runRanges, begin.column, end.column); + } + else + { + for(vint i=begin.row;i<=end.row;i++) + { + Ptr paragraph=paragraphs[i]; + if(begin.row replaceToModel, bool copy) + { + // check caret range + RunRangeMap runRanges; + if(!CheckEditRange(begin, end, runRanges)) return -1; + + auto model = replaceToModel; + if (copy) + { + model = replaceToModel->CopyDocument(); + } + + // calculate new names for the model's styles to prevent conflicting + List oldNames, newNames; + CopyFrom(oldNames, model->styles.Keys()); + CopyFrom(newNames, model->styles.Keys()); + for(vint i=0;istyles.Keys().Contains(newName)) + { + newNames[i]=newName; + break; + } + } + } + } + + // rename model's styles + typedef Pair NamePair; + FOREACH(NamePair, name, From(oldNames).Pairwise(newNames)) + { + model->RenameStyle(name.key, name.value); + } + FOREACH(WString, name, newNames) + { + if((name.Length()==0 || name[0]!=L'#') && !styles.Keys().Contains(name)) + { + styles.Add(name, model->styles[name]); + } + } + + // edit runs + Array> runs; + CopyFrom(runs, model->paragraphs); + return EditRunNoCopy(begin, end, runs); + } + + vint DocumentModel::EditRunNoCopy(TextPos begin, TextPos end, const collections::Array>& runs) + { + // check caret range + RunRangeMap runRanges; + if(!CheckEditRange(begin, end, runRanges)) return -1; + + // remove unnecessary paragraphs + if(begin.row!=end.row) + { + for(vint i=end.row-1;i>begin.row;i--) + { + paragraphs.RemoveAt(i); + } + end.row=begin.row+1; + } + + // remove unnecessary runs and ensure begin.row!=end.row + if(begin.row==end.row) + { + RemoveRun(paragraphs[begin.row].Obj(), runRanges, begin.column, end.column); + + Ptr leftRun, rightRun; + runRanges.Clear(); + GetRunRange(paragraphs[begin.row].Obj(), runRanges); + CutRun(paragraphs[begin.row].Obj(), runRanges, begin.column, leftRun, rightRun); + + paragraphs.RemoveAt(begin.row); + paragraphs.Insert(begin.row, leftRun.Cast()); + paragraphs.Insert(begin.row+1, rightRun.Cast()); + end.row=begin.row+1; + } + else + { + RemoveRun(paragraphs[begin.row].Obj(), runRanges, begin.column, runRanges[paragraphs[begin.row].Obj()].end); + RemoveRun(paragraphs[end.row].Obj(), runRanges, 0, end.column); + } + + // insert new paragraphs + Ptr beginParagraph=paragraphs[begin.row]; + Ptr endParagraph=paragraphs[end.row]; + if(runs.Count()==0) + { + CopyFrom(beginParagraph->runs, endParagraph->runs, true); + paragraphs.RemoveAt(end.row); + } + else if(runs.Count()==1) + { + CopyFrom(beginParagraph->runs, runs[0]->runs, true); + CopyFrom(beginParagraph->runs, endParagraph->runs, true); + paragraphs.RemoveAt(end.row); + } + else + { + Ptr newBeginRuns=runs[0]; + CopyFrom(beginParagraph->runs, newBeginRuns->runs, true); + + Ptr newEndRuns=runs[runs.Count()-1]; + if (newEndRuns->alignment) + { + endParagraph->alignment = newEndRuns->alignment; + } + for(vint i=0;iruns.Count();i++) + { + endParagraph->runs.Insert(i, newEndRuns->runs[i]); + } + + for(vint i=1;i& text) + { + // check caret range + RunRangeMap runRanges; + if(!CheckEditRange(begin, end, runRanges)) return -1; + + // calcuate the position to get the text style + TextPos stylePosition; + if(frontSide) + { + stylePosition=begin; + if(stylePosition.column==0) + { + frontSide=false; + } + } + else + { + stylePosition=end; + if(stylePosition.column==runRanges[paragraphs[end.row].Obj()].end) + { + frontSide=true; + } + } + + // copy runs that contains the target style for new text + List styleRuns; + LocateStyle(paragraphs[stylePosition.row].Obj(), runRanges, stylePosition.column, frontSide, styleRuns); + + // create paragraphs + Array> runs(text.Count()); + for(vint i=0;i paragraph=CopyStyledText(styleRuns, text[i]); + runs[i]=paragraph.Cast(); + } + + // replace the paragraphs + return EditRunNoCopy(begin, end, runs); + } + +/*********************************************************************** +DocumentModel::EditStyle +***********************************************************************/ + + bool DocumentModel::EditStyle(TextPos begin, TextPos end, Ptr style) + { + return EditContainer(begin, end, [=](DocumentParagraphRun* paragraph, RunRangeMap& runRanges, vint start, vint end) + { + AddStyle(paragraph, runRanges, start, end, style); + }); + } + +/*********************************************************************** +DocumentModel::EditImage +***********************************************************************/ + + Ptr DocumentModel::EditImage(TextPos begin, TextPos end, Ptr image) + { + Ptr imageRun=new DocumentImageRun; + imageRun->size=image->GetImage()->GetFrame(image->GetFrameIndex())->GetSize(); + imageRun->baseline=imageRun->size.y; + imageRun->image=image->GetImage(); + imageRun->frameIndex=image->GetFrameIndex(); + + Ptr paragraph=new DocumentParagraphRun; + paragraph->runs.Add(imageRun); + + Array> runs(1); + runs[0]=paragraph; + if(EditRunNoCopy(begin, end, runs)) + { + return imageRun; + } + else + { + return 0; + } + } + +/*********************************************************************** +DocumentModel::EditHyperlink +***********************************************************************/ + + bool DocumentModel::EditHyperlink(vint paragraphIndex, vint begin, vint end, const WString& reference, const WString& normalStyleName, const WString& activeStyleName) + { + auto package = GetHyperlink(paragraphIndex, begin, end); + if (package->hyperlinks.Count() > 0) + { + FOREACH(Ptr, run, package->hyperlinks) + { + run->reference = reference; + run->normalStyleName = normalStyleName; + run->activeStyleName = activeStyleName; + run->styleName = normalStyleName; + } + return true; + } + else if (RemoveHyperlink(paragraphIndex, begin, end)) + { + CutEditRange(TextPos(paragraphIndex, begin), TextPos(paragraphIndex, end)); + + RunRangeMap runRanges; + Ptr paragraph = paragraphs[paragraphIndex]; + GetRunRange(paragraph.Obj(), runRanges); + AddHyperlink(paragraph.Obj(), runRanges, begin, end, reference, normalStyleName, activeStyleName); + + ClearUnnecessaryRun(paragraph.Obj(), this); + return true; + } + return false; + } + + bool DocumentModel::RemoveHyperlink(vint paragraphIndex, vint begin, vint end) + { + RunRangeMap runRanges; + if (!CheckEditRange(TextPos(paragraphIndex, begin), TextPos(paragraphIndex, end), runRanges)) return 0; + + auto paragraph = paragraphs[paragraphIndex]; + auto package = LocateHyperlink(paragraph.Obj(), runRanges, paragraphIndex, begin, end); + document_editor::RemoveHyperlink(paragraph.Obj(), runRanges, package->start, package->end); + ClearUnnecessaryRun(paragraph.Obj(), this); + return true; + } + + Ptr DocumentModel::GetHyperlink(vint paragraphIndex, vint begin, vint end) + { + RunRangeMap runRanges; + if (!CheckEditRange(TextPos(paragraphIndex, begin), TextPos(paragraphIndex, end), runRanges)) return 0; + + auto paragraph = paragraphs[paragraphIndex]; + return LocateHyperlink(paragraph.Obj(), runRanges, paragraphIndex, begin, end); + } + +/*********************************************************************** +DocumentModel::EditStyleName +***********************************************************************/ + + bool DocumentModel::EditStyleName(TextPos begin, TextPos end, const WString& styleName) + { + return EditContainer(begin, end, [=](DocumentParagraphRun* paragraph, RunRangeMap& runRanges, vint start, vint end) + { + AddStyleName(paragraph, runRanges, start, end, styleName); + }); + } + + bool DocumentModel::RemoveStyleName(TextPos begin, TextPos end) + { + return EditContainer(begin, end, [=](DocumentParagraphRun* paragraph, RunRangeMap& runRanges, vint start, vint end) + { + document_editor::RemoveStyleName(paragraph, runRanges, start, end); + }); + } + + bool DocumentModel::RenameStyle(const WString& oldStyleName, const WString& newStyleName) + { + vint index=styles.Keys().IndexOf(oldStyleName); + if(index==-1) return false; + if(styles.Keys().Contains(newStyleName)) return false; + + Ptr style=styles.Values()[index]; + styles.Remove(oldStyleName); + styles.Add(newStyleName, style); + + FOREACH(Ptr, subStyle, styles.Values()) + { + if(subStyle->parentStyleName==oldStyleName) + { + subStyle->parentStyleName=newStyleName; + } + } + + FOREACH(Ptr, paragraph, paragraphs) + { + ReplaceStyleName(paragraph.Obj(), oldStyleName, newStyleName); + } + return true; + } + +/*********************************************************************** +DocumentModel::ClearStyle +***********************************************************************/ + + bool DocumentModel::ClearStyle(TextPos begin, TextPos end) + { + return EditContainer(begin, end, [=](DocumentParagraphRun* paragraph, RunRangeMap& runRanges, vint start, vint end) + { + document_editor::ClearStyle(paragraph, runRanges, start, end); + }); + } + +/*********************************************************************** +DocumentModel::ClearStyle +***********************************************************************/ + + Ptr DocumentModel::SummarizeStyle(TextPos begin, TextPos end) + { + Ptr style; + RunRangeMap runRanges; + + if(begin==end) goto END_OF_SUMMERIZING; + + // check caret range + if(!CheckEditRange(begin, end, runRanges)) return nullptr; + + // summerize container + if(begin.row==end.row) + { + style=SummerizeStyle(paragraphs[begin.row].Obj(), runRanges, this, begin.column, end.column); + } + else + { + for(vint i=begin.row;i<=end.row;i++) + { + Ptr paragraph=paragraphs[i]; + if(begin.row paragraphStyle; + if(i==begin.row) + { + paragraphStyle=SummerizeStyle(paragraph.Obj(), runRanges, this, begin.column, range.end); + } + else if(i==end.row) + { + paragraphStyle=SummerizeStyle(paragraph.Obj(), runRanges, this, range.start, end.column); + } + else + { + paragraphStyle=SummerizeStyle(paragraph.Obj(), runRanges, this, range.start, range.end); + } + + if(!style) + { + style=paragraphStyle; + } + else if(paragraphStyle) + { + AggregateStyle(style, paragraphStyle); + } + } + } + + END_OF_SUMMERIZING: + if(!style) + { + style=new DocumentStyleProperties; + } + return style; + } + + Nullable DocumentModel::SummarizeParagraphAlignment(TextPos begin, TextPos end) + { + bool left = false; + bool center = false; + bool right = false; + + RunRangeMap runRanges; + if (!CheckEditRange(begin, end, runRanges)) return {}; + + for (vint i = begin.row; i <= end.row; i++) + { + auto paragraph = paragraphs[i]; + if (paragraph->alignment) + { + switch (paragraph->alignment.Value()) + { + case Alignment::Left: + left = true; + break; + case Alignment::Center: + center = true; + break; + case Alignment::Right: + right = true; + break; + } + } + else + { + left = true; + } + } + + if (left && !center && !right) return Alignment::Left; + if (!left && center && !right) return Alignment::Center; + if (!left && !center && right) return Alignment::Right; + return {}; + } } } diff --git a/Import/GacUI.h b/Import/GacUI.h index ec098202..7bfbf23b 100644 --- a/Import/GacUI.h +++ b/Import/GacUI.h @@ -5,7 +5,7 @@ DEVELOPER: Zihan Chen(vczh) #include "Vlpp.h" /*********************************************************************** -GUITYPES.H +.\GUITYPES.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -670,7 +670,7 @@ Resources #endif /*********************************************************************** -GRAPHICSELEMENT\GUIGRAPHICSELEMENTINTERFACES.H +.\GRAPHICSELEMENT\GUIGRAPHICSELEMENTINTERFACES.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -863,7 +863,7 @@ Basic Construction #endif /*********************************************************************** -GRAPHICSELEMENT\GUIGRAPHICSDOCUMENTINTERFACES.H +.\GRAPHICSELEMENT\GUIGRAPHICSDOCUMENTINTERFACES.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -1112,7 +1112,7 @@ Layout Engine #endif /*********************************************************************** -NATIVEWINDOW\GUINATIVEWINDOW.H +.\NATIVEWINDOW\GUINATIVEWINDOW.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -1120,10 +1120,10 @@ Developer: Zihan Chen(vczh) GacUI::Native Window Interfaces: - INativeWindow £º´°¿ÚÊÊÅäÆ÷ - INativeWindowListener £º´°¿Úʼþ¼àÌýÆ÷ - INativeController £ºÈ«¾Ö¿ØÖÆÆ÷ - INativeControllerListener £ºÈ«¾Öʼþ¼àÌýÆ÷ + INativeWindow :窗口适配器 + INativeWindowListener :窗口事件监听器 + INativeController :全局控制器 + INativeControllerListener :全局事件监听器 Renderers: GUI_GRAPHICS_RENDERER_GDI @@ -2909,7 +2909,556 @@ Native Window Provider #endif /*********************************************************************** -GRAPHICSELEMENT\GUIGRAPHICSRESOURCEMANAGER.H +.\GRAPHICSCOMPOSITION\GUIGRAPHICSEVENTRECEIVER.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Event Model + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSEVENTRECEIVER +#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSEVENTRECEIVER + + +namespace vl +{ + namespace presentation + { + namespace controls + { + namespace tree + { + class INodeProvider; + } + } + } +} + +namespace vl +{ + namespace presentation + { + using namespace reflection; + + namespace compositions + { + class GuiGraphicsComposition; + +/*********************************************************************** +Event +***********************************************************************/ + + class IGuiGraphicsEventHandler : public virtual IDescriptable, public Description + { + public: + class Container + { + public: + Ptr handler; + }; + + virtual bool IsAttached() = 0; + }; + + template + class GuiGraphicsEvent : public Object, public Description> + { + public: + typedef void(RawFunctionType)(GuiGraphicsComposition*, T&); + typedef Func FunctionType; + typedef T ArgumentType; + + class FunctionHandler : public Object, public IGuiGraphicsEventHandler + { + public: + bool isAttached = true; + FunctionType handler; + + FunctionHandler(const FunctionType& _handler) + :handler(_handler) + { + } + + bool IsAttached()override + { + return isAttached; + } + + void Execute(GuiGraphicsComposition* sender, T& argument) + { + handler(sender, argument); + } + }; + protected: + struct HandlerNode + { + Ptr handler; + Ptr next; + }; + + GuiGraphicsComposition* sender; + Ptr handlers; + + bool Attach(Ptr handler) + { + Ptr* currentHandler = &handlers; + while (*currentHandler) + { + if ((*currentHandler)->handler == handler) + { + return false; + } + else + { + currentHandler = &(*currentHandler)->next; + } + } + (*currentHandler) = new HandlerNode; + (*currentHandler)->handler = handler; + return true; + } + public: + GuiGraphicsEvent(GuiGraphicsComposition* _sender=0) + :sender(_sender) + { + } + + ~GuiGraphicsEvent() + { + } + + GuiGraphicsComposition* GetAssociatedComposition() + { + return sender; + } + + void SetAssociatedComposition(GuiGraphicsComposition* _sender) + { + sender=_sender; + } + + template + Ptr AttachMethod(TClass* receiver, TMethod TClass::* method) + { + auto handler=MakePtr(FunctionType(receiver, method)); + Attach(handler); + return handler; + } + + Ptr AttachFunction(RawFunctionType* function) + { + auto handler = MakePtr(FunctionType(function)); + Attach(handler); + return handler; + } + + Ptr AttachFunction(const FunctionType& function) + { + auto handler = MakePtr(function); + Attach(handler); + return handler; + } + + template + Ptr AttachLambda(const TLambda& lambda) + { + auto handler = MakePtr(FunctionType(lambda)); + Attach(handler); + return handler; + } + + bool Detach(Ptr handler) + { + auto typedHandler = handler.Cast(); + if (!typedHandler) + { + return false; + } + + auto currentHandler=&handlers; + while(*currentHandler) + { + if((*currentHandler)->handler == typedHandler) + { + (*currentHandler)->handler->isAttached = false; + + auto next=(*currentHandler)->next; + (*currentHandler)=next; + return true; + } + else + { + currentHandler=&(*currentHandler)->next; + } + } + return false; + } + + void ExecuteWithNewSender(T& argument, GuiGraphicsComposition* newSender) + { + auto currentHandler=&handlers; + while(*currentHandler) + { + (*currentHandler)->handler->Execute(newSender?newSender:sender, argument); + currentHandler=&(*currentHandler)->next; + } + } + + void Execute(T& argument) + { + ExecuteWithNewSender(argument, 0); + } + + void Execute(const T& argument) + { + auto t = argument; + ExecuteWithNewSender(t, 0); + } + }; + +/*********************************************************************** +Predefined Events +***********************************************************************/ + + /// Notify event arguments. + struct GuiEventArgs : public Object, public AggregatableDescription + { + /// The event raiser composition. + GuiGraphicsComposition* compositionSource; + /// The nearest parent of the event raiser composition that contains an event receiver. If the event raiser composition contains an event receiver, it will be the event raiser composition. + GuiGraphicsComposition* eventSource; + /// Set this field to true will stop the event routing. This is a signal that the event is properly handeled, and the event handler want to override the default behavior. + bool handled; + + /// Create an event arguments with and set to null. + GuiEventArgs() + :compositionSource(0) + ,eventSource(0) + ,handled(false) + { + } + + /// Create an event arguments with and set to a specified value. + /// The speciied value to set and . + GuiEventArgs(GuiGraphicsComposition* composition) + :compositionSource(composition) + ,eventSource(composition) + ,handled(false) + { + } + + ~GuiEventArgs() + { + FinalizeAggregation(); + } + }; + + /// Request event arguments. + struct GuiRequestEventArgs : public GuiEventArgs, public Description + { + /// Set this field to false in event handlers will stop the corresponding action. + bool cancel; + + /// Create an event arguments with and set to null. + GuiRequestEventArgs() + :cancel(false) + { + } + + /// Create an event arguments with and set to a specified value. + /// The speciied value to set and . + GuiRequestEventArgs(GuiGraphicsComposition* composition) + :GuiEventArgs(composition) + ,cancel(false) + { + } + }; + + /// Keyboard event arguments. + struct GuiKeyEventArgs : public GuiEventArgs, public NativeWindowKeyInfo, public Description + { + /// Create an event arguments with and set to null. + GuiKeyEventArgs() + { + } + + /// Create an event arguments with and set to a specified value. + /// The speciied value to set and . + GuiKeyEventArgs(GuiGraphicsComposition* composition) + :GuiEventArgs(composition) + { + } + }; + + /// Char input event arguments. + struct GuiCharEventArgs : public GuiEventArgs, public NativeWindowCharInfo, public Description + { + /// Create an event arguments with and set to null. + GuiCharEventArgs() + { + } + + /// Create an event arguments with and set to a specified value. + /// The speciied value to set and . + GuiCharEventArgs(GuiGraphicsComposition* composition) + :GuiEventArgs(composition) + { + } + }; + + /// Mouse event arguments. + struct GuiMouseEventArgs : public GuiEventArgs, public NativeWindowMouseInfo, public Description + { + /// Create an event arguments with and set to null. + GuiMouseEventArgs() + { + } + + /// Create an event arguments with and set to a specified value. + /// The speciied value to set and . + GuiMouseEventArgs(GuiGraphicsComposition* composition) + :GuiEventArgs(composition) + { + } + }; + + typedef GuiGraphicsEvent GuiNotifyEvent; + typedef GuiGraphicsEvent GuiRequestEvent; + typedef GuiGraphicsEvent GuiKeyEvent; + typedef GuiGraphicsEvent GuiCharEvent; + typedef GuiGraphicsEvent GuiMouseEvent; + +/*********************************************************************** +Predefined Item Events +***********************************************************************/ + + /// Item event arguments. + struct GuiItemEventArgs : public GuiEventArgs, public Description + { + /// Item index. + vint itemIndex; + + GuiItemEventArgs() + :itemIndex(-1) + { + } + + /// Create an event arguments with and set to a specified value. + /// The speciied value to set and . + GuiItemEventArgs(GuiGraphicsComposition* composition) + :GuiEventArgs(composition) + ,itemIndex(-1) + { + } + }; + + /// Item mouse event arguments. + struct GuiItemMouseEventArgs : public GuiMouseEventArgs, public Description + { + /// Item index. + vint itemIndex; + + GuiItemMouseEventArgs() + :itemIndex(-1) + { + } + + /// Create an event arguments with and set to a specified value. + /// The speciied value to set and . + GuiItemMouseEventArgs(GuiGraphicsComposition* composition) + :GuiMouseEventArgs(composition) + ,itemIndex(-1) + { + } + }; + + typedef GuiGraphicsEvent GuiItemNotifyEvent; + typedef GuiGraphicsEvent GuiItemMouseEvent; + +/*********************************************************************** +Predefined Node Events +***********************************************************************/ + + /// Node event arguments. + struct GuiNodeEventArgs : public GuiEventArgs, public Description + { + /// Tree node. + controls::tree::INodeProvider* node; + + GuiNodeEventArgs() + :node(0) + { + } + + /// Create an event arguments with and set to a specified value. + /// The speciied value to set and . + GuiNodeEventArgs(GuiGraphicsComposition* composition) + :GuiEventArgs(composition) + ,node(0) + { + } + }; + + /// Node mouse event arguments. + struct GuiNodeMouseEventArgs : public GuiMouseEventArgs, public Description + { + /// Tree node. + controls::tree::INodeProvider* node; + + GuiNodeMouseEventArgs() + :node(0) + { + } + + /// Create an event arguments with and set to a specified value. + /// The speciied value to set and . + GuiNodeMouseEventArgs(GuiGraphicsComposition* composition) + :GuiMouseEventArgs(composition) + ,node(0) + { + } + }; + + typedef GuiGraphicsEvent GuiNodeNotifyEvent; + typedef GuiGraphicsEvent GuiNodeMouseEvent; + +/*********************************************************************** +Event Receiver +***********************************************************************/ + + /// + /// Contains all available user input events for a . Almost all events are routed events. Routed events means, not only the activated composition receives the event, all it direct or indirect parents receives the event. The argument(all derives from ) for the event will store the original event raiser composition. + /// + class GuiGraphicsEventReceiver : public Object + { + protected: + GuiGraphicsComposition* sender; + public: + GuiGraphicsEventReceiver(GuiGraphicsComposition* _sender); + ~GuiGraphicsEventReceiver(); + + GuiGraphicsComposition* GetAssociatedComposition(); + + /// Left mouse button down event. + GuiMouseEvent leftButtonDown; + /// Left mouse button up event. + GuiMouseEvent leftButtonUp; + /// Left mouse button double click event. + GuiMouseEvent leftButtonDoubleClick; + /// Middle mouse button down event. + GuiMouseEvent middleButtonDown; + /// Middle mouse button up event. + GuiMouseEvent middleButtonUp; + /// Middle mouse button double click event. + GuiMouseEvent middleButtonDoubleClick; + /// Right mouse button down event. + GuiMouseEvent rightButtonDown; + /// Right mouse button up event. + GuiMouseEvent rightButtonUp; + /// Right mouse button double click event. + GuiMouseEvent rightButtonDoubleClick; + /// Horizontal wheel scrolling event. + GuiMouseEvent horizontalWheel; + /// Vertical wheel scrolling event. + GuiMouseEvent verticalWheel; + /// Mouse move event. + GuiMouseEvent mouseMove; + /// Mouse enter event. + GuiNotifyEvent mouseEnter; + /// Mouse leave event. + GuiNotifyEvent mouseLeave; + + /// Preview key event. + GuiKeyEvent previewKey; + /// Key down event. + GuiKeyEvent keyDown; + /// Key up event. + GuiKeyEvent keyUp; + /// System key down event. + GuiKeyEvent systemKeyDown; + /// System key up event. + GuiKeyEvent systemKeyUp; + /// Preview char input event. + GuiCharEvent previewCharInput; + /// Char input event. + GuiCharEvent charInput; + /// Got focus event. + GuiNotifyEvent gotFocus; + /// Lost focus event. + GuiNotifyEvent lostFocus; + /// Caret notify event. This event is raised when a caret graph need to change the visibility state. + GuiNotifyEvent caretNotify; + /// Clipboard notify event. This event is raised when the content in the system clipboard is changed. + GuiNotifyEvent clipboardNotify; + /// Render target changed event. This event is raised when the render target of this composition is changed. + GuiNotifyEvent renderTargetChanged; + }; + } + } + + /*********************************************************************** + Workflow to C++ Codegen Helpers + ***********************************************************************/ + + namespace __vwsn + { + template + struct EventHelper> + { + using Event = presentation::compositions::GuiGraphicsEvent; + using Sender = presentation::compositions::GuiGraphicsComposition; + using IGuiGraphicsEventHandler = presentation::compositions::IGuiGraphicsEventHandler; + using Handler = Func; + + class EventHandlerImpl : public Object, public reflection::description::IEventHandler + { + public: + Ptr handler; + + EventHandlerImpl(Ptr _handler) + :handler(_handler) + { + } + + bool IsAttached()override + { + return handler->IsAttached(); + } + }; + + static Ptr Attach(Event& e, Handler handler) + { + return MakePtr(e.AttachLambda([=](Sender* sender, T& args) + { + handler(sender, &args); + })); + } + + static bool Detach(Event& e, Ptr handler) + { + auto impl = handler.Cast(); + if (!impl) return false; + return e.Detach(impl->handler); + } + + static auto Invoke(Event& e) + { + return [&](Sender* sender, T* args) + { + e.ExecuteWithNewSender(*args, sender); + }; + } + }; + } +} + +#endif + +/*********************************************************************** +.\GRAPHICSELEMENT\GUIGRAPHICSRESOURCEMANAGER.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -3240,7 +3789,7 @@ Helpers #endif /*********************************************************************** -RESOURCES\GUIRESOURCE.H +.\RESOURCES\GUIRESOURCE.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -3997,13 +4546,17 @@ Resource Resolver Manager }; extern IGuiResourceResolverManager* GetResourceResolverManager(); + extern vint CopyStream(stream::IStream& inputStream, stream::IStream& outputStream); + extern void CompressStream(stream::IStream& inputStream, stream::IStream& outputStream); + extern void DecompressStream(stream::IStream& inputStream, stream::IStream& outputStream); + extern void DecompressStream(const char** buffer, bool compress, vint rows, vint block, vint remain, stream::IStream& outputStream); } } #endif /*********************************************************************** -RESOURCES\GUIDOCUMENT.H +.\RESOURCES\GUIDOCUMENT.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -4393,7 +4946,7 @@ Rich Content Document (model) #endif /*********************************************************************** -GRAPHICSELEMENT\GUIGRAPHICSELEMENT.H +.\GRAPHICSELEMENT\GUIGRAPHICSELEMENT.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -5015,7 +5568,309 @@ Elements #endif /*********************************************************************** -GRAPHICSELEMENT\GUIGRAPHICSTEXTELEMENT.H +.\GRAPHICSELEMENT\GUIGRAPHICSDOCUMENTELEMENT.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Element System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSDOCUMENTELEMENT +#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSDOCUMENTELEMENT + + +namespace vl +{ + namespace presentation + { + namespace elements + { + + namespace visitors + { + class SetPropertiesVisitor; + } + +/*********************************************************************** +Rich Content Document (element) +***********************************************************************/ + + /// Defines a rich text document element for rendering complex styled document. + class GuiDocumentElement : public GuiElementBase + { + DEFINE_GUI_GRAPHICS_ELEMENT(GuiDocumentElement, L"RichDocument"); + public: + /// Callback interface for this element. + class ICallback : public virtual IDescriptable, public Description + { + public: + /// Called when the rendering is started. + virtual void OnStartRender() = 0; + + /// Called when the rendering is finished. + virtual void OnFinishRender() = 0; + + /// Called when an embedded object is being rendered. + /// Returns the new size of the rendered embedded object. + /// The name of the embedded object + /// The location of the embedded object, relative to the left-top corner of this element. + virtual Size OnRenderEmbeddedObject(const WString& name, const Rect& location) = 0; + }; + + class GuiDocumentElementRenderer : public Object, public IGuiGraphicsRenderer, private IGuiGraphicsParagraphCallback + { + friend class visitors::SetPropertiesVisitor; + + DEFINE_GUI_GRAPHICS_RENDERER(GuiDocumentElement, GuiDocumentElementRenderer, IGuiGraphicsRenderTarget) + protected: + struct EmbeddedObject + { + WString name; + Size size; + vint start; + bool resized = false; + }; + + typedef collections::Dictionary> IdEmbeddedObjectMap; + typedef collections::Dictionary NameIdMap; + typedef collections::List FreeIdList; + + struct ParagraphCache + { + WString fullText; + Ptr graphicsParagraph; + IdEmbeddedObjectMap embeddedObjects; + vint selectionBegin; + vint selectionEnd; + + ParagraphCache() + :selectionBegin(-1) + ,selectionEnd(-1) + { + } + }; + + typedef collections::Array> ParagraphCacheArray; + typedef collections::Array ParagraphHeightArray; + + private: + + Size OnRenderInlineObject(vint callbackId, Rect location)override; + protected: + vint paragraphDistance; + vint lastMaxWidth; + vint cachedTotalHeight; + IGuiGraphicsLayoutProvider* layoutProvider; + ParagraphCacheArray paragraphCaches; + ParagraphHeightArray paragraphHeights; + + TextPos lastCaret; + Color lastCaretColor; + bool lastCaretFrontSide; + + NameIdMap nameCallbackIdMap; + FreeIdList freeCallbackIds; + vint usedCallbackIds = 0; + + vint renderingParagraph = -1; + Point renderingParagraphOffset; + + void InitializeInternal(); + void FinalizeInternal(); + void RenderTargetChangedInternal(IGuiGraphicsRenderTarget* oldRenderTarget, IGuiGraphicsRenderTarget* newRenderTarget); + Ptr EnsureAndGetCache(vint paragraphIndex, bool createParagraph); + bool GetParagraphIndexFromPoint(Point point, vint& top, vint& index); + public: + GuiDocumentElementRenderer(); + + void Render(Rect bounds)override; + void OnElementStateChanged()override; + void NotifyParagraphUpdated(vint index, vint oldCount, vint newCount, bool updatedText); + Ptr GetHyperlinkFromPoint(Point point); + + void OpenCaret(TextPos caret, Color color, bool frontSide); + void CloseCaret(TextPos caret); + void SetSelection(TextPos begin, TextPos end); + TextPos CalculateCaret(TextPos comparingCaret, IGuiGraphicsParagraph::CaretRelativePosition position, bool& preferFrontSide); + TextPos CalculateCaretFromPoint(Point point); + Rect GetCaretBounds(TextPos caret, bool frontSide); + }; + + protected: + Ptr document; + ICallback* callback = nullptr; + TextPos caretBegin; + TextPos caretEnd; + bool caretVisible; + bool caretFrontSide; + Color caretColor; + + void UpdateCaret(); + + GuiDocumentElement(); + public: + /// Get the callback. + /// The callback. + ICallback* GetCallback(); + /// Set the callback. + /// The callback. + void SetCallback(ICallback* value); + + /// Get the document. + /// The document. + Ptr GetDocument(); + /// Set the document. When a document is set to this element, modifying the document without invoking will lead to undefined behavior. + /// The document. + void SetDocument(Ptr value); + /// + /// Get the begin position of the selection area. + /// + /// The begin position of the selection area. + TextPos GetCaretBegin(); + /// + /// Get the end position of the selection area. + /// + /// The end position of the selection area. + TextPos GetCaretEnd(); + /// + /// Get the prefer side for the caret. + /// + /// Returns true if the caret is rendered for the front side. + bool IsCaretEndPreferFrontSide(); + /// + /// Set the end position of the selection area. + /// + /// The begin position of the selection area. + /// The end position of the selection area. + /// Set to true to show the caret for the character before it. This argument is ignored if begin and end are the same. + void SetCaret(TextPos begin, TextPos end, bool frontSide); + /// + /// Get the caret visibility. + /// + /// Returns true if the caret will be rendered. + bool GetCaretVisible(); + /// + /// Set the caret visibility. + /// + /// True if the caret will be rendered. + void SetCaretVisible(bool value); + /// + /// Get the color of the caret. + /// + /// The color of the caret. + Color GetCaretColor(); + /// + /// Set the color of the caret. + /// + /// The color of the caret. + void SetCaretColor(Color value); + + /// Calculate a caret using a specified comparing caret and a relative position. + /// The calculated caret. + /// The comparing caret. + /// The relative position. + /// Specify the side for the comparingCaret. Retrive the suggested side for the new caret. If the return caret equals compareCaret, this output is ignored. + TextPos CalculateCaret(TextPos comparingCaret, IGuiGraphicsParagraph::CaretRelativePosition position, bool& preferFrontSide); + /// Calculate a caret using a specified point. + /// The calculated caret. + /// The specified point. + TextPos CalculateCaretFromPoint(Point point); + /// Get the bounds of a caret. + /// The bounds. + /// The caret. + /// Set to true to get the bounds for the character before it. + Rect GetCaretBounds(TextPos caret, bool frontSide); + + /// Notify that some paragraphs are updated. + /// The start paragraph index. + /// The number of paragraphs to be updated. + /// The number of updated paragraphs. + /// Set to true to notify that the text is updated. + void NotifyParagraphUpdated(vint index, vint oldCount, vint newCount, bool updatedText); + /// Edit run in a specified range. + /// The begin position of the range. + /// The end position of the range. + /// The new run. + /// Set to true to copy the model before editing. Otherwise, objects inside the model will be used directly + void EditRun(TextPos begin, TextPos end, Ptr model, bool copy); + /// Edit text in a specified range. + /// The begin position of the range. + /// The end position of the range. + /// Set to true to use the text style in front of the specified range. + /// The new text. + void EditText(TextPos begin, TextPos end, bool frontSide, const collections::Array& text); + /// Edit style in a specified range. + /// The begin position of the range. + /// The end position of the range. + /// The new style. + void EditStyle(TextPos begin, TextPos end, Ptr style); + /// Edit image in a specified range. + /// The begin position of the range. + /// The end position of the range. + /// The new image. + void EditImage(TextPos begin, TextPos end, Ptr image); + /// Set hyperlink in a specified range. + /// The index of the paragraph to edit. + /// The begin position of the range. + /// The end position of the range. + /// The reference of the hyperlink. + /// The normal style name of the hyperlink. + /// The active style name of the hyperlink. + void EditHyperlink(vint paragraphIndex, vint begin, vint end, const WString& reference, const WString& normalStyleName=DocumentModel::NormalLinkStyleName, const WString& activeStyleName=DocumentModel::ActiveLinkStyleName); + /// Remove hyperlink in a specified range. + /// The index of the paragraph to edit. + /// The begin position of the range. + /// The end position of the range. + void RemoveHyperlink(vint paragraphIndex, vint begin, vint end); + /// Edit style name in a specified range. + /// The begin position of the range. + /// The end position of the range. + /// The new style name. + void EditStyleName(TextPos begin, TextPos end, const WString& styleName); + /// Remove style name in a specified range. + /// The begin position of the range. + /// The end position of the range. + void RemoveStyleName(TextPos begin, TextPos end); + /// Rename a style. + /// The name of the style. + /// The new name. + void RenameStyle(const WString& oldStyleName, const WString& newStyleName); + /// Clear all styles in a specified range. + /// The begin position of the range. + /// The end position of the range. + void ClearStyle(TextPos begin, TextPos end); + /// Summarize the text style in a specified range. + /// The text style summary. + /// The begin position of the range. + /// The end position of the range. + Ptr SummarizeStyle(TextPos begin, TextPos end); + /// Set the alignment of paragraphs in a specified range. + /// The begin position of the range. + /// The end position of the range. + /// The alignment for each paragraph. + void SetParagraphAlignment(TextPos begin, TextPos end, const collections::Array>& alignments); + /// Summarize the text alignment in a specified range. + /// The text alignment summary. + /// The begin position of the range. + /// The end position of the range. + Nullable SummarizeParagraphAlignment(TextPos begin, TextPos end); + + /// Get hyperlink from point. + /// Corressponding hyperlink id. Returns -1 indicates that the point is not in a hyperlink. + /// The point to get the hyperlink id. + Ptr GetHyperlinkFromPoint(Point point); + }; + } + } +} + +#endif + +/*********************************************************************** +.\GRAPHICSELEMENT\GUIGRAPHICSTEXTELEMENT.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -5600,858 +6455,7 @@ Colorized Plain Text (element) #endif /*********************************************************************** -GRAPHICSELEMENT\GUIGRAPHICSDOCUMENTELEMENT.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Element System - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSDOCUMENTELEMENT -#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSDOCUMENTELEMENT - - -namespace vl -{ - namespace presentation - { - namespace elements - { - - namespace visitors - { - class SetPropertiesVisitor; - } - -/*********************************************************************** -Rich Content Document (element) -***********************************************************************/ - - /// Defines a rich text document element for rendering complex styled document. - class GuiDocumentElement : public GuiElementBase - { - DEFINE_GUI_GRAPHICS_ELEMENT(GuiDocumentElement, L"RichDocument"); - public: - /// Callback interface for this element. - class ICallback : public virtual IDescriptable, public Description - { - public: - /// Called when the rendering is started. - virtual void OnStartRender() = 0; - - /// Called when the rendering is finished. - virtual void OnFinishRender() = 0; - - /// Called when an embedded object is being rendered. - /// Returns the new size of the rendered embedded object. - /// The name of the embedded object - /// The location of the embedded object, relative to the left-top corner of this element. - virtual Size OnRenderEmbeddedObject(const WString& name, const Rect& location) = 0; - }; - - class GuiDocumentElementRenderer : public Object, public IGuiGraphicsRenderer, private IGuiGraphicsParagraphCallback - { - friend class visitors::SetPropertiesVisitor; - - DEFINE_GUI_GRAPHICS_RENDERER(GuiDocumentElement, GuiDocumentElementRenderer, IGuiGraphicsRenderTarget) - protected: - struct EmbeddedObject - { - WString name; - Size size; - vint start; - bool resized = false; - }; - - typedef collections::Dictionary> IdEmbeddedObjectMap; - typedef collections::Dictionary NameIdMap; - typedef collections::List FreeIdList; - - struct ParagraphCache - { - WString fullText; - Ptr graphicsParagraph; - IdEmbeddedObjectMap embeddedObjects; - vint selectionBegin; - vint selectionEnd; - - ParagraphCache() - :selectionBegin(-1) - ,selectionEnd(-1) - { - } - }; - - typedef collections::Array> ParagraphCacheArray; - typedef collections::Array ParagraphHeightArray; - - private: - - Size OnRenderInlineObject(vint callbackId, Rect location)override; - protected: - vint paragraphDistance; - vint lastMaxWidth; - vint cachedTotalHeight; - IGuiGraphicsLayoutProvider* layoutProvider; - ParagraphCacheArray paragraphCaches; - ParagraphHeightArray paragraphHeights; - - TextPos lastCaret; - Color lastCaretColor; - bool lastCaretFrontSide; - - NameIdMap nameCallbackIdMap; - FreeIdList freeCallbackIds; - vint usedCallbackIds = 0; - - vint renderingParagraph = -1; - Point renderingParagraphOffset; - - void InitializeInternal(); - void FinalizeInternal(); - void RenderTargetChangedInternal(IGuiGraphicsRenderTarget* oldRenderTarget, IGuiGraphicsRenderTarget* newRenderTarget); - Ptr EnsureAndGetCache(vint paragraphIndex, bool createParagraph); - bool GetParagraphIndexFromPoint(Point point, vint& top, vint& index); - public: - GuiDocumentElementRenderer(); - - void Render(Rect bounds)override; - void OnElementStateChanged()override; - void NotifyParagraphUpdated(vint index, vint oldCount, vint newCount, bool updatedText); - Ptr GetHyperlinkFromPoint(Point point); - - void OpenCaret(TextPos caret, Color color, bool frontSide); - void CloseCaret(TextPos caret); - void SetSelection(TextPos begin, TextPos end); - TextPos CalculateCaret(TextPos comparingCaret, IGuiGraphicsParagraph::CaretRelativePosition position, bool& preferFrontSide); - TextPos CalculateCaretFromPoint(Point point); - Rect GetCaretBounds(TextPos caret, bool frontSide); - }; - - protected: - Ptr document; - ICallback* callback = nullptr; - TextPos caretBegin; - TextPos caretEnd; - bool caretVisible; - bool caretFrontSide; - Color caretColor; - - void UpdateCaret(); - - GuiDocumentElement(); - public: - /// Get the callback. - /// The callback. - ICallback* GetCallback(); - /// Set the callback. - /// The callback. - void SetCallback(ICallback* value); - - /// Get the document. - /// The document. - Ptr GetDocument(); - /// Set the document. When a document is set to this element, modifying the document without invoking will lead to undefined behavior. - /// The document. - void SetDocument(Ptr value); - /// - /// Get the begin position of the selection area. - /// - /// The begin position of the selection area. - TextPos GetCaretBegin(); - /// - /// Get the end position of the selection area. - /// - /// The end position of the selection area. - TextPos GetCaretEnd(); - /// - /// Get the prefer side for the caret. - /// - /// Returns true if the caret is rendered for the front side. - bool IsCaretEndPreferFrontSide(); - /// - /// Set the end position of the selection area. - /// - /// The begin position of the selection area. - /// The end position of the selection area. - /// Set to true to show the caret for the character before it. This argument is ignored if begin and end are the same. - void SetCaret(TextPos begin, TextPos end, bool frontSide); - /// - /// Get the caret visibility. - /// - /// Returns true if the caret will be rendered. - bool GetCaretVisible(); - /// - /// Set the caret visibility. - /// - /// True if the caret will be rendered. - void SetCaretVisible(bool value); - /// - /// Get the color of the caret. - /// - /// The color of the caret. - Color GetCaretColor(); - /// - /// Set the color of the caret. - /// - /// The color of the caret. - void SetCaretColor(Color value); - - /// Calculate a caret using a specified comparing caret and a relative position. - /// The calculated caret. - /// The comparing caret. - /// The relative position. - /// Specify the side for the comparingCaret. Retrive the suggested side for the new caret. If the return caret equals compareCaret, this output is ignored. - TextPos CalculateCaret(TextPos comparingCaret, IGuiGraphicsParagraph::CaretRelativePosition position, bool& preferFrontSide); - /// Calculate a caret using a specified point. - /// The calculated caret. - /// The specified point. - TextPos CalculateCaretFromPoint(Point point); - /// Get the bounds of a caret. - /// The bounds. - /// The caret. - /// Set to true to get the bounds for the character before it. - Rect GetCaretBounds(TextPos caret, bool frontSide); - - /// Notify that some paragraphs are updated. - /// The start paragraph index. - /// The number of paragraphs to be updated. - /// The number of updated paragraphs. - /// Set to true to notify that the text is updated. - void NotifyParagraphUpdated(vint index, vint oldCount, vint newCount, bool updatedText); - /// Edit run in a specified range. - /// The begin position of the range. - /// The end position of the range. - /// The new run. - /// Set to true to copy the model before editing. Otherwise, objects inside the model will be used directly - void EditRun(TextPos begin, TextPos end, Ptr model, bool copy); - /// Edit text in a specified range. - /// The begin position of the range. - /// The end position of the range. - /// Set to true to use the text style in front of the specified range. - /// The new text. - void EditText(TextPos begin, TextPos end, bool frontSide, const collections::Array& text); - /// Edit style in a specified range. - /// The begin position of the range. - /// The end position of the range. - /// The new style. - void EditStyle(TextPos begin, TextPos end, Ptr style); - /// Edit image in a specified range. - /// The begin position of the range. - /// The end position of the range. - /// The new image. - void EditImage(TextPos begin, TextPos end, Ptr image); - /// Set hyperlink in a specified range. - /// The index of the paragraph to edit. - /// The begin position of the range. - /// The end position of the range. - /// The reference of the hyperlink. - /// The normal style name of the hyperlink. - /// The active style name of the hyperlink. - void EditHyperlink(vint paragraphIndex, vint begin, vint end, const WString& reference, const WString& normalStyleName=DocumentModel::NormalLinkStyleName, const WString& activeStyleName=DocumentModel::ActiveLinkStyleName); - /// Remove hyperlink in a specified range. - /// The index of the paragraph to edit. - /// The begin position of the range. - /// The end position of the range. - void RemoveHyperlink(vint paragraphIndex, vint begin, vint end); - /// Edit style name in a specified range. - /// The begin position of the range. - /// The end position of the range. - /// The new style name. - void EditStyleName(TextPos begin, TextPos end, const WString& styleName); - /// Remove style name in a specified range. - /// The begin position of the range. - /// The end position of the range. - void RemoveStyleName(TextPos begin, TextPos end); - /// Rename a style. - /// The name of the style. - /// The new name. - void RenameStyle(const WString& oldStyleName, const WString& newStyleName); - /// Clear all styles in a specified range. - /// The begin position of the range. - /// The end position of the range. - void ClearStyle(TextPos begin, TextPos end); - /// Summarize the text style in a specified range. - /// The text style summary. - /// The begin position of the range. - /// The end position of the range. - Ptr SummarizeStyle(TextPos begin, TextPos end); - /// Set the alignment of paragraphs in a specified range. - /// The begin position of the range. - /// The end position of the range. - /// The alignment for each paragraph. - void SetParagraphAlignment(TextPos begin, TextPos end, const collections::Array>& alignments); - /// Summarize the text alignment in a specified range. - /// The text alignment summary. - /// The begin position of the range. - /// The end position of the range. - Nullable SummarizeParagraphAlignment(TextPos begin, TextPos end); - - /// Get hyperlink from point. - /// Corressponding hyperlink id. Returns -1 indicates that the point is not in a hyperlink. - /// The point to get the hyperlink id. - Ptr GetHyperlinkFromPoint(Point point); - }; - } - } -} - -#endif - -/*********************************************************************** -GRAPHICSCOMPOSITION\GUIGRAPHICSEVENTRECEIVER.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Event Model - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSEVENTRECEIVER -#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSEVENTRECEIVER - - -namespace vl -{ - namespace presentation - { - namespace controls - { - namespace tree - { - class INodeProvider; - } - } - } -} - -namespace vl -{ - namespace presentation - { - using namespace reflection; - - namespace compositions - { - class GuiGraphicsComposition; - -/*********************************************************************** -Event -***********************************************************************/ - - class IGuiGraphicsEventHandler : public virtual IDescriptable, public Description - { - public: - class Container - { - public: - Ptr handler; - }; - - virtual bool IsAttached() = 0; - }; - - template - class GuiGraphicsEvent : public Object, public Description> - { - public: - typedef void(RawFunctionType)(GuiGraphicsComposition*, T&); - typedef Func FunctionType; - typedef T ArgumentType; - - class FunctionHandler : public Object, public IGuiGraphicsEventHandler - { - public: - bool isAttached = true; - FunctionType handler; - - FunctionHandler(const FunctionType& _handler) - :handler(_handler) - { - } - - bool IsAttached()override - { - return isAttached; - } - - void Execute(GuiGraphicsComposition* sender, T& argument) - { - handler(sender, argument); - } - }; - protected: - struct HandlerNode - { - Ptr handler; - Ptr next; - }; - - GuiGraphicsComposition* sender; - Ptr handlers; - - bool Attach(Ptr handler) - { - Ptr* currentHandler = &handlers; - while (*currentHandler) - { - if ((*currentHandler)->handler == handler) - { - return false; - } - else - { - currentHandler = &(*currentHandler)->next; - } - } - (*currentHandler) = new HandlerNode; - (*currentHandler)->handler = handler; - return true; - } - public: - GuiGraphicsEvent(GuiGraphicsComposition* _sender=0) - :sender(_sender) - { - } - - ~GuiGraphicsEvent() - { - } - - GuiGraphicsComposition* GetAssociatedComposition() - { - return sender; - } - - void SetAssociatedComposition(GuiGraphicsComposition* _sender) - { - sender=_sender; - } - - template - Ptr AttachMethod(TClass* receiver, TMethod TClass::* method) - { - auto handler=MakePtr(FunctionType(receiver, method)); - Attach(handler); - return handler; - } - - Ptr AttachFunction(RawFunctionType* function) - { - auto handler = MakePtr(FunctionType(function)); - Attach(handler); - return handler; - } - - Ptr AttachFunction(const FunctionType& function) - { - auto handler = MakePtr(function); - Attach(handler); - return handler; - } - - template - Ptr AttachLambda(const TLambda& lambda) - { - auto handler = MakePtr(FunctionType(lambda)); - Attach(handler); - return handler; - } - - bool Detach(Ptr handler) - { - auto typedHandler = handler.Cast(); - if (!typedHandler) - { - return false; - } - - auto currentHandler=&handlers; - while(*currentHandler) - { - if((*currentHandler)->handler == typedHandler) - { - (*currentHandler)->handler->isAttached = false; - - auto next=(*currentHandler)->next; - (*currentHandler)=next; - return true; - } - else - { - currentHandler=&(*currentHandler)->next; - } - } - return false; - } - - void ExecuteWithNewSender(T& argument, GuiGraphicsComposition* newSender) - { - auto currentHandler=&handlers; - while(*currentHandler) - { - (*currentHandler)->handler->Execute(newSender?newSender:sender, argument); - currentHandler=&(*currentHandler)->next; - } - } - - void Execute(T& argument) - { - ExecuteWithNewSender(argument, 0); - } - - void Execute(const T& argument) - { - auto t = argument; - ExecuteWithNewSender(t, 0); - } - }; - -/*********************************************************************** -Predefined Events -***********************************************************************/ - - /// Notify event arguments. - struct GuiEventArgs : public Object, public AggregatableDescription - { - /// The event raiser composition. - GuiGraphicsComposition* compositionSource; - /// The nearest parent of the event raiser composition that contains an event receiver. If the event raiser composition contains an event receiver, it will be the event raiser composition. - GuiGraphicsComposition* eventSource; - /// Set this field to true will stop the event routing. This is a signal that the event is properly handeled, and the event handler want to override the default behavior. - bool handled; - - /// Create an event arguments with and set to null. - GuiEventArgs() - :compositionSource(0) - ,eventSource(0) - ,handled(false) - { - } - - /// Create an event arguments with and set to a specified value. - /// The speciied value to set and . - GuiEventArgs(GuiGraphicsComposition* composition) - :compositionSource(composition) - ,eventSource(composition) - ,handled(false) - { - } - - ~GuiEventArgs() - { - FinalizeAggregation(); - } - }; - - /// Request event arguments. - struct GuiRequestEventArgs : public GuiEventArgs, public Description - { - /// Set this field to false in event handlers will stop the corresponding action. - bool cancel; - - /// Create an event arguments with and set to null. - GuiRequestEventArgs() - :cancel(false) - { - } - - /// Create an event arguments with and set to a specified value. - /// The speciied value to set and . - GuiRequestEventArgs(GuiGraphicsComposition* composition) - :GuiEventArgs(composition) - ,cancel(false) - { - } - }; - - /// Keyboard event arguments. - struct GuiKeyEventArgs : public GuiEventArgs, public NativeWindowKeyInfo, public Description - { - /// Create an event arguments with and set to null. - GuiKeyEventArgs() - { - } - - /// Create an event arguments with and set to a specified value. - /// The speciied value to set and . - GuiKeyEventArgs(GuiGraphicsComposition* composition) - :GuiEventArgs(composition) - { - } - }; - - /// Char input event arguments. - struct GuiCharEventArgs : public GuiEventArgs, public NativeWindowCharInfo, public Description - { - /// Create an event arguments with and set to null. - GuiCharEventArgs() - { - } - - /// Create an event arguments with and set to a specified value. - /// The speciied value to set and . - GuiCharEventArgs(GuiGraphicsComposition* composition) - :GuiEventArgs(composition) - { - } - }; - - /// Mouse event arguments. - struct GuiMouseEventArgs : public GuiEventArgs, public NativeWindowMouseInfo, public Description - { - /// Create an event arguments with and set to null. - GuiMouseEventArgs() - { - } - - /// Create an event arguments with and set to a specified value. - /// The speciied value to set and . - GuiMouseEventArgs(GuiGraphicsComposition* composition) - :GuiEventArgs(composition) - { - } - }; - - typedef GuiGraphicsEvent GuiNotifyEvent; - typedef GuiGraphicsEvent GuiRequestEvent; - typedef GuiGraphicsEvent GuiKeyEvent; - typedef GuiGraphicsEvent GuiCharEvent; - typedef GuiGraphicsEvent GuiMouseEvent; - -/*********************************************************************** -Predefined Item Events -***********************************************************************/ - - /// Item event arguments. - struct GuiItemEventArgs : public GuiEventArgs, public Description - { - /// Item index. - vint itemIndex; - - GuiItemEventArgs() - :itemIndex(-1) - { - } - - /// Create an event arguments with and set to a specified value. - /// The speciied value to set and . - GuiItemEventArgs(GuiGraphicsComposition* composition) - :GuiEventArgs(composition) - ,itemIndex(-1) - { - } - }; - - /// Item mouse event arguments. - struct GuiItemMouseEventArgs : public GuiMouseEventArgs, public Description - { - /// Item index. - vint itemIndex; - - GuiItemMouseEventArgs() - :itemIndex(-1) - { - } - - /// Create an event arguments with and set to a specified value. - /// The speciied value to set and . - GuiItemMouseEventArgs(GuiGraphicsComposition* composition) - :GuiMouseEventArgs(composition) - ,itemIndex(-1) - { - } - }; - - typedef GuiGraphicsEvent GuiItemNotifyEvent; - typedef GuiGraphicsEvent GuiItemMouseEvent; - -/*********************************************************************** -Predefined Node Events -***********************************************************************/ - - /// Node event arguments. - struct GuiNodeEventArgs : public GuiEventArgs, public Description - { - /// Tree node. - controls::tree::INodeProvider* node; - - GuiNodeEventArgs() - :node(0) - { - } - - /// Create an event arguments with and set to a specified value. - /// The speciied value to set and . - GuiNodeEventArgs(GuiGraphicsComposition* composition) - :GuiEventArgs(composition) - ,node(0) - { - } - }; - - /// Node mouse event arguments. - struct GuiNodeMouseEventArgs : public GuiMouseEventArgs, public Description - { - /// Tree node. - controls::tree::INodeProvider* node; - - GuiNodeMouseEventArgs() - :node(0) - { - } - - /// Create an event arguments with and set to a specified value. - /// The speciied value to set and . - GuiNodeMouseEventArgs(GuiGraphicsComposition* composition) - :GuiMouseEventArgs(composition) - ,node(0) - { - } - }; - - typedef GuiGraphicsEvent GuiNodeNotifyEvent; - typedef GuiGraphicsEvent GuiNodeMouseEvent; - -/*********************************************************************** -Event Receiver -***********************************************************************/ - - /// - /// Contains all available user input events for a . Almost all events are routed events. Routed events means, not only the activated composition receives the event, all it direct or indirect parents receives the event. The argument(all derives from ) for the event will store the original event raiser composition. - /// - class GuiGraphicsEventReceiver : public Object - { - protected: - GuiGraphicsComposition* sender; - public: - GuiGraphicsEventReceiver(GuiGraphicsComposition* _sender); - ~GuiGraphicsEventReceiver(); - - GuiGraphicsComposition* GetAssociatedComposition(); - - /// Left mouse button down event. - GuiMouseEvent leftButtonDown; - /// Left mouse button up event. - GuiMouseEvent leftButtonUp; - /// Left mouse button double click event. - GuiMouseEvent leftButtonDoubleClick; - /// Middle mouse button down event. - GuiMouseEvent middleButtonDown; - /// Middle mouse button up event. - GuiMouseEvent middleButtonUp; - /// Middle mouse button double click event. - GuiMouseEvent middleButtonDoubleClick; - /// Right mouse button down event. - GuiMouseEvent rightButtonDown; - /// Right mouse button up event. - GuiMouseEvent rightButtonUp; - /// Right mouse button double click event. - GuiMouseEvent rightButtonDoubleClick; - /// Horizontal wheel scrolling event. - GuiMouseEvent horizontalWheel; - /// Vertical wheel scrolling event. - GuiMouseEvent verticalWheel; - /// Mouse move event. - GuiMouseEvent mouseMove; - /// Mouse enter event. - GuiNotifyEvent mouseEnter; - /// Mouse leave event. - GuiNotifyEvent mouseLeave; - - /// Preview key event. - GuiKeyEvent previewKey; - /// Key down event. - GuiKeyEvent keyDown; - /// Key up event. - GuiKeyEvent keyUp; - /// System key down event. - GuiKeyEvent systemKeyDown; - /// System key up event. - GuiKeyEvent systemKeyUp; - /// Preview char input event. - GuiCharEvent previewCharInput; - /// Char input event. - GuiCharEvent charInput; - /// Got focus event. - GuiNotifyEvent gotFocus; - /// Lost focus event. - GuiNotifyEvent lostFocus; - /// Caret notify event. This event is raised when a caret graph need to change the visibility state. - GuiNotifyEvent caretNotify; - /// Clipboard notify event. This event is raised when the content in the system clipboard is changed. - GuiNotifyEvent clipboardNotify; - /// Render target changed event. This event is raised when the render target of this composition is changed. - GuiNotifyEvent renderTargetChanged; - }; - } - } - - /*********************************************************************** - Workflow to C++ Codegen Helpers - ***********************************************************************/ - - namespace __vwsn - { - template - struct EventHelper> - { - using Event = presentation::compositions::GuiGraphicsEvent; - using Sender = presentation::compositions::GuiGraphicsComposition; - using IGuiGraphicsEventHandler = presentation::compositions::IGuiGraphicsEventHandler; - using Handler = Func; - - class EventHandlerImpl : public Object, public reflection::description::IEventHandler - { - public: - Ptr handler; - - EventHandlerImpl(Ptr _handler) - :handler(_handler) - { - } - - bool IsAttached()override - { - return handler->IsAttached(); - } - }; - - static Ptr Attach(Event& e, Handler handler) - { - return MakePtr(e.AttachLambda([=](Sender* sender, T& args) - { - handler(sender, &args); - })); - } - - static bool Detach(Event& e, Ptr handler) - { - auto impl = handler.Cast(); - if (!impl) return false; - return e.Detach(impl->handler); - } - - static auto Invoke(Event& e) - { - return [&](Sender* sender, T* args) - { - e.ExecuteWithNewSender(*args, sender); - }; - } - }; - } -} - -#endif - -/*********************************************************************** -GRAPHICSCOMPOSITION\GUIGRAPHICSCOMPOSITIONBASE.H +.\GRAPHICSCOMPOSITION\GUIGRAPHICSCOMPOSITIONBASE.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -6736,7 +6740,158 @@ Helper Functions #endif /*********************************************************************** -GRAPHICSCOMPOSITION\GUIGRAPHICSBASICCOMPOSITION.H +.\GRAPHICSCOMPOSITION\GUIGRAPHICSAXIS.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Composition System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSAXIS +#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSAXIS + + +namespace vl +{ + namespace presentation + { + namespace compositions + { + +/*********************************************************************** +Axis Interface +***********************************************************************/ + + /// Represents the four directions that is accessable by keyboard. + enum class KeyDirection + { + /// The up direction. + Up, + /// The down direction. + Down, + /// The left direction. + Left, + /// The right direction. + Right, + /// The home direction. + Home, + /// The end direction. + End, + /// The page up direction. + PageUp, + /// The page down direction. + PageDown, + /// The page left direction. + PageLeft, + /// The page right direction. + PageRight, + }; + + /// Item coordinate transformer for a . In all functions in this interface, real coordinate is in the list control's container space, virtual coordinate is in a space that the transformer created. + class IGuiAxis : public virtual IDescriptable, public Description + { + public: + /// Translate real size to virtual size. + /// The virtual size. + /// The real size. + virtual Size RealSizeToVirtualSize(Size size)=0; + /// Translate virtual size to real size. + /// The real size. + /// The virtual size. + virtual Size VirtualSizeToRealSize(Size size)=0; + /// Translate real point to virtual point. + /// The virtual point. + /// The real full size. + /// The real point. + virtual Point RealPointToVirtualPoint(Size realFullSize, Point point)=0; + /// Translate virtual point to real point. + /// The real point. + /// The real full size. + /// The virtual point. + virtual Point VirtualPointToRealPoint(Size realFullSize, Point point)=0; + /// Translate real bounds to virtual bounds. + /// The virtual bounds. + /// The real full size. + /// The real bounds. + virtual Rect RealRectToVirtualRect(Size realFullSize, Rect rect)=0; + /// Translate virtual bounds to real bounds. + /// The real bounds. + /// The real full size. + /// The virtual bounds. + virtual Rect VirtualRectToRealRect(Size realFullSize, Rect rect)=0; + /// Translate real margin to margin size. + /// The virtual margin. + /// The real margin. + virtual Margin RealMarginToVirtualMargin(Margin margin)=0; + /// Translate virtual margin to margin size. + /// The real margin. + /// The virtual margin. + virtual Margin VirtualMarginToRealMargin(Margin margin)=0; + /// Translate real key direction to virtual key direction. + /// The virtual key direction. + /// The real key direction. + virtual KeyDirection RealKeyDirectionToVirtualKeyDirection(KeyDirection key)=0; + }; + +/*********************************************************************** +Axis Implementation +***********************************************************************/ + + /// Default item coordinate transformer. This transformer doesn't transform any coordinate. + class GuiDefaultAxis : public Object, virtual public IGuiAxis, public Description + { + public: + /// Create the transformer. + GuiDefaultAxis(); + ~GuiDefaultAxis(); + + Size RealSizeToVirtualSize(Size size)override; + Size VirtualSizeToRealSize(Size size)override; + Point RealPointToVirtualPoint(Size realFullSize, Point point)override; + Point VirtualPointToRealPoint(Size realFullSize, Point point)override; + Rect RealRectToVirtualRect(Size realFullSize, Rect rect)override; + Rect VirtualRectToRealRect(Size realFullSize, Rect rect)override; + Margin RealMarginToVirtualMargin(Margin margin)override; + Margin VirtualMarginToRealMargin(Margin margin)override; + KeyDirection RealKeyDirectionToVirtualKeyDirection(KeyDirection key)override; + }; + + /// Axis aligned item coordinate transformer. This transformer transforms coordinates by changing the axis direction. + class GuiAxis : public Object, virtual public IGuiAxis, public Description + { + protected: + AxisDirection axisDirection; + + public: + /// Create the transformer with a specified axis direction. + /// The specified axis direction. + GuiAxis(AxisDirection _axisDirection); + ~GuiAxis(); + + /// Get the specified axis direction. + /// The specified axis direction. + AxisDirection GetDirection(); + Size RealSizeToVirtualSize(Size size)override; + Size VirtualSizeToRealSize(Size size)override; + Point RealPointToVirtualPoint(Size realFullSize, Point point)override; + Point VirtualPointToRealPoint(Size realFullSize, Point point)override; + Rect RealRectToVirtualRect(Size realFullSize, Rect rect)override; + Rect VirtualRectToRealRect(Size realFullSize, Rect rect)override; + Margin RealMarginToVirtualMargin(Margin margin)override; + Margin VirtualMarginToRealMargin(Margin margin)override; + KeyDirection RealKeyDirectionToVirtualKeyDirection(KeyDirection key)override; + }; + } + } +} + +#endif + +/*********************************************************************** +.\GRAPHICSCOMPOSITION\GUIGRAPHICSBASICCOMPOSITION.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -6810,7 +6965,461 @@ Basic Compositions #endif /*********************************************************************** -GRAPHICSCOMPOSITION\GUIGRAPHICSTABLECOMPOSITION.H +.\GRAPHICSCOMPOSITION\GUIGRAPHICSFLOWCOMPOSITION.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Composition System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSFLOWCOMPOSITION +#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSFLOWCOMPOSITION + + +namespace vl +{ + namespace presentation + { + namespace compositions + { + class GuiFlowComposition; + class GuiFlowItemComposition; + +/*********************************************************************** +Flow Compositions +***********************************************************************/ + + /// + /// Alignment for a row in a flow layout + /// + enum class FlowAlignment + { + /// Align to the left. + Left, + /// Align to the center. + Center, + /// Extend to the entire row. + Extend, + }; + + /// + /// Represents a flow composition. + /// + class GuiFlowComposition : public GuiBoundsComposition, public Description + { + friend class GuiFlowItemComposition; + + typedef collections::List ItemCompositionList; + protected: + Margin extraMargin; + vint rowPadding = 0; + vint columnPadding = 0; + FlowAlignment alignment = FlowAlignment::Left; + Ptr axis; + + ItemCompositionList flowItems; + collections::Array flowItemBounds; + Rect bounds; + vint minHeight = 0; + bool needUpdate = false; + + void UpdateFlowItemBounds(bool forceUpdate); + void OnBoundsChanged(GuiGraphicsComposition* sender, GuiEventArgs& arguments); + void OnChildInserted(GuiGraphicsComposition* child)override; + void OnChildRemoved(GuiGraphicsComposition* child)override; + public: + GuiFlowComposition(); + ~GuiFlowComposition(); + + /// Get all flow items inside the flow composition. + /// All flow items inside the flow composition. + const ItemCompositionList& GetFlowItems(); + + /// Get the extra margin inside the flow composition. + /// The extra margin inside the flow composition. + Margin GetExtraMargin(); + /// Set the extra margin inside the flow composition. + /// The extra margin inside the flow composition. + void SetExtraMargin(Margin value); + + /// Get the distance between rows. + /// The distance between rows. + vint GetRowPadding(); + /// Set the distance between rows. + /// The distance between rows. + void SetRowPadding(vint value); + + /// Get the distance between columns. + /// The distance between columns. + vint GetColumnPadding(); + /// Set the distance between columns. + /// The distance between columns. + void SetColumnPadding(vint value); + + /// Get the axis of the layout. + /// The axis. + Ptr GetAxis(); + /// Set the axis of the layout. + /// The axis. + void SetAxis(Ptr value); + + /// Get the alignment for rows. + /// The alignment. + FlowAlignment GetAlignment(); + /// Set the alignment for rows. + /// The alignment. + void SetAlignment(FlowAlignment value); + + void ForceCalculateSizeImmediately()override; + Size GetMinPreferredClientSize()override; + Rect GetBounds()override; + }; + + /// + /// Represnets a base line configuration for a flow item. + /// + struct GuiFlowOption + { + /// Base line calculation algorithm + enum BaselineType + { + /// By percentage of the height from the top. + Percentage, + /// By a distance from the top. + FromTop, + /// By a distance from the bottom. + FromBottom, + }; + + /// The base line calculation algorithm. + BaselineType baseline = FromBottom; + /// The percentage value. + double percentage = 0.0; + /// The distance value. + vint distance = 0; + }; + + /// + /// Represents a flow item composition of a . + /// + class GuiFlowItemComposition : public GuiGraphicsSite, public Description + { + friend class GuiFlowComposition; + protected: + GuiFlowComposition* flowParent; + Rect bounds; + Margin extraMargin; + GuiFlowOption option; + + void OnParentChanged(GuiGraphicsComposition* oldParent, GuiGraphicsComposition* newParent)override; + Size GetMinSize(); + public: + GuiFlowItemComposition(); + ~GuiFlowItemComposition(); + + bool IsSizeAffectParent()override; + Rect GetBounds()override; + void SetBounds(Rect value); + + /// Get the extra margin for this flow item. An extra margin is used to enlarge the bounds of the flow item, but only the non-extra part will be used for deciding the flow item layout. + /// The extra margin for this flow item. + Margin GetExtraMargin(); + /// Set the extra margin for this flow item. An extra margin is used to enlarge the bounds of the flow item, but only the non-extra part will be used for deciding the flow item layout. + /// The extra margin for this flow item. + void SetExtraMargin(Margin value); + + /// Get the base line option for this flow item. + /// The base line option. + GuiFlowOption GetFlowOption(); + /// Set the base line option for this flow item. + /// The base line option. + void SetFlowOption(GuiFlowOption value); + }; + } + } +} + +#endif + + +/*********************************************************************** +.\GRAPHICSCOMPOSITION\GUIGRAPHICSSPECIALIZEDCOMPOSITION.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Composition System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSSPECIALIZEDCOMPOSITION +#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSSPECIALIZEDCOMPOSITION + + +namespace vl +{ + namespace presentation + { + namespace compositions + { + +/*********************************************************************** +Specialized Compositions +***********************************************************************/ + + /// + /// Represents a composition that is aligned to one border of the parent composition. + /// + class GuiSideAlignedComposition : public GuiGraphicsSite, public Description + { + public: + /// The border to align. + enum Direction + { + /// The left border. + Left, + /// The top border. + Top, + /// The right border. + Right, + /// The bottom border. + Bottom, + }; + protected: + Direction direction; + vint maxLength; + double maxRatio; + public: + GuiSideAlignedComposition(); + ~GuiSideAlignedComposition(); + + /// Get the border to align. + /// The border to align. + Direction GetDirection(); + /// Set the border to align. + /// The border to align. + void SetDirection(Direction value); + /// Get the maximum length of this composition. + /// The maximum length of this composition. + vint GetMaxLength(); + /// Set the maximum length of this composition. + /// The maximum length of this composition. + void SetMaxLength(vint value); + /// Get the maximum ratio to limit the size according to the size of the parent. + /// The maximum ratio to limit the size according to the size of the parent. + double GetMaxRatio(); + /// Set the maximum ratio to limit the size according to the size of the parent. + /// The maximum ratio to limit the size according to the size of the parent. + void SetMaxRatio(double value); + + bool IsSizeAffectParent()override; + Rect GetBounds()override; + }; + + /// + /// Represents a composition that its location and size are decided by the client area of the parent composition by setting ratios. + /// + class GuiPartialViewComposition : public GuiGraphicsSite, public Description + { + protected: + double wRatio; + double wPageSize; + double hRatio; + double hPageSize; + + public: + GuiPartialViewComposition(); + ~GuiPartialViewComposition(); + + /// Get the width ratio to decided the horizontal location. Value in [0, 1-pageSize]. + /// The width ratio to decided the horizontal location. + double GetWidthRatio(); + /// Get the page size to decide the horizontal size. Value in [0, 1]. + /// The page size to decide the horizontal size. + double GetWidthPageSize(); + /// Get the height ratio to decided the vertical location. Value in [0, 1-pageSize]. + /// The height ratio to decided the vertical location. + double GetHeightRatio(); + /// Get the page size to decide the vertical size. Value in [0, 1]. + /// The page size to decide the vertical size. + double GetHeightPageSize(); + /// Set the width ratio to decided the horizontal location. Value in [0, 1-pageSize]. + /// The width ratio to decided the horizontal location. + void SetWidthRatio(double value); + /// Set the page size to decide the horizontal size. Value in [0, 1]. + /// The page size to decide the horizontal size. + void SetWidthPageSize(double value); + /// Set the height ratio to decided the vertical location. Value in [0, 1-pageSize]. + /// The height ratio to decided the vertical location. + void SetHeightRatio(double value); + /// Set the page size to decide the vertical size. Value in [0, 1]. + /// The page size to decide the vertical size. + void SetHeightPageSize(double value); + + bool IsSizeAffectParent()override; + Rect GetBounds()override; + }; + } + } +} + +#endif + +/*********************************************************************** +.\GRAPHICSCOMPOSITION\GUIGRAPHICSSTACKCOMPOSITION.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Composition System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSSTACKCOMPOSITION +#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSSTACKCOMPOSITION + + +namespace vl +{ + namespace presentation + { + namespace compositions + { + +/*********************************************************************** +Stack Compositions +***********************************************************************/ + + class GuiStackComposition; + class GuiStackItemComposition; + + /// + /// Represents a stack composition. + /// + class GuiStackComposition : public GuiBoundsComposition, public Description + { + friend class GuiStackItemComposition; + + typedef collections::List ItemCompositionList; + public: + /// Stack item layout direction. + enum Direction + { + /// Stack items is layouted from left to right. + Horizontal, + /// Stack items is layouted from top to bottom. + Vertical, + /// Stack items is layouted from right to left. + ReversedHorizontal, + /// Stack items is layouted from bottom to top. + ReversedVertical, + }; + protected: + Direction direction = Horizontal; + ItemCompositionList stackItems; + GuiStackItemComposition* ensuringVisibleStackItem = nullptr; + + vint padding = 0; + vint adjustment = 0; + Margin extraMargin; + + collections::Array stackItemBounds; + Size stackItemTotalSize; + Rect previousBounds; + + void UpdateStackItemBounds(); + void EnsureStackItemVisible(); + void OnBoundsChanged(GuiGraphicsComposition* sender, GuiEventArgs& arguments); + void OnChildInserted(GuiGraphicsComposition* child)override; + void OnChildRemoved(GuiGraphicsComposition* child)override; + public: + GuiStackComposition(); + ~GuiStackComposition(); + + /// Get all stack items inside the stack composition. + /// All stack items inside the stack composition. + const ItemCompositionList& GetStackItems(); + /// Insert an stack item at a specified position. + /// Returns true if this operation succeeded. + /// The position. + /// The statck item to insert. + bool InsertStackItem(vint index, GuiStackItemComposition* item); + + /// Get the stack item layout direction. + /// The stack item layout direction. + Direction GetDirection(); + /// Set the stack item layout direction. + /// The stack item layout direction. + void SetDirection(Direction value); + /// Get the stack item padding. + /// The stack item padding. + vint GetPadding(); + /// Set the stack item padding. + /// The stack item padding. + void SetPadding(vint value); + + void ForceCalculateSizeImmediately()override; + Size GetMinPreferredClientSize()override; + Rect GetBounds()override; + + /// Get the extra margin inside the stack composition. + /// The extra margin inside the stack composition. + Margin GetExtraMargin(); + /// Set the extra margin inside the stack composition. + /// The extra margin inside the stack composition. + void SetExtraMargin(Margin value); + /// Test is any stack item clipped in the stack direction. + /// Returns true if any stack item is clipped. + bool IsStackItemClipped(); + /// Make an item visible as complete as possible. + /// Returns true if this operation succeeded. + /// The index of the item. + bool EnsureVisible(vint index); + }; + + /// + /// Represents a stack item composition of a . + /// + class GuiStackItemComposition : public GuiGraphicsSite, public Description + { + friend class GuiStackComposition; + protected: + GuiStackComposition* stackParent; + Rect bounds; + Margin extraMargin; + + void OnParentChanged(GuiGraphicsComposition* oldParent, GuiGraphicsComposition* newParent)override; + Size GetMinSize(); + public: + GuiStackItemComposition(); + ~GuiStackItemComposition(); + + bool IsSizeAffectParent()override; + Rect GetBounds()override; + /// Set the expected bounds of a stack item. In most of the cases only the size of the bounds is used. + /// The expected bounds of a stack item. + void SetBounds(Rect value); + + /// Get the extra margin for this stack item. An extra margin is used to enlarge the bounds of the stack item, but only the non-extra part will be used for deciding the stack item layout. + /// The extra margin for this stack item. + Margin GetExtraMargin(); + /// Set the extra margin for this stack item. An extra margin is used to enlarge the bounds of the stack item, but only the non-extra part will be used for deciding the stack item layout. + /// The extra margin for this stack item. + void SetExtraMargin(Margin value); + }; + } + } +} + +#endif + +/*********************************************************************** +.\GRAPHICSCOMPOSITION\GUIGRAPHICSTABLECOMPOSITION.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -7175,611 +7784,7 @@ Table Compositions #endif /*********************************************************************** -GRAPHICSCOMPOSITION\GUIGRAPHICSSTACKCOMPOSITION.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Composition System - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSSTACKCOMPOSITION -#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSSTACKCOMPOSITION - - -namespace vl -{ - namespace presentation - { - namespace compositions - { - -/*********************************************************************** -Stack Compositions -***********************************************************************/ - - class GuiStackComposition; - class GuiStackItemComposition; - - /// - /// Represents a stack composition. - /// - class GuiStackComposition : public GuiBoundsComposition, public Description - { - friend class GuiStackItemComposition; - - typedef collections::List ItemCompositionList; - public: - /// Stack item layout direction. - enum Direction - { - /// Stack items is layouted from left to right. - Horizontal, - /// Stack items is layouted from top to bottom. - Vertical, - /// Stack items is layouted from right to left. - ReversedHorizontal, - /// Stack items is layouted from bottom to top. - ReversedVertical, - }; - protected: - Direction direction = Horizontal; - ItemCompositionList stackItems; - GuiStackItemComposition* ensuringVisibleStackItem = nullptr; - - vint padding = 0; - vint adjustment = 0; - Margin extraMargin; - - collections::Array stackItemBounds; - Size stackItemTotalSize; - Rect previousBounds; - - void UpdateStackItemBounds(); - void EnsureStackItemVisible(); - void OnBoundsChanged(GuiGraphicsComposition* sender, GuiEventArgs& arguments); - void OnChildInserted(GuiGraphicsComposition* child)override; - void OnChildRemoved(GuiGraphicsComposition* child)override; - public: - GuiStackComposition(); - ~GuiStackComposition(); - - /// Get all stack items inside the stack composition. - /// All stack items inside the stack composition. - const ItemCompositionList& GetStackItems(); - /// Insert an stack item at a specified position. - /// Returns true if this operation succeeded. - /// The position. - /// The statck item to insert. - bool InsertStackItem(vint index, GuiStackItemComposition* item); - - /// Get the stack item layout direction. - /// The stack item layout direction. - Direction GetDirection(); - /// Set the stack item layout direction. - /// The stack item layout direction. - void SetDirection(Direction value); - /// Get the stack item padding. - /// The stack item padding. - vint GetPadding(); - /// Set the stack item padding. - /// The stack item padding. - void SetPadding(vint value); - - void ForceCalculateSizeImmediately()override; - Size GetMinPreferredClientSize()override; - Rect GetBounds()override; - - /// Get the extra margin inside the stack composition. - /// The extra margin inside the stack composition. - Margin GetExtraMargin(); - /// Set the extra margin inside the stack composition. - /// The extra margin inside the stack composition. - void SetExtraMargin(Margin value); - /// Test is any stack item clipped in the stack direction. - /// Returns true if any stack item is clipped. - bool IsStackItemClipped(); - /// Make an item visible as complete as possible. - /// Returns true if this operation succeeded. - /// The index of the item. - bool EnsureVisible(vint index); - }; - - /// - /// Represents a stack item composition of a . - /// - class GuiStackItemComposition : public GuiGraphicsSite, public Description - { - friend class GuiStackComposition; - protected: - GuiStackComposition* stackParent; - Rect bounds; - Margin extraMargin; - - void OnParentChanged(GuiGraphicsComposition* oldParent, GuiGraphicsComposition* newParent)override; - Size GetMinSize(); - public: - GuiStackItemComposition(); - ~GuiStackItemComposition(); - - bool IsSizeAffectParent()override; - Rect GetBounds()override; - /// Set the expected bounds of a stack item. In most of the cases only the size of the bounds is used. - /// The expected bounds of a stack item. - void SetBounds(Rect value); - - /// Get the extra margin for this stack item. An extra margin is used to enlarge the bounds of the stack item, but only the non-extra part will be used for deciding the stack item layout. - /// The extra margin for this stack item. - Margin GetExtraMargin(); - /// Set the extra margin for this stack item. An extra margin is used to enlarge the bounds of the stack item, but only the non-extra part will be used for deciding the stack item layout. - /// The extra margin for this stack item. - void SetExtraMargin(Margin value); - }; - } - } -} - -#endif - -/*********************************************************************** -GRAPHICSCOMPOSITION\GUIGRAPHICSAXIS.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Composition System - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSAXIS -#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSAXIS - - -namespace vl -{ - namespace presentation - { - namespace compositions - { - -/*********************************************************************** -Axis Interface -***********************************************************************/ - - /// Represents the four directions that is accessable by keyboard. - enum class KeyDirection - { - /// The up direction. - Up, - /// The down direction. - Down, - /// The left direction. - Left, - /// The right direction. - Right, - /// The home direction. - Home, - /// The end direction. - End, - /// The page up direction. - PageUp, - /// The page down direction. - PageDown, - /// The page left direction. - PageLeft, - /// The page right direction. - PageRight, - }; - - /// Item coordinate transformer for a . In all functions in this interface, real coordinate is in the list control's container space, virtual coordinate is in a space that the transformer created. - class IGuiAxis : public virtual IDescriptable, public Description - { - public: - /// Translate real size to virtual size. - /// The virtual size. - /// The real size. - virtual Size RealSizeToVirtualSize(Size size)=0; - /// Translate virtual size to real size. - /// The real size. - /// The virtual size. - virtual Size VirtualSizeToRealSize(Size size)=0; - /// Translate real point to virtual point. - /// The virtual point. - /// The real full size. - /// The real point. - virtual Point RealPointToVirtualPoint(Size realFullSize, Point point)=0; - /// Translate virtual point to real point. - /// The real point. - /// The real full size. - /// The virtual point. - virtual Point VirtualPointToRealPoint(Size realFullSize, Point point)=0; - /// Translate real bounds to virtual bounds. - /// The virtual bounds. - /// The real full size. - /// The real bounds. - virtual Rect RealRectToVirtualRect(Size realFullSize, Rect rect)=0; - /// Translate virtual bounds to real bounds. - /// The real bounds. - /// The real full size. - /// The virtual bounds. - virtual Rect VirtualRectToRealRect(Size realFullSize, Rect rect)=0; - /// Translate real margin to margin size. - /// The virtual margin. - /// The real margin. - virtual Margin RealMarginToVirtualMargin(Margin margin)=0; - /// Translate virtual margin to margin size. - /// The real margin. - /// The virtual margin. - virtual Margin VirtualMarginToRealMargin(Margin margin)=0; - /// Translate real key direction to virtual key direction. - /// The virtual key direction. - /// The real key direction. - virtual KeyDirection RealKeyDirectionToVirtualKeyDirection(KeyDirection key)=0; - }; - -/*********************************************************************** -Axis Implementation -***********************************************************************/ - - /// Default item coordinate transformer. This transformer doesn't transform any coordinate. - class GuiDefaultAxis : public Object, virtual public IGuiAxis, public Description - { - public: - /// Create the transformer. - GuiDefaultAxis(); - ~GuiDefaultAxis(); - - Size RealSizeToVirtualSize(Size size)override; - Size VirtualSizeToRealSize(Size size)override; - Point RealPointToVirtualPoint(Size realFullSize, Point point)override; - Point VirtualPointToRealPoint(Size realFullSize, Point point)override; - Rect RealRectToVirtualRect(Size realFullSize, Rect rect)override; - Rect VirtualRectToRealRect(Size realFullSize, Rect rect)override; - Margin RealMarginToVirtualMargin(Margin margin)override; - Margin VirtualMarginToRealMargin(Margin margin)override; - KeyDirection RealKeyDirectionToVirtualKeyDirection(KeyDirection key)override; - }; - - /// Axis aligned item coordinate transformer. This transformer transforms coordinates by changing the axis direction. - class GuiAxis : public Object, virtual public IGuiAxis, public Description - { - protected: - AxisDirection axisDirection; - - public: - /// Create the transformer with a specified axis direction. - /// The specified axis direction. - GuiAxis(AxisDirection _axisDirection); - ~GuiAxis(); - - /// Get the specified axis direction. - /// The specified axis direction. - AxisDirection GetDirection(); - Size RealSizeToVirtualSize(Size size)override; - Size VirtualSizeToRealSize(Size size)override; - Point RealPointToVirtualPoint(Size realFullSize, Point point)override; - Point VirtualPointToRealPoint(Size realFullSize, Point point)override; - Rect RealRectToVirtualRect(Size realFullSize, Rect rect)override; - Rect VirtualRectToRealRect(Size realFullSize, Rect rect)override; - Margin RealMarginToVirtualMargin(Margin margin)override; - Margin VirtualMarginToRealMargin(Margin margin)override; - KeyDirection RealKeyDirectionToVirtualKeyDirection(KeyDirection key)override; - }; - } - } -} - -#endif - -/*********************************************************************** -GRAPHICSCOMPOSITION\GUIGRAPHICSFLOWCOMPOSITION.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Composition System - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSFLOWCOMPOSITION -#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSFLOWCOMPOSITION - - -namespace vl -{ - namespace presentation - { - namespace compositions - { - class GuiFlowComposition; - class GuiFlowItemComposition; - -/*********************************************************************** -Flow Compositions -***********************************************************************/ - - /// - /// Alignment for a row in a flow layout - /// - enum class FlowAlignment - { - /// Align to the left. - Left, - /// Align to the center. - Center, - /// Extend to the entire row. - Extend, - }; - - /// - /// Represents a flow composition. - /// - class GuiFlowComposition : public GuiBoundsComposition, public Description - { - friend class GuiFlowItemComposition; - - typedef collections::List ItemCompositionList; - protected: - Margin extraMargin; - vint rowPadding = 0; - vint columnPadding = 0; - FlowAlignment alignment = FlowAlignment::Left; - Ptr axis; - - ItemCompositionList flowItems; - collections::Array flowItemBounds; - Rect bounds; - vint minHeight = 0; - bool needUpdate = false; - - void UpdateFlowItemBounds(bool forceUpdate); - void OnBoundsChanged(GuiGraphicsComposition* sender, GuiEventArgs& arguments); - void OnChildInserted(GuiGraphicsComposition* child)override; - void OnChildRemoved(GuiGraphicsComposition* child)override; - public: - GuiFlowComposition(); - ~GuiFlowComposition(); - - /// Get all flow items inside the flow composition. - /// All flow items inside the flow composition. - const ItemCompositionList& GetFlowItems(); - - /// Get the extra margin inside the flow composition. - /// The extra margin inside the flow composition. - Margin GetExtraMargin(); - /// Set the extra margin inside the flow composition. - /// The extra margin inside the flow composition. - void SetExtraMargin(Margin value); - - /// Get the distance between rows. - /// The distance between rows. - vint GetRowPadding(); - /// Set the distance between rows. - /// The distance between rows. - void SetRowPadding(vint value); - - /// Get the distance between columns. - /// The distance between columns. - vint GetColumnPadding(); - /// Set the distance between columns. - /// The distance between columns. - void SetColumnPadding(vint value); - - /// Get the axis of the layout. - /// The axis. - Ptr GetAxis(); - /// Set the axis of the layout. - /// The axis. - void SetAxis(Ptr value); - - /// Get the alignment for rows. - /// The alignment. - FlowAlignment GetAlignment(); - /// Set the alignment for rows. - /// The alignment. - void SetAlignment(FlowAlignment value); - - void ForceCalculateSizeImmediately()override; - Size GetMinPreferredClientSize()override; - Rect GetBounds()override; - }; - - /// - /// Represnets a base line configuration for a flow item. - /// - struct GuiFlowOption - { - /// Base line calculation algorithm - enum BaselineType - { - /// By percentage of the height from the top. - Percentage, - /// By a distance from the top. - FromTop, - /// By a distance from the bottom. - FromBottom, - }; - - /// The base line calculation algorithm. - BaselineType baseline = FromBottom; - /// The percentage value. - double percentage = 0.0; - /// The distance value. - vint distance = 0; - }; - - /// - /// Represents a flow item composition of a . - /// - class GuiFlowItemComposition : public GuiGraphicsSite, public Description - { - friend class GuiFlowComposition; - protected: - GuiFlowComposition* flowParent; - Rect bounds; - Margin extraMargin; - GuiFlowOption option; - - void OnParentChanged(GuiGraphicsComposition* oldParent, GuiGraphicsComposition* newParent)override; - Size GetMinSize(); - public: - GuiFlowItemComposition(); - ~GuiFlowItemComposition(); - - bool IsSizeAffectParent()override; - Rect GetBounds()override; - void SetBounds(Rect value); - - /// Get the extra margin for this flow item. An extra margin is used to enlarge the bounds of the flow item, but only the non-extra part will be used for deciding the flow item layout. - /// The extra margin for this flow item. - Margin GetExtraMargin(); - /// Set the extra margin for this flow item. An extra margin is used to enlarge the bounds of the flow item, but only the non-extra part will be used for deciding the flow item layout. - /// The extra margin for this flow item. - void SetExtraMargin(Margin value); - - /// Get the base line option for this flow item. - /// The base line option. - GuiFlowOption GetFlowOption(); - /// Set the base line option for this flow item. - /// The base line option. - void SetFlowOption(GuiFlowOption value); - }; - } - } -} - -#endif - -/*********************************************************************** -GRAPHICSCOMPOSITION\GUIGRAPHICSSPECIALIZEDCOMPOSITION.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Composition System - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSSPECIALIZEDCOMPOSITION -#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSSPECIALIZEDCOMPOSITION - - -namespace vl -{ - namespace presentation - { - namespace compositions - { - -/*********************************************************************** -Specialized Compositions -***********************************************************************/ - - /// - /// Represents a composition that is aligned to one border of the parent composition. - /// - class GuiSideAlignedComposition : public GuiGraphicsSite, public Description - { - public: - /// The border to align. - enum Direction - { - /// The left border. - Left, - /// The top border. - Top, - /// The right border. - Right, - /// The bottom border. - Bottom, - }; - protected: - Direction direction; - vint maxLength; - double maxRatio; - public: - GuiSideAlignedComposition(); - ~GuiSideAlignedComposition(); - - /// Get the border to align. - /// The border to align. - Direction GetDirection(); - /// Set the border to align. - /// The border to align. - void SetDirection(Direction value); - /// Get the maximum length of this composition. - /// The maximum length of this composition. - vint GetMaxLength(); - /// Set the maximum length of this composition. - /// The maximum length of this composition. - void SetMaxLength(vint value); - /// Get the maximum ratio to limit the size according to the size of the parent. - /// The maximum ratio to limit the size according to the size of the parent. - double GetMaxRatio(); - /// Set the maximum ratio to limit the size according to the size of the parent. - /// The maximum ratio to limit the size according to the size of the parent. - void SetMaxRatio(double value); - - bool IsSizeAffectParent()override; - Rect GetBounds()override; - }; - - /// - /// Represents a composition that its location and size are decided by the client area of the parent composition by setting ratios. - /// - class GuiPartialViewComposition : public GuiGraphicsSite, public Description - { - protected: - double wRatio; - double wPageSize; - double hRatio; - double hPageSize; - - public: - GuiPartialViewComposition(); - ~GuiPartialViewComposition(); - - /// Get the width ratio to decided the horizontal location. Value in [0, 1-pageSize]. - /// The width ratio to decided the horizontal location. - double GetWidthRatio(); - /// Get the page size to decide the horizontal size. Value in [0, 1]. - /// The page size to decide the horizontal size. - double GetWidthPageSize(); - /// Get the height ratio to decided the vertical location. Value in [0, 1-pageSize]. - /// The height ratio to decided the vertical location. - double GetHeightRatio(); - /// Get the page size to decide the vertical size. Value in [0, 1]. - /// The page size to decide the vertical size. - double GetHeightPageSize(); - /// Set the width ratio to decided the horizontal location. Value in [0, 1-pageSize]. - /// The width ratio to decided the horizontal location. - void SetWidthRatio(double value); - /// Set the page size to decide the horizontal size. Value in [0, 1]. - /// The page size to decide the horizontal size. - void SetWidthPageSize(double value); - /// Set the height ratio to decided the vertical location. Value in [0, 1-pageSize]. - /// The height ratio to decided the vertical location. - void SetHeightRatio(double value); - /// Set the page size to decide the vertical size. Value in [0, 1]. - /// The page size to decide the vertical size. - void SetHeightPageSize(double value); - - bool IsSizeAffectParent()override; - Rect GetBounds()override; - }; - } - } -} - -#endif - -/*********************************************************************** -GRAPHICSCOMPOSITION\GUIGRAPHICSCOMPOSITION.H +.\GRAPHICSCOMPOSITION\GUIGRAPHICSCOMPOSITION.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -7857,396 +7862,7 @@ namespace vl #endif /*********************************************************************** -GRAPHICSELEMENT\GUIGRAPHICSHOST.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Graphics Composition Host - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSHOST -#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSHOST - - -namespace vl -{ - namespace presentation - { - namespace controls - { - class GuiWindow; - } - - namespace compositions - { - -/*********************************************************************** -Animation -***********************************************************************/ - - /// - /// Represents an animation. Use [M:vl.presentation.compositions.GuiGraphicsHost.GetAnimationManager] to access this object. - /// - class IGuiGraphicsAnimation : public virtual IDescriptable, public Description - { - public: - /// Get the total length. - /// The total length. - virtual vint GetTotalLength()=0; - /// Get the current position. Value in [0, TotalLength-1]. This function doesn't return a internal state. It return the suggested current position at the moment this function is called. - /// The current position. - virtual vint GetCurrentPosition()=0; - /// Display a state in the animation with the specified current position and the specified total length. - /// The current position. When this function is called by [T:vl.presentation.compositions.GuiGraphicsAnimationManager], this value comes from . - /// The total length. When this function is called by [T:vl.presentation.compositions.GuiGraphicsAnimationManager], this value comes from . - virtual void Play(vint currentPosition, vint totalLength)=0; - /// Stop the animation. - virtual void Stop()=0; - }; - - /// - /// Animation manager. - /// - class GuiGraphicsAnimationManager : public Object, public Description - { - typedef collections::List> AnimationList; - protected: - AnimationList playingAnimations; - public: - GuiGraphicsAnimationManager(); - ~GuiGraphicsAnimationManager(); - - /// Add a new animation. - /// The new animation to add. - void AddAnimation(Ptr animation); - /// Test is the animation manager contains any alive animation. - /// Returns true if the animation manager contains any alive animation. - bool HasAnimation(); - /// Play all alive animations. Any animation that comes to the end will be removed. - void Play(); - }; - -/*********************************************************************** -Shortcut Key Manager -***********************************************************************/ - - class IGuiShortcutKeyManager; - - /// Shortcut key item. - class IGuiShortcutKeyItem : public virtual IDescriptable, public Description - { - public: - /// Shortcut key executed event. - GuiNotifyEvent Executed; - - /// Get the associated object. - /// The associated shortcut key manager. - virtual IGuiShortcutKeyManager* GetManager()=0; - /// Get the name represents the shortcut key combination for this item. - /// The name represents the shortcut key combination for this item. - virtual WString GetName()=0; - }; - - /// Shortcut key manager item. - class IGuiShortcutKeyManager : public virtual IDescriptable, public Description - { - public: - /// Get the number of shortcut key items that already attached to the manager. - /// T number of shortcut key items that already attached to the manager. - virtual vint GetItemCount()=0; - /// Get the associated with the index. - /// The shortcut key item. - /// The index. - virtual IGuiShortcutKeyItem* GetItem(vint index)=0; - /// Execute shortcut key items using a key event info. - /// Returns true if at least one shortcut key item is executed. - /// The key event info. - virtual bool Execute(const NativeWindowKeyInfo& info)=0; - }; - -/*********************************************************************** -Alt-Combined Shortcut Key Interfaces -***********************************************************************/ - - class IGuiAltActionHost; - - /// IGuiAltAction is the handler when an alt-combined shortcut key is activated. - class IGuiAltAction : public virtual IDescriptable - { - public: - /// The identifier for this service. - static const wchar_t* const Identifier; - - static bool IsLegalAlt(const WString& alt); - - virtual const WString& GetAlt() = 0; - virtual bool IsAltEnabled() = 0; - virtual bool IsAltAvailable() = 0; - virtual GuiGraphicsComposition* GetAltComposition() = 0; - virtual IGuiAltActionHost* GetActivatingAltHost() = 0; - virtual void OnActiveAlt() = 0; - }; - - /// IGuiAltActionContainer enumerates multiple . - class IGuiAltActionContainer : public virtual IDescriptable - { - public: - /// The identifier for this service. - static const wchar_t* const Identifier; - - virtual vint GetAltActionCount() = 0; - virtual IGuiAltAction* GetAltAction(vint index) = 0; - }; - - /// IGuiAltActionHost is an alt-combined shortcut key host. A host can also be entered or leaved, with multiple sub actions enabled or disabled. - class IGuiAltActionHost : public virtual IDescriptable - { - public: - /// The identifier for this service. - static const wchar_t* const Identifier; - - static void CollectAltActionsFromControl(controls::GuiControl* control, collections::Group& actions); - - virtual GuiGraphicsComposition* GetAltComposition() = 0; - virtual IGuiAltActionHost* GetPreviousAltHost() = 0; - virtual void OnActivatedAltHost(IGuiAltActionHost* previousHost) = 0; - virtual void OnDeactivatedAltHost() = 0; - virtual void CollectAltActions(collections::Group& actions) = 0; - }; - -/*********************************************************************** -Host -***********************************************************************/ - - /// - /// GuiGraphicsHost hosts an in an . The composition will fill the whole window. - /// - class GuiGraphicsHost : public Object, private INativeWindowListener, private INativeControllerListener, public Description - { - typedef collections::List CompositionList; - typedef collections::Dictionary AltActionMap; - typedef collections::Dictionary AltControlMap; - typedef GuiGraphicsComposition::GraphicsHostRecord HostRecord; - public: - static const vuint64_t CaretInterval = 500; - protected: - HostRecord hostRecord; - bool supressPaint = false; - bool needRender = true; - - IGuiShortcutKeyManager* shortcutKeyManager; - GuiWindowComposition* windowComposition; - GuiGraphicsComposition* focusedComposition; - Size previousClientSize; - Size minSize; - Point caretPoint; - vuint64_t lastCaretTime; - - GuiGraphicsAnimationManager animationManager; - GuiGraphicsComposition* mouseCaptureComposition; - CompositionList mouseEnterCompositions; - - IGuiAltActionHost* currentAltHost; - AltActionMap currentActiveAltActions; - AltControlMap currentActiveAltTitles; - WString currentAltPrefix; - vint supressAltKey; - - void EnterAltHost(IGuiAltActionHost* host); - void LeaveAltHost(); - bool EnterAltKey(wchar_t key); - void LeaveAltKey(); - void CreateAltTitles(const collections::Group& actions); - vint FilterTitles(); - void ClearAltHost(); - void CloseAltHost(); - void RefreshRelatedHostRecord(INativeWindow* nativeWindow); - - void DisconnectCompositionInternal(GuiGraphicsComposition* composition); - void MouseCapture(const NativeWindowMouseInfo& info); - void MouseUncapture(const NativeWindowMouseInfo& info); - void OnCharInput(const NativeWindowCharInfo& info, GuiGraphicsComposition* composition, GuiCharEvent GuiGraphicsEventReceiver::* eventReceiverEvent); - void OnKeyInput(const NativeWindowKeyInfo& info, GuiGraphicsComposition* composition, GuiKeyEvent GuiGraphicsEventReceiver::* eventReceiverEvent); - void RaiseMouseEvent(GuiMouseEventArgs& arguments, GuiGraphicsComposition* composition, GuiMouseEvent GuiGraphicsEventReceiver::* eventReceiverEvent); - void OnMouseInput(const NativeWindowMouseInfo& info, GuiMouseEvent GuiGraphicsEventReceiver::* eventReceiverEvent); - - private: - INativeWindowListener::HitTestResult HitTest(Point location)override; - void Moving(Rect& bounds, bool fixSizeOnly)override; - void Moved()override; - void Paint()override; - - void LeftButtonDown(const NativeWindowMouseInfo& info)override; - void LeftButtonUp(const NativeWindowMouseInfo& info)override; - void LeftButtonDoubleClick(const NativeWindowMouseInfo& info)override; - void RightButtonDown(const NativeWindowMouseInfo& info)override; - void RightButtonUp(const NativeWindowMouseInfo& info)override; - void RightButtonDoubleClick(const NativeWindowMouseInfo& info)override; - void MiddleButtonDown(const NativeWindowMouseInfo& info)override; - void MiddleButtonUp(const NativeWindowMouseInfo& info)override; - void MiddleButtonDoubleClick(const NativeWindowMouseInfo& info)override; - void HorizontalWheel(const NativeWindowMouseInfo& info)override; - void VerticalWheel(const NativeWindowMouseInfo& info)override; - void MouseMoving(const NativeWindowMouseInfo& info)override; - void MouseEntered()override; - void MouseLeaved()override; - - void KeyDown(const NativeWindowKeyInfo& info)override; - void KeyUp(const NativeWindowKeyInfo& info)override; - void SysKeyDown(const NativeWindowKeyInfo& info)override; - void SysKeyUp(const NativeWindowKeyInfo& info)override; - void Char(const NativeWindowCharInfo& info)override; - - void GlobalTimer()override; - public: - GuiGraphicsHost(); - ~GuiGraphicsHost(); - - /// Get the associated window. - /// The associated window. - INativeWindow* GetNativeWindow(); - /// Associate a window. A will fill and appear in the window. - /// The window to associated. - void SetNativeWindow(INativeWindow* _nativeWindow); - /// Get the main . If a window is associated, everything that put into the main composition will be shown in the window. - /// The main compositoin. - GuiGraphicsComposition* GetMainComposition(); - /// Render the main composition and all content to the associated window. - void Render(bool forceUpdate); - /// Request a rendering - void RequestRender(); - - /// Get the attached with this graphics host. - /// The shortcut key manager. - IGuiShortcutKeyManager* GetShortcutKeyManager(); - /// Attach or detach the associated with this graphics host. When this graphics host is disposing, the associated shortcut key manager will be deleted if exists. - /// The shortcut key manager. Set to null to detach the previous shortcut key manager from this graphics host. - void SetShortcutKeyManager(IGuiShortcutKeyManager* value); - - /// Set the focus composition. A focused composition will receive keyboard messages. - /// Returns true if this operation succeeded. - /// The composition to set focus. This composition should be or in the main composition. - bool SetFocus(GuiGraphicsComposition* composition); - /// Get the focus composition. A focused composition will receive keyboard messages. - /// The focus composition. - GuiGraphicsComposition* GetFocusedComposition(); - /// Get the caret point. A caret point is the position to place the edit box of the activated input method editor. - /// The caret point. - Point GetCaretPoint(); - /// Set the caret point. A caret point is the position to place the edit box of the activated input method editor. - /// The caret point. - /// The point space. If this argument is null, the "value" argument will use the point space of the client area in the main composition. - void SetCaretPoint(Point value, GuiGraphicsComposition* referenceComposition=0); - - /// Get the animation manager. - /// The animation manager. - GuiGraphicsAnimationManager* GetAnimationManager(); - /// Notify that a composition is going to disconnect from this graphics host. Generally this happens when a composition's parent line changes. - /// The composition to disconnect - void DisconnectComposition(GuiGraphicsComposition* composition); - }; - -/*********************************************************************** -Animation Helpers -***********************************************************************/ - - /// - /// Represents a time based animation. - /// - class GuiTimeBasedAnimation : public IGuiGraphicsAnimation, public Description - { - protected: - vuint64_t startTime; - vint length; - public: - /// Create an animation with a specified length in milliseconds. - /// The specified length in milliseconds. - GuiTimeBasedAnimation(vint totalMilliseconds); - ~GuiTimeBasedAnimation(); - - /// Restart an animation with a specified length in milliseconds. - /// The specified length in milliseconds. If the value is -1, it will use the previous length. - void Restart(vint totalMilliseconds=-1); - vint GetTotalLength()override; - vint GetCurrentPosition()override; - }; - -/*********************************************************************** -Shortcut Key Manager Helpers -***********************************************************************/ - - class GuiShortcutKeyManager; - - class GuiShortcutKeyItem : public Object, public IGuiShortcutKeyItem - { - protected: - GuiShortcutKeyManager* shortcutKeyManager; - bool ctrl; - bool shift; - bool alt; - vint key; - - void AttachManager(GuiShortcutKeyManager* manager); - void DetachManager(GuiShortcutKeyManager* manager); - public: - GuiShortcutKeyItem(GuiShortcutKeyManager* _shortcutKeyManager, bool _ctrl, bool _shift, bool _alt, vint _key); - ~GuiShortcutKeyItem(); - - IGuiShortcutKeyManager* GetManager()override; - WString GetName()override; - bool CanActivate(const NativeWindowKeyInfo& info); - bool CanActivate(bool _ctrl, bool _shift, bool _alt, vint _key); - }; - - /// A default implementation for . - class GuiShortcutKeyManager : public Object, public IGuiShortcutKeyManager, public Description - { - typedef collections::List> ShortcutKeyItemList; - protected: - ShortcutKeyItemList shortcutKeyItems; - - public: - /// Create the shortcut key manager. - GuiShortcutKeyManager(); - ~GuiShortcutKeyManager(); - - vint GetItemCount()override; - IGuiShortcutKeyItem* GetItem(vint index)override; - bool Execute(const NativeWindowKeyInfo& info)override; - - /// Create a shortcut key item using a key combination. If the item for the key combination exists, this function returns the item that is created before. - /// The created shortcut key item. - /// Set to true if the CTRL key is required. - /// Set to true if the SHIFT key is required. - /// Set to true if the ALT key is required. - /// The non-control key. - IGuiShortcutKeyItem* CreateShortcut(bool ctrl, bool shift, bool alt, vint key); - /// Destroy a shortcut key item using a key combination - /// Returns true if the manager destroyed a existing shortcut key item. - /// Set to true if the CTRL key is required. - /// Set to true if the SHIFT key is required. - /// Set to true if the ALT key is required. - /// The non-control key. - bool DestroyShortcut(bool ctrl, bool shift, bool alt, vint key); - /// Get a shortcut key item using a key combination. If the item for the key combination does not exist, this function returns null. - /// The shortcut key item. - /// Set to true if the CTRL key is required. - /// Set to true if the SHIFT key is required. - /// Set to true if the ALT key is required. - /// The non-control key. - IGuiShortcutKeyItem* TryGetShortcut(bool ctrl, bool shift, bool alt, vint key); - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\TEMPLATES\GUICONTROLTEMPLATES.H +.\CONTROLS\TEMPLATES\GUICONTROLTEMPLATES.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -8273,9 +7889,16 @@ namespace vl template using TemplateProperty = Func; + namespace templates + { + class GuiTemplate; + } + namespace controls { class GuiListControl; + class GuiControlHost; + class GuiCustomControl; /// The visual state for button. enum class ButtonState @@ -8376,8 +7999,10 @@ namespace vl /// Returns true if this object has been finalized. bool IsFinalized(); - void FinalizeInstanceRecursively(compositions::GuiGraphicsComposition* thisObject); - void FinalizeInstanceRecursively(GuiControl* thisObject); + void FinalizeInstanceRecursively(templates::GuiTemplate* thisObject); + void FinalizeInstanceRecursively(GuiCustomControl* thisObject); + void FinalizeInstanceRecursively(GuiControlHost* thisObject); + void FinalizeGeneralInstance(GuiInstanceRootObject* thisObject); /// Set the resource resolver to connect the current root object to the resource creating it. /// The resource resolver @@ -8869,7 +8494,396 @@ Item Template #endif /*********************************************************************** -CONTROLS\GUIBASICCONTROLS.H +.\GRAPHICSELEMENT\GUIGRAPHICSHOST.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Graphics Composition Host + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSHOST +#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSHOST + + +namespace vl +{ + namespace presentation + { + namespace controls + { + class GuiWindow; + } + + namespace compositions + { + +/*********************************************************************** +Animation +***********************************************************************/ + + /// + /// Represents an animation. Use [M:vl.presentation.compositions.GuiGraphicsHost.GetAnimationManager] to access this object. + /// + class IGuiGraphicsAnimation : public virtual IDescriptable, public Description + { + public: + /// Get the total length. + /// The total length. + virtual vint GetTotalLength()=0; + /// Get the current position. Value in [0, TotalLength-1]. This function doesn't return a internal state. It return the suggested current position at the moment this function is called. + /// The current position. + virtual vint GetCurrentPosition()=0; + /// Display a state in the animation with the specified current position and the specified total length. + /// The current position. When this function is called by [T:vl.presentation.compositions.GuiGraphicsAnimationManager], this value comes from . + /// The total length. When this function is called by [T:vl.presentation.compositions.GuiGraphicsAnimationManager], this value comes from . + virtual void Play(vint currentPosition, vint totalLength)=0; + /// Stop the animation. + virtual void Stop()=0; + }; + + /// + /// Animation manager. + /// + class GuiGraphicsAnimationManager : public Object, public Description + { + typedef collections::List> AnimationList; + protected: + AnimationList playingAnimations; + public: + GuiGraphicsAnimationManager(); + ~GuiGraphicsAnimationManager(); + + /// Add a new animation. + /// The new animation to add. + void AddAnimation(Ptr animation); + /// Test is the animation manager contains any alive animation. + /// Returns true if the animation manager contains any alive animation. + bool HasAnimation(); + /// Play all alive animations. Any animation that comes to the end will be removed. + void Play(); + }; + +/*********************************************************************** +Shortcut Key Manager +***********************************************************************/ + + class IGuiShortcutKeyManager; + + /// Shortcut key item. + class IGuiShortcutKeyItem : public virtual IDescriptable, public Description + { + public: + /// Shortcut key executed event. + GuiNotifyEvent Executed; + + /// Get the associated object. + /// The associated shortcut key manager. + virtual IGuiShortcutKeyManager* GetManager()=0; + /// Get the name represents the shortcut key combination for this item. + /// The name represents the shortcut key combination for this item. + virtual WString GetName()=0; + }; + + /// Shortcut key manager item. + class IGuiShortcutKeyManager : public virtual IDescriptable, public Description + { + public: + /// Get the number of shortcut key items that already attached to the manager. + /// T number of shortcut key items that already attached to the manager. + virtual vint GetItemCount()=0; + /// Get the associated with the index. + /// The shortcut key item. + /// The index. + virtual IGuiShortcutKeyItem* GetItem(vint index)=0; + /// Execute shortcut key items using a key event info. + /// Returns true if at least one shortcut key item is executed. + /// The key event info. + virtual bool Execute(const NativeWindowKeyInfo& info)=0; + }; + +/*********************************************************************** +Alt-Combined Shortcut Key Interfaces +***********************************************************************/ + + class IGuiAltActionHost; + + /// IGuiAltAction is the handler when an alt-combined shortcut key is activated. + class IGuiAltAction : public virtual IDescriptable + { + public: + /// The identifier for this service. + static const wchar_t* const Identifier; + + static bool IsLegalAlt(const WString& alt); + + virtual const WString& GetAlt() = 0; + virtual bool IsAltEnabled() = 0; + virtual bool IsAltAvailable() = 0; + virtual GuiGraphicsComposition* GetAltComposition() = 0; + virtual IGuiAltActionHost* GetActivatingAltHost() = 0; + virtual void OnActiveAlt() = 0; + }; + + /// IGuiAltActionContainer enumerates multiple . + class IGuiAltActionContainer : public virtual IDescriptable + { + public: + /// The identifier for this service. + static const wchar_t* const Identifier; + + virtual vint GetAltActionCount() = 0; + virtual IGuiAltAction* GetAltAction(vint index) = 0; + }; + + /// IGuiAltActionHost is an alt-combined shortcut key host. A host can also be entered or leaved, with multiple sub actions enabled or disabled. + class IGuiAltActionHost : public virtual IDescriptable + { + public: + /// The identifier for this service. + static const wchar_t* const Identifier; + + static void CollectAltActionsFromControl(controls::GuiControl* control, collections::Group& actions); + + virtual GuiGraphicsComposition* GetAltComposition() = 0; + virtual IGuiAltActionHost* GetPreviousAltHost() = 0; + virtual void OnActivatedAltHost(IGuiAltActionHost* previousHost) = 0; + virtual void OnDeactivatedAltHost() = 0; + virtual void CollectAltActions(collections::Group& actions) = 0; + }; + +/*********************************************************************** +Host +***********************************************************************/ + + /// + /// GuiGraphicsHost hosts an in an . The composition will fill the whole window. + /// + class GuiGraphicsHost : public Object, private INativeWindowListener, private INativeControllerListener, public Description + { + typedef collections::List CompositionList; + typedef collections::Dictionary AltActionMap; + typedef collections::Dictionary AltControlMap; + typedef GuiGraphicsComposition::GraphicsHostRecord HostRecord; + public: + static const vuint64_t CaretInterval = 500; + protected: + HostRecord hostRecord; + bool supressPaint = false; + bool needRender = true; + + IGuiShortcutKeyManager* shortcutKeyManager; + GuiWindowComposition* windowComposition; + GuiGraphicsComposition* focusedComposition; + Size previousClientSize; + Size minSize; + Point caretPoint; + vuint64_t lastCaretTime; + + GuiGraphicsAnimationManager animationManager; + GuiGraphicsComposition* mouseCaptureComposition; + CompositionList mouseEnterCompositions; + + IGuiAltActionHost* currentAltHost; + AltActionMap currentActiveAltActions; + AltControlMap currentActiveAltTitles; + WString currentAltPrefix; + vint supressAltKey; + + void EnterAltHost(IGuiAltActionHost* host); + void LeaveAltHost(); + bool EnterAltKey(wchar_t key); + void LeaveAltKey(); + void CreateAltTitles(const collections::Group& actions); + vint FilterTitles(); + void ClearAltHost(); + void CloseAltHost(); + void RefreshRelatedHostRecord(INativeWindow* nativeWindow); + + void DisconnectCompositionInternal(GuiGraphicsComposition* composition); + void MouseCapture(const NativeWindowMouseInfo& info); + void MouseUncapture(const NativeWindowMouseInfo& info); + void OnCharInput(const NativeWindowCharInfo& info, GuiGraphicsComposition* composition, GuiCharEvent GuiGraphicsEventReceiver::* eventReceiverEvent); + void OnKeyInput(const NativeWindowKeyInfo& info, GuiGraphicsComposition* composition, GuiKeyEvent GuiGraphicsEventReceiver::* eventReceiverEvent); + void RaiseMouseEvent(GuiMouseEventArgs& arguments, GuiGraphicsComposition* composition, GuiMouseEvent GuiGraphicsEventReceiver::* eventReceiverEvent); + void OnMouseInput(const NativeWindowMouseInfo& info, GuiMouseEvent GuiGraphicsEventReceiver::* eventReceiverEvent); + + private: + INativeWindowListener::HitTestResult HitTest(Point location)override; + void Moving(Rect& bounds, bool fixSizeOnly)override; + void Moved()override; + void Paint()override; + + void LeftButtonDown(const NativeWindowMouseInfo& info)override; + void LeftButtonUp(const NativeWindowMouseInfo& info)override; + void LeftButtonDoubleClick(const NativeWindowMouseInfo& info)override; + void RightButtonDown(const NativeWindowMouseInfo& info)override; + void RightButtonUp(const NativeWindowMouseInfo& info)override; + void RightButtonDoubleClick(const NativeWindowMouseInfo& info)override; + void MiddleButtonDown(const NativeWindowMouseInfo& info)override; + void MiddleButtonUp(const NativeWindowMouseInfo& info)override; + void MiddleButtonDoubleClick(const NativeWindowMouseInfo& info)override; + void HorizontalWheel(const NativeWindowMouseInfo& info)override; + void VerticalWheel(const NativeWindowMouseInfo& info)override; + void MouseMoving(const NativeWindowMouseInfo& info)override; + void MouseEntered()override; + void MouseLeaved()override; + + void KeyDown(const NativeWindowKeyInfo& info)override; + void KeyUp(const NativeWindowKeyInfo& info)override; + void SysKeyDown(const NativeWindowKeyInfo& info)override; + void SysKeyUp(const NativeWindowKeyInfo& info)override; + void Char(const NativeWindowCharInfo& info)override; + + void GlobalTimer()override; + public: + GuiGraphicsHost(); + ~GuiGraphicsHost(); + + /// Get the associated window. + /// The associated window. + INativeWindow* GetNativeWindow(); + /// Associate a window. A will fill and appear in the window. + /// The window to associated. + void SetNativeWindow(INativeWindow* _nativeWindow); + /// Get the main . If a window is associated, everything that put into the main composition will be shown in the window. + /// The main compositoin. + GuiGraphicsComposition* GetMainComposition(); + /// Render the main composition and all content to the associated window. + void Render(bool forceUpdate); + /// Request a rendering + void RequestRender(); + + /// Get the attached with this graphics host. + /// The shortcut key manager. + IGuiShortcutKeyManager* GetShortcutKeyManager(); + /// Attach or detach the associated with this graphics host. When this graphics host is disposing, the associated shortcut key manager will be deleted if exists. + /// The shortcut key manager. Set to null to detach the previous shortcut key manager from this graphics host. + void SetShortcutKeyManager(IGuiShortcutKeyManager* value); + + /// Set the focus composition. A focused composition will receive keyboard messages. + /// Returns true if this operation succeeded. + /// The composition to set focus. This composition should be or in the main composition. + bool SetFocus(GuiGraphicsComposition* composition); + /// Get the focus composition. A focused composition will receive keyboard messages. + /// The focus composition. + GuiGraphicsComposition* GetFocusedComposition(); + /// Get the caret point. A caret point is the position to place the edit box of the activated input method editor. + /// The caret point. + Point GetCaretPoint(); + /// Set the caret point. A caret point is the position to place the edit box of the activated input method editor. + /// The caret point. + /// The point space. If this argument is null, the "value" argument will use the point space of the client area in the main composition. + void SetCaretPoint(Point value, GuiGraphicsComposition* referenceComposition=0); + + /// Get the animation manager. + /// The animation manager. + GuiGraphicsAnimationManager* GetAnimationManager(); + /// Notify that a composition is going to disconnect from this graphics host. Generally this happens when a composition's parent line changes. + /// The composition to disconnect + void DisconnectComposition(GuiGraphicsComposition* composition); + }; + +/*********************************************************************** +Animation Helpers +***********************************************************************/ + + /// + /// Represents a time based animation. + /// + class GuiTimeBasedAnimation : public IGuiGraphicsAnimation, public Description + { + protected: + vuint64_t startTime; + vint length; + public: + /// Create an animation with a specified length in milliseconds. + /// The specified length in milliseconds. + GuiTimeBasedAnimation(vint totalMilliseconds); + ~GuiTimeBasedAnimation(); + + /// Restart an animation with a specified length in milliseconds. + /// The specified length in milliseconds. If the value is -1, it will use the previous length. + void Restart(vint totalMilliseconds=-1); + vint GetTotalLength()override; + vint GetCurrentPosition()override; + }; + +/*********************************************************************** +Shortcut Key Manager Helpers +***********************************************************************/ + + class GuiShortcutKeyManager; + + class GuiShortcutKeyItem : public Object, public IGuiShortcutKeyItem + { + protected: + GuiShortcutKeyManager* shortcutKeyManager; + bool ctrl; + bool shift; + bool alt; + vint key; + + void AttachManager(GuiShortcutKeyManager* manager); + void DetachManager(GuiShortcutKeyManager* manager); + public: + GuiShortcutKeyItem(GuiShortcutKeyManager* _shortcutKeyManager, bool _ctrl, bool _shift, bool _alt, vint _key); + ~GuiShortcutKeyItem(); + + IGuiShortcutKeyManager* GetManager()override; + WString GetName()override; + bool CanActivate(const NativeWindowKeyInfo& info); + bool CanActivate(bool _ctrl, bool _shift, bool _alt, vint _key); + }; + + /// A default implementation for . + class GuiShortcutKeyManager : public Object, public IGuiShortcutKeyManager, public Description + { + typedef collections::List> ShortcutKeyItemList; + protected: + ShortcutKeyItemList shortcutKeyItems; + + public: + /// Create the shortcut key manager. + GuiShortcutKeyManager(); + ~GuiShortcutKeyManager(); + + vint GetItemCount()override; + IGuiShortcutKeyItem* GetItem(vint index)override; + bool Execute(const NativeWindowKeyInfo& info)override; + + /// Create a shortcut key item using a key combination. If the item for the key combination exists, this function returns the item that is created before. + /// The created shortcut key item. + /// Set to true if the CTRL key is required. + /// Set to true if the SHIFT key is required. + /// Set to true if the ALT key is required. + /// The non-control key. + IGuiShortcutKeyItem* CreateShortcut(bool ctrl, bool shift, bool alt, vint key); + /// Destroy a shortcut key item using a key combination + /// Returns true if the manager destroyed a existing shortcut key item. + /// Set to true if the CTRL key is required. + /// Set to true if the SHIFT key is required. + /// Set to true if the ALT key is required. + /// The non-control key. + bool DestroyShortcut(bool ctrl, bool shift, bool alt, vint key); + /// Get a shortcut key item using a key combination. If the item for the key combination does not exist, this function returns null. + /// The shortcut key item. + /// Set to true if the CTRL key is required. + /// Set to true if the SHIFT key is required. + /// Set to true if the ALT key is required. + /// The non-control key. + IGuiShortcutKeyItem* TryGetShortcut(bool ctrl, bool shift, bool alt, vint key); + }; + } + } +} + +#endif + +/*********************************************************************** +.\CONTROLS\GUIBASICCONTROLS.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -9183,8 +9197,501 @@ Basic Construction #endif + /*********************************************************************** -CONTROLS\GUILABELCONTROLS.H +.\CONTROLS\GUIBUTTONCONTROLS.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Control System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_CONTROLS_GUIBUTTONCONTROLS +#define VCZH_PRESENTATION_CONTROLS_GUIBUTTONCONTROLS + + +namespace vl +{ + namespace presentation + { + namespace controls + { + +/*********************************************************************** +Buttons +***********************************************************************/ + + /// A control with 3 phases state transffering when mouse click happens. + class GuiButton : public GuiControl, public Description + { + public: + /// Style controller interface for . + class IStyleController : virtual public GuiControl::IStyleController, public Description + { + public: + /// Called when the control state changed. + /// The new control state. + virtual void Transfer(ButtonState value) = 0; + }; + protected: + IStyleController* styleController; + bool clickOnMouseUp; + bool mousePressing; + bool mouseHoving; + ButtonState controlState; + + void OnParentLineChanged()override; + void OnActiveAlt()override; + void UpdateControlState(); + void OnLeftButtonDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); + void OnLeftButtonUp(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); + void OnMouseEnter(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void OnMouseLeave(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + public: + /// Create a control with a specified style controller. + /// The style controller. + GuiButton(IStyleController* _styleController); + ~GuiButton(); + + /// Mouse click event. + compositions::GuiNotifyEvent Clicked; + + /// Test is the event raised when left mouse button up. + /// Returns true if this event is raised when left mouse button up + bool GetClickOnMouseUp(); + /// Set is the event raised when left mouse button up or not. + /// Set to true to make this event raised when left mouse button up + void SetClickOnMouseUp(bool value); + }; + + /// A with a selection state. + class GuiSelectableButton : public GuiButton, public Description + { + public: + /// Style controller interface for . + class IStyleController : public virtual GuiButton::IStyleController, public Description + { + public: + /// Called when the selection state changed. + /// The new control state. + virtual void SetSelected(bool value) = 0; + }; + + /// Selection group controller. Control the selection state of all attached button. + class GroupController : public GuiComponent, public Description + { + protected: + collections::List buttons; + public: + GroupController(); + ~GroupController(); + + /// Called when the group controller is attached to a . use [M:vl.presentation.controls.GuiSelectableButton.SetGroupController] to attach or detach a group controller to or from a selectable button. + /// The button to attach. + virtual void Attach(GuiSelectableButton* button); + /// Called when the group controller is deteched to a . use [M:vl.presentation.controls.GuiSelectableButton.SetGroupController] to attach or detach a group controller to or from a selectable button. + /// The button to detach. + virtual void Detach(GuiSelectableButton* button); + /// Called when the selection state of any changed. + /// The button that changed the selection state. + virtual void OnSelectedChanged(GuiSelectableButton* button) = 0; + }; + + /// A mutex group controller, usually for radio buttons. + class MutexGroupController : public GroupController, public Description + { + protected: + bool suppress; + public: + MutexGroupController(); + ~MutexGroupController(); + + void OnSelectedChanged(GuiSelectableButton* button)override; + }; + + protected: + IStyleController* styleController; + GroupController* groupController; + bool autoSelection; + bool isSelected; + + void OnClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + public: + /// Create a control with a specified style controller. + /// The style controller. + GuiSelectableButton(IStyleController* _styleController); + ~GuiSelectableButton(); + + /// Group controller changed event. + compositions::GuiNotifyEvent GroupControllerChanged; + /// Auto selection changed event. + compositions::GuiNotifyEvent AutoSelectionChanged; + /// Selected changed event. + compositions::GuiNotifyEvent SelectedChanged; + + /// Get the attached group controller. + /// The attached group controller. + virtual GroupController* GetGroupController(); + /// Set the attached group controller. + /// The attached group controller. + virtual void SetGroupController(GroupController* value); + + /// Get the auto selection state. True if the button is automatically selected or unselected when the button is clicked. + /// The auto selection state. + virtual bool GetAutoSelection(); + /// Set the auto selection state. True if the button is automatically selected or unselected when the button is clicked. + /// The auto selection state. + virtual void SetAutoSelection(bool value); + + /// Get the selected state. + /// The selected state. + virtual bool GetSelected(); + /// Set the selected state. + /// The selected state. + virtual void SetSelected(bool value); + }; + } + } +} + +#endif + + +/*********************************************************************** +.\CONTROLS\GUIDIALOGS.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Control System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_CONTROLS_GUIDIALOGS +#define VCZH_PRESENTATION_CONTROLS_GUIDIALOGS + + +namespace vl +{ + namespace presentation + { + namespace controls + { + +/*********************************************************************** +Dialogs +***********************************************************************/ + + /// Base class for dialogs. + class GuiDialogBase abstract : public GuiComponent, public Description + { + protected: + GuiInstanceRootObject* rootObject = nullptr; + + GuiWindow* GetHostWindow(); + public: + GuiDialogBase(); + ~GuiDialogBase(); + + void Attach(GuiInstanceRootObject* _rootObject); + void Detach(GuiInstanceRootObject* _rootObject); + }; + + /// Message dialog. + class GuiMessageDialog : public GuiDialogBase, public Description + { + protected: + INativeDialogService::MessageBoxButtonsInput input = INativeDialogService::DisplayOK; + INativeDialogService::MessageBoxDefaultButton defaultButton = INativeDialogService::DefaultFirst; + INativeDialogService::MessageBoxIcons icon = INativeDialogService::IconNone; + INativeDialogService::MessageBoxModalOptions modalOption = INativeDialogService::ModalWindow; + WString text; + WString title; + + public: + /// Create a message dialog. + GuiMessageDialog(); + ~GuiMessageDialog(); + + /// Get the button combination that appear on the dialog. + /// The button combination. + INativeDialogService::MessageBoxButtonsInput GetInput(); + /// Set the button combination that appear on the dialog. + /// The button combination. + void SetInput(INativeDialogService::MessageBoxButtonsInput value); + + /// Get the default button for the selected button combination. + /// The default button. + INativeDialogService::MessageBoxDefaultButton GetDefaultButton(); + /// Set the default button for the selected button combination. + /// The default button. + void SetDefaultButton(INativeDialogService::MessageBoxDefaultButton value); + + /// Get the icon that appears on the dialog. + /// The icon. + INativeDialogService::MessageBoxIcons GetIcon(); + /// Set the icon that appears on the dialog. + /// The icon. + void SetIcon(INativeDialogService::MessageBoxIcons value); + + /// Get the way that how this dialog disable windows of the current process. + /// The way that how this dialog disable windows of the current process. + INativeDialogService::MessageBoxModalOptions GetModalOption(); + /// Set the way that how this dialog disable windows of the current process. + /// The way that how this dialog disable windows of the current process. + void SetModalOption(INativeDialogService::MessageBoxModalOptions value); + + /// Get the text for the dialog. + /// The text. + const WString& GetText(); + /// Set the text for the dialog. + /// The text. + void SetText(const WString& value); + + /// Get the title for the dialog. + /// The title. + const WString& GetTitle(); + /// Set the title for the dialog. If the title is empty, the dialog will use the title of the window that host this dialog. + /// The title. + void SetTitle(const WString& value); + + /// Show the dialog. + /// Returns the clicked button. + INativeDialogService::MessageBoxButtonsOutput ShowDialog(); + }; + + /// Color dialog. + class GuiColorDialog : public GuiDialogBase, public Description + { + protected: + bool enabledCustomColor = true; + bool openedCustomColor = false; + Color selectedColor; + bool showSelection = true; + collections::List customColors; + + public: + /// Create a color dialog. + GuiColorDialog(); + ~GuiColorDialog(); + + /// Selected color changed event. + compositions::GuiNotifyEvent SelectedColorChanged; + + /// Get if the custom color panel is enabled for the dialog. + /// Returns true if the color panel is enabled for the dialog. + bool GetEnabledCustomColor(); + /// Set if custom color panel is enabled for the dialog. + /// Set to true to enable the custom color panel for the dialog. + void SetEnabledCustomColor(bool value); + + /// Get if the custom color panel is opened by default when it is enabled. + /// Returns true if the custom color panel is opened by default. + bool GetOpenedCustomColor(); + /// Set if the custom color panel is opened by default when it is enabled. + /// Set to true to open custom color panel by default if it is enabled. + void SetOpenedCustomColor(bool value); + + /// Get the selected color. + /// The selected color. + Color GetSelectedColor(); + /// Set the selected color. + /// The selected color. + void SetSelectedColor(Color value); + + /// Get the list to access 16 selected custom colors on the palette. Colors in the list is guaranteed to have exactly 16 items after the dialog is closed. + /// The list to access custom colors on the palette. + collections::List& GetCustomColors(); + + /// Show the dialog. + /// Returns true if the "OK" button is clicked. + bool ShowDialog(); + }; + + /// Font dialog. + class GuiFontDialog : public GuiDialogBase, public Description + { + protected: + FontProperties selectedFont; + Color selectedColor; + bool showSelection = true; + bool showEffect = true; + bool forceFontExist = true; + + public: + /// Create a font dialog. + GuiFontDialog(); + ~GuiFontDialog(); + + /// Selected font changed event. + compositions::GuiNotifyEvent SelectedFontChanged; + /// Selected color changed event. + compositions::GuiNotifyEvent SelectedColorChanged; + + /// Get the selected font. + /// The selected font. + const FontProperties& GetSelectedFont(); + /// Set the selected font. + /// The selected font. + void SetSelectedFont(const FontProperties& value); + + /// Get the selected color. + /// The selected color. + Color GetSelectedColor(); + /// Set the selected color. + /// The selected color. + void SetSelectedColor(Color value); + + /// Get if the selected font is already selected on the dialog when it is opened. + /// Returns true if the selected font is already selected on the dialog when it is opened. + bool GetShowSelection(); + /// Set if the selected font is already selected on the dialog when it is opened. + /// Set to true to select the selected font when the dialog is opened. + void SetShowSelection(bool value); + + /// Get if the font preview is enabled. + /// Returns true if the font preview is enabled. + bool GetShowEffect(); + /// Set if the font preview is enabled. + /// Set to true to enable the font preview. + void SetShowEffect(bool value); + + /// Get if the dialog only accepts an existing font. + /// Returns true if the dialog only accepts an existing font. + bool GetForceFontExist(); + /// Set if the dialog only accepts an existing font. + /// Set to true to let the dialog only accept an existing font. + void SetForceFontExist(bool value); + + /// Show the dialog. + /// Returns true if the "OK" button is clicked. + bool ShowDialog(); + }; + + /// Base class for file dialogs. + class GuiFileDialogBase abstract : public GuiDialogBase, public Description + { + protected: + WString filter = L"All Files (*.*)|*.*"; + vint filterIndex = 0; + bool enabledPreview = false; + WString title; + WString fileName; + WString directory; + WString defaultExtension; + INativeDialogService::FileDialogOptions options; + + public: + GuiFileDialogBase(); + ~GuiFileDialogBase(); + + /// File name changed event. + compositions::GuiNotifyEvent FileNameChanged; + /// Filter index changed event. + compositions::GuiNotifyEvent FilterIndexChanged; + + /// Get the filter. + /// The filter. + const WString& GetFilter(); + /// Set the filter. The filter is formed by pairs of filter name and wildcard concatenated by "|", like "Text Files (*.txt)|*.txt|All Files (*.*)|*.*". + /// The filter. + void SetFilter(const WString& value); + + /// Get the filter index. + /// The filter index. + vint GetFilterIndex(); + /// Set the filter index. + /// The filter index. + void SetFilterIndex(vint value); + + /// Get if the file preview is enabled. + /// Returns true if the file preview is enabled. + bool GetEnabledPreview(); + /// Set if the file preview is enabled. + /// Set to true to enable the file preview. + void SetEnabledPreview(bool value); + + /// Get the title. + /// The title. + WString GetTitle(); + /// Set the title. + /// The title. + void SetTitle(const WString& value); + + /// Get the selected file name. + /// The selected file name. + WString GetFileName(); + /// Set the selected file name. + /// The selected file name. + void SetFileName(const WString& value); + + /// Get the default folder. + /// The default folder. + WString GetDirectory(); + /// Set the default folder. + /// The default folder. + void SetDirectory(const WString& value); + + /// Get the default file extension. + /// The default file extension. + WString GetDefaultExtension(); + /// Set the default file extension like "txt". If the user does not specify a file extension, the default file extension will be appended using "." after the file name. + /// The default file extension. + void SetDefaultExtension(const WString& value); + + /// Get the dialog options. + /// The dialog options. + INativeDialogService::FileDialogOptions GetOptions(); + /// Set the dialog options. + /// The dialog options. + void SetOptions(INativeDialogService::FileDialogOptions value); + }; + + /// Open file dialog. + class GuiOpenFileDialog : public GuiFileDialogBase, public Description + { + protected: + collections::List fileNames; + + public: + /// Create a open file dialog. + GuiOpenFileDialog(); + ~GuiOpenFileDialog(); + + /// Get the list to access multiple selected file names. + /// The list to access multiple selected file names. + collections::List& GetFileNames(); + + /// Show the dialog. + /// Returns true if the "Open" button is clicked. + bool ShowDialog(); + }; + + /// Save file dialog. + class GuiSaveFileDialog : public GuiFileDialogBase, public Description + { + public: + /// Create a save file dialog. + GuiSaveFileDialog(); + ~GuiSaveFileDialog(); + + /// Show the dialog. + /// Returns true if the "Save" button is clicked. + bool ShowDialog(); + }; + } + } +} + +#endif + + +/*********************************************************************** +.\CONTROLS\GUILABELCONTROLS.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -9246,8 +9753,487 @@ Label #endif + /*********************************************************************** -CONTROLS\GUIWINDOWCONTROLS.H +.\CONTROLS\GUISCROLLCONTROLS.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Control System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_CONTROLS_GUISCROLLCONTROLS +#define VCZH_PRESENTATION_CONTROLS_GUISCROLLCONTROLS + + +namespace vl +{ + namespace presentation + { + + namespace controls + { + +/*********************************************************************** +Scrolls +***********************************************************************/ + + /// A scroll control, which represents a one dimension sub range of a whole range. + class GuiScroll : public GuiControl, public Description + { + public: + /// Style controller interface for . + class IStyleController : public virtual GuiControl::IStyleController, public Description + { + public: + /// Called when the command executor is changed. + /// The command executor. + virtual void SetCommandExecutor(IScrollCommandExecutor* value)=0; + /// Called when the total size is changed. + /// The total size. + virtual void SetTotalSize(vint value)=0; + /// Called when the page size is changed. + /// The page size. + virtual void SetPageSize(vint value)=0; + /// Called when the position is changed. + /// The position. + virtual void SetPosition(vint value)=0; + }; + protected: + class CommandExecutor : public Object, public IScrollCommandExecutor + { + protected: + GuiScroll* scroll; + public: + CommandExecutor(GuiScroll* _scroll); + ~CommandExecutor(); + + void SmallDecrease()override; + void SmallIncrease()override; + void BigDecrease()override; + void BigIncrease()override; + + void SetTotalSize(vint value)override; + void SetPageSize(vint value)override; + void SetPosition(vint value)override; + }; + + IStyleController* styleController; + Ptr commandExecutor; + vint totalSize; + vint pageSize; + vint position; + vint smallMove; + vint bigMove; + public: + /// Create a control with a specified style controller. + /// The style controller. + GuiScroll(IStyleController* _styleController); + ~GuiScroll(); + + /// Total size changed event. + compositions::GuiNotifyEvent TotalSizeChanged; + /// Page size changed event. + compositions::GuiNotifyEvent PageSizeChanged; + /// Position changed event. + compositions::GuiNotifyEvent PositionChanged; + /// Small move changed event. + compositions::GuiNotifyEvent SmallMoveChanged; + /// Big move changed event. + compositions::GuiNotifyEvent BigMoveChanged; + + /// Get the total size. + /// The total size. + virtual vint GetTotalSize(); + /// Set the total size. + /// The total size. + virtual void SetTotalSize(vint value); + /// Get the page size. + /// The page size. + virtual vint GetPageSize(); + /// Set the page size. + /// The page size. + virtual void SetPageSize(vint value); + /// Get the position. + /// The position. + virtual vint GetPosition(); + /// Set the position. + /// The position. + virtual void SetPosition(vint value); + /// Get the small move. + /// The small move. + virtual vint GetSmallMove(); + /// Set the small move. + /// The small move. + virtual void SetSmallMove(vint value); + /// Get the big move. + /// The big move. + virtual vint GetBigMove(); + /// Set the big move. + /// The big move. + virtual void SetBigMove(vint value); + + /// Get the minimum possible position. + /// The minimum possible position. + vint GetMinPosition(); + /// Get the maximum possible position. + /// The maximum possible position. + vint GetMaxPosition(); + }; + } + } +} + +#endif + + +/*********************************************************************** +.\CONTROLS\GUICONTAINERCONTROLS.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Control System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_CONTROLS_GUICONTAINERCONTROLS +#define VCZH_PRESENTATION_CONTROLS_GUICONTAINERCONTROLS + + +namespace vl +{ + namespace presentation + { + namespace controls + { +/*********************************************************************** +Tab Control +***********************************************************************/ + + class GuiTabPageList; + class GuiTab; + + /// Represnets a tab page control. + class GuiTabPage : public GuiCustomControl, public AggregatableDescription + { + friend class GuiTabPageList; + friend class GuiTab; + protected: + GuiTab* tab = nullptr; + + bool IsAltAvailable()override; + void OnTextChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void OnAltChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + public: + /// Create a tab page control with a specified style controller. + /// The style controller. + GuiTabPage(IStyleController* _styleController); + ~GuiTabPage(); + }; + + class GuiTabPageList : public collections::ObservableListBase + { + protected: + GuiTab* tab; + + bool QueryInsert(vint index, GuiTabPage* const& value)override; + void AfterInsert(vint index, GuiTabPage* const& value)override; + void BeforeRemove(vint index, GuiTabPage* const& value)override; + public: + GuiTabPageList(GuiTab* _tab); + ~GuiTabPageList(); + }; + + /// Represents a container with multiple named tabs. + class GuiTab : public GuiControl, public Description + { + friend class GuiTabPage; + friend class GuiTabPageList; + public: + + /// Style controller interface for . + class IStyleController : public virtual GuiControl::IStyleController, public Description + { + public: + /// Called when the command executor is changed. + /// The command executor. + virtual void SetCommandExecutor(ITabCommandExecutor* value)=0; + /// Insert a tab header at the specified position. + /// The specified position. + virtual void InsertTab(vint index)=0; + /// Set the text of a tab header at the specified position. + /// The specified position. + /// The text. + virtual void SetTabText(vint index, const WString& value)=0; + /// Remove the tab header at the specified position. + /// The specified position. + virtual void RemoveTab(vint index)=0; + /// Render a tab header at the specified position as selected. + /// The specified position. + virtual void SetSelectedTab(vint index)=0; + /// Set the Alt-combined shortcut key of a tab header at the specified position. + /// The specified position. + /// The Alt-combined shortcut key. + virtual void SetTabAlt(vint index, const WString& value)=0; + /// Get the associated object of a tab header at the specified position. + /// The associated object. + /// The specified position. + virtual compositions::IGuiAltAction* GetTabAltAction(vint index) = 0; + }; + protected: + class CommandExecutor : public Object, public ITabCommandExecutor + { + protected: + GuiTab* tab; + public: + CommandExecutor(GuiTab* _tab); + ~CommandExecutor(); + + void ShowTab(vint index)override; + }; + + Ptr commandExecutor; + IStyleController* styleController = nullptr; + GuiTabPageList tabPages; + GuiTabPage* selectedPage = nullptr; + public: + /// Create a control with a specified style controller. + /// The style controller. + GuiTab(IStyleController* _styleController); + ~GuiTab(); + + /// Selected page changed event. + compositions::GuiNotifyEvent SelectedPageChanged; + + /// Get all pages. + /// All pages. + GuiTabPageList& GetPages(); + + /// Get the selected page. + /// The selected page. + GuiTabPage* GetSelectedPage(); + /// Set the selected page. + /// Returns true if this operation succeeded. + /// The selected page. + bool SetSelectedPage(GuiTabPage* value); + }; + +/*********************************************************************** +Scroll View +***********************************************************************/ + + /// A control with a vertical scroll bar and a horizontal scroll bar to perform partial viewing. + class GuiScrollView : public GuiControl, public Description + { + public: + /// Style provider interface for . + class IStyleProvider : public virtual GuiControl::IStyleProvider, public Description + { + public: + /// Create a control style for the horizontal scroll bar. + /// The created control style for the horizontal scroll bar. + virtual GuiScroll::IStyleController* CreateHorizontalScrollStyle()=0; + /// Create a control style for the vertical scroll bar. + /// The created control style for the vertical scroll bar. + virtual GuiScroll::IStyleController* CreateVerticalScrollStyle()=0; + /// Get the default scroll size for scroll bars, width for vertical, height for horizontal. + /// The default scroll size. + virtual vint GetDefaultScrollSize()=0; + /// Called when the control begins to initialize. The control pass the bounds composition, and the style provider can put background compositions and elements on it, and return a container composition to contain content and scroll bars. + /// A container composition to contain content and scroll bars + /// The bounds composition to install background. + virtual compositions::GuiGraphicsComposition* InstallBackground(compositions::GuiBoundsComposition* boundsComposition)=0; + }; + + /// Style controller for . + class StyleController : public Object, public GuiControl::IStyleController, public Description + { + protected: + Ptr styleProvider; + GuiScrollView* scrollView; + GuiScroll* horizontalScroll; + GuiScroll* verticalScroll; + compositions::GuiBoundsComposition* boundsComposition; + compositions::GuiTableComposition* tableComposition; + compositions::GuiCellComposition* containerCellComposition; + compositions::GuiBoundsComposition* containerComposition; + bool horizontalAlwaysVisible; + bool verticalAlwaysVisible; + + void UpdateTable(); + public: + /// Create a style controller with a specified style provider. + /// The style provider. + StyleController(IStyleProvider* _styleProvider); + ~StyleController(); + + /// Called when the style controller is attched to a . + /// The scroll view control that attached to. + void SetScrollView(GuiScrollView* _scrollView); + /// Called when the view size of the scroll view changed. Scroll bars will be adjusted. + /// The view size. + void AdjustView(Size fullSize); + /// Get the attached style provider. + /// The attached style provider. + IStyleProvider* GetStyleProvider(); + + /// Get the horizontal scroll control. + /// The horizontal scroll control. + GuiScroll* GetHorizontalScroll(); + /// Get the vertical scroll control. + /// The vertical scroll control. + GuiScroll* GetVerticalScroll(); + + compositions::GuiTableComposition* GetInternalTableComposition(); + compositions::GuiBoundsComposition* GetInternalContainerComposition(); + + /// Test is the horizontal scroll bar always visible even the content doesn't exceed the view bounds. + /// Returns true if the horizontal scroll bar always visible even the content doesn't exceed the view bounds + bool GetHorizontalAlwaysVisible(); + /// Set is the horizontal scroll bar always visible even the content doesn't exceed the view bounds. + /// Set to true if the horizontal scroll bar always visible even the content doesn't exceed the view bounds + void SetHorizontalAlwaysVisible(bool value); + /// Test is the vertical scroll bar always visible even the content doesn't exceed the view bounds. + /// Returns true if the vertical scroll bar always visible even the content doesn't exceed the view bounds + bool GetVerticalAlwaysVisible(); + /// Set is the vertical scroll bar always visible even the content doesn't exceed the view bounds. + /// Set to true if the vertical scroll bar always visible even the content doesn't exceed the view bounds + void SetVerticalAlwaysVisible(bool value); + + compositions::GuiBoundsComposition* GetBoundsComposition()override; + compositions::GuiGraphicsComposition* GetContainerComposition()override; + void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; + void SetText(const WString& value)override; + void SetFont(const FontProperties& value)override; + void SetVisuallyEnabled(bool value)override; + }; + protected: + + StyleController* styleController; + bool supressScrolling; + + void OnContainerBoundsChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void OnHorizontalScroll(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void OnVerticalScroll(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void OnHorizontalWheel(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); + void OnVerticalWheel(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); + void CallUpdateView(); + void Initialize(); + + /// Calculate the full size of the content. + /// The full size of the content. + virtual Size QueryFullSize()=0; + /// Update the visible content using a view bounds. The view bounds is in the space from (0,0) to full size. + /// The view bounds. + virtual void UpdateView(Rect viewBounds)=0; + /// Calculate the small move of the scroll bar. + /// The small move of the scroll bar. + virtual vint GetSmallMove(); + /// Calculate the big move of the scroll bar. + /// The big move of the scroll bar. + virtual Size GetBigMove(); + + /// Create a control with a specified style controller. + /// The style controller. + GuiScrollView(StyleController* _styleController); + public: + /// Create a control with a specified style provider. + /// The style provider. + GuiScrollView(IStyleProvider* styleProvider); + ~GuiScrollView(); + + virtual void SetFont(const FontProperties& value); + + /// Force to update contents and scroll bars. + void CalculateView(); + /// Get the view size. + /// The view size. + Size GetViewSize(); + /// Get the view bounds. + /// The view bounds. + Rect GetViewBounds(); + + /// Get the horizontal scroll control. + /// The horizontal scroll control. + GuiScroll* GetHorizontalScroll(); + /// Get the vertical scroll control. + /// The vertical scroll control. + GuiScroll* GetVerticalScroll(); + /// Test is the horizontal scroll bar always visible even the content doesn't exceed the view bounds. + /// Returns true if the horizontal scroll bar always visible even the content doesn't exceed the view bounds + bool GetHorizontalAlwaysVisible(); + /// Set is the horizontal scroll bar always visible even the content doesn't exceed the view bounds. + /// Set to true if the horizontal scroll bar always visible even the content doesn't exceed the view bounds + void SetHorizontalAlwaysVisible(bool value); + /// Test is the vertical scroll bar always visible even the content doesn't exceed the view bounds. + /// Returns true if the vertical scroll bar always visible even the content doesn't exceed the view bounds + bool GetVerticalAlwaysVisible(); + /// Set is the vertical scroll bar always visible even the content doesn't exceed the view bounds. + /// Set to true if the vertical scroll bar always visible even the content doesn't exceed the view bounds + void SetVerticalAlwaysVisible(bool value); + }; + + /// A control container with a vertical scroll bar and a horizontal scroll bar to perform partial viewing. When controls are added, removed, moved or resized, the scroll bars will adjust automatically. + class GuiScrollContainer : public GuiScrollView, public Description + { + public: + /// Style controller for . + class StyleController : public GuiScrollView::StyleController, public Description + { + protected: + compositions::GuiBoundsComposition* controlContainerComposition; + bool extendToFullWidth; + public: + /// Create a style controller with a specified style provider. + /// The style provider. + StyleController(GuiScrollView::IStyleProvider* styleProvider); + ~StyleController(); + + compositions::GuiGraphicsComposition* GetContainerComposition()override; + /// Update sub controls using a specified left-top position of the view bounds. + /// The specified left-top position of the view bounds. + void MoveContainer(Point leftTop); + + /// Test does the content container always extend its width to fill the scroll container. + /// Return true if the content container always extend its width to fill the scroll container. + bool GetExtendToFullWidth(); + /// Set does the content container always extend its width to fill the scroll container. + /// Set to true if the content container always extend its width to fill the scroll container. + void SetExtendToFullWidth(bool value); + }; + + protected: + StyleController* styleController; + + void OnControlContainerBoundsChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + Size QueryFullSize()override; + void UpdateView(Rect viewBounds)override; + public: + /// Create a control with a specified style provider. + /// The style provider. + GuiScrollContainer(GuiScrollContainer::IStyleProvider* styleProvider); + ~GuiScrollContainer(); + + /// Test does the content container always extend its width to fill the scroll container. + /// Return true if the content container always extend its width to fill the scroll container. + bool GetExtendToFullWidth(); + /// Set does the content container always extend its width to fill the scroll container. + /// Set to true if the content container always extend its width to fill the scroll container. + void SetExtendToFullWidth(bool value); + }; + } + } +} + +#endif + +/*********************************************************************** +.\CONTROLS\GUIWINDOWCONTROLS.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -9754,7 +10740,7 @@ Window #endif /*********************************************************************** -CONTROLS\GUIAPPLICATION.H +.\CONTROLS\GUIAPPLICATION.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -9905,10 +10891,14 @@ Plugin class IGuiPlugin : public IDescriptable, public Description { public: + /// Get the name of this plugin. + /// Returns the name of the plugin. + virtual WString GetName() = 0; + /// Get all dependencies of this plugin. + /// To receive all dependencies. + virtual void GetDependencies(collections::List& dependencies) = 0; /// Called when the plugin manager want to load this plugin. virtual void Load()=0; - /// Called after the plugin manager loaded all plugins. - virtual void AfterLoad()=0; /// Called when the plugin manager want to unload this plugin. virtual void Unload()=0; }; @@ -9917,14 +10907,13 @@ Plugin class IGuiPluginManager : public IDescriptable, public Description { public: - /// Add a plugin. + /// Add a plugin before [F:vl.presentation.controls.IGuiPluginManager.Load] is called. /// The plugin. virtual void AddPlugin(Ptr plugin)=0; - /// Load all plugins. + /// Load all plugins, and check if dependencies of all plugins are ready. virtual void Load()=0; /// Unload all plugins. virtual void Unload()=0; - /// Test if all plugins are loaded or not. /// Returns true if all plugins are loaded. virtual bool IsLoaded()=0; }; @@ -9962,648 +10951,16 @@ extern void GuiApplicationMain(); }\ } instance_GuiRegisterPluginClass_##TYPE;\ -#endif +#define GUI_PLUGIN_NAME(NAME)\ + vl::WString GetName()override { return L ## #NAME; }\ + void GetDependencies(vl::collections::List& dependencies)override\ -/*********************************************************************** -CONTROLS\GUIBUTTONCONTROLS.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control System - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_GUIBUTTONCONTROLS -#define VCZH_PRESENTATION_CONTROLS_GUIBUTTONCONTROLS - - -namespace vl -{ - namespace presentation - { - namespace controls - { - -/*********************************************************************** -Buttons -***********************************************************************/ - - /// A control with 3 phases state transffering when mouse click happens. - class GuiButton : public GuiControl, public Description - { - public: - /// Style controller interface for . - class IStyleController : virtual public GuiControl::IStyleController, public Description - { - public: - /// Called when the control state changed. - /// The new control state. - virtual void Transfer(ButtonState value) = 0; - }; - protected: - IStyleController* styleController; - bool clickOnMouseUp; - bool mousePressing; - bool mouseHoving; - ButtonState controlState; - - void OnParentLineChanged()override; - void OnActiveAlt()override; - void UpdateControlState(); - void OnLeftButtonDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); - void OnLeftButtonUp(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); - void OnMouseEnter(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnMouseLeave(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - public: - /// Create a control with a specified style controller. - /// The style controller. - GuiButton(IStyleController* _styleController); - ~GuiButton(); - - /// Mouse click event. - compositions::GuiNotifyEvent Clicked; - - /// Test is the event raised when left mouse button up. - /// Returns true if this event is raised when left mouse button up - bool GetClickOnMouseUp(); - /// Set is the event raised when left mouse button up or not. - /// Set to true to make this event raised when left mouse button up - void SetClickOnMouseUp(bool value); - }; - - /// A with a selection state. - class GuiSelectableButton : public GuiButton, public Description - { - public: - /// Style controller interface for . - class IStyleController : public virtual GuiButton::IStyleController, public Description - { - public: - /// Called when the selection state changed. - /// The new control state. - virtual void SetSelected(bool value) = 0; - }; - - /// Selection group controller. Control the selection state of all attached button. - class GroupController : public GuiComponent, public Description - { - protected: - collections::List buttons; - public: - GroupController(); - ~GroupController(); - - /// Called when the group controller is attached to a . use [M:vl.presentation.controls.GuiSelectableButton.SetGroupController] to attach or detach a group controller to or from a selectable button. - /// The button to attach. - virtual void Attach(GuiSelectableButton* button); - /// Called when the group controller is deteched to a . use [M:vl.presentation.controls.GuiSelectableButton.SetGroupController] to attach or detach a group controller to or from a selectable button. - /// The button to detach. - virtual void Detach(GuiSelectableButton* button); - /// Called when the selection state of any changed. - /// The button that changed the selection state. - virtual void OnSelectedChanged(GuiSelectableButton* button) = 0; - }; - - /// A mutex group controller, usually for radio buttons. - class MutexGroupController : public GroupController, public Description - { - protected: - bool suppress; - public: - MutexGroupController(); - ~MutexGroupController(); - - void OnSelectedChanged(GuiSelectableButton* button)override; - }; - - protected: - IStyleController* styleController; - GroupController* groupController; - bool autoSelection; - bool isSelected; - - void OnClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - public: - /// Create a control with a specified style controller. - /// The style controller. - GuiSelectableButton(IStyleController* _styleController); - ~GuiSelectableButton(); - - /// Group controller changed event. - compositions::GuiNotifyEvent GroupControllerChanged; - /// Auto selection changed event. - compositions::GuiNotifyEvent AutoSelectionChanged; - /// Selected changed event. - compositions::GuiNotifyEvent SelectedChanged; - - /// Get the attached group controller. - /// The attached group controller. - virtual GroupController* GetGroupController(); - /// Set the attached group controller. - /// The attached group controller. - virtual void SetGroupController(GroupController* value); - - /// Get the auto selection state. True if the button is automatically selected or unselected when the button is clicked. - /// The auto selection state. - virtual bool GetAutoSelection(); - /// Set the auto selection state. True if the button is automatically selected or unselected when the button is clicked. - /// The auto selection state. - virtual void SetAutoSelection(bool value); - - /// Get the selected state. - /// The selected state. - virtual bool GetSelected(); - /// Set the selected state. - /// The selected state. - virtual void SetSelected(bool value); - }; - } - } -} +#define GUI_PLUGIN_DEPEND(NAME) dependencies.Add(L ## #NAME) #endif /*********************************************************************** -CONTROLS\GUISCROLLCONTROLS.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control System - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_GUISCROLLCONTROLS -#define VCZH_PRESENTATION_CONTROLS_GUISCROLLCONTROLS - - -namespace vl -{ - namespace presentation - { - - namespace controls - { - -/*********************************************************************** -Scrolls -***********************************************************************/ - - /// A scroll control, which represents a one dimension sub range of a whole range. - class GuiScroll : public GuiControl, public Description - { - public: - /// Style controller interface for . - class IStyleController : public virtual GuiControl::IStyleController, public Description - { - public: - /// Called when the command executor is changed. - /// The command executor. - virtual void SetCommandExecutor(IScrollCommandExecutor* value)=0; - /// Called when the total size is changed. - /// The total size. - virtual void SetTotalSize(vint value)=0; - /// Called when the page size is changed. - /// The page size. - virtual void SetPageSize(vint value)=0; - /// Called when the position is changed. - /// The position. - virtual void SetPosition(vint value)=0; - }; - protected: - class CommandExecutor : public Object, public IScrollCommandExecutor - { - protected: - GuiScroll* scroll; - public: - CommandExecutor(GuiScroll* _scroll); - ~CommandExecutor(); - - void SmallDecrease()override; - void SmallIncrease()override; - void BigDecrease()override; - void BigIncrease()override; - - void SetTotalSize(vint value)override; - void SetPageSize(vint value)override; - void SetPosition(vint value)override; - }; - - IStyleController* styleController; - Ptr commandExecutor; - vint totalSize; - vint pageSize; - vint position; - vint smallMove; - vint bigMove; - public: - /// Create a control with a specified style controller. - /// The style controller. - GuiScroll(IStyleController* _styleController); - ~GuiScroll(); - - /// Total size changed event. - compositions::GuiNotifyEvent TotalSizeChanged; - /// Page size changed event. - compositions::GuiNotifyEvent PageSizeChanged; - /// Position changed event. - compositions::GuiNotifyEvent PositionChanged; - /// Small move changed event. - compositions::GuiNotifyEvent SmallMoveChanged; - /// Big move changed event. - compositions::GuiNotifyEvent BigMoveChanged; - - /// Get the total size. - /// The total size. - virtual vint GetTotalSize(); - /// Set the total size. - /// The total size. - virtual void SetTotalSize(vint value); - /// Get the page size. - /// The page size. - virtual vint GetPageSize(); - /// Set the page size. - /// The page size. - virtual void SetPageSize(vint value); - /// Get the position. - /// The position. - virtual vint GetPosition(); - /// Set the position. - /// The position. - virtual void SetPosition(vint value); - /// Get the small move. - /// The small move. - virtual vint GetSmallMove(); - /// Set the small move. - /// The small move. - virtual void SetSmallMove(vint value); - /// Get the big move. - /// The big move. - virtual vint GetBigMove(); - /// Set the big move. - /// The big move. - virtual void SetBigMove(vint value); - - /// Get the minimum possible position. - /// The minimum possible position. - vint GetMinPosition(); - /// Get the maximum possible position. - /// The maximum possible position. - vint GetMaxPosition(); - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\GUICONTAINERCONTROLS.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control System - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_GUICONTAINERCONTROLS -#define VCZH_PRESENTATION_CONTROLS_GUICONTAINERCONTROLS - - -namespace vl -{ - namespace presentation - { - namespace controls - { -/*********************************************************************** -Tab Control -***********************************************************************/ - - class GuiTabPageList; - class GuiTab; - - /// Represnets a tab page control. - class GuiTabPage : public GuiCustomControl, public AggregatableDescription - { - friend class GuiTabPageList; - friend class GuiTab; - protected: - GuiTab* tab = nullptr; - - bool IsAltAvailable()override; - void OnTextChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnAltChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - public: - /// Create a tab page control with a specified style controller. - /// The style controller. - GuiTabPage(IStyleController* _styleController); - ~GuiTabPage(); - }; - - class GuiTabPageList : public collections::ObservableListBase - { - protected: - GuiTab* tab; - - bool QueryInsert(vint index, GuiTabPage* const& value)override; - void AfterInsert(vint index, GuiTabPage* const& value)override; - void BeforeRemove(vint index, GuiTabPage* const& value)override; - public: - GuiTabPageList(GuiTab* _tab); - ~GuiTabPageList(); - }; - - /// Represents a container with multiple named tabs. - class GuiTab : public GuiControl, public Description - { - friend class GuiTabPage; - friend class GuiTabPageList; - public: - - /// Style controller interface for . - class IStyleController : public virtual GuiControl::IStyleController, public Description - { - public: - /// Called when the command executor is changed. - /// The command executor. - virtual void SetCommandExecutor(ITabCommandExecutor* value)=0; - /// Insert a tab header at the specified position. - /// The specified position. - virtual void InsertTab(vint index)=0; - /// Set the text of a tab header at the specified position. - /// The specified position. - /// The text. - virtual void SetTabText(vint index, const WString& value)=0; - /// Remove the tab header at the specified position. - /// The specified position. - virtual void RemoveTab(vint index)=0; - /// Render a tab header at the specified position as selected. - /// The specified position. - virtual void SetSelectedTab(vint index)=0; - /// Set the Alt-combined shortcut key of a tab header at the specified position. - /// The specified position. - /// The Alt-combined shortcut key. - virtual void SetTabAlt(vint index, const WString& value)=0; - /// Get the associated object of a tab header at the specified position. - /// The associated object. - /// The specified position. - virtual compositions::IGuiAltAction* GetTabAltAction(vint index) = 0; - }; - protected: - class CommandExecutor : public Object, public ITabCommandExecutor - { - protected: - GuiTab* tab; - public: - CommandExecutor(GuiTab* _tab); - ~CommandExecutor(); - - void ShowTab(vint index)override; - }; - - Ptr commandExecutor; - IStyleController* styleController = nullptr; - GuiTabPageList tabPages; - GuiTabPage* selectedPage = nullptr; - public: - /// Create a control with a specified style controller. - /// The style controller. - GuiTab(IStyleController* _styleController); - ~GuiTab(); - - /// Selected page changed event. - compositions::GuiNotifyEvent SelectedPageChanged; - - /// Get all pages. - /// All pages. - GuiTabPageList& GetPages(); - - /// Get the selected page. - /// The selected page. - GuiTabPage* GetSelectedPage(); - /// Set the selected page. - /// Returns true if this operation succeeded. - /// The selected page. - bool SetSelectedPage(GuiTabPage* value); - }; - -/*********************************************************************** -Scroll View -***********************************************************************/ - - /// A control with a vertical scroll bar and a horizontal scroll bar to perform partial viewing. - class GuiScrollView : public GuiControl, public Description - { - public: - /// Style provider interface for . - class IStyleProvider : public virtual GuiControl::IStyleProvider, public Description - { - public: - /// Create a control style for the horizontal scroll bar. - /// The created control style for the horizontal scroll bar. - virtual GuiScroll::IStyleController* CreateHorizontalScrollStyle()=0; - /// Create a control style for the vertical scroll bar. - /// The created control style for the vertical scroll bar. - virtual GuiScroll::IStyleController* CreateVerticalScrollStyle()=0; - /// Get the default scroll size for scroll bars, width for vertical, height for horizontal. - /// The default scroll size. - virtual vint GetDefaultScrollSize()=0; - /// Called when the control begins to initialize. The control pass the bounds composition, and the style provider can put background compositions and elements on it, and return a container composition to contain content and scroll bars. - /// A container composition to contain content and scroll bars - /// The bounds composition to install background. - virtual compositions::GuiGraphicsComposition* InstallBackground(compositions::GuiBoundsComposition* boundsComposition)=0; - }; - - /// Style controller for . - class StyleController : public Object, public GuiControl::IStyleController, public Description - { - protected: - Ptr styleProvider; - GuiScrollView* scrollView; - GuiScroll* horizontalScroll; - GuiScroll* verticalScroll; - compositions::GuiBoundsComposition* boundsComposition; - compositions::GuiTableComposition* tableComposition; - compositions::GuiCellComposition* containerCellComposition; - compositions::GuiBoundsComposition* containerComposition; - bool horizontalAlwaysVisible; - bool verticalAlwaysVisible; - - void UpdateTable(); - public: - /// Create a style controller with a specified style provider. - /// The style provider. - StyleController(IStyleProvider* _styleProvider); - ~StyleController(); - - /// Called when the style controller is attched to a . - /// The scroll view control that attached to. - void SetScrollView(GuiScrollView* _scrollView); - /// Called when the view size of the scroll view changed. Scroll bars will be adjusted. - /// The view size. - void AdjustView(Size fullSize); - /// Get the attached style provider. - /// The attached style provider. - IStyleProvider* GetStyleProvider(); - - /// Get the horizontal scroll control. - /// The horizontal scroll control. - GuiScroll* GetHorizontalScroll(); - /// Get the vertical scroll control. - /// The vertical scroll control. - GuiScroll* GetVerticalScroll(); - - compositions::GuiTableComposition* GetInternalTableComposition(); - compositions::GuiBoundsComposition* GetInternalContainerComposition(); - - /// Test is the horizontal scroll bar always visible even the content doesn't exceed the view bounds. - /// Returns true if the horizontal scroll bar always visible even the content doesn't exceed the view bounds - bool GetHorizontalAlwaysVisible(); - /// Set is the horizontal scroll bar always visible even the content doesn't exceed the view bounds. - /// Set to true if the horizontal scroll bar always visible even the content doesn't exceed the view bounds - void SetHorizontalAlwaysVisible(bool value); - /// Test is the vertical scroll bar always visible even the content doesn't exceed the view bounds. - /// Returns true if the vertical scroll bar always visible even the content doesn't exceed the view bounds - bool GetVerticalAlwaysVisible(); - /// Set is the vertical scroll bar always visible even the content doesn't exceed the view bounds. - /// Set to true if the vertical scroll bar always visible even the content doesn't exceed the view bounds - void SetVerticalAlwaysVisible(bool value); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - }; - protected: - - StyleController* styleController; - bool supressScrolling; - - void OnContainerBoundsChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnHorizontalScroll(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnVerticalScroll(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnHorizontalWheel(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); - void OnVerticalWheel(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); - void CallUpdateView(); - void Initialize(); - - /// Calculate the full size of the content. - /// The full size of the content. - virtual Size QueryFullSize()=0; - /// Update the visible content using a view bounds. The view bounds is in the space from (0,0) to full size. - /// The view bounds. - virtual void UpdateView(Rect viewBounds)=0; - /// Calculate the small move of the scroll bar. - /// The small move of the scroll bar. - virtual vint GetSmallMove(); - /// Calculate the big move of the scroll bar. - /// The big move of the scroll bar. - virtual Size GetBigMove(); - - /// Create a control with a specified style controller. - /// The style controller. - GuiScrollView(StyleController* _styleController); - public: - /// Create a control with a specified style provider. - /// The style provider. - GuiScrollView(IStyleProvider* styleProvider); - ~GuiScrollView(); - - virtual void SetFont(const FontProperties& value); - - /// Force to update contents and scroll bars. - void CalculateView(); - /// Get the view size. - /// The view size. - Size GetViewSize(); - /// Get the view bounds. - /// The view bounds. - Rect GetViewBounds(); - - /// Get the horizontal scroll control. - /// The horizontal scroll control. - GuiScroll* GetHorizontalScroll(); - /// Get the vertical scroll control. - /// The vertical scroll control. - GuiScroll* GetVerticalScroll(); - /// Test is the horizontal scroll bar always visible even the content doesn't exceed the view bounds. - /// Returns true if the horizontal scroll bar always visible even the content doesn't exceed the view bounds - bool GetHorizontalAlwaysVisible(); - /// Set is the horizontal scroll bar always visible even the content doesn't exceed the view bounds. - /// Set to true if the horizontal scroll bar always visible even the content doesn't exceed the view bounds - void SetHorizontalAlwaysVisible(bool value); - /// Test is the vertical scroll bar always visible even the content doesn't exceed the view bounds. - /// Returns true if the vertical scroll bar always visible even the content doesn't exceed the view bounds - bool GetVerticalAlwaysVisible(); - /// Set is the vertical scroll bar always visible even the content doesn't exceed the view bounds. - /// Set to true if the vertical scroll bar always visible even the content doesn't exceed the view bounds - void SetVerticalAlwaysVisible(bool value); - }; - - /// A control container with a vertical scroll bar and a horizontal scroll bar to perform partial viewing. When controls are added, removed, moved or resized, the scroll bars will adjust automatically. - class GuiScrollContainer : public GuiScrollView, public Description - { - public: - /// Style controller for . - class StyleController : public GuiScrollView::StyleController, public Description - { - protected: - compositions::GuiBoundsComposition* controlContainerComposition; - bool extendToFullWidth; - public: - /// Create a style controller with a specified style provider. - /// The style provider. - StyleController(GuiScrollView::IStyleProvider* styleProvider); - ~StyleController(); - - compositions::GuiGraphicsComposition* GetContainerComposition()override; - /// Update sub controls using a specified left-top position of the view bounds. - /// The specified left-top position of the view bounds. - void MoveContainer(Point leftTop); - - /// Test does the content container always extend its width to fill the scroll container. - /// Return true if the content container always extend its width to fill the scroll container. - bool GetExtendToFullWidth(); - /// Set does the content container always extend its width to fill the scroll container. - /// Set to true if the content container always extend its width to fill the scroll container. - void SetExtendToFullWidth(bool value); - }; - - protected: - StyleController* styleController; - - void OnControlContainerBoundsChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - Size QueryFullSize()override; - void UpdateView(Rect viewBounds)override; - public: - /// Create a control with a specified style provider. - /// The style provider. - GuiScrollContainer(GuiScrollContainer::IStyleProvider* styleProvider); - ~GuiScrollContainer(); - - /// Test does the content container always extend its width to fill the scroll container. - /// Return true if the content container always extend its width to fill the scroll container. - bool GetExtendToFullWidth(); - /// Set does the content container always extend its width to fill the scroll container. - /// Set to true if the content container always extend its width to fill the scroll container. - void SetExtendToFullWidth(bool value); - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\LISTCONTROLPACKAGE\GUILISTCONTROLS.H +.\CONTROLS\LISTCONTROLPACKAGE\GUILISTCONTROLS.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -11100,8 +11457,179 @@ Predefined ItemProvider #endif + /*********************************************************************** -CONTROLS\LISTCONTROLPACKAGE\GUITEXTLISTCONTROLS.H +.\CONTROLS\LISTCONTROLPACKAGE\GUILISTCONTROLITEMARRANGERS.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Control System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_CONTROLS_GUILISTCONTROLITEMARRANGERS +#define VCZH_PRESENTATION_CONTROLS_GUILISTCONTROLITEMARRANGERS + + +namespace vl +{ + namespace presentation + { + namespace controls + { + +/*********************************************************************** +Predefined ItemArranger +***********************************************************************/ + + namespace list + { + /// Ranged item arranger. This arranger implements most of the common functionality for those arrangers that display a continuing subset of item at a time. + class RangedItemArrangerBase : public Object, virtual public GuiListControl::IItemArranger, public Description + { + protected: + using ItemStyleRecord = collections::Pair; + typedef collections::List StyleList; + + GuiListControl* listControl = nullptr; + GuiListControl::IItemArrangerCallback* callback = nullptr; + GuiListControl::IItemProvider* itemProvider = nullptr; + + bool suppressOnViewChanged = false; + Rect viewBounds; + vint startIndex = 0; + StyleList visibleStyles; + + protected: + + void InvalidateAdoptedSize(); + vint CalculateAdoptedSize(vint expectedSize, vint count, vint itemSize); + ItemStyleRecord CreateStyle(vint index); + void DeleteStyle(ItemStyleRecord style); + compositions::GuiBoundsComposition* GetStyleBounds(ItemStyleRecord style); + void ClearStyles(); + void OnViewChangedInternal(Rect oldBounds, Rect newBounds); + virtual void RearrangeItemBounds(); + + virtual void BeginPlaceItem(bool forMoving, Rect newBounds, vint& newStartIndex) = 0; + virtual void PlaceItem(bool forMoving, vint index, ItemStyleRecord style, Rect viewBounds, Rect& bounds, Margin& alignmentToParent) = 0; + virtual bool IsItemOutOfViewBounds(vint index, ItemStyleRecord style, Rect bounds, Rect viewBounds) = 0; + virtual bool EndPlaceItem(bool forMoving, Rect newBounds, vint newStartIndex) = 0; + virtual void InvalidateItemSizeCache() = 0; + virtual Size OnCalculateTotalSize() = 0; + public: + /// Create the arranger. + RangedItemArrangerBase(); + ~RangedItemArrangerBase(); + + void OnAttached(GuiListControl::IItemProvider* provider)override; + void OnItemModified(vint start, vint count, vint newCount)override; + void AttachListControl(GuiListControl* value)override; + void DetachListControl()override; + GuiListControl::IItemArrangerCallback* GetCallback()override; + void SetCallback(GuiListControl::IItemArrangerCallback* value)override; + Size GetTotalSize()override; + GuiListControl::ItemStyle* GetVisibleStyle(vint itemIndex)override; + vint GetVisibleIndex(GuiListControl::ItemStyle* style)override; + void OnViewChanged(Rect bounds)override; + }; + + /// Fixed height item arranger. This arranger lists all item with the same height value. This value is the maximum height of all minimum heights of displayed items. + class FixedHeightItemArranger : public RangedItemArrangerBase, public Description + { + private: + vint pi_width = 0; + vint pim_rowHeight = 0; + + protected: + vint rowHeight; + + virtual vint GetWidth(); + virtual vint GetYOffset(); + + void BeginPlaceItem(bool forMoving, Rect newBounds, vint& newStartIndex)override; + void PlaceItem(bool forMoving, vint index, ItemStyleRecord style, Rect viewBounds, Rect& bounds, Margin& alignmentToParent)override; + bool IsItemOutOfViewBounds(vint index, ItemStyleRecord style, Rect bounds, Rect viewBounds)override; + bool EndPlaceItem(bool forMoving, Rect newBounds, vint newStartIndex)override; + void InvalidateItemSizeCache()override; + Size OnCalculateTotalSize()override; + public: + /// Create the arranger. + FixedHeightItemArranger(); + ~FixedHeightItemArranger(); + + vint FindItem(vint itemIndex, compositions::KeyDirection key)override; + bool EnsureItemVisible(vint itemIndex)override; + Size GetAdoptedSize(Size expectedSize)override; + }; + + /// Fixed size multiple columns item arranger. This arranger adjust all items in multiple lines with the same size. The width is the maximum width of all minimum widths of displayed items. The same to height. + class FixedSizeMultiColumnItemArranger : public RangedItemArrangerBase, public Description + { + private: + Size pim_itemSize; + + protected: + Size itemSize; + + void CalculateRange(Size itemSize, Rect bounds, vint count, vint& start, vint& end); + + void BeginPlaceItem(bool forMoving, Rect newBounds, vint& newStartIndex)override; + void PlaceItem(bool forMoving, vint index, ItemStyleRecord style, Rect viewBounds, Rect& bounds, Margin& alignmentToParent)override; + bool IsItemOutOfViewBounds(vint index, ItemStyleRecord style, Rect bounds, Rect viewBounds)override; + bool EndPlaceItem(bool forMoving, Rect newBounds, vint newStartIndex)override; + void InvalidateItemSizeCache()override; + Size OnCalculateTotalSize()override; + public: + /// Create the arranger. + FixedSizeMultiColumnItemArranger(); + ~FixedSizeMultiColumnItemArranger(); + + vint FindItem(vint itemIndex, compositions::KeyDirection key)override; + bool EnsureItemVisible(vint itemIndex)override; + Size GetAdoptedSize(Size expectedSize)override; + }; + + /// Fixed size multiple columns item arranger. This arranger adjust all items in multiple columns with the same height. The height is the maximum width of all minimum height of displayed items. Each item will displayed using its minimum width. + class FixedHeightMultiColumnItemArranger : public RangedItemArrangerBase, public Description + { + private: + vint pi_currentWidth = 0; + vint pi_totalWidth = 0; + vint pim_itemHeight = 0; + + protected: + vint itemHeight; + + void CalculateRange(vint itemHeight, Rect bounds, vint& rows, vint& startColumn); + + void BeginPlaceItem(bool forMoving, Rect newBounds, vint& newStartIndex)override; + void PlaceItem(bool forMoving, vint index, ItemStyleRecord style, Rect viewBounds, Rect& bounds, Margin& alignmentToParent)override; + bool IsItemOutOfViewBounds(vint index, ItemStyleRecord style, Rect bounds, Rect viewBounds)override; + bool EndPlaceItem(bool forMoving, Rect newBounds, vint newStartIndex)override; + void InvalidateItemSizeCache()override; + Size OnCalculateTotalSize()override; + public: + /// Create the arranger. + FixedHeightMultiColumnItemArranger(); + ~FixedHeightMultiColumnItemArranger(); + + vint FindItem(vint itemIndex, compositions::KeyDirection key)override; + bool EnsureItemVisible(vint itemIndex)override; + Size GetAdoptedSize(Size expectedSize)override; + }; + } + } + } +} + +#endif + + +/*********************************************************************** +.\CONTROLS\LISTCONTROLPACKAGE\GUITEXTLISTCONTROLS.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -11339,964 +11867,7 @@ GuiTextList #endif /*********************************************************************** -CONTROLS\LISTCONTROLPACKAGE\GUILISTCONTROLITEMARRANGERS.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control System - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_GUILISTCONTROLITEMARRANGERS -#define VCZH_PRESENTATION_CONTROLS_GUILISTCONTROLITEMARRANGERS - - -namespace vl -{ - namespace presentation - { - namespace controls - { - -/*********************************************************************** -Predefined ItemArranger -***********************************************************************/ - - namespace list - { - /// Ranged item arranger. This arranger implements most of the common functionality for those arrangers that display a continuing subset of item at a time. - class RangedItemArrangerBase : public Object, virtual public GuiListControl::IItemArranger, public Description - { - protected: - using ItemStyleRecord = collections::Pair; - typedef collections::List StyleList; - - GuiListControl* listControl = nullptr; - GuiListControl::IItemArrangerCallback* callback = nullptr; - GuiListControl::IItemProvider* itemProvider = nullptr; - - bool suppressOnViewChanged = false; - Rect viewBounds; - vint startIndex = 0; - StyleList visibleStyles; - - protected: - - void InvalidateAdoptedSize(); - vint CalculateAdoptedSize(vint expectedSize, vint count, vint itemSize); - ItemStyleRecord CreateStyle(vint index); - void DeleteStyle(ItemStyleRecord style); - compositions::GuiBoundsComposition* GetStyleBounds(ItemStyleRecord style); - void ClearStyles(); - void OnViewChangedInternal(Rect oldBounds, Rect newBounds); - virtual void RearrangeItemBounds(); - - virtual void BeginPlaceItem(bool forMoving, Rect newBounds, vint& newStartIndex) = 0; - virtual void PlaceItem(bool forMoving, vint index, ItemStyleRecord style, Rect viewBounds, Rect& bounds, Margin& alignmentToParent) = 0; - virtual bool IsItemOutOfViewBounds(vint index, ItemStyleRecord style, Rect bounds, Rect viewBounds) = 0; - virtual bool EndPlaceItem(bool forMoving, Rect newBounds, vint newStartIndex) = 0; - virtual void InvalidateItemSizeCache() = 0; - virtual Size OnCalculateTotalSize() = 0; - public: - /// Create the arranger. - RangedItemArrangerBase(); - ~RangedItemArrangerBase(); - - void OnAttached(GuiListControl::IItemProvider* provider)override; - void OnItemModified(vint start, vint count, vint newCount)override; - void AttachListControl(GuiListControl* value)override; - void DetachListControl()override; - GuiListControl::IItemArrangerCallback* GetCallback()override; - void SetCallback(GuiListControl::IItemArrangerCallback* value)override; - Size GetTotalSize()override; - GuiListControl::ItemStyle* GetVisibleStyle(vint itemIndex)override; - vint GetVisibleIndex(GuiListControl::ItemStyle* style)override; - void OnViewChanged(Rect bounds)override; - }; - - /// Fixed height item arranger. This arranger lists all item with the same height value. This value is the maximum height of all minimum heights of displayed items. - class FixedHeightItemArranger : public RangedItemArrangerBase, public Description - { - private: - vint pi_width = 0; - vint pim_rowHeight = 0; - - protected: - vint rowHeight; - - virtual vint GetWidth(); - virtual vint GetYOffset(); - - void BeginPlaceItem(bool forMoving, Rect newBounds, vint& newStartIndex)override; - void PlaceItem(bool forMoving, vint index, ItemStyleRecord style, Rect viewBounds, Rect& bounds, Margin& alignmentToParent)override; - bool IsItemOutOfViewBounds(vint index, ItemStyleRecord style, Rect bounds, Rect viewBounds)override; - bool EndPlaceItem(bool forMoving, Rect newBounds, vint newStartIndex)override; - void InvalidateItemSizeCache()override; - Size OnCalculateTotalSize()override; - public: - /// Create the arranger. - FixedHeightItemArranger(); - ~FixedHeightItemArranger(); - - vint FindItem(vint itemIndex, compositions::KeyDirection key)override; - bool EnsureItemVisible(vint itemIndex)override; - Size GetAdoptedSize(Size expectedSize)override; - }; - - /// Fixed size multiple columns item arranger. This arranger adjust all items in multiple lines with the same size. The width is the maximum width of all minimum widths of displayed items. The same to height. - class FixedSizeMultiColumnItemArranger : public RangedItemArrangerBase, public Description - { - private: - Size pim_itemSize; - - protected: - Size itemSize; - - void CalculateRange(Size itemSize, Rect bounds, vint count, vint& start, vint& end); - - void BeginPlaceItem(bool forMoving, Rect newBounds, vint& newStartIndex)override; - void PlaceItem(bool forMoving, vint index, ItemStyleRecord style, Rect viewBounds, Rect& bounds, Margin& alignmentToParent)override; - bool IsItemOutOfViewBounds(vint index, ItemStyleRecord style, Rect bounds, Rect viewBounds)override; - bool EndPlaceItem(bool forMoving, Rect newBounds, vint newStartIndex)override; - void InvalidateItemSizeCache()override; - Size OnCalculateTotalSize()override; - public: - /// Create the arranger. - FixedSizeMultiColumnItemArranger(); - ~FixedSizeMultiColumnItemArranger(); - - vint FindItem(vint itemIndex, compositions::KeyDirection key)override; - bool EnsureItemVisible(vint itemIndex)override; - Size GetAdoptedSize(Size expectedSize)override; - }; - - /// Fixed size multiple columns item arranger. This arranger adjust all items in multiple columns with the same height. The height is the maximum width of all minimum height of displayed items. Each item will displayed using its minimum width. - class FixedHeightMultiColumnItemArranger : public RangedItemArrangerBase, public Description - { - private: - vint pi_currentWidth = 0; - vint pi_totalWidth = 0; - vint pim_itemHeight = 0; - - protected: - vint itemHeight; - - void CalculateRange(vint itemHeight, Rect bounds, vint& rows, vint& startColumn); - - void BeginPlaceItem(bool forMoving, Rect newBounds, vint& newStartIndex)override; - void PlaceItem(bool forMoving, vint index, ItemStyleRecord style, Rect viewBounds, Rect& bounds, Margin& alignmentToParent)override; - bool IsItemOutOfViewBounds(vint index, ItemStyleRecord style, Rect bounds, Rect viewBounds)override; - bool EndPlaceItem(bool forMoving, Rect newBounds, vint newStartIndex)override; - void InvalidateItemSizeCache()override; - Size OnCalculateTotalSize()override; - public: - /// Create the arranger. - FixedHeightMultiColumnItemArranger(); - ~FixedHeightMultiColumnItemArranger(); - - vint FindItem(vint itemIndex, compositions::KeyDirection key)override; - bool EnsureItemVisible(vint itemIndex)override; - Size GetAdoptedSize(Size expectedSize)override; - }; - } - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\TOOLSTRIPPACKAGE\GUIMENUCONTROLS.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control System - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_GUIMENUCONTROLS -#define VCZH_PRESENTATION_CONTROLS_GUIMENUCONTROLS - - -namespace vl -{ - namespace presentation - { - namespace controls - { - -/*********************************************************************** -Menu Service -***********************************************************************/ - - class GuiMenu; - - /// IGuiMenuService is a required service for menu item container. - class IGuiMenuService : public virtual IDescriptable, public Description - { - public: - /// The identifier for this service. - static const wchar_t* const Identifier; - - /// Direction to decide the position for a menu with specified control. - enum Direction - { - /// Aligned to the top or bottom side. - Horizontal, - /// Aligned to the left or right side. - Vertical, - }; - protected: - GuiMenu* openingMenu; - public: - IGuiMenuService(); - - /// Get the parent service. This service represents the parent menu that host the menu item control that contains this menu. - /// The parent service. - virtual IGuiMenuService* GetParentMenuService()=0; - /// Get the preferred direction to open the sub menu. - /// The preferred direction to open the sub menu. - virtual Direction GetPreferredDirection()=0; - /// Test is this menu is active. When an menu is active, the sub menu is automatically opened when the corresponding menu item is opened. - /// Returns true if this menu is active. - virtual bool IsActiveState()=0; - /// Test all sub menu items are actived by mouse down. - /// Returns true if all sub menu items are actived by mouse down. - virtual bool IsSubMenuActivatedByMouseDown()=0; - - /// Called when the menu item is executed. - virtual void MenuItemExecuted(); - /// Get the opening sub menu. - /// The opening sub menu. - virtual GuiMenu* GetOpeningMenu(); - /// Called when the sub menu is opened. - /// The sub menu. - virtual void MenuOpened(GuiMenu* menu); - /// Called when the sub menu is closed. - /// The sub menu. - virtual void MenuClosed(GuiMenu* menu); - }; - -/*********************************************************************** -Menu -***********************************************************************/ - - /// Popup menu. - class GuiMenu : public GuiPopup, private IGuiMenuService, public Description - { - private: - IGuiMenuService* parentMenuService; - - IGuiMenuService* GetParentMenuService()override; - Direction GetPreferredDirection()override; - bool IsActiveState()override; - bool IsSubMenuActivatedByMouseDown()override; - void MenuItemExecuted()override; - protected: - GuiControl* owner; - - void OnDeactivatedAltHost()override; - void MouseClickedOnOtherWindow(GuiWindow* window)override; - void OnWindowOpened(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnWindowClosed(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - public: - /// Create a control with a specified style controller. - /// The style controller. - /// The owner menu item of the parent menu. - GuiMenu(IStyleController* _styleController, GuiControl* _owner); - ~GuiMenu(); - - /// Update the reference to the parent . This function is not required to call outside the menu or menu item control. - void UpdateMenuService(); - IDescriptable* QueryService(const WString& identifier)override; - }; - - /// Menu bar. - class GuiMenuBar : public GuiControl, private IGuiMenuService, public Description - { - private: - IGuiMenuService* GetParentMenuService()override; - Direction GetPreferredDirection()override; - bool IsActiveState()override; - bool IsSubMenuActivatedByMouseDown()override; - public: - /// Create a control with a specified style controller. - /// The style controller. - GuiMenuBar(GuiControl::IStyleController* _styleController); - ~GuiMenuBar(); - - IDescriptable* QueryService(const WString& identifier)override; - }; - -/*********************************************************************** -MenuButton -***********************************************************************/ - - /// Menu item. - class GuiMenuButton : public GuiSelectableButton, public Description - { - public: - /// Style controller interface for . - class IStyleController : public virtual GuiSelectableButton::IStyleController, public Description - { - public: - /// Create a style controller for the sub menu. - /// The style controller for the sub menu. - virtual GuiMenu::IStyleController* CreateSubMenuStyleController()=0; - /// Notify that the sub menu is created or destroyed. - /// Set to true if the sub menu is created. - virtual void SetSubMenuExisting(bool value)=0; - /// Notify that the sub menu is opened or closed. - /// Set to true if the sub menu is opened. - virtual void SetSubMenuOpening(bool value)=0; - /// Get the button control that is expected to be associated with a sub menu. - /// The button control that is expected to be associated with a sub menu. Returns null means that the sub menu will be directly associated to the menu button. - virtual GuiButton* GetSubMenuHost()=0; - /// Notify that the image for the menu button is changed. - /// The image for the menu button. - virtual void SetImage(Ptr value)=0; - /// Notify that the shortcut key text for the menu button is changed. - /// The shortcut key text for the menu button. - virtual void SetShortcutText(const WString& value)=0; - }; - protected: - IStyleController* styleController; - Ptr image; - WString shortcutText; - GuiMenu* subMenu; - bool ownedSubMenu; - Size preferredMenuClientSize; - IGuiMenuService* ownerMenuService; - bool cascadeAction; - - GuiButton* GetSubMenuHost(); - void OpenSubMenuInternal(); - void OnParentLineChanged()override; - bool IsAltAvailable()override; - compositions::IGuiAltActionHost* GetActivatingAltHost()override; - - void OnSubMenuWindowOpened(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnSubMenuWindowClosed(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnMouseEnter(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - - virtual IGuiMenuService::Direction GetSubMenuDirection(); - public: - /// Create a control with a specified style controller. - /// The style controller. - GuiMenuButton(IStyleController* _styleController); - ~GuiMenuButton(); - - /// Sub menu opening changed event. - compositions::GuiNotifyEvent SubMenuOpeningChanged; - /// Image changed event. - compositions::GuiNotifyEvent ImageChanged; - /// Shortcut text changed event. - compositions::GuiNotifyEvent ShortcutTextChanged; - - /// Get the image for the menu button. - /// The image for the menu button. - Ptr GetImage(); - /// Set the image for the menu button. - /// The image for the menu button. - void SetImage(Ptr value); - /// Get the shortcut key text for the menu button. - /// The shortcut key text for the menu button. - const WString& GetShortcutText(); - /// Set the shortcut key text for the menu button. - /// The shortcut key text for the menu button. - void SetShortcutText(const WString& value); - - /// Test does the sub menu exist. - /// Returns true if the sub menu exists. - bool IsSubMenuExists(); - /// Get the sub menu. If the sub menu is not created, it returns null. - /// The sub menu. - GuiMenu* GetSubMenu(); - /// Create the sub menu if necessary. The created sub menu is owned by this menu button. - /// The created sub menu. - /// The style controller for the sub menu. If this argument is null, it will call for a style controller. - GuiMenu* CreateSubMenu(GuiMenu::IStyleController* subMenuStyleController=0); - /// Associate a sub menu if there is no sub menu binded in this menu button. The associated sub menu is not owned by this menu button if the "owned" argument is set to false. - /// The sub menu to associate. - /// Set to true if the menu is expected to be owned. - void SetSubMenu(GuiMenu* value, bool owned); - /// Destroy the sub menu if necessary. - void DestroySubMenu(); - /// Test is the sub menu owned by this menu button. If the sub menu is owned, both deleting this menu button or calling will delete the sub menu. - /// Returns true if the sub menu is owned by this menu button. - bool GetOwnedSubMenu(); - - /// Test is the sub menu opened. - /// Returns true if the sub menu is opened. - bool GetSubMenuOpening(); - /// Open or close the sub menu. - /// Set to true to open the sub menu. - void SetSubMenuOpening(bool value); - - /// Get the preferred client size for the sub menu. - /// The preferred client size for the sub menu. - Size GetPreferredMenuClientSize(); - /// Set the preferred client size for the sub menu. - /// The preferred client size for the sub menu. - void SetPreferredMenuClientSize(Size value); - - /// Test is cascade action enabled. If the cascade action is enabled, when the mouse enter this menu button, the sub menu will be automatically opened if the parent menu is in an active state (see ), closing the sub menu will also close the parent menu. - /// Returns true if cascade action is enabled. - bool GetCascadeAction(); - /// Enable or disable cascade action. - /// Set to true to enable cascade action. - void SetCascadeAction(bool value); - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\LISTCONTROLPACKAGE\GUILISTVIEWCONTROLS.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control System - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_GUILISTVIEWCONTROLS -#define VCZH_PRESENTATION_CONTROLS_GUILISTVIEWCONTROLS - - -namespace vl -{ - namespace presentation - { - namespace controls - { - ///List view column header control for detailed view. - class GuiListViewColumnHeader : public GuiMenuButton, public Description - { - public: - /// Style provider for . - class IStyleController : public virtual GuiMenuButton::IStyleController, public Description - { - public: - /// Notify that the column sorting state is changed. - /// The new column sorting state. - virtual void SetColumnSortingState(ColumnSortingState value)=0; - }; - - protected: - IStyleController* styleController = nullptr; - ColumnSortingState columnSortingState = ColumnSortingState::NotSorted; - - public: - /// Create a control with a specified style controller. - /// The style controller. - GuiListViewColumnHeader(IStyleController* _styleController); - ~GuiListViewColumnHeader(); - - bool IsAltAvailable()override; - - /// Get the column sorting state. - /// The column sorting state. - ColumnSortingState GetColumnSortingState(); - /// Set the column sorting state. - /// The new column sorting state. - void SetColumnSortingState(ColumnSortingState value); - }; - - /// List view base control. All list view controls inherit from this class. is suggested to be the base class of item style providers for list view control. - class GuiListViewBase : public GuiSelectableListControl, public Description - { - public: - /// Style provider for . - class IStyleProvider : public virtual GuiSelectableListControl::IStyleProvider, public Description - { - public: - /// Create a style controller for a column header. - /// The created style controller for a column header. - virtual GuiListViewColumnHeader::IStyleController* CreateColumnStyle()=0; - /// Get the primary text color. - /// The primary text color. - virtual Color GetPrimaryTextColor()=0; - /// Get the secondary text color. - /// The secondary text color. - virtual Color GetSecondaryTextColor()=0; - /// Get the item peparator text color. - /// The item peparator text color. - virtual Color GetItemSeparatorColor()=0; - }; - - protected: - IStyleProvider* styleProvider; - - public: - /// Create a list view base control. - /// The style provider for this control. - /// The item provider for this control. - GuiListViewBase(IStyleProvider* _styleProvider, GuiListControl::IItemProvider* _itemProvider); - ~GuiListViewBase(); - - /// Column clicked event. - compositions::GuiItemNotifyEvent ColumnClicked; - - /// Get the associated style provider. - /// The style provider. - IStyleProvider* GetListViewStyleProvider(); - }; - -/*********************************************************************** -ListView ItemStyleProvider -***********************************************************************/ - - namespace list - { - /// The required view for . - class IListViewItemView : public virtual IDescriptable, public Description - { - public: - /// The identifier for this view. - static const wchar_t* const Identifier; - - /// Get the small image of an item. - /// The small image. - /// The index of the item. - virtual Ptr GetSmallImage(vint itemIndex) = 0; - /// Get the large image of an item. - /// The large image. - /// The index of the item. - virtual Ptr GetLargeImage(vint itemIndex) = 0; - /// Get the text of an item. - /// The text. - /// The index of the item. - virtual WString GetText(vint itemIndex) = 0; - /// Get the sub item text of an item. If the sub item index out of range, it returns an empty string. - /// The sub item text. - /// The index of the item. - /// The sub item index of the item. - virtual WString GetSubItem(vint itemIndex, vint index) = 0; - - /// Get the number of data columns. - /// The number of data columns. - virtual vint GetDataColumnCount() = 0; - /// Get the column index of the index-th data column. - /// The column index. - /// The order of the data column. - virtual vint GetDataColumn(vint index) = 0; - - /// Get the number of all columns. - /// The number of all columns. - virtual vint GetColumnCount() = 0; - /// Get the text of the column. - /// The text of the column. - /// The index of the column. - virtual WString GetColumnText(vint index) = 0; - }; - -/*********************************************************************** -ListViewColumnItemArranger -***********************************************************************/ - - /// List view column item arranger. This arranger contains column headers. When an column header is resized, all items will be notified via the [T:vl.presentation.controls.list.ListViewColumnItemArranger.IColumnItemView] for . - class ListViewColumnItemArranger : public FixedHeightItemArranger, public Description - { - typedef collections::List ColumnHeaderButtonList; - typedef collections::List ColumnHeaderSplitterList; - public: - static const vint SplitterWidth=8; - - /// Callback for [T:vl.presentation.controls.list.ListViewColumnItemArranger.IColumnItemView]. Column item view use this interface to notify column related modification. - class IColumnItemViewCallback : public virtual IDescriptable, public Description - { - public: - /// Called when any column is changed (inserted, removed, text changed, etc.). - virtual void OnColumnChanged()=0; - }; - - /// The required view for . - class IColumnItemView : public virtual IDescriptable, public Description - { - public: - /// The identifier for this view. - static const wchar_t* const Identifier; - - /// Attach an column item view callback to this view. - /// Returns true if this operation succeeded. - /// The column item view callback. - virtual bool AttachCallback(IColumnItemViewCallback* value)=0; - /// Detach an column item view callback from this view. - /// Returns true if this operation succeeded. - /// The column item view callback. - virtual bool DetachCallback(IColumnItemViewCallback* value)=0; - - /// Get the size of the column. - /// The size of the column. - /// The index of the column. - virtual vint GetColumnSize(vint index)=0; - /// Set the size of the column. - /// The index of the column. - /// The new size of the column. - virtual void SetColumnSize(vint index, vint value)=0; - - /// Get the popup binded to the column. - /// The popup binded to the column. - /// The index of the column. - virtual GuiMenu* GetDropdownPopup(vint index)=0; - /// Get the sorting state of the column. - /// The sorting state of the column. - /// The index of the column. - virtual ColumnSortingState GetSortingState(vint index)=0; - }; - protected: - class ColumnItemViewCallback : public Object, public virtual IColumnItemViewCallback - { - protected: - ListViewColumnItemArranger* arranger; - public: - ColumnItemViewCallback(ListViewColumnItemArranger* _arranger); - ~ColumnItemViewCallback(); - - void OnColumnChanged(); - }; - - GuiListViewBase* listView = nullptr; - GuiListViewBase::IStyleProvider* styleProvider = nullptr; - IListViewItemView* listViewItemView = nullptr; - IColumnItemView* columnItemView = nullptr; - Ptr columnItemViewCallback; - compositions::GuiStackComposition* columnHeaders = nullptr; - ColumnHeaderButtonList columnHeaderButtons; - ColumnHeaderSplitterList columnHeaderSplitters; - bool splitterDragging = false; - vint splitterLatestX = 0; - - void ColumnClicked(vint index, compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void ColumnBoundsChanged(vint index, compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void ColumnHeaderSplitterLeftButtonDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); - void ColumnHeaderSplitterLeftButtonUp(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); - void ColumnHeaderSplitterMouseMove(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); - - void RearrangeItemBounds()override; - vint GetWidth()override; - vint GetYOffset()override; - Size OnCalculateTotalSize()override; - void DeleteColumnButtons(); - void RebuildColumns(); - public: - ListViewColumnItemArranger(); - ~ListViewColumnItemArranger(); - - void AttachListControl(GuiListControl* value)override; - void DetachListControl()override; - }; - } - -/*********************************************************************** -ListViewItemProvider -***********************************************************************/ - - namespace list - { - class ListViewItem; - - class ListViewSubItems : public collections::ObservableListBase - { - friend class ListViewItem; - protected: - ListViewItem* owner; - - void NotifyUpdateInternal(vint start, vint count, vint newCount)override; - public: - }; - - class ListViewItemProvider; - - /// List view item. - class ListViewItem : public Object, public Description - { - friend class ListViewSubItems; - friend class ListViewItemProvider; - protected: - ListViewItemProvider* owner; - ListViewSubItems subItems; - Ptr smallImage; - Ptr largeImage; - WString text; - description::Value tag; - - void NotifyUpdate(); - public: - /// Create a list view item. - ListViewItem(); - - /// Get all sub items of this item. - /// All sub items of this item. - ListViewSubItems& GetSubItems(); - /// Get the small image of this item. - /// The small image of this item. - Ptr GetSmallImage(); - /// Set the small image of this item. - /// The small image of this item. - void SetSmallImage(Ptr value); - /// Get the large image of this item. - /// The large image of this item. - Ptr GetLargeImage(); - /// Set the large image of this item. - /// The large image of this item. - void SetLargeImage(Ptr value); - /// Get the text of this item. - /// The text of this item. - const WString& GetText(); - /// Set the text of this item. - /// The text of this item. - void SetText(const WString& value); - /// Get the tag of this item. - /// The tag of this item. - description::Value GetTag(); - /// Set the tag of this item. - /// The tag of this item. - void SetTag(const description::Value& value); - }; - - class ListViewColumns; - - /// List view column. - class ListViewColumn : public Object, public Description - { - friend class ListViewColumns; - protected: - ListViewColumns* owner = nullptr; - WString text; - ItemProperty textProperty; - vint size; - bool ownPopup = true; - GuiMenu* dropdownPopup = nullptr; - ColumnSortingState sortingState = ColumnSortingState::NotSorted; - - void NotifyUpdate(bool affectItem); - public: - /// Create a column with the specified text and size. - /// The specified text. - /// The specified size. - ListViewColumn(const WString& _text=L"", vint _size=160); - ~ListViewColumn(); - - /// Get the text of this item. - /// The text of this item. - const WString& GetText(); - /// Set the text of this item. - /// The text of this item. - void SetText(const WString& value); - /// Get the text property of this item. - /// The text property of this item. - ItemProperty GetTextProperty(); - /// Set the text property of this item. - /// The text property of this item. - void SetTextProperty(const ItemProperty& value); - /// Get the size of this item. - /// The size of this item. - vint GetSize(); - /// Set the size of this item. - /// The size of this item. - void SetSize(vint value); - /// Test if the column owns the popup. Owned popup will be deleted in the destructor. - /// Returns true if the column owns the popup. - bool GetOwnPopup(); - /// Set if the column owns the popup. - /// Set to true to let the column own the popup. - void SetOwnPopup(bool value); - /// Get the dropdown context menu of this item. - /// The dropdown context menu of this item. - GuiMenu* GetDropdownPopup(); - /// Set the dropdown context menu of this item. - /// The dropdown context menu of this item. - void SetDropdownPopup(GuiMenu* value); - /// Get the sorting state of this item. - /// The sorting state of this item. - ColumnSortingState GetSortingState(); - /// Set the sorting state of this item. - /// The sorting state of this item. - void SetSortingState(ColumnSortingState value); - }; - - class IListViewItemProvider : public virtual Interface - { - public: - virtual void NotifyAllItemsUpdate() = 0; - virtual void NotifyAllColumnsUpdate() = 0; - }; - - /// List view data column container. - class ListViewDataColumns : public collections::ObservableListBase - { - protected: - IListViewItemProvider* itemProvider; - - void NotifyUpdateInternal(vint start, vint count, vint newCount)override; - public: - /// Create a container. - /// The item provider in the same control to receive notifications. - ListViewDataColumns(IListViewItemProvider* _itemProvider); - ~ListViewDataColumns(); - }; - - /// List view column container. - class ListViewColumns : public collections::ObservableListBase> - { - friend class ListViewColumn; - protected: - IListViewItemProvider* itemProvider; - bool affectItemFlag = true; - - void NotifyColumnUpdated(vint column, bool affectItem); - void AfterInsert(vint index, const Ptr& value)override; - void BeforeRemove(vint index, const Ptr& value)override; - void NotifyUpdateInternal(vint start, vint count, vint newCount)override; - public: - /// Create a container. - /// The item provider in the same control to receive notifications. - ListViewColumns(IListViewItemProvider* _itemProvider); - ~ListViewColumns(); - }; - - /// Item provider for and . - class ListViewItemProvider - : public ListProvider> - , protected virtual IListViewItemProvider - , protected virtual IListViewItemView - , protected virtual ListViewColumnItemArranger::IColumnItemView - , public Description - { - friend class ListViewItem; - friend class ListViewColumns; - friend class ListViewDataColumns; - typedef collections::List ColumnItemViewCallbackList; - protected: - ListViewDataColumns dataColumns; - ListViewColumns columns; - ColumnItemViewCallbackList columnItemViewCallbacks; - - void AfterInsert(vint index, const Ptr& value)override; - void BeforeRemove(vint index, const Ptr& value)override; - - void NotifyAllItemsUpdate()override; - void NotifyAllColumnsUpdate()override; - - Ptr GetSmallImage(vint itemIndex)override; - Ptr GetLargeImage(vint itemIndex)override; - WString GetText(vint itemIndex)override; - WString GetSubItem(vint itemIndex, vint index)override; - vint GetDataColumnCount()override; - vint GetDataColumn(vint index)override; - vint GetColumnCount()override; - WString GetColumnText(vint index)override;; - - bool AttachCallback(ListViewColumnItemArranger::IColumnItemViewCallback* value)override; - bool DetachCallback(ListViewColumnItemArranger::IColumnItemViewCallback* value)override; - vint GetColumnSize(vint index)override; - void SetColumnSize(vint index, vint value)override; - GuiMenu* GetDropdownPopup(vint index)override; - ColumnSortingState GetSortingState(vint index)override; - - WString GetTextValue(vint itemIndex)override; - description::Value GetBindingValue(vint itemIndex)override; - public: - ListViewItemProvider(); - ~ListViewItemProvider(); - - IDescriptable* RequestView(const WString& identifier)override; - - /// Get all data columns indices in columns. - /// All data columns indices in columns. - ListViewDataColumns& GetDataColumns(); - /// Get all columns. - /// All columns. - ListViewColumns& GetColumns(); - }; - } - -/*********************************************************************** -GuiVirtualListView -***********************************************************************/ - - enum class ListViewView - { - BigIcon, - SmallIcon, - List, - Tile, - Information, - Detail, - Unknown, - }; - - /// List view control in virtual mode. - class GuiVirtualListView : public GuiListViewBase, public Description - { - protected: - ListViewView view = ListViewView::Unknown; - - void OnStyleInstalled(vint itemIndex, ItemStyle* style)override; - void OnItemTemplateChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - public: - /// Create a list view control in virtual mode. - /// The style provider for this control. - /// The item provider for this control. - GuiVirtualListView(IStyleProvider* _styleProvider, GuiListControl::IItemProvider* _itemProvider); - ~GuiVirtualListView(); - - /// Get the current view. - /// The current view. After [M:vl.presentation.controls.GuiListControl.SetItemTemplate] is called, the current view is reset to Unknown. - ListViewView GetView(); - /// Set the current view. - /// The current view. - void SetView(ListViewView _view); - }; - -/*********************************************************************** -GuiListView -***********************************************************************/ - - /// List view control in virtual mode. - class GuiListView : public GuiVirtualListView, public Description - { - protected: - list::ListViewItemProvider* items; - public: - /// Create a list view control. - /// The style provider for this control. - GuiListView(IStyleProvider* _styleProvider); - ~GuiListView(); - - /// Get all list view items. - /// All list view items. - list::ListViewItemProvider& GetItems(); - /// Get all data columns indices in columns. - /// All data columns indices in columns. - list::ListViewDataColumns& GetDataColumns(); - /// Get all columns. - /// All columns. - list::ListViewColumns& GetColumns(); - - /// Get the selected item. - /// Returns the selected item. If there are multiple selected items, or there is no selected item, null will be returned. - Ptr GetSelectedItem(); - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\LISTCONTROLPACKAGE\GUITREEVIEWCONTROLS.H +.\CONTROLS\LISTCONTROLPACKAGE\GUITREEVIEWCONTROLS.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -12862,692 +12433,7 @@ DefaultTreeItemTemplate #endif /*********************************************************************** -CONTROLS\LISTCONTROLPACKAGE\GUICOMBOCONTROLS.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control System - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_GUICOMBOCONTROLS -#define VCZH_PRESENTATION_CONTROLS_GUICOMBOCONTROLS - - -namespace vl -{ - namespace presentation - { - namespace controls - { - -/*********************************************************************** -ComboBox Base -***********************************************************************/ - - /// The base class of combo box control. - class GuiComboBoxBase : public GuiMenuButton, public Description - { - public: - /// Style controller interface for . - class IStyleController : public virtual GuiMenuButton::IStyleController, public Description - { - public: - /// Called when the command executor is changed. - /// The command executor. - virtual void SetCommandExecutor(IComboBoxCommandExecutor* value)=0; - /// Notify that an item is selected. - virtual void OnItemSelected()=0; - }; - protected: - - class CommandExecutor : public Object, public virtual IComboBoxCommandExecutor - { - protected: - GuiComboBoxBase* combo; - - public: - CommandExecutor(GuiComboBoxBase* _combo); - ~CommandExecutor(); - - void SelectItem()override; - }; - - Ptr commandExecutor; - IStyleController* styleController; - - bool IsAltAvailable()override; - IGuiMenuService::Direction GetSubMenuDirection()override; - virtual void SelectItem(); - void OnBoundsChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - public: - /// Create a control with a specified style controller. - /// The style controller. - GuiComboBoxBase(IStyleController* _styleController); - ~GuiComboBoxBase(); - - /// Item selected event. - compositions::GuiNotifyEvent ItemSelected; - }; - -/*********************************************************************** -ComboBox with GuiListControl -***********************************************************************/ - - /// Combo box list control. This control is a combo box with a list control in its popup. - class GuiComboBoxListControl : public GuiComboBoxBase, public Description - { - public: - using ItemStyleProperty = TemplateProperty; - - /// Style controller interface for . - class IStyleController : public virtual GuiComboBoxBase::IStyleController, public Description - { - public: - /// Indicate that if the combo box need to display text. - /// Set to true to display text. - virtual void SetTextVisible(bool value) = 0; - }; - - protected: - IStyleController* styleController = nullptr; - GuiSelectableListControl* containedListControl = nullptr; - ItemStyleProperty itemStyleProperty; - templates::GuiTemplate* itemStyleController = nullptr; - - bool IsAltAvailable()override; - void OnActiveAlt()override; - void RemoveStyleController(); - void InstallStyleController(vint itemIndex); - virtual void DisplaySelectedContent(vint itemIndex); - void OnTextChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnFontChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnVisuallyEnabledChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnListControlAdoptedSizeInvalidated(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnListControlSelectionChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - public: - /// Create a control with a specified style controller and a list control that will be put in the popup control to show all items. - /// The style controller. - /// The list controller. - GuiComboBoxListControl(IStyleController* _styleController, GuiSelectableListControl* _containedListControl); - ~GuiComboBoxListControl(); - - /// Style provider changed event. - compositions::GuiNotifyEvent ItemTemplateChanged; - /// Selected index changed event. - compositions::GuiNotifyEvent SelectedIndexChanged; - - /// Get the list control. - /// The list control. - GuiSelectableListControl* GetContainedListControl(); - - /// Get the item style provider. - /// The item style provider. - virtual ItemStyleProperty GetItemTemplate(); - /// Set the item style provider - /// The old item style provider - /// The new item style provider - virtual void SetItemTemplate(ItemStyleProperty value); - - /// Get the selected index. - /// The selected index. - vint GetSelectedIndex(); - /// Set the selected index. - /// The selected index. - void SetSelectedIndex(vint value); - - /// Get the selected item. - /// The selected item. - description::Value GetSelectedItem(); - /// Get the item provider in the list control. - /// The item provider in the list control. - GuiListControl::IItemProvider* GetItemProvider(); - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\GUIDATETIMECONTROLS.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control System - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_GUIDATETIMECONTROLS -#define VCZH_PRESENTATION_CONTROLS_GUIDATETIMECONTROLS - - -namespace vl -{ - namespace presentation - { - namespace controls - { - -/*********************************************************************** -DatePicker -***********************************************************************/ - - /// Date picker control that display a calendar. - class GuiDatePicker : public GuiControl, public Description - { - public: - /// Style provider interface for . - class IStyleProvider : public virtual GuiControl::IStyleProvider, public Description - { - public: - /// Create a style for date button for choosing "day". - /// The created style. - virtual GuiSelectableButton::IStyleController* CreateDateButtonStyle()=0; - /// Create a text list for candidate "year" and "month". - /// The created control. - virtual GuiTextList* CreateTextList()=0; - /// Create a combo box style for "year" and "month". - /// The created style. - virtual GuiComboBoxListControl::IStyleController* CreateComboBoxStyle()=0; - - /// Get the color for background. - /// The color. - virtual Color GetBackgroundColor()=0; - /// Get the color for "day" that in the current month. - /// The color. - virtual Color GetPrimaryTextColor()=0; - /// Get the color for "day" that not in the current month. - /// The color. - virtual Color GetSecondaryTextColor()=0; - }; - - /// Style controller for . - class StyleController : public Object, public virtual GuiControl::IStyleController, public Description - { - protected: - static const vint DaysOfWeek=7; - static const vint DayRows=6; - static const vint DayRowStart=2; - static const vint YearFirst=1900; - static const vint YearLast=2099; - - IStyleProvider* styleProvider; - GuiDatePicker* datePicker; - DateTime currentDate; - Locale dateLocale; - compositions::GuiTableComposition* boundsComposition; - bool preventComboEvent; - bool preventButtonEvent; - - GuiComboBoxListControl* comboYear; - GuiTextList* listYears; - GuiComboBoxListControl* comboMonth; - GuiTextList* listMonths; - collections::Array labelDaysOfWeek; - collections::Array buttonDays; - collections::Array labelDays; - collections::Array dateDays; - Ptr dayMutexController; - - void SetDay(const DateTime& day, vint& index, bool currentMonth); - void DisplayMonth(vint year, vint month); - void SelectDay(vint day); - void comboYearMonth_SelectedIndexChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void buttonDay_SelectedChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - public: - /// Create a style controller with a specified style provider. - /// The style provider. - StyleController(IStyleProvider* _styleProvider); - ~StyleController(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - - /// Set the data picker that owns this style controller. - /// The date picker. - void SetDatePicker(GuiDatePicker* _datePicker); - /// Set the locale to display texts. - /// The locale. - void SetDateLocale(const Locale& _dateLocale); - /// Get the displayed date. - /// The date. - const DateTime& GetDate(); - /// Display a date. - /// The date. - /// Set to true to refill all data in the control whatever cached or not. - void SetDate(const DateTime& value, bool forceUpdate=false); - }; - - protected: - StyleController* styleController; - WString dateFormat; - Locale dateLocale; - - void UpdateText(); - void NotifyDateChanged(); - public: - /// Create a control with a specified style provider. - /// The style provider. - GuiDatePicker(IStyleProvider* _styleProvider); - ~GuiDatePicker(); - - /// Date changed event. - compositions::GuiNotifyEvent DateChanged; - /// Date navigated event. Called when the current month is changed. - compositions::GuiNotifyEvent DateNavigated; - /// Date selected event. Called when a day button is selected. - compositions::GuiNotifyEvent DateSelected; - /// Date format changed event. - compositions::GuiNotifyEvent DateFormatChanged; - /// Date locale changed event. - compositions::GuiNotifyEvent DateLocaleChanged; - - /// Get the displayed date. - /// The date. - const DateTime& GetDate(); - /// Display a date. - /// The date. - void SetDate(const DateTime& value); - /// Get the format. - /// The format. - const WString& GetDateFormat(); - /// Set the format for the text of this control. - /// The format. - void SetDateFormat(const WString& value); - /// Get the locale. - /// The locale. - const Locale& GetDateLocale(); - /// Set the locale to display texts. - /// The locale. - void SetDateLocale(const Locale& value); - - void SetText(const WString& value)override; - }; - -/*********************************************************************** -DateComboBox -***********************************************************************/ - - /// A combo box control with a date picker control. - class GuiDateComboBox : public GuiComboBoxBase, public Description - { - protected: - GuiDatePicker* datePicker; - DateTime selectedDate; - - void UpdateText(); - void NotifyUpdateSelectedDate(); - void OnSubMenuOpeningChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void datePicker_DateLocaleChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void datePicker_DateFormatChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void datePicker_DateSelected(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - public: - /// Create a control with a specified style provider. - /// The style provider. - /// The date picker control to show in the popup. - GuiDateComboBox(IStyleController* _styleController, GuiDatePicker* _datePicker); - ~GuiDateComboBox(); - - /// Selected data changed event. - compositions::GuiNotifyEvent SelectedDateChanged; - - void SetFont(const FontProperties& value)override; - /// Get the displayed date. - /// The date. - const DateTime& GetSelectedDate(); - /// Display a date. - /// The date. - void SetSelectedDate(const DateTime& value); - /// Get the date picker control. - /// The date picker control. - GuiDatePicker* GetDatePicker(); - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\GUIDIALOGS.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control System - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_GUIDIALOGS -#define VCZH_PRESENTATION_CONTROLS_GUIDIALOGS - - -namespace vl -{ - namespace presentation - { - namespace controls - { - -/*********************************************************************** -Dialogs -***********************************************************************/ - - /// Base class for dialogs. - class GuiDialogBase abstract : public GuiComponent, public Description - { - protected: - GuiInstanceRootObject* rootObject = nullptr; - - GuiWindow* GetHostWindow(); - public: - GuiDialogBase(); - ~GuiDialogBase(); - - void Attach(GuiInstanceRootObject* _rootObject); - void Detach(GuiInstanceRootObject* _rootObject); - }; - - /// Message dialog. - class GuiMessageDialog : public GuiDialogBase, public Description - { - protected: - INativeDialogService::MessageBoxButtonsInput input = INativeDialogService::DisplayOK; - INativeDialogService::MessageBoxDefaultButton defaultButton = INativeDialogService::DefaultFirst; - INativeDialogService::MessageBoxIcons icon = INativeDialogService::IconNone; - INativeDialogService::MessageBoxModalOptions modalOption = INativeDialogService::ModalWindow; - WString text; - WString title; - - public: - /// Create a message dialog. - GuiMessageDialog(); - ~GuiMessageDialog(); - - /// Get the button combination that appear on the dialog. - /// The button combination. - INativeDialogService::MessageBoxButtonsInput GetInput(); - /// Set the button combination that appear on the dialog. - /// The button combination. - void SetInput(INativeDialogService::MessageBoxButtonsInput value); - - /// Get the default button for the selected button combination. - /// The default button. - INativeDialogService::MessageBoxDefaultButton GetDefaultButton(); - /// Set the default button for the selected button combination. - /// The default button. - void SetDefaultButton(INativeDialogService::MessageBoxDefaultButton value); - - /// Get the icon that appears on the dialog. - /// The icon. - INativeDialogService::MessageBoxIcons GetIcon(); - /// Set the icon that appears on the dialog. - /// The icon. - void SetIcon(INativeDialogService::MessageBoxIcons value); - - /// Get the way that how this dialog disable windows of the current process. - /// The way that how this dialog disable windows of the current process. - INativeDialogService::MessageBoxModalOptions GetModalOption(); - /// Set the way that how this dialog disable windows of the current process. - /// The way that how this dialog disable windows of the current process. - void SetModalOption(INativeDialogService::MessageBoxModalOptions value); - - /// Get the text for the dialog. - /// The text. - const WString& GetText(); - /// Set the text for the dialog. - /// The text. - void SetText(const WString& value); - - /// Get the title for the dialog. - /// The title. - const WString& GetTitle(); - /// Set the title for the dialog. If the title is empty, the dialog will use the title of the window that host this dialog. - /// The title. - void SetTitle(const WString& value); - - /// Show the dialog. - /// Returns the clicked button. - INativeDialogService::MessageBoxButtonsOutput ShowDialog(); - }; - - /// Color dialog. - class GuiColorDialog : public GuiDialogBase, public Description - { - protected: - bool enabledCustomColor = true; - bool openedCustomColor = false; - Color selectedColor; - bool showSelection = true; - collections::List customColors; - - public: - /// Create a color dialog. - GuiColorDialog(); - ~GuiColorDialog(); - - /// Selected color changed event. - compositions::GuiNotifyEvent SelectedColorChanged; - - /// Get if the custom color panel is enabled for the dialog. - /// Returns true if the color panel is enabled for the dialog. - bool GetEnabledCustomColor(); - /// Set if custom color panel is enabled for the dialog. - /// Set to true to enable the custom color panel for the dialog. - void SetEnabledCustomColor(bool value); - - /// Get if the custom color panel is opened by default when it is enabled. - /// Returns true if the custom color panel is opened by default. - bool GetOpenedCustomColor(); - /// Set if the custom color panel is opened by default when it is enabled. - /// Set to true to open custom color panel by default if it is enabled. - void SetOpenedCustomColor(bool value); - - /// Get the selected color. - /// The selected color. - Color GetSelectedColor(); - /// Set the selected color. - /// The selected color. - void SetSelectedColor(Color value); - - /// Get the list to access 16 selected custom colors on the palette. Colors in the list is guaranteed to have exactly 16 items after the dialog is closed. - /// The list to access custom colors on the palette. - collections::List& GetCustomColors(); - - /// Show the dialog. - /// Returns true if the "OK" button is clicked. - bool ShowDialog(); - }; - - /// Font dialog. - class GuiFontDialog : public GuiDialogBase, public Description - { - protected: - FontProperties selectedFont; - Color selectedColor; - bool showSelection = true; - bool showEffect = true; - bool forceFontExist = true; - - public: - /// Create a font dialog. - GuiFontDialog(); - ~GuiFontDialog(); - - /// Selected font changed event. - compositions::GuiNotifyEvent SelectedFontChanged; - /// Selected color changed event. - compositions::GuiNotifyEvent SelectedColorChanged; - - /// Get the selected font. - /// The selected font. - const FontProperties& GetSelectedFont(); - /// Set the selected font. - /// The selected font. - void SetSelectedFont(const FontProperties& value); - - /// Get the selected color. - /// The selected color. - Color GetSelectedColor(); - /// Set the selected color. - /// The selected color. - void SetSelectedColor(Color value); - - /// Get if the selected font is already selected on the dialog when it is opened. - /// Returns true if the selected font is already selected on the dialog when it is opened. - bool GetShowSelection(); - /// Set if the selected font is already selected on the dialog when it is opened. - /// Set to true to select the selected font when the dialog is opened. - void SetShowSelection(bool value); - - /// Get if the font preview is enabled. - /// Returns true if the font preview is enabled. - bool GetShowEffect(); - /// Set if the font preview is enabled. - /// Set to true to enable the font preview. - void SetShowEffect(bool value); - - /// Get if the dialog only accepts an existing font. - /// Returns true if the dialog only accepts an existing font. - bool GetForceFontExist(); - /// Set if the dialog only accepts an existing font. - /// Set to true to let the dialog only accept an existing font. - void SetForceFontExist(bool value); - - /// Show the dialog. - /// Returns true if the "OK" button is clicked. - bool ShowDialog(); - }; - - /// Base class for file dialogs. - class GuiFileDialogBase abstract : public GuiDialogBase, public Description - { - protected: - WString filter = L"All Files (*.*)|*.*"; - vint filterIndex = 0; - bool enabledPreview = false; - WString title; - WString fileName; - WString directory; - WString defaultExtension; - INativeDialogService::FileDialogOptions options; - - public: - GuiFileDialogBase(); - ~GuiFileDialogBase(); - - /// File name changed event. - compositions::GuiNotifyEvent FileNameChanged; - /// Filter index changed event. - compositions::GuiNotifyEvent FilterIndexChanged; - - /// Get the filter. - /// The filter. - const WString& GetFilter(); - /// Set the filter. The filter is formed by pairs of filter name and wildcard concatenated by "|", like "Text Files (*.txt)|*.txt|All Files (*.*)|*.*". - /// The filter. - void SetFilter(const WString& value); - - /// Get the filter index. - /// The filter index. - vint GetFilterIndex(); - /// Set the filter index. - /// The filter index. - void SetFilterIndex(vint value); - - /// Get if the file preview is enabled. - /// Returns true if the file preview is enabled. - bool GetEnabledPreview(); - /// Set if the file preview is enabled. - /// Set to true to enable the file preview. - void SetEnabledPreview(bool value); - - /// Get the title. - /// The title. - WString GetTitle(); - /// Set the title. - /// The title. - void SetTitle(const WString& value); - - /// Get the selected file name. - /// The selected file name. - WString GetFileName(); - /// Set the selected file name. - /// The selected file name. - void SetFileName(const WString& value); - - /// Get the default folder. - /// The default folder. - WString GetDirectory(); - /// Set the default folder. - /// The default folder. - void SetDirectory(const WString& value); - - /// Get the default file extension. - /// The default file extension. - WString GetDefaultExtension(); - /// Set the default file extension like "txt". If the user does not specify a file extension, the default file extension will be appended using "." after the file name. - /// The default file extension. - void SetDefaultExtension(const WString& value); - - /// Get the dialog options. - /// The dialog options. - INativeDialogService::FileDialogOptions GetOptions(); - /// Set the dialog options. - /// The dialog options. - void SetOptions(INativeDialogService::FileDialogOptions value); - }; - - /// Open file dialog. - class GuiOpenFileDialog : public GuiFileDialogBase, public Description - { - protected: - collections::List fileNames; - - public: - /// Create a open file dialog. - GuiOpenFileDialog(); - ~GuiOpenFileDialog(); - - /// Get the list to access multiple selected file names. - /// The list to access multiple selected file names. - collections::List& GetFileNames(); - - /// Show the dialog. - /// Returns true if the "Open" button is clicked. - bool ShowDialog(); - }; - - /// Save file dialog. - class GuiSaveFileDialog : public GuiFileDialogBase, public Description - { - public: - /// Create a save file dialog. - GuiSaveFileDialog(); - ~GuiSaveFileDialog(); - - /// Show the dialog. - /// Returns true if the "Save" button is clicked. - bool ShowDialog(); - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\TEXTEDITORPACKAGE\EDITORCALLBACK\GUITEXTGENERALOPERATIONS.H +.\CONTROLS\TEXTEDITORPACKAGE\EDITORCALLBACK\GUITEXTGENERALOPERATIONS.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -13674,7 +12560,146 @@ Common Operations #endif /*********************************************************************** -CONTROLS\TEXTEDITORPACKAGE\EDITORCALLBACK\GUITEXTCOLORIZER.H +.\CONTROLS\TEXTEDITORPACKAGE\EDITORCALLBACK\GUITEXTAUTOCOMPLETE.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Control System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_CONTROLS_GUITEXTAUTOCOMPLETE +#define VCZH_PRESENTATION_CONTROLS_GUITEXTAUTOCOMPLETE + + +namespace vl +{ + namespace presentation + { + namespace controls + { + +/*********************************************************************** +GuiTextBoxAutoCompleteBase +***********************************************************************/ + + /// The base class of text box auto complete controller. + class GuiTextBoxAutoCompleteBase : public Object, public virtual ICommonTextEditCallback + { + public: + /// Represents an auto complete candidate item. + struct AutoCompleteItem + { + /// Tag object for any purpose, e.g., data binding. + description::Value tag; + /// Display text for the item. + WString text; + }; + + /// Auto complete control provider. + class IAutoCompleteControlProvider : public virtual Interface + { + public: + /// Get the auto complete control that will be installed in a popup to show candidate items. + /// The auto complete control. + virtual GuiControl* GetAutoCompleteControl() = 0; + + /// Get the list control storing candidate items. + /// The list control. It should be inside the auto complete control, or the auto complete control itself. + virtual GuiSelectableListControl* GetListControl() = 0; + + /// Store candidate items in the list control. + /// Candidate items. + virtual void SetSortedContent(const collections::List& items) = 0; + + /// Get the numbers of all stored candidate items. + /// The number of all stored candidate items. + virtual vint GetItemCount() = 0; + + /// Get the text of a specified item. + /// The index of the item. + /// The text of the item. + virtual WString GetItemText(vint index) = 0; + }; + + class TextListControlProvider : public Object, public virtual IAutoCompleteControlProvider + { + protected: + GuiTextList* autoCompleteList; + + public: + TextListControlProvider(GuiTextList::IStyleProvider* styleProvider = nullptr); + ~TextListControlProvider(); + + GuiControl* GetAutoCompleteControl()override; + GuiSelectableListControl* GetListControl()override; + void SetSortedContent(const collections::List& items)override; + vint GetItemCount()override; + WString GetItemText(vint index)override; + }; + + protected: + elements::GuiColorizedTextElement* element; + SpinLock* elementModifyLock; + compositions::GuiGraphicsComposition* ownerComposition; + GuiPopup* autoCompletePopup; + Ptr autoCompleteControlProvider; + TextPos autoCompleteStartPosition; + + bool IsPrefix(const WString& prefix, const WString& candidate); + public: + /// Create an auto complete. + /// A auto complete control provider. Set to null to use a default one. + GuiTextBoxAutoCompleteBase(Ptr _autoCompleteControlProvider = nullptr); + ~GuiTextBoxAutoCompleteBase(); + + void Attach(elements::GuiColorizedTextElement* _element, SpinLock& _elementModifyLock, compositions::GuiGraphicsComposition* _ownerComposition, vuint editVersion)override; + void Detach()override; + void TextEditPreview(TextEditPreviewStruct& arguments)override; + void TextEditNotify(const TextEditNotifyStruct& arguments)override; + void TextCaretChanged(const TextCaretChangedStruct& arguments)override; + void TextEditFinished(vuint editVersion)override; + + /// Get the list state. + /// Returns true if the list is visible. + bool IsListOpening(); + /// Notify the list to be visible. + /// The text position to show the list. + void OpenList(TextPos startPosition); + /// Notify the list to be invisible. + void CloseList(); + /// Set the content of the list. + /// The content of the list. + void SetListContent(const collections::List& items); + /// Get the last start position when the list is opened. + /// The start position. + TextPos GetListStartPosition(); + /// Select the previous item. + /// Returns true if this operation succeeded. + bool SelectPreviousListItem(); + /// Select the next item. + /// Returns true if this operation succeeded. + bool SelectNextListItem(); + /// Apply the selected item into the text box. + /// Returns true if this operation succeeded. + bool ApplySelectedListItem(); + /// Get the selected item. + /// The text of the selected item. Returns empty if there is no selected item. + WString GetSelectedListItem(); + /// Highlight a candidate item in the list. + /// The text to match an item. + void HighlightList(const WString& editingText); + }; + } + } +} + +#endif + +/*********************************************************************** +.\CONTROLS\TEXTEDITORPACKAGE\EDITORCALLBACK\GUITEXTCOLORIZER.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -13826,146 +12851,7 @@ GuiTextBoxRegexColorizer #endif /*********************************************************************** -CONTROLS\TEXTEDITORPACKAGE\EDITORCALLBACK\GUITEXTAUTOCOMPLETE.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control System - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_GUITEXTAUTOCOMPLETE -#define VCZH_PRESENTATION_CONTROLS_GUITEXTAUTOCOMPLETE - - -namespace vl -{ - namespace presentation - { - namespace controls - { - -/*********************************************************************** -GuiTextBoxAutoCompleteBase -***********************************************************************/ - - /// The base class of text box auto complete controller. - class GuiTextBoxAutoCompleteBase : public Object, public virtual ICommonTextEditCallback - { - public: - /// Represents an auto complete candidate item. - struct AutoCompleteItem - { - /// Tag object for any purpose, e.g., data binding. - description::Value tag; - /// Display text for the item. - WString text; - }; - - /// Auto complete control provider. - class IAutoCompleteControlProvider : public virtual Interface - { - public: - /// Get the auto complete control that will be installed in a popup to show candidate items. - /// The auto complete control. - virtual GuiControl* GetAutoCompleteControl() = 0; - - /// Get the list control storing candidate items. - /// The list control. It should be inside the auto complete control, or the auto complete control itself. - virtual GuiSelectableListControl* GetListControl() = 0; - - /// Store candidate items in the list control. - /// Candidate items. - virtual void SetSortedContent(const collections::List& items) = 0; - - /// Get the numbers of all stored candidate items. - /// The number of all stored candidate items. - virtual vint GetItemCount() = 0; - - /// Get the text of a specified item. - /// The index of the item. - /// The text of the item. - virtual WString GetItemText(vint index) = 0; - }; - - class TextListControlProvider : public Object, public virtual IAutoCompleteControlProvider - { - protected: - GuiTextList* autoCompleteList; - - public: - TextListControlProvider(GuiTextList::IStyleProvider* styleProvider = nullptr); - ~TextListControlProvider(); - - GuiControl* GetAutoCompleteControl()override; - GuiSelectableListControl* GetListControl()override; - void SetSortedContent(const collections::List& items)override; - vint GetItemCount()override; - WString GetItemText(vint index)override; - }; - - protected: - elements::GuiColorizedTextElement* element; - SpinLock* elementModifyLock; - compositions::GuiGraphicsComposition* ownerComposition; - GuiPopup* autoCompletePopup; - Ptr autoCompleteControlProvider; - TextPos autoCompleteStartPosition; - - bool IsPrefix(const WString& prefix, const WString& candidate); - public: - /// Create an auto complete. - /// A auto complete control provider. Set to null to use a default one. - GuiTextBoxAutoCompleteBase(Ptr _autoCompleteControlProvider = nullptr); - ~GuiTextBoxAutoCompleteBase(); - - void Attach(elements::GuiColorizedTextElement* _element, SpinLock& _elementModifyLock, compositions::GuiGraphicsComposition* _ownerComposition, vuint editVersion)override; - void Detach()override; - void TextEditPreview(TextEditPreviewStruct& arguments)override; - void TextEditNotify(const TextEditNotifyStruct& arguments)override; - void TextCaretChanged(const TextCaretChangedStruct& arguments)override; - void TextEditFinished(vuint editVersion)override; - - /// Get the list state. - /// Returns true if the list is visible. - bool IsListOpening(); - /// Notify the list to be visible. - /// The text position to show the list. - void OpenList(TextPos startPosition); - /// Notify the list to be invisible. - void CloseList(); - /// Set the content of the list. - /// The content of the list. - void SetListContent(const collections::List& items); - /// Get the last start position when the list is opened. - /// The start position. - TextPos GetListStartPosition(); - /// Select the previous item. - /// Returns true if this operation succeeded. - bool SelectPreviousListItem(); - /// Select the next item. - /// Returns true if this operation succeeded. - bool SelectNextListItem(); - /// Apply the selected item into the text box. - /// Returns true if this operation succeeded. - bool ApplySelectedListItem(); - /// Get the selected item. - /// The text of the selected item. Returns empty if there is no selected item. - WString GetSelectedListItem(); - /// Highlight a candidate item in the list. - /// The text to match an item. - void HighlightList(const WString& editingText); - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\TEXTEDITORPACKAGE\EDITORCALLBACK\GUITEXTUNDOREDO.H +.\CONTROLS\TEXTEDITORPACKAGE\EDITORCALLBACK\GUITEXTUNDOREDO.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -14145,468 +13031,7 @@ Undo Redo (Document) #endif /*********************************************************************** -CONTROLS\TEXTEDITORPACKAGE\GUITEXTCOMMONINTERFACE.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control System - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_GUITEXTCOMMONINTERFACE -#define VCZH_PRESENTATION_CONTROLS_GUITEXTCOMMONINTERFACE - - -namespace vl -{ - namespace presentation - { - namespace controls - { - -/*********************************************************************** -Common Interface -***********************************************************************/ - - /// Common interface for text box controls. - class GuiTextBoxCommonInterface abstract : public Description - { - typedef collections::Array ColorArray; - protected: - class ICallback : public virtual IDescriptable, public Description - { - public: - virtual TextPos GetLeftWord(TextPos pos)=0; - virtual TextPos GetRightWord(TextPos pos)=0; - virtual void GetWord(TextPos pos, TextPos& begin, TextPos& end)=0; - virtual vint GetPageRows()=0; - virtual bool BeforeModify(TextPos start, TextPos end, const WString& originalText, WString& inputText)=0; - virtual void AfterModify(TextPos originalStart, TextPos originalEnd, const WString& originalText, TextPos inputStart, TextPos inputEnd, const WString& inputText)=0; - virtual void ScrollToView(Point point)=0; - virtual vint GetTextMargin()=0; - }; - - class DefaultCallback : public Object, public ICallback, public Description - { - protected: - elements::GuiColorizedTextElement* textElement; - compositions::GuiGraphicsComposition* textComposition; - bool readonly; - public: - DefaultCallback(elements::GuiColorizedTextElement* _textElement, compositions::GuiGraphicsComposition* _textComposition); - ~DefaultCallback(); - - TextPos GetLeftWord(TextPos pos)override; - TextPos GetRightWord(TextPos pos)override; - void GetWord(TextPos pos, TextPos& begin, TextPos& end)override; - vint GetPageRows()override; - bool BeforeModify(TextPos start, TextPos end, const WString& originalText, WString& inputText)override; - }; - private: - elements::GuiColorizedTextElement* textElement; - compositions::GuiGraphicsComposition* textComposition; - vuint editVersion; - GuiControl* textControl; - ICallback* callback; - bool dragging; - bool readonly; - Ptr colorizer; - Ptr autoComplete; - Ptr undoRedoProcessor; - - bool filledDefaultColors = false; - ColorArray defaultColors; - - SpinLock elementModifyLock; - collections::List> textEditCallbacks; - Ptr internalShortcutKeyManager; - bool preventEnterDueToAutoComplete; - - void InvokeUndoRedoChanged(); - void InvokeModifiedChanged(); - void UpdateCaretPoint(); - void Move(TextPos pos, bool shift); - void Modify(TextPos start, TextPos end, const WString& input, bool asKeyInput); - bool ProcessKey(vint code, bool shift, bool ctrl); - - void OnGotFocus(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnLostFocus(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnCaretNotify(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - - void OnLeftButtonDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); - void OnLeftButtonUp(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); - void OnMouseMove(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); - void OnKeyDown(compositions::GuiGraphicsComposition* sender, compositions::GuiKeyEventArgs& arguments); - void OnCharInput(compositions::GuiGraphicsComposition* sender, compositions::GuiCharEventArgs& arguments); - - protected: - - void Install(elements::GuiColorizedTextElement* _textElement, compositions::GuiGraphicsComposition* _textComposition, GuiControl* _textControl); - ICallback* GetCallback(); - void SetCallback(ICallback* value); - bool AttachTextEditCallback(Ptr value); - bool DetachTextEditCallback(Ptr value); - void AddShortcutCommand(vint key, const Func& eventHandler); - elements::GuiColorizedTextElement* GetTextElement(); - void UnsafeSetText(const WString& value); - - public: - GuiTextBoxCommonInterface(); - ~GuiTextBoxCommonInterface(); - - /// Selection changed event. - compositions::GuiNotifyEvent SelectionChanged; - /// Undo redo status changed event. - compositions::GuiNotifyEvent UndoRedoChanged; - /// Modified status changed event. - compositions::GuiNotifyEvent ModifiedChanged; - - //================ clipboard operations - - /// Test can the selection be cut. - /// Returns true if the selection can be cut. - bool CanCut(); - /// Test can the selection be copied. - /// Returns true if the selection can be cut. - bool CanCopy(); - /// Test can the content in the clipboard be pasted. - /// Returns true if the content in the clipboard can be pasted. - bool CanPaste(); - /// Cut the selection text. - /// Returns true if this operation succeeded. - bool Cut(); - /// Copy the selection text. - /// Returns true if this operation succeeded. - bool Copy(); - /// Paste the content from the clipboard and replace the selected text. - /// Returns true if this operation succeeded. - bool Paste(); - - //================ editing control - - /// Get the readonly mode. - /// Returns true if the text box is readonly. - bool GetReadonly(); - /// Set the readonly mode. - /// Set to true to make the texg box readonly. - void SetReadonly(bool value); - - //================ text operations - - /// Select all text. - void SelectAll(); - /// Select (highlight) a part of text. - /// The begin position. - /// The end position. This is also the caret position. - void Select(TextPos begin, TextPos end); - /// Get the selected text. - /// The selected text. - WString GetSelectionText(); - /// Set the selected text. - /// The selected text. - void SetSelectionText(const WString& value); - /// Set the selected text and let to text box treat this changing as input by the keyboard. - /// The selected text. - void SetSelectionTextAsKeyInput(const WString& value); - - /// Get the text from a specified row number. - /// The text from a specified row number. - /// The specified row number. - WString GetRowText(vint row); - /// Get the number of rows. - /// The number of rows. - vint GetRowCount(); - /// Get the text from a specified range. - /// The text from a specified range. - /// The specified start position. - /// The specified end position. - WString GetFragmentText(TextPos start, TextPos end); - - /// Get the begin text position of the selection. - /// The begin text position of the selection. - TextPos GetCaretBegin(); - /// Get the end text position of the selection. - /// The end text position of the selection. - TextPos GetCaretEnd(); - /// Get the left-top text position of the selection. - /// The left-top text position of the selection. - TextPos GetCaretSmall(); - /// Get the right-bottom text position of the selection. - /// The right-bottom text position of the selection. - TextPos GetCaretLarge(); - - //================ position query - - /// Get the width of a row. - /// The width of a row in pixel. - /// The specified row number - vint GetRowWidth(vint row); - /// Get the height of a row. - /// The height of a row in pixel. - vint GetRowHeight(); - /// Get the maximum width of all rows. - /// The maximum width of all rows. - vint GetMaxWidth(); - /// Get the total height of all rows. - /// The total height of all rows. - vint GetMaxHeight(); - /// Get the nearest position of a character from a specified display position. - /// Get the nearest position of a character. - /// The specified display position. - TextPos GetTextPosFromPoint(Point point); - /// Get the display position of a character from a specified text position. - /// Get the display position of a character. - /// The specified text position. - Point GetPointFromTextPos(TextPos pos); - /// Get the display bounds of a character from a specified text position. - /// Get the display bounds of a character. - /// The specified text position. - Rect GetRectFromTextPos(TextPos pos); - /// Get the nearest text position from a specified display position. - /// Get the nearest text position. - /// The specified display position. - TextPos GetNearestTextPos(Point point); - - //================ colorizing - - /// Get the current colorizer. - /// The current colorizer. - Ptr GetColorizer(); - /// Set the current colorizer. - /// The current colorizer. - void SetColorizer(Ptr value); - - //================ auto complete - - /// Get the current auto complete controller. - /// The current auto complete controller. - Ptr GetAutoComplete(); - /// Set the current auto complete controller. - /// The current auto complete controller. - void SetAutoComplete(Ptr value); - - //================ undo redo control - - /// Get the current edit version. When the control is modified, the edit version increased. Calling will not reset the edit version. - /// The current edit version. - vuint GetEditVersion(); - /// Test can undo. - /// Returns true if this action can be performed. - bool CanUndo(); - /// Test can redo. - /// Returns true if this action can be performed. - bool CanRedo(); - /// Clear all undo and redo information. - void ClearUndoRedo(); - /// Test is the text box modified. - /// Returns true if the text box is modified. - bool GetModified(); - /// Notify the text box that the current status is considered saved. - void NotifyModificationSaved(); - /// Perform the undo action. - /// Returns true if this operation succeeded. - bool Undo(); - /// Perform the redo action. - /// Returns true if this operation succeeded. - bool Redo(); - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\TEXTEDITORPACKAGE\GUITEXTCONTROLS.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control System - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_GUITEXTCONTROLS -#define VCZH_PRESENTATION_CONTROLS_GUITEXTCONTROLS - - -namespace vl -{ - namespace presentation - { - namespace controls - { - -/*********************************************************************** -MultilineTextBox -***********************************************************************/ - - /// Multiline text box control. - class GuiMultilineTextBox : public GuiScrollView, public GuiTextBoxCommonInterface, public Description - { - public: - static const vint TextMargin=3; - - class StyleController : public GuiScrollView::StyleController, public Description - { - protected: - elements::GuiColorizedTextElement* textElement; - compositions::GuiBoundsComposition* textComposition; - GuiMultilineTextBox* textBox; - Ptr defaultCallback; - - public: - StyleController(GuiScrollView::IStyleProvider* styleProvider); - ~StyleController(); - - void Initialize(GuiMultilineTextBox* control); - elements::GuiColorizedTextElement* GetTextElement(); - compositions::GuiGraphicsComposition* GetTextComposition(); - void SetViewPosition(Point value); - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - - WString GetText(); - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - }; - - protected: - class TextElementOperatorCallback : public GuiTextBoxCommonInterface::DefaultCallback, public Description - { - protected: - GuiMultilineTextBox* textControl; - StyleController* textController; - public: - TextElementOperatorCallback(GuiMultilineTextBox* _textControl); - - void AfterModify(TextPos originalStart, TextPos originalEnd, const WString& originalText, TextPos inputStart, TextPos inputEnd, const WString& inputText)override; - void ScrollToView(Point point)override; - vint GetTextMargin()override; - }; - - protected: - StyleController* styleController; - - void CalculateViewAndSetScroll(); - void OnRenderTargetChanged(elements::IGuiGraphicsRenderTarget* renderTarget)override; - Size QueryFullSize()override; - void UpdateView(Rect viewBounds)override; - void OnBoundsMouseButtonDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); - public: - /// Create a control with a specified style provider. - /// The style provider. - GuiMultilineTextBox(GuiMultilineTextBox::IStyleProvider* styleProvider); - ~GuiMultilineTextBox(); - - const WString& GetText()override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - }; - -/*********************************************************************** -SinglelineTextBox -***********************************************************************/ - - /// Single text box control. - class GuiSinglelineTextBox : public GuiControl, public GuiTextBoxCommonInterface, public Description - { - public: - static const vint TextMargin=3; - - /// Style controller interface for . - class IStyleProvider : public virtual GuiControl::IStyleProvider, public Description - { - public: - /// Create a background in the specified background container composition. - /// The container composition. If the style does not have a inner composition to be the container composition, just return the background argument. - /// The background container composition. - virtual compositions::GuiGraphicsComposition* InstallBackground(compositions::GuiBoundsComposition* background)=0; - }; - - class StyleController : public Object, public GuiControl::IStyleController, public Description - { - protected: - Ptr styleProvider; - compositions::GuiBoundsComposition* boundsComposition; - compositions::GuiGraphicsComposition* containerComposition; - - GuiSinglelineTextBox* textBox; - elements::GuiColorizedTextElement* textElement; - compositions::GuiTableComposition* textCompositionTable; - compositions::GuiCellComposition* textComposition; - Ptr defaultCallback; - - public: - StyleController(IStyleProvider* _styleProvider); - ~StyleController(); - - void SetTextBox(GuiSinglelineTextBox* control); - void RearrangeTextElement(); - compositions::GuiBoundsComposition* GetBoundsComposition(); - compositions::GuiGraphicsComposition* GetContainerComposition(); - void SetFocusableComposition(compositions::GuiGraphicsComposition* value); - - WString GetText(); - void SetText(const WString& value); - void SetFont(const FontProperties& value); - void SetVisuallyEnabled(bool value); - - elements::GuiColorizedTextElement* GetTextElement(); - compositions::GuiGraphicsComposition* GetTextComposition(); - void SetViewPosition(Point value); - }; - - protected: - class TextElementOperatorCallback : public GuiTextBoxCommonInterface::DefaultCallback, public Description - { - protected: - GuiSinglelineTextBox* textControl; - StyleController* textController; - public: - TextElementOperatorCallback(GuiSinglelineTextBox* _textControl); - - bool BeforeModify(TextPos start, TextPos end, const WString& originalText, WString& inputText)override; - void AfterModify(TextPos originalStart, TextPos originalEnd, const WString& originalText, TextPos inputStart, TextPos inputEnd, const WString& inputText)override; - void ScrollToView(Point point)override; - vint GetTextMargin()override; - }; - protected: - StyleController* styleController; - - void OnRenderTargetChanged(elements::IGuiGraphicsRenderTarget* renderTarget)override; - void OnBoundsMouseButtonDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); - public: - /// Create a control with a specified style provider. - /// The style provider. - GuiSinglelineTextBox(GuiSinglelineTextBox::IStyleProvider* styleProvider); - ~GuiSinglelineTextBox(); - - const WString& GetText()override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - /// - /// Get the password mode displaying character. - /// - /// The password mode displaying character. Returns L'\0' means the password mode is not activated. - wchar_t GetPasswordChar(); - /// - /// Set the password mode displaying character. - /// - /// The password mode displaying character. Set to L'\0' to deactivate the password mode. - void SetPasswordChar(wchar_t value); - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\TEXTEDITORPACKAGE\GUIDOCUMENTVIEWER.H +.\CONTROLS\TEXTEDITORPACKAGE\GUIDOCUMENTVIEWER.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -15007,8 +13432,2172 @@ GuiDocumentViewer #endif + /*********************************************************************** -CONTROLS\LISTCONTROLPACKAGE\GUIDATAGRIDINTERFACES.H +.\CONTROLS\TEXTEDITORPACKAGE\GUITEXTCOMMONINTERFACE.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Control System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_CONTROLS_GUITEXTCOMMONINTERFACE +#define VCZH_PRESENTATION_CONTROLS_GUITEXTCOMMONINTERFACE + + +namespace vl +{ + namespace presentation + { + namespace controls + { + +/*********************************************************************** +Common Interface +***********************************************************************/ + + /// Common interface for text box controls. + class GuiTextBoxCommonInterface abstract : public Description + { + typedef collections::Array ColorArray; + protected: + class ICallback : public virtual IDescriptable, public Description + { + public: + virtual TextPos GetLeftWord(TextPos pos)=0; + virtual TextPos GetRightWord(TextPos pos)=0; + virtual void GetWord(TextPos pos, TextPos& begin, TextPos& end)=0; + virtual vint GetPageRows()=0; + virtual bool BeforeModify(TextPos start, TextPos end, const WString& originalText, WString& inputText)=0; + virtual void AfterModify(TextPos originalStart, TextPos originalEnd, const WString& originalText, TextPos inputStart, TextPos inputEnd, const WString& inputText)=0; + virtual void ScrollToView(Point point)=0; + virtual vint GetTextMargin()=0; + }; + + class DefaultCallback : public Object, public ICallback, public Description + { + protected: + elements::GuiColorizedTextElement* textElement; + compositions::GuiGraphicsComposition* textComposition; + bool readonly; + public: + DefaultCallback(elements::GuiColorizedTextElement* _textElement, compositions::GuiGraphicsComposition* _textComposition); + ~DefaultCallback(); + + TextPos GetLeftWord(TextPos pos)override; + TextPos GetRightWord(TextPos pos)override; + void GetWord(TextPos pos, TextPos& begin, TextPos& end)override; + vint GetPageRows()override; + bool BeforeModify(TextPos start, TextPos end, const WString& originalText, WString& inputText)override; + }; + private: + elements::GuiColorizedTextElement* textElement; + compositions::GuiGraphicsComposition* textComposition; + vuint editVersion; + GuiControl* textControl; + ICallback* callback; + bool dragging; + bool readonly; + Ptr colorizer; + Ptr autoComplete; + Ptr undoRedoProcessor; + + bool filledDefaultColors = false; + ColorArray defaultColors; + + SpinLock elementModifyLock; + collections::List> textEditCallbacks; + Ptr internalShortcutKeyManager; + bool preventEnterDueToAutoComplete; + + void InvokeUndoRedoChanged(); + void InvokeModifiedChanged(); + void UpdateCaretPoint(); + void Move(TextPos pos, bool shift); + void Modify(TextPos start, TextPos end, const WString& input, bool asKeyInput); + bool ProcessKey(vint code, bool shift, bool ctrl); + + void OnGotFocus(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void OnLostFocus(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void OnCaretNotify(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + + void OnLeftButtonDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); + void OnLeftButtonUp(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); + void OnMouseMove(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); + void OnKeyDown(compositions::GuiGraphicsComposition* sender, compositions::GuiKeyEventArgs& arguments); + void OnCharInput(compositions::GuiGraphicsComposition* sender, compositions::GuiCharEventArgs& arguments); + + protected: + + void Install(elements::GuiColorizedTextElement* _textElement, compositions::GuiGraphicsComposition* _textComposition, GuiControl* _textControl); + ICallback* GetCallback(); + void SetCallback(ICallback* value); + bool AttachTextEditCallback(Ptr value); + bool DetachTextEditCallback(Ptr value); + void AddShortcutCommand(vint key, const Func& eventHandler); + elements::GuiColorizedTextElement* GetTextElement(); + void UnsafeSetText(const WString& value); + + public: + GuiTextBoxCommonInterface(); + ~GuiTextBoxCommonInterface(); + + /// Selection changed event. + compositions::GuiNotifyEvent SelectionChanged; + /// Undo redo status changed event. + compositions::GuiNotifyEvent UndoRedoChanged; + /// Modified status changed event. + compositions::GuiNotifyEvent ModifiedChanged; + + //================ clipboard operations + + /// Test can the selection be cut. + /// Returns true if the selection can be cut. + bool CanCut(); + /// Test can the selection be copied. + /// Returns true if the selection can be cut. + bool CanCopy(); + /// Test can the content in the clipboard be pasted. + /// Returns true if the content in the clipboard can be pasted. + bool CanPaste(); + /// Cut the selection text. + /// Returns true if this operation succeeded. + bool Cut(); + /// Copy the selection text. + /// Returns true if this operation succeeded. + bool Copy(); + /// Paste the content from the clipboard and replace the selected text. + /// Returns true if this operation succeeded. + bool Paste(); + + //================ editing control + + /// Get the readonly mode. + /// Returns true if the text box is readonly. + bool GetReadonly(); + /// Set the readonly mode. + /// Set to true to make the texg box readonly. + void SetReadonly(bool value); + + //================ text operations + + /// Select all text. + void SelectAll(); + /// Select (highlight) a part of text. + /// The begin position. + /// The end position. This is also the caret position. + void Select(TextPos begin, TextPos end); + /// Get the selected text. + /// The selected text. + WString GetSelectionText(); + /// Set the selected text. + /// The selected text. + void SetSelectionText(const WString& value); + /// Set the selected text and let to text box treat this changing as input by the keyboard. + /// The selected text. + void SetSelectionTextAsKeyInput(const WString& value); + + /// Get the text from a specified row number. + /// The text from a specified row number. + /// The specified row number. + WString GetRowText(vint row); + /// Get the number of rows. + /// The number of rows. + vint GetRowCount(); + /// Get the text from a specified range. + /// The text from a specified range. + /// The specified start position. + /// The specified end position. + WString GetFragmentText(TextPos start, TextPos end); + + /// Get the begin text position of the selection. + /// The begin text position of the selection. + TextPos GetCaretBegin(); + /// Get the end text position of the selection. + /// The end text position of the selection. + TextPos GetCaretEnd(); + /// Get the left-top text position of the selection. + /// The left-top text position of the selection. + TextPos GetCaretSmall(); + /// Get the right-bottom text position of the selection. + /// The right-bottom text position of the selection. + TextPos GetCaretLarge(); + + //================ position query + + /// Get the width of a row. + /// The width of a row in pixel. + /// The specified row number + vint GetRowWidth(vint row); + /// Get the height of a row. + /// The height of a row in pixel. + vint GetRowHeight(); + /// Get the maximum width of all rows. + /// The maximum width of all rows. + vint GetMaxWidth(); + /// Get the total height of all rows. + /// The total height of all rows. + vint GetMaxHeight(); + /// Get the nearest position of a character from a specified display position. + /// Get the nearest position of a character. + /// The specified display position. + TextPos GetTextPosFromPoint(Point point); + /// Get the display position of a character from a specified text position. + /// Get the display position of a character. + /// The specified text position. + Point GetPointFromTextPos(TextPos pos); + /// Get the display bounds of a character from a specified text position. + /// Get the display bounds of a character. + /// The specified text position. + Rect GetRectFromTextPos(TextPos pos); + /// Get the nearest text position from a specified display position. + /// Get the nearest text position. + /// The specified display position. + TextPos GetNearestTextPos(Point point); + + //================ colorizing + + /// Get the current colorizer. + /// The current colorizer. + Ptr GetColorizer(); + /// Set the current colorizer. + /// The current colorizer. + void SetColorizer(Ptr value); + + //================ auto complete + + /// Get the current auto complete controller. + /// The current auto complete controller. + Ptr GetAutoComplete(); + /// Set the current auto complete controller. + /// The current auto complete controller. + void SetAutoComplete(Ptr value); + + //================ undo redo control + + /// Get the current edit version. When the control is modified, the edit version increased. Calling will not reset the edit version. + /// The current edit version. + vuint GetEditVersion(); + /// Test can undo. + /// Returns true if this action can be performed. + bool CanUndo(); + /// Test can redo. + /// Returns true if this action can be performed. + bool CanRedo(); + /// Clear all undo and redo information. + void ClearUndoRedo(); + /// Test is the text box modified. + /// Returns true if the text box is modified. + bool GetModified(); + /// Notify the text box that the current status is considered saved. + void NotifyModificationSaved(); + /// Perform the undo action. + /// Returns true if this operation succeeded. + bool Undo(); + /// Perform the redo action. + /// Returns true if this operation succeeded. + bool Redo(); + }; + } + } +} + +#endif + +/*********************************************************************** +.\CONTROLS\TEXTEDITORPACKAGE\GUITEXTCONTROLS.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Control System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_CONTROLS_GUITEXTCONTROLS +#define VCZH_PRESENTATION_CONTROLS_GUITEXTCONTROLS + + +namespace vl +{ + namespace presentation + { + namespace controls + { + +/*********************************************************************** +MultilineTextBox +***********************************************************************/ + + /// Multiline text box control. + class GuiMultilineTextBox : public GuiScrollView, public GuiTextBoxCommonInterface, public Description + { + public: + static const vint TextMargin=3; + + class StyleController : public GuiScrollView::StyleController, public Description + { + protected: + elements::GuiColorizedTextElement* textElement; + compositions::GuiBoundsComposition* textComposition; + GuiMultilineTextBox* textBox; + Ptr defaultCallback; + + public: + StyleController(GuiScrollView::IStyleProvider* styleProvider); + ~StyleController(); + + void Initialize(GuiMultilineTextBox* control); + elements::GuiColorizedTextElement* GetTextElement(); + compositions::GuiGraphicsComposition* GetTextComposition(); + void SetViewPosition(Point value); + void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; + + WString GetText(); + void SetText(const WString& value)override; + void SetFont(const FontProperties& value)override; + void SetVisuallyEnabled(bool value)override; + }; + + protected: + class TextElementOperatorCallback : public GuiTextBoxCommonInterface::DefaultCallback, public Description + { + protected: + GuiMultilineTextBox* textControl; + StyleController* textController; + public: + TextElementOperatorCallback(GuiMultilineTextBox* _textControl); + + void AfterModify(TextPos originalStart, TextPos originalEnd, const WString& originalText, TextPos inputStart, TextPos inputEnd, const WString& inputText)override; + void ScrollToView(Point point)override; + vint GetTextMargin()override; + }; + + protected: + StyleController* styleController; + + void CalculateViewAndSetScroll(); + void OnRenderTargetChanged(elements::IGuiGraphicsRenderTarget* renderTarget)override; + Size QueryFullSize()override; + void UpdateView(Rect viewBounds)override; + void OnBoundsMouseButtonDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); + public: + /// Create a control with a specified style provider. + /// The style provider. + GuiMultilineTextBox(GuiMultilineTextBox::IStyleProvider* styleProvider); + ~GuiMultilineTextBox(); + + const WString& GetText()override; + void SetText(const WString& value)override; + void SetFont(const FontProperties& value)override; + }; + +/*********************************************************************** +SinglelineTextBox +***********************************************************************/ + + /// Single text box control. + class GuiSinglelineTextBox : public GuiControl, public GuiTextBoxCommonInterface, public Description + { + public: + static const vint TextMargin=3; + + /// Style controller interface for . + class IStyleProvider : public virtual GuiControl::IStyleProvider, public Description + { + public: + /// Create a background in the specified background container composition. + /// The container composition. If the style does not have a inner composition to be the container composition, just return the background argument. + /// The background container composition. + virtual compositions::GuiGraphicsComposition* InstallBackground(compositions::GuiBoundsComposition* background)=0; + }; + + class StyleController : public Object, public GuiControl::IStyleController, public Description + { + protected: + Ptr styleProvider; + compositions::GuiBoundsComposition* boundsComposition; + compositions::GuiGraphicsComposition* containerComposition; + + GuiSinglelineTextBox* textBox; + elements::GuiColorizedTextElement* textElement; + compositions::GuiTableComposition* textCompositionTable; + compositions::GuiCellComposition* textComposition; + Ptr defaultCallback; + + public: + StyleController(IStyleProvider* _styleProvider); + ~StyleController(); + + void SetTextBox(GuiSinglelineTextBox* control); + void RearrangeTextElement(); + compositions::GuiBoundsComposition* GetBoundsComposition(); + compositions::GuiGraphicsComposition* GetContainerComposition(); + void SetFocusableComposition(compositions::GuiGraphicsComposition* value); + + WString GetText(); + void SetText(const WString& value); + void SetFont(const FontProperties& value); + void SetVisuallyEnabled(bool value); + + elements::GuiColorizedTextElement* GetTextElement(); + compositions::GuiGraphicsComposition* GetTextComposition(); + void SetViewPosition(Point value); + }; + + protected: + class TextElementOperatorCallback : public GuiTextBoxCommonInterface::DefaultCallback, public Description + { + protected: + GuiSinglelineTextBox* textControl; + StyleController* textController; + public: + TextElementOperatorCallback(GuiSinglelineTextBox* _textControl); + + bool BeforeModify(TextPos start, TextPos end, const WString& originalText, WString& inputText)override; + void AfterModify(TextPos originalStart, TextPos originalEnd, const WString& originalText, TextPos inputStart, TextPos inputEnd, const WString& inputText)override; + void ScrollToView(Point point)override; + vint GetTextMargin()override; + }; + protected: + StyleController* styleController; + + void OnRenderTargetChanged(elements::IGuiGraphicsRenderTarget* renderTarget)override; + void OnBoundsMouseButtonDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); + public: + /// Create a control with a specified style provider. + /// The style provider. + GuiSinglelineTextBox(GuiSinglelineTextBox::IStyleProvider* styleProvider); + ~GuiSinglelineTextBox(); + + const WString& GetText()override; + void SetText(const WString& value)override; + void SetFont(const FontProperties& value)override; + /// + /// Get the password mode displaying character. + /// + /// The password mode displaying character. Returns L'\0' means the password mode is not activated. + wchar_t GetPasswordChar(); + /// + /// Set the password mode displaying character. + /// + /// The password mode displaying character. Set to L'\0' to deactivate the password mode. + void SetPasswordChar(wchar_t value); + }; + } + } +} + +#endif + +/*********************************************************************** +.\CONTROLS\TEXTEDITORPACKAGE\LANGUAGESERVICE\GUILANGUAGEOPERATIONS.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Control System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_CONTROLS_GUILANGUAGEOPERATIONS +#define VCZH_PRESENTATION_CONTROLS_GUILANGUAGEOPERATIONS + + +namespace vl +{ + namespace presentation + { + namespace controls + { + +/*********************************************************************** +ParsingInput +***********************************************************************/ + + class RepeatingParsingExecutor; + + /// A data structure storing the parsing input for text box control. + struct RepeatingParsingInput + { + /// The text box edit version of the code. + vuint editVersion = 0; + /// The code. + WString code; + }; + +/*********************************************************************** +ParsingOutput +***********************************************************************/ + + /// A data structure storing the parsing result for text box control. + struct RepeatingParsingOutput + { + /// The parsed syntax tree. + Ptr node; + /// The text box edit version of the code. + vuint editVersion = 0; + /// The code. + WString code; + /// The cache created from [T:vl.presentation.controls.RepeatingParsingExecutor.IParsingAnalyzer]. + Ptr cache; + }; + +/*********************************************************************** +PartialParsingOutput +***********************************************************************/ + + /// A data structure storing the parsing result for partial updating when a text box control is modified. + struct RepeatingPartialParsingOutput + { + /// The input data. + RepeatingParsingOutput input; + /// The rule name that can parse the code of the selected context. + WString rule; + /// Range of the original context in the input. + parsing::ParsingTextRange originalRange; + /// The original context in the syntax tree. + Ptr originalNode; + /// The modified context in the syntax tree. + Ptr modifiedNode; + /// The modified code of the selected context. + WString modifiedCode; + }; + +/*********************************************************************** +PartialParsingOutput +***********************************************************************/ + + /// A data structure storing the information for a candidate item. + struct ParsingCandidateItem + { + /// Semantic id. + vint semanticId = -1; + /// Display name. + WString name; + /// Tag object for any purpose, e.g., data binding. + description::Value tag; + }; + +/*********************************************************************** +ParsingContext +***********************************************************************/ + + /// A data structure storing the context of a token. + struct ParsingTokenContext + { + /// Token syntax tree for the selected token. + parsing::ParsingTreeToken* foundToken = nullptr; + /// The object syntax tree parent of the token. + parsing::ParsingTreeObject* tokenParent = nullptr; + /// Type of the parent. + WString type; + /// Field of the parent that contains the token. + WString field; + /// All acceptable semantic ids. + Ptr> acceptableSemanticIds; + + static bool RetriveContext(ParsingTokenContext& output, parsing::ParsingTreeNode* foundNode, RepeatingParsingExecutor* executor); + static bool RetriveContext(ParsingTokenContext& output, parsing::ParsingTextPos pos, parsing::ParsingTreeObject* rootNode, RepeatingParsingExecutor* executor); + static bool RetriveContext(ParsingTokenContext& output, parsing::ParsingTextRange range, parsing::ParsingTreeObject* rootNode, RepeatingParsingExecutor* executor); + }; + +/*********************************************************************** +RepeatingParsingExecutor +***********************************************************************/ + + /// Repeating parsing executor. + class RepeatingParsingExecutor : public RepeatingTaskExecutor, public Description + { + public: + /// Callback. + class ICallback : public virtual Interface + { + public: + /// Callback when a parsing task is finished. + /// the result of the parsing. + virtual void OnParsingFinishedAsync(const RepeatingParsingOutput& output)=0; + /// Callback when requires enabling or disabling automatically repeating calling to the SubmitTask function. + /// Set to true to require an automatically repeating calling to the SubmitTask function + virtual void RequireAutoSubmitTask(bool enabled)=0; + }; + + /// Parsing analyzer. + class IParsingAnalyzer : public virtual Interface + { + private: + parsing::ParsingTreeNode* ToParent(parsing::ParsingTreeNode* node, const RepeatingPartialParsingOutput* output); + parsing::ParsingTreeObject* ToChild(parsing::ParsingTreeObject* node, const RepeatingPartialParsingOutput* output); + Ptr ToChild(Ptr node, const RepeatingPartialParsingOutput* output); + + protected: + /// Get a syntax tree node's parent when the whole tree is in a partial modified state. You should use this function instead of ParsingTreeNode::GetParent when implementing this interface. + /// Returns the parent node. + /// The node. + /// The partial parsing output, which describes how the whole tree is partial modified. + parsing::ParsingTreeNode* GetParent(parsing::ParsingTreeNode* node, const RepeatingPartialParsingOutput* output); + /// Get a syntax tree node's member when the whole tree is in a partial modified state. You should use this function instead of ParsingTreeObject::GetMember when implementing this interface. + /// Returns the member node. + /// The node. + /// The name of the member. + /// The partial parsing output, which describes how the whole tree is partial modified. + Ptr GetMember(parsing::ParsingTreeObject* node, const WString& name, const RepeatingPartialParsingOutput* output); + /// Get a syntax tree node's item when the whole tree is in a partial modified state. You should use this function instead of ParsingTreeArray::GetItem when implementing this interface. + /// Returns the item node. + /// The node. + /// The index of the item. + /// The partial parsing output, which describes how the whole tree is partial modified. + Ptr GetItem(parsing::ParsingTreeArray* node, vint index, const RepeatingPartialParsingOutput* output); + + public: + /// Called when a is created. + /// The releated . + virtual void Attach(RepeatingParsingExecutor* executor) = 0; + + /// Called when a is destroyed. + /// The releated . + virtual void Detach(RepeatingParsingExecutor* executor) = 0; + + /// Called when a new parsing result is produced. A parsing analyzer can create a cache to be attached to the output containing anything necessary. This function does not run in UI thread. + /// The new parsing result. + /// The created cache object, which can be null. + virtual Ptr CreateCacheAsync(const RepeatingParsingOutput& output) = 0; + + /// Called when an semantic id for a token is needed. If an semantic id is returned, a context sensitive color can be assigned to this token. This functio does not run in UI thread, but it will only be called (for several times) after the cache object is initialized. + /// The token context. + /// The current parsing result. + /// The semantic id. + virtual vint GetSemanticIdForTokenAsync(const ParsingTokenContext& tokenContext, const RepeatingParsingOutput& output) = 0; + + /// Called when multiple auto complete candidate items for a token is needed. If nothing is written into the "candidateItems" parameter and the grammar also doesn't provide static candidate items, nothing will popup. This functio does not run in UI thread, but it will only be called (for several times) after the cache object is initialized. + /// The token context. + /// The partial parsing result. It contains the current parsing result, and an incremental parsing result. If the calculation of candidate items are is very context sensitive, then you should be very careful when traversing the syntax tree, by carefully looking at the "originalNode" and the "modifiedNode" in the "partialOutput" parameter. + /// The candidate items. + virtual void GetCandidateItemsAsync(const ParsingTokenContext& tokenContext, const RepeatingPartialParsingOutput& partialOutput, collections::List& candidateItems) = 0; + + /// Create a tag object for a candidate item without a tag object. An candidate item without a tag maybe created by calling or any token marked by a @Candidate attribute in the grammar. + /// The candidate item. + /// The tag object. In most of the case this object is used for data binding or any other purpose when you want to customize the auto complete control. Returns null if the specified [T.vl.presentation.controls.GuiTextBoxAutoCompleteBase.IAutoCompleteControlProvider] can handle null tag correctly. + virtual description::Value CreateTagForCandidateItem(ParsingCandidateItem& item) = 0; + }; + + /// A base class for implementing a callback. + class CallbackBase : public virtual ICallback, public virtual ICommonTextEditCallback + { + private: + bool callbackAutoPushing; + elements::GuiColorizedTextElement* callbackElement; + SpinLock* callbackElementModifyLock; + + protected: + Ptr parsingExecutor; + + public: + CallbackBase(Ptr _parsingExecutor); + ~CallbackBase(); + + void RequireAutoSubmitTask(bool enabled)override; + void Attach(elements::GuiColorizedTextElement* _element, SpinLock& _elementModifyLock, compositions::GuiGraphicsComposition* _ownerComposition, vuint editVersion)override; + void Detach()override; + void TextEditPreview(TextEditPreviewStruct& arguments)override; + void TextEditNotify(const TextEditNotifyStruct& arguments)override; + void TextCaretChanged(const TextCaretChangedStruct& arguments)override; + void TextEditFinished(vuint editVersion)override; + }; + + struct TokenMetaData + { + vint tableTokenIndex; + vint lexerTokenIndex; + vint defaultColorIndex; + bool hasContextColor; + bool hasAutoComplete; + bool isCandidate; + WString unescapedRegexText; + }; + + struct FieldMetaData + { + vint colorIndex; + Ptr> semantics; + }; + private: + Ptr grammarParser; + WString grammarRule; + Ptr analyzer; + collections::List callbacks; + collections::List activatedCallbacks; + ICallback* autoPushingCallback; + + typedef collections::Pair FieldDesc; + collections::Dictionary tokenIndexMap; + collections::SortedList semanticIndexMap; + collections::Dictionary tokenMetaDatas; + collections::Dictionary fieldMetaDatas; + + protected: + + void Execute(const RepeatingParsingInput& input)override; + void PrepareMetaData(); + + /// Called when semantic analyzing is needed. It is encouraged to set the "cache" fields in "context" argument. If there is an binded to the , this function can be automatically done. + /// The parsing result. + virtual void OnContextFinishedAsync(RepeatingParsingOutput& context); + public: + /// Initialize the parsing executor. + /// Parser generated from a grammar. + /// The rule name to parse a complete code. + /// The parsing analyzer to create semantic metadatas, it can be null. + RepeatingParsingExecutor(Ptr _grammarParser, const WString& _grammarRule, Ptr _analyzer = 0); + ~RepeatingParsingExecutor(); + + /// Get the internal parser that parse the text. + /// The internal parser. + Ptr GetParser(); + /// Detach callback. + /// Returns true if this operation succeeded. + /// The callback. + bool AttachCallback(ICallback* value); + /// Detach callback. + /// Returns true if this operation succeeded. + /// The callback. + bool DetachCallback(ICallback* value); + /// Activate a callback. Activating a callback means that the callback owner has an ability to watch a text box modification, e.g., an attached that is also an . The may require one of the activated callback to push code for parsing automatically via a call to . + /// Returns true if this operation succeeded. + /// The callback. + bool ActivateCallback(ICallback* value); + /// Deactivate a callback. See for deatils. + /// Returns true if this operation succeeded. + /// The callback. + bool DeactivateCallback(ICallback* value); + /// Get the parsing analyzer. + /// The parsing analyzer. + Ptr GetAnalyzer(); + + vint GetTokenIndex(const WString& tokenName); + vint GetSemanticId(const WString& name); + WString GetSemanticName(vint id); + const TokenMetaData& GetTokenMetaData(vint regexTokenIndex); + const FieldMetaData& GetFieldMetaData(const WString& type, const WString& field); + + Ptr GetAttribute(vint index, const WString& name, vint argumentCount); + Ptr GetColorAttribute(vint index); + Ptr GetContextColorAttribute(vint index); + Ptr GetSemanticAttribute(vint index); + Ptr GetCandidateAttribute(vint index); + Ptr GetAutoCompleteAttribute(vint index); + + /* + @Color(ColorName) + field: color of the token field when the token type is marked with @ContextColor + token: color of the token + @ContextColor() + token: the color of the token may be changed if the token field is marked with @Color or @Semantic + @Semantic(Type1, Type2, ...) + field: After resolved symbols for this field, only types of symbols that specified in the arguments are acceptable. + @Candidate() + token: when the token can be available after the editing caret, than it will be in the auto complete list. + @AutoComplete() + token: when the token is editing, an auto complete list will appear if possible + */ + }; + } + } +} + +#endif + +/*********************************************************************** +.\CONTROLS\TEXTEDITORPACKAGE\LANGUAGESERVICE\GUILANGUAGEAUTOCOMPLETE.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Control System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_CONTROLS_GUILANGUAGEAUTOCOMPLETE +#define VCZH_PRESENTATION_CONTROLS_GUILANGUAGEAUTOCOMPLETE + +namespace vl +{ + namespace presentation + { + namespace controls + { + +/*********************************************************************** +GuiGrammarAutoComplete +***********************************************************************/ + + /// Grammar based auto complete controller. + class GuiGrammarAutoComplete + : public GuiTextBoxAutoCompleteBase + , protected RepeatingParsingExecutor::CallbackBase + , private RepeatingTaskExecutor + { + public: + + /// The auto complete list data. + struct AutoCompleteData : ParsingTokenContext + { + /// Available candidate tokens (in lexer token index). + collections::List candidates; + /// Available candidate tokens (in lexer token index) that marked with @AutoCompleteCandidate(). + collections::List shownCandidates; + /// Candidate items. + collections::List candidateItems; + /// The start position of the editing token in global coordination. + TextPos startPosition; + }; + + /// The analysed data from an input code. + struct AutoCompleteContext : RepeatingPartialParsingOutput + { + /// The edit version of modified code. + vuint modifiedEditVersion = 0; + /// The analysed auto complete list data. + Ptr autoComplete; + }; + private: + Ptr grammarParser; + collections::SortedList leftRecursiveRules; + bool editing; + + SpinLock editTraceLock; + collections::List editTrace; + + SpinLock contextLock; + AutoCompleteContext context; + + void Attach(elements::GuiColorizedTextElement* _element, SpinLock& _elementModifyLock, compositions::GuiGraphicsComposition* _ownerComposition, vuint editVersion)override; + void Detach()override; + void TextEditPreview(TextEditPreviewStruct& arguments)override; + void TextEditNotify(const TextEditNotifyStruct& arguments)override; + void TextCaretChanged(const TextCaretChangedStruct& arguments)override; + void TextEditFinished(vuint editVersion)override; + void OnParsingFinishedAsync(const RepeatingParsingOutput& output)override; + void CollectLeftRecursiveRules(); + + vint UnsafeGetEditTraceIndex(vuint editVersion); + TextPos ChooseCorrectTextPos(TextPos pos, const regex::RegexTokens& tokens); + void ExecuteRefresh(AutoCompleteContext& newContext); + + bool NormalizeTextPos(AutoCompleteContext& newContext, elements::text::TextLines& lines, TextPos& pos); + void ExecuteEdit(AutoCompleteContext& newContext); + + void DeleteFutures(collections::List& futures); + regex::RegexToken* TraverseTransitions( + parsing::tabling::ParsingState& state, + parsing::tabling::ParsingTransitionCollector& transitionCollector, + TextPos stopPosition, + collections::List& nonRecoveryFutures, + collections::List& recoveryFutures + ); + regex::RegexToken* SearchValidInputToken( + parsing::tabling::ParsingState& state, + parsing::tabling::ParsingTransitionCollector& transitionCollector, + TextPos stopPosition, + AutoCompleteContext& newContext, + collections::SortedList& tableTokenIndices + ); + + TextPos GlobalTextPosToModifiedTextPos(AutoCompleteContext& newContext, TextPos pos); + TextPos ModifiedTextPosToGlobalTextPos(AutoCompleteContext& newContext, TextPos pos); + void ExecuteCalculateList(AutoCompleteContext& newContext); + + void Execute(const RepeatingParsingOutput& input)override; + void PostList(const AutoCompleteContext& newContext, bool byGlobalCorrection); + void Initialize(); + protected: + + /// Called when the context of the code is selected. It is encouraged to set the "candidateItems" field in "context.autoComplete" during the call. If there is an binded to the , this function can be automatically done. + /// The selected context. + virtual void OnContextFinishedAsync(AutoCompleteContext& context); + + /// Call this function in the derived class's destructor when it overrided . + void EnsureAutoCompleteFinished(); + public: + /// Create the auto complete controller with a created parsing executor. + /// The parsing executor. + GuiGrammarAutoComplete(Ptr _parsingExecutor); + /// Create the auto complete controller with a specified grammar and start rule to create a . + /// Parser generated from a grammar. + /// + GuiGrammarAutoComplete(Ptr _grammarParser, const WString& _grammarRule); + ~GuiGrammarAutoComplete(); + + /// Get the internal parsing executor. + /// The parsing executor. + Ptr GetParsingExecutor(); + }; + } + } +} + +#endif + +/*********************************************************************** +.\CONTROLS\TEXTEDITORPACKAGE\LANGUAGESERVICE\GUILANGUAGECOLORIZER.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Control System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_CONTROLS_GUILANGUAGECOLORIZER +#define VCZH_PRESENTATION_CONTROLS_GUILANGUAGECOLORIZER + + +namespace vl +{ + namespace presentation + { + namespace controls + { + +/*********************************************************************** +GuiGrammarColorizer +***********************************************************************/ + + /// Grammar based colorizer. + class GuiGrammarColorizer : public GuiTextBoxRegexColorizer, protected RepeatingParsingExecutor::CallbackBase + { + typedef collections::Pair FieldDesc; + typedef collections::Dictionary FieldContextColors; + typedef collections::Dictionary FieldSemanticColors; + typedef elements::text::ColorEntry ColorEntry; + public: + /// Context for doing semantic colorizing. + struct SemanticColorizeContext : ParsingTokenContext + { + /// Output semantic id that comes from one the argument in the @Semantic attribute. + vint semanticId; + }; + private: + collections::Dictionary colorSettings; + collections::Dictionary semanticColorMap; + + SpinLock contextLock; + RepeatingParsingOutput context; + + void OnParsingFinishedAsync(const RepeatingParsingOutput& output)override; + protected: + /// Called when the node is parsed successfully before restarting colorizing. + /// The result of the parsing. + virtual void OnContextFinishedAsync(const RepeatingParsingOutput& context); + + void Attach(elements::GuiColorizedTextElement* _element, SpinLock& _elementModifyLock, compositions::GuiGraphicsComposition* _ownerComposition, vuint editVersion)override; + void Detach()override; + void TextEditPreview(TextEditPreviewStruct& arguments)override; + void TextEditNotify(const TextEditNotifyStruct& arguments)override; + void TextCaretChanged(const TextCaretChangedStruct& arguments)override; + void TextEditFinished(vuint editVersion)override; + + /// Called when a @SemanticColor attribute in a grammar is activated during colorizing to determine a color for the token. If there is an binded to the , this function can be automatically done. + /// Context for doing semantic colorizing. + /// The corressponding result from the . + virtual void OnSemanticColorize(SemanticColorizeContext& context, const RepeatingParsingOutput& input); + + /// Call this function in the derived class's destructor when it overrided . + void EnsureColorizerFinished(); + public: + /// Create the colorizer with a created parsing executor. + /// The parsing executor. + GuiGrammarColorizer(Ptr _parsingExecutor); + /// Create the colorizer with a specified grammar and start rule to create a . + /// Parser generated from a grammar. + /// + GuiGrammarColorizer(Ptr _grammarParser, const WString& _grammarRule); + ~GuiGrammarColorizer(); + + /// Reset all color settings. + void BeginSetColors(); + /// Get all color names. + /// All color names. + const collections::SortedList& GetColorNames(); + /// Get the color for a token theme name (@Color or @ContextColor("theme-name") in the grammar). + /// The color. + /// The token theme name. + ColorEntry GetColor(const WString& name); + /// Set a color for a token theme name (@Color or @ContextColor("theme-name") in the grammar). + /// The token theme name. + /// The color. + void SetColor(const WString& name, const ColorEntry& entry); + /// Set a color for a token theme name (@Color or @ContextColor("theme-name") in the grammar). + /// The token theme name. + /// The color. + void SetColor(const WString& name, const Color& color); + /// Submit all color settings. + void EndSetColors(); + void ColorizeTokenContextSensitive(vint lineIndex, const wchar_t* text, vint start, vint length, vint& token, vint& contextState)override; + + /// Get the internal parsing executor. + /// The parsing executor. + Ptr GetParsingExecutor(); + }; + } + } +} + +#endif + +/*********************************************************************** +.\CONTROLS\TOOLSTRIPPACKAGE\GUIMENUCONTROLS.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Control System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_CONTROLS_GUIMENUCONTROLS +#define VCZH_PRESENTATION_CONTROLS_GUIMENUCONTROLS + + +namespace vl +{ + namespace presentation + { + namespace controls + { + +/*********************************************************************** +Menu Service +***********************************************************************/ + + class GuiMenu; + + /// IGuiMenuService is a required service for menu item container. + class IGuiMenuService : public virtual IDescriptable, public Description + { + public: + /// The identifier for this service. + static const wchar_t* const Identifier; + + /// Direction to decide the position for a menu with specified control. + enum Direction + { + /// Aligned to the top or bottom side. + Horizontal, + /// Aligned to the left or right side. + Vertical, + }; + protected: + GuiMenu* openingMenu; + public: + IGuiMenuService(); + + /// Get the parent service. This service represents the parent menu that host the menu item control that contains this menu. + /// The parent service. + virtual IGuiMenuService* GetParentMenuService()=0; + /// Get the preferred direction to open the sub menu. + /// The preferred direction to open the sub menu. + virtual Direction GetPreferredDirection()=0; + /// Test is this menu is active. When an menu is active, the sub menu is automatically opened when the corresponding menu item is opened. + /// Returns true if this menu is active. + virtual bool IsActiveState()=0; + /// Test all sub menu items are actived by mouse down. + /// Returns true if all sub menu items are actived by mouse down. + virtual bool IsSubMenuActivatedByMouseDown()=0; + + /// Called when the menu item is executed. + virtual void MenuItemExecuted(); + /// Get the opening sub menu. + /// The opening sub menu. + virtual GuiMenu* GetOpeningMenu(); + /// Called when the sub menu is opened. + /// The sub menu. + virtual void MenuOpened(GuiMenu* menu); + /// Called when the sub menu is closed. + /// The sub menu. + virtual void MenuClosed(GuiMenu* menu); + }; + +/*********************************************************************** +Menu +***********************************************************************/ + + /// Popup menu. + class GuiMenu : public GuiPopup, private IGuiMenuService, public Description + { + private: + IGuiMenuService* parentMenuService; + + IGuiMenuService* GetParentMenuService()override; + Direction GetPreferredDirection()override; + bool IsActiveState()override; + bool IsSubMenuActivatedByMouseDown()override; + void MenuItemExecuted()override; + protected: + GuiControl* owner; + + void OnDeactivatedAltHost()override; + void MouseClickedOnOtherWindow(GuiWindow* window)override; + void OnWindowOpened(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void OnWindowClosed(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + public: + /// Create a control with a specified style controller. + /// The style controller. + /// The owner menu item of the parent menu. + GuiMenu(IStyleController* _styleController, GuiControl* _owner); + ~GuiMenu(); + + /// Update the reference to the parent . This function is not required to call outside the menu or menu item control. + void UpdateMenuService(); + IDescriptable* QueryService(const WString& identifier)override; + }; + + /// Menu bar. + class GuiMenuBar : public GuiControl, private IGuiMenuService, public Description + { + private: + IGuiMenuService* GetParentMenuService()override; + Direction GetPreferredDirection()override; + bool IsActiveState()override; + bool IsSubMenuActivatedByMouseDown()override; + public: + /// Create a control with a specified style controller. + /// The style controller. + GuiMenuBar(GuiControl::IStyleController* _styleController); + ~GuiMenuBar(); + + IDescriptable* QueryService(const WString& identifier)override; + }; + +/*********************************************************************** +MenuButton +***********************************************************************/ + + /// Menu item. + class GuiMenuButton : public GuiSelectableButton, public Description + { + public: + /// Style controller interface for . + class IStyleController : public virtual GuiSelectableButton::IStyleController, public Description + { + public: + /// Create a style controller for the sub menu. + /// The style controller for the sub menu. + virtual GuiMenu::IStyleController* CreateSubMenuStyleController()=0; + /// Notify that the sub menu is created or destroyed. + /// Set to true if the sub menu is created. + virtual void SetSubMenuExisting(bool value)=0; + /// Notify that the sub menu is opened or closed. + /// Set to true if the sub menu is opened. + virtual void SetSubMenuOpening(bool value)=0; + /// Get the button control that is expected to be associated with a sub menu. + /// The button control that is expected to be associated with a sub menu. Returns null means that the sub menu will be directly associated to the menu button. + virtual GuiButton* GetSubMenuHost()=0; + /// Notify that the image for the menu button is changed. + /// The image for the menu button. + virtual void SetImage(Ptr value)=0; + /// Notify that the shortcut key text for the menu button is changed. + /// The shortcut key text for the menu button. + virtual void SetShortcutText(const WString& value)=0; + }; + protected: + IStyleController* styleController; + Ptr image; + WString shortcutText; + GuiMenu* subMenu; + bool ownedSubMenu; + Size preferredMenuClientSize; + IGuiMenuService* ownerMenuService; + bool cascadeAction; + + GuiButton* GetSubMenuHost(); + void OpenSubMenuInternal(); + void OnParentLineChanged()override; + bool IsAltAvailable()override; + compositions::IGuiAltActionHost* GetActivatingAltHost()override; + + void OnSubMenuWindowOpened(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void OnSubMenuWindowClosed(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void OnMouseEnter(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void OnClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + + virtual IGuiMenuService::Direction GetSubMenuDirection(); + public: + /// Create a control with a specified style controller. + /// The style controller. + GuiMenuButton(IStyleController* _styleController); + ~GuiMenuButton(); + + /// Sub menu opening changed event. + compositions::GuiNotifyEvent SubMenuOpeningChanged; + /// Image changed event. + compositions::GuiNotifyEvent ImageChanged; + /// Shortcut text changed event. + compositions::GuiNotifyEvent ShortcutTextChanged; + + /// Get the image for the menu button. + /// The image for the menu button. + Ptr GetImage(); + /// Set the image for the menu button. + /// The image for the menu button. + void SetImage(Ptr value); + /// Get the shortcut key text for the menu button. + /// The shortcut key text for the menu button. + const WString& GetShortcutText(); + /// Set the shortcut key text for the menu button. + /// The shortcut key text for the menu button. + void SetShortcutText(const WString& value); + + /// Test does the sub menu exist. + /// Returns true if the sub menu exists. + bool IsSubMenuExists(); + /// Get the sub menu. If the sub menu is not created, it returns null. + /// The sub menu. + GuiMenu* GetSubMenu(); + /// Create the sub menu if necessary. The created sub menu is owned by this menu button. + /// The created sub menu. + /// The style controller for the sub menu. If this argument is null, it will call for a style controller. + GuiMenu* CreateSubMenu(GuiMenu::IStyleController* subMenuStyleController=0); + /// Associate a sub menu if there is no sub menu binded in this menu button. The associated sub menu is not owned by this menu button if the "owned" argument is set to false. + /// The sub menu to associate. + /// Set to true if the menu is expected to be owned. + void SetSubMenu(GuiMenu* value, bool owned); + /// Destroy the sub menu if necessary. + void DestroySubMenu(); + /// Test is the sub menu owned by this menu button. If the sub menu is owned, both deleting this menu button or calling will delete the sub menu. + /// Returns true if the sub menu is owned by this menu button. + bool GetOwnedSubMenu(); + + /// Test is the sub menu opened. + /// Returns true if the sub menu is opened. + bool GetSubMenuOpening(); + /// Open or close the sub menu. + /// Set to true to open the sub menu. + void SetSubMenuOpening(bool value); + + /// Get the preferred client size for the sub menu. + /// The preferred client size for the sub menu. + Size GetPreferredMenuClientSize(); + /// Set the preferred client size for the sub menu. + /// The preferred client size for the sub menu. + void SetPreferredMenuClientSize(Size value); + + /// Test is cascade action enabled. If the cascade action is enabled, when the mouse enter this menu button, the sub menu will be automatically opened if the parent menu is in an active state (see ), closing the sub menu will also close the parent menu. + /// Returns true if cascade action is enabled. + bool GetCascadeAction(); + /// Enable or disable cascade action. + /// Set to true to enable cascade action. + void SetCascadeAction(bool value); + }; + } + } +} + +#endif + +/*********************************************************************** +.\CONTROLS\LISTCONTROLPACKAGE\GUILISTVIEWCONTROLS.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Control System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_CONTROLS_GUILISTVIEWCONTROLS +#define VCZH_PRESENTATION_CONTROLS_GUILISTVIEWCONTROLS + + +namespace vl +{ + namespace presentation + { + namespace controls + { + ///List view column header control for detailed view. + class GuiListViewColumnHeader : public GuiMenuButton, public Description + { + public: + /// Style provider for . + class IStyleController : public virtual GuiMenuButton::IStyleController, public Description + { + public: + /// Notify that the column sorting state is changed. + /// The new column sorting state. + virtual void SetColumnSortingState(ColumnSortingState value)=0; + }; + + protected: + IStyleController* styleController = nullptr; + ColumnSortingState columnSortingState = ColumnSortingState::NotSorted; + + public: + /// Create a control with a specified style controller. + /// The style controller. + GuiListViewColumnHeader(IStyleController* _styleController); + ~GuiListViewColumnHeader(); + + bool IsAltAvailable()override; + + /// Get the column sorting state. + /// The column sorting state. + ColumnSortingState GetColumnSortingState(); + /// Set the column sorting state. + /// The new column sorting state. + void SetColumnSortingState(ColumnSortingState value); + }; + + /// List view base control. All list view controls inherit from this class. is suggested to be the base class of item style providers for list view control. + class GuiListViewBase : public GuiSelectableListControl, public Description + { + public: + /// Style provider for . + class IStyleProvider : public virtual GuiSelectableListControl::IStyleProvider, public Description + { + public: + /// Create a style controller for a column header. + /// The created style controller for a column header. + virtual GuiListViewColumnHeader::IStyleController* CreateColumnStyle()=0; + /// Get the primary text color. + /// The primary text color. + virtual Color GetPrimaryTextColor()=0; + /// Get the secondary text color. + /// The secondary text color. + virtual Color GetSecondaryTextColor()=0; + /// Get the item peparator text color. + /// The item peparator text color. + virtual Color GetItemSeparatorColor()=0; + }; + + protected: + IStyleProvider* styleProvider; + + public: + /// Create a list view base control. + /// The style provider for this control. + /// The item provider for this control. + GuiListViewBase(IStyleProvider* _styleProvider, GuiListControl::IItemProvider* _itemProvider); + ~GuiListViewBase(); + + /// Column clicked event. + compositions::GuiItemNotifyEvent ColumnClicked; + + /// Get the associated style provider. + /// The style provider. + IStyleProvider* GetListViewStyleProvider(); + }; + +/*********************************************************************** +ListView ItemStyleProvider +***********************************************************************/ + + namespace list + { + /// The required view for . + class IListViewItemView : public virtual IDescriptable, public Description + { + public: + /// The identifier for this view. + static const wchar_t* const Identifier; + + /// Get the small image of an item. + /// The small image. + /// The index of the item. + virtual Ptr GetSmallImage(vint itemIndex) = 0; + /// Get the large image of an item. + /// The large image. + /// The index of the item. + virtual Ptr GetLargeImage(vint itemIndex) = 0; + /// Get the text of an item. + /// The text. + /// The index of the item. + virtual WString GetText(vint itemIndex) = 0; + /// Get the sub item text of an item. If the sub item index out of range, it returns an empty string. + /// The sub item text. + /// The index of the item. + /// The sub item index of the item. + virtual WString GetSubItem(vint itemIndex, vint index) = 0; + + /// Get the number of data columns. + /// The number of data columns. + virtual vint GetDataColumnCount() = 0; + /// Get the column index of the index-th data column. + /// The column index. + /// The order of the data column. + virtual vint GetDataColumn(vint index) = 0; + + /// Get the number of all columns. + /// The number of all columns. + virtual vint GetColumnCount() = 0; + /// Get the text of the column. + /// The text of the column. + /// The index of the column. + virtual WString GetColumnText(vint index) = 0; + }; + +/*********************************************************************** +ListViewColumnItemArranger +***********************************************************************/ + + /// List view column item arranger. This arranger contains column headers. When an column header is resized, all items will be notified via the [T:vl.presentation.controls.list.ListViewColumnItemArranger.IColumnItemView] for . + class ListViewColumnItemArranger : public FixedHeightItemArranger, public Description + { + typedef collections::List ColumnHeaderButtonList; + typedef collections::List ColumnHeaderSplitterList; + public: + static const vint SplitterWidth=8; + + /// Callback for [T:vl.presentation.controls.list.ListViewColumnItemArranger.IColumnItemView]. Column item view use this interface to notify column related modification. + class IColumnItemViewCallback : public virtual IDescriptable, public Description + { + public: + /// Called when any column is changed (inserted, removed, text changed, etc.). + virtual void OnColumnChanged()=0; + }; + + /// The required view for . + class IColumnItemView : public virtual IDescriptable, public Description + { + public: + /// The identifier for this view. + static const wchar_t* const Identifier; + + /// Attach an column item view callback to this view. + /// Returns true if this operation succeeded. + /// The column item view callback. + virtual bool AttachCallback(IColumnItemViewCallback* value)=0; + /// Detach an column item view callback from this view. + /// Returns true if this operation succeeded. + /// The column item view callback. + virtual bool DetachCallback(IColumnItemViewCallback* value)=0; + + /// Get the size of the column. + /// The size of the column. + /// The index of the column. + virtual vint GetColumnSize(vint index)=0; + /// Set the size of the column. + /// The index of the column. + /// The new size of the column. + virtual void SetColumnSize(vint index, vint value)=0; + + /// Get the popup binded to the column. + /// The popup binded to the column. + /// The index of the column. + virtual GuiMenu* GetDropdownPopup(vint index)=0; + /// Get the sorting state of the column. + /// The sorting state of the column. + /// The index of the column. + virtual ColumnSortingState GetSortingState(vint index)=0; + }; + protected: + class ColumnItemViewCallback : public Object, public virtual IColumnItemViewCallback + { + protected: + ListViewColumnItemArranger* arranger; + public: + ColumnItemViewCallback(ListViewColumnItemArranger* _arranger); + ~ColumnItemViewCallback(); + + void OnColumnChanged(); + }; + + GuiListViewBase* listView = nullptr; + GuiListViewBase::IStyleProvider* styleProvider = nullptr; + IListViewItemView* listViewItemView = nullptr; + IColumnItemView* columnItemView = nullptr; + Ptr columnItemViewCallback; + compositions::GuiStackComposition* columnHeaders = nullptr; + ColumnHeaderButtonList columnHeaderButtons; + ColumnHeaderSplitterList columnHeaderSplitters; + bool splitterDragging = false; + vint splitterLatestX = 0; + + void ColumnClicked(vint index, compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void ColumnBoundsChanged(vint index, compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void ColumnHeaderSplitterLeftButtonDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); + void ColumnHeaderSplitterLeftButtonUp(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); + void ColumnHeaderSplitterMouseMove(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments); + + void RearrangeItemBounds()override; + vint GetWidth()override; + vint GetYOffset()override; + Size OnCalculateTotalSize()override; + void DeleteColumnButtons(); + void RebuildColumns(); + public: + ListViewColumnItemArranger(); + ~ListViewColumnItemArranger(); + + void AttachListControl(GuiListControl* value)override; + void DetachListControl()override; + }; + } + +/*********************************************************************** +ListViewItemProvider +***********************************************************************/ + + namespace list + { + class ListViewItem; + + class ListViewSubItems : public collections::ObservableListBase + { + friend class ListViewItem; + protected: + ListViewItem* owner; + + void NotifyUpdateInternal(vint start, vint count, vint newCount)override; + public: + }; + + class ListViewItemProvider; + + /// List view item. + class ListViewItem : public Object, public Description + { + friend class ListViewSubItems; + friend class ListViewItemProvider; + protected: + ListViewItemProvider* owner; + ListViewSubItems subItems; + Ptr smallImage; + Ptr largeImage; + WString text; + description::Value tag; + + void NotifyUpdate(); + public: + /// Create a list view item. + ListViewItem(); + + /// Get all sub items of this item. + /// All sub items of this item. + ListViewSubItems& GetSubItems(); + /// Get the small image of this item. + /// The small image of this item. + Ptr GetSmallImage(); + /// Set the small image of this item. + /// The small image of this item. + void SetSmallImage(Ptr value); + /// Get the large image of this item. + /// The large image of this item. + Ptr GetLargeImage(); + /// Set the large image of this item. + /// The large image of this item. + void SetLargeImage(Ptr value); + /// Get the text of this item. + /// The text of this item. + const WString& GetText(); + /// Set the text of this item. + /// The text of this item. + void SetText(const WString& value); + /// Get the tag of this item. + /// The tag of this item. + description::Value GetTag(); + /// Set the tag of this item. + /// The tag of this item. + void SetTag(const description::Value& value); + }; + + class ListViewColumns; + + /// List view column. + class ListViewColumn : public Object, public Description + { + friend class ListViewColumns; + protected: + ListViewColumns* owner = nullptr; + WString text; + ItemProperty textProperty; + vint size; + bool ownPopup = true; + GuiMenu* dropdownPopup = nullptr; + ColumnSortingState sortingState = ColumnSortingState::NotSorted; + + void NotifyUpdate(bool affectItem); + public: + /// Create a column with the specified text and size. + /// The specified text. + /// The specified size. + ListViewColumn(const WString& _text=L"", vint _size=160); + ~ListViewColumn(); + + /// Get the text of this item. + /// The text of this item. + const WString& GetText(); + /// Set the text of this item. + /// The text of this item. + void SetText(const WString& value); + /// Get the text property of this item. + /// The text property of this item. + ItemProperty GetTextProperty(); + /// Set the text property of this item. + /// The text property of this item. + void SetTextProperty(const ItemProperty& value); + /// Get the size of this item. + /// The size of this item. + vint GetSize(); + /// Set the size of this item. + /// The size of this item. + void SetSize(vint value); + /// Test if the column owns the popup. Owned popup will be deleted in the destructor. + /// Returns true if the column owns the popup. + bool GetOwnPopup(); + /// Set if the column owns the popup. + /// Set to true to let the column own the popup. + void SetOwnPopup(bool value); + /// Get the dropdown context menu of this item. + /// The dropdown context menu of this item. + GuiMenu* GetDropdownPopup(); + /// Set the dropdown context menu of this item. + /// The dropdown context menu of this item. + void SetDropdownPopup(GuiMenu* value); + /// Get the sorting state of this item. + /// The sorting state of this item. + ColumnSortingState GetSortingState(); + /// Set the sorting state of this item. + /// The sorting state of this item. + void SetSortingState(ColumnSortingState value); + }; + + class IListViewItemProvider : public virtual Interface + { + public: + virtual void NotifyAllItemsUpdate() = 0; + virtual void NotifyAllColumnsUpdate() = 0; + }; + + /// List view data column container. + class ListViewDataColumns : public collections::ObservableListBase + { + protected: + IListViewItemProvider* itemProvider; + + void NotifyUpdateInternal(vint start, vint count, vint newCount)override; + public: + /// Create a container. + /// The item provider in the same control to receive notifications. + ListViewDataColumns(IListViewItemProvider* _itemProvider); + ~ListViewDataColumns(); + }; + + /// List view column container. + class ListViewColumns : public collections::ObservableListBase> + { + friend class ListViewColumn; + protected: + IListViewItemProvider* itemProvider; + bool affectItemFlag = true; + + void NotifyColumnUpdated(vint column, bool affectItem); + void AfterInsert(vint index, const Ptr& value)override; + void BeforeRemove(vint index, const Ptr& value)override; + void NotifyUpdateInternal(vint start, vint count, vint newCount)override; + public: + /// Create a container. + /// The item provider in the same control to receive notifications. + ListViewColumns(IListViewItemProvider* _itemProvider); + ~ListViewColumns(); + }; + + /// Item provider for and . + class ListViewItemProvider + : public ListProvider> + , protected virtual IListViewItemProvider + , protected virtual IListViewItemView + , protected virtual ListViewColumnItemArranger::IColumnItemView + , public Description + { + friend class ListViewItem; + friend class ListViewColumns; + friend class ListViewDataColumns; + typedef collections::List ColumnItemViewCallbackList; + protected: + ListViewDataColumns dataColumns; + ListViewColumns columns; + ColumnItemViewCallbackList columnItemViewCallbacks; + + void AfterInsert(vint index, const Ptr& value)override; + void BeforeRemove(vint index, const Ptr& value)override; + + void NotifyAllItemsUpdate()override; + void NotifyAllColumnsUpdate()override; + + Ptr GetSmallImage(vint itemIndex)override; + Ptr GetLargeImage(vint itemIndex)override; + WString GetText(vint itemIndex)override; + WString GetSubItem(vint itemIndex, vint index)override; + vint GetDataColumnCount()override; + vint GetDataColumn(vint index)override; + vint GetColumnCount()override; + WString GetColumnText(vint index)override;; + + bool AttachCallback(ListViewColumnItemArranger::IColumnItemViewCallback* value)override; + bool DetachCallback(ListViewColumnItemArranger::IColumnItemViewCallback* value)override; + vint GetColumnSize(vint index)override; + void SetColumnSize(vint index, vint value)override; + GuiMenu* GetDropdownPopup(vint index)override; + ColumnSortingState GetSortingState(vint index)override; + + WString GetTextValue(vint itemIndex)override; + description::Value GetBindingValue(vint itemIndex)override; + public: + ListViewItemProvider(); + ~ListViewItemProvider(); + + IDescriptable* RequestView(const WString& identifier)override; + + /// Get all data columns indices in columns. + /// All data columns indices in columns. + ListViewDataColumns& GetDataColumns(); + /// Get all columns. + /// All columns. + ListViewColumns& GetColumns(); + }; + } + +/*********************************************************************** +GuiVirtualListView +***********************************************************************/ + + enum class ListViewView + { + BigIcon, + SmallIcon, + List, + Tile, + Information, + Detail, + Unknown, + }; + + /// List view control in virtual mode. + class GuiVirtualListView : public GuiListViewBase, public Description + { + protected: + ListViewView view = ListViewView::Unknown; + + void OnStyleInstalled(vint itemIndex, ItemStyle* style)override; + void OnItemTemplateChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + public: + /// Create a list view control in virtual mode. + /// The style provider for this control. + /// The item provider for this control. + GuiVirtualListView(IStyleProvider* _styleProvider, GuiListControl::IItemProvider* _itemProvider); + ~GuiVirtualListView(); + + /// Get the current view. + /// The current view. After [M:vl.presentation.controls.GuiListControl.SetItemTemplate] is called, the current view is reset to Unknown. + ListViewView GetView(); + /// Set the current view. + /// The current view. + void SetView(ListViewView _view); + }; + +/*********************************************************************** +GuiListView +***********************************************************************/ + + /// List view control in virtual mode. + class GuiListView : public GuiVirtualListView, public Description + { + protected: + list::ListViewItemProvider* items; + public: + /// Create a list view control. + /// The style provider for this control. + GuiListView(IStyleProvider* _styleProvider); + ~GuiListView(); + + /// Get all list view items. + /// All list view items. + list::ListViewItemProvider& GetItems(); + /// Get all data columns indices in columns. + /// All data columns indices in columns. + list::ListViewDataColumns& GetDataColumns(); + /// Get all columns. + /// All columns. + list::ListViewColumns& GetColumns(); + + /// Get the selected item. + /// Returns the selected item. If there are multiple selected items, or there is no selected item, null will be returned. + Ptr GetSelectedItem(); + }; + } + } +} + +#endif + +/*********************************************************************** +.\CONTROLS\LISTCONTROLPACKAGE\GUICOMBOCONTROLS.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Control System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_CONTROLS_GUICOMBOCONTROLS +#define VCZH_PRESENTATION_CONTROLS_GUICOMBOCONTROLS + + +namespace vl +{ + namespace presentation + { + namespace controls + { + +/*********************************************************************** +ComboBox Base +***********************************************************************/ + + /// The base class of combo box control. + class GuiComboBoxBase : public GuiMenuButton, public Description + { + public: + /// Style controller interface for . + class IStyleController : public virtual GuiMenuButton::IStyleController, public Description + { + public: + /// Called when the command executor is changed. + /// The command executor. + virtual void SetCommandExecutor(IComboBoxCommandExecutor* value)=0; + /// Notify that an item is selected. + virtual void OnItemSelected()=0; + }; + protected: + + class CommandExecutor : public Object, public virtual IComboBoxCommandExecutor + { + protected: + GuiComboBoxBase* combo; + + public: + CommandExecutor(GuiComboBoxBase* _combo); + ~CommandExecutor(); + + void SelectItem()override; + }; + + Ptr commandExecutor; + IStyleController* styleController; + + bool IsAltAvailable()override; + IGuiMenuService::Direction GetSubMenuDirection()override; + virtual void SelectItem(); + void OnBoundsChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + public: + /// Create a control with a specified style controller. + /// The style controller. + GuiComboBoxBase(IStyleController* _styleController); + ~GuiComboBoxBase(); + + /// Item selected event. + compositions::GuiNotifyEvent ItemSelected; + }; + +/*********************************************************************** +ComboBox with GuiListControl +***********************************************************************/ + + /// Combo box list control. This control is a combo box with a list control in its popup. + class GuiComboBoxListControl : public GuiComboBoxBase, public Description + { + public: + using ItemStyleProperty = TemplateProperty; + + /// Style controller interface for . + class IStyleController : public virtual GuiComboBoxBase::IStyleController, public Description + { + public: + /// Indicate that if the combo box need to display text. + /// Set to true to display text. + virtual void SetTextVisible(bool value) = 0; + }; + + protected: + IStyleController* styleController = nullptr; + GuiSelectableListControl* containedListControl = nullptr; + ItemStyleProperty itemStyleProperty; + templates::GuiTemplate* itemStyleController = nullptr; + + bool IsAltAvailable()override; + void OnActiveAlt()override; + void RemoveStyleController(); + void InstallStyleController(vint itemIndex); + virtual void DisplaySelectedContent(vint itemIndex); + void OnTextChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void OnFontChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void OnVisuallyEnabledChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void OnListControlAdoptedSizeInvalidated(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void OnListControlSelectionChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + public: + /// Create a control with a specified style controller and a list control that will be put in the popup control to show all items. + /// The style controller. + /// The list controller. + GuiComboBoxListControl(IStyleController* _styleController, GuiSelectableListControl* _containedListControl); + ~GuiComboBoxListControl(); + + /// Style provider changed event. + compositions::GuiNotifyEvent ItemTemplateChanged; + /// Selected index changed event. + compositions::GuiNotifyEvent SelectedIndexChanged; + + /// Get the list control. + /// The list control. + GuiSelectableListControl* GetContainedListControl(); + + /// Get the item style provider. + /// The item style provider. + virtual ItemStyleProperty GetItemTemplate(); + /// Set the item style provider + /// The old item style provider + /// The new item style provider + virtual void SetItemTemplate(ItemStyleProperty value); + + /// Get the selected index. + /// The selected index. + vint GetSelectedIndex(); + /// Set the selected index. + /// The selected index. + void SetSelectedIndex(vint value); + + /// Get the selected item. + /// The selected item. + description::Value GetSelectedItem(); + /// Get the item provider in the list control. + /// The item provider in the list control. + GuiListControl::IItemProvider* GetItemProvider(); + }; + } + } +} + +#endif + +/*********************************************************************** +.\CONTROLS\GUIDATETIMECONTROLS.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Control System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_CONTROLS_GUIDATETIMECONTROLS +#define VCZH_PRESENTATION_CONTROLS_GUIDATETIMECONTROLS + + +namespace vl +{ + namespace presentation + { + namespace controls + { + +/*********************************************************************** +DatePicker +***********************************************************************/ + + /// Date picker control that display a calendar. + class GuiDatePicker : public GuiControl, public Description + { + public: + /// Style provider interface for . + class IStyleProvider : public virtual GuiControl::IStyleProvider, public Description + { + public: + /// Create a style for date button for choosing "day". + /// The created style. + virtual GuiSelectableButton::IStyleController* CreateDateButtonStyle()=0; + /// Create a text list for candidate "year" and "month". + /// The created control. + virtual GuiTextList* CreateTextList()=0; + /// Create a combo box style for "year" and "month". + /// The created style. + virtual GuiComboBoxListControl::IStyleController* CreateComboBoxStyle()=0; + + /// Get the color for background. + /// The color. + virtual Color GetBackgroundColor()=0; + /// Get the color for "day" that in the current month. + /// The color. + virtual Color GetPrimaryTextColor()=0; + /// Get the color for "day" that not in the current month. + /// The color. + virtual Color GetSecondaryTextColor()=0; + }; + + /// Style controller for . + class StyleController : public Object, public virtual GuiControl::IStyleController, public Description + { + protected: + static const vint DaysOfWeek=7; + static const vint DayRows=6; + static const vint DayRowStart=2; + static const vint YearFirst=1900; + static const vint YearLast=2099; + + IStyleProvider* styleProvider; + GuiDatePicker* datePicker; + DateTime currentDate; + Locale dateLocale; + compositions::GuiTableComposition* boundsComposition; + bool preventComboEvent; + bool preventButtonEvent; + + GuiComboBoxListControl* comboYear; + GuiTextList* listYears; + GuiComboBoxListControl* comboMonth; + GuiTextList* listMonths; + collections::Array labelDaysOfWeek; + collections::Array buttonDays; + collections::Array labelDays; + collections::Array dateDays; + Ptr dayMutexController; + + void SetDay(const DateTime& day, vint& index, bool currentMonth); + void DisplayMonth(vint year, vint month); + void SelectDay(vint day); + void comboYearMonth_SelectedIndexChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void buttonDay_SelectedChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + public: + /// Create a style controller with a specified style provider. + /// The style provider. + StyleController(IStyleProvider* _styleProvider); + ~StyleController(); + + compositions::GuiBoundsComposition* GetBoundsComposition()override; + compositions::GuiGraphicsComposition* GetContainerComposition()override; + void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; + void SetText(const WString& value)override; + void SetFont(const FontProperties& value)override; + void SetVisuallyEnabled(bool value)override; + + /// Set the data picker that owns this style controller. + /// The date picker. + void SetDatePicker(GuiDatePicker* _datePicker); + /// Set the locale to display texts. + /// The locale. + void SetDateLocale(const Locale& _dateLocale); + /// Get the displayed date. + /// The date. + const DateTime& GetDate(); + /// Display a date. + /// The date. + /// Set to true to refill all data in the control whatever cached or not. + void SetDate(const DateTime& value, bool forceUpdate=false); + }; + + protected: + StyleController* styleController; + WString dateFormat; + Locale dateLocale; + + void UpdateText(); + void NotifyDateChanged(); + public: + /// Create a control with a specified style provider. + /// The style provider. + GuiDatePicker(IStyleProvider* _styleProvider); + ~GuiDatePicker(); + + /// Date changed event. + compositions::GuiNotifyEvent DateChanged; + /// Date navigated event. Called when the current month is changed. + compositions::GuiNotifyEvent DateNavigated; + /// Date selected event. Called when a day button is selected. + compositions::GuiNotifyEvent DateSelected; + /// Date format changed event. + compositions::GuiNotifyEvent DateFormatChanged; + /// Date locale changed event. + compositions::GuiNotifyEvent DateLocaleChanged; + + /// Get the displayed date. + /// The date. + const DateTime& GetDate(); + /// Display a date. + /// The date. + void SetDate(const DateTime& value); + /// Get the format. + /// The format. + const WString& GetDateFormat(); + /// Set the format for the text of this control. + /// The format. + void SetDateFormat(const WString& value); + /// Get the locale. + /// The locale. + const Locale& GetDateLocale(); + /// Set the locale to display texts. + /// The locale. + void SetDateLocale(const Locale& value); + + void SetText(const WString& value)override; + }; + +/*********************************************************************** +DateComboBox +***********************************************************************/ + + /// A combo box control with a date picker control. + class GuiDateComboBox : public GuiComboBoxBase, public Description + { + protected: + GuiDatePicker* datePicker; + DateTime selectedDate; + + void UpdateText(); + void NotifyUpdateSelectedDate(); + void OnSubMenuOpeningChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void datePicker_DateLocaleChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void datePicker_DateFormatChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void datePicker_DateSelected(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + public: + /// Create a control with a specified style provider. + /// The style provider. + /// The date picker control to show in the popup. + GuiDateComboBox(IStyleController* _styleController, GuiDatePicker* _datePicker); + ~GuiDateComboBox(); + + /// Selected data changed event. + compositions::GuiNotifyEvent SelectedDateChanged; + + void SetFont(const FontProperties& value)override; + /// Get the displayed date. + /// The date. + const DateTime& GetSelectedDate(); + /// Display a date. + /// The date. + void SetSelectedDate(const DateTime& value); + /// Get the date picker control. + /// The date picker control. + GuiDatePicker* GetDatePicker(); + }; + } + } +} + +#endif + +/*********************************************************************** +.\CONTROLS\LISTCONTROLPACKAGE\GUIDATAGRIDINTERFACES.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -15192,7 +15781,177 @@ Datagrid Interfaces #endif /*********************************************************************** -CONTROLS\LISTCONTROLPACKAGE\GUILISTVIEWITEMTEMPLATES.H +.\CONTROLS\LISTCONTROLPACKAGE\GUIDATAGRIDEXTENSIONS.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Control System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_CONTROLS_GUIDATAEXTENSIONS +#define VCZH_PRESENTATION_CONTROLS_GUIDATAEXTENSIONS + + +namespace vl +{ + namespace presentation + { + namespace controls + { + namespace list + { + +/*********************************************************************** +Extension Bases +***********************************************************************/ + + class DataVisualizerFactory; + class DataEditorFactory; + + /// Base class for all data visualizers. + class DataVisualizerBase : public Object, public virtual IDataVisualizer + { + friend class DataVisualizerFactory; + using ItemTemplate = templates::GuiGridVisualizerTemplate; + protected: + DataVisualizerFactory* factory = nullptr; + IDataGridContext* dataGridContext = nullptr; + templates::GuiGridVisualizerTemplate* visualizerTemplate = nullptr; + + public: + /// Create the data visualizer. + /// The decorated data visualizer inside the current data visualizer. + DataVisualizerBase(); + ~DataVisualizerBase(); + + IDataVisualizerFactory* GetFactory()override; + templates::GuiGridVisualizerTemplate* GetTemplate()override; + void NotifyDeletedTemplate()override; + void BeforeVisualizeCell(GuiListControl::IItemProvider* itemProvider, vint row, vint column)override; + void SetSelected(bool value)override; + }; + + class DataVisualizerFactory : public Object, public virtual IDataVisualizerFactory, public Description + { + using ItemTemplate = templates::GuiGridVisualizerTemplate; + protected: + TemplateProperty templateFactory; + Ptr decoratedFactory; + + ItemTemplate* CreateItemTemplate(controls::list::IDataGridContext* dataGridContext); + public: + DataVisualizerFactory(TemplateProperty _templateFactory, Ptr _decoratedFactory = nullptr); + ~DataVisualizerFactory(); + + Ptr CreateVisualizer(IDataGridContext* dataGridContext)override; + }; + + /// Base class for all data editors. + class DataEditorBase : public Object, public virtual IDataEditor + { + friend class DataEditorFactory; + using ItemTemplate = templates::GuiGridEditorTemplate; + protected: + IDataEditorFactory* factory = nullptr; + IDataGridContext* dataGridContext = nullptr; + templates::GuiGridEditorTemplate* editorTemplate = nullptr; + + void OnCellValueChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + public: + /// Create the data editor. + DataEditorBase(); + ~DataEditorBase(); + + IDataEditorFactory* GetFactory()override; + templates::GuiGridEditorTemplate* GetTemplate()override; + void NotifyDeletedTemplate()override; + void BeforeEditCell(GuiListControl::IItemProvider* itemProvider, vint row, vint column)override; + bool GetCellValueSaved()override; + }; + + class DataEditorFactory : public Object, public virtual IDataEditorFactory, public Description + { + using ItemTemplate = templates::GuiGridEditorTemplate; + protected: + TemplateProperty templateFactory; + + public: + DataEditorFactory(TemplateProperty _templateFactory); + ~DataEditorFactory(); + + Ptr CreateEditor(IDataGridContext* dataGridContext)override; + }; + +/*********************************************************************** +Visualizer Extensions +***********************************************************************/ + + class MainColumnVisualizerTemplate : public templates::GuiGridVisualizerTemplate + { + protected: + elements::GuiImageFrameElement* image = nullptr; + elements::GuiSolidLabelElement* text = nullptr; + + void OnTextChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void OnFontChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void OnTextColorChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void OnSmallImageChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + public: + MainColumnVisualizerTemplate(); + ~MainColumnVisualizerTemplate(); + }; + + class SubColumnVisualizerTemplate : public templates::GuiGridVisualizerTemplate + { + protected: + elements::GuiSolidLabelElement* text = nullptr; + + void OnTextChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void OnFontChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void OnTextColorChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void Initialize(bool fixTextColor); + + SubColumnVisualizerTemplate(bool fixTextColor); + public: + SubColumnVisualizerTemplate(); + ~SubColumnVisualizerTemplate(); + }; + + class HyperlinkVisualizerTemplate : public SubColumnVisualizerTemplate + { + protected: + void label_MouseEnter(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + void label_MouseLeave(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + + public: + HyperlinkVisualizerTemplate(); + ~HyperlinkVisualizerTemplate(); + }; + + class CellBorderVisualizerTemplate : public templates::GuiGridVisualizerTemplate + { + protected: + elements::GuiSolidBorderElement* border1 = nullptr; + elements::GuiSolidBorderElement* border2 = nullptr; + + void OnItemSeparatorColorChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + + public: + CellBorderVisualizerTemplate(); + ~CellBorderVisualizerTemplate(); + }; + } + } + } +} + +#endif + +/*********************************************************************** +.\CONTROLS\LISTCONTROLPACKAGE\GUILISTVIEWITEMTEMPLATES.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -15325,7 +16084,7 @@ namespace vl #endif /*********************************************************************** -CONTROLS\LISTCONTROLPACKAGE\GUIDATAGRIDCONTROLS.H +.\CONTROLS\LISTCONTROLPACKAGE\GUIDATAGRIDCONTROLS.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -15453,433 +16212,9 @@ GuiVirtualDataGrid #endif -/*********************************************************************** -CONTROLS\LISTCONTROLPACKAGE\GUIBINDABLELISTCONTROLS.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control System - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_GUIBINDABLELISTCONTROLS -#define VCZH_PRESENTATION_CONTROLS_GUIBINDABLELISTCONTROLS - - -namespace vl -{ - namespace presentation - { - namespace controls - { - template - struct DefaultValueOf - { - static T Get() - { - return TypedValueSerializerProvider::GetDefaultValue(); - } - }; - - template - struct DefaultValueOf> - { - static Ptr Get() - { - return nullptr; - } - }; - - template<> - struct DefaultValueOf - { - static description::Value Get() - { - return description::Value(); - } - }; - - template - T ReadProperty(const description::Value& thisObject, const ItemProperty& propertyName) - { - if (!thisObject.IsNull() && propertyName) - { - return propertyName(thisObject); - } - else - { - return DefaultValueOf::Get(); - } - } - - template - T ReadProperty(const description::Value& thisObject, const WritableItemProperty& propertyName) - { - auto defaultValue = DefaultValueOf::Get(); - if (!thisObject.IsNull() && propertyName) - { - return propertyName(thisObject, defaultValue, false); - } - else - { - return defaultValue; - } - } - - template - void WriteProperty(const description::Value& thisObject, const WritableItemProperty& propertyName, const T& value) - { - if (!thisObject.IsNull() && propertyName) - { - propertyName(thisObject, value, true); - } - } /*********************************************************************** -GuiBindableTextList -***********************************************************************/ - - /// A bindable Text list control. - class GuiBindableTextList : public GuiVirtualTextList, public Description - { - protected: - class ItemSource - : public list::ItemProviderBase - , protected list::ITextItemView - { - protected: - Ptr itemChangedEventHandler; - Ptr itemSource; - - public: - ItemProperty textProperty; - WritableItemProperty checkedProperty; - - public: - ItemSource(); - ~ItemSource(); - - Ptr GetItemSource(); - void SetItemSource(Ptr _itemSource); - - description::Value Get(vint index); - void UpdateBindingProperties(); - - // ===================== GuiListControl::IItemProvider ===================== - - WString GetTextValue(vint itemIndex)override; - description::Value GetBindingValue(vint itemIndex)override; - vint Count()override; - IDescriptable* RequestView(const WString& identifier)override; - - // ===================== list::TextItemStyleProvider::ITextItemView ===================== - - bool GetChecked(vint itemIndex)override; - void SetChecked(vint itemIndex, bool value)override; - }; - - protected: - ItemSource* itemSource; - - public: - /// Create a bindable Text list control. - /// The style provider for this control. - /// The factory object to create the control styles for bullet before a text item. - GuiBindableTextList(IStyleProvider* _styleProvider); - ~GuiBindableTextList(); - - /// Text property name changed event. - compositions::GuiNotifyEvent TextPropertyChanged; - /// Checked property name changed event. - compositions::GuiNotifyEvent CheckedPropertyChanged; - - /// Get the item source. - /// The item source. - Ptr GetItemSource(); - /// Set the item source. - /// The item source. Null is acceptable if you want to clear all data. - void SetItemSource(Ptr _itemSource); - - /// Get the text property name to get the item text from an item. - /// The text property name. - ItemProperty GetTextProperty(); - /// Set the text property name to get the item text from an item. - /// The text property name. - void SetTextProperty(const ItemProperty& value); - - /// Get the checked property name to get the check state from an item. - /// The checked property name. - WritableItemProperty GetCheckedProperty(); - /// Set the checked property name to get the check state from an item. - /// The checked property name. - void SetCheckedProperty(const WritableItemProperty& value); - - /// Get the selected item. - /// Returns the selected item. If there are multiple selected items, or there is no selected item, null will be returned. - description::Value GetSelectedItem(); - }; - -/*********************************************************************** -GuiBindableListView -***********************************************************************/ - - /// A bindable List view control. - class GuiBindableListView : public GuiVirtualListView, public Description - { - protected: - class ItemSource - : public list::ItemProviderBase - , protected virtual list::IListViewItemProvider - , protected virtual list::IListViewItemView - , protected virtual list::ListViewColumnItemArranger::IColumnItemView - { - typedef collections::List ColumnItemViewCallbackList; - protected: - list::ListViewDataColumns dataColumns; - list::ListViewColumns columns; - ColumnItemViewCallbackList columnItemViewCallbacks; - Ptr itemChangedEventHandler; - Ptr itemSource; - - public: - ItemProperty> largeImageProperty; - ItemProperty> smallImageProperty; - - public: - ItemSource(); - ~ItemSource(); - - Ptr GetItemSource(); - void SetItemSource(Ptr _itemSource); - - description::Value Get(vint index); - void UpdateBindingProperties(); - bool NotifyUpdate(vint start, vint count); - list::ListViewDataColumns& GetDataColumns(); - list::ListViewColumns& GetColumns(); - - // ===================== list::IListViewItemProvider ===================== - - void NotifyAllItemsUpdate()override; - void NotifyAllColumnsUpdate()override; - - // ===================== GuiListControl::IItemProvider ===================== - - WString GetTextValue(vint itemIndex)override; - description::Value GetBindingValue(vint itemIndex)override; - vint Count()override; - IDescriptable* RequestView(const WString& identifier)override; - - // ===================== list::ListViewItemStyleProvider::IListViewItemView ===================== - - Ptr GetSmallImage(vint itemIndex)override; - Ptr GetLargeImage(vint itemIndex)override; - WString GetText(vint itemIndex)override; - WString GetSubItem(vint itemIndex, vint index)override; - vint GetDataColumnCount()override; - vint GetDataColumn(vint index)override; - vint GetColumnCount()override; - WString GetColumnText(vint index)override; - - // ===================== list::ListViewColumnItemArranger::IColumnItemView ===================== - - bool AttachCallback(list::ListViewColumnItemArranger::IColumnItemViewCallback* value)override; - bool DetachCallback(list::ListViewColumnItemArranger::IColumnItemViewCallback* value)override; - vint GetColumnSize(vint index)override; - void SetColumnSize(vint index, vint value)override; - GuiMenu* GetDropdownPopup(vint index)override; - ColumnSortingState GetSortingState(vint index)override; - }; - - protected: - ItemSource* itemSource; - - public: - /// Create a bindable List view control. - /// The style provider for this control. - GuiBindableListView(IStyleProvider* _styleProvider); - ~GuiBindableListView(); - - /// Get all data columns indices in columns. - /// All data columns indices in columns. - list::ListViewDataColumns& GetDataColumns(); - /// Get all columns. - /// All columns. - list::ListViewColumns& GetColumns(); - - /// Get the item source. - /// The item source. - Ptr GetItemSource(); - /// Set the item source. - /// The item source. Null is acceptable if you want to clear all data. - void SetItemSource(Ptr _itemSource); - - /// Large image property name changed event. - compositions::GuiNotifyEvent LargeImagePropertyChanged; - /// Small image property name changed event. - compositions::GuiNotifyEvent SmallImagePropertyChanged; - - /// Get the large image property name to get the large image from an item. - /// The large image property name. - ItemProperty> GetLargeImageProperty(); - /// Set the large image property name to get the large image from an item. - /// The large image property name. - void SetLargeImageProperty(const ItemProperty>& value); - - /// Get the small image property name to get the small image from an item. - /// The small image property name. - ItemProperty> GetSmallImageProperty(); - /// Set the small image property name to get the small image from an item. - /// The small image property name. - void SetSmallImageProperty(const ItemProperty>& value); - - /// Get the selected item. - /// Returns the selected item. If there are multiple selected items, or there is no selected item, null will be returned. - description::Value GetSelectedItem(); - }; - -/*********************************************************************** -GuiBindableTreeView -***********************************************************************/ - - /// A bindable Tree view control. - class GuiBindableTreeView : public GuiVirtualTreeView, public Description - { - using IValueEnumerable = reflection::description::IValueEnumerable; - protected: - class ItemSource; - - class ItemSourceNode - : public Object - , public virtual tree::INodeProvider - { - friend class ItemSource; - typedef collections::List> NodeList; - protected: - description::Value itemSource; - ItemSource* rootProvider; - ItemSourceNode* parent; - tree::INodeProviderCallback* callback; - bool expanding = false; - - Ptr itemChangedEventHandler; - Ptr childrenVirtualList; - NodeList children; - - void PrepareChildren(); - void UnprepareChildren(); - public: - ItemSourceNode(const description::Value& _itemSource, ItemSourceNode* _parent); - ItemSourceNode(ItemSource* _rootProvider); - ~ItemSourceNode(); - - description::Value GetItemSource(); - void SetItemSource(const description::Value& _itemSource); - - // ===================== tree::INodeProvider ===================== - - bool GetExpanding()override; - void SetExpanding(bool value)override; - vint CalculateTotalVisibleNodes()override; - - vint GetChildCount()override; - tree::INodeProvider* GetParent()override; - tree::INodeProvider* GetChild(vint index)override; - void Increase()override; - void Release()override; - }; - - class ItemSource - : public tree::NodeRootProviderBase - , protected virtual tree::ITreeViewItemView - { - friend class ItemSourceNode; - public: - ItemProperty textProperty; - ItemProperty> imageProperty; - ItemProperty> childrenProperty; - Ptr rootNode; - - public: - ItemSource(); - ~ItemSource(); - - description::Value GetItemSource(); - void SetItemSource(const description::Value& _itemSource); - - void UpdateBindingProperties(bool updateChildrenProperty); - - // ===================== tree::INodeRootProvider ===================== - - tree::INodeProvider* GetRootNode()override; - WString GetTextValue(tree::INodeProvider* node)override; - description::Value GetBindingValue(tree::INodeProvider* node)override; - IDescriptable* RequestView(const WString& identifier)override; - - - // ===================== tree::ITreeViewItemView ===================== - - Ptr GetNodeImage(tree::INodeProvider* node)override; - }; - - protected: - ItemSource* itemSource; - - public: - /// Create a bindable Tree view control. - /// The style provider for this control. - GuiBindableTreeView(IStyleProvider* _styleProvider); - ~GuiBindableTreeView(); - - /// Text property name changed event. - compositions::GuiNotifyEvent TextPropertyChanged; - /// Image property name changed event. - compositions::GuiNotifyEvent ImagePropertyChanged; - /// Children property name changed event. - compositions::GuiNotifyEvent ChildrenPropertyChanged; - - /// Get the item source. - /// The item source. - description::Value GetItemSource(); - /// Set the item source. - /// The item source. Null is acceptable if you want to clear all data. - void SetItemSource(description::Value _itemSource); - - /// Get the text property name to get the item text from an item. - /// The text property name. - ItemProperty GetTextProperty(); - /// Set the text property name to get the item text from an item. - /// The text property name. - void SetTextProperty(const ItemProperty& value); - - /// Get the image property name to get the image from an item. - /// The image property name. - ItemProperty> GetImageProperty(); - /// Set the image property name to get the image from an item. - /// The image property name. - void SetImageProperty(const ItemProperty>& value); - - /// Get the children property name to get the children from an item. - /// The children property name. - ItemProperty> GetChildrenProperty(); - /// Set the children property name to get the children from an item. - /// The children property name. - void SetChildrenProperty(const ItemProperty>& value); - - /// Get the selected item. - /// Returns the selected item. If there are multiple selected items, or there is no selected item, null will be returned. - description::Value GetSelectedItem(); - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\LISTCONTROLPACKAGE\GUIBINDABLEDATAGRID.H +.\CONTROLS\LISTCONTROLPACKAGE\GUIBINDABLEDATAGRID.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -16373,7 +16708,432 @@ GuiBindableDataGrid #endif /*********************************************************************** -CONTROLS\TOOLSTRIPPACKAGE\GUITOOLSTRIPCOMMAND.H +.\CONTROLS\LISTCONTROLPACKAGE\GUIBINDABLELISTCONTROLS.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Control System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_CONTROLS_GUIBINDABLELISTCONTROLS +#define VCZH_PRESENTATION_CONTROLS_GUIBINDABLELISTCONTROLS + + +namespace vl +{ + namespace presentation + { + namespace controls + { + template + struct DefaultValueOf + { + static T Get() + { + return TypedValueSerializerProvider::GetDefaultValue(); + } + }; + + template + struct DefaultValueOf> + { + static Ptr Get() + { + return nullptr; + } + }; + + template<> + struct DefaultValueOf + { + static description::Value Get() + { + return description::Value(); + } + }; + + template + T ReadProperty(const description::Value& thisObject, const ItemProperty& propertyName) + { + if (!thisObject.IsNull() && propertyName) + { + return propertyName(thisObject); + } + else + { + return DefaultValueOf::Get(); + } + } + + template + T ReadProperty(const description::Value& thisObject, const WritableItemProperty& propertyName) + { + auto defaultValue = DefaultValueOf::Get(); + if (!thisObject.IsNull() && propertyName) + { + return propertyName(thisObject, defaultValue, false); + } + else + { + return defaultValue; + } + } + + template + void WriteProperty(const description::Value& thisObject, const WritableItemProperty& propertyName, const T& value) + { + if (!thisObject.IsNull() && propertyName) + { + propertyName(thisObject, value, true); + } + } + +/*********************************************************************** +GuiBindableTextList +***********************************************************************/ + + /// A bindable Text list control. + class GuiBindableTextList : public GuiVirtualTextList, public Description + { + protected: + class ItemSource + : public list::ItemProviderBase + , protected list::ITextItemView + { + protected: + Ptr itemChangedEventHandler; + Ptr itemSource; + + public: + ItemProperty textProperty; + WritableItemProperty checkedProperty; + + public: + ItemSource(); + ~ItemSource(); + + Ptr GetItemSource(); + void SetItemSource(Ptr _itemSource); + + description::Value Get(vint index); + void UpdateBindingProperties(); + + // ===================== GuiListControl::IItemProvider ===================== + + WString GetTextValue(vint itemIndex)override; + description::Value GetBindingValue(vint itemIndex)override; + vint Count()override; + IDescriptable* RequestView(const WString& identifier)override; + + // ===================== list::TextItemStyleProvider::ITextItemView ===================== + + bool GetChecked(vint itemIndex)override; + void SetChecked(vint itemIndex, bool value)override; + }; + + protected: + ItemSource* itemSource; + + public: + /// Create a bindable Text list control. + /// The style provider for this control. + /// The factory object to create the control styles for bullet before a text item. + GuiBindableTextList(IStyleProvider* _styleProvider); + ~GuiBindableTextList(); + + /// Text property name changed event. + compositions::GuiNotifyEvent TextPropertyChanged; + /// Checked property name changed event. + compositions::GuiNotifyEvent CheckedPropertyChanged; + + /// Get the item source. + /// The item source. + Ptr GetItemSource(); + /// Set the item source. + /// The item source. Null is acceptable if you want to clear all data. + void SetItemSource(Ptr _itemSource); + + /// Get the text property name to get the item text from an item. + /// The text property name. + ItemProperty GetTextProperty(); + /// Set the text property name to get the item text from an item. + /// The text property name. + void SetTextProperty(const ItemProperty& value); + + /// Get the checked property name to get the check state from an item. + /// The checked property name. + WritableItemProperty GetCheckedProperty(); + /// Set the checked property name to get the check state from an item. + /// The checked property name. + void SetCheckedProperty(const WritableItemProperty& value); + + /// Get the selected item. + /// Returns the selected item. If there are multiple selected items, or there is no selected item, null will be returned. + description::Value GetSelectedItem(); + }; + +/*********************************************************************** +GuiBindableListView +***********************************************************************/ + + /// A bindable List view control. + class GuiBindableListView : public GuiVirtualListView, public Description + { + protected: + class ItemSource + : public list::ItemProviderBase + , protected virtual list::IListViewItemProvider + , protected virtual list::IListViewItemView + , protected virtual list::ListViewColumnItemArranger::IColumnItemView + { + typedef collections::List ColumnItemViewCallbackList; + protected: + list::ListViewDataColumns dataColumns; + list::ListViewColumns columns; + ColumnItemViewCallbackList columnItemViewCallbacks; + Ptr itemChangedEventHandler; + Ptr itemSource; + + public: + ItemProperty> largeImageProperty; + ItemProperty> smallImageProperty; + + public: + ItemSource(); + ~ItemSource(); + + Ptr GetItemSource(); + void SetItemSource(Ptr _itemSource); + + description::Value Get(vint index); + void UpdateBindingProperties(); + bool NotifyUpdate(vint start, vint count); + list::ListViewDataColumns& GetDataColumns(); + list::ListViewColumns& GetColumns(); + + // ===================== list::IListViewItemProvider ===================== + + void NotifyAllItemsUpdate()override; + void NotifyAllColumnsUpdate()override; + + // ===================== GuiListControl::IItemProvider ===================== + + WString GetTextValue(vint itemIndex)override; + description::Value GetBindingValue(vint itemIndex)override; + vint Count()override; + IDescriptable* RequestView(const WString& identifier)override; + + // ===================== list::ListViewItemStyleProvider::IListViewItemView ===================== + + Ptr GetSmallImage(vint itemIndex)override; + Ptr GetLargeImage(vint itemIndex)override; + WString GetText(vint itemIndex)override; + WString GetSubItem(vint itemIndex, vint index)override; + vint GetDataColumnCount()override; + vint GetDataColumn(vint index)override; + vint GetColumnCount()override; + WString GetColumnText(vint index)override; + + // ===================== list::ListViewColumnItemArranger::IColumnItemView ===================== + + bool AttachCallback(list::ListViewColumnItemArranger::IColumnItemViewCallback* value)override; + bool DetachCallback(list::ListViewColumnItemArranger::IColumnItemViewCallback* value)override; + vint GetColumnSize(vint index)override; + void SetColumnSize(vint index, vint value)override; + GuiMenu* GetDropdownPopup(vint index)override; + ColumnSortingState GetSortingState(vint index)override; + }; + + protected: + ItemSource* itemSource; + + public: + /// Create a bindable List view control. + /// The style provider for this control. + GuiBindableListView(IStyleProvider* _styleProvider); + ~GuiBindableListView(); + + /// Get all data columns indices in columns. + /// All data columns indices in columns. + list::ListViewDataColumns& GetDataColumns(); + /// Get all columns. + /// All columns. + list::ListViewColumns& GetColumns(); + + /// Get the item source. + /// The item source. + Ptr GetItemSource(); + /// Set the item source. + /// The item source. Null is acceptable if you want to clear all data. + void SetItemSource(Ptr _itemSource); + + /// Large image property name changed event. + compositions::GuiNotifyEvent LargeImagePropertyChanged; + /// Small image property name changed event. + compositions::GuiNotifyEvent SmallImagePropertyChanged; + + /// Get the large image property name to get the large image from an item. + /// The large image property name. + ItemProperty> GetLargeImageProperty(); + /// Set the large image property name to get the large image from an item. + /// The large image property name. + void SetLargeImageProperty(const ItemProperty>& value); + + /// Get the small image property name to get the small image from an item. + /// The small image property name. + ItemProperty> GetSmallImageProperty(); + /// Set the small image property name to get the small image from an item. + /// The small image property name. + void SetSmallImageProperty(const ItemProperty>& value); + + /// Get the selected item. + /// Returns the selected item. If there are multiple selected items, or there is no selected item, null will be returned. + description::Value GetSelectedItem(); + }; + +/*********************************************************************** +GuiBindableTreeView +***********************************************************************/ + + /// A bindable Tree view control. + class GuiBindableTreeView : public GuiVirtualTreeView, public Description + { + using IValueEnumerable = reflection::description::IValueEnumerable; + protected: + class ItemSource; + + class ItemSourceNode + : public Object + , public virtual tree::INodeProvider + { + friend class ItemSource; + typedef collections::List> NodeList; + protected: + description::Value itemSource; + ItemSource* rootProvider; + ItemSourceNode* parent; + tree::INodeProviderCallback* callback; + bool expanding = false; + + Ptr itemChangedEventHandler; + Ptr childrenVirtualList; + NodeList children; + + void PrepareChildren(); + void UnprepareChildren(); + public: + ItemSourceNode(const description::Value& _itemSource, ItemSourceNode* _parent); + ItemSourceNode(ItemSource* _rootProvider); + ~ItemSourceNode(); + + description::Value GetItemSource(); + void SetItemSource(const description::Value& _itemSource); + + // ===================== tree::INodeProvider ===================== + + bool GetExpanding()override; + void SetExpanding(bool value)override; + vint CalculateTotalVisibleNodes()override; + + vint GetChildCount()override; + tree::INodeProvider* GetParent()override; + tree::INodeProvider* GetChild(vint index)override; + void Increase()override; + void Release()override; + }; + + class ItemSource + : public tree::NodeRootProviderBase + , protected virtual tree::ITreeViewItemView + { + friend class ItemSourceNode; + public: + ItemProperty textProperty; + ItemProperty> imageProperty; + ItemProperty> childrenProperty; + Ptr rootNode; + + public: + ItemSource(); + ~ItemSource(); + + description::Value GetItemSource(); + void SetItemSource(const description::Value& _itemSource); + + void UpdateBindingProperties(bool updateChildrenProperty); + + // ===================== tree::INodeRootProvider ===================== + + tree::INodeProvider* GetRootNode()override; + WString GetTextValue(tree::INodeProvider* node)override; + description::Value GetBindingValue(tree::INodeProvider* node)override; + IDescriptable* RequestView(const WString& identifier)override; + + + // ===================== tree::ITreeViewItemView ===================== + + Ptr GetNodeImage(tree::INodeProvider* node)override; + }; + + protected: + ItemSource* itemSource; + + public: + /// Create a bindable Tree view control. + /// The style provider for this control. + GuiBindableTreeView(IStyleProvider* _styleProvider); + ~GuiBindableTreeView(); + + /// Text property name changed event. + compositions::GuiNotifyEvent TextPropertyChanged; + /// Image property name changed event. + compositions::GuiNotifyEvent ImagePropertyChanged; + /// Children property name changed event. + compositions::GuiNotifyEvent ChildrenPropertyChanged; + + /// Get the item source. + /// The item source. + description::Value GetItemSource(); + /// Set the item source. + /// The item source. Null is acceptable if you want to clear all data. + void SetItemSource(description::Value _itemSource); + + /// Get the text property name to get the item text from an item. + /// The text property name. + ItemProperty GetTextProperty(); + /// Set the text property name to get the item text from an item. + /// The text property name. + void SetTextProperty(const ItemProperty& value); + + /// Get the image property name to get the image from an item. + /// The image property name. + ItemProperty> GetImageProperty(); + /// Set the image property name to get the image from an item. + /// The image property name. + void SetImageProperty(const ItemProperty>& value); + + /// Get the children property name to get the children from an item. + /// The children property name. + ItemProperty> GetChildrenProperty(); + /// Set the children property name to get the children from an item. + /// The children property name. + void SetChildrenProperty(const ItemProperty>& value); + + /// Get the selected item. + /// Returns the selected item. If there are multiple selected items, or there is no selected item, null will be returned. + description::Value GetSelectedItem(); + }; + } + } +} + +#endif + +/*********************************************************************** +.\CONTROLS\TOOLSTRIPPACKAGE\GUITOOLSTRIPCOMMAND.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -16483,7 +17243,7 @@ namespace vl #endif /*********************************************************************** -CONTROLS\TOOLSTRIPPACKAGE\GUITOOLSTRIPMENU.H +.\CONTROLS\TOOLSTRIPPACKAGE\GUITOOLSTRIPMENU.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -16751,7 +17511,7 @@ Toolstrip Component #endif /*********************************************************************** -CONTROLS\STYLES\GUITHEMESTYLEFACTORY.H +.\CONTROLS\STYLES\GUITHEMESTYLEFACTORY.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -16811,9 +17571,6 @@ namespace vl /// Create a style for singleline text box. /// The created style. virtual controls::GuiSinglelineTextBox::IStyleProvider* CreateTextBoxStyle()=0; - /// Get the default color configuration for text box characters. - /// The default color configuration. - virtual elements::text::ColorEntry GetDefaultTextBoxColorEntry()=0; /// Create a style for document viewer. /// The created style. virtual controls::GuiDocumentViewer::IStyleProvider* CreateDocumentViewerStyle()=0; @@ -16895,12 +17652,6 @@ namespace vl /// Create a style for progress bar. /// The created style. virtual controls::GuiScroll::IStyleController* CreateProgressBarStyle()=0; - /// Get the default size for scrolls. - /// The default size for scrolls. - virtual vint GetScrollDefaultSize()=0; - /// Get the default size for trackers. - /// The default size for trackers. - virtual vint GetTrackerDefaultSize()=0; /// Create a style for text list. /// The created style. @@ -16913,12 +17664,74 @@ namespace vl virtual controls::GuiSelectableButton::IStyleController* CreateRadioTextListItemStyle()=0; }; + class Theme; + + /// Partial control template collections. [F:vl.presentation.theme.GetCurrentTheme] will returns an object, which walks through multiple registered [T:vl.presentation.theme.ThemeTemplates] to create a correct template object for a control. + class ThemeTemplates : public controls::GuiInstanceRootObject, public AggregatableDescription + { + friend class Theme; + protected: + ThemeTemplates* previous = nullptr; + ThemeTemplates* next = nullptr; + + public: + ~ThemeTemplates(); + + TemplateProperty window; + TemplateProperty customControl; + TemplateProperty tooltip; + TemplateProperty label; + TemplateProperty shortcutKey; + TemplateProperty scrollView; + TemplateProperty groupBox; + TemplateProperty tab; + TemplateProperty comboBox; + TemplateProperty multilineTextBox; + TemplateProperty singlelineTextBox; + TemplateProperty documentViewer; + TemplateProperty documentLabel; + TemplateProperty documentTextBox; + TemplateProperty listView; + TemplateProperty treeView; + TemplateProperty textList; + TemplateProperty listItemBackground; + TemplateProperty treeItemExpander; + TemplateProperty checkTextListItem; + TemplateProperty radioTextListItem; + TemplateProperty menu; + TemplateProperty menuBar; + TemplateProperty menuSplitter; + TemplateProperty menuBarButton; + TemplateProperty menuItemButton; + TemplateProperty toolBar; + TemplateProperty toolBarButton; + TemplateProperty toolBarDropdownButton; + TemplateProperty toolBarSplitButton; + TemplateProperty toolBarSplitter; + TemplateProperty button; + TemplateProperty checkBox; + TemplateProperty radioButton; + TemplateProperty datePicker; + TemplateProperty hScroll; + TemplateProperty vScroll; + TemplateProperty hTracker; + TemplateProperty vTracker; + TemplateProperty progressBar; + }; + /// Get the current theme style factory object. The default theme is [T:vl.presentation.win7.Win7Theme]. Call [M:vl.presentation.theme.SetCurrentTheme] to change the default theme. /// The current theme style factory object. extern ITheme* GetCurrentTheme(); - /// Set the current theme style factory object. - /// The current theme style factory object. - extern void SetCurrentTheme(ITheme* theme); + extern void InitializeTheme(); + extern void FinalizeTheme(); + /// Register a control template collection object. + /// The name of the theme. + /// The control template collection object. + extern bool RegisterTheme(const WString& name, Ptr theme); + /// Unregister a control template collection object. + /// The registered object. Returns null if it does not exist. + /// The name of the theme. + extern Ptr UnregisterTheme(const WString& name); namespace g { @@ -17044,353 +17857,317 @@ namespace vl #endif /*********************************************************************** -CONTROLS\STYLES\GUIWIN7STYLES.H +.\CONTROLS\STYLES\GUICOMMONSTYLES.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 Developer: Zihan Chen(vczh) -GacUI::Control Styles::Windows7 Styles - -Clases: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_GUIWIN7STYLES -#define VCZH_PRESENTATION_CONTROLS_GUIWIN7STYLES - - -namespace vl -{ - namespace presentation - { - namespace win7 - { - -/*********************************************************************** -Theme -***********************************************************************/ - - /// Windows 7 theme. - class Win7Theme : public Object, public theme::ITheme - { - public: - /// Create the theme. - Win7Theme(); - ~Win7Theme(); - - controls::GuiWindow::IStyleController* CreateWindowStyle()override; - controls::GuiCustomControl::IStyleController* CreateCustomControlStyle()override; - controls::GuiTooltip::IStyleController* CreateTooltipStyle()override; - controls::GuiLabel::IStyleController* CreateLabelStyle()override; - controls::GuiLabel::IStyleController* CreateShortcutKeyStyle()override; - controls::GuiScrollContainer::IStyleProvider* CreateScrollContainerStyle()override; - controls::GuiControl::IStyleController* CreateGroupBoxStyle()override; - controls::GuiTab::IStyleController* CreateTabStyle()override; - controls::GuiComboBoxListControl::IStyleController* CreateComboBoxStyle()override; - controls::GuiScrollView::IStyleProvider* CreateMultilineTextBoxStyle()override; - controls::GuiSinglelineTextBox::IStyleProvider* CreateTextBoxStyle()override; - elements::text::ColorEntry GetDefaultTextBoxColorEntry()override; - controls::GuiDocumentViewer::IStyleProvider* CreateDocumentViewerStyle()override; - controls::GuiDocumentLabel::IStyleController* CreateDocumentLabelStyle()override; - controls::GuiDocumentLabel::IStyleController* CreateDocumentTextBoxStyle()override; - controls::GuiListView::IStyleProvider* CreateListViewStyle()override; - controls::GuiTreeView::IStyleProvider* CreateTreeViewStyle()override; - controls::GuiSelectableButton::IStyleController* CreateListItemBackgroundStyle()override; - controls::GuiSelectableButton::IStyleController* CreateTreeItemExpanderStyle()override; - - controls::GuiToolstripMenu::IStyleController* CreateMenuStyle()override; - controls::GuiToolstripMenuBar::IStyleController* CreateMenuBarStyle()override; - controls::GuiControl::IStyleController* CreateMenuSplitterStyle()override; - controls::GuiToolstripButton::IStyleController* CreateMenuBarButtonStyle()override; - controls::GuiToolstripButton::IStyleController* CreateMenuItemButtonStyle()override; - controls::GuiToolstripToolBar::IStyleController* CreateToolBarStyle()override; - controls::GuiToolstripButton::IStyleController* CreateToolBarButtonStyle()override; - controls::GuiToolstripButton::IStyleController* CreateToolBarDropdownButtonStyle()override; - controls::GuiToolstripButton::IStyleController* CreateToolBarSplitButtonStyle()override; - controls::GuiControl::IStyleController* CreateToolBarSplitterStyle()override; - - controls::GuiButton::IStyleController* CreateButtonStyle()override; - controls::GuiSelectableButton::IStyleController* CreateCheckBoxStyle()override; - controls::GuiSelectableButton::IStyleController* CreateRadioButtonStyle()override; - controls::GuiDatePicker::IStyleProvider* CreateDatePickerStyle()override; - - controls::GuiScroll::IStyleController* CreateHScrollStyle()override; - controls::GuiScroll::IStyleController* CreateVScrollStyle()override; - controls::GuiScroll::IStyleController* CreateHTrackerStyle()override; - controls::GuiScroll::IStyleController* CreateVTrackerStyle()override; - controls::GuiScroll::IStyleController* CreateProgressBarStyle()override; - vint GetScrollDefaultSize()override; - vint GetTrackerDefaultSize()override; - - controls::GuiVirtualTextList::IStyleProvider* CreateTextListStyle()override; - controls::GuiSelectableButton::IStyleController* CreateCheckTextListItemStyle()override; - controls::GuiSelectableButton::IStyleController* CreateRadioTextListItemStyle()override; - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\STYLES\GUIWIN8STYLES.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control Styles::Windows8 Styles - -Clases: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_GUIWIN8STYLES -#define VCZH_PRESENTATION_CONTROLS_GUIWIN8STYLES - - -namespace vl -{ - namespace presentation - { - namespace win8 - { - -/*********************************************************************** -Theme -***********************************************************************/ - - /// Windows 8 theme. - class Win8Theme : public Object, public theme::ITheme - { - public: - /// Create the theme. - Win8Theme(); - ~Win8Theme(); - - controls::GuiWindow::IStyleController* CreateWindowStyle()override; - controls::GuiCustomControl::IStyleController* CreateCustomControlStyle()override; - controls::GuiTooltip::IStyleController* CreateTooltipStyle()override; - controls::GuiLabel::IStyleController* CreateLabelStyle()override; - controls::GuiLabel::IStyleController* CreateShortcutKeyStyle()override; - controls::GuiScrollContainer::IStyleProvider* CreateScrollContainerStyle()override; - controls::GuiControl::IStyleController* CreateGroupBoxStyle()override; - controls::GuiTab::IStyleController* CreateTabStyle()override; - controls::GuiComboBoxListControl::IStyleController* CreateComboBoxStyle()override; - controls::GuiScrollView::IStyleProvider* CreateMultilineTextBoxStyle()override; - controls::GuiSinglelineTextBox::IStyleProvider* CreateTextBoxStyle()override; - elements::text::ColorEntry GetDefaultTextBoxColorEntry()override; - controls::GuiDocumentViewer::IStyleProvider* CreateDocumentViewerStyle()override; - controls::GuiDocumentLabel::IStyleController* CreateDocumentLabelStyle()override; - controls::GuiDocumentLabel::IStyleController* CreateDocumentTextBoxStyle()override; - controls::GuiListView::IStyleProvider* CreateListViewStyle()override; - controls::GuiTreeView::IStyleProvider* CreateTreeViewStyle()override; - controls::GuiSelectableButton::IStyleController* CreateListItemBackgroundStyle()override; - controls::GuiSelectableButton::IStyleController* CreateTreeItemExpanderStyle()override; - - controls::GuiToolstripMenu::IStyleController* CreateMenuStyle()override; - controls::GuiToolstripMenuBar::IStyleController* CreateMenuBarStyle()override; - controls::GuiControl::IStyleController* CreateMenuSplitterStyle()override; - controls::GuiToolstripButton::IStyleController* CreateMenuBarButtonStyle()override; - controls::GuiToolstripButton::IStyleController* CreateMenuItemButtonStyle()override; - controls::GuiToolstripToolBar::IStyleController* CreateToolBarStyle()override; - controls::GuiToolstripButton::IStyleController* CreateToolBarButtonStyle()override; - controls::GuiToolstripButton::IStyleController* CreateToolBarDropdownButtonStyle()override; - controls::GuiToolstripButton::IStyleController* CreateToolBarSplitButtonStyle()override; - controls::GuiControl::IStyleController* CreateToolBarSplitterStyle()override; - - controls::GuiButton::IStyleController* CreateButtonStyle()override; - controls::GuiSelectableButton::IStyleController* CreateCheckBoxStyle()override; - controls::GuiSelectableButton::IStyleController* CreateRadioButtonStyle()override; - controls::GuiDatePicker::IStyleProvider* CreateDatePickerStyle()override; - - controls::GuiScroll::IStyleController* CreateHScrollStyle()override; - controls::GuiScroll::IStyleController* CreateVScrollStyle()override; - controls::GuiScroll::IStyleController* CreateHTrackerStyle()override; - controls::GuiScroll::IStyleController* CreateVTrackerStyle()override; - controls::GuiScroll::IStyleController* CreateProgressBarStyle()override; - vint GetScrollDefaultSize()override; - vint GetTrackerDefaultSize()override; - - controls::GuiVirtualTextList::IStyleProvider* CreateTextListStyle()override; - controls::GuiSelectableButton::IStyleController* CreateCheckTextListItemStyle()override; - controls::GuiSelectableButton::IStyleController* CreateRadioTextListItemStyle()override; - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\LISTCONTROLPACKAGE\GUIDATAGRIDEXTENSIONS.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control System +GacUI::Control Styles::Common Style Helpers Interfaces: ***********************************************************************/ -#ifndef VCZH_PRESENTATION_CONTROLS_GUIDATAEXTENSIONS -#define VCZH_PRESENTATION_CONTROLS_GUIDATAEXTENSIONS +#ifndef VCZH_PRESENTATION_CONTROLS_GUICOMMONSTYLES +#define VCZH_PRESENTATION_CONTROLS_GUICOMMONSTYLES namespace vl { namespace presentation { - namespace controls + namespace common_styles { - namespace list + +/*********************************************************************** +CommonScrollStyle +***********************************************************************/ + + /// A general implementation for to make a scroll control. + class CommonScrollStyle : public Object, public virtual controls::GuiScroll::IStyleController, public Description { + public: + /// Scroll direction. + enum Direction + { + /// Horizontal scroll. + Horizontal, + /// Vertical scroll. + Vertical, + }; + protected: + Direction direction; + controls::IScrollCommandExecutor* commandExecutor; + controls::GuiButton* decreaseButton; + controls::GuiButton* increaseButton; + controls::GuiButton* handleButton; + compositions::GuiPartialViewComposition* handleComposition; + compositions::GuiBoundsComposition* boundsComposition; + compositions::GuiBoundsComposition* containerComposition; + + vint totalSize; + vint pageSize; + vint position; + Point draggingStartLocation; + bool draggingHandle; + + void UpdateHandle(); + void OnDecreaseButtonClicked(compositions::GuiGraphicsComposition* sender,compositions::GuiEventArgs& arguments); + void OnIncreaseButtonClicked(compositions::GuiGraphicsComposition* sender,compositions::GuiEventArgs& arguments); + void OnHandleMouseDown(compositions::GuiGraphicsComposition* sender,compositions::GuiMouseEventArgs& arguments); + void OnHandleMouseMove(compositions::GuiGraphicsComposition* sender,compositions::GuiMouseEventArgs& arguments); + void OnHandleMouseUp(compositions::GuiGraphicsComposition* sender,compositions::GuiMouseEventArgs& arguments);; + void OnBigMoveMouseDown(compositions::GuiGraphicsComposition* sender,compositions::GuiMouseEventArgs& arguments); + + /// Callback to create a style controller for the decrement button. + /// The created style controller. + /// The direction of the scroll. + virtual controls::GuiButton::IStyleController* CreateDecreaseButtonStyle(Direction direction)=0; + /// Callback to create a style controller for the increment button. + /// The created style controller. + /// The direction of the scroll. + virtual controls::GuiButton::IStyleController* CreateIncreaseButtonStyle(Direction direction)=0; + /// Callback to create a style controller for the handle button. + /// The created style controller. + /// The direction of the scroll. + virtual controls::GuiButton::IStyleController* CreateHandleButtonStyle(Direction direction)=0; + /// Install necessary compositions and elements to the background. + /// The created container composition. + /// The background composition. + /// The direction of the scroll. + virtual compositions::GuiBoundsComposition* InstallBackground(compositions::GuiBoundsComposition* boundsComposition, Direction direction)=0; + /// Build the style. This function is supposed to be called in the contructor of the sub class. + /// The size of the increment button and decrement button. + /// The size of the arrows in the increment button and decrement button. + void BuildStyle(vint defaultSize, vint arrowSize); + public: + /// Create the style controller using a specified direction. + /// The specified direction + CommonScrollStyle(Direction _direction); + ~CommonScrollStyle(); + + compositions::GuiBoundsComposition* GetBoundsComposition()override; + compositions::GuiGraphicsComposition* GetContainerComposition()override; + void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; + void SetText(const WString& value)override; + void SetFont(const FontProperties& value)override; + void SetVisuallyEnabled(bool value)override; + void SetCommandExecutor(controls::IScrollCommandExecutor* value)override; + void SetTotalSize(vint value)override; + void SetPageSize(vint value)override; + void SetPosition(vint value)override; + }; /*********************************************************************** -Extension Bases +CommonTrackStyle ***********************************************************************/ - - class DataVisualizerFactory; - class DataEditorFactory; - - /// Base class for all data visualizers. - class DataVisualizerBase : public Object, public virtual IDataVisualizer + + /// A general implementation for to make a tracker control (or a slide bar). + class CommonTrackStyle : public Object, public virtual controls::GuiScroll::IStyleController, public Description + { + public: + /// Track direction. + enum Direction { - friend class DataVisualizerFactory; - using ItemTemplate = templates::GuiGridVisualizerTemplate; - protected: - DataVisualizerFactory* factory = nullptr; - IDataGridContext* dataGridContext = nullptr; - templates::GuiGridVisualizerTemplate* visualizerTemplate = nullptr; - - public: - /// Create the data visualizer. - /// The decorated data visualizer inside the current data visualizer. - DataVisualizerBase(); - ~DataVisualizerBase(); - - IDataVisualizerFactory* GetFactory()override; - templates::GuiGridVisualizerTemplate* GetTemplate()override; - void NotifyDeletedTemplate()override; - void BeforeVisualizeCell(GuiListControl::IItemProvider* itemProvider, vint row, vint column)override; - void SetSelected(bool value)override; + /// Horizontal scroll. + Horizontal, + /// Vertical scroll. + Vertical, }; + protected: + Direction direction; + controls::IScrollCommandExecutor* commandExecutor; + compositions::GuiBoundsComposition* boundsComposition; + controls::GuiButton* handleButton; + compositions::GuiTableComposition* handleComposition; + + vint totalSize; + vint pageSize; + vint position; + Point draggingStartLocation; + bool draggingHandle; + + void UpdateHandle(); + void OnHandleMouseDown(compositions::GuiGraphicsComposition* sender,compositions::GuiMouseEventArgs& arguments); + void OnHandleMouseMove(compositions::GuiGraphicsComposition* sender,compositions::GuiMouseEventArgs& arguments); + void OnHandleMouseUp(compositions::GuiGraphicsComposition* sender,compositions::GuiMouseEventArgs& arguments); - class DataVisualizerFactory : public Object, public virtual IDataVisualizerFactory, public Description - { - using ItemTemplate = templates::GuiGridVisualizerTemplate; - protected: - TemplateProperty templateFactory; - Ptr decoratedFactory; + /// Callback to create a style controller for the handle button. + /// The created style controller. + /// The direction of the tracker. + virtual controls::GuiButton::IStyleController* CreateHandleButtonStyle(Direction direction)=0; + /// Install necessary compositions and elements to the background. + /// The background composition. + /// The direction of the tracker. + virtual void InstallBackground(compositions::GuiGraphicsComposition* boundsComposition, Direction direction)=0; + /// Install necessary compositions and elements to the tracker groove. + /// The tracker groove composition. + /// The direction of the tracker. + virtual void InstallTrack(compositions::GuiGraphicsComposition* trackComposition, Direction direction)=0; + /// Build the style. This function is supposed to be called in the contructor of the sub class. + /// The thickness of the tracker troove. + /// The padding between the tracker groove to the control. + /// The size of the long size of the handle button. Horizontal: height; Vertical: width. + /// The size of the short size of the handle button. Horizontal: width; Vertical: height. + void BuildStyle(vint trackThickness, vint trackPadding, vint handleLong, vint handleShort); + public: + /// Create the style controller using a specified direction. + /// The specified direction + CommonTrackStyle(Direction _direction); + ~CommonTrackStyle(); - ItemTemplate* CreateItemTemplate(controls::list::IDataGridContext* dataGridContext); - public: - DataVisualizerFactory(TemplateProperty _templateFactory, Ptr _decoratedFactory = nullptr); - ~DataVisualizerFactory(); - - Ptr CreateVisualizer(IDataGridContext* dataGridContext)override; - }; - - /// Base class for all data editors. - class DataEditorBase : public Object, public virtual IDataEditor - { - friend class DataEditorFactory; - using ItemTemplate = templates::GuiGridEditorTemplate; - protected: - IDataEditorFactory* factory = nullptr; - IDataGridContext* dataGridContext = nullptr; - templates::GuiGridEditorTemplate* editorTemplate = nullptr; - - void OnCellValueChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - public: - /// Create the data editor. - DataEditorBase(); - ~DataEditorBase(); - - IDataEditorFactory* GetFactory()override; - templates::GuiGridEditorTemplate* GetTemplate()override; - void NotifyDeletedTemplate()override; - void BeforeEditCell(GuiListControl::IItemProvider* itemProvider, vint row, vint column)override; - bool GetCellValueSaved()override; - }; - - class DataEditorFactory : public Object, public virtual IDataEditorFactory, public Description - { - using ItemTemplate = templates::GuiGridEditorTemplate; - protected: - TemplateProperty templateFactory; - - public: - DataEditorFactory(TemplateProperty _templateFactory); - ~DataEditorFactory(); - - Ptr CreateEditor(IDataGridContext* dataGridContext)override; - }; + compositions::GuiBoundsComposition* GetBoundsComposition()override; + compositions::GuiGraphicsComposition* GetContainerComposition()override; + void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; + void SetText(const WString& value)override; + void SetFont(const FontProperties& value)override; + void SetVisuallyEnabled(bool value)override; + void SetCommandExecutor(controls::IScrollCommandExecutor* value)override; + void SetTotalSize(vint value)override; + void SetPageSize(vint value)override; + void SetPosition(vint value)override; + }; /*********************************************************************** -Visualizer Extensions +CommonFragmentBuilder ***********************************************************************/ - class MainColumnVisualizerTemplate : public templates::GuiGridVisualizerTemplate - { - protected: - elements::GuiImageFrameElement* image = nullptr; - elements::GuiSolidLabelElement* text = nullptr; + class CommonFragmentBuilder + { + private: + static compositions::GuiBoundsComposition* BuildDockedElementContainer(elements::IGuiGraphicsElement* element); + public: + static void FillUpArrow(elements::GuiPolygonElement* element); + static void FillDownArrow(elements::GuiPolygonElement* element); + static void FillLeftArrow(elements::GuiPolygonElement* element); + static void FillRightArrow(elements::GuiPolygonElement* element); - void OnTextChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnFontChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnTextColorChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnSmallImageChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - public: - MainColumnVisualizerTemplate(); - ~MainColumnVisualizerTemplate(); - }; + static elements::GuiPolygonElement* BuildUpArrow(); + static elements::GuiPolygonElement* BuildDownArrow(); + static elements::GuiPolygonElement* BuildLeftArrow(); + static elements::GuiPolygonElement* BuildRightArrow(); - class SubColumnVisualizerTemplate : public templates::GuiGridVisualizerTemplate - { - protected: - elements::GuiSolidLabelElement* text = nullptr; - - void OnTextChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnFontChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnTextColorChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void Initialize(bool fixTextColor); - - SubColumnVisualizerTemplate(bool fixTextColor); - public: - SubColumnVisualizerTemplate(); - ~SubColumnVisualizerTemplate(); - }; - - class HyperlinkVisualizerTemplate : public SubColumnVisualizerTemplate - { - protected: - void label_MouseEnter(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void label_MouseLeave(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - - public: - HyperlinkVisualizerTemplate(); - ~HyperlinkVisualizerTemplate(); - }; - - class CellBorderVisualizerTemplate : public templates::GuiGridVisualizerTemplate - { - protected: - elements::GuiSolidBorderElement* border1 = nullptr; - elements::GuiSolidBorderElement* border2 = nullptr; - - void OnItemSeparatorColorChanged(GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - - public: - CellBorderVisualizerTemplate(); - ~CellBorderVisualizerTemplate(); - }; - } + static compositions::GuiBoundsComposition* BuildUpArrow(elements::GuiPolygonElement*& elementOut); + static compositions::GuiBoundsComposition* BuildDownArrow(elements::GuiPolygonElement*& elementOut); + static compositions::GuiBoundsComposition* BuildLeftArrow(elements::GuiPolygonElement*& elementOut); + static compositions::GuiBoundsComposition* BuildRightArrow(elements::GuiPolygonElement*& elementOut); + }; } + +/*********************************************************************** +Helper Functions +***********************************************************************/ + + extern unsigned char IntToColor(vint color); + extern Color BlendColor(Color c1, Color c2, vint currentPosition, vint totalLength); + +/*********************************************************************** +Animation +***********************************************************************/ + +#define DEFINE_TRANSFERRING_ANIMATION(TSTATE, TSTYLECONTROLLER)\ + class TransferringAnimation : public compositions::GuiTimeBasedAnimation\ + {\ + protected:\ + TSTATE colorBegin;\ + TSTATE colorEnd;\ + TSTATE colorCurrent;\ + TSTYLECONTROLLER* style;\ + bool stopped;\ + bool disabled;\ + bool enableAnimation;\ + void PlayInternal(vint currentPosition, vint totalLength);\ + public:\ + TransferringAnimation(TSTYLECONTROLLER* _style, const TSTATE& begin);\ + void Disable();\ + void Play(vint currentPosition, vint totalLength)override;\ + void Stop()override;\ + bool GetEnableAnimation();\ + void SetEnableAnimation(bool value);\ + void Transfer(const TSTATE& end);\ + };\ + +/*********************************************************************** +Animation Implementation +***********************************************************************/ + +#define DEFAULT_TRANSFERRING_ANIMATION_HOST_GETTER(STYLE) (STYLE->GetBoundsComposition()->GetRelatedGraphicsHost()) + +#define IMPLEMENT_TRANSFERRING_ANIMATION_BASE(TSTATE, TSTYLECONTROLLER, HOST_GETTER)\ + TSTYLECONTROLLER::TransferringAnimation::TransferringAnimation(TSTYLECONTROLLER* _style, const TSTATE& begin)\ + :GuiTimeBasedAnimation(0)\ + ,colorBegin(begin)\ + ,colorEnd(begin)\ + ,colorCurrent(begin)\ + ,style(_style)\ + ,stopped(true)\ + ,disabled(false)\ + ,enableAnimation(true)\ + {\ + }\ + void TSTYLECONTROLLER::TransferringAnimation::Disable()\ + {\ + disabled=true;\ + }\ + void TSTYLECONTROLLER::TransferringAnimation::Play(vint currentPosition, vint totalLength)\ + {\ + if(!disabled)\ + {\ + PlayInternal(currentPosition, totalLength);\ + }\ + }\ + void TSTYLECONTROLLER::TransferringAnimation::Stop()\ + {\ + stopped=true;\ + }\ + bool TSTYLECONTROLLER::TransferringAnimation::GetEnableAnimation()\ + {\ + return enableAnimation;\ + }\ + void TSTYLECONTROLLER::TransferringAnimation::SetEnableAnimation(bool value)\ + {\ + enableAnimation=value;\ + }\ + void TSTYLECONTROLLER::TransferringAnimation::Transfer(const TSTATE& end)\ + {\ + if(colorEnd!=end)\ + {\ + GuiGraphicsHost* host=HOST_GETTER(style);\ + if(enableAnimation && host)\ + {\ + Restart(120);\ + if(stopped)\ + {\ + colorBegin=colorEnd;\ + colorEnd=end;\ + host->GetAnimationManager()->AddAnimation(style->transferringAnimation);\ + stopped=false;\ + }\ + else\ + {\ + colorBegin=colorCurrent;\ + colorEnd=end;\ + }\ + }\ + else\ + {\ + colorBegin=end;\ + colorEnd=end;\ + colorCurrent=end;\ + Play(1, 1);\ + }\ + }\ + }\ + void TSTYLECONTROLLER::TransferringAnimation::PlayInternal(vint currentPosition, vint totalLength)\ + +#define IMPLEMENT_TRANSFERRING_ANIMATION(TSTATE, TSTYLECONTROLLER)\ + IMPLEMENT_TRANSFERRING_ANIMATION_BASE(TSTATE, TSTYLECONTROLLER, DEFAULT_TRANSFERRING_ANIMATION_HOST_GETTER) } } #endif /*********************************************************************** -CONTROLS\TEMPLATES\GUICONTROLTEMPLATESTYLES.H +.\CONTROLS\TEMPLATES\GUICONTROLTEMPLATESTYLES.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -17829,129 +18606,49 @@ Helper Functions #endif /*********************************************************************** -RESOURCES\GUIRESOURCEMANAGER.H +.\RESOURCES\GUIDOCUMENTEDITOR.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 Developer: Zihan Chen(vczh) -GacUI Reflection: Instance Loader +GacUI::Resource Interfaces: ***********************************************************************/ -#ifndef VCZH_PRESENTATION_REFLECTION_GUIRESOURCEMANAGER -#define VCZH_PRESENTATION_REFLECTION_GUIRESOURCEMANAGER +#ifndef VCZH_PRESENTATION_RESOURCES_GUIDOCUMENTEDITOR +#define VCZH_PRESENTATION_RESOURCES_GUIDOCUMENTEDITOR namespace vl { namespace presentation { - using namespace reflection; + typedef DocumentModel::RunRange RunRange; + typedef DocumentModel::RunRangeMap RunRangeMap; -/*********************************************************************** -IGuiResourceManager -***********************************************************************/ - - class GuiResourceClassNameRecord : public Object, public Description + namespace document_editor { - public: - collections::List classNames; - }; - - class IGuiResourceManager : public IDescriptable, public Description - { - public: - virtual bool SetResource(const WString& name, Ptr resource, GuiResourceUsage usage = GuiResourceUsage::DataOnly) = 0; - virtual Ptr GetResource(const WString& name) = 0; - virtual Ptr GetResourceFromClassName(const WString& classFullName) = 0; - }; - - extern IGuiResourceManager* GetResourceManager(); - } -} - -#endif - -/*********************************************************************** -GACUIREFLECTIONHELPER.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI Reflection Helper - -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_GACUIREFLECTIONHELPER -#define VCZH_PRESENTATION_GACUIREFLECTIONHELPER - - -namespace vl -{ - namespace reflection - { - namespace description - { - -/*********************************************************************** -Serialization -***********************************************************************/ - - template<> - struct TypedValueSerializerProvider - { - static presentation::Color GetDefaultValue(); - static bool Serialize(const presentation::Color& input, WString& output); - static bool Deserialize(const WString& input, presentation::Color& output); - static IBoxedValue::CompareResult Compare(const presentation::Color& a, const presentation::Color& b); - }; - - template<> - struct TypedValueSerializerProvider - { - static presentation::DocumentFontSize GetDefaultValue(); - static bool Serialize(const presentation::DocumentFontSize& input, WString& output); - static bool Deserialize(const WString& input, presentation::DocumentFontSize& output); - static IBoxedValue::CompareResult Compare(const presentation::DocumentFontSize& a, const presentation::DocumentFontSize& b); - }; - - template<> - struct TypedValueSerializerProvider - { - static presentation::GlobalStringKey GetDefaultValue(); - static bool Serialize(const presentation::GlobalStringKey& input, WString& output); - static bool Deserialize(const WString& input, presentation::GlobalStringKey& output); - static IBoxedValue::CompareResult Compare(const presentation::GlobalStringKey& a, const presentation::GlobalStringKey& b); - }; - -/*********************************************************************** -External Functions -***********************************************************************/ - - extern presentation::compositions::GuiGraphicsAnimationManager* GuiControlHost_GetAnimationManager(presentation::controls::GuiControlHost* thisObject); - extern Ptr INativeImage_Constructor(const WString& path); - extern presentation::INativeCursor* INativeCursor_Constructor1(); - extern presentation::INativeCursor* INativeCursor_Constructor2(presentation::INativeCursor::SystemCursorType type); - - template - Ptr Element_Constructor() - { - return T::Create(); - } - extern presentation::elements::text::TextLines* GuiColorizedTextElement_GetLines(presentation::elements::GuiColorizedTextElement* thisObject); - - extern void GuiTableComposition_SetRows(presentation::compositions::GuiTableComposition* thisObject, vint value); - extern void GuiTableComposition_SetColumns(presentation::compositions::GuiTableComposition* thisObject, vint value); - extern void IGuiAltActionHost_CollectAltActions(presentation::compositions::IGuiAltActionHost* host, collections::List& actions); - - extern Ptr CreateWin7Theme(); - extern Ptr CreateWin8Theme(); - template - WString Interface_GetIdentifier() - { - return T::Identifier; - } + extern void GetRunRange(DocumentParagraphRun* run, RunRangeMap& runRanges); + extern void LocateStyle(DocumentParagraphRun* run, RunRangeMap& runRanges, vint position, bool frontSide, collections::List& locatedRuns); + extern Ptr LocateHyperlink(DocumentParagraphRun* run, RunRangeMap& runRanges, vint row, vint start, vint end); + extern Ptr CopyStyle(Ptr style); + extern Ptr CopyRun(DocumentRun* run); + extern Ptr CopyStyledText(collections::List& styleRuns, const WString& text); + extern Ptr CopyRunRecursively(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end, bool deepCopy); + extern void CollectStyleName(DocumentParagraphRun* run, collections::List& styleNames); + extern void ReplaceStyleName(DocumentParagraphRun* run, const WString& oldStyleName, const WString& newStyleName); + extern void RemoveRun(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end); + extern void CutRun(DocumentParagraphRun* run, RunRangeMap& runRanges, vint position, Ptr& leftRun, Ptr& rightRun); + extern void ClearUnnecessaryRun(DocumentParagraphRun* run, DocumentModel* model); + extern void AddStyle(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end, Ptr style); + extern void AddHyperlink(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end, const WString& reference, const WString& normalStyleName, const WString& activeStyleName); + extern void AddStyleName(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end, const WString& styleName); + extern void RemoveHyperlink(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end); + extern void RemoveStyleName(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end); + extern void ClearStyle(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end); + extern Ptr SummerizeStyle(DocumentParagraphRun* run, RunRangeMap& runRanges, DocumentModel* model, vint start, vint end); + extern void AggregateStyle(Ptr& dst, Ptr src); } } } @@ -17959,7 +18656,7 @@ External Functions #endif /*********************************************************************** -RESOURCES\GUIPARSERMANAGER.H +.\RESOURCES\GUIPARSERMANAGER.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -18126,508 +18823,127 @@ Parser Manager #endif /*********************************************************************** -CONTROLS\STYLES\GUICOMMONSTYLES.H +.\RESOURCES\GUIRESOURCEMANAGER.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 Developer: Zihan Chen(vczh) -GacUI::Control Styles::Common Style Helpers +GacUI Reflection: Instance Loader Interfaces: ***********************************************************************/ -#ifndef VCZH_PRESENTATION_CONTROLS_GUICOMMONSTYLES -#define VCZH_PRESENTATION_CONTROLS_GUICOMMONSTYLES +#ifndef VCZH_PRESENTATION_REFLECTION_GUIRESOURCEMANAGER +#define VCZH_PRESENTATION_REFLECTION_GUIRESOURCEMANAGER namespace vl { namespace presentation { - namespace common_styles + using namespace reflection; + +/*********************************************************************** +IGuiResourceManager +***********************************************************************/ + + class GuiResourceClassNameRecord : public Object, public Description { + public: + collections::List classNames; + }; -/*********************************************************************** -CommonScrollStyle -***********************************************************************/ + class IGuiResourceManager : public IDescriptable, public Description + { + public: + virtual bool SetResource(const WString& name, Ptr resource, GuiResourceUsage usage = GuiResourceUsage::DataOnly) = 0; + virtual Ptr GetResource(const WString& name) = 0; + virtual Ptr GetResourceFromClassName(const WString& classFullName) = 0; + }; - /// A general implementation for to make a scroll control. - class CommonScrollStyle : public Object, public virtual controls::GuiScroll::IStyleController, public Description - { - public: - /// Scroll direction. - enum Direction - { - /// Horizontal scroll. - Horizontal, - /// Vertical scroll. - Vertical, - }; - protected: - Direction direction; - controls::IScrollCommandExecutor* commandExecutor; - controls::GuiButton* decreaseButton; - controls::GuiButton* increaseButton; - controls::GuiButton* handleButton; - compositions::GuiPartialViewComposition* handleComposition; - compositions::GuiBoundsComposition* boundsComposition; - compositions::GuiBoundsComposition* containerComposition; - - vint totalSize; - vint pageSize; - vint position; - Point draggingStartLocation; - bool draggingHandle; - - void UpdateHandle(); - void OnDecreaseButtonClicked(compositions::GuiGraphicsComposition* sender,compositions::GuiEventArgs& arguments); - void OnIncreaseButtonClicked(compositions::GuiGraphicsComposition* sender,compositions::GuiEventArgs& arguments); - void OnHandleMouseDown(compositions::GuiGraphicsComposition* sender,compositions::GuiMouseEventArgs& arguments); - void OnHandleMouseMove(compositions::GuiGraphicsComposition* sender,compositions::GuiMouseEventArgs& arguments); - void OnHandleMouseUp(compositions::GuiGraphicsComposition* sender,compositions::GuiMouseEventArgs& arguments);; - void OnBigMoveMouseDown(compositions::GuiGraphicsComposition* sender,compositions::GuiMouseEventArgs& arguments); - - /// Callback to create a style controller for the decrement button. - /// The created style controller. - /// The direction of the scroll. - virtual controls::GuiButton::IStyleController* CreateDecreaseButtonStyle(Direction direction)=0; - /// Callback to create a style controller for the increment button. - /// The created style controller. - /// The direction of the scroll. - virtual controls::GuiButton::IStyleController* CreateIncreaseButtonStyle(Direction direction)=0; - /// Callback to create a style controller for the handle button. - /// The created style controller. - /// The direction of the scroll. - virtual controls::GuiButton::IStyleController* CreateHandleButtonStyle(Direction direction)=0; - /// Install necessary compositions and elements to the background. - /// The created container composition. - /// The background composition. - /// The direction of the scroll. - virtual compositions::GuiBoundsComposition* InstallBackground(compositions::GuiBoundsComposition* boundsComposition, Direction direction)=0; - /// Build the style. This function is supposed to be called in the contructor of the sub class. - /// The size of the increment button and decrement button. - /// The size of the arrows in the increment button and decrement button. - void BuildStyle(vint defaultSize, vint arrowSize); - public: - /// Create the style controller using a specified direction. - /// The specified direction - CommonScrollStyle(Direction _direction); - ~CommonScrollStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - void SetCommandExecutor(controls::IScrollCommandExecutor* value)override; - void SetTotalSize(vint value)override; - void SetPageSize(vint value)override; - void SetPosition(vint value)override; - }; - -/*********************************************************************** -CommonTrackStyle -***********************************************************************/ - - /// A general implementation for to make a tracker control (or a slide bar). - class CommonTrackStyle : public Object, public virtual controls::GuiScroll::IStyleController, public Description - { - public: - /// Track direction. - enum Direction - { - /// Horizontal scroll. - Horizontal, - /// Vertical scroll. - Vertical, - }; - protected: - Direction direction; - controls::IScrollCommandExecutor* commandExecutor; - compositions::GuiBoundsComposition* boundsComposition; - controls::GuiButton* handleButton; - compositions::GuiTableComposition* handleComposition; - - vint totalSize; - vint pageSize; - vint position; - Point draggingStartLocation; - bool draggingHandle; - - void UpdateHandle(); - void OnHandleMouseDown(compositions::GuiGraphicsComposition* sender,compositions::GuiMouseEventArgs& arguments); - void OnHandleMouseMove(compositions::GuiGraphicsComposition* sender,compositions::GuiMouseEventArgs& arguments); - void OnHandleMouseUp(compositions::GuiGraphicsComposition* sender,compositions::GuiMouseEventArgs& arguments); - - /// Callback to create a style controller for the handle button. - /// The created style controller. - /// The direction of the tracker. - virtual controls::GuiButton::IStyleController* CreateHandleButtonStyle(Direction direction)=0; - /// Install necessary compositions and elements to the background. - /// The background composition. - /// The direction of the tracker. - virtual void InstallBackground(compositions::GuiGraphicsComposition* boundsComposition, Direction direction)=0; - /// Install necessary compositions and elements to the tracker groove. - /// The tracker groove composition. - /// The direction of the tracker. - virtual void InstallTrack(compositions::GuiGraphicsComposition* trackComposition, Direction direction)=0; - /// Build the style. This function is supposed to be called in the contructor of the sub class. - /// The thickness of the tracker troove. - /// The padding between the tracker groove to the control. - /// The size of the long size of the handle button. Horizontal: height; Vertical: width. - /// The size of the short size of the handle button. Horizontal: width; Vertical: height. - void BuildStyle(vint trackThickness, vint trackPadding, vint handleLong, vint handleShort); - public: - /// Create the style controller using a specified direction. - /// The specified direction - CommonTrackStyle(Direction _direction); - ~CommonTrackStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - void SetCommandExecutor(controls::IScrollCommandExecutor* value)override; - void SetTotalSize(vint value)override; - void SetPageSize(vint value)override; - void SetPosition(vint value)override; - }; - -/*********************************************************************** -CommonFragmentBuilder -***********************************************************************/ - - class CommonFragmentBuilder - { - private: - static compositions::GuiBoundsComposition* BuildDockedElementContainer(elements::IGuiGraphicsElement* element); - public: - static void FillUpArrow(elements::GuiPolygonElement* element); - static void FillDownArrow(elements::GuiPolygonElement* element); - static void FillLeftArrow(elements::GuiPolygonElement* element); - static void FillRightArrow(elements::GuiPolygonElement* element); - - static elements::GuiPolygonElement* BuildUpArrow(); - static elements::GuiPolygonElement* BuildDownArrow(); - static elements::GuiPolygonElement* BuildLeftArrow(); - static elements::GuiPolygonElement* BuildRightArrow(); - - static compositions::GuiBoundsComposition* BuildUpArrow(elements::GuiPolygonElement*& elementOut); - static compositions::GuiBoundsComposition* BuildDownArrow(elements::GuiPolygonElement*& elementOut); - static compositions::GuiBoundsComposition* BuildLeftArrow(elements::GuiPolygonElement*& elementOut); - static compositions::GuiBoundsComposition* BuildRightArrow(elements::GuiPolygonElement*& elementOut); - }; - } - -/*********************************************************************** -Helper Functions -***********************************************************************/ - - extern unsigned char IntToColor(vint color); - extern Color BlendColor(Color c1, Color c2, vint currentPosition, vint totalLength); - -/*********************************************************************** -Animation -***********************************************************************/ - -#define DEFINE_TRANSFERRING_ANIMATION(TSTATE, TSTYLECONTROLLER)\ - class TransferringAnimation : public compositions::GuiTimeBasedAnimation\ - {\ - protected:\ - TSTATE colorBegin;\ - TSTATE colorEnd;\ - TSTATE colorCurrent;\ - TSTYLECONTROLLER* style;\ - bool stopped;\ - bool disabled;\ - bool enableAnimation;\ - void PlayInternal(vint currentPosition, vint totalLength);\ - public:\ - TransferringAnimation(TSTYLECONTROLLER* _style, const TSTATE& begin);\ - void Disable();\ - void Play(vint currentPosition, vint totalLength)override;\ - void Stop()override;\ - bool GetEnableAnimation();\ - void SetEnableAnimation(bool value);\ - void Transfer(const TSTATE& end);\ - };\ - -/*********************************************************************** -Animation Implementation -***********************************************************************/ - -#define DEFAULT_TRANSFERRING_ANIMATION_HOST_GETTER(STYLE) (STYLE->GetBoundsComposition()->GetRelatedGraphicsHost()) - -#define IMPLEMENT_TRANSFERRING_ANIMATION_BASE(TSTATE, TSTYLECONTROLLER, HOST_GETTER)\ - TSTYLECONTROLLER::TransferringAnimation::TransferringAnimation(TSTYLECONTROLLER* _style, const TSTATE& begin)\ - :GuiTimeBasedAnimation(0)\ - ,colorBegin(begin)\ - ,colorEnd(begin)\ - ,colorCurrent(begin)\ - ,style(_style)\ - ,stopped(true)\ - ,disabled(false)\ - ,enableAnimation(true)\ - {\ - }\ - void TSTYLECONTROLLER::TransferringAnimation::Disable()\ - {\ - disabled=true;\ - }\ - void TSTYLECONTROLLER::TransferringAnimation::Play(vint currentPosition, vint totalLength)\ - {\ - if(!disabled)\ - {\ - PlayInternal(currentPosition, totalLength);\ - }\ - }\ - void TSTYLECONTROLLER::TransferringAnimation::Stop()\ - {\ - stopped=true;\ - }\ - bool TSTYLECONTROLLER::TransferringAnimation::GetEnableAnimation()\ - {\ - return enableAnimation;\ - }\ - void TSTYLECONTROLLER::TransferringAnimation::SetEnableAnimation(bool value)\ - {\ - enableAnimation=value;\ - }\ - void TSTYLECONTROLLER::TransferringAnimation::Transfer(const TSTATE& end)\ - {\ - if(colorEnd!=end)\ - {\ - GuiGraphicsHost* host=HOST_GETTER(style);\ - if(enableAnimation && host)\ - {\ - Restart(120);\ - if(stopped)\ - {\ - colorBegin=colorEnd;\ - colorEnd=end;\ - host->GetAnimationManager()->AddAnimation(style->transferringAnimation);\ - stopped=false;\ - }\ - else\ - {\ - colorBegin=colorCurrent;\ - colorEnd=end;\ - }\ - }\ - else\ - {\ - colorBegin=end;\ - colorEnd=end;\ - colorCurrent=end;\ - Play(1, 1);\ - }\ - }\ - }\ - void TSTYLECONTROLLER::TransferringAnimation::PlayInternal(vint currentPosition, vint totalLength)\ - -#define IMPLEMENT_TRANSFERRING_ANIMATION(TSTATE, TSTYLECONTROLLER)\ - IMPLEMENT_TRANSFERRING_ANIMATION_BASE(TSTATE, TSTYLECONTROLLER, DEFAULT_TRANSFERRING_ANIMATION_HOST_GETTER) + extern IGuiResourceManager* GetResourceManager(); } } #endif /*********************************************************************** -CONTROLS\STYLES\WIN7STYLES\GUIWIN7STYLESCOMMON.H +.\GACUIREFLECTIONHELPER.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 Developer: Zihan Chen(vczh) -GacUI::Control Styles::Windows7 Styles +GacUI Reflection Helper -Clases: ***********************************************************************/ -#ifndef VCZH_PRESENTATION_CONTROLS_WIN7STYLES_GUIWIN7STYLESCOMMON -#define VCZH_PRESENTATION_CONTROLS_WIN7STYLES_GUIWIN7STYLESCOMMON +#ifndef VCZH_PRESENTATION_GACUIREFLECTIONHELPER +#define VCZH_PRESENTATION_GACUIREFLECTIONHELPER namespace vl { - namespace presentation + namespace reflection { - namespace win7 + namespace description { /*********************************************************************** -Button Configuration +Serialization ***********************************************************************/ - - struct Win7ButtonColors + + template<> + struct TypedValueSerializerProvider { - Color borderColor; - Color backgroundColor; - Color g1; - Color g2; - Color g3; - Color g4; - Color textColor; - Color bulletLight; - Color bulletDark; - - bool operator==(const Win7ButtonColors& colors) - { - return - borderColor == colors.borderColor && - backgroundColor == colors.backgroundColor && - g1 == colors.g1 && - g2 == colors.g2 && - g3 == colors.g3 && - g4 == colors.g4 && - textColor == colors.textColor && - bulletLight == colors.bulletLight && - bulletDark == colors.bulletDark; - } - - bool operator!=(const Win7ButtonColors& colors) - { - return !(*this==colors); - } - - void SetAlphaWithoutText(unsigned char a); - - static Win7ButtonColors Blend(const Win7ButtonColors& c1, const Win7ButtonColors& c2, vint ratio, vint total); - - static Win7ButtonColors ButtonNormal(); - static Win7ButtonColors ButtonActive(); - static Win7ButtonColors ButtonPressed(); - static Win7ButtonColors ButtonDisabled(); - - static Win7ButtonColors ItemNormal(); - static Win7ButtonColors ItemActive(); - static Win7ButtonColors ItemSelected(); - static Win7ButtonColors ItemDisabled(); - - static Win7ButtonColors CheckedNormal(bool selected); - static Win7ButtonColors CheckedActive(bool selected); - static Win7ButtonColors CheckedPressed(bool selected); - static Win7ButtonColors CheckedDisabled(bool selected); - - static Win7ButtonColors ToolstripButtonNormal(); - static Win7ButtonColors ToolstripButtonActive(); - static Win7ButtonColors ToolstripButtonPressed(); - static Win7ButtonColors ToolstripButtonSelected(); - static Win7ButtonColors ToolstripButtonDisabled(); - - static Win7ButtonColors MenuBarButtonNormal(); - static Win7ButtonColors MenuBarButtonActive(); - static Win7ButtonColors MenuBarButtonPressed(); - static Win7ButtonColors MenuBarButtonDisabled(); - - static Win7ButtonColors MenuItemButtonNormal(); - static Win7ButtonColors MenuItemButtonNormalActive(); - static Win7ButtonColors MenuItemButtonSelected(); - static Win7ButtonColors MenuItemButtonSelectedActive(); - static Win7ButtonColors MenuItemButtonDisabled(); - static Win7ButtonColors MenuItemButtonDisabledActive(); - - static Win7ButtonColors TabPageHeaderNormal(); - static Win7ButtonColors TabPageHeaderActive(); - static Win7ButtonColors TabPageHeaderSelected(); + static presentation::Color GetDefaultValue(); + static bool Serialize(const presentation::Color& input, WString& output); + static bool Deserialize(const WString& input, presentation::Color& output); + static IBoxedValue::CompareResult Compare(const presentation::Color& a, const presentation::Color& b); }; - struct Win7ButtonElements + template<> + struct TypedValueSerializerProvider { - elements::GuiSolidBorderElement* rectBorderElement; - elements::GuiRoundBorderElement* roundBorderElement; - elements::GuiSolidBackgroundElement* backgroundElement; - elements::GuiGradientBackgroundElement* topGradientElement; - elements::GuiGradientBackgroundElement* bottomGradientElement; - elements::GuiSolidLabelElement* textElement; - compositions::GuiBoundsComposition* textComposition; - compositions::GuiBoundsComposition* mainComposition; - compositions::GuiBoundsComposition* backgroundComposition; - compositions::GuiTableComposition* gradientComposition; - - static Win7ButtonElements Create(bool verticalGradient, bool roundBorder, Alignment horizontal=Alignment::Center, Alignment vertical=Alignment::Center); - void Apply(const Win7ButtonColors& colors); + static presentation::DocumentFontSize GetDefaultValue(); + static bool Serialize(const presentation::DocumentFontSize& input, WString& output); + static bool Deserialize(const WString& input, presentation::DocumentFontSize& output); + static IBoxedValue::CompareResult Compare(const presentation::DocumentFontSize& a, const presentation::DocumentFontSize& b); }; - struct Win7CheckedButtonElements + template<> + struct TypedValueSerializerProvider { - elements::GuiSolidBorderElement* borderElement; - elements::GuiSolidBackgroundElement* backgroundElement; - elements::GuiGradientBackgroundElement* outerGradientElement; - elements::GuiGradientBackgroundElement* innerGradientElement; - elements::GuiSolidLabelElement* textElement; - elements::GuiSolidLabelElement* bulletCheckElement; - elements::GuiSolidBackgroundElement* bulletRadioElement; - compositions::GuiBoundsComposition* textComposition; - compositions::GuiBoundsComposition* mainComposition; - - static Win7CheckedButtonElements Create(elements::ElementShape shape, bool backgroundVisible); - void Apply(const Win7ButtonColors& colors); - }; - - struct Win7MenuItemButtonElements - { - elements::GuiRoundBorderElement* borderElement; - elements::GuiSolidBackgroundElement* backgroundElement; - elements::GuiGradientBackgroundElement* gradientElement; - elements::Gui3DSplitterElement* splitterElement; - compositions::GuiCellComposition* splitterComposition; - elements::GuiImageFrameElement* imageElement; - elements::GuiSolidLabelElement* textElement; - compositions::GuiSharedSizeItemComposition* textComposition; - elements::GuiSolidLabelElement* shortcutElement; - compositions::GuiSharedSizeItemComposition* shortcutComposition; - elements::GuiPolygonElement* subMenuArrowElement; - compositions::GuiGraphicsComposition* subMenuArrowComposition; - compositions::GuiBoundsComposition* mainComposition; - - static Win7MenuItemButtonElements Create(); - void Apply(const Win7ButtonColors& colors); - void SetActive(bool value); - void SetSubMenuExisting(bool value); - }; - - struct Win7TextBoxColors - { - Color borderColor; - Color backgroundColor; - - bool operator==(const Win7TextBoxColors& colors) - { - return - borderColor == colors.borderColor && - backgroundColor == colors.backgroundColor; - } - - bool operator!=(const Win7TextBoxColors& colors) - { - return !(*this==colors); - } - - static Win7TextBoxColors Blend(const Win7TextBoxColors& c1, const Win7TextBoxColors& c2, vint ratio, vint total); - - static Win7TextBoxColors Normal(); - static Win7TextBoxColors Active(); - static Win7TextBoxColors Focused(); - static Win7TextBoxColors Disabled(); + static presentation::GlobalStringKey GetDefaultValue(); + static bool Serialize(const presentation::GlobalStringKey& input, WString& output); + static bool Deserialize(const WString& input, presentation::GlobalStringKey& output); + static IBoxedValue::CompareResult Compare(const presentation::GlobalStringKey& a, const presentation::GlobalStringKey& b); }; /*********************************************************************** -Helper Functions +External Functions ***********************************************************************/ - - extern Color Win7GetSystemWindowColor(); - extern Color Win7GetSystemTabContentColor(); - extern Color Win7GetSystemBorderColor(); - extern Color Win7GetSystemBorderSinkColor(); - extern Color Win7GetSystemBorderRaiseColor(); - extern Color Win7GetSystemTextColor(bool enabled); - extern void Win7SetFont(elements::GuiSolidLabelElement* element, compositions::GuiBoundsComposition* composition, const FontProperties& fontProperties); - extern void Win7CreateSolidLabelElement(elements::GuiSolidLabelElement*& element, compositions::GuiBoundsComposition*& composition, Alignment horizontal, Alignment vertical); - extern void Win7CreateSolidLabelElement(elements::GuiSolidLabelElement*& element, compositions::GuiSharedSizeItemComposition*& composition, const WString& group, Alignment horizontal, Alignment vertical); - extern elements::text::ColorEntry Win7GetTextBoxTextColor(); + + extern presentation::compositions::GuiGraphicsAnimationManager* GuiControlHost_GetAnimationManager(presentation::controls::GuiControlHost* thisObject); + extern Ptr INativeImage_Constructor(const WString& path); + extern presentation::INativeCursor* INativeCursor_Constructor1(); + extern presentation::INativeCursor* INativeCursor_Constructor2(presentation::INativeCursor::SystemCursorType type); + + template + Ptr Element_Constructor() + { + return T::Create(); + } + extern presentation::elements::text::TextLines* GuiColorizedTextElement_GetLines(presentation::elements::GuiColorizedTextElement* thisObject); + + extern void GuiTableComposition_SetRows(presentation::compositions::GuiTableComposition* thisObject, vint value); + extern void GuiTableComposition_SetColumns(presentation::compositions::GuiTableComposition* thisObject, vint value); + extern void IGuiAltActionHost_CollectAltActions(presentation::compositions::IGuiAltActionHost* host, collections::List& actions); + + template + WString Interface_GetIdentifier() + { + return T::Identifier; + } } } } @@ -18635,3055 +18951,7 @@ Helper Functions #endif /*********************************************************************** -CONTROLS\STYLES\WIN7STYLES\GUIWIN7BUTTONSTYLES.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control Styles::Windows7 Styles - -Clases: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_WIN7STYLES_GUIWIN7BUTTONSTYLES -#define VCZH_PRESENTATION_CONTROLS_WIN7STYLES_GUIWIN7BUTTONSTYLES - - -namespace vl -{ - namespace presentation - { - namespace win7 - { - -/*********************************************************************** -Button -***********************************************************************/ - - /// The base class of all button style implementations. (Windows 7) - class Win7ButtonStyleBase : public Object, public virtual controls::GuiSelectableButton::IStyleController, public Description - { - protected: - DEFINE_TRANSFERRING_ANIMATION(Win7ButtonColors, Win7ButtonStyleBase) - - Win7ButtonElements elements; - Ptr transferringAnimation; - controls::ButtonState controlStyle; - bool isVisuallyEnabled; - bool isSelected; - bool transparentWhenInactive; - bool transparentWhenDisabled; - - virtual void TransferInternal(controls::ButtonState value, bool enabled, bool selected)=0; - virtual void AfterApplyColors(const Win7ButtonColors& colors); - public: - /// Create the style. - /// Set to true to have a vertical gradient background. - /// Set to true to have a round border - /// Set to true to set the initial colors of all components for a button. - /// Horizontal alignment for text. - /// Vertical alignment for text. - Win7ButtonStyleBase(bool verticalGradient, bool roundBorder, const Win7ButtonColors& initialColor, Alignment horizontal, Alignment vertical); - ~Win7ButtonStyleBase(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - void SetSelected(bool value)override; - void Transfer(controls::ButtonState value)override; - - /// Get the transparent style for the inactive state. - /// Returns true if the background is not transparent for the inactive state. - bool GetTransparentWhenInactive(); - /// Set the transparent style for the inactive state. - /// Set to troe true to make the background not transparent for the inactive state. - void SetTransparentWhenInactive(bool value); - /// Get the transparent style for the disabled state. - /// Returns true if the background is not transparent for the disabled state. - bool GetTransparentWhenDisabled(); - /// Set the transparent style for the inactive state. - /// Set to troe true to make the background not transparent for the disabled state. - void SetTransparentWhenDisabled(bool value); - /// Get the automatically size changing state of the button. - /// Returns true if the style automatically changes its size if the text changed. - bool GetAutoSizeForText(); - /// Set the automatically size changing state of the button. - /// Set to true to make the style automatically changes its size if the text changed. - void SetAutoSizeForText(bool value); - }; - - /// Button style (Windows 7). - class Win7ButtonStyle : public Win7ButtonStyleBase, public Description - { - protected: - void TransferInternal(controls::ButtonState value, bool enabled, bool selected)override; - public: - /// Create the style. - /// Set to true to have a vertical gradient background. - Win7ButtonStyle(bool verticalGradient=true); - ~Win7ButtonStyle(); - }; - - /// Check box style (Windows 7). - class Win7CheckBoxStyle : public Object, public virtual controls::GuiSelectableButton::IStyleController, public Description - { - public: - /// Bullet style. - enum BulletStyle - { - /// Check box bullet. - CheckBox, - /// Radio button bullet. - RadioButton, - }; - protected: - DEFINE_TRANSFERRING_ANIMATION(Win7ButtonColors, Win7CheckBoxStyle) - - Win7CheckedButtonElements elements; - Ptr transferringAnimation; - controls::ButtonState controlStyle; - bool isVisuallyEnabled; - bool isSelected; - - void TransferInternal(controls::ButtonState value, bool enabled, bool selected); - public: - /// Create the style. - /// The bullet style. - /// Set to true to make the background visible. - Win7CheckBoxStyle(BulletStyle bulletStyle, bool backgroundVisible=false); - ~Win7CheckBoxStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - void SetSelected(bool value)override; - void Transfer(controls::ButtonState value)override; - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\STYLES\WIN7STYLES\GUIWIN7SCROLLABLESTYLES.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control Styles::Windows7 Styles - -Clases: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_WIN7STYLES_GUIWIN7SCROLLABLESTYLES -#define VCZH_PRESENTATION_CONTROLS_WIN7STYLES_GUIWIN7SCROLLABLESTYLES - - -namespace vl -{ - namespace presentation - { - namespace win7 - { - -/*********************************************************************** -Scroll -***********************************************************************/ - - /// Scroll bar arrow button style (Windows 7). - class Win7ScrollArrowButtonStyle : public Win7ButtonStyleBase, public Description - { - protected: - elements::GuiPolygonElement* arrowElement; - - void TransferInternal(controls::ButtonState value, bool enabled, bool selected)override; - void AfterApplyColors(const Win7ButtonColors& colors)override; - public: - /// Create the style. - /// The direction of the arrow. - /// Set to true to create the arrow for the increase button, otherwise for the decrease button. - Win7ScrollArrowButtonStyle(common_styles::CommonScrollStyle::Direction direction, bool increaseButton); - ~Win7ScrollArrowButtonStyle(); - }; - - /// Scroll bar style (Windows 7). - class Win7ScrollStyle : public common_styles::CommonScrollStyle, public Description - { - public: - static const vint DefaultSize=18; - static const vint ArrowSize=10; - protected: - controls::GuiButton::IStyleController* CreateDecreaseButtonStyle(Direction direction)override; - controls::GuiButton::IStyleController* CreateIncreaseButtonStyle(Direction direction)override; - controls::GuiButton::IStyleController* CreateHandleButtonStyle(Direction direction)override; - compositions::GuiBoundsComposition* InstallBackground(compositions::GuiBoundsComposition* boundsComposition, Direction direction)override; - public: - /// Create the style using a specified direction. - /// The specified direction - Win7ScrollStyle(Direction _direction); - ~Win7ScrollStyle(); - }; - - /// Tracker (slide bar) style (Windows 7). - class Win7TrackStyle : public common_styles::CommonTrackStyle, public Description - { - public: - static const vint TrackThickness=4; - static const vint TrackPadding=8; - static const vint HandleLong=21; - static const vint HandleShort=10; - - protected: - controls::GuiButton::IStyleController* CreateHandleButtonStyle(Direction direction)override; - void InstallBackground(compositions::GuiGraphicsComposition* boundsComposition, Direction direction)override; - void InstallTrack(compositions::GuiGraphicsComposition* trackComposition, Direction direction)override; - public: - /// Create the style using a specified direction. - /// The specified direction - Win7TrackStyle(Direction _direction); - ~Win7TrackStyle(); - }; - - /// Progress bar style (Windows 7). - class Win7ProgressBarStyle : public Object, public virtual controls::GuiScroll::IStyleController, public Description - { - protected: - vint totalSize; - vint pageSize; - vint position; - compositions::GuiBoundsComposition* boundsComposition; - compositions::GuiBoundsComposition* containerComposition; - compositions::GuiPartialViewComposition* progressComposition; - - void UpdateProgressBar(); - void FillProgressColors(compositions::GuiGraphicsComposition* parent, Color g1, Color g2, Color g3, Color g4, Color g5); - public: - Win7ProgressBarStyle(); - ~Win7ProgressBarStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - void SetCommandExecutor(controls::IScrollCommandExecutor* value)override; - void SetTotalSize(vint value)override; - void SetPageSize(vint value)override; - void SetPosition(vint value)override; - }; - -/*********************************************************************** -ScrollView -***********************************************************************/ - - /// Scroll view style (Windows 7). - class Win7ScrollViewProvider : public Object, public virtual controls::GuiScrollView::IStyleProvider, public Description - { - public: - /// Create the style. - Win7ScrollViewProvider(); - ~Win7ScrollViewProvider(); - - void AssociateStyleController(controls::GuiControl::IStyleController* controller)override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - - controls::GuiScroll::IStyleController* CreateHorizontalScrollStyle()override; - controls::GuiScroll::IStyleController* CreateVerticalScrollStyle()override; - vint GetDefaultScrollSize()override; - compositions::GuiGraphicsComposition* InstallBackground(compositions::GuiBoundsComposition* boundsComposition)override; - }; - -/*********************************************************************** -TextBox -***********************************************************************/ - - class Win7TextBoxBackground : public Object, public Description - { - protected: - DEFINE_TRANSFERRING_ANIMATION(Win7TextBoxColors, Win7TextBoxBackground) - - elements::GuiRoundBorderElement* borderElement; - elements::GuiSolidBackgroundElement* backgroundElement; - compositions::GuiGraphicsComposition* focusableComposition; - bool isMouseEnter; - bool isFocused; - bool isVisuallyEnabled; - Ptr transferringAnimation; - controls::GuiControl::IStyleController* styleController; - elements::GuiColorizedTextElement* textElement; - - void UpdateStyle(); - void Apply(const Win7TextBoxColors& colors); - - void OnBoundsMouseEnter(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnBoundsMouseLeave(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnBoundsGotFocus(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnBoundsLostFocus(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - public: - Win7TextBoxBackground(); - ~Win7TextBoxBackground(); - - void AssociateStyleController(controls::GuiControl::IStyleController* controller); - void SetFocusableComposition(compositions::GuiGraphicsComposition* value); - void SetVisuallyEnabled(bool value); - compositions::GuiGraphicsComposition* InstallBackground(compositions::GuiBoundsComposition* boundsComposition); - void InitializeTextElement(elements::GuiColorizedTextElement* _textElement); - }; - - /// Multiline text box style (Windows 7). - class Win7MultilineTextBoxProvider : public Win7ScrollViewProvider, public Description - { - protected: - Win7TextBoxBackground background; - controls::GuiControl::IStyleController* styleController; - public: - /// Create the style. - Win7MultilineTextBoxProvider(); - ~Win7MultilineTextBoxProvider(); - - void AssociateStyleController(controls::GuiControl::IStyleController* controller)override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetVisuallyEnabled(bool value)override; - compositions::GuiGraphicsComposition* InstallBackground(compositions::GuiBoundsComposition* boundsComposition)override; - }; - - /// Singleline text box style (Windows 7). - class Win7SinglelineTextBoxProvider : public Object, public virtual controls::GuiSinglelineTextBox::IStyleProvider, public Description - { - protected: - Win7TextBoxBackground background; - controls::GuiControl::IStyleController* styleController; - public: - /// Create the style. - Win7SinglelineTextBoxProvider(); - ~Win7SinglelineTextBoxProvider(); - - void AssociateStyleController(controls::GuiControl::IStyleController* controller)override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - compositions::GuiGraphicsComposition* InstallBackground(compositions::GuiBoundsComposition* boundsComposition)override; - }; - -#pragma warning(push) -#pragma warning(disable:4250) - - /// Document viewer style (Windows 7). - class Win7DocumentViewerStyle : public Win7MultilineTextBoxProvider, public virtual controls::GuiDocumentViewer::IStyleProvider, public Description - { - public: - /// Create the style. - Win7DocumentViewerStyle(); - ~Win7DocumentViewerStyle(); - - Ptr GetBaselineDocument()override; - Color GetCaretColor()override; - }; - - /// Document label style (Windows 7). - class Win7DocumentLabelStyle : public controls::GuiControl::EmptyStyleController, public virtual controls::GuiDocumentLabel::IStyleController, public Description - { - public: - /// Create the style. - Win7DocumentLabelStyle(); - ~Win7DocumentLabelStyle(); - - Ptr GetBaselineDocument()override; - Color GetCaretColor()override; - }; - - /// Document label style (Windows 7). - class Win7DocumentTextBoxStyle : public controls::GuiControl::EmptyStyleController, public virtual controls::GuiDocumentLabel::IStyleController, public Description - { - protected: - Win7TextBoxBackground background; - compositions::GuiBoundsComposition* boundsComposition; - compositions::GuiGraphicsComposition* containerComposition; - - public: - /// Create the style. - Win7DocumentTextBoxStyle(); - ~Win7DocumentTextBoxStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - Ptr GetBaselineDocument()override; - Color GetCaretColor()override; - }; -#pragma warning(pop) - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\STYLES\WIN7STYLES\GUIWIN7CONTROLSTYLES.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control Styles::Windows7 Styles - -Clases: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_WIN7STYLES_GUIWIN7CONTROLSTYLES -#define VCZH_PRESENTATION_CONTROLS_WIN7STYLES_GUIWIN7CONTROLSTYLES - - -namespace vl -{ - namespace presentation - { - namespace win7 - { - -/*********************************************************************** -Container -***********************************************************************/ - - /// Empty style. Nothing but a color filled the whole control. - class Win7EmptyStyle : public Object, public virtual controls::GuiControl::IStyleController, public Description - { - protected: - compositions::GuiBoundsComposition* boundsComposition; - public: - /// Create the style with a specified color. - /// The specified color. - Win7EmptyStyle(Color color); - ~Win7EmptyStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - }; - - /// Window style (Windows 7). Using the Windows 7 window background color to fill the whole control. - class Win7WindowStyle : public virtual controls::GuiWindow::DefaultBehaviorStyleController, public Description - { - protected: - compositions::GuiBoundsComposition* boundsComposition; - public: - /// Create the style. - Win7WindowStyle(); - ~Win7WindowStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - }; - - /// Tooltip style (Windows 7). Using the Windows 7 tooltip background color to fill the whole control. - class Win7TooltipStyle : public virtual controls::GuiWindow::DefaultBehaviorStyleController, public Description - { - protected: - compositions::GuiBoundsComposition* boundsComposition; - compositions::GuiBoundsComposition* containerComposition; - public: - /// Create the style. - Win7TooltipStyle(); - ~Win7TooltipStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - }; - - /// Label style (Windows 7). A label contains a text, and the label will automatically resize to fit the text. - class Win7LabelStyle : public Object, public virtual controls::GuiLabel::IStyleController, public Description - { - protected: - compositions::GuiBoundsComposition* boundsComposition; - elements::GuiSolidLabelElement* textElement; - public: - /// Create the style. - /// Set to true to create a style for displaying shortcut key. - Win7LabelStyle(bool forShortcutKey); - ~Win7LabelStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - Color GetDefaultTextColor()override; - void SetTextColor(Color value)override; - }; - - /// Group box style (Windows 7). - class Win7GroupBoxStyle : public Object, public virtual controls::GuiControl::IStyleController, public Description - { - protected: - DEFINE_TRANSFERRING_ANIMATION(Color, Win7GroupBoxStyle) - - compositions::GuiBoundsComposition* boundsComposition; - compositions::GuiBoundsComposition* sinkBorderComposition; - compositions::GuiBoundsComposition* raisedBorderComposition; - compositions::GuiBoundsComposition* textComposition; - compositions::GuiBoundsComposition* textBackgroundComposition; - compositions::GuiBoundsComposition* containerComposition; - elements::GuiSolidLabelElement* textElement; - Ptr transferringAnimation; - - void SetMargins(vint fontSize); - public: - /// Create the style. - Win7GroupBoxStyle(); - ~Win7GroupBoxStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - }; - - /// Date Picker (Windows 7) - class Win7DatePickerStyle : public Object, public virtual controls::GuiDatePicker::IStyleProvider, public Description - { - public: - /// Create the style. - Win7DatePickerStyle(); - ~Win7DatePickerStyle(); - - void AssociateStyleController(controls::GuiControl::IStyleController* controller)override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - - controls::GuiSelectableButton::IStyleController* CreateDateButtonStyle()override; - controls::GuiTextList* CreateTextList()override; - controls::GuiComboBoxListControl::IStyleController* CreateComboBoxStyle()override; - - Color GetBackgroundColor()override; - Color GetPrimaryTextColor()override; - Color GetSecondaryTextColor()override; - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\STYLES\WIN7STYLES\GUIWIN7MENUSTYLES.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control Styles::Windows7 Styles - -Clases: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_WIN7STYLES_GUIWIN7MENUSTYLES -#define VCZH_PRESENTATION_CONTROLS_WIN7STYLES_GUIWIN7MENUSTYLES - - -namespace vl -{ - namespace presentation - { - namespace win7 - { - -/*********************************************************************** -Menu Container -***********************************************************************/ - - /// Menu style (Windows 7). For the background of a popup menu. - class Win7MenuStyle : public Object, public virtual controls::GuiWindow::DefaultBehaviorStyleController, public Description - { - protected: - compositions::GuiBoundsComposition* boundsComposition; - compositions::GuiBoundsComposition* containerComposition; - public: - /// Create the style. - Win7MenuStyle(); - ~Win7MenuStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - }; - - /// Menu bar style (Windows 7). For the background of a menu bar. - class Win7MenuBarStyle : public Object, public virtual controls::GuiControl::IStyleController, public Description - { - protected: - compositions::GuiBoundsComposition* boundsComposition; - public: - /// Create the style. - Win7MenuBarStyle(); - ~Win7MenuBarStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - }; - -/*********************************************************************** -Menu Button -***********************************************************************/ - - /// Menu bar button style (Windows 7). For menu buttons in a menu bar. - class Win7MenuBarButtonStyle : public Object, public virtual controls::GuiMenuButton::IStyleController, public Description - { - protected: - Win7ButtonElements elements; - controls::ButtonState controlStyle; - bool isVisuallyEnabled; - bool isOpening; - - void TransferInternal(controls::ButtonState value, bool enabled, bool opening); - public: - /// Create the style. - Win7MenuBarButtonStyle(); - ~Win7MenuBarButtonStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - void SetSelected(bool value)override; - controls::GuiMenu::IStyleController* CreateSubMenuStyleController()override; - void SetSubMenuExisting(bool value)override; - void SetSubMenuOpening(bool value)override; - controls::GuiButton* GetSubMenuHost()override; - void SetImage(Ptr value)override; - void SetShortcutText(const WString& value)override; - void Transfer(controls::ButtonState value)override; - }; - - /// Menu item button style (Windows 7). For menu buttons in a popup menu. - class Win7MenuItemButtonStyle : public Object, public virtual controls::GuiMenuButton::IStyleController, public Description - { - protected: - Win7MenuItemButtonElements elements; - controls::ButtonState controlStyle; - bool isVisuallyEnabled; - bool isSelected; - bool isOpening; - - void TransferInternal(controls::ButtonState value, bool enabled, bool selected, bool opening); - public: - /// Create the style. - Win7MenuItemButtonStyle(); - ~Win7MenuItemButtonStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - void SetSelected(bool value)override; - controls::GuiMenu::IStyleController* CreateSubMenuStyleController()override; - void SetSubMenuExisting(bool value)override; - void SetSubMenuOpening(bool value)override; - controls::GuiButton* GetSubMenuHost()override; - void SetImage(Ptr value)override; - void SetShortcutText(const WString& value)override; - void Transfer(controls::ButtonState value)override; - }; - - /// Menu splitter style (Windows 7). For splitters in a popup menu. - class Win7MenuSplitterStyle : public Object, public virtual controls::GuiControl::IStyleController, public Description - { - protected: - compositions::GuiBoundsComposition* boundsComposition; - public: - /// Create the style. - Win7MenuSplitterStyle(); - ~Win7MenuSplitterStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\STYLES\WIN8STYLES\GUIWIN8STYLESCOMMON.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control Styles::Windows8 Styles - -Clases: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_WIN8STYLES_GUIWIN8STYLESCOMMON -#define VCZH_PRESENTATION_CONTROLS_WIN8STYLES_GUIWIN8STYLESCOMMON - - -namespace vl -{ - namespace presentation - { - namespace win8 - { - -/*********************************************************************** -Button Configuration -***********************************************************************/ - - struct Win8ButtonColors - { - Color borderColor; - Color g1; - Color g2; - Color textColor; - Color bullet; - - bool operator==(const Win8ButtonColors& colors) - { - return - borderColor == colors.borderColor && - g1 == colors.g1 && - g2 == colors.g2 && - textColor == colors.textColor && - bullet == colors.bullet; - } - - bool operator!=(const Win8ButtonColors& colors) - { - return !(*this==colors); - } - - void SetAlphaWithoutText(unsigned char a); - - static Win8ButtonColors Blend(const Win8ButtonColors& c1, const Win8ButtonColors& c2, vint ratio, vint total); - - static Win8ButtonColors ButtonNormal(); - static Win8ButtonColors ButtonActive(); - static Win8ButtonColors ButtonPressed(); - static Win8ButtonColors ButtonDisabled(); - - static Win8ButtonColors ItemNormal(); - static Win8ButtonColors ItemActive(); - static Win8ButtonColors ItemSelected(); - static Win8ButtonColors ItemDisabled(); - - static Win8ButtonColors CheckedNormal(bool selected); - static Win8ButtonColors CheckedActive(bool selected); - static Win8ButtonColors CheckedPressed(bool selected); - static Win8ButtonColors CheckedDisabled(bool selected); - - static Win8ButtonColors ToolstripButtonNormal(); - static Win8ButtonColors ToolstripButtonActive(); - static Win8ButtonColors ToolstripButtonPressed(); - static Win8ButtonColors ToolstripButtonSelected(); - static Win8ButtonColors ToolstripButtonDisabled(); - - static Win8ButtonColors ScrollHandleNormal(); - static Win8ButtonColors ScrollHandleActive(); - static Win8ButtonColors ScrollHandlePressed(); - static Win8ButtonColors ScrollHandleDisabled(); - static Win8ButtonColors ScrollArrowNormal(); - static Win8ButtonColors ScrollArrowActive(); - static Win8ButtonColors ScrollArrowPressed(); - static Win8ButtonColors ScrollArrowDisabled(); - - static Win8ButtonColors MenuBarButtonNormal(); - static Win8ButtonColors MenuBarButtonActive(); - static Win8ButtonColors MenuBarButtonPressed(); - static Win8ButtonColors MenuBarButtonDisabled(); - - static Win8ButtonColors MenuItemButtonNormal(); - static Win8ButtonColors MenuItemButtonNormalActive(); - static Win8ButtonColors MenuItemButtonSelected(); - static Win8ButtonColors MenuItemButtonSelectedActive(); - static Win8ButtonColors MenuItemButtonDisabled(); - static Win8ButtonColors MenuItemButtonDisabledActive(); - - static Win8ButtonColors TabPageHeaderNormal(); - static Win8ButtonColors TabPageHeaderActive(); - static Win8ButtonColors TabPageHeaderSelected(); - }; - - struct Win8ButtonElements - { - elements::GuiSolidBorderElement* rectBorderElement; - elements::GuiGradientBackgroundElement* backgroundElement; - elements::GuiSolidLabelElement* textElement; - compositions::GuiBoundsComposition* textComposition; - compositions::GuiBoundsComposition* mainComposition; - compositions::GuiBoundsComposition* backgroundComposition; - - static Win8ButtonElements Create(Alignment horizontal=Alignment::Center, Alignment vertical=Alignment::Center); - void Apply(const Win8ButtonColors& colors); - }; - - struct Win8CheckedButtonElements - { - elements::GuiSolidBorderElement* bulletBorderElement; - elements::GuiGradientBackgroundElement* bulletBackgroundElement; - elements::GuiSolidLabelElement* bulletCheckElement; - elements::GuiSolidBackgroundElement* bulletRadioElement; - elements::GuiSolidLabelElement* textElement; - compositions::GuiBoundsComposition* textComposition; - compositions::GuiBoundsComposition* mainComposition; - - static Win8CheckedButtonElements Create(elements::ElementShape shape, bool backgroundVisible); - void Apply(const Win8ButtonColors& colors); - }; - - struct Win8MenuItemButtonElements - { - elements::GuiSolidBorderElement* borderElement; - elements::GuiGradientBackgroundElement* backgroundElement; - elements::GuiSolidBorderElement* splitterElement; - compositions::GuiCellComposition* splitterComposition; - elements::GuiImageFrameElement* imageElement; - elements::GuiSolidLabelElement* textElement; - compositions::GuiSharedSizeItemComposition* textComposition; - elements::GuiSolidLabelElement* shortcutElement; - compositions::GuiSharedSizeItemComposition* shortcutComposition; - elements::GuiPolygonElement* subMenuArrowElement; - compositions::GuiGraphicsComposition* subMenuArrowComposition; - compositions::GuiBoundsComposition* mainComposition; - - static Win8MenuItemButtonElements Create(); - void Apply(const Win8ButtonColors& colors); - void SetActive(bool value); - void SetSubMenuExisting(bool value); - }; - - struct Win8TextBoxColors - { - Color borderColor; - Color backgroundColor; - - bool operator==(const Win8TextBoxColors& colors) - { - return - borderColor == colors.borderColor && - backgroundColor == colors.backgroundColor; - } - - bool operator!=(const Win8TextBoxColors& colors) - { - return !(*this==colors); - } - - static Win8TextBoxColors Blend(const Win8TextBoxColors& c1, const Win8TextBoxColors& c2, vint ratio, vint total); - - static Win8TextBoxColors Normal(); - static Win8TextBoxColors Active(); - static Win8TextBoxColors Focused(); - static Win8TextBoxColors Disabled(); - }; - -/*********************************************************************** -Helper Functions -***********************************************************************/ - - extern Color Win8GetSystemWindowColor(); - extern Color Win8GetSystemTabContentColor(); - extern Color Win8GetSystemBorderColor(); - extern Color Win8GetSystemTextColor(bool enabled); - extern Color Win8GetMenuBorderColor(); - extern Color Win8GetMenuSplitterColor(); - extern void Win8SetFont(elements::GuiSolidLabelElement* element, compositions::GuiBoundsComposition* composition, const FontProperties& fontProperties); - extern void Win8CreateSolidLabelElement(elements::GuiSolidLabelElement*& element, compositions::GuiBoundsComposition*& composition, Alignment horizontal, Alignment vertical); - extern void Win8CreateSolidLabelElement(elements::GuiSolidLabelElement*& element, compositions::GuiSharedSizeItemComposition*& composition, const WString& group, Alignment horizontal, Alignment vertical); - extern elements::text::ColorEntry Win8GetTextBoxTextColor(); - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\STYLES\WIN8STYLES\GUIWIN8BUTTONSTYLES.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control Styles::Windows8 Styles - -Clases: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_WIN7STYLES_GUIWIN8BUTTONSTYLES -#define VCZH_PRESENTATION_CONTROLS_WIN7STYLES_GUIWIN8BUTTONSTYLES - - -namespace vl -{ - namespace presentation - { - namespace win8 - { - -/*********************************************************************** -Button -***********************************************************************/ - - /// The base class of all button style implementations. (Windows 8) - class Win8ButtonStyleBase : public Object, public virtual controls::GuiSelectableButton::IStyleController, public Description - { - protected: - DEFINE_TRANSFERRING_ANIMATION(Win8ButtonColors, Win8ButtonStyleBase) - - Win8ButtonElements elements; - Ptr transferringAnimation; - controls::ButtonState controlStyle; - bool isVisuallyEnabled; - bool isSelected; - bool transparentWhenInactive; - bool transparentWhenDisabled; - - virtual void TransferInternal(controls::ButtonState value, bool enabled, bool selected)=0; - virtual void AfterApplyColors(const Win8ButtonColors& colors); - public: - /// Create the style. - /// Set to true to set the initial colors of all components for a button. - /// Horizontal alignment for text. - /// Vertical alignment for text. - Win8ButtonStyleBase(const Win8ButtonColors& initialColor, Alignment horizontal, Alignment vertical); - ~Win8ButtonStyleBase(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - void SetSelected(bool value)override; - void Transfer(controls::ButtonState value)override; - - /// Get the transparent style for the inactive state. - /// Returns true if the background is not transparent for the inactive state. - bool GetTransparentWhenInactive(); - /// Set the transparent style for the inactive state. - /// Set to troe true to make the background not transparent for the inactive state. - void SetTransparentWhenInactive(bool value); - /// Get the transparent style for the disabled state. - /// Returns true if the background is not transparent for the disabled state. - bool GetTransparentWhenDisabled(); - /// Set the transparent style for the inactive state. - /// Set to troe true to make the background not transparent for the disabled state. - void SetTransparentWhenDisabled(bool value); - /// Get the automatically size changing state of the button. - /// Returns true if the style automatically changes its size if the text changed. - bool GetAutoSizeForText(); - /// Set the automatically size changing state of the button. - /// Set to true to make the style automatically changes its size if the text changed. - void SetAutoSizeForText(bool value); - }; - - /// Button style (Windows 8). - class Win8ButtonStyle : public Win8ButtonStyleBase, public Description - { - protected: - void TransferInternal(controls::ButtonState value, bool enabled, bool selected)override; - public: - /// Create the style. - Win8ButtonStyle(); - ~Win8ButtonStyle(); - }; - - /// Check box style (Windows 8). - class Win8CheckBoxStyle : public Object, public virtual controls::GuiSelectableButton::IStyleController, public Description - { - public: - /// Bullet style. - enum BulletStyle - { - /// Check box bullet. - CheckBox, - /// Radio button bullet. - RadioButton, - }; - protected: - DEFINE_TRANSFERRING_ANIMATION(Win8ButtonColors, Win8CheckBoxStyle) - - Win8CheckedButtonElements elements; - Ptr transferringAnimation; - controls::ButtonState controlStyle; - bool isVisuallyEnabled; - bool isSelected; - - void TransferInternal(controls::ButtonState value, bool enabled, bool selected); - public: - /// Create the style. - /// The bullet style. - /// Set to true to make the background visible. - Win8CheckBoxStyle(BulletStyle bulletStyle, bool backgroundVisible=false); - ~Win8CheckBoxStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - void SetSelected(bool value)override; - void Transfer(controls::ButtonState value)override; - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\STYLES\WIN8STYLES\GUIWIN8SCROLLABLESTYLES.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control Styles::Windows8 Styles - -Clases: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_WIN8STYLES_GUIWin8SCROLLABLESTYLES -#define VCZH_PRESENTATION_CONTROLS_WIN8STYLES_GUIWin8SCROLLABLESTYLES - - -namespace vl -{ - namespace presentation - { - namespace win8 - { - -/*********************************************************************** -Scroll -***********************************************************************/ - - /// Scroll bar handle button style (Windows 8). - class Win8ScrollHandleButtonStyle : public Win8ButtonStyleBase, public Description - { - protected: - void TransferInternal(controls::ButtonState value, bool enabled, bool selected)override; - public: - /// Create the style. - Win8ScrollHandleButtonStyle(); - ~Win8ScrollHandleButtonStyle(); - }; - - /// Scroll bar arrow button style (Windows 8). - class Win8ScrollArrowButtonStyle : public Win8ButtonStyleBase, public Description - { - protected: - elements::GuiPolygonElement* arrowElement; - - void TransferInternal(controls::ButtonState value, bool enabled, bool selected)override; - void AfterApplyColors(const Win8ButtonColors& colors)override; - public: - /// Create the style. - /// The direction of the arrow. - /// Set to true to create the arrow for the increase button, otherwise for the decrease button. - Win8ScrollArrowButtonStyle(common_styles::CommonScrollStyle::Direction direction, bool increaseButton); - ~Win8ScrollArrowButtonStyle(); - }; - - /// Scroll bar style (Windows 8). - class Win8ScrollStyle : public common_styles::CommonScrollStyle, public Description - { - public: - static const vint DefaultSize=16; - static const vint ArrowSize=8; - protected: - controls::GuiButton::IStyleController* CreateDecreaseButtonStyle(Direction direction)override; - controls::GuiButton::IStyleController* CreateIncreaseButtonStyle(Direction direction)override; - controls::GuiButton::IStyleController* CreateHandleButtonStyle(Direction direction)override; - compositions::GuiBoundsComposition* InstallBackground(compositions::GuiBoundsComposition* boundsComposition, Direction direction)override; - public: - /// Create the style using a specified direction. - /// The specified direction - Win8ScrollStyle(Direction _direction); - ~Win8ScrollStyle(); - }; - - /// Tracker (slide bar) style (Windows 8). - class Win8TrackStyle : public common_styles::CommonTrackStyle, public Description - { - public: - static const vint TrackThickness=4; - static const vint TrackPadding=6; - static const vint HandleLong=16; - static const vint HandleShort=10; - - protected: - controls::GuiButton::IStyleController* CreateHandleButtonStyle(Direction direction)override; - void InstallBackground(compositions::GuiGraphicsComposition* boundsComposition, Direction direction)override; - void InstallTrack(compositions::GuiGraphicsComposition* trackComposition, Direction direction)override; - public: - /// Create the style using a specified direction. - /// The specified direction - Win8TrackStyle(Direction _direction); - ~Win8TrackStyle(); - }; - - /// Progress bar style (Windows 8). - class Win8ProgressBarStyle : public Object, public virtual controls::GuiScroll::IStyleController, public Description - { - protected: - vint totalSize; - vint pageSize; - vint position; - compositions::GuiBoundsComposition* boundsComposition; - compositions::GuiBoundsComposition* containerComposition; - compositions::GuiPartialViewComposition* progressComposition; - - void UpdateProgressBar(); - public: - Win8ProgressBarStyle(); - ~Win8ProgressBarStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - void SetCommandExecutor(controls::IScrollCommandExecutor* value)override; - void SetTotalSize(vint value)override; - void SetPageSize(vint value)override; - void SetPosition(vint value)override; - }; - -/*********************************************************************** -ScrollView -***********************************************************************/ - - /// Scroll view style (Windows 8). - class Win8ScrollViewProvider : public Object, public virtual controls::GuiScrollView::IStyleProvider, public Description - { - public: - /// Create the style. - Win8ScrollViewProvider(); - ~Win8ScrollViewProvider(); - - void AssociateStyleController(controls::GuiControl::IStyleController* controller)override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - - controls::GuiScroll::IStyleController* CreateHorizontalScrollStyle()override; - controls::GuiScroll::IStyleController* CreateVerticalScrollStyle()override; - vint GetDefaultScrollSize()override; - compositions::GuiGraphicsComposition* InstallBackground(compositions::GuiBoundsComposition* boundsComposition)override; - }; - -/*********************************************************************** -TextBox -***********************************************************************/ - - class Win8TextBoxBackground : public Object, public Description - { - protected: - DEFINE_TRANSFERRING_ANIMATION(Win8TextBoxColors, Win8TextBoxBackground) - - elements::GuiSolidBorderElement* borderElement; - elements::GuiSolidBackgroundElement* backgroundElement; - compositions::GuiGraphicsComposition* focusableComposition; - bool isMouseEnter; - bool isFocused; - bool isVisuallyEnabled; - Ptr transferringAnimation; - controls::GuiControl::IStyleController* styleController; - elements::GuiColorizedTextElement* textElement; - - void UpdateStyle(); - void Apply(const Win8TextBoxColors& colors); - - void OnBoundsMouseEnter(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnBoundsMouseLeave(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnBoundsGotFocus(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnBoundsLostFocus(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - public: - Win8TextBoxBackground(); - ~Win8TextBoxBackground(); - - void AssociateStyleController(controls::GuiControl::IStyleController* controller); - void SetFocusableComposition(compositions::GuiGraphicsComposition* value); - void SetVisuallyEnabled(bool value); - compositions::GuiGraphicsComposition* InstallBackground(compositions::GuiBoundsComposition* boundsComposition); - void InitializeTextElement(elements::GuiColorizedTextElement* _textElement); - }; - - /// Multiline text box style (Windows 8). - class Win8MultilineTextBoxProvider : public Win8ScrollViewProvider, public Description - { - protected: - Win8TextBoxBackground background; - controls::GuiControl::IStyleController* styleController; - public: - /// Create the style. - Win8MultilineTextBoxProvider(); - ~Win8MultilineTextBoxProvider(); - - void AssociateStyleController(controls::GuiControl::IStyleController* controller)override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetVisuallyEnabled(bool value)override; - compositions::GuiGraphicsComposition* InstallBackground(compositions::GuiBoundsComposition* boundsComposition)override; - }; - - /// Singleline text box style (Windows 8). - class Win8SinglelineTextBoxProvider : public Object, public virtual controls::GuiSinglelineTextBox::IStyleProvider, public Description - { - protected: - Win8TextBoxBackground background; - controls::GuiControl::IStyleController* styleController; - public: - /// Create the style. - Win8SinglelineTextBoxProvider(); - ~Win8SinglelineTextBoxProvider(); - - void AssociateStyleController(controls::GuiControl::IStyleController* controller)override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - compositions::GuiGraphicsComposition* InstallBackground(compositions::GuiBoundsComposition* boundsComposition)override; - }; - -#pragma warning(push) -#pragma warning(disable:4250) - /// Document viewer style (Windows 8). - class Win8DocumentViewerStyle : public Win8MultilineTextBoxProvider, public virtual controls::GuiDocumentViewer::IStyleProvider, public Description - { - public: - /// Create the style. - Win8DocumentViewerStyle(); - ~Win8DocumentViewerStyle(); - - Ptr GetBaselineDocument()override; - Color GetCaretColor()override; - }; - - /// Document label style (Windows 8). - class Win8DocumentLabelStyle : public controls::GuiControl::EmptyStyleController, public virtual controls::GuiDocumentLabel::IStyleController, public Description - { - public: - /// Create the style. - Win8DocumentLabelStyle(); - ~Win8DocumentLabelStyle(); - - Ptr GetBaselineDocument()override; - Color GetCaretColor()override; - }; - - /// Document label style (Windows 8). - class Win8DocumentTextBoxStyle : public virtual controls::GuiDocumentLabel::IStyleController, public Description - { - protected: - Win8TextBoxBackground background; - compositions::GuiBoundsComposition* boundsComposition; - compositions::GuiGraphicsComposition* containerComposition; - - public: - /// Create the style. - Win8DocumentTextBoxStyle(); - ~Win8DocumentTextBoxStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - Ptr GetBaselineDocument()override; - Color GetCaretColor()override; - }; -#pragma warning(pop) - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\STYLES\WIN8STYLES\GUIWIN8CONTROLSTYLES.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control Styles::Windows8 Styles - -Clases: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_WIN8STYLES_GUIWin8CONTROLSTYLES -#define VCZH_PRESENTATION_CONTROLS_WIN8STYLES_GUIWin8CONTROLSTYLES - - -namespace vl -{ - namespace presentation - { - namespace win8 - { - -/*********************************************************************** -Container -***********************************************************************/ - - /// Empty style. Nothing but a color filled the whole control. - class Win8EmptyStyle : public Object, public virtual controls::GuiControl::IStyleController, public Description - { - protected: - compositions::GuiBoundsComposition* boundsComposition; - public: - /// Create the style with a specified color. - /// The specified color. - Win8EmptyStyle(Color color); - ~Win8EmptyStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - }; - - /// Window style (Windows 8). Using the Windows 8 window background color to fill the whold control - class Win8WindowStyle : public virtual controls::GuiWindow::DefaultBehaviorStyleController, public Description - { - protected: - compositions::GuiBoundsComposition* boundsComposition; - public: - /// Create the style. - Win8WindowStyle(); - ~Win8WindowStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - }; - - /// Tooltip style (Windows 8). Using the Windows 8 tooltip background color to fill the whole control. - class Win8TooltipStyle : public virtual controls::GuiWindow::DefaultBehaviorStyleController, public Description - { - protected: - compositions::GuiBoundsComposition* boundsComposition; - compositions::GuiBoundsComposition* containerComposition; - public: - /// Create the style. - Win8TooltipStyle(); - ~Win8TooltipStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - }; - - /// Label style (Windows 8). A label contains a text, and the label will automatically resize to fit the text. - class Win8LabelStyle : public Object, public virtual controls::GuiLabel::IStyleController, public Description - { - protected: - compositions::GuiBoundsComposition* boundsComposition; - elements::GuiSolidLabelElement* textElement; - public: - /// Create the style. - /// Set to true to create a style for displaying shortcut key. - Win8LabelStyle(bool forShortcutKey); - ~Win8LabelStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - Color GetDefaultTextColor()override; - void SetTextColor(Color value)override; - }; - - /// Group box style (Windows 8). - class Win8GroupBoxStyle : public Object, public virtual controls::GuiControl::IStyleController, public Description - { - protected: - DEFINE_TRANSFERRING_ANIMATION(Color, Win8GroupBoxStyle) - - compositions::GuiBoundsComposition* boundsComposition; - compositions::GuiBoundsComposition* borderComposition; - compositions::GuiBoundsComposition* textComposition; - compositions::GuiBoundsComposition* textBackgroundComposition; - compositions::GuiBoundsComposition* containerComposition; - elements::GuiSolidLabelElement* textElement; - Ptr transferringAnimation; - - void SetMargins(vint fontSize); - public: - /// Create the style. - Win8GroupBoxStyle(); - ~Win8GroupBoxStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - }; - - /// Date Picker (Windows 8) - class Win8DatePickerStyle : public Object, public virtual controls::GuiDatePicker::IStyleProvider, public Description - { - public: - /// Create the style. - Win8DatePickerStyle(); - ~Win8DatePickerStyle(); - - void AssociateStyleController(controls::GuiControl::IStyleController* controller)override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - - controls::GuiSelectableButton::IStyleController* CreateDateButtonStyle()override; - controls::GuiTextList* CreateTextList()override; - controls::GuiComboBoxListControl::IStyleController* CreateComboBoxStyle()override; - - Color GetBackgroundColor()override; - Color GetPrimaryTextColor()override; - Color GetSecondaryTextColor()override; - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\STYLES\WIN8STYLES\GUIWIN8MENUSTYLES.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control Styles::Windows8 Styles - -Clases: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_WIN8STYLES_GUIWIN8MENUSTYLES -#define VCZH_PRESENTATION_CONTROLS_WIN8STYLES_GUIWIN8MENUSTYLES - - -namespace vl -{ - namespace presentation - { - namespace win8 - { - -/*********************************************************************** -Menu Container -***********************************************************************/ - - /// Menu style (Windows 8). For the background of a popup menu. - class Win8MenuStyle : public Object, public virtual controls::GuiWindow::DefaultBehaviorStyleController, public Description - { - protected: - compositions::GuiBoundsComposition* boundsComposition; - compositions::GuiBoundsComposition* containerComposition; - public: - /// Create the style. - Win8MenuStyle(); - ~Win8MenuStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - }; - - /// Menu bar style (Windows 8). For the background of a menu bar. - class Win8MenuBarStyle : public Object, public virtual controls::GuiControl::IStyleController, public Description - { - protected: - compositions::GuiBoundsComposition* boundsComposition; - compositions::GuiBoundsComposition* containerComposition; - public: - /// Create the style. - Win8MenuBarStyle(); - ~Win8MenuBarStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - }; - -/*********************************************************************** -Menu Button -***********************************************************************/ - - /// Menu bar button style (Windows 8). For menu buttons in a menu bar. - class Win8MenuBarButtonStyle : public Object, public virtual controls::GuiMenuButton::IStyleController, public Description - { - protected: - Win8ButtonElements elements; - controls::ButtonState controlStyle; - bool isVisuallyEnabled; - bool isOpening; - - void TransferInternal(controls::ButtonState value, bool enabled, bool opening); - public: - /// Create the style. - Win8MenuBarButtonStyle(); - ~Win8MenuBarButtonStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - void SetSelected(bool value)override; - controls::GuiMenu::IStyleController* CreateSubMenuStyleController()override; - void SetSubMenuExisting(bool value)override; - void SetSubMenuOpening(bool value)override; - controls::GuiButton* GetSubMenuHost()override; - void SetImage(Ptr value)override; - void SetShortcutText(const WString& value)override; - void Transfer(controls::ButtonState value)override; - }; - - /// Menu item button style (Windows 8). For menu buttons in a popup menu. - class Win8MenuItemButtonStyle : public Object, public virtual controls::GuiMenuButton::IStyleController, public Description - { - protected: - Win8MenuItemButtonElements elements; - controls::ButtonState controlStyle; - bool isVisuallyEnabled; - bool isSelected; - bool isOpening; - - void TransferInternal(controls::ButtonState value, bool enabled, bool selected, bool opening); - public: - /// Create the style. - Win8MenuItemButtonStyle(); - ~Win8MenuItemButtonStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - void SetSelected(bool value)override; - controls::GuiMenu::IStyleController* CreateSubMenuStyleController()override; - void SetSubMenuExisting(bool value)override; - void SetSubMenuOpening(bool value)override; - controls::GuiButton* GetSubMenuHost()override; - void SetImage(Ptr value)override; - void SetShortcutText(const WString& value)override; - void Transfer(controls::ButtonState value)override; - }; - - /// Menu splitter style (Windows 8). For splitters in a popup menu. - class Win8MenuSplitterStyle : public Object, public virtual controls::GuiControl::IStyleController, public Description - { - protected: - compositions::GuiBoundsComposition* boundsComposition; - public: - /// Create the style. - Win8MenuSplitterStyle(); - ~Win8MenuSplitterStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\STYLES\WIN7STYLES\GUIWIN7TABSTYLES.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control Styles::Windows7 Styles - -Clases: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_WIN7STYLES_GUIWIN7TABSTYLES -#define VCZH_PRESENTATION_CONTROLS_WIN7STYLES_GUIWIN7TABSTYLES - - -namespace vl -{ - namespace presentation - { - namespace win7 - { - -/*********************************************************************** -Tab -***********************************************************************/ - - /// Tab page header style (Windows 7). - class Win7TabPageHeaderStyle : public Win7ButtonStyleBase, public Description - { - protected: - void TransferInternal(controls::ButtonState value, bool enabled, bool selected)override; - public: - /// Create the style. - Win7TabPageHeaderStyle(); - ~Win7TabPageHeaderStyle(); - - void SetFont(const FontProperties& value)override; - }; - - /// Tab control style (Windows 7). - class Win7TabStyle : public Object, public virtual controls::GuiTab::IStyleController, public Description - { - protected: - compositions::GuiTableComposition* boundsComposition; - compositions::GuiBoundsComposition* containerComposition; - compositions::GuiStackComposition* tabHeaderComposition; - compositions::GuiBoundsComposition* tabContentTopLineComposition; - FontProperties headerFont; - controls::ITabCommandExecutor* commandExecutor; - - Ptr headerController; - collections::List headerButtons; - elements::GuiPolygonElement* headerOverflowArrowElement; - controls::GuiButton* headerOverflowButton; - controls::GuiToolstripMenu* headerOverflowMenu; - - void OnHeaderButtonClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnTabHeaderBoundsChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnHeaderOverflowButtonClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - void OnHeaderOverflowMenuButtonClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); - - void UpdateHeaderOverflowButtonVisibility(); - void UpdateHeaderZOrder(); - void UpdateHeaderVisibilityIndex(); - void UpdateHeaderLayout(); - - void Initialize(); - protected: - - virtual controls::GuiSelectableButton::IStyleController* CreateHeaderStyleController(); - virtual controls::GuiButton::IStyleController* CreateMenuButtonStyleController(); - virtual controls::GuiToolstripMenu::IStyleController* CreateMenuStyleController(); - virtual controls::GuiToolstripButton::IStyleController* CreateMenuItemStyleController(); - virtual Color GetBorderColor(); - virtual Color GetBackgroundColor(); - public: - /// Create the style. - /// Set to true to initialize the style. Otherwise the function should be called after creating the style. - Win7TabStyle(bool initialize=true); - ~Win7TabStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - - void SetCommandExecutor(controls::ITabCommandExecutor* value)override; - void InsertTab(vint index)override; - void SetTabText(vint index, const WString& value)override; - void RemoveTab(vint index)override; - void SetSelectedTab(vint index)override; - void SetTabAlt(vint index, const WString& value)override; - compositions::IGuiAltAction* GetTabAltAction(vint index)override; - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\TEXTEDITORPACKAGE\LANGUAGESERVICE\GUILANGUAGEOPERATIONS.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control System - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_GUILANGUAGEOPERATIONS -#define VCZH_PRESENTATION_CONTROLS_GUILANGUAGEOPERATIONS - - -namespace vl -{ - namespace presentation - { - namespace controls - { - -/*********************************************************************** -ParsingInput -***********************************************************************/ - - class RepeatingParsingExecutor; - - /// A data structure storing the parsing input for text box control. - struct RepeatingParsingInput - { - /// The text box edit version of the code. - vuint editVersion = 0; - /// The code. - WString code; - }; - -/*********************************************************************** -ParsingOutput -***********************************************************************/ - - /// A data structure storing the parsing result for text box control. - struct RepeatingParsingOutput - { - /// The parsed syntax tree. - Ptr node; - /// The text box edit version of the code. - vuint editVersion = 0; - /// The code. - WString code; - /// The cache created from [T:vl.presentation.controls.RepeatingParsingExecutor.IParsingAnalyzer]. - Ptr cache; - }; - -/*********************************************************************** -PartialParsingOutput -***********************************************************************/ - - /// A data structure storing the parsing result for partial updating when a text box control is modified. - struct RepeatingPartialParsingOutput - { - /// The input data. - RepeatingParsingOutput input; - /// The rule name that can parse the code of the selected context. - WString rule; - /// Range of the original context in the input. - parsing::ParsingTextRange originalRange; - /// The original context in the syntax tree. - Ptr originalNode; - /// The modified context in the syntax tree. - Ptr modifiedNode; - /// The modified code of the selected context. - WString modifiedCode; - }; - -/*********************************************************************** -PartialParsingOutput -***********************************************************************/ - - /// A data structure storing the information for a candidate item. - struct ParsingCandidateItem - { - /// Semantic id. - vint semanticId = -1; - /// Display name. - WString name; - /// Tag object for any purpose, e.g., data binding. - description::Value tag; - }; - -/*********************************************************************** -ParsingContext -***********************************************************************/ - - /// A data structure storing the context of a token. - struct ParsingTokenContext - { - /// Token syntax tree for the selected token. - parsing::ParsingTreeToken* foundToken = nullptr; - /// The object syntax tree parent of the token. - parsing::ParsingTreeObject* tokenParent = nullptr; - /// Type of the parent. - WString type; - /// Field of the parent that contains the token. - WString field; - /// All acceptable semantic ids. - Ptr> acceptableSemanticIds; - - static bool RetriveContext(ParsingTokenContext& output, parsing::ParsingTreeNode* foundNode, RepeatingParsingExecutor* executor); - static bool RetriveContext(ParsingTokenContext& output, parsing::ParsingTextPos pos, parsing::ParsingTreeObject* rootNode, RepeatingParsingExecutor* executor); - static bool RetriveContext(ParsingTokenContext& output, parsing::ParsingTextRange range, parsing::ParsingTreeObject* rootNode, RepeatingParsingExecutor* executor); - }; - -/*********************************************************************** -RepeatingParsingExecutor -***********************************************************************/ - - /// Repeating parsing executor. - class RepeatingParsingExecutor : public RepeatingTaskExecutor, public Description - { - public: - /// Callback. - class ICallback : public virtual Interface - { - public: - /// Callback when a parsing task is finished. - /// the result of the parsing. - virtual void OnParsingFinishedAsync(const RepeatingParsingOutput& output)=0; - /// Callback when requires enabling or disabling automatically repeating calling to the SubmitTask function. - /// Set to true to require an automatically repeating calling to the SubmitTask function - virtual void RequireAutoSubmitTask(bool enabled)=0; - }; - - /// Parsing analyzer. - class IParsingAnalyzer : public virtual Interface - { - private: - parsing::ParsingTreeNode* ToParent(parsing::ParsingTreeNode* node, const RepeatingPartialParsingOutput* output); - parsing::ParsingTreeObject* ToChild(parsing::ParsingTreeObject* node, const RepeatingPartialParsingOutput* output); - Ptr ToChild(Ptr node, const RepeatingPartialParsingOutput* output); - - protected: - /// Get a syntax tree node's parent when the whole tree is in a partial modified state. You should use this function instead of ParsingTreeNode::GetParent when implementing this interface. - /// Returns the parent node. - /// The node. - /// The partial parsing output, which describes how the whole tree is partial modified. - parsing::ParsingTreeNode* GetParent(parsing::ParsingTreeNode* node, const RepeatingPartialParsingOutput* output); - /// Get a syntax tree node's member when the whole tree is in a partial modified state. You should use this function instead of ParsingTreeObject::GetMember when implementing this interface. - /// Returns the member node. - /// The node. - /// The name of the member. - /// The partial parsing output, which describes how the whole tree is partial modified. - Ptr GetMember(parsing::ParsingTreeObject* node, const WString& name, const RepeatingPartialParsingOutput* output); - /// Get a syntax tree node's item when the whole tree is in a partial modified state. You should use this function instead of ParsingTreeArray::GetItem when implementing this interface. - /// Returns the item node. - /// The node. - /// The index of the item. - /// The partial parsing output, which describes how the whole tree is partial modified. - Ptr GetItem(parsing::ParsingTreeArray* node, vint index, const RepeatingPartialParsingOutput* output); - - public: - /// Called when a is created. - /// The releated . - virtual void Attach(RepeatingParsingExecutor* executor) = 0; - - /// Called when a is destroyed. - /// The releated . - virtual void Detach(RepeatingParsingExecutor* executor) = 0; - - /// Called when a new parsing result is produced. A parsing analyzer can create a cache to be attached to the output containing anything necessary. This function does not run in UI thread. - /// The new parsing result. - /// The created cache object, which can be null. - virtual Ptr CreateCacheAsync(const RepeatingParsingOutput& output) = 0; - - /// Called when an semantic id for a token is needed. If an semantic id is returned, a context sensitive color can be assigned to this token. This functio does not run in UI thread, but it will only be called (for several times) after the cache object is initialized. - /// The token context. - /// The current parsing result. - /// The semantic id. - virtual vint GetSemanticIdForTokenAsync(const ParsingTokenContext& tokenContext, const RepeatingParsingOutput& output) = 0; - - /// Called when multiple auto complete candidate items for a token is needed. If nothing is written into the "candidateItems" parameter and the grammar also doesn't provide static candidate items, nothing will popup. This functio does not run in UI thread, but it will only be called (for several times) after the cache object is initialized. - /// The token context. - /// The partial parsing result. It contains the current parsing result, and an incremental parsing result. If the calculation of candidate items are is very context sensitive, then you should be very careful when traversing the syntax tree, by carefully looking at the "originalNode" and the "modifiedNode" in the "partialOutput" parameter. - /// The candidate items. - virtual void GetCandidateItemsAsync(const ParsingTokenContext& tokenContext, const RepeatingPartialParsingOutput& partialOutput, collections::List& candidateItems) = 0; - - /// Create a tag object for a candidate item without a tag object. An candidate item without a tag maybe created by calling or any token marked by a @Candidate attribute in the grammar. - /// The candidate item. - /// The tag object. In most of the case this object is used for data binding or any other purpose when you want to customize the auto complete control. Returns null if the specified [T.vl.presentation.controls.GuiTextBoxAutoCompleteBase.IAutoCompleteControlProvider] can handle null tag correctly. - virtual description::Value CreateTagForCandidateItem(ParsingCandidateItem& item) = 0; - }; - - /// A base class for implementing a callback. - class CallbackBase : public virtual ICallback, public virtual ICommonTextEditCallback - { - private: - bool callbackAutoPushing; - elements::GuiColorizedTextElement* callbackElement; - SpinLock* callbackElementModifyLock; - - protected: - Ptr parsingExecutor; - - public: - CallbackBase(Ptr _parsingExecutor); - ~CallbackBase(); - - void RequireAutoSubmitTask(bool enabled)override; - void Attach(elements::GuiColorizedTextElement* _element, SpinLock& _elementModifyLock, compositions::GuiGraphicsComposition* _ownerComposition, vuint editVersion)override; - void Detach()override; - void TextEditPreview(TextEditPreviewStruct& arguments)override; - void TextEditNotify(const TextEditNotifyStruct& arguments)override; - void TextCaretChanged(const TextCaretChangedStruct& arguments)override; - void TextEditFinished(vuint editVersion)override; - }; - - struct TokenMetaData - { - vint tableTokenIndex; - vint lexerTokenIndex; - vint defaultColorIndex; - bool hasContextColor; - bool hasAutoComplete; - bool isCandidate; - WString unescapedRegexText; - }; - - struct FieldMetaData - { - vint colorIndex; - Ptr> semantics; - }; - private: - Ptr grammarParser; - WString grammarRule; - Ptr analyzer; - collections::List callbacks; - collections::List activatedCallbacks; - ICallback* autoPushingCallback; - - typedef collections::Pair FieldDesc; - collections::Dictionary tokenIndexMap; - collections::SortedList semanticIndexMap; - collections::Dictionary tokenMetaDatas; - collections::Dictionary fieldMetaDatas; - - protected: - - void Execute(const RepeatingParsingInput& input)override; - void PrepareMetaData(); - - /// Called when semantic analyzing is needed. It is encouraged to set the "cache" fields in "context" argument. If there is an binded to the , this function can be automatically done. - /// The parsing result. - virtual void OnContextFinishedAsync(RepeatingParsingOutput& context); - public: - /// Initialize the parsing executor. - /// Parser generated from a grammar. - /// The rule name to parse a complete code. - /// The parsing analyzer to create semantic metadatas, it can be null. - RepeatingParsingExecutor(Ptr _grammarParser, const WString& _grammarRule, Ptr _analyzer = 0); - ~RepeatingParsingExecutor(); - - /// Get the internal parser that parse the text. - /// The internal parser. - Ptr GetParser(); - /// Detach callback. - /// Returns true if this operation succeeded. - /// The callback. - bool AttachCallback(ICallback* value); - /// Detach callback. - /// Returns true if this operation succeeded. - /// The callback. - bool DetachCallback(ICallback* value); - /// Activate a callback. Activating a callback means that the callback owner has an ability to watch a text box modification, e.g., an attached that is also an . The may require one of the activated callback to push code for parsing automatically via a call to . - /// Returns true if this operation succeeded. - /// The callback. - bool ActivateCallback(ICallback* value); - /// Deactivate a callback. See for deatils. - /// Returns true if this operation succeeded. - /// The callback. - bool DeactivateCallback(ICallback* value); - /// Get the parsing analyzer. - /// The parsing analyzer. - Ptr GetAnalyzer(); - - vint GetTokenIndex(const WString& tokenName); - vint GetSemanticId(const WString& name); - WString GetSemanticName(vint id); - const TokenMetaData& GetTokenMetaData(vint regexTokenIndex); - const FieldMetaData& GetFieldMetaData(const WString& type, const WString& field); - - Ptr GetAttribute(vint index, const WString& name, vint argumentCount); - Ptr GetColorAttribute(vint index); - Ptr GetContextColorAttribute(vint index); - Ptr GetSemanticAttribute(vint index); - Ptr GetCandidateAttribute(vint index); - Ptr GetAutoCompleteAttribute(vint index); - - /* - @Color(ColorName) - field: color of the token field when the token type is marked with @ContextColor - token: color of the token - @ContextColor() - token: the color of the token may be changed if the token field is marked with @Color or @Semantic - @Semantic(Type1, Type2, ...) - field: After resolved symbols for this field, only types of symbols that specified in the arguments are acceptable. - @Candidate() - token: when the token can be available after the editing caret, than it will be in the auto complete list. - @AutoComplete() - token: when the token is editing, an auto complete list will appear if possible - */ - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\STYLES\WIN7STYLES\GUIWIN7TOOLSTRIPSTYLES.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control Styles::Windows7 Styles - -Clases: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_WIN7STYLES_GUIWIN7TOOLSTRIPSTYLES -#define VCZH_PRESENTATION_CONTROLS_WIN7STYLES_GUIWIN7TOOLSTRIPSTYLES - - -namespace vl -{ - namespace presentation - { - namespace win7 - { - -/*********************************************************************** -Toolstrip Button -***********************************************************************/ - - /// Toolstrip toolbar style (Windows 7). Using the Windows 7 window background color to fill the whold control - class Win7ToolstripToolBarStyle : public Win7EmptyStyle, public Description - { - public: - /// Create the style. - Win7ToolstripToolBarStyle(); - ~Win7ToolstripToolBarStyle(); - }; - - /// Toolstrip split button dropdown style (Windows 7). - class Win7ToolstripButtonDropdownStyle : public Object, public virtual controls::GuiButton::IStyleController, public Description - { - protected: - compositions::GuiBoundsComposition* boundsComposition; - compositions::GuiBoundsComposition* splitterComposition; - compositions::GuiBoundsComposition* containerComposition; - bool isVisuallyEnabled; - controls::ButtonState controlState; - - virtual void TransferInternal(controls::ButtonState value, bool enabled); - public: - /// Create the style. - Win7ToolstripButtonDropdownStyle(); - ~Win7ToolstripButtonDropdownStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - void Transfer(controls::ButtonState value)override; - }; - - /// Toolstrip button style (Windows 7). - class Win7ToolstripButtonStyle : public Object, public virtual controls::GuiMenuButton::IStyleController, public Description - { - public: - /// Sub menu dropdown arrow style. - enum ButtonStyle - { - /// No dropdown. - CommandButton, - /// The whole button is a dropdown. - DropdownButton, - /// The button and the dropdown is splitted. - SplitButton, - }; - protected: - DEFINE_TRANSFERRING_ANIMATION(Win7ButtonColors, Win7ToolstripButtonStyle) - - Win7ButtonElements elements; - Ptr transferringAnimation; - controls::ButtonState controlStyle; - bool isVisuallyEnabled; - bool isSelected; - bool isOpening; - elements::GuiImageFrameElement* imageElement; - compositions::GuiBoundsComposition* imageComposition; - ButtonStyle buttonStyle; - controls::GuiButton* subMenuHost; - - virtual void TransferInternal(controls::ButtonState value, bool enabled, bool selected, bool menuOpening); - public: - /// Create the style. - /// Defines the sub menu dropdown arrow style. - Win7ToolstripButtonStyle(ButtonStyle _buttonStyle); - ~Win7ToolstripButtonStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - void SetSelected(bool value)override; - controls::GuiMenu::IStyleController* CreateSubMenuStyleController()override; - void SetSubMenuExisting(bool value)override; - void SetSubMenuOpening(bool value)override; - controls::GuiButton* GetSubMenuHost()override; - void SetImage(Ptr value)override; - void SetShortcutText(const WString& value)override; - void Transfer(controls::ButtonState value)override; - }; - - /// Toolstrip splitter style (Windows 7). - class Win7ToolstripSplitterStyle : public Object, public virtual controls::GuiControl::IStyleController, public Description - { - protected: - compositions::GuiBoundsComposition* boundsComposition; - public: - /// Create the style. - Win7ToolstripSplitterStyle(); - ~Win7ToolstripSplitterStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\STYLES\WIN7STYLES\GUIWIN7LISTSTYLES.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control Styles::Windows7 Styles - -Clases: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_WIN7STYLES_GUIWIN7LISTSTYLES -#define VCZH_PRESENTATION_CONTROLS_WIN7STYLES_GUIWIN7LISTSTYLES - - -namespace vl -{ - namespace presentation - { - namespace win7 - { - -/*********************************************************************** -List Control Buttons -***********************************************************************/ - - /// Selectable item style (Windows 7). Generally for list box item background. - class Win7SelectableItemStyle : public Win7ButtonStyleBase, public Description - { - protected: - void TransferInternal(controls::ButtonState value, bool enabled, bool selected)override; - public: - /// Create the style. - Win7SelectableItemStyle(); - ~Win7SelectableItemStyle(); - }; - - /// List view column drop down button style (Windows 7). - class Win7ListViewColumnDropDownStyle : public Object, public virtual controls::GuiSelectableButton::IStyleController, public Description - { - protected: - controls::ButtonState controlStyle; - bool isVisuallyEnabled; - bool isSelected; - - compositions::GuiBoundsComposition* mainComposition; - compositions::GuiBoundsComposition* leftBorderComposition; - compositions::GuiBoundsComposition* borderComposition; - compositions::GuiBoundsComposition* gradientComposition; - compositions::GuiBoundsComposition* arrowComposition; - - elements::GuiGradientBackgroundElement* leftBorderElement; - elements::GuiSolidBorderElement* borderElement; - elements::GuiGradientBackgroundElement* gradientElement; - elements::GuiPolygonElement* arrowElement; - - void TransferInternal(controls::ButtonState value, bool enabled, bool selected); - public: - /// Create the style. - Win7ListViewColumnDropDownStyle(); - ~Win7ListViewColumnDropDownStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - void SetSelected(bool value)override; - void Transfer(controls::ButtonState value)override; - }; - - /// List view column header style (Windows 7). - class Win7ListViewColumnHeaderStyle : public Object, public virtual controls::GuiListViewColumnHeader::IStyleController, public Description - { - protected: - controls::ButtonState controlStyle; - bool isVisuallyEnabled; - bool isSubMenuExisting; - bool isSubMenuOpening; - - compositions::GuiBoundsComposition* mainComposition; - compositions::GuiBoundsComposition* rightBorderComposition; - compositions::GuiBoundsComposition* borderComposition; - compositions::GuiBoundsComposition* gradientComposition; - compositions::GuiBoundsComposition* textComposition; - compositions::GuiBoundsComposition* arrowComposition; - - elements::GuiSolidBackgroundElement* backgroundElement; - elements::GuiGradientBackgroundElement* rightBorderElement; - elements::GuiSolidBorderElement* borderElement; - elements::GuiGradientBackgroundElement* gradientElement; - elements::GuiSolidLabelElement* textElement; - elements::GuiPolygonElement* arrowElement; - - controls::GuiButton* dropdownButton; - - void TransferInternal(controls::ButtonState value, bool enabled, bool subMenuExisting, bool subMenuOpening); - public: - /// Create the style. - Win7ListViewColumnHeaderStyle(); - ~Win7ListViewColumnHeaderStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - void SetSelected(bool value)override; - void Transfer(controls::ButtonState value)override; - controls::GuiMenu::IStyleController* CreateSubMenuStyleController()override; - void SetSubMenuExisting(bool value)override; - void SetSubMenuOpening(bool value)override; - controls::GuiButton* GetSubMenuHost()override; - void SetImage(Ptr value)override; - void SetShortcutText(const WString& value)override; - void SetColumnSortingState(controls::ColumnSortingState value)override; - }; - - /// Tree view expanding button style (Windows 7). Show the triangle to indicate the expanding state of a tree view item. - class Win7TreeViewExpandingButtonStyle : public Object, public virtual controls::GuiSelectableButton::IStyleController, public Description - { - protected: - controls::ButtonState controlStyle; - bool isVisuallyEnabled; - bool isSelected; - - compositions::GuiBoundsComposition* mainComposition; - elements::GuiPolygonElement* polygonElement; - - void TransferInternal(controls::ButtonState value, bool enabled, bool selected); - public: - /// Create the style. - Win7TreeViewExpandingButtonStyle(); - ~Win7TreeViewExpandingButtonStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - void SetSelected(bool value)override; - void Transfer(controls::ButtonState value)override; - }; - -/*********************************************************************** -ComboBox -***********************************************************************/ - -#pragma warning(push) -#pragma warning(disable:4250) - /// Drop down combo box style (Windows 7). - class Win7DropDownComboBoxStyle : public Win7ButtonStyle, public virtual controls::GuiComboBoxListControl::IStyleController, public Description - { - protected: - controls::IComboBoxCommandExecutor* commandExecutor; - compositions::GuiTableComposition* table; - compositions::GuiCellComposition* textComposition; - compositions::GuiCellComposition* dropDownComposition; - elements::GuiPolygonElement* dropDownElement; - WString text; - bool textVisible; - - void TransferInternal(controls::ButtonState value, bool enabled, bool selected)override; - void AfterApplyColors(const Win7ButtonColors& colors)override; - public: - /// Create the style. - Win7DropDownComboBoxStyle(); - ~Win7DropDownComboBoxStyle(); - - compositions::GuiGraphicsComposition* GetContainerComposition()override; - - controls::GuiMenu::IStyleController* CreateSubMenuStyleController()override; - void SetSubMenuExisting(bool value)override; - void SetSubMenuOpening(bool value)override; - controls::GuiButton* GetSubMenuHost()override; - void SetImage(Ptr value)override; - void SetShortcutText(const WString& value)override; - void SetCommandExecutor(controls::IComboBoxCommandExecutor* value)override; - void OnItemSelected()override; - void SetText(const WString& value)override; - void SetTextVisible(bool value)override; - }; -#pragma warning(pop) - -/*********************************************************************** -List -***********************************************************************/ - -#pragma warning(push) -#pragma warning(disable:4250) - - /// Multiline text box style (Windows 7). - class Win7TextListProvider : public Win7MultilineTextBoxProvider, public virtual controls::GuiVirtualTextList::IStyleProvider, public Description - { - public: - /// Create the style. - Win7TextListProvider(); - ~Win7TextListProvider(); - - virtual Color GetTextColor()override; - controls::GuiSelectableButton::IStyleController* CreateItemBackground()override; - controls::GuiSelectableButton::IStyleController* CreateCheckBulletStyle()override; - controls::GuiSelectableButton::IStyleController* CreateRadioBulletStyle()override; - }; - - /// List view style (Windows 7). - class Win7ListViewProvider : public Win7MultilineTextBoxProvider, public virtual controls::GuiListView::IStyleProvider, public Description - { - public: - /// Create the style. - Win7ListViewProvider(); - ~Win7ListViewProvider(); - - controls::GuiSelectableButton::IStyleController* CreateItemBackground()override; - controls::GuiListViewColumnHeader::IStyleController* CreateColumnStyle()override; - Color GetPrimaryTextColor()override; - Color GetSecondaryTextColor()override; - Color GetItemSeparatorColor()override; - }; - - /// Tree view style (Windows 7). - class Win7TreeViewProvider : public Win7MultilineTextBoxProvider, public virtual controls::GuiTreeView::IStyleProvider, public Description - { - public: - /// Create the style. - Win7TreeViewProvider(); - ~Win7TreeViewProvider(); - - controls::GuiSelectableButton::IStyleController* CreateItemBackground()override; - controls::GuiSelectableButton::IStyleController* CreateItemExpandingDecorator()override; - Color GetTextColor()override; - }; -#pragma warning(pop) - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\STYLES\WIN8STYLES\GUIWIN8TABSTYLES.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control Styles::Windows8 Styles - -Clases: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_WIN8STYLES_GUIWIN8TABSTYLES -#define VCZH_PRESENTATION_CONTROLS_WIN8STYLES_GUIWIN8TABSTYLES - - -namespace vl -{ - namespace presentation - { - namespace win8 - { - -/*********************************************************************** -Tab -***********************************************************************/ - - /// Tab page header style (Windows 8). - class Win8TabPageHeaderStyle : public Win8ButtonStyleBase, public Description - { - protected: - void TransferInternal(controls::ButtonState value, bool enabled, bool selected)override; - public: - /// Create the style. - Win8TabPageHeaderStyle(); - ~Win8TabPageHeaderStyle(); - - void SetFont(const FontProperties& value)override; - }; - - /// Tab control style (Windows 8). - class Win8TabStyle : public win7::Win7TabStyle, public Description - { - protected: - - controls::GuiSelectableButton::IStyleController* CreateHeaderStyleController()override; - controls::GuiButton::IStyleController* CreateMenuButtonStyleController()override; - controls::GuiToolstripMenu::IStyleController* CreateMenuStyleController()override; - controls::GuiToolstripButton::IStyleController* CreateMenuItemStyleController()override; - Color GetBorderColor()override; - Color GetBackgroundColor()override; - public: - /// Create the style. - Win8TabStyle(); - ~Win8TabStyle(); - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\STYLES\WIN8STYLES\GUIWIN8TOOLSTRIPSTYLES.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control Styles::Windows8 Styles - -Clases: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_WIN8STYLES_GUIWIN8TOOLSTRIPSTYLES -#define VCZH_PRESENTATION_CONTROLS_WIN8STYLES_GUIWIN8TOOLSTRIPSTYLES - - -namespace vl -{ - namespace presentation - { - namespace win8 - { - -/*********************************************************************** -Toolstrip Button -***********************************************************************/ - - /// Toolstrip toolbar style (Windows 8). Using the Windows 8 window background color to fill the whold control - class Win8ToolstripToolBarStyle : public Object, public virtual controls::GuiControl::IStyleController, public Description - { - protected: - compositions::GuiBoundsComposition* boundsComposition; - compositions::GuiBoundsComposition* containerComposition; - public: - /// Create the style. - Win8ToolstripToolBarStyle(); - ~Win8ToolstripToolBarStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - }; - - /// Toolstrip split button dropdown style (Windows 8). - class Win8ToolstripButtonDropdownStyle : public Object, public virtual controls::GuiButton::IStyleController, public Description - { - protected: - compositions::GuiBoundsComposition* boundsComposition; - compositions::GuiBoundsComposition* splitterComposition; - compositions::GuiBoundsComposition* containerComposition; - bool isVisuallyEnabled; - controls::ButtonState controlState; - - virtual void TransferInternal(controls::ButtonState value, bool enabled); - public: - /// Create the style. - Win8ToolstripButtonDropdownStyle(); - ~Win8ToolstripButtonDropdownStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - void Transfer(controls::ButtonState value)override; - }; - - /// Toolstrip button style (Windows 8). - class Win8ToolstripButtonStyle : public Object, public virtual controls::GuiMenuButton::IStyleController, public Description - { - public: - /// Sub menu dropdown arrow style. - enum ButtonStyle - { - /// No dropdown. - CommandButton, - /// The whole button is a dropdown. - DropdownButton, - /// The button and the dropdown is splitted. - SplitButton, - }; - protected: - DEFINE_TRANSFERRING_ANIMATION(Win8ButtonColors, Win8ToolstripButtonStyle) - - Win8ButtonElements elements; - Ptr transferringAnimation; - controls::ButtonState controlStyle; - bool isVisuallyEnabled; - bool isSelected; - bool isOpening; - elements::GuiImageFrameElement* imageElement; - compositions::GuiBoundsComposition* imageComposition; - ButtonStyle buttonStyle; - controls::GuiButton* subMenuHost; - - virtual void TransferInternal(controls::ButtonState value, bool enabled, bool selected, bool menuOpening); - public: - /// Create the style. - /// Defines the sub menu dropdown arrow style. - Win8ToolstripButtonStyle(ButtonStyle _buttonStyle); - ~Win8ToolstripButtonStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - void SetSelected(bool value)override; - controls::GuiMenu::IStyleController* CreateSubMenuStyleController()override; - void SetSubMenuExisting(bool value)override; - void SetSubMenuOpening(bool value)override; - controls::GuiButton* GetSubMenuHost()override; - void SetImage(Ptr value)override; - void SetShortcutText(const WString& value)override; - void Transfer(controls::ButtonState value)override; - }; - - /// Toolstrip splitter style (Windows 8). - class Win8ToolstripSplitterStyle : public Object, public virtual controls::GuiControl::IStyleController, public Description - { - protected: - compositions::GuiBoundsComposition* boundsComposition; - public: - /// Create the style. - Win8ToolstripSplitterStyle(); - ~Win8ToolstripSplitterStyle(); - - compositions::GuiBoundsComposition* GetBoundsComposition()override; - compositions::GuiGraphicsComposition* GetContainerComposition()override; - void SetFocusableComposition(compositions::GuiGraphicsComposition* value)override; - void SetText(const WString& value)override; - void SetFont(const FontProperties& value)override; - void SetVisuallyEnabled(bool value)override; - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\STYLES\WIN8STYLES\GUIWIN8LISTSTYLES.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control Styles::Windows8 Styles - -Clases: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_WIN8STYLES_GUIWin8LISTSTYLES -#define VCZH_PRESENTATION_CONTROLS_WIN8STYLES_GUIWin8LISTSTYLES - - -namespace vl -{ - namespace presentation - { - namespace win8 - { - -/*********************************************************************** -List Control Buttons -***********************************************************************/ - - /// Selectable item style (Windows 8). Generally for list box item background. - class Win8SelectableItemStyle : public Win8ButtonStyleBase, public Description - { - protected: - void TransferInternal(controls::ButtonState value, bool enabled, bool selected)override; - public: - /// Create the style. - Win8SelectableItemStyle(); - ~Win8SelectableItemStyle(); - }; - -/*********************************************************************** -ComboBox -***********************************************************************/ - -#pragma warning(push) -#pragma warning(disable:4250) - /// Drop down combo box style (Windows 8). - class Win8DropDownComboBoxStyle : public Win8ButtonStyle, public virtual controls::GuiComboBoxListControl::IStyleController, public Description - { - protected: - controls::IComboBoxCommandExecutor* commandExecutor; - compositions::GuiTableComposition* table; - compositions::GuiCellComposition* textComposition; - compositions::GuiCellComposition* dropDownComposition; - elements::GuiPolygonElement* dropDownElement; - WString text; - bool textVisible; - - void TransferInternal(controls::ButtonState value, bool enabled, bool selected)override; - void AfterApplyColors(const Win8ButtonColors& colors)override; - public: - /// Create the style. - Win8DropDownComboBoxStyle(); - ~Win8DropDownComboBoxStyle(); - - compositions::GuiGraphicsComposition* GetContainerComposition()override; - - controls::GuiMenu::IStyleController* CreateSubMenuStyleController()override; - void SetSubMenuExisting(bool value)override; - void SetSubMenuOpening(bool value)override; - controls::GuiButton* GetSubMenuHost()override; - void SetImage(Ptr value)override; - void SetShortcutText(const WString& value)override; - void SetCommandExecutor(controls::IComboBoxCommandExecutor* value)override; - void OnItemSelected()override; - void SetText(const WString& value)override; - void SetTextVisible(bool value)override; - }; -#pragma warning(pop) - -/*********************************************************************** -List -***********************************************************************/ - -#pragma warning(push) -#pragma warning(disable:4250) - - /// Multiline text box style (Windows 7). - class Win8TextListProvider : public Win8MultilineTextBoxProvider, public virtual controls::GuiVirtualTextList::IStyleProvider, public Description - { - public: - /// Create the style. - Win8TextListProvider(); - ~Win8TextListProvider(); - - virtual Color GetTextColor()override; - controls::GuiSelectableButton::IStyleController* CreateItemBackground()override; - controls::GuiSelectableButton::IStyleController* CreateCheckBulletStyle()override; - controls::GuiSelectableButton::IStyleController* CreateRadioBulletStyle()override; - }; - - /// List view style (Windows 8). - class Win8ListViewProvider : public Win8MultilineTextBoxProvider, public virtual controls::GuiListView::IStyleProvider, public Description - { - public: - /// Create the style. - Win8ListViewProvider(); - ~Win8ListViewProvider(); - - controls::GuiSelectableButton::IStyleController* CreateItemBackground()override; - controls::GuiListViewColumnHeader::IStyleController* CreateColumnStyle()override; - Color GetPrimaryTextColor()override; - Color GetSecondaryTextColor()override; - Color GetItemSeparatorColor()override; - }; - - /// Tree view style (Windows 8). - class Win8TreeViewProvider : public Win8MultilineTextBoxProvider, public virtual controls::GuiTreeView::IStyleProvider, public Description - { - public: - /// Create the style. - Win8TreeViewProvider(); - ~Win8TreeViewProvider(); - - controls::GuiSelectableButton::IStyleController* CreateItemBackground()override; - controls::GuiSelectableButton::IStyleController* CreateItemExpandingDecorator()override; - Color GetTextColor()override; - }; -#pragma warning(pop) - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\TEXTEDITORPACKAGE\LANGUAGESERVICE\GUILANGUAGEAUTOCOMPLETE.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control System - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_GUILANGUAGEAUTOCOMPLETE -#define VCZH_PRESENTATION_CONTROLS_GUILANGUAGEAUTOCOMPLETE - -namespace vl -{ - namespace presentation - { - namespace controls - { - -/*********************************************************************** -GuiGrammarAutoComplete -***********************************************************************/ - - /// Grammar based auto complete controller. - class GuiGrammarAutoComplete - : public GuiTextBoxAutoCompleteBase - , protected RepeatingParsingExecutor::CallbackBase - , private RepeatingTaskExecutor - { - public: - - /// The auto complete list data. - struct AutoCompleteData : ParsingTokenContext - { - /// Available candidate tokens (in lexer token index). - collections::List candidates; - /// Available candidate tokens (in lexer token index) that marked with @AutoCompleteCandidate(). - collections::List shownCandidates; - /// Candidate items. - collections::List candidateItems; - /// The start position of the editing token in global coordination. - TextPos startPosition; - }; - - /// The analysed data from an input code. - struct AutoCompleteContext : RepeatingPartialParsingOutput - { - /// The edit version of modified code. - vuint modifiedEditVersion = 0; - /// The analysed auto complete list data. - Ptr autoComplete; - }; - private: - Ptr grammarParser; - collections::SortedList leftRecursiveRules; - bool editing; - - SpinLock editTraceLock; - collections::List editTrace; - - SpinLock contextLock; - AutoCompleteContext context; - - void Attach(elements::GuiColorizedTextElement* _element, SpinLock& _elementModifyLock, compositions::GuiGraphicsComposition* _ownerComposition, vuint editVersion)override; - void Detach()override; - void TextEditPreview(TextEditPreviewStruct& arguments)override; - void TextEditNotify(const TextEditNotifyStruct& arguments)override; - void TextCaretChanged(const TextCaretChangedStruct& arguments)override; - void TextEditFinished(vuint editVersion)override; - void OnParsingFinishedAsync(const RepeatingParsingOutput& output)override; - void CollectLeftRecursiveRules(); - - vint UnsafeGetEditTraceIndex(vuint editVersion); - TextPos ChooseCorrectTextPos(TextPos pos, const regex::RegexTokens& tokens); - void ExecuteRefresh(AutoCompleteContext& newContext); - - bool NormalizeTextPos(AutoCompleteContext& newContext, elements::text::TextLines& lines, TextPos& pos); - void ExecuteEdit(AutoCompleteContext& newContext); - - void DeleteFutures(collections::List& futures); - regex::RegexToken* TraverseTransitions( - parsing::tabling::ParsingState& state, - parsing::tabling::ParsingTransitionCollector& transitionCollector, - TextPos stopPosition, - collections::List& nonRecoveryFutures, - collections::List& recoveryFutures - ); - regex::RegexToken* SearchValidInputToken( - parsing::tabling::ParsingState& state, - parsing::tabling::ParsingTransitionCollector& transitionCollector, - TextPos stopPosition, - AutoCompleteContext& newContext, - collections::SortedList& tableTokenIndices - ); - - TextPos GlobalTextPosToModifiedTextPos(AutoCompleteContext& newContext, TextPos pos); - TextPos ModifiedTextPosToGlobalTextPos(AutoCompleteContext& newContext, TextPos pos); - void ExecuteCalculateList(AutoCompleteContext& newContext); - - void Execute(const RepeatingParsingOutput& input)override; - void PostList(const AutoCompleteContext& newContext, bool byGlobalCorrection); - void Initialize(); - protected: - - /// Called when the context of the code is selected. It is encouraged to set the "candidateItems" field in "context.autoComplete" during the call. If there is an binded to the , this function can be automatically done. - /// The selected context. - virtual void OnContextFinishedAsync(AutoCompleteContext& context); - - /// Call this function in the derived class's destructor when it overrided . - void EnsureAutoCompleteFinished(); - public: - /// Create the auto complete controller with a created parsing executor. - /// The parsing executor. - GuiGrammarAutoComplete(Ptr _parsingExecutor); - /// Create the auto complete controller with a specified grammar and start rule to create a . - /// Parser generated from a grammar. - /// - GuiGrammarAutoComplete(Ptr _grammarParser, const WString& _grammarRule); - ~GuiGrammarAutoComplete(); - - /// Get the internal parsing executor. - /// The parsing executor. - Ptr GetParsingExecutor(); - }; - } - } -} - -#endif - -/*********************************************************************** -CONTROLS\TEXTEDITORPACKAGE\LANGUAGESERVICE\GUILANGUAGECOLORIZER.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Control System - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_CONTROLS_GUILANGUAGECOLORIZER -#define VCZH_PRESENTATION_CONTROLS_GUILANGUAGECOLORIZER - - -namespace vl -{ - namespace presentation - { - namespace controls - { - -/*********************************************************************** -GuiGrammarColorizer -***********************************************************************/ - - /// Grammar based colorizer. - class GuiGrammarColorizer : public GuiTextBoxRegexColorizer, protected RepeatingParsingExecutor::CallbackBase - { - typedef collections::Pair FieldDesc; - typedef collections::Dictionary FieldContextColors; - typedef collections::Dictionary FieldSemanticColors; - typedef elements::text::ColorEntry ColorEntry; - public: - /// Context for doing semantic colorizing. - struct SemanticColorizeContext : ParsingTokenContext - { - /// Output semantic id that comes from one the argument in the @Semantic attribute. - vint semanticId; - }; - private: - collections::Dictionary colorSettings; - collections::Dictionary semanticColorMap; - - SpinLock contextLock; - RepeatingParsingOutput context; - - void OnParsingFinishedAsync(const RepeatingParsingOutput& output)override; - protected: - /// Called when the node is parsed successfully before restarting colorizing. - /// The result of the parsing. - virtual void OnContextFinishedAsync(const RepeatingParsingOutput& context); - - void Attach(elements::GuiColorizedTextElement* _element, SpinLock& _elementModifyLock, compositions::GuiGraphicsComposition* _ownerComposition, vuint editVersion)override; - void Detach()override; - void TextEditPreview(TextEditPreviewStruct& arguments)override; - void TextEditNotify(const TextEditNotifyStruct& arguments)override; - void TextCaretChanged(const TextCaretChangedStruct& arguments)override; - void TextEditFinished(vuint editVersion)override; - - /// Called when a @SemanticColor attribute in a grammar is activated during colorizing to determine a color for the token. If there is an binded to the , this function can be automatically done. - /// Context for doing semantic colorizing. - /// The corressponding result from the . - virtual void OnSemanticColorize(SemanticColorizeContext& context, const RepeatingParsingOutput& input); - - /// Call this function in the derived class's destructor when it overrided . - void EnsureColorizerFinished(); - public: - /// Create the colorizer with a created parsing executor. - /// The parsing executor. - GuiGrammarColorizer(Ptr _parsingExecutor); - /// Create the colorizer with a specified grammar and start rule to create a . - /// Parser generated from a grammar. - /// - GuiGrammarColorizer(Ptr _grammarParser, const WString& _grammarRule); - ~GuiGrammarColorizer(); - - /// Reset all color settings. - void BeginSetColors(); - /// Get all color names. - /// All color names. - const collections::SortedList& GetColorNames(); - /// Get the color for a token theme name (@Color or @ContextColor("theme-name") in the grammar). - /// The color. - /// The token theme name. - ColorEntry GetColor(const WString& name); - /// Set a color for a token theme name (@Color or @ContextColor("theme-name") in the grammar). - /// The token theme name. - /// The color. - void SetColor(const WString& name, const ColorEntry& entry); - /// Set a color for a token theme name (@Color or @ContextColor("theme-name") in the grammar). - /// The token theme name. - /// The color. - void SetColor(const WString& name, const Color& color); - /// Submit all color settings. - void EndSetColors(); - void ColorizeTokenContextSensitive(vint lineIndex, const wchar_t* text, vint start, vint length, vint& token, vint& contextState)override; - - /// Get the internal parsing executor. - /// The parsing executor. - Ptr GetParsingExecutor(); - }; - } - } -} - -#endif - -/*********************************************************************** -RESOURCES\GUIDOCUMENTEDITOR.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Resource - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_RESOURCES_GUIDOCUMENTEDITOR -#define VCZH_PRESENTATION_RESOURCES_GUIDOCUMENTEDITOR - - -namespace vl -{ - namespace presentation - { - typedef DocumentModel::RunRange RunRange; - typedef DocumentModel::RunRangeMap RunRangeMap; - - namespace document_editor - { - extern void GetRunRange(DocumentParagraphRun* run, RunRangeMap& runRanges); - extern void LocateStyle(DocumentParagraphRun* run, RunRangeMap& runRanges, vint position, bool frontSide, collections::List& locatedRuns); - extern Ptr LocateHyperlink(DocumentParagraphRun* run, RunRangeMap& runRanges, vint row, vint start, vint end); - extern Ptr CopyStyle(Ptr style); - extern Ptr CopyRun(DocumentRun* run); - extern Ptr CopyStyledText(collections::List& styleRuns, const WString& text); - extern Ptr CopyRunRecursively(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end, bool deepCopy); - extern void CollectStyleName(DocumentParagraphRun* run, collections::List& styleNames); - extern void ReplaceStyleName(DocumentParagraphRun* run, const WString& oldStyleName, const WString& newStyleName); - extern void RemoveRun(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end); - extern void CutRun(DocumentParagraphRun* run, RunRangeMap& runRanges, vint position, Ptr& leftRun, Ptr& rightRun); - extern void ClearUnnecessaryRun(DocumentParagraphRun* run, DocumentModel* model); - extern void AddStyle(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end, Ptr style); - extern void AddHyperlink(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end, const WString& reference, const WString& normalStyleName, const WString& activeStyleName); - extern void AddStyleName(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end, const WString& styleName); - extern void RemoveHyperlink(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end); - extern void RemoveStyleName(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end); - extern void ClearStyle(DocumentParagraphRun* run, RunRangeMap& runRanges, vint start, vint end); - extern Ptr SummerizeStyle(DocumentParagraphRun* run, RunRangeMap& runRanges, DocumentModel* model, vint start, vint end); - extern void AggregateStyle(Ptr& dst, Ptr src); - } - } -} - -#endif - -/*********************************************************************** -GACUI.H +.\GACUI.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 diff --git a/Import/GacUICompiler.cpp b/Import/GacUICompiler.cpp index a1f86a3e..558ab965 100644 --- a/Import/GacUICompiler.cpp +++ b/Import/GacUICompiler.cpp @@ -5,7 +5,318 @@ DEVELOPER: Zihan Chen(vczh) #include "GacUICompiler.h" /*********************************************************************** -GUIINSTANCEHELPERTYPES.CPP +.\GUICPPGEN.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + using namespace collections; + using namespace stream; + using namespace filesystem; + using namespace workflow; + using namespace workflow::cppcodegen; + + Ptr PrecompileAndWriteErrors( + Ptr resource, + IGuiResourcePrecompileCallback* callback, + collections::List& errors, + const filesystem::FilePath& errorPath) + { + auto precompiledFolder = resource->Precompile(callback, errors); + if (errors.Count() > 0) + { + List output; + GuiResourceError::SortAndLog(errors, output); + if (!File(errorPath).WriteAllLines(output, true, BomEncoder::Utf8)) + { + return false; + } + } + return precompiledFolder; + } + + Ptr WriteWorkflowScript( + Ptr precompiledFolder, + const filesystem::FilePath& workflowPath) + { + if (precompiledFolder) + { + auto compiled = precompiledFolder->GetValueByPath(L"Workflow/InstanceClass").Cast(); + WString text; + if (compiled->assembly) + { + auto& codes = compiled->assembly->insAfterCodegen->moduleCodes; + FOREACH_INDEXER(WString, code, codeIndex, codes) + { + text += L"================================(" + itow(codeIndex + 1) + L"/" + itow(codes.Count()) + L")================================\r\n"; + text += code + L"\r\n"; + } + } + else + { + FOREACH_INDEXER(GuiInstanceCompiledWorkflow::ModuleRecord, moduleRecord, codeIndex, compiled->modules) + { + WString code; + { + MemoryStream stream; + { + StreamWriter writer(stream); + WfPrint(moduleRecord.module, L"", writer); + } + stream.SeekFromBegin(0); + { + StreamReader reader(stream); + code = reader.ReadToEnd(); + } + } + text += L"================================(" + itow(codeIndex + 1) + L"/" + itow(compiled->modules.Count()) + L")================================\r\n"; + text += code + L"\r\n"; + } + } + + if (File(workflowPath).WriteAllText(text)) + { + return compiled; + } + } + return nullptr; + } + + Ptr WriteCppCodesToFile( + Ptr compiled, + Ptr cppInput, + const filesystem::FilePath& cppFolder) + { + auto output = GenerateCppFiles(cppInput, compiled->metadata.Obj()); + FOREACH_INDEXER(WString, fileName, index, output->cppFiles.Keys()) + { + WString code = output->cppFiles.Values()[index]; + File file(cppFolder / fileName); + + if (file.Exists()) + { + WString inputText; + BomEncoder::Encoding inputEncoding; + bool inputBom; + file.ReadAllTextWithEncodingTesting(inputText, inputEncoding, inputBom); + code = MergeCppFileContent(inputText, code); + } + + if (file.Exists()) + { + WString inputText; + BomEncoder::Encoding inputEncoding; + bool inputBom; + file.ReadAllTextWithEncodingTesting(inputText, inputEncoding, inputBom); + if (inputText == code) + { + continue; + } + } + file.WriteAllText(code, true, BomEncoder::Utf8); + } + return output; + } + + bool WriteBinaryResource( + Ptr resource, + bool compress, + bool workflow, + const filesystem::FilePath& filePath) + { + auto precompiled = resource->GetFolder(L"Precompiled"); + auto folder = precompiled->GetFolder(L"Workflow"); + if (!workflow) + { + precompiled->RemoveFolder(L"Workflow"); + } + + FileStream fileStream(filePath.GetFullPath(), FileStream::WriteOnly); + + if (fileStream.IsAvailable()) + { + if (compress) + { + LzwEncoder encoder; + EncoderStream encoderStream(fileStream, encoder); + resource->SavePrecompiledBinary(encoderStream); + } + else + { + resource->SavePrecompiledBinary(fileStream); + } + } + + if (folder && !workflow) + { + precompiled->AddFolder(L"Workflow", folder); + } + + return fileStream.IsAvailable(); + } + + void WriteEmbeddedBinaryClass(MemoryStream& binaryStream, bool compress, const WString& className, const WString& prefix, StreamWriter& writer) + { + MemoryStream compressedStream; + binaryStream.SeekFromBegin(0); + if (compress) + { + CompressStream(binaryStream, compressedStream); + } + else + { + CopyStream(binaryStream, compressedStream); + } + compressedStream.SeekFromBegin(0); + + vint lengthBeforeCompressing = (vint)binaryStream.Size(); + vint length = (vint)compressedStream.Size(); + const vint block = 1024; + vint remain = length % block; + vint rows = length / block + (remain ? 1 : 0); + +#define PREFIX writer.WriteString(prefix); + + PREFIX writer.WriteLine(L"class " + className); + PREFIX writer.WriteLine(L"{"); + PREFIX writer.WriteLine(L"public:"); + + PREFIX writer.WriteLine(L"\tstatic const vint parserBufferLength = " + itow(length) + L"; // " + itow(lengthBeforeCompressing) + L" bytes before compressing"); + PREFIX writer.WriteLine(L"\tstatic const vint parserBufferBlock = " + itow(block) + L";"); + PREFIX writer.WriteLine(L"\tstatic const vint parserBufferRemain = " + itow(remain) + L";"); + PREFIX writer.WriteLine(L"\tstatic const vint parserBufferRows = " + itow(rows) + L";"); + PREFIX writer.WriteLine(L"\tstatic const char* parserBuffer[" + itow(rows) + L"];"); + writer.WriteLine(L""); + + PREFIX writer.WriteLine(L"\tstatic void ReadToStream(vl::stream::MemoryStream& stream)"); + PREFIX writer.WriteLine(L"\t{"); + PREFIX writer.WriteLine(L"\t\tDecompressStream(parserBuffer, " + WString(compress ? L"true" : L"false") + L", parserBufferRows, parserBufferBlock, parserBufferRemain, stream);"); + PREFIX writer.WriteLine(L"\t}"); + + PREFIX writer.WriteLine(L"};"); + writer.WriteLine(L""); + PREFIX writer.WriteLine(L"const char* " + className + L"::parserBuffer[] = {"); + + char buffer[block]; + const wchar_t* hex = L"0123456789ABCDEF"; + for (vint i = 0; i < rows; i++) + { + vint size = i == rows - 1 ? remain : block; + compressedStream.Read(buffer, size); + PREFIX writer.WriteString(L"\t\""); + for (vint j = 0; j < size; j++) + { + vuint8_t byte = buffer[j]; + writer.WriteString(L"\\x"); + writer.WriteChar(hex[byte / 16]); + writer.WriteChar(hex[byte % 16]); + } + writer.WriteLine(L"\","); + } + PREFIX writer.WriteLine(L"\t};"); + +#undef PREFIX + } + + bool WriteEmbeddedResource(Ptr resource, + Ptr cppInput, + Ptr cppOutput, + bool compress, + const filesystem::FilePath& filePath) + { + WString code; + MemoryStream stream; + { + StreamWriter writer(stream); + + writer.WriteLine(L"#include \"" + cppOutput->entryFileName + L".h\""); + writer.WriteLine(L""); + writer.WriteLine(L"namespace vl"); + writer.WriteLine(L"{"); + writer.WriteLine(L"\tnamespace presentation"); + writer.WriteLine(L"\t{"); + writer.WriteLine(L"\t\tnamespace user_resource"); + writer.WriteLine(L"\t\t{"); + writer.WriteLine(L"\t\t\tusing namespace collections;"); + writer.WriteLine(L"\t\t\tusing namespace stream;"); + writer.WriteLine(L"\t\t\tusing namespace controls;"); + writer.WriteLine(L""); + + { + MemoryStream resourceStream; + { + auto precompiled = resource->GetFolder(L"Precompiled"); + auto folder = precompiled->GetFolder(L"Workflow"); + precompiled->RemoveFolder(L"Workflow"); + resource->SavePrecompiledBinary(resourceStream); + precompiled->AddFolder(L"Workflow", folder); + } + WriteEmbeddedBinaryClass(resourceStream, compress, cppInput->assemblyName + L"ResourceReader", L"\t\t\t", writer); + writer.WriteLine(L""); + } + { + writer.WriteLine(L"\t\t\tclass " + cppInput->assemblyName + L"ResourceLoaderPlugin : public Object, public IGuiPlugin"); + writer.WriteLine(L"\t\t\t{"); + writer.WriteLine(L"\t\t\tpublic:"); + writer.WriteLine(L""); + writer.WriteLine(L"\t\t\t\tGUI_PLUGIN_NAME(GacGen_" + cppInput->assemblyName + L"ResourceLoader)"); + writer.WriteLine(L"\t\t\t\t{"); + writer.WriteLine(L"\t\t\t\t\tGUI_PLUGIN_DEPEND(GacUI_Res_Resource);"); + writer.WriteLine(L"\t\t\t\t\tGUI_PLUGIN_DEPEND(GacUI_Res_TypeResolvers);"); + writer.WriteLine(L"#ifndef VCZH_DEBUG_NO_REFLECTION"); + writer.WriteLine(L"\t\t\t\t\tGUI_PLUGIN_DEPEND(GacUI_Instance_Reflection);"); + writer.WriteLine(L"\t\t\t\t\tGUI_PLUGIN_DEPEND(GacUI_Compiler_WorkflowTypeResolvers);"); + writer.WriteLine(L"#endif"); + writer.WriteLine(L"\t\t\t\t}"); + writer.WriteLine(L""); + writer.WriteLine(L"\t\t\t\tvoid Load()override"); + writer.WriteLine(L"\t\t\t\t{"); + writer.WriteLine(L"\t\t\t\t\tList errors;"); + writer.WriteLine(L"\t\t\t\t\tMemoryStream resourceStream;"); + writer.WriteLine(L"\t\t\t\t\t" + cppInput->assemblyName + L"ResourceReader::ReadToStream(resourceStream);"); + writer.WriteLine(L"\t\t\t\t\tresourceStream.SeekFromBegin(0);"); + writer.WriteLine(L"\t\t\t\t\tauto resource = GuiResource::LoadPrecompiledBinary(resourceStream, errors);"); + writer.WriteLine(L"\t\t\t\t\tGetResourceManager()->SetResource(L\"" + cppInput->assemblyName + L"\", resource, GuiResourceUsage::InstanceClass);"); + writer.WriteLine(L"\t\t\t\t}"); + writer.WriteLine(L""); + writer.WriteLine(L"\t\t\t\tvoid Unload()override"); + writer.WriteLine(L"\t\t\t\t{"); + writer.WriteLine(L"\t\t\t\t}"); + writer.WriteLine(L"\t\t\t};"); + writer.WriteLine(L"\t\t\tGUI_REGISTER_PLUGIN(" + cppInput->assemblyName + L"ResourceLoaderPlugin)"); + } + + writer.WriteLine(L"\t\t}"); + writer.WriteLine(L"\t}"); + writer.WriteLine(L"}"); + } + stream.SeekFromBegin(0); + { + StreamReader reader(stream); + code = reader.ReadToEnd(); + } + + File file(filePath); + if (file.Exists()) + { + WString inputText; + BomEncoder::Encoding inputEncoding; + bool inputBom; + file.ReadAllTextWithEncodingTesting(inputText, inputEncoding, inputBom); + if (inputText == code) + { + return true; + } + } + return file.WriteAllText(code, true, BomEncoder::Utf8); + } + } +} + +/*********************************************************************** +.\GUIINSTANCEHELPERTYPES.CPP ***********************************************************************/ namespace vl @@ -73,6 +384,12 @@ GuiHelperTypesLoaderPlugin class GuiHelperTypesLoaderPlugin : public Object, public IGuiPlugin { public: + + GUI_PLUGIN_NAME(GacUI_Instance_ReflectionHelper) + { + GUI_PLUGIN_DEPEND(GacUI_Instance_Reflection); + } + void Load()override { ITypeManager* manager=GetGlobalTypeManager(); @@ -83,10 +400,6 @@ GuiHelperTypesLoaderPlugin } } - void AfterLoad()override - { - } - void Unload()override { } @@ -97,7 +410,865 @@ GuiHelperTypesLoaderPlugin } /*********************************************************************** -GUIINSTANCELOADER.CPP +.\GUIINSTANCESHAREDSCRIPT.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + using namespace parsing::xml; + +/*********************************************************************** +GuiInstanceSharedScript +***********************************************************************/ + + Ptr GuiInstanceSharedScript::LoadFromXml(Ptr resource, Ptr xml, GuiResourceError::List& errors) + { + if (xml->rootElement->subNodes.Count() == 1) + { + if (auto cdata = xml->rootElement->subNodes[0].Cast()) + { + auto script = MakePtr(); + script->language = xml->rootElement->name.value; + script->code = cdata->content.value; + script->codePosition = { {resource},cdata->codeRange.start }; + script->codePosition.column += 9; // rootElement->codeRange.start }, L"Script should be contained in a CDATA section.")); + return nullptr; + } + + Ptr GuiInstanceSharedScript::SaveToXml() + { + auto cdata = MakePtr(); + cdata->content.value = code; + + auto xml = MakePtr(); + xml->name.value = language; + xml->subNodes.Add(cdata); + + return xml; + } + } +} + +/*********************************************************************** +.\INSTANCEQUERY\GUIINSTANCEQUERY.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + using namespace collections; + +/*********************************************************************** +ExecuteQueryVisitor +***********************************************************************/ + + class ExecuteQueryVisitor : public Object, public GuiIqQuery::IVisitor + { + public: + Ptr context; + List>& input; + List>& output; + + ExecuteQueryVisitor(Ptr _context, List>& _input, List>& _output) + :context(_context), input(_input), output(_output) + { + } + + static bool TestCtor(GuiIqPrimaryQuery* node, GlobalStringKey attribute, Ptr ctor) + { + if (node->attributeNameOption == GuiIqNameOption::Specified && node->attributeName.value != attribute.ToString()) + { + return false; + } + if (node->typeNameOption == GuiIqNameOption::Specified && node->typeName.value != ctor->typeName.ToString()) + { + return false; + } + if (node->referenceName.value != L"") + { + bool instanceName = ctor->instanceName != GlobalStringKey::Empty && node->referenceName.value == ctor->instanceName.ToString(); + bool styleName = ctor->styleName && node->referenceName.value == ctor->styleName.Value(); + return instanceName || styleName; + } + return true; + } + + void Traverse(GuiIqPrimaryQuery* node, Ptr setter) + { + if (setter) + { + FOREACH_INDEXER(GlobalStringKey, attribute, index, setter->setters.Keys()) + { + auto setterValue = setter->setters.Values()[index]; + FOREACH(Ptr, value, setterValue->values) + { + if (auto ctor = value.Cast()) + { + if (TestCtor(node, attribute, ctor)) + { + output.Add(ctor); + } + } + if (node->childOption == GuiIqChildOption::Indirect) + { + if (auto setter = value.Cast()) + { + Traverse(node, setter); + } + } + } + } + } + else + { + if (TestCtor(node, GlobalStringKey::Empty, context->instance)) + { + output.Add(context->instance); + } + if (node->childOption == GuiIqChildOption::Indirect) + { + Traverse(node, context->instance); + } + } + } + + void Visit(GuiIqPrimaryQuery* node)override + { + auto inputExists = &input; + if (inputExists) + { + FOREACH(Ptr, setter, input) + { + Traverse(node, setter); + } + } + else + { + Traverse(node, 0); + } + } + + void Visit(GuiIqCascadeQuery* node)override + { + List> temp; + ExecuteQuery(node->parent, context, input, temp); + ExecuteQuery(node->child, context, temp, output); + } + + void Visit(GuiIqSetQuery* node)override + { + List> first, second; + ExecuteQuery(node->first, context, input, first); + ExecuteQuery(node->second, context, input, second); + + switch (node->op) + { + case GuiIqBinaryOperator::ExclusiveOr: + CopyFrom(output, From(first).Except(second).Union(From(second).Except(second))); + break; + case GuiIqBinaryOperator::Intersect: + CopyFrom(output, From(first).Intersect(second)); + break; + case GuiIqBinaryOperator::Union: + CopyFrom(output, From(first).Union(second)); + break; + case GuiIqBinaryOperator::Substract: + CopyFrom(output, From(first).Except(second)); + break; + } + } + }; + +/*********************************************************************** +ExecuteQuery +***********************************************************************/ + + void ExecuteQuery(Ptr query, Ptr context, collections::List>& input, collections::List>& output) + { + ExecuteQueryVisitor visitor(context, input, output); + query->Accept(&visitor); + } + + void ExecuteQuery(Ptr query, Ptr context, collections::List>& output) + { + ExecuteQuery(query, context, *(List>*)0, output); + } + +/*********************************************************************** +ApplyStyle +***********************************************************************/ + + void ApplyStyleInternal(Ptr src, Ptr dst) + { + FOREACH_INDEXER(GlobalStringKey, attribute, srcIndex, src->setters.Keys()) + { + auto srcValue = src->setters.Values()[srcIndex]; + vint dstIndex = dst->setters.Keys().IndexOf(attribute); + if (dstIndex == -1) + { + dst->setters.Add(attribute, srcValue); + } + else + { + auto dstValue = dst->setters.Values()[dstIndex]; + if (srcValue->binding == dstValue->binding) + { + if (srcValue->binding == GlobalStringKey::_Set) + { + ApplyStyleInternal(srcValue->values[0].Cast(), dstValue->values[0].Cast()); + } + else + { + CopyFrom(dstValue->values, srcValue->values, true); + } + } + } + } + + FOREACH_INDEXER(GlobalStringKey, eventName, srcIndex, src->eventHandlers.Keys()) + { + if (!dst->eventHandlers.Keys().Contains(eventName)) + { + auto srcValue = src->eventHandlers.Values()[srcIndex]; + dst->eventHandlers.Add(eventName, srcValue); + } + } + + FOREACH_INDEXER(GlobalStringKey, varName, srcIndex, src->environmentVariables.Keys()) + { + if (!dst->environmentVariables.Keys().Contains(varName)) + { + auto srcValue = src->environmentVariables.Values()[srcIndex]; + dst->environmentVariables.Add(varName, srcValue); + } + } + } + + void ApplyStyle(Ptr style, Ptr ctor) + { + ApplyStyleInternal(style->setter->Clone().Cast(), ctor); + } + +/*********************************************************************** +GuiIqPrint +***********************************************************************/ + + class GuiIqPrintVisitor : public Object, public GuiIqQuery::IVisitor + { + public: + stream::StreamWriter& writer; + + GuiIqPrintVisitor(stream::StreamWriter& _writer) + :writer(_writer) + { + } + + void Visit(GuiIqPrimaryQuery* node)override + { + switch (node->childOption) + { + case GuiIqChildOption::Direct: + writer.WriteString(L"/"); + break; + case GuiIqChildOption::Indirect: + writer.WriteString(L"//"); + break; + } + + if (node->attributeNameOption == GuiIqNameOption::Specified) + { + writer.WriteChar(L'@'); + writer.WriteString(node->attributeName.value); + writer.WriteChar(L':'); + } + + if (node->typeNameOption == GuiIqNameOption::Specified) + { + writer.WriteString(node->typeName.value); + } + else + { + writer.WriteChar(L'*'); + } + + if (node->referenceName.value != L"") + { + writer.WriteChar(L'.'); + writer.WriteString(node->referenceName.value); + } + } + + void Visit(GuiIqCascadeQuery* node)override + { + node->parent->Accept(this); + node->child->Accept(this); + } + + void Visit(GuiIqSetQuery* node)override + { + writer.WriteChar(L'('); + node->first->Accept(this); + switch (node->op) + { + case GuiIqBinaryOperator::ExclusiveOr: + writer.WriteString(L" ^ "); + break; + case GuiIqBinaryOperator::Intersect: + writer.WriteString(L" * "); + break; + case GuiIqBinaryOperator::Union: + writer.WriteString(L" + "); + break; + case GuiIqBinaryOperator::Substract: + writer.WriteString(L" - "); + break; + } + node->second->Accept(this); + writer.WriteChar(L')'); + } + }; + + void GuiIqPrint(Ptr query, stream::StreamWriter& writer) + { + GuiIqPrintVisitor visitor(writer); + query->Accept(&visitor); + } + } +} + + +/*********************************************************************** +.\INSTANCEQUERY\GUIINSTANCEQUERY_AST.CPP +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Parser::GuiInstanceQuery_Parser.parser.txt + +This file is generated by: Vczh Parser Generator +***********************************************************************/ + + +namespace vl +{ + namespace presentation + { +/*********************************************************************** +Visitor Pattern Implementation +***********************************************************************/ + + void GuiIqPrimaryQuery::Accept(GuiIqQuery::IVisitor* visitor) + { + visitor->Visit(this); + } + + void GuiIqCascadeQuery::Accept(GuiIqQuery::IVisitor* visitor) + { + visitor->Visit(this); + } + + void GuiIqSetQuery::Accept(GuiIqQuery::IVisitor* visitor) + { + visitor->Visit(this); + } + + } +} +namespace vl +{ + namespace reflection + { + namespace description + { +#ifndef VCZH_DEBUG_NO_REFLECTION + using namespace vl::presentation; + +#define PARSING_TOKEN_FIELD(NAME)\ + CLASS_MEMBER_EXTERNALMETHOD_TEMPLATE(get_##NAME, NO_PARAMETER, vl::WString(ClassType::*)(), [](ClassType* node) { return node->NAME.value; }, L"*", L"*")\ + CLASS_MEMBER_EXTERNALMETHOD_TEMPLATE(set_##NAME, { L"value" }, void(ClassType::*)(const vl::WString&), [](ClassType* node, const vl::WString& value) { node->NAME.value = value; }, L"*", L"*")\ + CLASS_MEMBER_PROPERTY_REFERENCETEMPLATE(NAME, get_##NAME, set_##NAME, L"$This->$Name.value")\ + + IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqQuery, presentation::GuiIqQuery) + IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqNameOption, presentation::GuiIqNameOption) + IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqChildOption, presentation::GuiIqChildOption) + IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqPrimaryQuery, presentation::GuiIqPrimaryQuery) + IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqCascadeQuery, presentation::GuiIqCascadeQuery) + IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqBinaryOperator, presentation::GuiIqBinaryOperator) + IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqSetQuery, presentation::GuiIqSetQuery) + IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqQuery::IVisitor, presentation::GuiIqQuery::IVisitor) + + BEGIN_CLASS_MEMBER(GuiIqQuery) + CLASS_MEMBER_METHOD_OVERLOAD(Accept, {L"visitor"}, void(GuiIqQuery::*)(GuiIqQuery::IVisitor* visitor)) + END_CLASS_MEMBER(GuiIqQuery) + + BEGIN_ENUM_ITEM(GuiIqNameOption) + ENUM_ITEM_NAMESPACE(GuiIqNameOption) + ENUM_NAMESPACE_ITEM(Specified) + ENUM_NAMESPACE_ITEM(Any) + END_ENUM_ITEM(GuiIqNameOption) + + BEGIN_ENUM_ITEM(GuiIqChildOption) + ENUM_ITEM_NAMESPACE(GuiIqChildOption) + ENUM_NAMESPACE_ITEM(Direct) + ENUM_NAMESPACE_ITEM(Indirect) + END_ENUM_ITEM(GuiIqChildOption) + + BEGIN_CLASS_MEMBER(GuiIqPrimaryQuery) + CLASS_MEMBER_BASE(GuiIqQuery) + + CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) + + CLASS_MEMBER_FIELD(childOption) + CLASS_MEMBER_FIELD(attributeNameOption) + PARSING_TOKEN_FIELD(attributeName) + CLASS_MEMBER_FIELD(typeNameOption) + PARSING_TOKEN_FIELD(typeName) + PARSING_TOKEN_FIELD(referenceName) + END_CLASS_MEMBER(GuiIqPrimaryQuery) + + BEGIN_CLASS_MEMBER(GuiIqCascadeQuery) + CLASS_MEMBER_BASE(GuiIqQuery) + + CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) + + CLASS_MEMBER_FIELD(parent) + CLASS_MEMBER_FIELD(child) + END_CLASS_MEMBER(GuiIqCascadeQuery) + + BEGIN_ENUM_ITEM(GuiIqBinaryOperator) + ENUM_ITEM_NAMESPACE(GuiIqBinaryOperator) + ENUM_NAMESPACE_ITEM(ExclusiveOr) + ENUM_NAMESPACE_ITEM(Intersect) + ENUM_NAMESPACE_ITEM(Union) + ENUM_NAMESPACE_ITEM(Substract) + END_ENUM_ITEM(GuiIqBinaryOperator) + + BEGIN_CLASS_MEMBER(GuiIqSetQuery) + CLASS_MEMBER_BASE(GuiIqQuery) + + CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) + + CLASS_MEMBER_FIELD(first) + CLASS_MEMBER_FIELD(second) + CLASS_MEMBER_FIELD(op) + END_CLASS_MEMBER(GuiIqSetQuery) + + BEGIN_INTERFACE_MEMBER(GuiIqQuery::IVisitor) + CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(GuiIqQuery::IVisitor::*)(GuiIqPrimaryQuery* node)) + CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(GuiIqQuery::IVisitor::*)(GuiIqCascadeQuery* node)) + CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(GuiIqQuery::IVisitor::*)(GuiIqSetQuery* node)) + END_INTERFACE_MEMBER(GuiIqQuery) + +#undef PARSING_TOKEN_FIELD + + class GuiIqTypeLoader : public vl::Object, public ITypeLoader + { + public: + void Load(ITypeManager* manager) + { + ADD_TYPE_INFO(vl::presentation::GuiIqQuery) + ADD_TYPE_INFO(vl::presentation::GuiIqNameOption) + ADD_TYPE_INFO(vl::presentation::GuiIqChildOption) + ADD_TYPE_INFO(vl::presentation::GuiIqPrimaryQuery) + ADD_TYPE_INFO(vl::presentation::GuiIqCascadeQuery) + ADD_TYPE_INFO(vl::presentation::GuiIqBinaryOperator) + ADD_TYPE_INFO(vl::presentation::GuiIqSetQuery) + ADD_TYPE_INFO(vl::presentation::GuiIqQuery::IVisitor) + } + + void Unload(ITypeManager* manager) + { + } + }; +#endif + + bool GuiIqLoadTypes() + { +#ifndef VCZH_DEBUG_NO_REFLECTION + ITypeManager* manager=GetGlobalTypeManager(); + if(manager) + { + Ptr loader=new GuiIqTypeLoader; + return manager->AddTypeLoader(loader); + } +#endif + return false; + } + } + } +} + + +/*********************************************************************** +.\INSTANCEQUERY\GUIINSTANCEQUERY_PARSER.CPP +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Parser::GuiInstanceQuery_Parser.parser.txt + +This file is generated by: Vczh Parser Generator +***********************************************************************/ + + +namespace vl +{ + namespace presentation + { +/*********************************************************************** +ParserText +***********************************************************************/ + +const wchar_t parserTextBuffer[] = +L"\r\n" L"" +L"\r\n" L"class Query" +L"\r\n" L"{" +L"\r\n" L"}" +L"\r\n" L"" +L"\r\n" L"enum NameOption" +L"\r\n" L"{" +L"\r\n" L"\tSpecified," +L"\r\n" L"\tAny," +L"\r\n" L"}" +L"\r\n" L"" +L"\r\n" L"enum ChildOption" +L"\r\n" L"{" +L"\r\n" L"\tDirect," +L"\r\n" L"\tIndirect," +L"\r\n" L"}" +L"\r\n" L"" +L"\r\n" L"class PrimaryQuery : Query" +L"\r\n" L"{" +L"\r\n" L"\tChildOption\t\tchildOption;" +L"\r\n" L"\tNameOption\t\tattributeNameOption;" +L"\r\n" L"\ttoken\t\t\tattributeName;" +L"\r\n" L"\tNameOption\t\ttypeNameOption;" +L"\r\n" L"\ttoken\t\t\ttypeName;" +L"\r\n" L"\ttoken\t\t\treferenceName;" +L"\r\n" L"}" +L"\r\n" L"" +L"\r\n" L"class CascadeQuery : Query" +L"\r\n" L"{" +L"\r\n" L"\tQuery\t\t\tparent;" +L"\r\n" L"\tQuery\t\t\tchild;" +L"\r\n" L"}" +L"\r\n" L"" +L"\r\n" L"enum BinaryOperator" +L"\r\n" L"{" +L"\r\n" L"\tExclusiveOr," +L"\r\n" L"\tIntersect," +L"\r\n" L"\tUnion," +L"\r\n" L"\tSubstract," +L"\r\n" L"}" +L"\r\n" L"" +L"\r\n" L"class SetQuery : Query" +L"\r\n" L"{" +L"\r\n" L"\tQuery\t\t\tfirst;" +L"\r\n" L"\tQuery\t\t\tsecond;" +L"\r\n" L"\tBinaryOperator\top;" +L"\r\n" L"}" +L"\r\n" L"" +L"\r\n" L"token INDIRECT = \"////\";" +L"\r\n" L"token DIRECT = \"//\";" +L"\r\n" L"token NAME = \"[a-zA-Z_][a-zA-Z0-9]*\";" +L"\r\n" L"token WILDCARD = \"/*\";" +L"\r\n" L"token OPEN = \"/(\";" +L"\r\n" L"token CLOSE = \"/)\";" +L"\r\n" L"token XOR = \"/^\";" +L"\r\n" L"token INTERSECT = \"/*\";" +L"\r\n" L"token UNION = \"/+\";" +L"\r\n" L"token SUBSTRACT = \"-\";" +L"\r\n" L"token ATTRIBUTE = \"@\";" +L"\r\n" L"token COLON = \":\";" +L"\r\n" L"token DOT = \".\";" +L"\r\n" L"" +L"\r\n" L"discardtoken SPACE = \"/s+\";" +L"\r\n" L"" +L"\r\n" L"rule PrimaryQuery QPrimaryFragment" +L"\r\n" L"\t=\t(" +L"\r\n" L"\t\t\t(NAME : typeName with {typeNameOption=\"Specified\"})" +L"\r\n" L"\t\t\t| (\"*\" with {typeNameOption=\"Any\"})" +L"\r\n" L"\t\t)" +L"\r\n" L"\t\t[\".\" NAME : referenceName] as PrimaryQuery" +L"\r\n" L"\t;" +L"\r\n" L"" +L"\r\n" L"rule PrimaryQuery QPrimaryAttributed" +L"\r\n" L"\t= !QPrimaryFragment with {attributeNameOption=\"Any\"}" +L"\r\n" L"\t= \"@\" [NAME : attributeName] \":\" !QPrimaryFragment with {attributeNameOption=\"Specified\"}" +L"\r\n" L"\t;" +L"\r\n" L"" +L"\r\n" L"rule PrimaryQuery QPrimary" +L"\r\n" L"\t= (\"/\" with {childOption=\"Direct\"}) !QPrimaryAttributed" +L"\r\n" L"\t= (\"//\" with {childOption=\"Indirect\"}) !QPrimaryAttributed" +L"\r\n" L"\t= \"(\" !QueryRoot \")\"" +L"\r\n" L"\t;" +L"\r\n" L"" +L"\r\n" L"rule Query Query0" +L"\r\n" L"\t= !QPrimary" +L"\r\n" L"\t= Query0 : parent QPrimary : child as CascadeQuery;" +L"\r\n" L"" +L"\r\n" L"rule Query Query1" +L"\r\n" L"\t= !Query0" +L"\r\n" L"\t= Query1 : first \"^\" Query0 : second as SetQuery with {op=\"ExclusiveOr\"}" +L"\r\n" L"\t= Query1 : first \"*\" Query0 : second as SetQuery with {op=\"Intersect\"}" +L"\r\n" L"\t;" +L"\r\n" L"\t" +L"\r\n" L"rule Query Query2" +L"\r\n" L"\t= !Query1" +L"\r\n" L"\t= Query2 : first \"+\" Query1 : second as SetQuery with {op=\"Union\"}" +L"\r\n" L"\t= Query2 : first \"-\" Query1 : second as SetQuery with {op=\"Substract\"}" +L"\r\n" L"\t;" +L"\r\n" L"" +L"\r\n" L"rule Query QueryRoot" +L"\r\n" L"\t= !Query2" +L"\r\n" L"\t;" +; + + vl::WString GuiIqGetParserTextBuffer() + { + return parserTextBuffer; + } + +/*********************************************************************** +SerializedTable +***********************************************************************/ + +const vint parserBufferLength = 5788; // 27819 bytes before compressing +const vint parserBufferBlock = 1024; +const vint parserBufferRemain = 668; +const vint parserBufferRows = 6; +const char* parserBuffer[] = { +"\x00\x00\x81\x81\x84\x02\x81\x80\x07\x82\x00\x87\x80\x83\x21\x33\x3B\x31\x30\x64\x65\x11\x35\x35\x32\x39\x3D\x7F\x18\x99\x98\x8A\x85\x84\x8C\x28\x39\x69\x6D\x21\x36\x83\x8D\x8B\x8A\x8D\x19\x85\x08\x80\x0A\x90\x81\x92\x8B\x28\x99\x88\x0B\x93\x98\x83\x29\x32\x74\x2F\xA7\x91\x9B\x03\x94\x8E\x81\x1C\x8C\x8E\x90\x82\x8C\x8A\x8B\x96\x05\xC8\xA3\x28\x39\x34\x34\x33\x98\x1B\xBE\x81\x82\xAF\x81\x8A\x9C\x03\x2B\xD8\x80\x90\x33\x95\x32\x36\x3A\x50\xFF\x7F\x86\x81\x87\x8D\x91\x91\x79\x3A\x8D\x0B\x9B\xB0\x81\x30\x3A\x74\x20\xA2\x35\x34\x3D\x32\x27\x30\x6D\x65\x21\xA3\xB9\x85\xB0\x90\x91\x24\xC6\xB9\x33\x0B\x94\xC2\xB6\xB8\x72\xF4\xB6\xB8\xB5\x37\x24\x38\x3A\x69\x6F\x2E\x3B\xB2\xA8\x82\xB2\xC0\x69\x82\xFD\x88\x8B\xC8\x03\xA5\xA6\x64\x0E\xD0\xD2\xC4\xC8\x86\x8F\xBF\x68\xEA\xAC\xA1\x82\x3D\x32\x33\x8A\x5E\xE3\x0B\xD9\xB5\xD5\x8E\xBF\xB3\x81\xA6\xB5\x85\x8B\xDC\x39\x3C\x38\xB3\xFA\x90\xBC\xB0\x07\xD0\xDD\xCC\x26\x8E\x2B\x8A\xE0\x86\xDC\xE1\xBB\x79\xA2\xD1\xD3\xC0\xAB\xDE\x81\xDD\x37\xB9\x82\xC8\xA2\x80\xA6\x33\x34\x72\x73\x20\xB5\xE4\x99\x81\xEC\x9D\x02\x2B\xA9\xE0\x8F\x30\x39\xB0\xEB\x01\xD8\xF8\x97\xA9\xA9\x83\x39\x32\x63\x12\xCF\xB0\xA1\x0B\x97\x17\x95\xFD\x6B\x42\x83\x4A\x61\x61\x53\x80\x81\x05\xB1\x47\x80\x42\x09\x8A\x8B\x82\x40\x0D\xA8\x40\x7C\x40\xBB\x49\x1E\x10\x11\x49\x12\x15\x13\x10\x54\x04\x48\x42\x87\x00\x2F\x02\x8B\x7F\x08\xB1\x4A\x55\x41\x27\x98\x8A\x84\x87\xEB\x45\x4D\x8A\x88\x01\x25\x88\x48\x88\x02\x60\x8E\x11\x10\x4D\x05\x15\x07\x4A\x3B\x80\x4B\x15\x18\x2D\x3A\x11\x11\x0B\x5A\x1F\x1D\x17\x8F\x41\x83\x9A\x14\x0C\x2D\x39\x0D\x16\x0A\x2D\x90\x84\x78\x42\xBB\x57\x19\x10\x13\x44\x03\x11\x12\x14\x44\x11\x91\x43\x8B\x2A\x03\x02\x8E\x46\x34\x83\x41\x43\x13\x50\x05\x1E\x12\x97\x00\x6F\x88\x09\x99\x00\x61\x5C\x75\x40\x48\x43\x1C\x13\x13\x53\x05\x1C\x98\x00\x2F\xA9\x03\x9D\x9C\x50\x62\x98\x42\xA0\x00\x18\x1F\x12\x14\x7B\xAF\x8E\x17\x89\x52\xB1\x49\x03\x4A\x8F\x80\x46\x84\x15\x45\x12\x19\x9C\x8B\xEA\x41\x4F\x0A\x0A\x07\x23\x99\x4B\x4A\x48\x55\x1E\x11\x12\x4F\x2B\x99\xA4\x40\x2F\x2B\x03\x84\x00\x61\x51\xA5\x42\xAB\x53\x15\x12\x13\x14\x54\x12\x11\x10\x87\x31\x88\x49\xAC\x00\x2D\x2E\xAD\xA0\x4A\xBE\x81\x4E\xA9\x10\x54\x35\xA9\x12\x10\x55\x14\xAB\xAE\x40\xBB\x80\x1A\x02\xA7\x18\x7F\x9C\x4B\x54\x4F\x37\x9E\x13\xB2\x01\x7B\xAA\x0D\x67\xBF\x9A\x44\xA2\x40\x84\x84\x1F\x10\x15\xD8\x80\x4B\xAE\x0B\xC4\x61\x55\xBB\xB4\x08\x48\x53\x14\x14\xB7\x85\x1F\xB5\x40\x84\xAF\x03\x1F\x0A\x6D\x45\x41\x58\x89\x28\xB5\x7E\x4A\x60\x32\x10\x0B\x4A\xC0\xFF\xA6\x42\x0E\x0B\x52\x2F\x1F\x18\x1D\x53\x34\x13\x48\x1D\xDC\x81\x4D\x64\x10\x20\x24\x0C\x0E\x4E\x32\x3E\x0C\xA1\x40\x27\x98\xC4\x70\x47\x18\xEE\x0D\xC3\xC3\xCF\x88\x45\xC8\x00\x14\xD7\xC0\xC2\x0F\xAB\xBB\x61\x17\x65\x68\x67\xC2\x43\xC9\x2F\xE8\x66\x46\x0B\x31\x15\x2B\x4A\xCE\x00\x57\xC0\xCE\x45\x3E\x3A\x00\x08\x0A\x20\x22\x0F\x0A\x08\x14\xF7\x19\x18\x1D\x68\x20\x0B\x1C\x08\x9F\x4E\x52\x76\x64\x20\x3D\x05\xD0\x11\xE0\x78\x74\x1E\x08\x20\x3D\x10\x09\x0A\x20\x21\x05\xCF\x71\x41\x08\x69\x1B\x5C\x75\x64\x1D\x02\x02\x3E\xF6\xC9\x1D\xD0\x43\xC5\xD2\x88\xD2\x20\x0A\xDC\xD2\xD3\x50\xCC\x52\xD7\x63\xD3\x55\xD5\xD1\x12\x6E\x24\x19\xD7\x18\x5B\xDD\xDF\xD5\xD8\x63\xD8\x65\xD9\x5C\x67\xCA\x64\x19\xCB\x01\x49\xE1\xCF\x4A\x34\xFF\xC9\x1E\x0B\x32\x1F\x0B\x4A\xE6\x3D\xD2\xE0\xD2\xD0\x22\x28\x04\xDE\xD8\x82\x49\xCB\xC1\xD1\x29\x22\x04\xC1\x41\xAB\xDE\xE9\x1E\x11\x72\x21\x17\x19\x5E\x5F\x52\x0B\x4A\xED\x2E\x56\xE0\xEE\xEC\xB4\xF4\x18\xCD\x2A\x2B\x40\xFD\xE6\xEE\xB1\xF3\xEE\x54\x1D\x70\xC4\xD4\xD3\x8D\x39\xA0\x02\xD2\x73\xC1\x75\xDB\xD1\xD3\x4F\xD0\xF0\x75\x63\x7C\xD4\xD6\xD6\x08\x53\x00\x73\x19\x1A\xDF\x65\x14\x18\xD7\x5E\xE0\xDC\x1D\xDC\x22\x2A\x0C\xD6\xDD\xD4\xE0\x06\xF4\x63\x53\xEE\x1E\xDE\x08\x41\x2E\x19\x1C\xF9\x87\xE9\x04\xC7\x16\x45\xEE\x0C\xD4\xF3\x45\x0E\x78\x08\x2D\x3F\x35\xD6\x2E\x0A\x36\xD7\x60\x05\x17\x20\x0D\x20\x10\x16\x72\x27\xAB\x62\x21\xEB\x44\x7C\x77\xE3\x78\x75\x20\x17\x8E\x77\xEE\x46\x7F\x2A\xCC\x42\x7D\x20\x1F\x8D\x6F\x71\x1B\x8D\x77\xE4\x71\x68\x80\x02\x8F\x7D\x5E\x52\x77\x6F\xEA\x7F\x31\x38\xF1\x73\x7D\xF7\x78\x30\x7D\x34\x22\x78\x7F\xE6\x68\x7E\xFA\x2C\x8D\x7C\x15\x98\x7B\x34\xF2\x7B\x79\xFD\x77\x76\x70", +"\xB0\x7A\x78\x04\xFC\x62\x06\xFF\x20\x08\x84\xA1\x44\x80\x36\x07\x91\x7B\x02\x8D\x8F\x80\xC1\x17\x82\x20\x19\x96\x73\xE2\x09\x39\x6C\x0A\x2B\x26\x8B\xB9\x6E\x6F\x16\x8D\x79\x6C\xCC\x74\x0B\x25\x67\x83\x7A\x18\xE6\x68\x6C\xF1\x70\x68\x69\x74\x7C\x7D\x13\x8C\x8C\x8C\xC5\x09\x83\x81\x22\x1A\x04\xD7\x62\x64\x82\x0E\xB4\x0C\x87\x78\x6F\x2C\xE3\x6D\x87\x7B\x18\x9B\x7B\x86\xDF\x61\x7F\xF8\x5D\x61\x83\x80\x13\x86\x6D\x24\x96\x83\xED\x11\x7D\x8F\xDE\x6E\x03\x06\x1F\x82\x21\x08\x9A\x85\x79\x12\x82\x6A\x79\x4C\x98\x45\x00\xCF\x7F\x85\x04\xAC\x78\x6F\x3E\x86\x91\xD1\x08\x95\x87\x1B\x85\x88\x04\xE7\x64\x69\xFA\x6B\x73\x7A\x54\xA5\x90\x7E\xD9\x61\x89\xD1\x43\x88\x87\xC3\x49\x8E\x7F\x14\x73\x8F\x13\x86\x88\x80\xC6\x0A\x84\x81\x73\x0E\x82\xDB\x10\x83\x60\x4A\x90\x95\x93\xC7\x78\x03\x4A\x52\x91\x8D\x11\x90\x9D\x83\xA6\x74\x0D\x11\x01\x7D\x47\x82\x1D\x9E\x62\x9C\x95\x83\x57\x3E\x00\x04\x20\x17\x89\x20\x59\x8B\x8F\x20\x8E\x70\x8D\x82\x2D\x9E\x75\x63\x8D\x8C\x19\x38\x63\x19\x95\x35\x9A\x8D\x64\x75\x8D\xDA\x70\x6C\x8F\x67\xA2\x9C\x0E\x49\x75\x97\xD3\x02\x9C\x8A\x18\xB9\x93\x7E\xBC\x9D\x6B\xDA\x22\x8A\x70\x7D\xAE\x88\x74\x40\x1C\x6A\x1C\xA2\x92\x80\x82\xA4\x8A\x8A\x45\x7A\x8C\xE2\x15\x97\x79\x80\xAD\x84\x8E\xEB\x95\x2D\x21\x87\xA7\x90\xEF\x6D\x93\x91\x7D\x07\x9C\x40\x69\x99\x9F\x90\xA2\x7D\x9D\x02\x2F\x9E\x16\x8E\xA3\x9E\x1A\x29\x8D\x20\x37\xAC\xA0\x5A\x71\x9E\x71\x37\x91\xA0\x89\xA1\x8D\x7A\xD0\x16\xA4\x90\x63\xB8\x8A\x8F\x14\x7D\x9E\x35\xFF\x90\x91\x81\x8E\xA3\xA4\x40\x92\x86\x49\x8A\x94\x7C\x95\x80\x04\xA5\x0D\xAE\xA4\x19\x30\xA1\x20\x99\xAA\x9D\xA0\xF3\x93\x07\x4D\x82\x29\xA6\x78\xB4\xA6\xA7\x12\xA1\xAB\x28\xA0\xA5\xA1\x3B\x94\x61\x8F\x7B\x81\x9E\x1F\xCD\xAC\xAD\x8B\x90\xAD\x6F\x25\xB4\x84\x55\x8C\x9D\x99\x6A\x98\x31\x92\xB5\x73\x92\x5F\xE8\x20\xB0\xDF\x75\x01\x93\x01\x3B\x90\x47\xE3\x9F\x93\x13\x94\xA4\x94\xCF\x26\x9B\x29\xAE\x81\xB3\xE8\x24\xA3\x95\x53\xB6\x84\x4A\x87\x71\x97\xA2\x7B\x83\xB2\xEE\x77\x96\x65\xD1\xA2\x88\xFB\x7D\x90\x6C\xBF\x9F\x7F\x63\x83\x8E\x34\x28\x85\x9B\x85\x53\x89\x99\x15\xA6\x20\x08\xC8\x43\xB6\x22\x32\x61\x21\xE5\x6E\x67\x92\x5B\x2B\x26\xB7\xF8\x98\x32\x09\xC6\x64\x97\x8F\x91\x69\x34\x97\xA2\x04\xD6\x2D\x34\x71\x5E\x8A\xA9\xAB\x60\xA0\x0B\x42\xAE\x73\xB9\xB9\x74\xAF\xB8\xAA\x82\x04\xE0\x02\x7C\xB9\xC2\x65\x7B\xA3\x5F\xB7\xA0\x19\x52\xBC\x6C\xEA\xA0\x72\x74\x88\x65\x76\xC2\x7F\x82\x05\xD4\x66\x9A\xB0\x00\x06\xAE\x56\x9A\x0B\x24\xFA\xB7\xB1\x0F\x3C\xA5\x8D\x36\xDB\x94\x0D\x0B\x2B\x26\xBF\x00\x20\x9F\x4C\xDA\xA4\x9D\xDA\xA5\x3F\xBE\x8D\x80\x23\x23\xC7\x38\x61\xF5\xBC\xB9\x5F\x02\x39\x5E\x80\xEE\x65\xC1\x8D\x40\x25\x63\x82\x30\x06\x6D\xF1\xB9\xC3\x4B\x91\x0B\x25\x1F\xDD\x71\x86\xF0\x6A\x26\x18\x02\x84\x2B\x06\x9F\x8E\xEB\x02\x87\xB8\x64\xA0\x04\x2A\x44\x3A\x24\x79\xAA\x66\x24\x18\x3C\x9E\x75\x40\x16\xC0\x00\x18\xC5\xC7\x0D\xE5\xC0\x73\x3B\x0B\x25\x90\xA2\xC5\xC6\x12\xD9\xC7\xC4\x5D\x3F\x28\x08\x2B\xC2\x69\x16\xCD\x80\xC6\x56\x22\x31\x8E\xFE\x5C\xC3\x1E\xC7\xC5\xCA\x16\x30\x04\xCE\x43\xC5\x20\x2E\xF4\xC1\xCB\x46\xD5\xC4\x92\xA9\xC4\x62\x26\xF9\x68\x34\x2E\xD0\xC9\x51\x26\x2A\xC6\x1E\xD9\xCC\x39\x05\x30\xCF\x8F\xFB\xB1\x71\x88\x40\x25\x33\xE0\x83\xC5\x39\xED\xC1\x72\xC1\x31\x06\xC7\x7E\xCE\x04\x0D\x3E\x1B\x24\x42\xC4\xCE\x22\x31\x01\xCC\xA2\x82\x8F\x3B\xF0\x2C\xBB\x87\x25\xC2\x83\x7D\x79\x31\x70\x17\xE7\x3A\x30\x74\xAD\x3F\xFC\x00\x75\x2F\xF0\x1A\x6C\x7C\x33\xDA\x25\xA2\xC2\x64\x75\x1A\xE1\xD6\xCF\x8A\xD9\x0D\x0C\x0C\xD0\x3C\xF1\x05\x6E\x0B\x5C\x71\xD2\xD0\x13\xDA\x3E\x4B\xF3\x38\xD3\xA0\xBA\xD3\xF6\x45\x08\x0F\x31\x2C\x0D\x0E\x73\x09\x0E\x1D\x0D\x32\x0E\x50\xFC\xCD\x60\x88\xC0\xD2\x49\x31\x07\x92\x55\x2B\x26\xD9\x87\xCA\xD5\xAA\xAB\xD2\x69\x46\xEE\xD2\x04\xB0\xCB\xCB\x91\xB3\xD8\x3F\x5A\xCD\x87\xD2\xB4\xB9\xD0\x1C\x73\x7C\xD6\x5F\xC0\xDA\xD8\xC4\xC4\x7F\x74\xA8\xD2\x68\x51\xEC\xD6\xD1\x9E\xB1\xD7\xB6\xA0\x04\xD7\x4A\xDF\xDF\xD6\xE1\xD9\xD7\xB8\xDB\x7C\xD3\x8A\x13\xD6\xBB\xC7\xD8\xC9\x1E\x32\x0A\xD8\x8B\x07\x61\x06\xB8\x0B\x25\xC2\xD1\xD9\x62\x52\xE2\xD7\xD4\x06\x69\xD6\x0C\x6F\xD7\xDB\x15\x32\xDB\xD9\x92\xDD\xDA\xBD\xC9\x90\xDC\x8B\x22\xDB\x7E\x55\x0E\x0F\x74\x20\xDB\xDD\x88\xED\xD8\x60\x14\xEC\xBD\x0B\x17\xEB\xD0\x6E", +"\xD4\xD4\x0C\xB6\xDA\x3A\x49\x1F\xE7\x91\x3A\x22\x0A\x3C\xB1\x6D\xB9\xD7\x53\xC8\x20\x37\xC3\xE5\xE0\x03\xE2\xD0\x29\x2B\x23\xE8\x86\xD2\xE1\xE5\x45\x6B\xE6\xB6\x98\xEE\xE4\x6F\xDC\xE0\xDF\x16\x3E\xA1\xFB\x3A\xDB\x94\x9B\xF8\xE1\x0C\x3A\xFD\x0D\xC9\x86\xE7\xE9\x6A\xED\xD4\xBD\x16\xEB\xE9\xCB\xF4\xDA\xE2\x98\xF7\xDA\xE6\x51\xF4\xE5\xD1\x21\xE3\xE5\xAE\x41\xE2\xD4\x40\xEC\xD9\x0C\x50\xD5\x20\xBA\xDF\xCA\xDA\x27\xEC\xE8\x08\x56\xD0\xA1\x78\xE2\xE9\x0F\x26\xCD\xEB\xC6\xA0\x0D\xE3\x3C\x2A\xEA\xBB\x5F\x3E\xDF\xA7\x8A\xA5\xBC\x76\xFF\xEC\xDA\x7B\xFF\xEB\x5B\xD9\xD2\xD6\xB2\xEF\xE1\xE6\x3A\x27\xF1\xB9\xBF\xD1\xD9\x61\xCF\x0D\xD8\x6E\xF4\xCA\xA8\xF0\xC2\x20\x39\xC1\xD4\xCE\x64\x16\xCC\x00\x78\xC7\xEF\x44\xFB\xCA\xF4\x00\x60\xEB\xC1\x32\x05\xE9\x82\x35\xF7\xEE\x0D\xFF\xEF\xC4\xDE\xEE\xD1\xB7\xA1\xEE\xDD\x82\xE6\xEF\xD3\xE8\xE6\xF0\x7D\xE0\xE2\xE4\x92\x2A\xDD\xE3\xA6\xEA\xF7\x94\xEF\xAA\xE9\xC0\xF6\xF2\xD3\x84\xF0\xEB\xE2\xC2\xA0\x04\x54\xFC\x7A\xD5\xF1\x28\xEA\x80\xF0\xF6\x60\xA4\xE1\x22\xE9\x86\x6D\xC1\x85\x7C\xBA\xF5\xAC\xF8\x61\x81\xC1\x50\x20\x57\x7A\x21\x9B\xE8\xFD\xCE\x49\x59\x98\x67\x6E\x82\x25\x9B\x77\xF9\x9B\x8D\x80\x6C\xE7\x7E\x48\xDA\xD5\x71\x78\x39\x74\x72\x10\x76\x72\x6A\xD3\x68\x74\xD8\x64\x37\x95\x75\x6F\xC2\x74\x7D\xC4\x7A\x79\xBD\x6C\x79\xE8\x6F\x79\xCA\x7D\x7A\x07\x8C\x7B\xD7\x6A\x3E\x65\x63\x6F\x0C\x88\x79\xB8\x67\x7D\xD9\x7D\x6F\x9E\x69\x75\x6F\x71\x7B\x57\x61\x32\x33\x05\x7B\x02\x17\x7B\xEA\x79\x77\x06\x78\x80\x2B\x7B\x81\x7A\x7D\x81\x67\x79\x79\xC6\x75\x73\x37\x7C\x7D\x59\x7B\x75\x03\x7D\x75\x91\x70\x6F\x22\x06\x71\x32\x83\x76\x34\x83\x7C\x36\x80\x82\xFB\x6B\x76\xC8\x7E\x06\xE4\x3C\x7E\x00\x0E\x7E\xEA\x5B\x30\x01\x25\x10\x53\x8F\x7E\xEB\x55\x7E\xDA\x41\x38\xE1\x70\x10\x70\x69\x67\xF3\x7B\x5E\x05\x6E\x63\x96\x39\x5B\x00\x1B\x5B\x0C\x64\x03\x9C\x35\x10\x69\x8A\x53\x9F\x35\x34\xE8\x55\x6A\x16\x19\x4D\x6F\x59\x3A\x4E\x80\x85\x5F\x8B\x30\x86\x15\x10\x79\x86\x85\x0B\x38\x85\x23\x32\x07\x74\x0B\x85\x00\x00\x67\x14\x3E\x85\x71\x80\x86\x75\x82\x7F\x87\x8B\x30\x0F\x0B\x12\x8D\x8F\x7F\xF4\x7F\x87\x74\x00\x61\x01\x19\x2F\x29\x3C\x87\xC8\x32\x86\x6E\x36\x55\x58\x58\x16\x7E\x8E\x30\x80\x84\x89\x00\x16\x89\x15\x3C\x86\x6F\x3A\x89\xC7\x12\x88\x72\x66\x39\x22\x30\x8A\x74\x0F\x31\x01\x17\x89\x96\x3A\x31\xDF\x79\x65\x09\x60\x00\xAD\x3D\x61\xD9\x42\x89\xF1\x70\x10\x85\x87\x77\x36\x65\x82\x35\x60\x8B\xFF\x7A\x65\x92\x84\x86\x00\x07\x32\x97\x83\x62\xC2\x88\x68\xB7\x89\x8B\xCB\x6F\x89\x0F\x3D\x8B\x28\x35\x8A\x06\x8D\x8C\xAA\x64\x8C\x02\x7C\x6C\xC7\x84\x39\xB1\x80\x02\x16\x8F\x8C\xCE\x4B\x54\x7E\x46\x5F\x05\x16\x8E\x72\x56\x49\xBB\x8E\x8A\xF6\x71\x10\xDD\x4F\x8B\xE9\x87\x3C\x3E\x02\x8E\xF7\x55\x58\x16\x0B\x12\xF7\x85\x8F\xD7\x4E\x3B\x92\x8C\x55\x00\x1D\x4E\xB2\x8E\x4F\x7E\x4E\x03\x9C\x83\x8E\xD0\x52\x5E\x1C\x0B\x12\x09\x97\x5F\xF9\x52\x3E\xD2\x80\x88\x00\x65\x10\x11\x90\x8F\x03\x60\x56\x04\x90\x5F\xF2\x50\x56\xD4\x45\x10\x1B\x99\x91\xE2\x5D\x8A\x0F\x39\x8F\x05\x12\x92\x01\x9D\x52\x16\x94\x8F\xF1\x5B\x58\x74\x05\x90\xFA\x8F\x4F\x82\x68\x58\x00\x1A\x58\x02\x9E\x49\x71\x3B\x3C\xAB\x5E\x43\x74\x59\x4A\xC9\x5C\x4A\x7B\x5F\x5D\x9D\x53\x4B\x39\x92\x5A\x3F\x48\x57\xBB\x46\x5A\xAF\x48\x5A\xFD\x3A\x5A\x42\x5C\x5A\x05\x41\x1B\x18\x54\x45\xCB\x42\x65\x2C\x99\x92\xE1\x52\x4F\xFE\x80\x00\x5E\x56\x92\x1F\x95\x03\xF7\x45\x10\x5D\x96\x8A\x0D\x94\x06\x68\x50\x54\x73\x44\x54\x76\x46\x54\x19\x51\x57\x2A\x94\x57\x66\x92\x52\xB8\x44\x5A\x98\x5A\x57\x9A\x54\x72\xE5\x55\x91\xE2\x57\x63\x6B\x90\x5A\x6D\x96\x50\x70\x94\x3F\x46\x9D\x07\x40\x0D\x29\x3D\x75\x8B\x03\x72\x2D\x48\x1A\x13\x0F\x2D\x2D\x19\x19\x88\x90\x8B\x5E\x86\x9A\x88\x79\x02\x20\x21\x00\x2D\xFF\x08\x8A\x98\x1A\x8D\xB3\x56\x11\x02\x23\x02\x94\x98\x8D\x30\x0F\x98\xFF\x72\x20\x25\x0D\x99\x84\x91\x03\xA0\x92\x70\x02\x27\x02\x94\x98\x92\xF1\x8F\x15\x98\x91\x95\x26\x12\x20\x29\x04\x99\x53\x9E\x91\xF2\x4F\x9A\xC7\x18\x98\x2B\x1B\x02\x94\x9F\x01\xF3\x2C\x2A\xEB\x2F\x0F\x02\x2B\x2E\x89\x95\x9C\xC6\x91\x27\xC1\x90\x27\x7C\x27\x9C\x2B\x1A\x9C\xD2\x24\x9C\xC6\x98\x8D\x32\x02\x2D\x28\x0C\x9C\x83\x97\x9D\xDB\x82\x2D\x26\x06\x9D\xFE\x7D\x9D\x25\x6A\x9C\x02\x24\x8D\xD8\x59\x4B\x1B\x6B\x5D\x83\x34\x07\x96\x98\x16", +"\xFF\x01\x9C\xD2\x2B\x27\xC7\x9E\x9C\x2B\x10\x9D\xC5\x92\x9D\xD4\x9C\x9D\x02\x18\x8D\xA6\x9B\x12\xDB\x96\x9F\x17\x64\x98\x30\x00\x9E\x2B\x12\x9E\x7A\x38\x5C\x40\x41\x70\xCB\x5A\x35\xE9\x9A\x99\xC0\x94\x20\xAB\x2F\x9B\xCC\x9E\xA0\xCF\x9C\x9F\xFD\x98\x9D\x18\x35\x9F\x12\xA8\x9F\xDA\x92\xA1\x3B\x6E\x9F\xC5\x9B\x9E\x04\x2A\x63\x00\xA5\x9C\x10\xA7\x2A\xFC\x99\xA0\x79\x02\x2D\x2C\x0A\xA1\xB5\x96\x97\xF2\x42\x9F\xBC\x17\x65\x3E\x42\x20\xAC\x9A\x92\x1E\xAC\x20\x82\x99\x14\x1A\xAB\x27\xED\x9A\xA1\x26\xA8\xA2\x2A\xA8\x91\x2C\xAE\x38\x0C\x21\x9C\x82\x8A\x63\xC7\x9B\x2E\x3B\xA2\xA1\x26\xA3\xA4\x04\x2A\x9C\xEE\x91\x9D\xA0\x2B\x12\x0E\xA7\x9C\x3D\xAB\x12\x22\x0A\xA1\x8C\x92\x70\xD9\x41\xA1\x17\xA4\x98\xD3\x9B\x12\xD5\x9D\xA5\x14\xAE\x67\x19\xA2\xA6\xDE\x99\x61\x21\xA5\x10\x02\xA0\x1A\xF1\x35\x9E\x81\x37\x9E\x26\xA5\xA3\xFA\x29\xA4\xFC\x9A\x63\xD2\x23\xA5\xC6\x95\xA5\x08\x17\xA5\x12\xA9\xA5\x98\x8C\xA5\x75\xAE\xA5\x16\xA1\xA8\x63\xAB\x6C\x65\xA4\xA8\x67\xA5\x63\x69\xA2\x10\x6B\xAB\x37\x05\xA4\x65\x07\xA4\x38\x4B\xAB\xA0\x0C\x2D\xA0\x1A\xA7\x9A\xE0\x2C\xA3\x27\x86\x39\xD2\x2C\xA7\xFC\x9E\xA7\x51\x84\x07\x80\xA6\x9F\xF4\x90\xA6\x1A\xA8\xA1\xFA\x97\xAA\x1C\xA2\x20\x72\xA0\x21\xEB\x2B\x2A\xC7\x9F\xA4\xC5\x98\x9B\x98\x1A\x9B\x08\x13\xA3\x33\x97\x3C\x8B\xA2\x7E\xCB\x11\x10\x3A\x90\x44\x59\xAC\x93\x9A\x58\xAB\xE4\x8D\x3B\xFF\x0B\x27\xC7\xA0\x29\xCA\xAC\xA4\x1F\x24\xA2\xAE\xA1\xA5\x08\x18\xAC\xAF\xA2\xA5\x04\x2B\x2E\xEB\x29\x86\xCF\xA8\x10\x4E\x82\x8A\x94\xA6\x1B\x08\x1E\x01\xD5\xAB\x1A\xDF\xA1\xAE\x08\x17\xA3\x02\x1D\x01\xE4\xA5\x10\xC8\x88\xAE\xBA\x2B\x12\x29\xAD\x2E\x1A\xA4\xAB\xA9\x12\x18\x32\xAD\x57\x54\x95\xAC\xBA\xA6\x9C\xAA\x8E\xAB\x42\x91\x3F\xC1\xA9\x59\xE2\x34\xAC\x7F\x5B\x8F\x3A\x6F\xAE\xFC\x92\xB0\x84\x5B\x8F\x78\xA2\xA1\x2B\xA5\x95\x8E\x3B\xAB\x00\x19\x87\x02\x19\x87\x7B\x97\x57\x92\x1E\xA0\x84\x23\x44\x0D\xBA\x95\xF2\x49\xAC\xDA\xAB\xAC\xFA\x26\xAD\x9B\x39\xAE\x40\x1B\x12\xE0\xAC\xAC\xAF\x22\xAE\x21\xBA\xB2\x02\x17\xB2\x2B\xB5\xAE\x2B\x1C\xAE\x2F\xBA\xAE\x31\xB4\xB2\x66\x21\xAD\x36\xB0\x10\x74\xA9\xAD\x2F\xA3\x28\xF1\x9E\x8D\xF0\xA2\xA1\xF2\xA9\x1B\x0A\xA7\xAB\xF6\xAD\x9A\x74\x00\xB1\x83\x8D\xAB\xCD\x1D\xAF\xB9\x4F\xAF\x72\x91\xB0\x47\xBA\x92\x3A\x68\x8C\xC7\x98\xB0\x16\x15\x58\x0B\xBC\x9F\x1B\xB7\x90\xF2\x4A\xB4\x12\xB1\x10\x14\xBF\x54\x6F\x93\x1D\x50\xB9\x48\x9A\x5D\xB5\x3B\x54\x53\x89\x9D\xAA\x01\x1F\x0F\xB7\x86\xAE\xD9\x29\xB3\x1B\xA6\x1A\xC6\x9B\x2E\x4A\xBB\xAF\x4D\xB5\x59\x43\x92\x19\x67\xB7\x52\x58\xBF\x3A\xFB\x8D\xAD\x3C\xB7\x1D\x39\xA1\xAF\x95\x10\x00\x99\x91\x99\xF6\xA2\x41\x06\x99\xB0\xFF\x49\xB7\x4C\xB0\x00\xBF\xA3\x1D\x18\xB1\x10\x43\x41\xB8\x85\x5E\xB1\xFA\x2B\x27\x59\xA5\xB8\xC2\x2C\xB2\x6F\xBB\x2E\xDC\xAE\xB2\xA0\xBD\x17\xE3\xA8\xB2\x02\x12\xB7\x00\x12\xB3\xA7\xB9\x8C\x35\xBA\xBA\x73\xB8\x10\x19\x04\xB7\x4E\xA4\xB7\x3B\xB3\xBA\x57\x69\xA9\xED\xA8\x10\x06\xBD\x1D\x88\xB6\xB7\x96\x10\x9B\x45\xBC\x3A\x53\xB9\xAB\x5F\x12\xB9\x08\x10\x67\x95\xB7\xB1\xD4\xA0\x10\x99\xB7\xBC\xF8\xAF\x15\x05\xBA\xA1\x9A\xBA\xB0\x1A\xA2\x20\x6A\xB6\x11\x61\x90\xB6\x85\x11\x10\x15\xB5\xB6\xCE\xBE\xB3\xD0\xB6\x3F\xDB\xB8\x5F\x34\x5C\xB9\x02\x1F\xB9\xBA\xBD\xBB\x05\x1B\x01\x74\xBB\xAD\x74\xB4\x1C\xA6\xBD\xBE\x05\x15\xBA\x74\xBC\xBA\x00\x0E\xBA\xF6\xB3\x33\xB1\xB3\xB3\x35\x2E\xAC\xFD\xB4\x27\x02\xC8\x9C\xBB\xB4\x2F\x3F\xB6\x32\xD0\xAC\x9F\x43\xB8\x1C\xC5\xBE\xB8\x46\xBD\x92\x7E\x4A\xBC\x71\x6C\xAF\x7C\xB1\x3F\x97\xB5\xBE\x79\x07\xBD\xFF\x45\xB5\xD6\xB2\xBD\x03\xBF\x4F\x5B\xB6\x9F\xE7\xBD\xBD\xC6\x91\xB6\x11\xB0\xBE\x64\xB3\x5A\x66\xB0\xB2\xC2\xA2\x3E\x25\xCC\xB6\x0F\x2E\xB6\x71\x21\xB7\x09\xC0\xC0\x1C\x39\xB8\x0F\x28\xB7\xFA\xA3\xB9\xCD\xBE\x06\x19\xC0\x00\xD1\xB1\xC1\xF7\xA1\xC2\x7E\x42\xBB\x71\x2A\x63\xAA\x77\xA4\x37\xCF\x20\xDC\xA9\x2F\xE1\xB9\x17\xDA\xB0\xA4\x0E\xB9\x36\xAC\xA1\x9C\x8F\x84\xB3\xD9\xBD\xB6\xC1\x9A\x63\xC4\x1C\xC4\xEE\xBE\xC4\x2A\xB3\x4C\x4E\x97\x3D\xF5\xA4\xC4\x48\xBB\xC5\x03\xC6\xC0\xCB\xBA\xC6\x38\xC1\x27\x7B\x2C\xAD\xC3\x95\xC0\xCB\x98\x9D\x02\x12\xAB\x89\x91\xC3\x5A\x53\xC2\xDC\x93\xA9\xD6\x94\xC3\xAC\x20\xA2\x87\xB1\xB4\x5A\xCC\xB5\x54\xCC\xB1\x8E\x3E\xA2\x86\xB4\x25\x16\xC1\x1C\x67\xC6\xBC\x12\xC6\xAC\xC1\x9A\xBF\xD2", +"\x20\xC6\x38\xAA\xC0\x0C\xB7\xC8\x5E\xB2\xA4\x1A\xA0\xC8\xFF\x09\xC5\xFE\xBE\xC6\x6F\xC4\xB8\xF1\x1A\xA1\x8A\xCB\x20\x0D\xC6\xAB\x90\xCB\xCA\x48\xBA\xBE\x6F\xBE\xB9\x77\xBE\xAE\xCD\x91\xBC\xDE\xAA\xB8\xC4\xBC\xB8\x44\xC0\xC1\x45\xC0\xB9\x7E\x45\xBD\x12\xAC\xC1\x7E\x4C\xC7\xD6\x9A\xC7\x60\x5E\xBD\x08\x13\xB6\x2E\x56\xB1\x40\xCF\xBC\x42\xC6\xBE\x9A\xCB\xB6\x5A\x5E\xCA\xED\x71\xCB\x98\xC5\x10\x4A\xB2\x20\xA9\xC4\xAF\x8D\xBE\x48\x8F\xB9\xB5\x04\xB0\xB4\x07\xB0\xC2\xBC\xCD\x3B\xC2\xCC\x9C\xC4\xC2\x5E\xC6\xCA\x87\x2A\xC9\xCC\xE2\xBE\x06\x7F\xBA\x48\xE7\xC2\x4F\xC6\x9E\xC9\xEB\x20\xCA\x6E\xC2\xCD\xAC\x2B\x27\xB7\x83\xC7\x08\x1B\x9F\x2E\x24\x65\x02\x1E\xCF\xF6\x96\xA2\xE5\xC7\x9C\x9E\x98\xCF\x53\x8B\xC3\xF0\x57\xC7\x00\xD8\x4E\x9A\xAC\xC8\xF7\x57\xCA\x3A\xBB\xC0\xC7\x52\x20\x9E\x92\xCA\xFC\x94\xCF\xDF\xB8\xD1\xF9\xC4\x20\x7B\x27\x95\x3A\x60\xC8\xEB\x20\xBF\x48\xCF\x84\xA2\xBC\xC6\xB5\xCD\xB2\x74\xB8\xBF\x25\xDA\xBF\xFC\xB8\xD2\xA1\xC5\x10\x2F\xD0\x00\xEB\x21\xA6\xFF\xC6\xC7\x01\x16\xD3\xA4\xAE\x9F\x05\xD0\xA5\x85\xA8\x68\xF8\xCD\x8E\x13\xA3\xCA\xD7\xA1\xBF\x27\xD4\xCA\xA8\xB5\x10\xF5\xB0\xD3\x95\x86\xB2\xF9\xBF\xBF\xAF\xBB\xAE\x4D\xC1\x10\x33\xDB\x27\x3A\x63\xD3\x06\xDE\x9F\x12\xD5\xB7\xDD\x9C\x80\x16\xD5\x9A\x9E\xCE\xA0\x56\x5E\xA0\x80\xC7\xBB\x25\xD9\xBB\x4C\xD4\x21\xCC\xCF\x20\x7B\x2A\xBF\x02\xDC\x9D\x9E\x9B\xD5\x01\x78\x62\xC7\x3F\xD5\x3F\xD0\x78\x1D\xA1\x9C\xEB\x28\xC2\xCC\x9B\xD5\xD8\xC9\xB8\x6A\x6A\xCA\xF7\x9E\x9F\xF8\xC8\xCF\x20\xD4\xB7\x23\xD6\xD4\x08\x1C\xAD\x80\xC4\xBF\x2B\xDE\xD4\x2D\xD0\xD5\x6B\xC0\xBB\x08\x13\xD3\x35\xDB\xD6\xDC\x9A\x8D\x81\xDA\xCD\x38\xD3\xD4\x25\x6A\x63\x3A\xD0\xD7\x3C\xDC\xD1\x5C\xD3\xD8\xFF\x71\x03\x41\xDD\xD0\x69\xD0\x00\x2C\xD4\xD4\x23\xB5\xD2\xF2\xB5\xD2\x8E\xD1\xD9\x95\xD4\xB7\x52\xD1\xC6\x54\xD8\xD9\xD6\x9A\xD9\x0D\x15\x15\x6B\x6F\xC0\x39\xC7\xD7\x30\x07\xD5\xAA\xA2\xDC\x72\xD4\x65\x5E\xDA\xDA\x5C\xD2\x6A\x61\xDB\xD0\x08\xC5\xD2\x66\xD3\xCA\x68\xD8\xD4\x00\x06\xA9\x22\xA4\xCB\x25\xBB\x10\xBD\xD1\x63\x9C\xDD\x9D\xA6\xD2\x70\x30\x0E\xD6\xC5\xD9\xA8\x59\x67\xDC\xD8\x94\xD7\x5F\x16\xD7\xE4\xD8\xD7\xC7\x9E\xC9\xD1\xD6\x9F\x3A\xAE\xDC\xD6\x9E\x99\x4A\xBD\xA8\x04\xA3\x1D\x6E\xAC\x5D\x08\xAB\xA9\x6E\x3E\xC9\xD3\xD1\xAB\x0B\xC8\x45\xE3\xDF\xDD\xDF\x96\x9C\xF6\xD1\x3F\x06\xA0\xA7\xFC\xD7\x1C\xAB\xD5\x99\xBA\xDD\xD7\x01\xEE\xD0\x66\xA4\xE0\x19\x6A\xC6\x1A\xD4\xBB\xA4\xD5\xD8\x7B\x21\x91\x01\xC5\xD2\x89\xD0\xDB\x47\xDD\xD8\x90\xD3\xCA\xAD\xDC\x2C\x23\xEC\xD0\x9D\xD0\x00\x4B\xDC\x9C\xF8\x96\xDE\x5D\xD5\x76\xEA\xD4\xE1\x06\x38\xCF\x22\x9D\xE1\xAE\xD8\x10\x24\xD3\xCA\xB1\xD3\xCA\xB3\xD4\xE2\x27\xE3\xBB\x05\x1B\x2E\x56\xD3\xD5\xF3\xD5\x9A\x3D\xD3\x9F\x5E\xAD\xDC\x08\x1B\x91\x28\xE3\xCA\x2E\xD6\xDB\x92\xD7\x20\x6D\xD6\xAA\x13\xE1\xDC\xDB\x8B\xD5\xA7\x9C\x77\x31\xE6\xE5\xA2\x69\xD7\x74\xB5\xBB\x1C\xDA\xE1\xFF\x53\xCB\x1E\xEB\x12\x39\xEF\xBA\x3B\xEF\xBA\x3D\xEF\xBA\x25\xE0\xE4\x2A\xD8\xB3\x29\xEB\xE2\x59\xD7\xD7\x31\x0E\xE2\xDF\xD9\xDC\x29\xEE\x73\x32\x04\xE3\x64\xE7\xE3\x6A\x8A\xD8\xF7\xB3\xBF\x3F\xEB\xDA\x6D\xE6\x2E\x44\xE5\xC7\xDE\xDE\xE6\xA2\xD4\xE7\x47\xE9\x98\xD2\x9A\xE4\x1C\x94\xC7\x80\xCF\xE4\x25\xD7\xDB\x89\x93\xE5\x08\x11\xDA\x45\xE4\xE7\x58\xEB\xC0\x5A\xEA\xDC\x3E\x71\x03\x5E\xE5\xD2\x67\xE7\xCF\xC1\x9B\x27\x0B\x97\xD3\x7E\xE2\x10\xD8\xA3\xD9\x69\xEA\xE8\x00\x1E\xA9\x4D\xEF\xDD\x02\x12\xEB\x8B\xEB\xDE\x32\x0D\xE8\x0F\x20\xAA\x77\x80\x16\xC1\x9E\xA0\xE6\x83\xEB\x93\xDB\xE6\x93\xD5\xE8\x03\x28\xE9\x41\xE3\xE0\x5C\xE0\x30\x9D\xE4\xC8\x9F\xE9\xE7\x90\x92\x03\xA3\xE3\xCA\xA5\xE6\xE1\xA7\xEA\x90\x92\xE2\xB2\x08\x1D\xEA\xAB\xDF\xEA\x86\xEB\xA7\x74\xCA\x63\xB6\xEB\xE9\xB8\xEA\xEB\x0B\x2C\xEB\x8B\x8E\xEB\x04\x20\xEC\xD9\xEA\xC3\x01\x1B\xE2\x80\xC6\xEC\x02\x28\xEC\x26\xE5\xE5\x9E\xDC\xEC\xC6\x99\xE5\x5F\x7B\xE5\xF7\xE6\x30\xF6\x9E\xC9\x94\xEC\x9F\x78\xCF\x20\x1B\x65\x78\xFC\xEB\xDC\x7E\x6A\xB4\x89\x21\x10\xED\x19\xA5\x22\x8F\x6F\xF8\x9D\xE0\x96\xE0\xDF\x0F\xDD\xB3\x00\x06\xF0\xA0\xE0\x99\x31\x0A\xF0\x24\xAD\x1E\xD4\x8B\x79\xE7\x6E\x79\x72\x01\xF1\xA4\xD3\xD9\x62\x13\xE8\xCC\x93\xF0\x0B\x25\xF0\xD5\x77\xF0\x7A\xEC\xF1\x70\xE0\x00\xED\x17\x9A\x6C\x72\x19\x8F\xE1\x9C\xF2\xE6\x9C\x2A\xF7\x20\x2C\xF4\x7C\x2E\xF1", +"\xED\x30\xFA\xEA\x0D\xFE\xC2\xDB\x79\x73\x74\x02\x9D\x19\xDA\xD7\xAF\xD8\xD1\x9E\xCB\x27\x20\x04\xCD\x05\x1E\xA0\x43\xE4\xBE\x9F\xA0\xB2\x98\x86\xEE\x3C\xFB\xE0\x98\x1F\xC7\xC9\x94\xC7\xC7\x93\xA2\xB5\xD6\xEF\x08\xF6\xA8\xA9\xA2\xF6\x3E\x7F\x9F\x06\xE1\xA0\x01\x13\x9E\x40\x49\xDF\x0A\xE0\xD1\xBB\xC0\x13\xEC\x9E\xF5\xC6\x90\xF6\x32\xDA\xEC\xFD\xE8\x68\x87\xAB\xD3\xC2\xD5\xDF\x6A\xF0\x10\x6C\xF3\x1D\x09\xED\x5D\x93\xAE\xC9\xD6\xD2\xF0\x11\xED\xBA\x78\xF3\xF6\x7A\xF5\xF6\x88\xA2\xE3\x59\x63\xC3\x5D\xF1\xF3\xF6\x90\x9F\xA9\xBF\xF8\xCB\xE6\x30\x83\xAC\xF7\xEB\xD9\x9F\xFD\xCB\xF8\x67\xFE\xF7\x9C\x1B\xF6\x03\xAD\xA6\x57\x66\x9E\x84\xFA\xF5\xEA\x93\xF7\x94\xFC\x9D\x96\xFA\xD4\xA0\xF1\xED\x9B\xF7\xEB\x90\xFA\x6A\x7B\xF4\xFB\x99\xF9\x65\xA2\xFA\xA6\xA4\xFC\xA6\xB9\x43\xF8\xFB\xD0\xF7\xAE\x3D\xE0\x87\xF6\x9F\x76\xFF\xE6\x98\xF9\xF7\x85\x94\xE5\xC9\xFC\xF8\xB6\xFE\xF8\x9C\xF5\xFB\x30\x05\xF2\x0D\xEE\xED\x25\xFE\xC9\x02\x23\xEE\xD4\xF2\xF9\x4D\xA4\xF7\xC5\x98\xA9\x01\x1A\xFD\xC7\x98\xEE\x79\x0B\xA5\x87\xE3\xE7\xB8\xE3\xFB\xE4\xE5\xFB\x9E\xF5\x10\x6F\xDB\xFE\xB9\xF0\x78\xBB\xFC\xA8\xBD\xFE\xA8\xF8\xD7\xFA\x6F\xA9\xFA\xC2\xF6\x39\xFE\xDE\xFD\x89\x90\xFE\xB1\x70\x4B\x56\x7B\x50\x53\xAA\x38\x7E\xF2\x7F\x52\x99\x71\xF6\x67\x6D\xDB\x70\xFF\x4A\x7C\xDA\x65\x4E\x07\x77\xF7\x50\x55\xB7\x76\xF1\x43\x7C\x75\x6E\x70\x54\x7D\xF2\x49\x7C\x00\x02\xFE\x46\x4C\xF9\x66\x7F\xB8\x6D\x01\x8E\x7E\x04\x85\x10\x1A\x74\x8B\x65\x4D\x0C\x87\x04\x82\x6F\x2B\x64\x20\x02\x10\x09\x1B\x7E\xCC\x4E\xBD\x7E\x7E\x85\x6D\xAC\x10\x83\xDF\x7E\x0C\xA5\x7C\x3C\x78\x7E\xFD\x62\xA9\x2A\x7E\xDC\x64\x10\xFF\x68\xEA\x76\x71\x07\x11\x01\x8F\x54\x76\x51\x54\xE8\x4E\x07\x8C\x5C\xC3\x7F\xE0\x57\x7D\x70\x42\x10\xEF\x78\x06\x87\x10\x19\x8D\xFA\x56\x4D\x7C\x7F\x7C\x66\x78\x32\x4F\x81\xC4\x45\x04\xF7\x7C\xDC\x68\x7D\xC1\x7D\x02\xBC\x7E\xD6\x7A\xEA\x14\x78\x21\x61\x68\x0A\x80\xBC\x73\x7E\x89\x15\xFF\x77\x6E\xCD\x73\x80\xFA\x7A\x0C\xAE\x1A\xE2\x7D\x04\xC2\x80\x01\x78\x82\xCD\x7F\xEC\x6C\x80\x06\x12\x20\x26\x82\x14\x9B\x83\xFA\x17\xBD\x5C\x4F\xE3\x79\xD3\x69\x82\xA8\x29\x81\xE8\x7A\xFA\x6B\x83\x3B\x3D\x06\xA6\x7F\x17\x99\x7F\x61\x83\x91\x71\x7B\x8B\x04\x06\xC2\x76\x75\x44\x84\x00\x0E\x0F\xBE\x69\xCE\x78\x08\x9B\x86\x22\x89\x7B\xA3\x78\xF0\x79\x80\x23\x8D\x9D\x48\x81\xE1\x61\x4E\xC5\x7C\x3B\x57\x83\x12\x86\x08\xE4\x50\xF4\x66\x80\xCE\x7B\xFA\x74\x5A\xE1\x4B\x12\x2A\x03\x1F\x8D\x6F\x5D\x65\xCF\x76\x4E\x6D\x79\x98\x1B\x31\x8C\x5B\x66\x0A\x35\x9B\x42\x5D\x7F\x20\xF0\x1B\x80\xF5\x78\x7E\xB2\x67\x16\x93\x76\x08\x12\xC8\x12\x53\x2A\x82\x08\xBF\x5C\x3B\x71\x67\x44\x69\xA7\x30\x52\x50\x4F\x64\xBA\x65\x95\x53\x64\x63\x86\x07\x93\x6A\xEF\x5F\x51\x08\x0D\x13\x5C\x5E\x19\x6F\xBA\x7F\x05\x91\x4A\x86\xA2\x60", +}; + + void GuiIqGetParserBuffer(vl::stream::MemoryStream& stream) + { + vl::stream::MemoryStream compressedStream; + for (vint i = 0; i < parserBufferRows; i++) + { + vint size = i == parserBufferRows - 1 ? parserBufferRemain : parserBufferBlock; + compressedStream.Write((void*)parserBuffer[i], size); + } + compressedStream.SeekFromBegin(0); + vl::stream::LzwDecoder decoder; + vl::stream::DecoderStream decoderStream(compressedStream, decoder); + vl::collections::Array buffer(65536); + while (true) + { + vl::vint size = decoderStream.Read(&buffer[0], 65536); + if (size == 0) break; + stream.Write(&buffer[0], size); + } + stream.SeekFromBegin(0); + } +/*********************************************************************** +Unescaping Function Foward Declarations +***********************************************************************/ + +/*********************************************************************** +Parsing Tree Conversion Driver Implementation +***********************************************************************/ + + class GuiIqTreeConverter : public vl::parsing::ParsingTreeConverter + { + public: + using vl::parsing::ParsingTreeConverter::SetMember; + + bool SetMember(GuiIqNameOption& member, vl::Ptr node, const TokenList& tokens) + { + vl::Ptr token=node.Cast(); + if(token) + { + if(token->GetValue()==L"Specified") { member=GuiIqNameOption::Specified; return true; } + else if(token->GetValue()==L"Any") { member=GuiIqNameOption::Any; return true; } + else { member=GuiIqNameOption::Specified; return false; } + } + member=GuiIqNameOption::Specified; + return false; + } + + bool SetMember(GuiIqChildOption& member, vl::Ptr node, const TokenList& tokens) + { + vl::Ptr token=node.Cast(); + if(token) + { + if(token->GetValue()==L"Direct") { member=GuiIqChildOption::Direct; return true; } + else if(token->GetValue()==L"Indirect") { member=GuiIqChildOption::Indirect; return true; } + else { member=GuiIqChildOption::Direct; return false; } + } + member=GuiIqChildOption::Direct; + return false; + } + + bool SetMember(GuiIqBinaryOperator& member, vl::Ptr node, const TokenList& tokens) + { + vl::Ptr token=node.Cast(); + if(token) + { + if(token->GetValue()==L"ExclusiveOr") { member=GuiIqBinaryOperator::ExclusiveOr; return true; } + else if(token->GetValue()==L"Intersect") { member=GuiIqBinaryOperator::Intersect; return true; } + else if(token->GetValue()==L"Union") { member=GuiIqBinaryOperator::Union; return true; } + else if(token->GetValue()==L"Substract") { member=GuiIqBinaryOperator::Substract; return true; } + else { member=GuiIqBinaryOperator::ExclusiveOr; return false; } + } + member=GuiIqBinaryOperator::ExclusiveOr; + return false; + } + + void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) + { + } + + void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) + { + SetMember(tree->childOption, obj->GetMember(L"childOption"), tokens); + SetMember(tree->attributeNameOption, obj->GetMember(L"attributeNameOption"), tokens); + SetMember(tree->attributeName, obj->GetMember(L"attributeName"), tokens); + SetMember(tree->typeNameOption, obj->GetMember(L"typeNameOption"), tokens); + SetMember(tree->typeName, obj->GetMember(L"typeName"), tokens); + SetMember(tree->referenceName, obj->GetMember(L"referenceName"), tokens); + } + + void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) + { + SetMember(tree->parent, obj->GetMember(L"parent"), tokens); + SetMember(tree->child, obj->GetMember(L"child"), tokens); + } + + void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) + { + SetMember(tree->first, obj->GetMember(L"first"), tokens); + SetMember(tree->second, obj->GetMember(L"second"), tokens); + SetMember(tree->op, obj->GetMember(L"op"), tokens); + } + + vl::Ptr ConvertClass(vl::Ptr obj, const TokenList& tokens)override + { + if(obj->GetType()==L"PrimaryQuery") + { + vl::Ptr tree = new GuiIqPrimaryQuery; + vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); + Fill(tree, obj, tokens); + Fill(tree.Cast(), obj, tokens); + return tree; + } + else if(obj->GetType()==L"CascadeQuery") + { + vl::Ptr tree = new GuiIqCascadeQuery; + vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); + Fill(tree, obj, tokens); + Fill(tree.Cast(), obj, tokens); + return tree; + } + else if(obj->GetType()==L"SetQuery") + { + vl::Ptr tree = new GuiIqSetQuery; + vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); + Fill(tree, obj, tokens); + Fill(tree.Cast(), obj, tokens); + return tree; + } + else + return 0; + } + }; + + vl::Ptr GuiIqConvertParsingTreeNode(vl::Ptr node, const vl::collections::List& tokens) + { + GuiIqTreeConverter converter; + vl::Ptr tree; + converter.SetMember(tree, node, tokens); + return tree; + } + +/*********************************************************************** +Parsing Tree Conversion Implementation +***********************************************************************/ + + vl::Ptr GuiIqPrimaryQuery::Convert(vl::Ptr node, const vl::collections::List& tokens) + { + return GuiIqConvertParsingTreeNode(node, tokens).Cast(); + } + + vl::Ptr GuiIqCascadeQuery::Convert(vl::Ptr node, const vl::collections::List& tokens) + { + return GuiIqConvertParsingTreeNode(node, tokens).Cast(); + } + + vl::Ptr GuiIqSetQuery::Convert(vl::Ptr node, const vl::collections::List& tokens) + { + return GuiIqConvertParsingTreeNode(node, tokens).Cast(); + } + +/*********************************************************************** +Parser Function +***********************************************************************/ + + vl::Ptr GuiIqParseAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex) + { + vl::parsing::tabling::ParsingState state(input, table, codeIndex); + state.Reset(L"QueryRoot"); + vl::Ptr parser=vl::parsing::tabling::CreateStrictParser(table); + vl::Ptr node=parser->Parse(state, errors); + return node; + } + + vl::Ptr GuiIqParseAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::vint codeIndex) + { + vl::collections::List> errors; + return GuiIqParseAsParsingTreeNode(input, table, errors, codeIndex); + } + + vl::Ptr GuiIqParse(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex) + { + vl::parsing::tabling::ParsingState state(input, table, codeIndex); + state.Reset(L"QueryRoot"); + vl::Ptr parser=vl::parsing::tabling::CreateStrictParser(table); + vl::Ptr node=parser->Parse(state, errors); + if(node && errors.Count()==0) + { + return GuiIqConvertParsingTreeNode(node, state.GetTokens()).Cast(); + } + return 0; + } + + vl::Ptr GuiIqParse(const vl::WString& input, vl::Ptr table, vl::vint codeIndex) + { + vl::collections::List> errors; + return GuiIqParse(input, table, errors, codeIndex); + } + +/*********************************************************************** +Table Generation +***********************************************************************/ + + vl::Ptr GuiIqLoadTable() + { + vl::stream::MemoryStream stream; + GuiIqGetParserBuffer(stream); + vl::Ptr table=new vl::parsing::tabling::ParsingTable(stream); + table->Initialize(); + return table; + } + + } +} + + +/*********************************************************************** +.\GUIINSTANCELOADER.CPP ***********************************************************************/ namespace vl @@ -893,13 +2064,14 @@ GuiInstanceLoaderManager rootLoader = new GuiDefaultInstanceLoader; } + GUI_PLUGIN_NAME(GacUI_Instance) + { + GUI_PLUGIN_DEPEND(GacUI_Parser); + } + void Load()override { instanceLoaderManager = this; - } - - void AfterLoad()override - { IGuiParserManager* manager = GetParserManager(); manager->SetParser(L"INSTANCE-ELEMENT-NAME", new GuiInstanceContextElementNameParser); } @@ -1079,8 +2251,9 @@ GuiInstanceLoaderManager } } + /*********************************************************************** -GUIINSTANCELOADER_PREDEFINEDINSTANCEBINDERS.CPP +.\GUIINSTANCELOADER_PREDEFINEDINSTANCEBINDERS.CPP ***********************************************************************/ namespace vl @@ -1351,18 +2524,19 @@ GuiPredefinedInstanceBindersPlugin class GuiPredefinedInstanceBindersPlugin : public Object, public IGuiPlugin { public: - GuiPredefinedInstanceBindersPlugin() + + GUI_PLUGIN_NAME(GacUI_Compiler_ParsersAndBinders) { + GUI_PLUGIN_DEPEND(GacUI_Parser); + GUI_PLUGIN_DEPEND(GacUI_Res_ResourceResolver); + GUI_PLUGIN_DEPEND(GacUI_Instance); + GUI_PLUGIN_DEPEND(GacUI_Instance_Reflection); } void Load()override { WfLoadTypes(); GuiIqLoadTypes(); - } - - void AfterLoad()override - { { IGuiParserManager* manager = GetParserManager(); manager->SetParsingTable(L"WORKFLOW", &WfLoadTable); @@ -1395,8 +2569,9 @@ GuiPredefinedInstanceBindersPlugin } } + /*********************************************************************** -GUIINSTANCELOADER_PREDEFINEDINSTANCEDESERIALIZERS.CPP +.\GUIINSTANCELOADER_PREDEFINEDINSTANCEDESERIALIZERS.CPP ***********************************************************************/ namespace vl @@ -2151,15 +3326,13 @@ GuiPredefinedInstanceDeserializersPlugin class GuiPredefinedInstanceDeserializersPlugin : public Object, public IGuiPlugin { public: - GuiPredefinedInstanceDeserializersPlugin() + + GUI_PLUGIN_NAME(GacUI_Instance_Deserializers) { + GUI_PLUGIN_DEPEND(GacUI_Instance); } void Load()override - { - } - - void AfterLoad()override { IGuiInstanceLoaderManager* manager = GetInstanceLoaderManager(); manager->AddInstanceDeserializer(new GuiTemplatePropertyDeserializer); @@ -2175,8 +3348,9 @@ GuiPredefinedInstanceDeserializersPlugin } } + /*********************************************************************** -GUIINSTANCELOADER_PREDEFINEDTYPERESOLVERS.CPP +.\GUIINSTANCELOADER_PREDEFINEDTYPERESOLVERS.CPP ***********************************************************************/ namespace vl @@ -2785,15 +3959,13 @@ Plugin class GuiCompilerTypeResolversPlugin : public Object, public IGuiPlugin { public: - GuiCompilerTypeResolversPlugin() + + GUI_PLUGIN_NAME(GacUI_Compiler_InstanceTypeResolvers) { + GUI_PLUGIN_DEPEND(GacUI_Res_ResourceResolver); } void Load()override - { - } - - void AfterLoad()override { IGuiResourceResolverManager* manager = GetResourceResolverManager(); manager->SetTypeResolver(new GuiResourceInstanceTypeResolver); @@ -2809,8 +3981,9 @@ Plugin } } + /*********************************************************************** -GUIINSTANCEREPRESENTATION.CPP +.\GUIINSTANCEREPRESENTATION.CPP ***********************************************************************/ namespace vl @@ -3407,7 +4580,8 @@ GuiInstanceContext L"presentation::elements::Gui*;" L"presentation::elements::text::*;" L"presentation::compositions::*;" - L"presentation::templates::*"; + L"presentation::templates::*;" + L"presentation::theme::*"; namespaceAttributes.Add(att); } FOREACH(Ptr, att, namespaceAttributes) @@ -3809,2789 +4983,7 @@ GuiInstanceStyleContext } /*********************************************************************** -GUIINSTANCESHAREDSCRIPT.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - using namespace parsing::xml; - -/*********************************************************************** -GuiInstanceSharedScript -***********************************************************************/ - - Ptr GuiInstanceSharedScript::LoadFromXml(Ptr resource, Ptr xml, GuiResourceError::List& errors) - { - if (xml->rootElement->subNodes.Count() == 1) - { - if (auto cdata = xml->rootElement->subNodes[0].Cast()) - { - auto script = MakePtr(); - script->language = xml->rootElement->name.value; - script->code = cdata->content.value; - script->codePosition = { {resource},cdata->codeRange.start }; - script->codePosition.column += 9; // rootElement->codeRange.start }, L"Script should be contained in a CDATA section.")); - return nullptr; - } - - Ptr GuiInstanceSharedScript::SaveToXml() - { - auto cdata = MakePtr(); - cdata->content.value = code; - - auto xml = MakePtr(); - xml->name.value = language; - xml->subNodes.Add(cdata); - - return xml; - } - } -} - -/*********************************************************************** -INSTANCELOADERS\GUIINSTANCELOADER_COMPOSITIONS.CPP -***********************************************************************/ - -#ifndef VCZH_DEBUG_NO_REFLECTION - -namespace vl -{ - namespace presentation - { - namespace instance_loaders - { - -/*********************************************************************** -GuiAxisInstanceLoader -***********************************************************************/ - - class GuiAxisInstanceLoader : public Object, public IGuiInstanceLoader - { - protected: - GlobalStringKey typeName; - GlobalStringKey _AxisDirection; - - public: - GuiAxisInstanceLoader() - { - typeName = GlobalStringKey::Get(description::TypeInfo::content.typeName); - _AxisDirection = GlobalStringKey::Get(L"AxisDirection"); - } - - GlobalStringKey GetTypeName()override - { - return typeName; - } - - void GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override - { - if (CanCreate(typeInfo)) - { - propertyNames.Add(_AxisDirection); - } - } - - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override - { - GetRequiredPropertyNames(typeInfo, propertyNames); - } - - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override - { - if (propertyInfo.propertyName == _AxisDirection) - { - auto info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver::CreateTypeInfo()); - info->usage = GuiInstancePropertyInfo::ConstructorArgument; - return info; - } - return IGuiInstanceLoader::GetPropertyType(propertyInfo); - } - - bool CanCreate(const TypeInfo& typeInfo)override - { - return typeName == typeInfo.typeName; - } - - Ptr CreateInstance(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos tagPosition, GuiResourceError::List& errors)override - { - if (CanCreate(typeInfo)) - { - vint indexAxisDirection = arguments.Keys().IndexOf(_AxisDirection); - if (indexAxisDirection != -1) - { - auto createExpr = MakePtr(); - createExpr->type = GetTypeFromTypeInfo(TypeInfoRetriver>::CreateTypeInfo().Obj()); - createExpr->arguments.Add(arguments.GetByIndex(indexAxisDirection)[0].expression); - - auto refVariable = MakePtr(); - refVariable->name.value = variableName.ToString(); - - auto assignExpr = MakePtr(); - assignExpr->op = WfBinaryOperator::Assign; - assignExpr->first = refVariable; - assignExpr->second = createExpr; - - auto assignStat = MakePtr(); - assignStat->expression = assignExpr; - return assignStat; - } - } - return nullptr; - } - }; - -/*********************************************************************** -GuiCompositionInstanceLoader -***********************************************************************/ - - class GuiCompositionInstanceLoader : public Object, public IGuiInstanceLoader - { - protected: - GlobalStringKey typeName; - - public: - GuiCompositionInstanceLoader() - { - typeName = GlobalStringKey::Get(description::TypeInfo::content.typeName); - } - - GlobalStringKey GetTypeName()override - { - return typeName; - } - - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override - { - propertyNames.Add(GlobalStringKey::Empty); - } - - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override - { - if (propertyInfo.propertyName == GlobalStringKey::Empty) - { - auto info = GuiInstancePropertyInfo::Collection(nullptr); - info->acceptableTypes.Add(TypeInfoRetriver::CreateTypeInfo()); - info->acceptableTypes.Add(TypeInfoRetriver::CreateTypeInfo()); - info->acceptableTypes.Add(TypeInfoRetriver>::CreateTypeInfo()); - return info; - } - return IGuiInstanceLoader::GetPropertyType(propertyInfo); - } - - Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override - { - auto block = MakePtr(); - - FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys()) - { - const auto& values = arguments.GetByIndex(index); - if (prop == GlobalStringKey::Empty) - { - auto value = values[0].expression; - auto td = values[0].typeInfo->GetTypeDescriptor(); - - Ptr expr; - if (td->CanConvertTo(description::GetTypeDescriptor())) - { - auto refComposition = MakePtr(); - refComposition->name.value = variableName.ToString(); - - auto refOwnedElement = MakePtr(); - refOwnedElement->parent = refComposition; - refOwnedElement->name.value = L"OwnedElement"; - - auto assign = MakePtr(); - assign->op = WfBinaryOperator::Assign; - assign->first = refOwnedElement; - assign->second = value; - - expr = assign; - } - else if (td->CanConvertTo(description::GetTypeDescriptor())) - { - auto refBoundsComposition = MakePtr(); - refBoundsComposition->parent = value; - refBoundsComposition->name.value = L"BoundsComposition"; - - auto refComposition = MakePtr(); - refComposition->name.value = variableName.ToString(); - - auto refAddChild = MakePtr(); - refAddChild->parent = refComposition; - refAddChild->name.value = L"AddChild"; - - auto call = MakePtr(); - call->function = refAddChild; - call->arguments.Add(refBoundsComposition); - - expr = call; - } - else if (td->CanConvertTo(description::GetTypeDescriptor())) - { - auto refComposition = MakePtr(); - refComposition->name.value = variableName.ToString(); - - auto refAddChild = MakePtr(); - refAddChild->parent = refComposition; - refAddChild->name.value = L"AddChild"; - - auto call = MakePtr(); - call->function = refAddChild; - call->arguments.Add(value); - - expr = call; - } - - if (expr) - { - auto stat = MakePtr(); - stat->expression = expr; - block->statements.Add(stat); - } - } - } - - if (block->statements.Count() > 0) - { - return block; - } - return nullptr; - } - }; - -/*********************************************************************** -GuiTableCompositionInstanceLoader -***********************************************************************/ - - class GuiTableCompositionInstanceLoader : public Object, public IGuiInstanceLoader - { - protected: - GlobalStringKey typeName; - GlobalStringKey _Rows, _Columns; - - public: - GuiTableCompositionInstanceLoader() - { - typeName = GlobalStringKey::Get(description::TypeInfo::content.typeName); - _Rows = GlobalStringKey::Get(L"Rows"); - _Columns = GlobalStringKey::Get(L"Columns"); - } - - GlobalStringKey GetTypeName()override - { - return typeName; - } - - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override - { - propertyNames.Add(_Rows); - propertyNames.Add(_Columns); - } - - void GetPairedProperties(const PropertyInfo& propertyInfo, collections::List& propertyNames)override - { - if (propertyInfo.propertyName == _Rows || propertyInfo.propertyName == _Columns) - { - propertyNames.Add(_Rows); - propertyNames.Add(_Columns); - } - } - - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override - { - if (propertyInfo.propertyName == _Rows || propertyInfo.propertyName == _Columns) - { - return GuiInstancePropertyInfo::Array(TypeInfoRetriver::CreateTypeInfo()); - } - return IGuiInstanceLoader::GetPropertyType(propertyInfo); - } - - Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override - { - auto block = MakePtr(); - - FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys()) - { - if (prop == _Rows) - { - auto indexColumns = arguments.Keys().IndexOf(_Columns); - if (indexColumns != -1) - { - auto& rows = arguments.GetByIndex(index); - auto& columns = arguments.GetByIndex(indexColumns); - - { - auto refComposition = MakePtr(); - refComposition->name.value = variableName.ToString(); - - auto refSetRowsAndColumns = MakePtr(); - refSetRowsAndColumns->parent = refComposition; - refSetRowsAndColumns->name.value = L"SetRowsAndColumns"; - - auto rowsExpr = MakePtr(); - rowsExpr->value.value = itow(rows.Count()); - - auto columnsExpr = MakePtr(); - columnsExpr->value.value = itow(columns.Count()); - - auto call = MakePtr(); - call->function = refSetRowsAndColumns; - call->arguments.Add(rowsExpr); - call->arguments.Add(columnsExpr); - - auto stat = MakePtr(); - stat->expression = call; - block->statements.Add(stat); - } - - for (vint i = 0; i < rows.Count(); i++) - { - auto refComposition = MakePtr(); - refComposition->name.value = variableName.ToString(); - - auto refSetRowOption = MakePtr(); - refSetRowOption->parent = refComposition; - refSetRowOption->name.value = L"SetRowOption"; - - auto indexExpr = MakePtr(); - indexExpr->value.value = itow(i); - - auto call = MakePtr(); - call->function = refSetRowOption; - call->arguments.Add(indexExpr); - call->arguments.Add(rows[i].expression); - - auto stat = MakePtr(); - stat->expression = call; - block->statements.Add(stat); - } - - for (vint i = 0; i < columns.Count(); i++) - { - auto refComposition = MakePtr(); - refComposition->name.value = variableName.ToString(); - - auto refSetColumnOption = MakePtr(); - refSetColumnOption->parent = refComposition; - refSetColumnOption->name.value = L"SetColumnOption"; - - auto indexExpr = MakePtr(); - indexExpr->value.value = itow(i); - - auto call = MakePtr(); - call->function = refSetColumnOption; - call->arguments.Add(indexExpr); - call->arguments.Add(columns[i].expression); - - auto stat = MakePtr(); - stat->expression = call; - block->statements.Add(stat); - } - } - } - } - - if (block->statements.Count() > 0) - { - return block; - } - return nullptr; - } - }; - -/*********************************************************************** -GuiCellCompositionInstanceLoader -***********************************************************************/ - - class GuiCellCompositionInstanceLoader : public Object, public IGuiInstanceLoader - { - protected: - GlobalStringKey typeName; - GlobalStringKey _Site; - - public: - GuiCellCompositionInstanceLoader() - { - typeName = GlobalStringKey::Get(description::TypeInfo::content.typeName); - _Site = GlobalStringKey::Get(L"Site"); - } - - GlobalStringKey GetTypeName()override - { - return typeName; - } - - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override - { - propertyNames.Add(_Site); - } - - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override - { - if (propertyInfo.propertyName == _Site) - { - return GuiInstancePropertyInfo::Assign(TypeInfoRetriver::CreateTypeInfo()); - } - return IGuiInstanceLoader::GetPropertyType(propertyInfo); - } - - Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override - { - auto block = MakePtr(); - - FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys()) - { - if (prop == _Site) - { - SiteValue site; - { - auto siteExpr = arguments.GetByIndex(index)[0].expression; - if (auto inferExpr = siteExpr.Cast()) - { - if (auto ctorExpr = inferExpr->expression.Cast()) - { - auto st = description::GetTypeDescriptor()->GetSerializableType(); - FOREACH(Ptr, argument, ctorExpr->arguments) - { - if (auto keyExpr = argument->key.Cast()) - { - if (auto valueExpr = argument->value.Cast()) - { - Value value; - if (st->Deserialize(valueExpr->value.value, value)) - { - vint propValue = UnboxValue(value); - if (keyExpr->name.value == L"row") - { - site.row = propValue; - } - else if (keyExpr->name.value == L"column") - { - site.column = propValue; - } - else if (keyExpr->name.value == L"rowSpan") - { - site.rowSpan = propValue; - } - else if (keyExpr->name.value == L"columnSpan") - { - site.columnSpan = propValue; - } - else - { - goto ILLEGAL_SITE_PROPERTY; - } - continue; - } - } - } - goto ILLEGAL_SITE_PROPERTY; - } - goto FINISH_SITE_PROPERTY; - } - } - ILLEGAL_SITE_PROPERTY: - errors.Add(GuiResourceError({ resolvingResult.resource }, attPosition, - L"Precompile: The value of property \"Site\" of type \"" + - typeInfo.typeName.ToString() + - L"\" is not in a correct format: \"row: column: [rowSpan:] [columnSpan:]\".")); - continue; - } - FINISH_SITE_PROPERTY:; - - { - auto refComposition = MakePtr(); - refComposition->name.value = variableName.ToString(); - - auto refSetSite = MakePtr(); - refSetSite->parent = refComposition; - refSetSite->name.value = L"SetSite"; - - auto call = MakePtr(); - call->function = refSetSite; - - auto GetValueText = [](const Value& value) - { - WString result; - auto st = value.GetTypeDescriptor()->GetSerializableType(); - st->Serialize(value, result); - return result; - }; - - { - auto arg = MakePtr(); - arg->value.value = itow(site.row); - call->arguments.Add(arg); - } - { - auto arg = MakePtr(); - arg->value.value = itow(site.column); - call->arguments.Add(arg); - } - { - auto arg = MakePtr(); - arg->value.value = itow(site.rowSpan); - call->arguments.Add(arg); - } - { - auto arg = MakePtr(); - arg->value.value = itow(site.columnSpan); - call->arguments.Add(arg); - } - - auto stat = MakePtr(); - stat->expression = call; - block->statements.Add(stat); - } - } - } - - if (block->statements.Count() > 0) - { - return block; - } - return nullptr; - } - }; - -/*********************************************************************** -Initialization -***********************************************************************/ - - void LoadCompositions(IGuiInstanceLoaderManager* manager) - { - manager->SetLoader(new GuiAxisInstanceLoader); - manager->SetLoader(new GuiCompositionInstanceLoader); - manager->SetLoader(new GuiTableCompositionInstanceLoader); - manager->SetLoader(new GuiCellCompositionInstanceLoader); - } - } - } -} - -#endif - -/*********************************************************************** -INSTANCELOADERS\GUIINSTANCELOADER_DOCUMENT.CPP -***********************************************************************/ - -#ifndef VCZH_DEBUG_NO_REFLECTION - -namespace vl -{ - namespace presentation - { - namespace instance_loaders - { - -/*********************************************************************** -GuiDocumentItemInstanceLoader -***********************************************************************/ - - class GuiDocumentItemInstanceLoader : public Object, public IGuiInstanceLoader - { - protected: - GlobalStringKey typeName; - GlobalStringKey _Name; - - public: - GuiDocumentItemInstanceLoader() - { - typeName = GlobalStringKey::Get(description::TypeInfo::content.typeName); - _Name = GlobalStringKey::Get(L"Name"); - } - - GlobalStringKey GetTypeName()override - { - return typeName; - } - - void GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override - { - if (CanCreate(typeInfo)) - { - propertyNames.Add(_Name); - } - } - - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override - { - GetRequiredPropertyNames(typeInfo, propertyNames); - propertyNames.Add(GlobalStringKey::Empty); - } - - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override - { - if (propertyInfo.propertyName == GlobalStringKey::Empty) - { - auto info = GuiInstancePropertyInfo::Collection(nullptr); - info->acceptableTypes.Add(TypeInfoRetriver::CreateTypeInfo()); - info->acceptableTypes.Add(TypeInfoRetriver::CreateTypeInfo()); - return info; - } - else if (propertyInfo.propertyName == _Name) - { - auto info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver::CreateTypeInfo()); - info->usage = GuiInstancePropertyInfo::ConstructorArgument; - return info; - } - return IGuiInstanceLoader::GetPropertyType(propertyInfo); - } - - - bool CanCreate(const TypeInfo& typeInfo)override - { - return typeName == typeInfo.typeName; - } - - Ptr CreateInstance(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos tagPosition, GuiResourceError::List& errors)override - { - if (CanCreate(typeInfo)) - { - vint indexName = arguments.Keys().IndexOf(_Name); - if (indexName != -1) - { - auto type = TypeInfoRetriver>::CreateTypeInfo(); - auto createExpr = MakePtr(); - createExpr->type = GetTypeFromTypeInfo(type.Obj()); - createExpr->arguments.Add(arguments.GetByIndex(indexName)[0].expression); - - auto refVariable = MakePtr(); - refVariable->name.value = variableName.ToString(); - - auto assignExpr = MakePtr(); - assignExpr->op = WfBinaryOperator::Assign; - assignExpr->first = refVariable; - assignExpr->second = createExpr; - - auto assignStat = MakePtr(); - assignStat->expression = assignExpr; - return assignStat; - } - } - return nullptr; - } - - Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override - { - auto block = MakePtr(); - - FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys()) - { - const auto& values = arguments.GetByIndex(index); - if (prop == GlobalStringKey::Empty) - { - auto value = values[0].expression; - auto td = values[0].typeInfo->GetTypeDescriptor(); - - Ptr compositionExpr; - if (td->CanConvertTo(description::GetTypeDescriptor())) - { - auto member = MakePtr(); - member->parent = value; - member->name.value = L"BoundsComposition"; - compositionExpr = member; - } - else if (td->CanConvertTo(description::GetTypeDescriptor())) - { - compositionExpr = value; - } - - if (compositionExpr) - { - auto refItem = MakePtr(); - refItem->name.value = variableName.ToString(); - - auto refContainer = MakePtr(); - refContainer->parent = refItem; - refContainer->name.value = L"Container"; - - auto refAddChild = MakePtr(); - refAddChild->parent = refContainer; - refAddChild->name.value = L"AddChild"; - - auto call = MakePtr(); - call->function = refAddChild; - call->arguments.Add(compositionExpr); - - auto stat = MakePtr(); - stat->expression = call; - block->statements.Add(stat); - } - } - } - - if (block->statements.Count() > 0) - { - return block; - } - return nullptr; - } - }; - -/*********************************************************************** -GuiDocumentInstanceLoaderBase -***********************************************************************/ - - template - class GuiDocumentInstanceLoaderBase : public TBaseType - { - public: - using PropertyInfo = IGuiInstanceLoader::PropertyInfo; - using ArgumentMap = IGuiInstanceLoader::ArgumentMap; - - GuiDocumentInstanceLoaderBase(const WString& _typeName, const WString& _styleMethod) - :TBaseType(_typeName, _styleMethod) - { - } - - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override - { - propertyNames.Add(GlobalStringKey::Empty); - TBaseType::GetPropertyNames(typeInfo, propertyNames); - } - - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override - { - if (propertyInfo.propertyName == GlobalStringKey::Empty) - { - return GuiInstancePropertyInfo::CollectionWithParent(TypeInfoRetriver>::CreateTypeInfo()); - } - return TBaseType::GetPropertyType(propertyInfo); - } - - Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override - { - auto block = MakePtr(); - - FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys()) - { - const auto& values = arguments.GetByIndex(index); - if (prop == GlobalStringKey::Empty) - { - auto refControl = MakePtr(); - refControl->name.value = variableName.ToString(); - - auto refAddDocumentItem = MakePtr(); - refAddDocumentItem->parent = refControl; - refAddDocumentItem->name.value = L"AddDocumentItem"; - - auto call = MakePtr(); - call->function = refAddDocumentItem; - call->arguments.Add(values[0].expression); - - auto stat = MakePtr(); - stat->expression = call; - block->statements.Add(stat); - } - } - - if (block->statements.Count() > 0) - { - return block; - } - return TBaseType::AssignParameters(precompileContext, resolvingResult, typeInfo, variableName, arguments, attPosition, errors); - } - }; - -/*********************************************************************** -GuiDocumentViewerInstanceLoader -***********************************************************************/ - -#define BASE_TYPE GuiTemplateControlInstanceLoader - class GuiDocumentViewerInstanceLoader : public GuiDocumentInstanceLoaderBase - { - public: - GuiDocumentViewerInstanceLoader() - :GuiDocumentInstanceLoaderBase(description::TypeInfo::content.typeName, L"CreateDocumentViewerStyle") - { - } - }; -#undef BASE_TYPE - -/*********************************************************************** -GuiDocumentLabelInstanceLoader -***********************************************************************/ - -#define BASE_TYPE GuiTemplateControlInstanceLoader - class GuiDocumentLabelInstanceLoader : public GuiDocumentInstanceLoaderBase - { - public: - GuiDocumentLabelInstanceLoader() - :GuiDocumentInstanceLoaderBase(description::TypeInfo::content.typeName, L"CreateDocumentLabelStyle") - { - } - }; -#undef BASE_TYPE - -/*********************************************************************** -Initialization -***********************************************************************/ - - void LoadDocumentControls(IGuiInstanceLoaderManager* manager) - { - manager->SetLoader(new GuiDocumentItemInstanceLoader); - manager->SetLoader(new GuiDocumentViewerInstanceLoader); - manager->SetLoader(new GuiDocumentLabelInstanceLoader); - } - } - } -} - -#endif - -/*********************************************************************** -INSTANCELOADERS\GUIINSTANCELOADER_LIST.CPP -***********************************************************************/ - -#ifndef VCZH_DEBUG_NO_REFLECTION - -namespace vl -{ - namespace presentation - { - namespace instance_loaders - { - - template - Ptr CreateSetControlTemplateStyle(types::ResolvingResult& resolvingResult, GlobalStringKey variableName, Ptr argument, const WString& propertyName) - { - auto createStyle = MakePtr(); - createStyle->type = GetTypeFromTypeInfo(TypeInfoRetriver>::CreateTypeInfo().Obj()); - createStyle->arguments.Add(argument); - - auto refControl = MakePtr(); - refControl->name.value = variableName.ToString(); - - auto refStyleProvider = MakePtr(); - refStyleProvider->parent = refControl; - refStyleProvider->name.value = propertyName; - - auto assign = MakePtr(); - assign->op = WfBinaryOperator::Assign; - assign->first = refStyleProvider; - assign->second = createStyle; - - auto stat = MakePtr(); - stat->expression = assign; - return stat; - } - -/*********************************************************************** -GuiComboBoxInstanceLoader -***********************************************************************/ - -#define BASE_TYPE GuiTemplateControlInstanceLoader - class GuiComboBoxInstanceLoader : public BASE_TYPE - { - protected: - GlobalStringKey _ListControl; - - void AddAdditionalArguments(types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceError::List& errors, Ptr createControl)override - { - vint indexListControl = arguments.Keys().IndexOf(_ListControl); - if (indexListControl != -1) - { - createControl->arguments.Add(arguments.GetByIndex(indexListControl)[0].expression); - } - } - public: - GuiComboBoxInstanceLoader() - :BASE_TYPE(L"presentation::controls::GuiComboBox", L"CreateComboBoxStyle") - { - _ListControl = GlobalStringKey::Get(L"ListControl"); - } - - void GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override - { - if (CanCreate(typeInfo)) - { - propertyNames.Add(_ListControl); - } - BASE_TYPE::GetRequiredPropertyNames(typeInfo, propertyNames); - } - - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override - { - GetRequiredPropertyNames(typeInfo, propertyNames); - BASE_TYPE::GetPropertyNames(typeInfo, propertyNames); - } - - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override - { - if (propertyInfo.propertyName == _ListControl) - { - auto info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver::CreateTypeInfo()); - info->usage = GuiInstancePropertyInfo::ConstructorArgument; - return info; - } - return BASE_TYPE::GetPropertyType(propertyInfo); - } - }; -#undef BASE_TYPE - -/*********************************************************************** -GuiTreeViewInstanceLoader -***********************************************************************/ - -#define BASE_TYPE GuiTemplateControlInstanceLoader - template - class GuiTreeViewInstanceLoaderBase : public BASE_TYPE - { - protected: - bool bindable; - GlobalStringKey _Nodes; - - public: - GuiTreeViewInstanceLoaderBase(bool _bindable) - :BASE_TYPE(description::TypeInfo::content.typeName, L"CreateTreeViewStyle") - , bindable(_bindable) - { - _Nodes = GlobalStringKey::Get(L"Nodes"); - } - - void GetPropertyNames(const typename BASE_TYPE::TypeInfo& typeInfo, collections::List& propertyNames)override - { - if (!bindable) - { - propertyNames.Add(_Nodes); - } - BASE_TYPE::GetPropertyNames(typeInfo, propertyNames); - } - - Ptr GetPropertyType(const typename BASE_TYPE::PropertyInfo& propertyInfo)override - { - if (propertyInfo.propertyName == _Nodes) - { - if (!bindable) - { - return GuiInstancePropertyInfo::Collection(TypeInfoRetriver>::CreateTypeInfo()); - } - } - return BASE_TYPE::GetPropertyType(propertyInfo); - } - - Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const typename BASE_TYPE::TypeInfo& typeInfo, GlobalStringKey variableName, typename BASE_TYPE::ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override - { - auto block = MakePtr(); - - FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys()) - { - if (prop == _Nodes) - { - auto refControl = MakePtr(); - refControl->name.value = variableName.ToString(); - - auto refNodes = MakePtr(); - refNodes->parent = refControl; - refNodes->name.value = L"Nodes"; - - auto refChildren = MakePtr(); - refChildren->parent = refNodes; - refChildren->name.value = L"Children"; - - auto refAdd = MakePtr(); - refAdd->parent = refChildren; - refAdd->name.value = L"Add"; - - auto call = MakePtr(); - call->function = refAdd; - call->arguments.Add(arguments.GetByIndex(index)[0].expression); - - auto stat = MakePtr(); - stat->expression = call; - block->statements.Add(stat); - } - } - - if (block->statements.Count() > 0) - { - return block; - } - return BASE_TYPE::AssignParameters(precompileContext, resolvingResult, typeInfo, variableName, arguments, attPosition, errors); - } - }; -#undef BASE_TYPE - - class GuiTreeViewInstanceLoader : public GuiTreeViewInstanceLoaderBase - { - public: - GuiTreeViewInstanceLoader() - :GuiTreeViewInstanceLoaderBase(false) - { - } - }; - - class GuiBindableTreeViewInstanceLoader : public GuiTreeViewInstanceLoaderBase - { - public: - GuiBindableTreeViewInstanceLoader() - :GuiTreeViewInstanceLoaderBase(true) - { - } - }; - -/*********************************************************************** -GuiTreeNodeInstanceLoader -***********************************************************************/ - - class GuiTreeNodeInstanceLoader : public Object, public IGuiInstanceLoader - { - protected: - GlobalStringKey typeName; - GlobalStringKey _Text, _Image, _Tag; - - public: - GuiTreeNodeInstanceLoader() - :typeName(GlobalStringKey::Get(L"presentation::controls::tree::TreeNode")) - { - _Text = GlobalStringKey::Get(L"Text"); - _Image = GlobalStringKey::Get(L"Image"); - _Tag = GlobalStringKey::Get(L"Tag"); - } - - GlobalStringKey GetTypeName()override - { - return typeName; - } - - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override - { - propertyNames.Add(_Text); - propertyNames.Add(_Image); - propertyNames.Add(_Tag); - propertyNames.Add(GlobalStringKey::Empty); - } - - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override - { - if (propertyInfo.propertyName == _Text) - { - auto info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver::CreateTypeInfo()); - info->usage = GuiInstancePropertyInfo::ConstructorArgument; - info->bindability = GuiInstancePropertyInfo::Bindable; - return info; - } - else if (propertyInfo.propertyName == _Image) - { - auto info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver>::CreateTypeInfo()); - info->usage = GuiInstancePropertyInfo::ConstructorArgument; - info->bindability = GuiInstancePropertyInfo::Bindable; - return info; - } - else if (propertyInfo.propertyName == _Tag) - { - return GuiInstancePropertyInfo::Assign(TypeInfoRetriver::CreateTypeInfo()); - } - else if (propertyInfo.propertyName == GlobalStringKey::Empty) - { - return GuiInstancePropertyInfo::Collection(TypeInfoRetriver>::CreateTypeInfo()); - } - return IGuiInstanceLoader::GetPropertyType(propertyInfo); - } - - bool CanCreate(const TypeInfo& typeInfo)override - { - return typeInfo.typeName == GetTypeName(); - } - - Ptr CreateInstance(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos tagPosition, GuiResourceError::List& errors)override - { - if (CanCreate(typeInfo)) - { - auto createItem = MakePtr(); - createItem->type = GetTypeFromTypeInfo(TypeInfoRetriver>::CreateTypeInfo().Obj()); - - vint imageIndex = arguments.Keys().IndexOf(_Image); - vint textIndex = arguments.Keys().IndexOf(_Text); - - if (imageIndex != -1 || textIndex != -1) - { - if (imageIndex == -1) - { - auto nullExpr = MakePtr(); - nullExpr->value = WfLiteralValue::Null; - createItem->arguments.Add(nullExpr); - } - else - { - createItem->arguments.Add(arguments.GetByIndex(imageIndex)[0].expression); - } - - if (textIndex == -1) - { - createItem->arguments.Add(MakePtr()); - } - else - { - createItem->arguments.Add(arguments.GetByIndex(textIndex)[0].expression); - } - } - - auto createNode = MakePtr(); - createNode->type = GetTypeFromTypeInfo(TypeInfoRetriver>::CreateTypeInfo().Obj()); - createNode->arguments.Add(createItem); - - auto refNode = MakePtr(); - refNode->name.value = variableName.ToString(); - - auto assign = MakePtr(); - assign->op = WfBinaryOperator::Assign; - assign->first = refNode; - assign->second = createNode; - - auto stat = MakePtr(); - stat->expression = assign; - return stat; - } - return nullptr; - } - - Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override - { - auto block = MakePtr(); - - FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys()) - { - if (prop == GlobalStringKey::Empty) - { - auto refNode = MakePtr(); - refNode->name.value = variableName.ToString(); - - auto refChildren = MakePtr(); - refChildren->parent = refNode; - refChildren->name.value = L"Children"; - - auto refAdd = MakePtr(); - refAdd->parent = refChildren; - refAdd->name.value = L"Add"; - - auto call = MakePtr(); - call->function = refAdd; - call->arguments.Add(arguments.GetByIndex(index)[0].expression); - - auto stat = MakePtr(); - stat->expression = call; - block->statements.Add(stat); - } - else if (prop == _Tag) - { - { - auto refNode = MakePtr(); - refNode->name.value = variableName.ToString(); - - auto refData = MakePtr(); - refData->parent = refNode; - refData->name.value = L"Data"; - - auto castExpr = MakePtr(); - castExpr->strategy = WfTypeCastingStrategy::Strong; - castExpr->type = GetTypeFromTypeInfo(TypeInfoRetriver>::CreateTypeInfo().Obj()); - castExpr->expression = refData; - - auto refProp = MakePtr(); - refProp->parent = castExpr; - refProp->name.value = L"tag"; - - auto assign = MakePtr(); - assign->op = WfBinaryOperator::Assign; - assign->first = refProp; - assign->second = arguments.GetByIndex(index)[0].expression; - - auto stat = MakePtr(); - stat->expression = assign; - block->statements.Add(stat); - } - - if (prop != _Tag) - { - auto refNode = MakePtr(); - refNode->name.value = variableName.ToString(); - - auto refNotifyDataModified = MakePtr(); - refNotifyDataModified->parent = refNode; - refNotifyDataModified->name.value = L"NotifyDataModified"; - - auto call = MakePtr(); - call->function = refNotifyDataModified; - - auto stat = MakePtr(); - stat->expression = call; - block->statements.Add(stat); - } - } - } - - if (block->statements.Count() > 0) - { - return block; - } - return nullptr; - } - }; - -/*********************************************************************** -GuiBindableDataGridInstanceLoader -***********************************************************************/ - -#define BASE_TYPE GuiTemplateControlInstanceLoader - class GuiBindableDataGridInstanceLoader : public BASE_TYPE - { - protected: - GlobalStringKey typeName; - GlobalStringKey _ViewModelContext; - - void AddAdditionalArguments(types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceError::List& errors, Ptr createControl)override - { - auto indexViewModelContext = arguments.Keys().IndexOf(_ViewModelContext); - if (indexViewModelContext == -1) - { - auto nullExpr = MakePtr(); - nullExpr->value = WfLiteralValue::Null; - createControl->arguments.Add(nullExpr); - } - else - { - createControl->arguments.Add(arguments.GetByIndex(indexViewModelContext)[0].expression); - } - } - public: - GuiBindableDataGridInstanceLoader() - :BASE_TYPE(description::TypeInfo::content.typeName, L"CreateListViewStyle") - { - typeName = GlobalStringKey::Get(description::TypeInfo::content.typeName); - _ViewModelContext = GlobalStringKey::Get(L"ViewModelContext"); - } - - GlobalStringKey GetTypeName()override - { - return typeName; - } - - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override - { - propertyNames.Add(_ViewModelContext); - BASE_TYPE::GetPropertyNames(typeInfo, propertyNames); - } - - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override - { - if (propertyInfo.propertyName == _ViewModelContext) - { - auto info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver::CreateTypeInfo()); - info->usage = GuiInstancePropertyInfo::ConstructorArgument; - info->bindability = GuiInstancePropertyInfo::Bindable; - return info; - } - return BASE_TYPE::GetPropertyType(propertyInfo); - } - }; -#undef BASE_TYPE - -/*********************************************************************** -Initialization -***********************************************************************/ - - void LoadListControls(IGuiInstanceLoaderManager* manager) - { - manager->CreateVirtualType( - GlobalStringKey::Get(description::TypeInfo::content.typeName), - new GuiComboBoxInstanceLoader - ); - - manager->SetLoader(new GuiTreeViewInstanceLoader); - manager->SetLoader(new GuiBindableTreeViewInstanceLoader); - manager->SetLoader(new GuiBindableDataGridInstanceLoader); - - manager->CreateVirtualType( - GlobalStringKey::Get(description::TypeInfo::content.typeName), - new GuiTreeNodeInstanceLoader - ); - } - } - } -} - -#endif - -/*********************************************************************** -INSTANCELOADERS\GUIINSTANCELOADER_PLUGIN.CPP -***********************************************************************/ -/* -GuiInstanceLoader_Plugin.cpp - GuiControl - default: GuiControl*, GuiGraphicsComposition* - GuiInstanceRootObject - default: GuiComponent* -GuiInstanceLoader_TemplateControl - GuiControl - ctor: ControlTemplate(ItemTemplate) -GuiInstanceLoader_Compositions.cpp - GuiAxis - ctor: AxisDirection - GuiComposition - default: GuiControl*, GuiGraphicsComposition*, Ptr - GuiTableComposition - Rows, Columns: array(GuiCellOption) - GuiCellComposition - Site: SiteValue -GuiInstanceLoader_Document.cpp - GuiDocumentItem - default: GuiControl*, GuiGraphicsComposition* - GuiDocumentViewer, GuiDocumentLable - default: Ptr -GuiInstanceLoader_List.cpp - GuiComboBox - ctor: _ListControl(GuiListControl*) - GuiTreeView, GuiBindableTreeView - Nodes: array(Ptr) - GuiBindableDataGrid - ctor: ViewModelContext - tree::TreeNode - ctor: Text, Image - Tag -GuiInstanceLoader_Templates.cpp - GuiTemplate - ctor: \w+(ItemTemplate) -GuiInstanceLoader_Toolstrip.cpp - GuiToolstripMenu, GuiToolstripMenuBar, GuiToolstripToolBar - default: collection(GuiControl*) - GuiToolstripButton - SubMenu-set: GuiToolstripMenu* -*/ - - -namespace vl -{ - namespace presentation - { - namespace instance_loaders - { - -#ifndef VCZH_DEBUG_NO_REFLECTION - -/*********************************************************************** -GuiControlInstanceLoader -***********************************************************************/ - - class GuiControlInstanceLoader : public Object, public IGuiInstanceLoader - { - protected: - GlobalStringKey typeName; - - public: - GuiControlInstanceLoader() - { - typeName = GlobalStringKey::Get(description::TypeInfo::content.typeName); - } - - GlobalStringKey GetTypeName()override - { - return typeName; - } - - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override - { - propertyNames.Add(GlobalStringKey::Empty); - } - - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override - { - if (propertyInfo.propertyName == GlobalStringKey::Empty) - { - auto info = GuiInstancePropertyInfo::Collection(nullptr); - info->acceptableTypes.Add(TypeInfoRetriver::CreateTypeInfo()); - info->acceptableTypes.Add(TypeInfoRetriver::CreateTypeInfo()); - if (propertyInfo.typeInfo.typeInfo->GetTypeDescriptor()->CanConvertTo(description::GetTypeDescriptor())) - { - info->acceptableTypes.Add(TypeInfoRetriver::CreateTypeInfo()); - } - return info; - } - return IGuiInstanceLoader::GetPropertyType(propertyInfo); - } - - Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override - { - auto block = MakePtr(); - - FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys()) - { - const auto& values = arguments.GetByIndex(index); - if (prop == GlobalStringKey::Empty) - { - auto value = values[0].expression; - auto td = values[0].typeInfo->GetTypeDescriptor(); - - Ptr expr; - if (td->CanConvertTo(description::GetTypeDescriptor())) - { - auto refControl = MakePtr(); - refControl->name.value = variableName.ToString(); - - auto refAddComponent = MakePtr(); - refAddComponent->parent = refControl; - refAddComponent->name.value = L"AddComponent"; - - auto call = MakePtr(); - call->function = refAddComponent; - call->arguments.Add(value); - - expr = call; - } - else if (td->CanConvertTo(description::GetTypeDescriptor())) - { - auto refControl = MakePtr(); - refControl->name.value = variableName.ToString(); - - auto refAddControlHostComponent = MakePtr(); - refAddControlHostComponent->parent = refControl; - refAddControlHostComponent->name.value = L"AddControlHostComponent"; - - auto call = MakePtr(); - call->function = refAddControlHostComponent; - call->arguments.Add(value); - - expr = call; - } - else if (td->CanConvertTo(description::GetTypeDescriptor())) - { - auto refControl = MakePtr(); - refControl->name.value = variableName.ToString(); - - auto refAddChild = MakePtr(); - refAddChild->parent = refControl; - refAddChild->name.value = L"AddChild"; - - auto call = MakePtr(); - call->function = refAddChild; - call->arguments.Add(value); - - expr = call; - } - else if (td->CanConvertTo(description::GetTypeDescriptor())) - { - auto refControl = MakePtr(); - refControl->name.value = variableName.ToString(); - - auto refContainerComposition = MakePtr(); - refContainerComposition->parent = refControl; - refContainerComposition->name.value = L"ContainerComposition"; - - auto refAddChild = MakePtr(); - refAddChild->parent = refContainerComposition; - refAddChild->name.value = L"AddChild"; - - auto call = MakePtr(); - call->function = refAddChild; - call->arguments.Add(value); - - expr = call; - } - - if (expr) - { - auto stat = MakePtr(); - stat->expression = expr; - block->statements.Add(stat); - } - } - } - - if (block->statements.Count() > 0) - { - return block; - } - return nullptr; - } - }; - -#endif - -/*********************************************************************** -GuiPredefinedInstanceLoadersPlugin -***********************************************************************/ - - Ptr CreateStandardDataPicker(IGuiInstanceLoader::ArgumentMap&) - { - using TControl = GuiDatePicker; - using TControlStyle = GuiDateComboBoxTemplate_StyleProvider; - using TTemplate = GuiDatePickerTemplate; - - auto controlType = TypeInfoRetriver::CreateTypeInfo(); - auto createControl = MakePtr(); - createControl->type = GetTypeFromTypeInfo(controlType.Obj()); - createControl->arguments.Add(GuiTemplateControlInstanceLoader::CreateIThemeCall(L"CreateDatePickerStyle")); - - return createControl; - } - - void InitializeTrackerProgressBar(const WString& variableName, Ptr block) - { - auto refVariable = MakePtr(); - refVariable->name.value = variableName; - - auto refSetPageSize = MakePtr(); - refSetPageSize->parent = refVariable; - refSetPageSize->name.value = L"SetPageSize"; - - auto refZero = MakePtr(); - refZero->value.value = L"0"; - - auto call = MakePtr(); - call->function = refSetPageSize; - call->arguments.Add(refZero); - - auto stat = MakePtr(); - stat->expression = call; - block->statements.Add(stat); - } - - extern void LoadToolstripControls(IGuiInstanceLoaderManager* manager); - extern void LoadListControls(IGuiInstanceLoaderManager* manager); - extern void LoadDocumentControls(IGuiInstanceLoaderManager* manager); - extern void LoadCompositions(IGuiInstanceLoaderManager* manager); - extern void LoadTemplates(IGuiInstanceLoaderManager* manager); - - class GuiPredefinedInstanceLoadersPlugin : public Object, public IGuiPlugin - { - public: - void Load()override - { - } - - void AfterLoad()override - { - #ifndef VCZH_DEBUG_NO_REFLECTION - IGuiInstanceLoaderManager* manager=GetInstanceLoaderManager(); - - #define ADD_VIRTUAL_TYPE_LOADER(TYPENAME, LOADER)\ - manager->CreateVirtualType(\ - GlobalStringKey::Get(description::TypeInfo::content.typeName),\ - new LOADER\ - ) - - #define ADD_TEMPLATE_CONTROL(TYPENAME, STYLE_METHOD, TEMPLATE)\ - manager->SetLoader(\ - new GuiTemplateControlInstanceLoader(\ - L"presentation::controls::" L ## #TYPENAME,\ - L ## #STYLE_METHOD\ - )\ - ) - - #define ADD_TEMPLATE_CONTROL_2(TYPENAME, STYLE_METHOD, ARGUMENT_FUNCTION, TEMPLATE)\ - manager->SetLoader(\ - new GuiTemplateControlInstanceLoader(\ - L"presentation::controls::" L ## #TYPENAME,\ - L ## #STYLE_METHOD,\ - ARGUMENT_FUNCTION\ - )\ - ) - - #define ADD_VIRTUAL_CONTROL(VIRTUALTYPENAME, TYPENAME, STYLE_METHOD, TEMPLATE)\ - manager->CreateVirtualType(GlobalStringKey::Get(description::TypeInfo::content.typeName),\ - new GuiTemplateControlInstanceLoader(\ - L"presentation::controls::Gui" L ## #VIRTUALTYPENAME,\ - L ## #STYLE_METHOD\ - )\ - ) - - #define ADD_VIRTUAL_CONTROL_F(VIRTUALTYPENAME, TYPENAME, STYLE_METHOD, TEMPLATE, INIT_FUNCTION)\ - manager->CreateVirtualType(GlobalStringKey::Get(description::TypeInfo::content.typeName),\ - new GuiTemplateControlInstanceLoader(\ - L"presentation::controls::Gui" L ## #VIRTUALTYPENAME,\ - L ## #STYLE_METHOD,\ - INIT_FUNCTION\ - )\ - ) - - manager->SetLoader(new GuiControlInstanceLoader); - - ADD_TEMPLATE_CONTROL ( GuiCustomControl, CreateCustomControlStyle, GuiControlTemplate ); - ADD_TEMPLATE_CONTROL ( GuiLabel, CreateLabelStyle, GuiLabelTemplate ); - ADD_TEMPLATE_CONTROL ( GuiButton, CreateButtonStyle, GuiButtonTemplate ); - ADD_TEMPLATE_CONTROL ( GuiTabPage, CreateCustomControlStyle, GuiControlTemplate ); - ADD_TEMPLATE_CONTROL ( GuiTab, CreateTabStyle, GuiTabTemplate ); - ADD_TEMPLATE_CONTROL ( GuiScrollContainer, CreateScrollContainerStyle, GuiScrollViewTemplate ); - ADD_TEMPLATE_CONTROL ( GuiWindow, CreateWindowStyle, GuiWindowTemplate ); - ADD_TEMPLATE_CONTROL ( GuiTextList, CreateTextListStyle, GuiTextListTemplate ); - ADD_TEMPLATE_CONTROL ( GuiBindableTextList, CreateTextListStyle, GuiTextListTemplate ); - ADD_TEMPLATE_CONTROL ( GuiListView, CreateListViewStyle, GuiListViewTemplate); - ADD_TEMPLATE_CONTROL ( GuiBindableListView, CreateListViewStyle, GuiListViewTemplate); - ADD_TEMPLATE_CONTROL ( GuiMultilineTextBox, CreateMultilineTextBoxStyle, GuiMultilineTextBoxTemplate ); - ADD_TEMPLATE_CONTROL ( GuiSinglelineTextBox, CreateTextBoxStyle, GuiSinglelineTextBoxTemplate ); - ADD_TEMPLATE_CONTROL ( GuiDatePicker, CreateDatePickerStyle, GuiDatePickerTemplate ); - ADD_TEMPLATE_CONTROL_2 ( GuiDateComboBox, CreateComboBoxStyle, CreateStandardDataPicker, GuiDateComboBoxTemplate ); - - ADD_VIRTUAL_CONTROL (GroupBox, GuiControl, CreateGroupBoxStyle, GuiControlTemplate ); - ADD_VIRTUAL_CONTROL (MenuSplitter, GuiControl, CreateMenuSplitterStyle, GuiControlTemplate ); - ADD_VIRTUAL_CONTROL (MenuBarButton, GuiToolstripButton, CreateMenuBarButtonStyle, GuiToolstripButtonTemplate ); - ADD_VIRTUAL_CONTROL (MenuItemButton, GuiToolstripButton, CreateMenuItemButtonStyle, GuiToolstripButtonTemplate ); - ADD_VIRTUAL_CONTROL (ToolstripDropdownButton, GuiToolstripButton, CreateToolBarDropdownButtonStyle, GuiToolstripButtonTemplate ); - ADD_VIRTUAL_CONTROL (ToolstripSplitButton, GuiToolstripButton, CreateToolBarSplitButtonStyle, GuiToolstripButtonTemplate ); - ADD_VIRTUAL_CONTROL (ToolstripSplitter, GuiControl, CreateToolBarSplitterStyle, GuiControlTemplate ); - ADD_VIRTUAL_CONTROL (CheckBox, GuiSelectableButton, CreateCheckBoxStyle, GuiSelectableButtonTemplate ); - ADD_VIRTUAL_CONTROL (RadioButton, GuiSelectableButton, CreateRadioButtonStyle, GuiSelectableButtonTemplate ); - ADD_VIRTUAL_CONTROL (HScroll, GuiScroll, CreateHScrollStyle, GuiScrollTemplate ); - ADD_VIRTUAL_CONTROL (VScroll, GuiScroll, CreateVScrollStyle, GuiScrollTemplate ); - ADD_VIRTUAL_CONTROL (DocumentTextBox, GuiDocumentLabel, CreateDocumentTextBoxStyle, GuiDocumentLabelTemplate ); - ADD_VIRTUAL_CONTROL_F (HTracker, GuiScroll, CreateHTrackerStyle, GuiScrollTemplate, InitializeTrackerProgressBar); - ADD_VIRTUAL_CONTROL_F (VTracker, GuiScroll, CreateVTrackerStyle, GuiScrollTemplate, InitializeTrackerProgressBar); - ADD_VIRTUAL_CONTROL_F (ProgressBar, GuiScroll, CreateProgressBarStyle, GuiScrollTemplate, InitializeTrackerProgressBar); - - LoadToolstripControls(manager); - LoadListControls(manager); - LoadDocumentControls(manager); - LoadCompositions(manager); - LoadTemplates(manager); - - #undef ADD_VIRTUAL_TYPE_LOADER - #undef ADD_TEMPLATE_CONTROL - #undef ADD_TEMPLATE_CONTROL_2 - #undef ADD_VIRTUAL_CONTROL - #undef ADD_VIRTUAL_CONTROL_F - #endif - } - - void Unload()override - { - } - }; - GUI_REGISTER_PLUGIN(GuiPredefinedInstanceLoadersPlugin) - } - } -} - -/*********************************************************************** -INSTANCELOADERS\GUIINSTANCELOADER_TEMPLATES.CPP -***********************************************************************/ - -#ifndef VCZH_DEBUG_NO_REFLECTION - -namespace vl -{ - namespace presentation - { - namespace instance_loaders - { - -/*********************************************************************** -GuiTemplateInstanceLoader -***********************************************************************/ - - class GuiTemplateInstanceLoader : public Object, public IGuiInstanceLoader - { - protected: - GlobalStringKey typeName; - - public: - GuiTemplateInstanceLoader() - { - typeName = GlobalStringKey::Get(description::TypeInfo::content.typeName); - } - - GlobalStringKey GetTypeName()override - { - return typeName; - } - - void GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override - { - List tds; - tds.Add(typeInfo.typeInfo->GetTypeDescriptor()); - - for (vint i = 0; i < tds.Count(); i++) - { - auto td = tds[i]; - if (td != description::GetTypeDescriptor()) - { - vint propCount = td->GetPropertyCount(); - for (vint i = 0; i < propCount; i++) - { - auto prop = td->GetProperty(i); - if (prop->IsWritable() && INVLOC.EndsWith(prop->GetName(), L"Template", Locale::None)) - { - propertyNames.Add(GlobalStringKey::Get(prop->GetName())); - } - } - - vint baseCount = td->GetBaseTypeDescriptorCount(); - for (vint i = 0; i < baseCount; i++) - { - auto baseTd = td->GetBaseTypeDescriptor(i); - if (!tds.Contains(baseTd)) - { - tds.Add(baseTd); - } - } - } - } - } - }; - -/*********************************************************************** -Initialization -***********************************************************************/ - - void LoadTemplates(IGuiInstanceLoaderManager* manager) - { - manager->SetLoader(new GuiTemplateInstanceLoader); - } - } - } -} - -#endif - -/*********************************************************************** -INSTANCELOADERS\GUIINSTANCELOADER_TOOLSTRIP.CPP -***********************************************************************/ - -#ifndef VCZH_DEBUG_NO_REFLECTION - -namespace vl -{ - namespace presentation - { - namespace instance_loaders - { - Ptr AddControlToToolstrip(GlobalStringKey variableName, IGuiInstanceLoader::ArgumentMap& arguments, GuiResourceError::List& errors) - { - auto block = MakePtr(); - - FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys()) - { - const auto& values = arguments.GetByIndex(index); - if (prop == GlobalStringKey::Empty) - { - auto value = values[0].expression; - auto td = values[0].typeInfo->GetTypeDescriptor(); - - Ptr expr; - if (td->CanConvertTo(description::GetTypeDescriptor())) - { - auto refControl = MakePtr(); - refControl->name.value = variableName.ToString(); - - auto refToolstripItems = MakePtr(); - refToolstripItems->parent = refControl; - refToolstripItems->name.value = L"ToolstripItems"; - - auto refAdd = MakePtr(); - refAdd->parent = refToolstripItems; - refAdd->name.value = L"Add"; - - auto call = MakePtr(); - call->function = refAdd; - call->arguments.Add(value); - - expr = call; - } - - if (expr) - { - auto stat = MakePtr(); - stat->expression = expr; - block->statements.Add(stat); - } - } - } - - if (block->statements.Count() > 0) - { - return block; - } - return nullptr; - } - -/*********************************************************************** -GuiToolstripInstanceLoaderBase -***********************************************************************/ - - template - class GuiToolstripInstanceLoaderBase : public TBaseType - { - public: - using ArgumentMap = IGuiInstanceLoader::ArgumentMap; - using PropertyInfo = IGuiInstanceLoader::PropertyInfo; - - GuiToolstripInstanceLoaderBase(const WString& _typeName, const WString& _styleMethod, Ptr(*_argumentFunction)(ArgumentMap&)) - :TBaseType(_typeName, _styleMethod, _argumentFunction) - { - } - - GuiToolstripInstanceLoaderBase(const WString& _typeName, const WString& _styleMethod) - :TBaseType(_typeName, _styleMethod) - { - } - - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override - { - propertyNames.Add(GlobalStringKey::Empty); - TBaseType::GetPropertyNames(typeInfo, propertyNames); - } - - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override - { - if (propertyInfo.propertyName == GlobalStringKey::Empty) - { - return GuiInstancePropertyInfo::CollectionWithParent(TypeInfoRetriver::CreateTypeInfo()); - } - return TBaseType::GetPropertyType(propertyInfo); - } - - Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override - { - if (auto statement = AddControlToToolstrip(variableName, arguments, errors)) - { - return statement; - } - else - { - return TBaseType::AssignParameters(precompileContext, resolvingResult, typeInfo, variableName, arguments, attPosition, errors); - } - } - }; - -/*********************************************************************** -GuiToolstripMenuInstanceLoader -***********************************************************************/ - -#define BASE_TYPE GuiTemplateControlInstanceLoader - class GuiToolstripMenuInstanceLoader : public GuiToolstripInstanceLoaderBase - { - public: - static Ptr ArgumentFunction(ArgumentMap&) - { - auto expr = MakePtr(); - expr->value = WfLiteralValue::Null; - return expr; - } - public: - GuiToolstripMenuInstanceLoader() - :GuiToolstripInstanceLoaderBase(description::TypeInfo::content.typeName, L"CreateMenuStyle", ArgumentFunction) - { - } - }; -#undef BASE_TYPE - -/*********************************************************************** -GuiToolstripMenuBarInstanceLoader -***********************************************************************/ - -#define BASE_TYPE GuiTemplateControlInstanceLoader - class GuiToolstripMenuBarInstanceLoader : public GuiToolstripInstanceLoaderBase - { - public: - GuiToolstripMenuBarInstanceLoader() - :GuiToolstripInstanceLoaderBase(description::TypeInfo::content.typeName, L"CreateMenuBarStyle") - { - } - }; -#undef BASE_TYPE - -/*********************************************************************** -GuiToolstripToolBarInstanceLoader -***********************************************************************/ - -#define BASE_TYPE GuiTemplateControlInstanceLoader - class GuiToolstripToolBarInstanceLoader : public GuiToolstripInstanceLoaderBase - { - public: - GuiToolstripToolBarInstanceLoader() - :GuiToolstripInstanceLoaderBase(description::TypeInfo::content.typeName, L"CreateToolBarStyle") - { - } - }; -#undef BASE_TYPE - -/*********************************************************************** -GuiToolstripButtonInstanceLoader -***********************************************************************/ - -#define BASE_TYPE GuiTemplateControlInstanceLoader - class GuiToolstripButtonInstanceLoader : public BASE_TYPE - { - protected: - GlobalStringKey _SubMenu; - - public: - GuiToolstripButtonInstanceLoader() - :BASE_TYPE(description::TypeInfo::content.typeName, L"CreateToolBarButtonStyle") - { - _SubMenu = GlobalStringKey::Get(L"SubMenu"); - } - - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override - { - propertyNames.Add(_SubMenu); - BASE_TYPE::GetPropertyNames(typeInfo, propertyNames); - } - - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override - { - if (propertyInfo.propertyName == _SubMenu) - { - return GuiInstancePropertyInfo::Set(TypeInfoRetriver::CreateTypeInfo()); - } - return BASE_TYPE::GetPropertyType(propertyInfo); - } - - Ptr GetParameter(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const PropertyInfo& propertyInfo, GlobalStringKey variableName, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override - { - if (propertyInfo.propertyName == _SubMenu) - { - auto refControl = MakePtr(); - refControl->name.value = variableName.ToString(); - - auto refEnsureToolstripSubMenu = MakePtr(); - refEnsureToolstripSubMenu->parent = refControl; - refEnsureToolstripSubMenu->name.value = L"EnsureToolstripSubMenu"; - - auto call = MakePtr(); - call->function = refEnsureToolstripSubMenu; - - return call; - } - return BASE_TYPE::GetParameter(precompileContext, resolvingResult, propertyInfo, variableName, attPosition, errors); - } - }; -#undef BASE_TYPE - -/*********************************************************************** -Initialization -***********************************************************************/ - - void LoadToolstripControls(IGuiInstanceLoaderManager* manager) - { - manager->SetLoader(new GuiToolstripMenuInstanceLoader); - manager->SetLoader(new GuiToolstripMenuBarInstanceLoader); - manager->SetLoader(new GuiToolstripToolBarInstanceLoader); - manager->SetLoader(new GuiToolstripButtonInstanceLoader); - } - } - } -} - -#endif - -/*********************************************************************** -INSTANCEQUERY\GUIINSTANCEQUERY.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - using namespace collections; - -/*********************************************************************** -ExecuteQueryVisitor -***********************************************************************/ - - class ExecuteQueryVisitor : public Object, public GuiIqQuery::IVisitor - { - public: - Ptr context; - List>& input; - List>& output; - - ExecuteQueryVisitor(Ptr _context, List>& _input, List>& _output) - :context(_context), input(_input), output(_output) - { - } - - static bool TestCtor(GuiIqPrimaryQuery* node, GlobalStringKey attribute, Ptr ctor) - { - if (node->attributeNameOption == GuiIqNameOption::Specified && node->attributeName.value != attribute.ToString()) - { - return false; - } - if (node->typeNameOption == GuiIqNameOption::Specified && node->typeName.value != ctor->typeName.ToString()) - { - return false; - } - if (node->referenceName.value != L"") - { - bool instanceName = ctor->instanceName != GlobalStringKey::Empty && node->referenceName.value == ctor->instanceName.ToString(); - bool styleName = ctor->styleName && node->referenceName.value == ctor->styleName.Value(); - return instanceName || styleName; - } - return true; - } - - void Traverse(GuiIqPrimaryQuery* node, Ptr setter) - { - if (setter) - { - FOREACH_INDEXER(GlobalStringKey, attribute, index, setter->setters.Keys()) - { - auto setterValue = setter->setters.Values()[index]; - FOREACH(Ptr, value, setterValue->values) - { - if (auto ctor = value.Cast()) - { - if (TestCtor(node, attribute, ctor)) - { - output.Add(ctor); - } - } - if (node->childOption == GuiIqChildOption::Indirect) - { - if (auto setter = value.Cast()) - { - Traverse(node, setter); - } - } - } - } - } - else - { - if (TestCtor(node, GlobalStringKey::Empty, context->instance)) - { - output.Add(context->instance); - } - if (node->childOption == GuiIqChildOption::Indirect) - { - Traverse(node, context->instance); - } - } - } - - void Visit(GuiIqPrimaryQuery* node)override - { - auto inputExists = &input; - if (inputExists) - { - FOREACH(Ptr, setter, input) - { - Traverse(node, setter); - } - } - else - { - Traverse(node, 0); - } - } - - void Visit(GuiIqCascadeQuery* node)override - { - List> temp; - ExecuteQuery(node->parent, context, input, temp); - ExecuteQuery(node->child, context, temp, output); - } - - void Visit(GuiIqSetQuery* node)override - { - List> first, second; - ExecuteQuery(node->first, context, input, first); - ExecuteQuery(node->second, context, input, second); - - switch (node->op) - { - case GuiIqBinaryOperator::ExclusiveOr: - CopyFrom(output, From(first).Except(second).Union(From(second).Except(second))); - break; - case GuiIqBinaryOperator::Intersect: - CopyFrom(output, From(first).Intersect(second)); - break; - case GuiIqBinaryOperator::Union: - CopyFrom(output, From(first).Union(second)); - break; - case GuiIqBinaryOperator::Substract: - CopyFrom(output, From(first).Except(second)); - break; - } - } - }; - -/*********************************************************************** -ExecuteQuery -***********************************************************************/ - - void ExecuteQuery(Ptr query, Ptr context, collections::List>& input, collections::List>& output) - { - ExecuteQueryVisitor visitor(context, input, output); - query->Accept(&visitor); - } - - void ExecuteQuery(Ptr query, Ptr context, collections::List>& output) - { - ExecuteQuery(query, context, *(List>*)0, output); - } - -/*********************************************************************** -ApplyStyle -***********************************************************************/ - - void ApplyStyleInternal(Ptr src, Ptr dst) - { - FOREACH_INDEXER(GlobalStringKey, attribute, srcIndex, src->setters.Keys()) - { - auto srcValue = src->setters.Values()[srcIndex]; - vint dstIndex = dst->setters.Keys().IndexOf(attribute); - if (dstIndex == -1) - { - dst->setters.Add(attribute, srcValue); - } - else - { - auto dstValue = dst->setters.Values()[dstIndex]; - if (srcValue->binding == dstValue->binding) - { - if (srcValue->binding == GlobalStringKey::_Set) - { - ApplyStyleInternal(srcValue->values[0].Cast(), dstValue->values[0].Cast()); - } - else - { - CopyFrom(dstValue->values, srcValue->values, true); - } - } - } - } - - FOREACH_INDEXER(GlobalStringKey, eventName, srcIndex, src->eventHandlers.Keys()) - { - if (!dst->eventHandlers.Keys().Contains(eventName)) - { - auto srcValue = src->eventHandlers.Values()[srcIndex]; - dst->eventHandlers.Add(eventName, srcValue); - } - } - - FOREACH_INDEXER(GlobalStringKey, varName, srcIndex, src->environmentVariables.Keys()) - { - if (!dst->environmentVariables.Keys().Contains(varName)) - { - auto srcValue = src->environmentVariables.Values()[srcIndex]; - dst->environmentVariables.Add(varName, srcValue); - } - } - } - - void ApplyStyle(Ptr style, Ptr ctor) - { - ApplyStyleInternal(style->setter->Clone().Cast(), ctor); - } - -/*********************************************************************** -GuiIqPrint -***********************************************************************/ - - class GuiIqPrintVisitor : public Object, public GuiIqQuery::IVisitor - { - public: - stream::StreamWriter& writer; - - GuiIqPrintVisitor(stream::StreamWriter& _writer) - :writer(_writer) - { - } - - void Visit(GuiIqPrimaryQuery* node)override - { - switch (node->childOption) - { - case GuiIqChildOption::Direct: - writer.WriteString(L"/"); - break; - case GuiIqChildOption::Indirect: - writer.WriteString(L"//"); - break; - } - - if (node->attributeNameOption == GuiIqNameOption::Specified) - { - writer.WriteChar(L'@'); - writer.WriteString(node->attributeName.value); - writer.WriteChar(L':'); - } - - if (node->typeNameOption == GuiIqNameOption::Specified) - { - writer.WriteString(node->typeName.value); - } - else - { - writer.WriteChar(L'*'); - } - - if (node->referenceName.value != L"") - { - writer.WriteChar(L'.'); - writer.WriteString(node->referenceName.value); - } - } - - void Visit(GuiIqCascadeQuery* node)override - { - node->parent->Accept(this); - node->child->Accept(this); - } - - void Visit(GuiIqSetQuery* node)override - { - writer.WriteChar(L'('); - node->first->Accept(this); - switch (node->op) - { - case GuiIqBinaryOperator::ExclusiveOr: - writer.WriteString(L" ^ "); - break; - case GuiIqBinaryOperator::Intersect: - writer.WriteString(L" * "); - break; - case GuiIqBinaryOperator::Union: - writer.WriteString(L" + "); - break; - case GuiIqBinaryOperator::Substract: - writer.WriteString(L" - "); - break; - } - node->second->Accept(this); - writer.WriteChar(L')'); - } - }; - - void GuiIqPrint(Ptr query, stream::StreamWriter& writer) - { - GuiIqPrintVisitor visitor(writer); - query->Accept(&visitor); - } - } -} - -/*********************************************************************** -INSTANCEQUERY\GUIINSTANCEQUERY_AST.CPP -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Parser::GuiInstanceQuery_Parser.parser.txt - -This file is generated by: Vczh Parser Generator -***********************************************************************/ - - -namespace vl -{ - namespace presentation - { -/*********************************************************************** -Visitor Pattern Implementation -***********************************************************************/ - - void GuiIqPrimaryQuery::Accept(GuiIqQuery::IVisitor* visitor) - { - visitor->Visit(this); - } - - void GuiIqCascadeQuery::Accept(GuiIqQuery::IVisitor* visitor) - { - visitor->Visit(this); - } - - void GuiIqSetQuery::Accept(GuiIqQuery::IVisitor* visitor) - { - visitor->Visit(this); - } - - } -} -namespace vl -{ - namespace reflection - { - namespace description - { -#ifndef VCZH_DEBUG_NO_REFLECTION - using namespace vl::presentation; - -#define PARSING_TOKEN_FIELD(NAME)\ - CLASS_MEMBER_EXTERNALMETHOD_TEMPLATE(get_##NAME, NO_PARAMETER, vl::WString(ClassType::*)(), [](ClassType* node) { return node->NAME.value; }, L"*", L"*")\ - CLASS_MEMBER_EXTERNALMETHOD_TEMPLATE(set_##NAME, { L"value" }, void(ClassType::*)(const vl::WString&), [](ClassType* node, const vl::WString& value) { node->NAME.value = value; }, L"*", L"*")\ - CLASS_MEMBER_PROPERTY_REFERENCETEMPLATE(NAME, get_##NAME, set_##NAME, L"$This->$Name.value")\ - - IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqQuery, presentation::GuiIqQuery) - IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqNameOption, presentation::GuiIqNameOption) - IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqChildOption, presentation::GuiIqChildOption) - IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqPrimaryQuery, presentation::GuiIqPrimaryQuery) - IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqCascadeQuery, presentation::GuiIqCascadeQuery) - IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqBinaryOperator, presentation::GuiIqBinaryOperator) - IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqSetQuery, presentation::GuiIqSetQuery) - IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqQuery::IVisitor, presentation::GuiIqQuery::IVisitor) - - BEGIN_CLASS_MEMBER(GuiIqQuery) - CLASS_MEMBER_METHOD_OVERLOAD(Accept, {L"visitor"}, void(GuiIqQuery::*)(GuiIqQuery::IVisitor* visitor)) - END_CLASS_MEMBER(GuiIqQuery) - - BEGIN_ENUM_ITEM(GuiIqNameOption) - ENUM_ITEM_NAMESPACE(GuiIqNameOption) - ENUM_NAMESPACE_ITEM(Specified) - ENUM_NAMESPACE_ITEM(Any) - END_ENUM_ITEM(GuiIqNameOption) - - BEGIN_ENUM_ITEM(GuiIqChildOption) - ENUM_ITEM_NAMESPACE(GuiIqChildOption) - ENUM_NAMESPACE_ITEM(Direct) - ENUM_NAMESPACE_ITEM(Indirect) - END_ENUM_ITEM(GuiIqChildOption) - - BEGIN_CLASS_MEMBER(GuiIqPrimaryQuery) - CLASS_MEMBER_BASE(GuiIqQuery) - - CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) - - CLASS_MEMBER_FIELD(childOption) - CLASS_MEMBER_FIELD(attributeNameOption) - PARSING_TOKEN_FIELD(attributeName) - CLASS_MEMBER_FIELD(typeNameOption) - PARSING_TOKEN_FIELD(typeName) - PARSING_TOKEN_FIELD(referenceName) - END_CLASS_MEMBER(GuiIqPrimaryQuery) - - BEGIN_CLASS_MEMBER(GuiIqCascadeQuery) - CLASS_MEMBER_BASE(GuiIqQuery) - - CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) - - CLASS_MEMBER_FIELD(parent) - CLASS_MEMBER_FIELD(child) - END_CLASS_MEMBER(GuiIqCascadeQuery) - - BEGIN_ENUM_ITEM(GuiIqBinaryOperator) - ENUM_ITEM_NAMESPACE(GuiIqBinaryOperator) - ENUM_NAMESPACE_ITEM(ExclusiveOr) - ENUM_NAMESPACE_ITEM(Intersect) - ENUM_NAMESPACE_ITEM(Union) - ENUM_NAMESPACE_ITEM(Substract) - END_ENUM_ITEM(GuiIqBinaryOperator) - - BEGIN_CLASS_MEMBER(GuiIqSetQuery) - CLASS_MEMBER_BASE(GuiIqQuery) - - CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) - - CLASS_MEMBER_FIELD(first) - CLASS_MEMBER_FIELD(second) - CLASS_MEMBER_FIELD(op) - END_CLASS_MEMBER(GuiIqSetQuery) - - BEGIN_INTERFACE_MEMBER(GuiIqQuery::IVisitor) - CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(GuiIqQuery::IVisitor::*)(GuiIqPrimaryQuery* node)) - CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(GuiIqQuery::IVisitor::*)(GuiIqCascadeQuery* node)) - CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(GuiIqQuery::IVisitor::*)(GuiIqSetQuery* node)) - END_INTERFACE_MEMBER(GuiIqQuery) - -#undef PARSING_TOKEN_FIELD - - class GuiIqTypeLoader : public vl::Object, public ITypeLoader - { - public: - void Load(ITypeManager* manager) - { - ADD_TYPE_INFO(vl::presentation::GuiIqQuery) - ADD_TYPE_INFO(vl::presentation::GuiIqNameOption) - ADD_TYPE_INFO(vl::presentation::GuiIqChildOption) - ADD_TYPE_INFO(vl::presentation::GuiIqPrimaryQuery) - ADD_TYPE_INFO(vl::presentation::GuiIqCascadeQuery) - ADD_TYPE_INFO(vl::presentation::GuiIqBinaryOperator) - ADD_TYPE_INFO(vl::presentation::GuiIqSetQuery) - ADD_TYPE_INFO(vl::presentation::GuiIqQuery::IVisitor) - } - - void Unload(ITypeManager* manager) - { - } - }; -#endif - - bool GuiIqLoadTypes() - { -#ifndef VCZH_DEBUG_NO_REFLECTION - ITypeManager* manager=GetGlobalTypeManager(); - if(manager) - { - Ptr loader=new GuiIqTypeLoader; - return manager->AddTypeLoader(loader); - } -#endif - return false; - } - } - } -} - -/*********************************************************************** -INSTANCEQUERY\GUIINSTANCEQUERY_PARSER.CPP -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Parser::GuiInstanceQuery_Parser.parser.txt - -This file is generated by: Vczh Parser Generator -***********************************************************************/ - - -namespace vl -{ - namespace presentation - { -/*********************************************************************** -ParserText -***********************************************************************/ - -const wchar_t parserTextBuffer[] = -L"\r\n" L"" -L"\r\n" L"class Query" -L"\r\n" L"{" -L"\r\n" L"}" -L"\r\n" L"" -L"\r\n" L"enum NameOption" -L"\r\n" L"{" -L"\r\n" L"\tSpecified," -L"\r\n" L"\tAny," -L"\r\n" L"}" -L"\r\n" L"" -L"\r\n" L"enum ChildOption" -L"\r\n" L"{" -L"\r\n" L"\tDirect," -L"\r\n" L"\tIndirect," -L"\r\n" L"}" -L"\r\n" L"" -L"\r\n" L"class PrimaryQuery : Query" -L"\r\n" L"{" -L"\r\n" L"\tChildOption\t\tchildOption;" -L"\r\n" L"\tNameOption\t\tattributeNameOption;" -L"\r\n" L"\ttoken\t\t\tattributeName;" -L"\r\n" L"\tNameOption\t\ttypeNameOption;" -L"\r\n" L"\ttoken\t\t\ttypeName;" -L"\r\n" L"\ttoken\t\t\treferenceName;" -L"\r\n" L"}" -L"\r\n" L"" -L"\r\n" L"class CascadeQuery : Query" -L"\r\n" L"{" -L"\r\n" L"\tQuery\t\t\tparent;" -L"\r\n" L"\tQuery\t\t\tchild;" -L"\r\n" L"}" -L"\r\n" L"" -L"\r\n" L"enum BinaryOperator" -L"\r\n" L"{" -L"\r\n" L"\tExclusiveOr," -L"\r\n" L"\tIntersect," -L"\r\n" L"\tUnion," -L"\r\n" L"\tSubstract," -L"\r\n" L"}" -L"\r\n" L"" -L"\r\n" L"class SetQuery : Query" -L"\r\n" L"{" -L"\r\n" L"\tQuery\t\t\tfirst;" -L"\r\n" L"\tQuery\t\t\tsecond;" -L"\r\n" L"\tBinaryOperator\top;" -L"\r\n" L"}" -L"\r\n" L"" -L"\r\n" L"token INDIRECT = \"////\";" -L"\r\n" L"token DIRECT = \"//\";" -L"\r\n" L"token NAME = \"[a-zA-Z_][a-zA-Z0-9]*\";" -L"\r\n" L"token WILDCARD = \"/*\";" -L"\r\n" L"token OPEN = \"/(\";" -L"\r\n" L"token CLOSE = \"/)\";" -L"\r\n" L"token XOR = \"/^\";" -L"\r\n" L"token INTERSECT = \"/*\";" -L"\r\n" L"token UNION = \"/+\";" -L"\r\n" L"token SUBSTRACT = \"-\";" -L"\r\n" L"token ATTRIBUTE = \"@\";" -L"\r\n" L"token COLON = \":\";" -L"\r\n" L"token DOT = \".\";" -L"\r\n" L"" -L"\r\n" L"discardtoken SPACE = \"/s+\";" -L"\r\n" L"" -L"\r\n" L"rule PrimaryQuery QPrimaryFragment" -L"\r\n" L"\t=\t(" -L"\r\n" L"\t\t\t(NAME : typeName with {typeNameOption=\"Specified\"})" -L"\r\n" L"\t\t\t| (\"*\" with {typeNameOption=\"Any\"})" -L"\r\n" L"\t\t)" -L"\r\n" L"\t\t[\".\" NAME : referenceName] as PrimaryQuery" -L"\r\n" L"\t;" -L"\r\n" L"" -L"\r\n" L"rule PrimaryQuery QPrimaryAttributed" -L"\r\n" L"\t= !QPrimaryFragment with {attributeNameOption=\"Any\"}" -L"\r\n" L"\t= \"@\" [NAME : attributeName] \":\" !QPrimaryFragment with {attributeNameOption=\"Specified\"}" -L"\r\n" L"\t;" -L"\r\n" L"" -L"\r\n" L"rule PrimaryQuery QPrimary" -L"\r\n" L"\t= (\"/\" with {childOption=\"Direct\"}) !QPrimaryAttributed" -L"\r\n" L"\t= (\"//\" with {childOption=\"Indirect\"}) !QPrimaryAttributed" -L"\r\n" L"\t= \"(\" !QueryRoot \")\"" -L"\r\n" L"\t;" -L"\r\n" L"" -L"\r\n" L"rule Query Query0" -L"\r\n" L"\t= !QPrimary" -L"\r\n" L"\t= Query0 : parent QPrimary : child as CascadeQuery;" -L"\r\n" L"" -L"\r\n" L"rule Query Query1" -L"\r\n" L"\t= !Query0" -L"\r\n" L"\t= Query1 : first \"^\" Query0 : second as SetQuery with {op=\"ExclusiveOr\"}" -L"\r\n" L"\t= Query1 : first \"*\" Query0 : second as SetQuery with {op=\"Intersect\"}" -L"\r\n" L"\t;" -L"\r\n" L"\t" -L"\r\n" L"rule Query Query2" -L"\r\n" L"\t= !Query1" -L"\r\n" L"\t= Query2 : first \"+\" Query1 : second as SetQuery with {op=\"Union\"}" -L"\r\n" L"\t= Query2 : first \"-\" Query1 : second as SetQuery with {op=\"Substract\"}" -L"\r\n" L"\t;" -L"\r\n" L"" -L"\r\n" L"rule Query QueryRoot" -L"\r\n" L"\t= !Query2" -L"\r\n" L"\t;" -; - - vl::WString GuiIqGetParserTextBuffer() - { - return parserTextBuffer; - } - -/*********************************************************************** -SerializedTable -***********************************************************************/ - -const vint parserBufferLength = 5788; // 27819 bytes before compressing -const vint parserBufferBlock = 1024; -const vint parserBufferRemain = 668; -const vint parserBufferRows = 6; -const char* parserBuffer[] = { -"\x00\x00\x81\x81\x84\x02\x81\x80\x07\x82\x00\x87\x80\x83\x21\x33\x3B\x31\x30\x64\x65\x11\x35\x35\x32\x39\x3D\x7F\x18\x99\x98\x8A\x85\x84\x8C\x28\x39\x69\x6D\x21\x36\x83\x8D\x8B\x8A\x8D\x19\x85\x08\x80\x0A\x90\x81\x92\x8B\x28\x99\x88\x0B\x93\x98\x83\x29\x32\x74\x2F\xA7\x91\x9B\x03\x94\x8E\x81\x1C\x8C\x8E\x90\x82\x8C\x8A\x8B\x96\x05\xC8\xA3\x28\x39\x34\x34\x33\x98\x1B\xBE\x81\x82\xAF\x81\x8A\x9C\x03\x2B\xD8\x80\x90\x33\x95\x32\x36\x3A\x50\xFF\x7F\x86\x81\x87\x8D\x91\x91\x79\x3A\x8D\x0B\x9B\xB0\x81\x30\x3A\x74\x20\xA2\x35\x34\x3D\x32\x27\x30\x6D\x65\x21\xA3\xB9\x85\xB0\x90\x91\x24\xC6\xB9\x33\x0B\x94\xC2\xB6\xB8\x72\xF4\xB6\xB8\xB5\x37\x24\x38\x3A\x69\x6F\x2E\x3B\xB2\xA8\x82\xB2\xC0\x69\x82\xFD\x88\x8B\xC8\x03\xA5\xA6\x64\x0E\xD0\xD2\xC4\xC8\x86\x8F\xBF\x68\xEA\xAC\xA1\x82\x3D\x32\x33\x8A\x5E\xE3\x0B\xD9\xB5\xD5\x8E\xBF\xB3\x81\xA6\xB5\x85\x8B\xDC\x39\x3C\x38\xB3\xFA\x90\xBC\xB0\x07\xD0\xDD\xCC\x26\x8E\x2B\x8A\xE0\x86\xDC\xE1\xBB\x79\xA2\xD1\xD3\xC0\xAB\xDE\x81\xDD\x37\xB9\x82\xC8\xA2\x80\xA6\x33\x34\x72\x73\x20\xB5\xE4\x99\x81\xEC\x9D\x02\x2B\xA9\xE0\x8F\x30\x39\xB0\xEB\x01\xD8\xF8\x97\xA9\xA9\x83\x39\x32\x63\x12\xCF\xB0\xA1\x0B\x97\x17\x95\xFD\x6B\x42\x83\x4A\x61\x61\x53\x80\x81\x05\xB1\x47\x80\x42\x09\x8A\x8B\x82\x40\x0D\xA8\x40\x7C\x40\xBB\x49\x1E\x10\x11\x49\x12\x15\x13\x10\x54\x04\x48\x42\x87\x00\x2F\x02\x8B\x7F\x08\xB1\x4A\x55\x41\x27\x98\x8A\x84\x87\xEB\x45\x4D\x8A\x88\x01\x25\x88\x48\x88\x02\x60\x8E\x11\x10\x4D\x05\x15\x07\x4A\x3B\x80\x4B\x15\x18\x2D\x3A\x11\x11\x0B\x5A\x1F\x1D\x17\x8F\x41\x83\x9A\x14\x0C\x2D\x39\x0D\x16\x0A\x2D\x90\x84\x78\x42\xBB\x57\x19\x10\x13\x44\x03\x11\x12\x14\x44\x11\x91\x43\x8B\x2A\x03\x02\x8E\x46\x34\x83\x41\x43\x13\x50\x05\x1E\x12\x97\x00\x6F\x88\x09\x99\x00\x61\x5C\x75\x40\x48\x43\x1C\x13\x13\x53\x05\x1C\x98\x00\x2F\xA9\x03\x9D\x9C\x50\x62\x98\x42\xA0\x00\x18\x1F\x12\x14\x7B\xAF\x8E\x17\x89\x52\xB1\x49\x03\x4A\x8F\x80\x46\x84\x15\x45\x12\x19\x9C\x8B\xEA\x41\x4F\x0A\x0A\x07\x23\x99\x4B\x4A\x48\x55\x1E\x11\x12\x4F\x2B\x99\xA4\x40\x2F\x2B\x03\x84\x00\x61\x51\xA5\x42\xAB\x53\x15\x12\x13\x14\x54\x12\x11\x10\x87\x31\x88\x49\xAC\x00\x2D\x2E\xAD\xA0\x4A\xBE\x81\x4E\xA9\x10\x54\x35\xA9\x12\x10\x55\x14\xAB\xAE\x40\xBB\x80\x1A\x02\xA7\x18\x7F\x9C\x4B\x54\x4F\x37\x9E\x13\xB2\x01\x7B\xAA\x0D\x67\xBF\x9A\x44\xA2\x40\x84\x84\x1F\x10\x15\xD8\x80\x4B\xAE\x0B\xC4\x61\x55\xBB\xB4\x08\x48\x53\x14\x14\xB7\x85\x1F\xB5\x40\x84\xAF\x03\x1F\x0A\x6D\x45\x41\x58\x89\x28\xB5\x7E\x4A\x60\x32\x10\x0B\x4A\xC0\xFF\xA6\x42\x0E\x0B\x52\x2F\x1F\x18\x1D\x53\x34\x13\x48\x1D\xDC\x81\x4D\x64\x10\x20\x24\x0C\x0E\x4E\x32\x3E\x0C\xA1\x40\x27\x98\xC4\x70\x47\x18\xEE\x0D\xC3\xC3\xCF\x88\x45\xC8\x00\x14\xD7\xC0\xC2\x0F\xAB\xBB\x61\x17\x65\x68\x67\xC2\x43\xC9\x2F\xE8\x66\x46\x0B\x31\x15\x2B\x4A\xCE\x00\x57\xC0\xCE\x45\x3E\x3A\x00\x08\x0A\x20\x22\x0F\x0A\x08\x14\xF7\x19\x18\x1D\x68\x20\x0B\x1C\x08\x9F\x4E\x52\x76\x64\x20\x3D\x05\xD0\x11\xE0\x78\x74\x1E\x08\x20\x3D\x10\x09\x0A\x20\x21\x05\xCF\x71\x41\x08\x69\x1B\x5C\x75\x64\x1D\x02\x02\x3E\xF6\xC9\x1D\xD0\x43\xC5\xD2\x88\xD2\x20\x0A\xDC\xD2\xD3\x50\xCC\x52\xD7\x63\xD3\x55\xD5\xD1\x12\x6E\x24\x19\xD7\x18\x5B\xDD\xDF\xD5\xD8\x63\xD8\x65\xD9\x5C\x67\xCA\x64\x19\xCB\x01\x49\xE1\xCF\x4A\x34\xFF\xC9\x1E\x0B\x32\x1F\x0B\x4A\xE6\x3D\xD2\xE0\xD2\xD0\x22\x28\x04\xDE\xD8\x82\x49\xCB\xC1\xD1\x29\x22\x04\xC1\x41\xAB\xDE\xE9\x1E\x11\x72\x21\x17\x19\x5E\x5F\x52\x0B\x4A\xED\x2E\x56\xE0\xEE\xEC\xB4\xF4\x18\xCD\x2A\x2B\x40\xFD\xE6\xEE\xB1\xF3\xEE\x54\x1D\x70\xC4\xD4\xD3\x8D\x39\xA0\x02\xD2\x73\xC1\x75\xDB\xD1\xD3\x4F\xD0\xF0\x75\x63\x7C\xD4\xD6\xD6\x08\x53\x00\x73\x19\x1A\xDF\x65\x14\x18\xD7\x5E\xE0\xDC\x1D\xDC\x22\x2A\x0C\xD6\xDD\xD4\xE0\x06\xF4\x63\x53\xEE\x1E\xDE\x08\x41\x2E\x19\x1C\xF9\x87\xE9\x04\xC7\x16\x45\xEE\x0C\xD4\xF3\x45\x0E\x78\x08\x2D\x3F\x35\xD6\x2E\x0A\x36\xD7\x60\x05\x17\x20\x0D\x20\x10\x16\x72\x27\xAB\x62\x21\xEB\x44\x7C\x77\xE3\x78\x75\x20\x17\x8E\x77\xEE\x46\x7F\x2A\xCC\x42\x7D\x20\x1F\x8D\x6F\x71\x1B\x8D\x77\xE4\x71\x68\x80\x02\x8F\x7D\x5E\x52\x77\x6F\xEA\x7F\x31\x38\xF1\x73\x7D\xF7\x78\x30\x7D\x34\x22\x78\x7F\xE6\x68\x7E\xFA\x2C\x8D\x7C\x15\x98\x7B\x34\xF2\x7B\x79\xFD\x77\x76\x70", -"\xB0\x7A\x78\x04\xFC\x62\x06\xFF\x20\x08\x84\xA1\x44\x80\x36\x07\x91\x7B\x02\x8D\x8F\x80\xC1\x17\x82\x20\x19\x96\x73\xE2\x09\x39\x6C\x0A\x2B\x26\x8B\xB9\x6E\x6F\x16\x8D\x79\x6C\xCC\x74\x0B\x25\x67\x83\x7A\x18\xE6\x68\x6C\xF1\x70\x68\x69\x74\x7C\x7D\x13\x8C\x8C\x8C\xC5\x09\x83\x81\x22\x1A\x04\xD7\x62\x64\x82\x0E\xB4\x0C\x87\x78\x6F\x2C\xE3\x6D\x87\x7B\x18\x9B\x7B\x86\xDF\x61\x7F\xF8\x5D\x61\x83\x80\x13\x86\x6D\x24\x96\x83\xED\x11\x7D\x8F\xDE\x6E\x03\x06\x1F\x82\x21\x08\x9A\x85\x79\x12\x82\x6A\x79\x4C\x98\x45\x00\xCF\x7F\x85\x04\xAC\x78\x6F\x3E\x86\x91\xD1\x08\x95\x87\x1B\x85\x88\x04\xE7\x64\x69\xFA\x6B\x73\x7A\x54\xA5\x90\x7E\xD9\x61\x89\xD1\x43\x88\x87\xC3\x49\x8E\x7F\x14\x73\x8F\x13\x86\x88\x80\xC6\x0A\x84\x81\x73\x0E\x82\xDB\x10\x83\x60\x4A\x90\x95\x93\xC7\x78\x03\x4A\x52\x91\x8D\x11\x90\x9D\x83\xA6\x74\x0D\x11\x01\x7D\x47\x82\x1D\x9E\x62\x9C\x95\x83\x57\x3E\x00\x04\x20\x17\x89\x20\x59\x8B\x8F\x20\x8E\x70\x8D\x82\x2D\x9E\x75\x63\x8D\x8C\x19\x38\x63\x19\x95\x35\x9A\x8D\x64\x75\x8D\xDA\x70\x6C\x8F\x67\xA2\x9C\x0E\x49\x75\x97\xD3\x02\x9C\x8A\x18\xB9\x93\x7E\xBC\x9D\x6B\xDA\x22\x8A\x70\x7D\xAE\x88\x74\x40\x1C\x6A\x1C\xA2\x92\x80\x82\xA4\x8A\x8A\x45\x7A\x8C\xE2\x15\x97\x79\x80\xAD\x84\x8E\xEB\x95\x2D\x21\x87\xA7\x90\xEF\x6D\x93\x91\x7D\x07\x9C\x40\x69\x99\x9F\x90\xA2\x7D\x9D\x02\x2F\x9E\x16\x8E\xA3\x9E\x1A\x29\x8D\x20\x37\xAC\xA0\x5A\x71\x9E\x71\x37\x91\xA0\x89\xA1\x8D\x7A\xD0\x16\xA4\x90\x63\xB8\x8A\x8F\x14\x7D\x9E\x35\xFF\x90\x91\x81\x8E\xA3\xA4\x40\x92\x86\x49\x8A\x94\x7C\x95\x80\x04\xA5\x0D\xAE\xA4\x19\x30\xA1\x20\x99\xAA\x9D\xA0\xF3\x93\x07\x4D\x82\x29\xA6\x78\xB4\xA6\xA7\x12\xA1\xAB\x28\xA0\xA5\xA1\x3B\x94\x61\x8F\x7B\x81\x9E\x1F\xCD\xAC\xAD\x8B\x90\xAD\x6F\x25\xB4\x84\x55\x8C\x9D\x99\x6A\x98\x31\x92\xB5\x73\x92\x5F\xE8\x20\xB0\xDF\x75\x01\x93\x01\x3B\x90\x47\xE3\x9F\x93\x13\x94\xA4\x94\xCF\x26\x9B\x29\xAE\x81\xB3\xE8\x24\xA3\x95\x53\xB6\x84\x4A\x87\x71\x97\xA2\x7B\x83\xB2\xEE\x77\x96\x65\xD1\xA2\x88\xFB\x7D\x90\x6C\xBF\x9F\x7F\x63\x83\x8E\x34\x28\x85\x9B\x85\x53\x89\x99\x15\xA6\x20\x08\xC8\x43\xB6\x22\x32\x61\x21\xE5\x6E\x67\x92\x5B\x2B\x26\xB7\xF8\x98\x32\x09\xC6\x64\x97\x8F\x91\x69\x34\x97\xA2\x04\xD6\x2D\x34\x71\x5E\x8A\xA9\xAB\x60\xA0\x0B\x42\xAE\x73\xB9\xB9\x74\xAF\xB8\xAA\x82\x04\xE0\x02\x7C\xB9\xC2\x65\x7B\xA3\x5F\xB7\xA0\x19\x52\xBC\x6C\xEA\xA0\x72\x74\x88\x65\x76\xC2\x7F\x82\x05\xD4\x66\x9A\xB0\x00\x06\xAE\x56\x9A\x0B\x24\xFA\xB7\xB1\x0F\x3C\xA5\x8D\x36\xDB\x94\x0D\x0B\x2B\x26\xBF\x00\x20\x9F\x4C\xDA\xA4\x9D\xDA\xA5\x3F\xBE\x8D\x80\x23\x23\xC7\x38\x61\xF5\xBC\xB9\x5F\x02\x39\x5E\x80\xEE\x65\xC1\x8D\x40\x25\x63\x82\x30\x06\x6D\xF1\xB9\xC3\x4B\x91\x0B\x25\x1F\xDD\x71\x86\xF0\x6A\x26\x18\x02\x84\x2B\x06\x9F\x8E\xEB\x02\x87\xB8\x64\xA0\x04\x2A\x44\x3A\x24\x79\xAA\x66\x24\x18\x3C\x9E\x75\x40\x16\xC0\x00\x18\xC5\xC7\x0D\xE5\xC0\x73\x3B\x0B\x25\x90\xA2\xC5\xC6\x12\xD9\xC7\xC4\x5D\x3F\x28\x08\x2B\xC2\x69\x16\xCD\x80\xC6\x56\x22\x31\x8E\xFE\x5C\xC3\x1E\xC7\xC5\xCA\x16\x30\x04\xCE\x43\xC5\x20\x2E\xF4\xC1\xCB\x46\xD5\xC4\x92\xA9\xC4\x62\x26\xF9\x68\x34\x2E\xD0\xC9\x51\x26\x2A\xC6\x1E\xD9\xCC\x39\x05\x30\xCF\x8F\xFB\xB1\x71\x88\x40\x25\x33\xE0\x83\xC5\x39\xED\xC1\x72\xC1\x31\x06\xC7\x7E\xCE\x04\x0D\x3E\x1B\x24\x42\xC4\xCE\x22\x31\x01\xCC\xA2\x82\x8F\x3B\xF0\x2C\xBB\x87\x25\xC2\x83\x7D\x79\x31\x70\x17\xE7\x3A\x30\x74\xAD\x3F\xFC\x00\x75\x2F\xF0\x1A\x6C\x7C\x33\xDA\x25\xA2\xC2\x64\x75\x1A\xE1\xD6\xCF\x8A\xD9\x0D\x0C\x0C\xD0\x3C\xF1\x05\x6E\x0B\x5C\x71\xD2\xD0\x13\xDA\x3E\x4B\xF3\x38\xD3\xA0\xBA\xD3\xF6\x45\x08\x0F\x31\x2C\x0D\x0E\x73\x09\x0E\x1D\x0D\x32\x0E\x50\xFC\xCD\x60\x88\xC0\xD2\x49\x31\x07\x92\x55\x2B\x26\xD9\x87\xCA\xD5\xAA\xAB\xD2\x69\x46\xEE\xD2\x04\xB0\xCB\xCB\x91\xB3\xD8\x3F\x5A\xCD\x87\xD2\xB4\xB9\xD0\x1C\x73\x7C\xD6\x5F\xC0\xDA\xD8\xC4\xC4\x7F\x74\xA8\xD2\x68\x51\xEC\xD6\xD1\x9E\xB1\xD7\xB6\xA0\x04\xD7\x4A\xDF\xDF\xD6\xE1\xD9\xD7\xB8\xDB\x7C\xD3\x8A\x13\xD6\xBB\xC7\xD8\xC9\x1E\x32\x0A\xD8\x8B\x07\x61\x06\xB8\x0B\x25\xC2\xD1\xD9\x62\x52\xE2\xD7\xD4\x06\x69\xD6\x0C\x6F\xD7\xDB\x15\x32\xDB\xD9\x92\xDD\xDA\xBD\xC9\x90\xDC\x8B\x22\xDB\x7E\x55\x0E\x0F\x74\x20\xDB\xDD\x88\xED\xD8\x60\x14\xEC\xBD\x0B\x17\xEB\xD0\x6E", -"\xD4\xD4\x0C\xB6\xDA\x3A\x49\x1F\xE7\x91\x3A\x22\x0A\x3C\xB1\x6D\xB9\xD7\x53\xC8\x20\x37\xC3\xE5\xE0\x03\xE2\xD0\x29\x2B\x23\xE8\x86\xD2\xE1\xE5\x45\x6B\xE6\xB6\x98\xEE\xE4\x6F\xDC\xE0\xDF\x16\x3E\xA1\xFB\x3A\xDB\x94\x9B\xF8\xE1\x0C\x3A\xFD\x0D\xC9\x86\xE7\xE9\x6A\xED\xD4\xBD\x16\xEB\xE9\xCB\xF4\xDA\xE2\x98\xF7\xDA\xE6\x51\xF4\xE5\xD1\x21\xE3\xE5\xAE\x41\xE2\xD4\x40\xEC\xD9\x0C\x50\xD5\x20\xBA\xDF\xCA\xDA\x27\xEC\xE8\x08\x56\xD0\xA1\x78\xE2\xE9\x0F\x26\xCD\xEB\xC6\xA0\x0D\xE3\x3C\x2A\xEA\xBB\x5F\x3E\xDF\xA7\x8A\xA5\xBC\x76\xFF\xEC\xDA\x7B\xFF\xEB\x5B\xD9\xD2\xD6\xB2\xEF\xE1\xE6\x3A\x27\xF1\xB9\xBF\xD1\xD9\x61\xCF\x0D\xD8\x6E\xF4\xCA\xA8\xF0\xC2\x20\x39\xC1\xD4\xCE\x64\x16\xCC\x00\x78\xC7\xEF\x44\xFB\xCA\xF4\x00\x60\xEB\xC1\x32\x05\xE9\x82\x35\xF7\xEE\x0D\xFF\xEF\xC4\xDE\xEE\xD1\xB7\xA1\xEE\xDD\x82\xE6\xEF\xD3\xE8\xE6\xF0\x7D\xE0\xE2\xE4\x92\x2A\xDD\xE3\xA6\xEA\xF7\x94\xEF\xAA\xE9\xC0\xF6\xF2\xD3\x84\xF0\xEB\xE2\xC2\xA0\x04\x54\xFC\x7A\xD5\xF1\x28\xEA\x80\xF0\xF6\x60\xA4\xE1\x22\xE9\x86\x6D\xC1\x85\x7C\xBA\xF5\xAC\xF8\x61\x81\xC1\x50\x20\x57\x7A\x21\x9B\xE8\xFD\xCE\x49\x59\x98\x67\x6E\x82\x25\x9B\x77\xF9\x9B\x8D\x80\x6C\xE7\x7E\x48\xDA\xD5\x71\x78\x39\x74\x72\x10\x76\x72\x6A\xD3\x68\x74\xD8\x64\x37\x95\x75\x6F\xC2\x74\x7D\xC4\x7A\x79\xBD\x6C\x79\xE8\x6F\x79\xCA\x7D\x7A\x07\x8C\x7B\xD7\x6A\x3E\x65\x63\x6F\x0C\x88\x79\xB8\x67\x7D\xD9\x7D\x6F\x9E\x69\x75\x6F\x71\x7B\x57\x61\x32\x33\x05\x7B\x02\x17\x7B\xEA\x79\x77\x06\x78\x80\x2B\x7B\x81\x7A\x7D\x81\x67\x79\x79\xC6\x75\x73\x37\x7C\x7D\x59\x7B\x75\x03\x7D\x75\x91\x70\x6F\x22\x06\x71\x32\x83\x76\x34\x83\x7C\x36\x80\x82\xFB\x6B\x76\xC8\x7E\x06\xE4\x3C\x7E\x00\x0E\x7E\xEA\x5B\x30\x01\x25\x10\x53\x8F\x7E\xEB\x55\x7E\xDA\x41\x38\xE1\x70\x10\x70\x69\x67\xF3\x7B\x5E\x05\x6E\x63\x96\x39\x5B\x00\x1B\x5B\x0C\x64\x03\x9C\x35\x10\x69\x8A\x53\x9F\x35\x34\xE8\x55\x6A\x16\x19\x4D\x6F\x59\x3A\x4E\x80\x85\x5F\x8B\x30\x86\x15\x10\x79\x86\x85\x0B\x38\x85\x23\x32\x07\x74\x0B\x85\x00\x00\x67\x14\x3E\x85\x71\x80\x86\x75\x82\x7F\x87\x8B\x30\x0F\x0B\x12\x8D\x8F\x7F\xF4\x7F\x87\x74\x00\x61\x01\x19\x2F\x29\x3C\x87\xC8\x32\x86\x6E\x36\x55\x58\x58\x16\x7E\x8E\x30\x80\x84\x89\x00\x16\x89\x15\x3C\x86\x6F\x3A\x89\xC7\x12\x88\x72\x66\x39\x22\x30\x8A\x74\x0F\x31\x01\x17\x89\x96\x3A\x31\xDF\x79\x65\x09\x60\x00\xAD\x3D\x61\xD9\x42\x89\xF1\x70\x10\x85\x87\x77\x36\x65\x82\x35\x60\x8B\xFF\x7A\x65\x92\x84\x86\x00\x07\x32\x97\x83\x62\xC2\x88\x68\xB7\x89\x8B\xCB\x6F\x89\x0F\x3D\x8B\x28\x35\x8A\x06\x8D\x8C\xAA\x64\x8C\x02\x7C\x6C\xC7\x84\x39\xB1\x80\x02\x16\x8F\x8C\xCE\x4B\x54\x7E\x46\x5F\x05\x16\x8E\x72\x56\x49\xBB\x8E\x8A\xF6\x71\x10\xDD\x4F\x8B\xE9\x87\x3C\x3E\x02\x8E\xF7\x55\x58\x16\x0B\x12\xF7\x85\x8F\xD7\x4E\x3B\x92\x8C\x55\x00\x1D\x4E\xB2\x8E\x4F\x7E\x4E\x03\x9C\x83\x8E\xD0\x52\x5E\x1C\x0B\x12\x09\x97\x5F\xF9\x52\x3E\xD2\x80\x88\x00\x65\x10\x11\x90\x8F\x03\x60\x56\x04\x90\x5F\xF2\x50\x56\xD4\x45\x10\x1B\x99\x91\xE2\x5D\x8A\x0F\x39\x8F\x05\x12\x92\x01\x9D\x52\x16\x94\x8F\xF1\x5B\x58\x74\x05\x90\xFA\x8F\x4F\x82\x68\x58\x00\x1A\x58\x02\x9E\x49\x71\x3B\x3C\xAB\x5E\x43\x74\x59\x4A\xC9\x5C\x4A\x7B\x5F\x5D\x9D\x53\x4B\x39\x92\x5A\x3F\x48\x57\xBB\x46\x5A\xAF\x48\x5A\xFD\x3A\x5A\x42\x5C\x5A\x05\x41\x1B\x18\x54\x45\xCB\x42\x65\x2C\x99\x92\xE1\x52\x4F\xFE\x80\x00\x5E\x56\x92\x1F\x95\x03\xF7\x45\x10\x5D\x96\x8A\x0D\x94\x06\x68\x50\x54\x73\x44\x54\x76\x46\x54\x19\x51\x57\x2A\x94\x57\x66\x92\x52\xB8\x44\x5A\x98\x5A\x57\x9A\x54\x72\xE5\x55\x91\xE2\x57\x63\x6B\x90\x5A\x6D\x96\x50\x70\x94\x3F\x46\x9D\x07\x40\x0D\x29\x3D\x75\x8B\x03\x72\x2D\x48\x1A\x13\x0F\x2D\x2D\x19\x19\x88\x90\x8B\x5E\x86\x9A\x88\x79\x02\x20\x21\x00\x2D\xFF\x08\x8A\x98\x1A\x8D\xB3\x56\x11\x02\x23\x02\x94\x98\x8D\x30\x0F\x98\xFF\x72\x20\x25\x0D\x99\x84\x91\x03\xA0\x92\x70\x02\x27\x02\x94\x98\x92\xF1\x8F\x15\x98\x91\x95\x26\x12\x20\x29\x04\x99\x53\x9E\x91\xF2\x4F\x9A\xC7\x18\x98\x2B\x1B\x02\x94\x9F\x01\xF3\x2C\x2A\xEB\x2F\x0F\x02\x2B\x2E\x89\x95\x9C\xC6\x91\x27\xC1\x90\x27\x7C\x27\x9C\x2B\x1A\x9C\xD2\x24\x9C\xC6\x98\x8D\x32\x02\x2D\x28\x0C\x9C\x83\x97\x9D\xDB\x82\x2D\x26\x06\x9D\xFE\x7D\x9D\x25\x6A\x9C\x02\x24\x8D\xD8\x59\x4B\x1B\x6B\x5D\x83\x34\x07\x96\x98\x16", -"\xFF\x01\x9C\xD2\x2B\x27\xC7\x9E\x9C\x2B\x10\x9D\xC5\x92\x9D\xD4\x9C\x9D\x02\x18\x8D\xA6\x9B\x12\xDB\x96\x9F\x17\x64\x98\x30\x00\x9E\x2B\x12\x9E\x7A\x38\x5C\x40\x41\x70\xCB\x5A\x35\xE9\x9A\x99\xC0\x94\x20\xAB\x2F\x9B\xCC\x9E\xA0\xCF\x9C\x9F\xFD\x98\x9D\x18\x35\x9F\x12\xA8\x9F\xDA\x92\xA1\x3B\x6E\x9F\xC5\x9B\x9E\x04\x2A\x63\x00\xA5\x9C\x10\xA7\x2A\xFC\x99\xA0\x79\x02\x2D\x2C\x0A\xA1\xB5\x96\x97\xF2\x42\x9F\xBC\x17\x65\x3E\x42\x20\xAC\x9A\x92\x1E\xAC\x20\x82\x99\x14\x1A\xAB\x27\xED\x9A\xA1\x26\xA8\xA2\x2A\xA8\x91\x2C\xAE\x38\x0C\x21\x9C\x82\x8A\x63\xC7\x9B\x2E\x3B\xA2\xA1\x26\xA3\xA4\x04\x2A\x9C\xEE\x91\x9D\xA0\x2B\x12\x0E\xA7\x9C\x3D\xAB\x12\x22\x0A\xA1\x8C\x92\x70\xD9\x41\xA1\x17\xA4\x98\xD3\x9B\x12\xD5\x9D\xA5\x14\xAE\x67\x19\xA2\xA6\xDE\x99\x61\x21\xA5\x10\x02\xA0\x1A\xF1\x35\x9E\x81\x37\x9E\x26\xA5\xA3\xFA\x29\xA4\xFC\x9A\x63\xD2\x23\xA5\xC6\x95\xA5\x08\x17\xA5\x12\xA9\xA5\x98\x8C\xA5\x75\xAE\xA5\x16\xA1\xA8\x63\xAB\x6C\x65\xA4\xA8\x67\xA5\x63\x69\xA2\x10\x6B\xAB\x37\x05\xA4\x65\x07\xA4\x38\x4B\xAB\xA0\x0C\x2D\xA0\x1A\xA7\x9A\xE0\x2C\xA3\x27\x86\x39\xD2\x2C\xA7\xFC\x9E\xA7\x51\x84\x07\x80\xA6\x9F\xF4\x90\xA6\x1A\xA8\xA1\xFA\x97\xAA\x1C\xA2\x20\x72\xA0\x21\xEB\x2B\x2A\xC7\x9F\xA4\xC5\x98\x9B\x98\x1A\x9B\x08\x13\xA3\x33\x97\x3C\x8B\xA2\x7E\xCB\x11\x10\x3A\x90\x44\x59\xAC\x93\x9A\x58\xAB\xE4\x8D\x3B\xFF\x0B\x27\xC7\xA0\x29\xCA\xAC\xA4\x1F\x24\xA2\xAE\xA1\xA5\x08\x18\xAC\xAF\xA2\xA5\x04\x2B\x2E\xEB\x29\x86\xCF\xA8\x10\x4E\x82\x8A\x94\xA6\x1B\x08\x1E\x01\xD5\xAB\x1A\xDF\xA1\xAE\x08\x17\xA3\x02\x1D\x01\xE4\xA5\x10\xC8\x88\xAE\xBA\x2B\x12\x29\xAD\x2E\x1A\xA4\xAB\xA9\x12\x18\x32\xAD\x57\x54\x95\xAC\xBA\xA6\x9C\xAA\x8E\xAB\x42\x91\x3F\xC1\xA9\x59\xE2\x34\xAC\x7F\x5B\x8F\x3A\x6F\xAE\xFC\x92\xB0\x84\x5B\x8F\x78\xA2\xA1\x2B\xA5\x95\x8E\x3B\xAB\x00\x19\x87\x02\x19\x87\x7B\x97\x57\x92\x1E\xA0\x84\x23\x44\x0D\xBA\x95\xF2\x49\xAC\xDA\xAB\xAC\xFA\x26\xAD\x9B\x39\xAE\x40\x1B\x12\xE0\xAC\xAC\xAF\x22\xAE\x21\xBA\xB2\x02\x17\xB2\x2B\xB5\xAE\x2B\x1C\xAE\x2F\xBA\xAE\x31\xB4\xB2\x66\x21\xAD\x36\xB0\x10\x74\xA9\xAD\x2F\xA3\x28\xF1\x9E\x8D\xF0\xA2\xA1\xF2\xA9\x1B\x0A\xA7\xAB\xF6\xAD\x9A\x74\x00\xB1\x83\x8D\xAB\xCD\x1D\xAF\xB9\x4F\xAF\x72\x91\xB0\x47\xBA\x92\x3A\x68\x8C\xC7\x98\xB0\x16\x15\x58\x0B\xBC\x9F\x1B\xB7\x90\xF2\x4A\xB4\x12\xB1\x10\x14\xBF\x54\x6F\x93\x1D\x50\xB9\x48\x9A\x5D\xB5\x3B\x54\x53\x89\x9D\xAA\x01\x1F\x0F\xB7\x86\xAE\xD9\x29\xB3\x1B\xA6\x1A\xC6\x9B\x2E\x4A\xBB\xAF\x4D\xB5\x59\x43\x92\x19\x67\xB7\x52\x58\xBF\x3A\xFB\x8D\xAD\x3C\xB7\x1D\x39\xA1\xAF\x95\x10\x00\x99\x91\x99\xF6\xA2\x41\x06\x99\xB0\xFF\x49\xB7\x4C\xB0\x00\xBF\xA3\x1D\x18\xB1\x10\x43\x41\xB8\x85\x5E\xB1\xFA\x2B\x27\x59\xA5\xB8\xC2\x2C\xB2\x6F\xBB\x2E\xDC\xAE\xB2\xA0\xBD\x17\xE3\xA8\xB2\x02\x12\xB7\x00\x12\xB3\xA7\xB9\x8C\x35\xBA\xBA\x73\xB8\x10\x19\x04\xB7\x4E\xA4\xB7\x3B\xB3\xBA\x57\x69\xA9\xED\xA8\x10\x06\xBD\x1D\x88\xB6\xB7\x96\x10\x9B\x45\xBC\x3A\x53\xB9\xAB\x5F\x12\xB9\x08\x10\x67\x95\xB7\xB1\xD4\xA0\x10\x99\xB7\xBC\xF8\xAF\x15\x05\xBA\xA1\x9A\xBA\xB0\x1A\xA2\x20\x6A\xB6\x11\x61\x90\xB6\x85\x11\x10\x15\xB5\xB6\xCE\xBE\xB3\xD0\xB6\x3F\xDB\xB8\x5F\x34\x5C\xB9\x02\x1F\xB9\xBA\xBD\xBB\x05\x1B\x01\x74\xBB\xAD\x74\xB4\x1C\xA6\xBD\xBE\x05\x15\xBA\x74\xBC\xBA\x00\x0E\xBA\xF6\xB3\x33\xB1\xB3\xB3\x35\x2E\xAC\xFD\xB4\x27\x02\xC8\x9C\xBB\xB4\x2F\x3F\xB6\x32\xD0\xAC\x9F\x43\xB8\x1C\xC5\xBE\xB8\x46\xBD\x92\x7E\x4A\xBC\x71\x6C\xAF\x7C\xB1\x3F\x97\xB5\xBE\x79\x07\xBD\xFF\x45\xB5\xD6\xB2\xBD\x03\xBF\x4F\x5B\xB6\x9F\xE7\xBD\xBD\xC6\x91\xB6\x11\xB0\xBE\x64\xB3\x5A\x66\xB0\xB2\xC2\xA2\x3E\x25\xCC\xB6\x0F\x2E\xB6\x71\x21\xB7\x09\xC0\xC0\x1C\x39\xB8\x0F\x28\xB7\xFA\xA3\xB9\xCD\xBE\x06\x19\xC0\x00\xD1\xB1\xC1\xF7\xA1\xC2\x7E\x42\xBB\x71\x2A\x63\xAA\x77\xA4\x37\xCF\x20\xDC\xA9\x2F\xE1\xB9\x17\xDA\xB0\xA4\x0E\xB9\x36\xAC\xA1\x9C\x8F\x84\xB3\xD9\xBD\xB6\xC1\x9A\x63\xC4\x1C\xC4\xEE\xBE\xC4\x2A\xB3\x4C\x4E\x97\x3D\xF5\xA4\xC4\x48\xBB\xC5\x03\xC6\xC0\xCB\xBA\xC6\x38\xC1\x27\x7B\x2C\xAD\xC3\x95\xC0\xCB\x98\x9D\x02\x12\xAB\x89\x91\xC3\x5A\x53\xC2\xDC\x93\xA9\xD6\x94\xC3\xAC\x20\xA2\x87\xB1\xB4\x5A\xCC\xB5\x54\xCC\xB1\x8E\x3E\xA2\x86\xB4\x25\x16\xC1\x1C\x67\xC6\xBC\x12\xC6\xAC\xC1\x9A\xBF\xD2", -"\x20\xC6\x38\xAA\xC0\x0C\xB7\xC8\x5E\xB2\xA4\x1A\xA0\xC8\xFF\x09\xC5\xFE\xBE\xC6\x6F\xC4\xB8\xF1\x1A\xA1\x8A\xCB\x20\x0D\xC6\xAB\x90\xCB\xCA\x48\xBA\xBE\x6F\xBE\xB9\x77\xBE\xAE\xCD\x91\xBC\xDE\xAA\xB8\xC4\xBC\xB8\x44\xC0\xC1\x45\xC0\xB9\x7E\x45\xBD\x12\xAC\xC1\x7E\x4C\xC7\xD6\x9A\xC7\x60\x5E\xBD\x08\x13\xB6\x2E\x56\xB1\x40\xCF\xBC\x42\xC6\xBE\x9A\xCB\xB6\x5A\x5E\xCA\xED\x71\xCB\x98\xC5\x10\x4A\xB2\x20\xA9\xC4\xAF\x8D\xBE\x48\x8F\xB9\xB5\x04\xB0\xB4\x07\xB0\xC2\xBC\xCD\x3B\xC2\xCC\x9C\xC4\xC2\x5E\xC6\xCA\x87\x2A\xC9\xCC\xE2\xBE\x06\x7F\xBA\x48\xE7\xC2\x4F\xC6\x9E\xC9\xEB\x20\xCA\x6E\xC2\xCD\xAC\x2B\x27\xB7\x83\xC7\x08\x1B\x9F\x2E\x24\x65\x02\x1E\xCF\xF6\x96\xA2\xE5\xC7\x9C\x9E\x98\xCF\x53\x8B\xC3\xF0\x57\xC7\x00\xD8\x4E\x9A\xAC\xC8\xF7\x57\xCA\x3A\xBB\xC0\xC7\x52\x20\x9E\x92\xCA\xFC\x94\xCF\xDF\xB8\xD1\xF9\xC4\x20\x7B\x27\x95\x3A\x60\xC8\xEB\x20\xBF\x48\xCF\x84\xA2\xBC\xC6\xB5\xCD\xB2\x74\xB8\xBF\x25\xDA\xBF\xFC\xB8\xD2\xA1\xC5\x10\x2F\xD0\x00\xEB\x21\xA6\xFF\xC6\xC7\x01\x16\xD3\xA4\xAE\x9F\x05\xD0\xA5\x85\xA8\x68\xF8\xCD\x8E\x13\xA3\xCA\xD7\xA1\xBF\x27\xD4\xCA\xA8\xB5\x10\xF5\xB0\xD3\x95\x86\xB2\xF9\xBF\xBF\xAF\xBB\xAE\x4D\xC1\x10\x33\xDB\x27\x3A\x63\xD3\x06\xDE\x9F\x12\xD5\xB7\xDD\x9C\x80\x16\xD5\x9A\x9E\xCE\xA0\x56\x5E\xA0\x80\xC7\xBB\x25\xD9\xBB\x4C\xD4\x21\xCC\xCF\x20\x7B\x2A\xBF\x02\xDC\x9D\x9E\x9B\xD5\x01\x78\x62\xC7\x3F\xD5\x3F\xD0\x78\x1D\xA1\x9C\xEB\x28\xC2\xCC\x9B\xD5\xD8\xC9\xB8\x6A\x6A\xCA\xF7\x9E\x9F\xF8\xC8\xCF\x20\xD4\xB7\x23\xD6\xD4\x08\x1C\xAD\x80\xC4\xBF\x2B\xDE\xD4\x2D\xD0\xD5\x6B\xC0\xBB\x08\x13\xD3\x35\xDB\xD6\xDC\x9A\x8D\x81\xDA\xCD\x38\xD3\xD4\x25\x6A\x63\x3A\xD0\xD7\x3C\xDC\xD1\x5C\xD3\xD8\xFF\x71\x03\x41\xDD\xD0\x69\xD0\x00\x2C\xD4\xD4\x23\xB5\xD2\xF2\xB5\xD2\x8E\xD1\xD9\x95\xD4\xB7\x52\xD1\xC6\x54\xD8\xD9\xD6\x9A\xD9\x0D\x15\x15\x6B\x6F\xC0\x39\xC7\xD7\x30\x07\xD5\xAA\xA2\xDC\x72\xD4\x65\x5E\xDA\xDA\x5C\xD2\x6A\x61\xDB\xD0\x08\xC5\xD2\x66\xD3\xCA\x68\xD8\xD4\x00\x06\xA9\x22\xA4\xCB\x25\xBB\x10\xBD\xD1\x63\x9C\xDD\x9D\xA6\xD2\x70\x30\x0E\xD6\xC5\xD9\xA8\x59\x67\xDC\xD8\x94\xD7\x5F\x16\xD7\xE4\xD8\xD7\xC7\x9E\xC9\xD1\xD6\x9F\x3A\xAE\xDC\xD6\x9E\x99\x4A\xBD\xA8\x04\xA3\x1D\x6E\xAC\x5D\x08\xAB\xA9\x6E\x3E\xC9\xD3\xD1\xAB\x0B\xC8\x45\xE3\xDF\xDD\xDF\x96\x9C\xF6\xD1\x3F\x06\xA0\xA7\xFC\xD7\x1C\xAB\xD5\x99\xBA\xDD\xD7\x01\xEE\xD0\x66\xA4\xE0\x19\x6A\xC6\x1A\xD4\xBB\xA4\xD5\xD8\x7B\x21\x91\x01\xC5\xD2\x89\xD0\xDB\x47\xDD\xD8\x90\xD3\xCA\xAD\xDC\x2C\x23\xEC\xD0\x9D\xD0\x00\x4B\xDC\x9C\xF8\x96\xDE\x5D\xD5\x76\xEA\xD4\xE1\x06\x38\xCF\x22\x9D\xE1\xAE\xD8\x10\x24\xD3\xCA\xB1\xD3\xCA\xB3\xD4\xE2\x27\xE3\xBB\x05\x1B\x2E\x56\xD3\xD5\xF3\xD5\x9A\x3D\xD3\x9F\x5E\xAD\xDC\x08\x1B\x91\x28\xE3\xCA\x2E\xD6\xDB\x92\xD7\x20\x6D\xD6\xAA\x13\xE1\xDC\xDB\x8B\xD5\xA7\x9C\x77\x31\xE6\xE5\xA2\x69\xD7\x74\xB5\xBB\x1C\xDA\xE1\xFF\x53\xCB\x1E\xEB\x12\x39\xEF\xBA\x3B\xEF\xBA\x3D\xEF\xBA\x25\xE0\xE4\x2A\xD8\xB3\x29\xEB\xE2\x59\xD7\xD7\x31\x0E\xE2\xDF\xD9\xDC\x29\xEE\x73\x32\x04\xE3\x64\xE7\xE3\x6A\x8A\xD8\xF7\xB3\xBF\x3F\xEB\xDA\x6D\xE6\x2E\x44\xE5\xC7\xDE\xDE\xE6\xA2\xD4\xE7\x47\xE9\x98\xD2\x9A\xE4\x1C\x94\xC7\x80\xCF\xE4\x25\xD7\xDB\x89\x93\xE5\x08\x11\xDA\x45\xE4\xE7\x58\xEB\xC0\x5A\xEA\xDC\x3E\x71\x03\x5E\xE5\xD2\x67\xE7\xCF\xC1\x9B\x27\x0B\x97\xD3\x7E\xE2\x10\xD8\xA3\xD9\x69\xEA\xE8\x00\x1E\xA9\x4D\xEF\xDD\x02\x12\xEB\x8B\xEB\xDE\x32\x0D\xE8\x0F\x20\xAA\x77\x80\x16\xC1\x9E\xA0\xE6\x83\xEB\x93\xDB\xE6\x93\xD5\xE8\x03\x28\xE9\x41\xE3\xE0\x5C\xE0\x30\x9D\xE4\xC8\x9F\xE9\xE7\x90\x92\x03\xA3\xE3\xCA\xA5\xE6\xE1\xA7\xEA\x90\x92\xE2\xB2\x08\x1D\xEA\xAB\xDF\xEA\x86\xEB\xA7\x74\xCA\x63\xB6\xEB\xE9\xB8\xEA\xEB\x0B\x2C\xEB\x8B\x8E\xEB\x04\x20\xEC\xD9\xEA\xC3\x01\x1B\xE2\x80\xC6\xEC\x02\x28\xEC\x26\xE5\xE5\x9E\xDC\xEC\xC6\x99\xE5\x5F\x7B\xE5\xF7\xE6\x30\xF6\x9E\xC9\x94\xEC\x9F\x78\xCF\x20\x1B\x65\x78\xFC\xEB\xDC\x7E\x6A\xB4\x89\x21\x10\xED\x19\xA5\x22\x8F\x6F\xF8\x9D\xE0\x96\xE0\xDF\x0F\xDD\xB3\x00\x06\xF0\xA0\xE0\x99\x31\x0A\xF0\x24\xAD\x1E\xD4\x8B\x79\xE7\x6E\x79\x72\x01\xF1\xA4\xD3\xD9\x62\x13\xE8\xCC\x93\xF0\x0B\x25\xF0\xD5\x77\xF0\x7A\xEC\xF1\x70\xE0\x00\xED\x17\x9A\x6C\x72\x19\x8F\xE1\x9C\xF2\xE6\x9C\x2A\xF7\x20\x2C\xF4\x7C\x2E\xF1", -"\xED\x30\xFA\xEA\x0D\xFE\xC2\xDB\x79\x73\x74\x02\x9D\x19\xDA\xD7\xAF\xD8\xD1\x9E\xCB\x27\x20\x04\xCD\x05\x1E\xA0\x43\xE4\xBE\x9F\xA0\xB2\x98\x86\xEE\x3C\xFB\xE0\x98\x1F\xC7\xC9\x94\xC7\xC7\x93\xA2\xB5\xD6\xEF\x08\xF6\xA8\xA9\xA2\xF6\x3E\x7F\x9F\x06\xE1\xA0\x01\x13\x9E\x40\x49\xDF\x0A\xE0\xD1\xBB\xC0\x13\xEC\x9E\xF5\xC6\x90\xF6\x32\xDA\xEC\xFD\xE8\x68\x87\xAB\xD3\xC2\xD5\xDF\x6A\xF0\x10\x6C\xF3\x1D\x09\xED\x5D\x93\xAE\xC9\xD6\xD2\xF0\x11\xED\xBA\x78\xF3\xF6\x7A\xF5\xF6\x88\xA2\xE3\x59\x63\xC3\x5D\xF1\xF3\xF6\x90\x9F\xA9\xBF\xF8\xCB\xE6\x30\x83\xAC\xF7\xEB\xD9\x9F\xFD\xCB\xF8\x67\xFE\xF7\x9C\x1B\xF6\x03\xAD\xA6\x57\x66\x9E\x84\xFA\xF5\xEA\x93\xF7\x94\xFC\x9D\x96\xFA\xD4\xA0\xF1\xED\x9B\xF7\xEB\x90\xFA\x6A\x7B\xF4\xFB\x99\xF9\x65\xA2\xFA\xA6\xA4\xFC\xA6\xB9\x43\xF8\xFB\xD0\xF7\xAE\x3D\xE0\x87\xF6\x9F\x76\xFF\xE6\x98\xF9\xF7\x85\x94\xE5\xC9\xFC\xF8\xB6\xFE\xF8\x9C\xF5\xFB\x30\x05\xF2\x0D\xEE\xED\x25\xFE\xC9\x02\x23\xEE\xD4\xF2\xF9\x4D\xA4\xF7\xC5\x98\xA9\x01\x1A\xFD\xC7\x98\xEE\x79\x0B\xA5\x87\xE3\xE7\xB8\xE3\xFB\xE4\xE5\xFB\x9E\xF5\x10\x6F\xDB\xFE\xB9\xF0\x78\xBB\xFC\xA8\xBD\xFE\xA8\xF8\xD7\xFA\x6F\xA9\xFA\xC2\xF6\x39\xFE\xDE\xFD\x89\x90\xFE\xB1\x70\x4B\x56\x7B\x50\x53\xAA\x38\x7E\xF2\x7F\x52\x99\x71\xF6\x67\x6D\xDB\x70\xFF\x4A\x7C\xDA\x65\x4E\x07\x77\xF7\x50\x55\xB7\x76\xF1\x43\x7C\x75\x6E\x70\x54\x7D\xF2\x49\x7C\x00\x02\xFE\x46\x4C\xF9\x66\x7F\xB8\x6D\x01\x8E\x7E\x04\x85\x10\x1A\x74\x8B\x65\x4D\x0C\x87\x04\x82\x6F\x2B\x64\x20\x02\x10\x09\x1B\x7E\xCC\x4E\xBD\x7E\x7E\x85\x6D\xAC\x10\x83\xDF\x7E\x0C\xA5\x7C\x3C\x78\x7E\xFD\x62\xA9\x2A\x7E\xDC\x64\x10\xFF\x68\xEA\x76\x71\x07\x11\x01\x8F\x54\x76\x51\x54\xE8\x4E\x07\x8C\x5C\xC3\x7F\xE0\x57\x7D\x70\x42\x10\xEF\x78\x06\x87\x10\x19\x8D\xFA\x56\x4D\x7C\x7F\x7C\x66\x78\x32\x4F\x81\xC4\x45\x04\xF7\x7C\xDC\x68\x7D\xC1\x7D\x02\xBC\x7E\xD6\x7A\xEA\x14\x78\x21\x61\x68\x0A\x80\xBC\x73\x7E\x89\x15\xFF\x77\x6E\xCD\x73\x80\xFA\x7A\x0C\xAE\x1A\xE2\x7D\x04\xC2\x80\x01\x78\x82\xCD\x7F\xEC\x6C\x80\x06\x12\x20\x26\x82\x14\x9B\x83\xFA\x17\xBD\x5C\x4F\xE3\x79\xD3\x69\x82\xA8\x29\x81\xE8\x7A\xFA\x6B\x83\x3B\x3D\x06\xA6\x7F\x17\x99\x7F\x61\x83\x91\x71\x7B\x8B\x04\x06\xC2\x76\x75\x44\x84\x00\x0E\x0F\xBE\x69\xCE\x78\x08\x9B\x86\x22\x89\x7B\xA3\x78\xF0\x79\x80\x23\x8D\x9D\x48\x81\xE1\x61\x4E\xC5\x7C\x3B\x57\x83\x12\x86\x08\xE4\x50\xF4\x66\x80\xCE\x7B\xFA\x74\x5A\xE1\x4B\x12\x2A\x03\x1F\x8D\x6F\x5D\x65\xCF\x76\x4E\x6D\x79\x98\x1B\x31\x8C\x5B\x66\x0A\x35\x9B\x42\x5D\x7F\x20\xF0\x1B\x80\xF5\x78\x7E\xB2\x67\x16\x93\x76\x08\x12\xC8\x12\x53\x2A\x82\x08\xBF\x5C\x3B\x71\x67\x44\x69\xA7\x30\x52\x50\x4F\x64\xBA\x65\x95\x53\x64\x63\x86\x07\x93\x6A\xEF\x5F\x51\x08\x0D\x13\x5C\x5E\x19\x6F\xBA\x7F\x05\x91\x4A\x86\xA2\x60", -}; - - void GuiIqGetParserBuffer(vl::stream::MemoryStream& stream) - { - vl::stream::MemoryStream compressedStream; - for (vint i = 0; i < parserBufferRows; i++) - { - vint size = i == parserBufferRows - 1 ? parserBufferRemain : parserBufferBlock; - compressedStream.Write((void*)parserBuffer[i], size); - } - compressedStream.SeekFromBegin(0); - vl::stream::LzwDecoder decoder; - vl::stream::DecoderStream decoderStream(compressedStream, decoder); - vl::collections::Array buffer(65536); - while (true) - { - vl::vint size = decoderStream.Read(&buffer[0], 65536); - if (size == 0) break; - stream.Write(&buffer[0], size); - } - stream.SeekFromBegin(0); - } -/*********************************************************************** -Unescaping Function Foward Declarations -***********************************************************************/ - -/*********************************************************************** -Parsing Tree Conversion Driver Implementation -***********************************************************************/ - - class GuiIqTreeConverter : public vl::parsing::ParsingTreeConverter - { - public: - using vl::parsing::ParsingTreeConverter::SetMember; - - bool SetMember(GuiIqNameOption& member, vl::Ptr node, const TokenList& tokens) - { - vl::Ptr token=node.Cast(); - if(token) - { - if(token->GetValue()==L"Specified") { member=GuiIqNameOption::Specified; return true; } - else if(token->GetValue()==L"Any") { member=GuiIqNameOption::Any; return true; } - else { member=GuiIqNameOption::Specified; return false; } - } - member=GuiIqNameOption::Specified; - return false; - } - - bool SetMember(GuiIqChildOption& member, vl::Ptr node, const TokenList& tokens) - { - vl::Ptr token=node.Cast(); - if(token) - { - if(token->GetValue()==L"Direct") { member=GuiIqChildOption::Direct; return true; } - else if(token->GetValue()==L"Indirect") { member=GuiIqChildOption::Indirect; return true; } - else { member=GuiIqChildOption::Direct; return false; } - } - member=GuiIqChildOption::Direct; - return false; - } - - bool SetMember(GuiIqBinaryOperator& member, vl::Ptr node, const TokenList& tokens) - { - vl::Ptr token=node.Cast(); - if(token) - { - if(token->GetValue()==L"ExclusiveOr") { member=GuiIqBinaryOperator::ExclusiveOr; return true; } - else if(token->GetValue()==L"Intersect") { member=GuiIqBinaryOperator::Intersect; return true; } - else if(token->GetValue()==L"Union") { member=GuiIqBinaryOperator::Union; return true; } - else if(token->GetValue()==L"Substract") { member=GuiIqBinaryOperator::Substract; return true; } - else { member=GuiIqBinaryOperator::ExclusiveOr; return false; } - } - member=GuiIqBinaryOperator::ExclusiveOr; - return false; - } - - void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) - { - } - - void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) - { - SetMember(tree->childOption, obj->GetMember(L"childOption"), tokens); - SetMember(tree->attributeNameOption, obj->GetMember(L"attributeNameOption"), tokens); - SetMember(tree->attributeName, obj->GetMember(L"attributeName"), tokens); - SetMember(tree->typeNameOption, obj->GetMember(L"typeNameOption"), tokens); - SetMember(tree->typeName, obj->GetMember(L"typeName"), tokens); - SetMember(tree->referenceName, obj->GetMember(L"referenceName"), tokens); - } - - void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) - { - SetMember(tree->parent, obj->GetMember(L"parent"), tokens); - SetMember(tree->child, obj->GetMember(L"child"), tokens); - } - - void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) - { - SetMember(tree->first, obj->GetMember(L"first"), tokens); - SetMember(tree->second, obj->GetMember(L"second"), tokens); - SetMember(tree->op, obj->GetMember(L"op"), tokens); - } - - vl::Ptr ConvertClass(vl::Ptr obj, const TokenList& tokens)override - { - if(obj->GetType()==L"PrimaryQuery") - { - vl::Ptr tree = new GuiIqPrimaryQuery; - vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); - Fill(tree, obj, tokens); - Fill(tree.Cast(), obj, tokens); - return tree; - } - else if(obj->GetType()==L"CascadeQuery") - { - vl::Ptr tree = new GuiIqCascadeQuery; - vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); - Fill(tree, obj, tokens); - Fill(tree.Cast(), obj, tokens); - return tree; - } - else if(obj->GetType()==L"SetQuery") - { - vl::Ptr tree = new GuiIqSetQuery; - vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); - Fill(tree, obj, tokens); - Fill(tree.Cast(), obj, tokens); - return tree; - } - else - return 0; - } - }; - - vl::Ptr GuiIqConvertParsingTreeNode(vl::Ptr node, const vl::collections::List& tokens) - { - GuiIqTreeConverter converter; - vl::Ptr tree; - converter.SetMember(tree, node, tokens); - return tree; - } - -/*********************************************************************** -Parsing Tree Conversion Implementation -***********************************************************************/ - - vl::Ptr GuiIqPrimaryQuery::Convert(vl::Ptr node, const vl::collections::List& tokens) - { - return GuiIqConvertParsingTreeNode(node, tokens).Cast(); - } - - vl::Ptr GuiIqCascadeQuery::Convert(vl::Ptr node, const vl::collections::List& tokens) - { - return GuiIqConvertParsingTreeNode(node, tokens).Cast(); - } - - vl::Ptr GuiIqSetQuery::Convert(vl::Ptr node, const vl::collections::List& tokens) - { - return GuiIqConvertParsingTreeNode(node, tokens).Cast(); - } - -/*********************************************************************** -Parser Function -***********************************************************************/ - - vl::Ptr GuiIqParseAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex) - { - vl::parsing::tabling::ParsingState state(input, table, codeIndex); - state.Reset(L"QueryRoot"); - vl::Ptr parser=vl::parsing::tabling::CreateStrictParser(table); - vl::Ptr node=parser->Parse(state, errors); - return node; - } - - vl::Ptr GuiIqParseAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::vint codeIndex) - { - vl::collections::List> errors; - return GuiIqParseAsParsingTreeNode(input, table, errors, codeIndex); - } - - vl::Ptr GuiIqParse(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex) - { - vl::parsing::tabling::ParsingState state(input, table, codeIndex); - state.Reset(L"QueryRoot"); - vl::Ptr parser=vl::parsing::tabling::CreateStrictParser(table); - vl::Ptr node=parser->Parse(state, errors); - if(node && errors.Count()==0) - { - return GuiIqConvertParsingTreeNode(node, state.GetTokens()).Cast(); - } - return 0; - } - - vl::Ptr GuiIqParse(const vl::WString& input, vl::Ptr table, vl::vint codeIndex) - { - vl::collections::List> errors; - return GuiIqParse(input, table, errors, codeIndex); - } - -/*********************************************************************** -Table Generation -***********************************************************************/ - - vl::Ptr GuiIqLoadTable() - { - vl::stream::MemoryStream stream; - GuiIqGetParserBuffer(stream); - vl::Ptr table=new vl::parsing::tabling::ParsingTable(stream); - table->Initialize(); - return table; - } - - } -} - -/*********************************************************************** -WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWCODEGEN.CPP +.\WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWCODEGEN.CPP ***********************************************************************/ namespace vl @@ -6607,6 +4999,7 @@ namespace vl using namespace controls; using namespace compositions; + using namespace templates; /*********************************************************************** FindInstanceLoadingSource @@ -7406,11 +5799,36 @@ Workflow_GenerateInstanceClass { auto ref = MakePtr(); - ref->name.value = L"FinalizeInstanceRecursively"; + ref->name.value = L"FinalizeGeneralInstance"; + + Ptr thisExpr = MakePtr(); + ITypeDescriptor* types[] = + { + description::GetTypeDescriptor(), + description::GetTypeDescriptor(), + description::GetTypeDescriptor(), + }; + + for (auto td : types) + { + if (baseType->GetTypeDescriptor()->CanConvertTo(td)) + { + ref->name.value = L"FinalizeInstanceRecursively"; + + Ptr typeInfo = MakePtr(td, TypeInfoHint::Normal); + typeInfo = MakePtr(typeInfo); + + auto inferExpr = MakePtr(); + inferExpr->type = GetTypeFromTypeInfo(typeInfo.Obj()); + inferExpr->expression = thisExpr; + thisExpr = inferExpr; + break; + } + } auto call = MakePtr(); call->function = ref; - call->arguments.Add(MakePtr()); + call->arguments.Add(thisExpr); auto stat = MakePtr(); stat->expression = call; @@ -7437,15 +5855,12 @@ GuiWorkflowSharedManagerPlugin Ptr workflowManager; public: - GuiWorkflowSharedManagerPlugin() + + GUI_PLUGIN_NAME(GacUI_Compiler_WorkflowSharedManager) { } void Load()override - { - } - - void AfterLoad()override { sharedManagerPlugin = this; } @@ -7485,8 +5900,9 @@ GuiWorkflowSharedManagerPlugin } } + /*********************************************************************** -WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWCOLLECTREFERENCES.CPP +.\WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWCOLLECTREFERENCES.CPP ***********************************************************************/ namespace vl @@ -8138,7 +6554,7 @@ WorkflowReferenceNamesVisitor } /*********************************************************************** -WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWGENERATEBINDINGS.CPP +.\WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWGENERATEBINDINGS.CPP ***********************************************************************/ namespace vl @@ -8342,7 +6758,7 @@ WorkflowGenerateBindingVisitor } /*********************************************************************** -WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWGENERATECREATING.CPP +.\WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWGENERATECREATING.CPP ***********************************************************************/ namespace vl @@ -8806,8 +7222,9 @@ WorkflowGenerateCreatingVisitor } } + /*********************************************************************** -WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWINSTALLBINDINGS.CPP +.\WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWINSTALLBINDINGS.CPP ***********************************************************************/ namespace vl @@ -9286,7 +7703,7 @@ Workflow_InstallEvalEvent } /*********************************************************************** -WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWMODULE.CPP +.\WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWMODULE.CPP ***********************************************************************/ namespace vl @@ -9489,7 +7906,7 @@ Variable } /*********************************************************************** -WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWPARSER.CPP +.\WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWPARSER.CPP ***********************************************************************/ namespace vl @@ -9638,7 +8055,7 @@ Converter } /*********************************************************************** -WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWSCRIPTPOSITION.CPP +.\WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWSCRIPTPOSITION.CPP ***********************************************************************/ namespace vl @@ -9751,3 +8168,1939 @@ WorkflowCompiler_ScriptPosition } } } + +/*********************************************************************** +.\INSTANCELOADERS\GUIINSTANCELOADER_COMPOSITIONS.CPP +***********************************************************************/ + +#ifndef VCZH_DEBUG_NO_REFLECTION + +namespace vl +{ + namespace presentation + { + namespace instance_loaders + { + +/*********************************************************************** +GuiAxisInstanceLoader +***********************************************************************/ + + class GuiAxisInstanceLoader : public Object, public IGuiInstanceLoader + { + protected: + GlobalStringKey typeName; + GlobalStringKey _AxisDirection; + + public: + GuiAxisInstanceLoader() + { + typeName = GlobalStringKey::Get(description::TypeInfo::content.typeName); + _AxisDirection = GlobalStringKey::Get(L"AxisDirection"); + } + + GlobalStringKey GetTypeName()override + { + return typeName; + } + + void GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + { + if (CanCreate(typeInfo)) + { + propertyNames.Add(_AxisDirection); + } + } + + void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + { + GetRequiredPropertyNames(typeInfo, propertyNames); + } + + Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + { + if (propertyInfo.propertyName == _AxisDirection) + { + auto info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver::CreateTypeInfo()); + info->usage = GuiInstancePropertyInfo::ConstructorArgument; + return info; + } + return IGuiInstanceLoader::GetPropertyType(propertyInfo); + } + + bool CanCreate(const TypeInfo& typeInfo)override + { + return typeName == typeInfo.typeName; + } + + Ptr CreateInstance(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos tagPosition, GuiResourceError::List& errors)override + { + if (CanCreate(typeInfo)) + { + vint indexAxisDirection = arguments.Keys().IndexOf(_AxisDirection); + if (indexAxisDirection != -1) + { + auto createExpr = MakePtr(); + createExpr->type = GetTypeFromTypeInfo(TypeInfoRetriver>::CreateTypeInfo().Obj()); + createExpr->arguments.Add(arguments.GetByIndex(indexAxisDirection)[0].expression); + + auto refVariable = MakePtr(); + refVariable->name.value = variableName.ToString(); + + auto assignExpr = MakePtr(); + assignExpr->op = WfBinaryOperator::Assign; + assignExpr->first = refVariable; + assignExpr->second = createExpr; + + auto assignStat = MakePtr(); + assignStat->expression = assignExpr; + return assignStat; + } + } + return nullptr; + } + }; + +/*********************************************************************** +GuiCompositionInstanceLoader +***********************************************************************/ + + class GuiCompositionInstanceLoader : public Object, public IGuiInstanceLoader + { + protected: + GlobalStringKey typeName; + + public: + GuiCompositionInstanceLoader() + { + typeName = GlobalStringKey::Get(description::TypeInfo::content.typeName); + } + + GlobalStringKey GetTypeName()override + { + return typeName; + } + + void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + { + propertyNames.Add(GlobalStringKey::Empty); + } + + Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + { + if (propertyInfo.propertyName == GlobalStringKey::Empty) + { + auto info = GuiInstancePropertyInfo::Collection(nullptr); + info->acceptableTypes.Add(TypeInfoRetriver::CreateTypeInfo()); + info->acceptableTypes.Add(TypeInfoRetriver::CreateTypeInfo()); + info->acceptableTypes.Add(TypeInfoRetriver>::CreateTypeInfo()); + return info; + } + return IGuiInstanceLoader::GetPropertyType(propertyInfo); + } + + Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override + { + auto block = MakePtr(); + + FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys()) + { + const auto& values = arguments.GetByIndex(index); + if (prop == GlobalStringKey::Empty) + { + auto value = values[0].expression; + auto td = values[0].typeInfo->GetTypeDescriptor(); + + Ptr expr; + if (td->CanConvertTo(description::GetTypeDescriptor())) + { + auto refComposition = MakePtr(); + refComposition->name.value = variableName.ToString(); + + auto refOwnedElement = MakePtr(); + refOwnedElement->parent = refComposition; + refOwnedElement->name.value = L"OwnedElement"; + + auto assign = MakePtr(); + assign->op = WfBinaryOperator::Assign; + assign->first = refOwnedElement; + assign->second = value; + + expr = assign; + } + else if (td->CanConvertTo(description::GetTypeDescriptor())) + { + auto refBoundsComposition = MakePtr(); + refBoundsComposition->parent = value; + refBoundsComposition->name.value = L"BoundsComposition"; + + auto refComposition = MakePtr(); + refComposition->name.value = variableName.ToString(); + + auto refAddChild = MakePtr(); + refAddChild->parent = refComposition; + refAddChild->name.value = L"AddChild"; + + auto call = MakePtr(); + call->function = refAddChild; + call->arguments.Add(refBoundsComposition); + + expr = call; + } + else if (td->CanConvertTo(description::GetTypeDescriptor())) + { + auto refComposition = MakePtr(); + refComposition->name.value = variableName.ToString(); + + auto refAddChild = MakePtr(); + refAddChild->parent = refComposition; + refAddChild->name.value = L"AddChild"; + + auto call = MakePtr(); + call->function = refAddChild; + call->arguments.Add(value); + + expr = call; + } + + if (expr) + { + auto stat = MakePtr(); + stat->expression = expr; + block->statements.Add(stat); + } + } + } + + if (block->statements.Count() > 0) + { + return block; + } + return nullptr; + } + }; + +/*********************************************************************** +GuiTableCompositionInstanceLoader +***********************************************************************/ + + class GuiTableCompositionInstanceLoader : public Object, public IGuiInstanceLoader + { + protected: + GlobalStringKey typeName; + GlobalStringKey _Rows, _Columns; + + public: + GuiTableCompositionInstanceLoader() + { + typeName = GlobalStringKey::Get(description::TypeInfo::content.typeName); + _Rows = GlobalStringKey::Get(L"Rows"); + _Columns = GlobalStringKey::Get(L"Columns"); + } + + GlobalStringKey GetTypeName()override + { + return typeName; + } + + void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + { + propertyNames.Add(_Rows); + propertyNames.Add(_Columns); + } + + void GetPairedProperties(const PropertyInfo& propertyInfo, collections::List& propertyNames)override + { + if (propertyInfo.propertyName == _Rows || propertyInfo.propertyName == _Columns) + { + propertyNames.Add(_Rows); + propertyNames.Add(_Columns); + } + } + + Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + { + if (propertyInfo.propertyName == _Rows || propertyInfo.propertyName == _Columns) + { + return GuiInstancePropertyInfo::Array(TypeInfoRetriver::CreateTypeInfo()); + } + return IGuiInstanceLoader::GetPropertyType(propertyInfo); + } + + Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override + { + auto block = MakePtr(); + + FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys()) + { + if (prop == _Rows) + { + auto indexColumns = arguments.Keys().IndexOf(_Columns); + if (indexColumns != -1) + { + auto& rows = arguments.GetByIndex(index); + auto& columns = arguments.GetByIndex(indexColumns); + + { + auto refComposition = MakePtr(); + refComposition->name.value = variableName.ToString(); + + auto refSetRowsAndColumns = MakePtr(); + refSetRowsAndColumns->parent = refComposition; + refSetRowsAndColumns->name.value = L"SetRowsAndColumns"; + + auto rowsExpr = MakePtr(); + rowsExpr->value.value = itow(rows.Count()); + + auto columnsExpr = MakePtr(); + columnsExpr->value.value = itow(columns.Count()); + + auto call = MakePtr(); + call->function = refSetRowsAndColumns; + call->arguments.Add(rowsExpr); + call->arguments.Add(columnsExpr); + + auto stat = MakePtr(); + stat->expression = call; + block->statements.Add(stat); + } + + for (vint i = 0; i < rows.Count(); i++) + { + auto refComposition = MakePtr(); + refComposition->name.value = variableName.ToString(); + + auto refSetRowOption = MakePtr(); + refSetRowOption->parent = refComposition; + refSetRowOption->name.value = L"SetRowOption"; + + auto indexExpr = MakePtr(); + indexExpr->value.value = itow(i); + + auto call = MakePtr(); + call->function = refSetRowOption; + call->arguments.Add(indexExpr); + call->arguments.Add(rows[i].expression); + + auto stat = MakePtr(); + stat->expression = call; + block->statements.Add(stat); + } + + for (vint i = 0; i < columns.Count(); i++) + { + auto refComposition = MakePtr(); + refComposition->name.value = variableName.ToString(); + + auto refSetColumnOption = MakePtr(); + refSetColumnOption->parent = refComposition; + refSetColumnOption->name.value = L"SetColumnOption"; + + auto indexExpr = MakePtr(); + indexExpr->value.value = itow(i); + + auto call = MakePtr(); + call->function = refSetColumnOption; + call->arguments.Add(indexExpr); + call->arguments.Add(columns[i].expression); + + auto stat = MakePtr(); + stat->expression = call; + block->statements.Add(stat); + } + } + } + } + + if (block->statements.Count() > 0) + { + return block; + } + return nullptr; + } + }; + +/*********************************************************************** +GuiCellCompositionInstanceLoader +***********************************************************************/ + + class GuiCellCompositionInstanceLoader : public Object, public IGuiInstanceLoader + { + protected: + GlobalStringKey typeName; + GlobalStringKey _Site; + + public: + GuiCellCompositionInstanceLoader() + { + typeName = GlobalStringKey::Get(description::TypeInfo::content.typeName); + _Site = GlobalStringKey::Get(L"Site"); + } + + GlobalStringKey GetTypeName()override + { + return typeName; + } + + void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + { + propertyNames.Add(_Site); + } + + Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + { + if (propertyInfo.propertyName == _Site) + { + return GuiInstancePropertyInfo::Assign(TypeInfoRetriver::CreateTypeInfo()); + } + return IGuiInstanceLoader::GetPropertyType(propertyInfo); + } + + Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override + { + auto block = MakePtr(); + + FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys()) + { + if (prop == _Site) + { + SiteValue site; + { + auto siteExpr = arguments.GetByIndex(index)[0].expression; + if (auto inferExpr = siteExpr.Cast()) + { + if (auto ctorExpr = inferExpr->expression.Cast()) + { + auto st = description::GetTypeDescriptor()->GetSerializableType(); + FOREACH(Ptr, argument, ctorExpr->arguments) + { + if (auto keyExpr = argument->key.Cast()) + { + if (auto valueExpr = argument->value.Cast()) + { + Value value; + if (st->Deserialize(valueExpr->value.value, value)) + { + vint propValue = UnboxValue(value); + if (keyExpr->name.value == L"row") + { + site.row = propValue; + } + else if (keyExpr->name.value == L"column") + { + site.column = propValue; + } + else if (keyExpr->name.value == L"rowSpan") + { + site.rowSpan = propValue; + } + else if (keyExpr->name.value == L"columnSpan") + { + site.columnSpan = propValue; + } + else + { + goto ILLEGAL_SITE_PROPERTY; + } + continue; + } + } + } + goto ILLEGAL_SITE_PROPERTY; + } + goto FINISH_SITE_PROPERTY; + } + } + ILLEGAL_SITE_PROPERTY: + errors.Add(GuiResourceError({ resolvingResult.resource }, attPosition, + L"Precompile: The value of property \"Site\" of type \"" + + typeInfo.typeName.ToString() + + L"\" is not in a correct format: \"row: column: [rowSpan:] [columnSpan:]\".")); + continue; + } + FINISH_SITE_PROPERTY:; + + { + auto refComposition = MakePtr(); + refComposition->name.value = variableName.ToString(); + + auto refSetSite = MakePtr(); + refSetSite->parent = refComposition; + refSetSite->name.value = L"SetSite"; + + auto call = MakePtr(); + call->function = refSetSite; + + auto GetValueText = [](const Value& value) + { + WString result; + auto st = value.GetTypeDescriptor()->GetSerializableType(); + st->Serialize(value, result); + return result; + }; + + { + auto arg = MakePtr(); + arg->value.value = itow(site.row); + call->arguments.Add(arg); + } + { + auto arg = MakePtr(); + arg->value.value = itow(site.column); + call->arguments.Add(arg); + } + { + auto arg = MakePtr(); + arg->value.value = itow(site.rowSpan); + call->arguments.Add(arg); + } + { + auto arg = MakePtr(); + arg->value.value = itow(site.columnSpan); + call->arguments.Add(arg); + } + + auto stat = MakePtr(); + stat->expression = call; + block->statements.Add(stat); + } + } + } + + if (block->statements.Count() > 0) + { + return block; + } + return nullptr; + } + }; + +/*********************************************************************** +Initialization +***********************************************************************/ + + void LoadCompositions(IGuiInstanceLoaderManager* manager) + { + manager->SetLoader(new GuiAxisInstanceLoader); + manager->SetLoader(new GuiCompositionInstanceLoader); + manager->SetLoader(new GuiTableCompositionInstanceLoader); + manager->SetLoader(new GuiCellCompositionInstanceLoader); + } + } + } +} + +#endif + + +/*********************************************************************** +.\INSTANCELOADERS\GUIINSTANCELOADER_DOCUMENT.CPP +***********************************************************************/ + +#ifndef VCZH_DEBUG_NO_REFLECTION + +namespace vl +{ + namespace presentation + { + namespace instance_loaders + { + +/*********************************************************************** +GuiDocumentItemInstanceLoader +***********************************************************************/ + + class GuiDocumentItemInstanceLoader : public Object, public IGuiInstanceLoader + { + protected: + GlobalStringKey typeName; + GlobalStringKey _Name; + + public: + GuiDocumentItemInstanceLoader() + { + typeName = GlobalStringKey::Get(description::TypeInfo::content.typeName); + _Name = GlobalStringKey::Get(L"Name"); + } + + GlobalStringKey GetTypeName()override + { + return typeName; + } + + void GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + { + if (CanCreate(typeInfo)) + { + propertyNames.Add(_Name); + } + } + + void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + { + GetRequiredPropertyNames(typeInfo, propertyNames); + propertyNames.Add(GlobalStringKey::Empty); + } + + Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + { + if (propertyInfo.propertyName == GlobalStringKey::Empty) + { + auto info = GuiInstancePropertyInfo::Collection(nullptr); + info->acceptableTypes.Add(TypeInfoRetriver::CreateTypeInfo()); + info->acceptableTypes.Add(TypeInfoRetriver::CreateTypeInfo()); + return info; + } + else if (propertyInfo.propertyName == _Name) + { + auto info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver::CreateTypeInfo()); + info->usage = GuiInstancePropertyInfo::ConstructorArgument; + return info; + } + return IGuiInstanceLoader::GetPropertyType(propertyInfo); + } + + + bool CanCreate(const TypeInfo& typeInfo)override + { + return typeName == typeInfo.typeName; + } + + Ptr CreateInstance(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos tagPosition, GuiResourceError::List& errors)override + { + if (CanCreate(typeInfo)) + { + vint indexName = arguments.Keys().IndexOf(_Name); + if (indexName != -1) + { + auto type = TypeInfoRetriver>::CreateTypeInfo(); + auto createExpr = MakePtr(); + createExpr->type = GetTypeFromTypeInfo(type.Obj()); + createExpr->arguments.Add(arguments.GetByIndex(indexName)[0].expression); + + auto refVariable = MakePtr(); + refVariable->name.value = variableName.ToString(); + + auto assignExpr = MakePtr(); + assignExpr->op = WfBinaryOperator::Assign; + assignExpr->first = refVariable; + assignExpr->second = createExpr; + + auto assignStat = MakePtr(); + assignStat->expression = assignExpr; + return assignStat; + } + } + return nullptr; + } + + Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override + { + auto block = MakePtr(); + + FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys()) + { + const auto& values = arguments.GetByIndex(index); + if (prop == GlobalStringKey::Empty) + { + auto value = values[0].expression; + auto td = values[0].typeInfo->GetTypeDescriptor(); + + Ptr compositionExpr; + if (td->CanConvertTo(description::GetTypeDescriptor())) + { + auto member = MakePtr(); + member->parent = value; + member->name.value = L"BoundsComposition"; + compositionExpr = member; + } + else if (td->CanConvertTo(description::GetTypeDescriptor())) + { + compositionExpr = value; + } + + if (compositionExpr) + { + auto refItem = MakePtr(); + refItem->name.value = variableName.ToString(); + + auto refContainer = MakePtr(); + refContainer->parent = refItem; + refContainer->name.value = L"Container"; + + auto refAddChild = MakePtr(); + refAddChild->parent = refContainer; + refAddChild->name.value = L"AddChild"; + + auto call = MakePtr(); + call->function = refAddChild; + call->arguments.Add(compositionExpr); + + auto stat = MakePtr(); + stat->expression = call; + block->statements.Add(stat); + } + } + } + + if (block->statements.Count() > 0) + { + return block; + } + return nullptr; + } + }; + +/*********************************************************************** +GuiDocumentInstanceLoaderBase +***********************************************************************/ + + template + class GuiDocumentInstanceLoaderBase : public TBaseType + { + public: + using PropertyInfo = IGuiInstanceLoader::PropertyInfo; + using ArgumentMap = IGuiInstanceLoader::ArgumentMap; + + GuiDocumentInstanceLoaderBase(const WString& _typeName, const WString& _styleMethod) + :TBaseType(_typeName, _styleMethod) + { + } + + void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + { + propertyNames.Add(GlobalStringKey::Empty); + TBaseType::GetPropertyNames(typeInfo, propertyNames); + } + + Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + { + if (propertyInfo.propertyName == GlobalStringKey::Empty) + { + return GuiInstancePropertyInfo::CollectionWithParent(TypeInfoRetriver>::CreateTypeInfo()); + } + return TBaseType::GetPropertyType(propertyInfo); + } + + Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override + { + auto block = MakePtr(); + + FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys()) + { + const auto& values = arguments.GetByIndex(index); + if (prop == GlobalStringKey::Empty) + { + auto refControl = MakePtr(); + refControl->name.value = variableName.ToString(); + + auto refAddDocumentItem = MakePtr(); + refAddDocumentItem->parent = refControl; + refAddDocumentItem->name.value = L"AddDocumentItem"; + + auto call = MakePtr(); + call->function = refAddDocumentItem; + call->arguments.Add(values[0].expression); + + auto stat = MakePtr(); + stat->expression = call; + block->statements.Add(stat); + } + } + + if (block->statements.Count() > 0) + { + return block; + } + return TBaseType::AssignParameters(precompileContext, resolvingResult, typeInfo, variableName, arguments, attPosition, errors); + } + }; + +/*********************************************************************** +GuiDocumentViewerInstanceLoader +***********************************************************************/ + +#define BASE_TYPE GuiTemplateControlInstanceLoader + class GuiDocumentViewerInstanceLoader : public GuiDocumentInstanceLoaderBase + { + public: + GuiDocumentViewerInstanceLoader() + :GuiDocumentInstanceLoaderBase(description::TypeInfo::content.typeName, L"CreateDocumentViewerStyle") + { + } + }; +#undef BASE_TYPE + +/*********************************************************************** +GuiDocumentLabelInstanceLoader +***********************************************************************/ + +#define BASE_TYPE GuiTemplateControlInstanceLoader + class GuiDocumentLabelInstanceLoader : public GuiDocumentInstanceLoaderBase + { + public: + GuiDocumentLabelInstanceLoader() + :GuiDocumentInstanceLoaderBase(description::TypeInfo::content.typeName, L"CreateDocumentLabelStyle") + { + } + }; +#undef BASE_TYPE + +/*********************************************************************** +Initialization +***********************************************************************/ + + void LoadDocumentControls(IGuiInstanceLoaderManager* manager) + { + manager->SetLoader(new GuiDocumentItemInstanceLoader); + manager->SetLoader(new GuiDocumentViewerInstanceLoader); + manager->SetLoader(new GuiDocumentLabelInstanceLoader); + } + } + } +} + +#endif + + +/*********************************************************************** +.\INSTANCELOADERS\GUIINSTANCELOADER_LIST.CPP +***********************************************************************/ + +#ifndef VCZH_DEBUG_NO_REFLECTION + +namespace vl +{ + namespace presentation + { + namespace instance_loaders + { + + template + Ptr CreateSetControlTemplateStyle(types::ResolvingResult& resolvingResult, GlobalStringKey variableName, Ptr argument, const WString& propertyName) + { + auto createStyle = MakePtr(); + createStyle->type = GetTypeFromTypeInfo(TypeInfoRetriver>::CreateTypeInfo().Obj()); + createStyle->arguments.Add(argument); + + auto refControl = MakePtr(); + refControl->name.value = variableName.ToString(); + + auto refStyleProvider = MakePtr(); + refStyleProvider->parent = refControl; + refStyleProvider->name.value = propertyName; + + auto assign = MakePtr(); + assign->op = WfBinaryOperator::Assign; + assign->first = refStyleProvider; + assign->second = createStyle; + + auto stat = MakePtr(); + stat->expression = assign; + return stat; + } + +/*********************************************************************** +GuiComboBoxInstanceLoader +***********************************************************************/ + +#define BASE_TYPE GuiTemplateControlInstanceLoader + class GuiComboBoxInstanceLoader : public BASE_TYPE + { + protected: + GlobalStringKey _ListControl; + + void AddAdditionalArguments(types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceError::List& errors, Ptr createControl)override + { + vint indexListControl = arguments.Keys().IndexOf(_ListControl); + if (indexListControl != -1) + { + createControl->arguments.Add(arguments.GetByIndex(indexListControl)[0].expression); + } + } + public: + GuiComboBoxInstanceLoader() + :BASE_TYPE(L"presentation::controls::GuiComboBox", L"CreateComboBoxStyle") + { + _ListControl = GlobalStringKey::Get(L"ListControl"); + } + + void GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + { + if (CanCreate(typeInfo)) + { + propertyNames.Add(_ListControl); + } + BASE_TYPE::GetRequiredPropertyNames(typeInfo, propertyNames); + } + + void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + { + GetRequiredPropertyNames(typeInfo, propertyNames); + BASE_TYPE::GetPropertyNames(typeInfo, propertyNames); + } + + Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + { + if (propertyInfo.propertyName == _ListControl) + { + auto info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver::CreateTypeInfo()); + info->usage = GuiInstancePropertyInfo::ConstructorArgument; + return info; + } + return BASE_TYPE::GetPropertyType(propertyInfo); + } + }; +#undef BASE_TYPE + +/*********************************************************************** +GuiTreeViewInstanceLoader +***********************************************************************/ + +#define BASE_TYPE GuiTemplateControlInstanceLoader + template + class GuiTreeViewInstanceLoaderBase : public BASE_TYPE + { + protected: + bool bindable; + GlobalStringKey _Nodes; + + public: + GuiTreeViewInstanceLoaderBase(bool _bindable) + :BASE_TYPE(description::TypeInfo::content.typeName, L"CreateTreeViewStyle") + , bindable(_bindable) + { + _Nodes = GlobalStringKey::Get(L"Nodes"); + } + + void GetPropertyNames(const typename BASE_TYPE::TypeInfo& typeInfo, collections::List& propertyNames)override + { + if (!bindable) + { + propertyNames.Add(_Nodes); + } + BASE_TYPE::GetPropertyNames(typeInfo, propertyNames); + } + + Ptr GetPropertyType(const typename BASE_TYPE::PropertyInfo& propertyInfo)override + { + if (propertyInfo.propertyName == _Nodes) + { + if (!bindable) + { + return GuiInstancePropertyInfo::Collection(TypeInfoRetriver>::CreateTypeInfo()); + } + } + return BASE_TYPE::GetPropertyType(propertyInfo); + } + + Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const typename BASE_TYPE::TypeInfo& typeInfo, GlobalStringKey variableName, typename BASE_TYPE::ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override + { + auto block = MakePtr(); + + FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys()) + { + if (prop == _Nodes) + { + auto refControl = MakePtr(); + refControl->name.value = variableName.ToString(); + + auto refNodes = MakePtr(); + refNodes->parent = refControl; + refNodes->name.value = L"Nodes"; + + auto refChildren = MakePtr(); + refChildren->parent = refNodes; + refChildren->name.value = L"Children"; + + auto refAdd = MakePtr(); + refAdd->parent = refChildren; + refAdd->name.value = L"Add"; + + auto call = MakePtr(); + call->function = refAdd; + call->arguments.Add(arguments.GetByIndex(index)[0].expression); + + auto stat = MakePtr(); + stat->expression = call; + block->statements.Add(stat); + } + } + + if (block->statements.Count() > 0) + { + return block; + } + return BASE_TYPE::AssignParameters(precompileContext, resolvingResult, typeInfo, variableName, arguments, attPosition, errors); + } + }; +#undef BASE_TYPE + + class GuiTreeViewInstanceLoader : public GuiTreeViewInstanceLoaderBase + { + public: + GuiTreeViewInstanceLoader() + :GuiTreeViewInstanceLoaderBase(false) + { + } + }; + + class GuiBindableTreeViewInstanceLoader : public GuiTreeViewInstanceLoaderBase + { + public: + GuiBindableTreeViewInstanceLoader() + :GuiTreeViewInstanceLoaderBase(true) + { + } + }; + +/*********************************************************************** +GuiTreeNodeInstanceLoader +***********************************************************************/ + + class GuiTreeNodeInstanceLoader : public Object, public IGuiInstanceLoader + { + protected: + GlobalStringKey typeName; + GlobalStringKey _Text, _Image, _Tag; + + public: + GuiTreeNodeInstanceLoader() + :typeName(GlobalStringKey::Get(L"presentation::controls::tree::TreeNode")) + { + _Text = GlobalStringKey::Get(L"Text"); + _Image = GlobalStringKey::Get(L"Image"); + _Tag = GlobalStringKey::Get(L"Tag"); + } + + GlobalStringKey GetTypeName()override + { + return typeName; + } + + void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + { + propertyNames.Add(_Text); + propertyNames.Add(_Image); + propertyNames.Add(_Tag); + propertyNames.Add(GlobalStringKey::Empty); + } + + Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + { + if (propertyInfo.propertyName == _Text) + { + auto info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver::CreateTypeInfo()); + info->usage = GuiInstancePropertyInfo::ConstructorArgument; + info->bindability = GuiInstancePropertyInfo::Bindable; + return info; + } + else if (propertyInfo.propertyName == _Image) + { + auto info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver>::CreateTypeInfo()); + info->usage = GuiInstancePropertyInfo::ConstructorArgument; + info->bindability = GuiInstancePropertyInfo::Bindable; + return info; + } + else if (propertyInfo.propertyName == _Tag) + { + return GuiInstancePropertyInfo::Assign(TypeInfoRetriver::CreateTypeInfo()); + } + else if (propertyInfo.propertyName == GlobalStringKey::Empty) + { + return GuiInstancePropertyInfo::Collection(TypeInfoRetriver>::CreateTypeInfo()); + } + return IGuiInstanceLoader::GetPropertyType(propertyInfo); + } + + bool CanCreate(const TypeInfo& typeInfo)override + { + return typeInfo.typeName == GetTypeName(); + } + + Ptr CreateInstance(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos tagPosition, GuiResourceError::List& errors)override + { + if (CanCreate(typeInfo)) + { + auto createItem = MakePtr(); + createItem->type = GetTypeFromTypeInfo(TypeInfoRetriver>::CreateTypeInfo().Obj()); + + vint imageIndex = arguments.Keys().IndexOf(_Image); + vint textIndex = arguments.Keys().IndexOf(_Text); + + if (imageIndex != -1 || textIndex != -1) + { + if (imageIndex == -1) + { + auto nullExpr = MakePtr(); + nullExpr->value = WfLiteralValue::Null; + createItem->arguments.Add(nullExpr); + } + else + { + createItem->arguments.Add(arguments.GetByIndex(imageIndex)[0].expression); + } + + if (textIndex == -1) + { + createItem->arguments.Add(MakePtr()); + } + else + { + createItem->arguments.Add(arguments.GetByIndex(textIndex)[0].expression); + } + } + + auto createNode = MakePtr(); + createNode->type = GetTypeFromTypeInfo(TypeInfoRetriver>::CreateTypeInfo().Obj()); + createNode->arguments.Add(createItem); + + auto refNode = MakePtr(); + refNode->name.value = variableName.ToString(); + + auto assign = MakePtr(); + assign->op = WfBinaryOperator::Assign; + assign->first = refNode; + assign->second = createNode; + + auto stat = MakePtr(); + stat->expression = assign; + return stat; + } + return nullptr; + } + + Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override + { + auto block = MakePtr(); + + FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys()) + { + if (prop == GlobalStringKey::Empty) + { + auto refNode = MakePtr(); + refNode->name.value = variableName.ToString(); + + auto refChildren = MakePtr(); + refChildren->parent = refNode; + refChildren->name.value = L"Children"; + + auto refAdd = MakePtr(); + refAdd->parent = refChildren; + refAdd->name.value = L"Add"; + + auto call = MakePtr(); + call->function = refAdd; + call->arguments.Add(arguments.GetByIndex(index)[0].expression); + + auto stat = MakePtr(); + stat->expression = call; + block->statements.Add(stat); + } + else if (prop == _Tag) + { + { + auto refNode = MakePtr(); + refNode->name.value = variableName.ToString(); + + auto refData = MakePtr(); + refData->parent = refNode; + refData->name.value = L"Data"; + + auto castExpr = MakePtr(); + castExpr->strategy = WfTypeCastingStrategy::Strong; + castExpr->type = GetTypeFromTypeInfo(TypeInfoRetriver>::CreateTypeInfo().Obj()); + castExpr->expression = refData; + + auto refProp = MakePtr(); + refProp->parent = castExpr; + refProp->name.value = L"tag"; + + auto assign = MakePtr(); + assign->op = WfBinaryOperator::Assign; + assign->first = refProp; + assign->second = arguments.GetByIndex(index)[0].expression; + + auto stat = MakePtr(); + stat->expression = assign; + block->statements.Add(stat); + } + + if (prop != _Tag) + { + auto refNode = MakePtr(); + refNode->name.value = variableName.ToString(); + + auto refNotifyDataModified = MakePtr(); + refNotifyDataModified->parent = refNode; + refNotifyDataModified->name.value = L"NotifyDataModified"; + + auto call = MakePtr(); + call->function = refNotifyDataModified; + + auto stat = MakePtr(); + stat->expression = call; + block->statements.Add(stat); + } + } + } + + if (block->statements.Count() > 0) + { + return block; + } + return nullptr; + } + }; + +/*********************************************************************** +GuiBindableDataGridInstanceLoader +***********************************************************************/ + +#define BASE_TYPE GuiTemplateControlInstanceLoader + class GuiBindableDataGridInstanceLoader : public BASE_TYPE + { + protected: + GlobalStringKey typeName; + GlobalStringKey _ViewModelContext; + + void AddAdditionalArguments(types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceError::List& errors, Ptr createControl)override + { + auto indexViewModelContext = arguments.Keys().IndexOf(_ViewModelContext); + if (indexViewModelContext == -1) + { + auto nullExpr = MakePtr(); + nullExpr->value = WfLiteralValue::Null; + createControl->arguments.Add(nullExpr); + } + else + { + createControl->arguments.Add(arguments.GetByIndex(indexViewModelContext)[0].expression); + } + } + public: + GuiBindableDataGridInstanceLoader() + :BASE_TYPE(description::TypeInfo::content.typeName, L"CreateListViewStyle") + { + typeName = GlobalStringKey::Get(description::TypeInfo::content.typeName); + _ViewModelContext = GlobalStringKey::Get(L"ViewModelContext"); + } + + GlobalStringKey GetTypeName()override + { + return typeName; + } + + void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + { + propertyNames.Add(_ViewModelContext); + BASE_TYPE::GetPropertyNames(typeInfo, propertyNames); + } + + Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + { + if (propertyInfo.propertyName == _ViewModelContext) + { + auto info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver::CreateTypeInfo()); + info->usage = GuiInstancePropertyInfo::ConstructorArgument; + info->bindability = GuiInstancePropertyInfo::Bindable; + return info; + } + return BASE_TYPE::GetPropertyType(propertyInfo); + } + }; +#undef BASE_TYPE + +/*********************************************************************** +Initialization +***********************************************************************/ + + void LoadListControls(IGuiInstanceLoaderManager* manager) + { + manager->CreateVirtualType( + GlobalStringKey::Get(description::TypeInfo::content.typeName), + new GuiComboBoxInstanceLoader + ); + + manager->SetLoader(new GuiTreeViewInstanceLoader); + manager->SetLoader(new GuiBindableTreeViewInstanceLoader); + manager->SetLoader(new GuiBindableDataGridInstanceLoader); + + manager->CreateVirtualType( + GlobalStringKey::Get(description::TypeInfo::content.typeName), + new GuiTreeNodeInstanceLoader + ); + } + } + } +} + +#endif + + +/*********************************************************************** +.\INSTANCELOADERS\GUIINSTANCELOADER_PLUGIN.CPP +***********************************************************************/ +/* +GuiInstanceLoader_Plugin.cpp + GuiControl + default: GuiControl*, GuiGraphicsComposition* + GuiInstanceRootObject + default: GuiComponent* +GuiInstanceLoader_TemplateControl + GuiControl + ctor: ControlTemplate(ItemTemplate) +GuiInstanceLoader_Compositions.cpp + GuiAxis + ctor: AxisDirection + GuiComposition + default: GuiControl*, GuiGraphicsComposition*, Ptr + GuiTableComposition + Rows, Columns: array(GuiCellOption) + GuiCellComposition + Site: SiteValue +GuiInstanceLoader_Document.cpp + GuiDocumentItem + default: GuiControl*, GuiGraphicsComposition* + GuiDocumentViewer, GuiDocumentLable + default: Ptr +GuiInstanceLoader_List.cpp + GuiComboBox + ctor: _ListControl(GuiListControl*) + GuiTreeView, GuiBindableTreeView + Nodes: array(Ptr) + GuiBindableDataGrid + ctor: ViewModelContext + tree::TreeNode + ctor: Text, Image + Tag +GuiInstanceLoader_Templates.cpp + GuiTemplate + ctor: \w+(ItemTemplate) +GuiInstanceLoader_Toolstrip.cpp + GuiToolstripMenu, GuiToolstripMenuBar, GuiToolstripToolBar + default: collection(GuiControl*) + GuiToolstripButton + SubMenu-set: GuiToolstripMenu* +*/ + + +namespace vl +{ + namespace presentation + { + namespace instance_loaders + { + +#ifndef VCZH_DEBUG_NO_REFLECTION + +/*********************************************************************** +GuiControlInstanceLoader +***********************************************************************/ + + class GuiControlInstanceLoader : public Object, public IGuiInstanceLoader + { + protected: + GlobalStringKey typeName; + + public: + GuiControlInstanceLoader() + { + typeName = GlobalStringKey::Get(description::TypeInfo::content.typeName); + } + + GlobalStringKey GetTypeName()override + { + return typeName; + } + + void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + { + propertyNames.Add(GlobalStringKey::Empty); + } + + Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + { + if (propertyInfo.propertyName == GlobalStringKey::Empty) + { + auto info = GuiInstancePropertyInfo::Collection(nullptr); + info->acceptableTypes.Add(TypeInfoRetriver::CreateTypeInfo()); + info->acceptableTypes.Add(TypeInfoRetriver::CreateTypeInfo()); + if (propertyInfo.typeInfo.typeInfo->GetTypeDescriptor()->CanConvertTo(description::GetTypeDescriptor())) + { + info->acceptableTypes.Add(TypeInfoRetriver::CreateTypeInfo()); + } + return info; + } + return IGuiInstanceLoader::GetPropertyType(propertyInfo); + } + + Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override + { + auto block = MakePtr(); + + FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys()) + { + const auto& values = arguments.GetByIndex(index); + if (prop == GlobalStringKey::Empty) + { + auto value = values[0].expression; + auto td = values[0].typeInfo->GetTypeDescriptor(); + + Ptr expr; + if (td->CanConvertTo(description::GetTypeDescriptor())) + { + auto refControl = MakePtr(); + refControl->name.value = variableName.ToString(); + + auto refAddComponent = MakePtr(); + refAddComponent->parent = refControl; + refAddComponent->name.value = L"AddComponent"; + + auto call = MakePtr(); + call->function = refAddComponent; + call->arguments.Add(value); + + expr = call; + } + else if (td->CanConvertTo(description::GetTypeDescriptor())) + { + auto refControl = MakePtr(); + refControl->name.value = variableName.ToString(); + + auto refAddControlHostComponent = MakePtr(); + refAddControlHostComponent->parent = refControl; + refAddControlHostComponent->name.value = L"AddControlHostComponent"; + + auto call = MakePtr(); + call->function = refAddControlHostComponent; + call->arguments.Add(value); + + expr = call; + } + else if (td->CanConvertTo(description::GetTypeDescriptor())) + { + auto refControl = MakePtr(); + refControl->name.value = variableName.ToString(); + + auto refAddChild = MakePtr(); + refAddChild->parent = refControl; + refAddChild->name.value = L"AddChild"; + + auto call = MakePtr(); + call->function = refAddChild; + call->arguments.Add(value); + + expr = call; + } + else if (td->CanConvertTo(description::GetTypeDescriptor())) + { + auto refControl = MakePtr(); + refControl->name.value = variableName.ToString(); + + auto refContainerComposition = MakePtr(); + refContainerComposition->parent = refControl; + refContainerComposition->name.value = L"ContainerComposition"; + + auto refAddChild = MakePtr(); + refAddChild->parent = refContainerComposition; + refAddChild->name.value = L"AddChild"; + + auto call = MakePtr(); + call->function = refAddChild; + call->arguments.Add(value); + + expr = call; + } + + if (expr) + { + auto stat = MakePtr(); + stat->expression = expr; + block->statements.Add(stat); + } + } + } + + if (block->statements.Count() > 0) + { + return block; + } + return nullptr; + } + }; + +#endif + +/*********************************************************************** +GuiPredefinedInstanceLoadersPlugin +***********************************************************************/ + + Ptr CreateStandardDataPicker(IGuiInstanceLoader::ArgumentMap&) + { + using TControl = GuiDatePicker; + using TControlStyle = GuiDateComboBoxTemplate_StyleProvider; + using TTemplate = GuiDatePickerTemplate; + + auto controlType = TypeInfoRetriver::CreateTypeInfo(); + auto createControl = MakePtr(); + createControl->type = GetTypeFromTypeInfo(controlType.Obj()); + createControl->arguments.Add(GuiTemplateControlInstanceLoader::CreateIThemeCall(L"CreateDatePickerStyle")); + + return createControl; + } + + void InitializeTrackerProgressBar(const WString& variableName, Ptr block) + { + auto refVariable = MakePtr(); + refVariable->name.value = variableName; + + auto refSetPageSize = MakePtr(); + refSetPageSize->parent = refVariable; + refSetPageSize->name.value = L"SetPageSize"; + + auto refZero = MakePtr(); + refZero->value.value = L"0"; + + auto call = MakePtr(); + call->function = refSetPageSize; + call->arguments.Add(refZero); + + auto stat = MakePtr(); + stat->expression = call; + block->statements.Add(stat); + } + + extern void LoadToolstripControls(IGuiInstanceLoaderManager* manager); + extern void LoadListControls(IGuiInstanceLoaderManager* manager); + extern void LoadDocumentControls(IGuiInstanceLoaderManager* manager); + extern void LoadCompositions(IGuiInstanceLoaderManager* manager); + extern void LoadTemplates(IGuiInstanceLoaderManager* manager); + + class GuiPredefinedInstanceLoadersPlugin : public Object, public IGuiPlugin + { + public: + + GUI_PLUGIN_NAME(GacUI_Instance_TypeLoaders) + { + GUI_PLUGIN_DEPEND(GacUI_Res_ResourceResolver); + GUI_PLUGIN_DEPEND(GacUI_Instance_Reflection); + GUI_PLUGIN_DEPEND(GacUI_Instance); + } + + void Load()override + { + #ifndef VCZH_DEBUG_NO_REFLECTION + IGuiInstanceLoaderManager* manager=GetInstanceLoaderManager(); + + #define ADD_VIRTUAL_TYPE_LOADER(TYPENAME, LOADER)\ + manager->CreateVirtualType(\ + GlobalStringKey::Get(description::TypeInfo::content.typeName),\ + new LOADER\ + ) + + #define ADD_TEMPLATE_CONTROL(TYPENAME, STYLE_METHOD, TEMPLATE)\ + manager->SetLoader(\ + new GuiTemplateControlInstanceLoader(\ + L"presentation::controls::" L ## #TYPENAME,\ + L ## #STYLE_METHOD\ + )\ + ) + + #define ADD_TEMPLATE_CONTROL_2(TYPENAME, STYLE_METHOD, ARGUMENT_FUNCTION, TEMPLATE)\ + manager->SetLoader(\ + new GuiTemplateControlInstanceLoader(\ + L"presentation::controls::" L ## #TYPENAME,\ + L ## #STYLE_METHOD,\ + ARGUMENT_FUNCTION\ + )\ + ) + + #define ADD_VIRTUAL_CONTROL(VIRTUALTYPENAME, TYPENAME, STYLE_METHOD, TEMPLATE)\ + manager->CreateVirtualType(GlobalStringKey::Get(description::TypeInfo::content.typeName),\ + new GuiTemplateControlInstanceLoader(\ + L"presentation::controls::Gui" L ## #VIRTUALTYPENAME,\ + L ## #STYLE_METHOD\ + )\ + ) + + #define ADD_VIRTUAL_CONTROL_F(VIRTUALTYPENAME, TYPENAME, STYLE_METHOD, TEMPLATE, INIT_FUNCTION)\ + manager->CreateVirtualType(GlobalStringKey::Get(description::TypeInfo::content.typeName),\ + new GuiTemplateControlInstanceLoader(\ + L"presentation::controls::Gui" L ## #VIRTUALTYPENAME,\ + L ## #STYLE_METHOD,\ + INIT_FUNCTION\ + )\ + ) + + manager->SetLoader(new GuiControlInstanceLoader); + + ADD_TEMPLATE_CONTROL ( GuiCustomControl, CreateCustomControlStyle, GuiControlTemplate ); + ADD_TEMPLATE_CONTROL ( GuiLabel, CreateLabelStyle, GuiLabelTemplate ); + ADD_TEMPLATE_CONTROL ( GuiButton, CreateButtonStyle, GuiButtonTemplate ); + ADD_TEMPLATE_CONTROL ( GuiTabPage, CreateCustomControlStyle, GuiControlTemplate ); + ADD_TEMPLATE_CONTROL ( GuiTab, CreateTabStyle, GuiTabTemplate ); + ADD_TEMPLATE_CONTROL ( GuiScrollContainer, CreateScrollContainerStyle, GuiScrollViewTemplate ); + ADD_TEMPLATE_CONTROL ( GuiWindow, CreateWindowStyle, GuiWindowTemplate ); + ADD_TEMPLATE_CONTROL ( GuiTextList, CreateTextListStyle, GuiTextListTemplate ); + ADD_TEMPLATE_CONTROL ( GuiBindableTextList, CreateTextListStyle, GuiTextListTemplate ); + ADD_TEMPLATE_CONTROL ( GuiListView, CreateListViewStyle, GuiListViewTemplate); + ADD_TEMPLATE_CONTROL ( GuiBindableListView, CreateListViewStyle, GuiListViewTemplate); + ADD_TEMPLATE_CONTROL ( GuiMultilineTextBox, CreateMultilineTextBoxStyle, GuiMultilineTextBoxTemplate ); + ADD_TEMPLATE_CONTROL ( GuiSinglelineTextBox, CreateTextBoxStyle, GuiSinglelineTextBoxTemplate ); + ADD_TEMPLATE_CONTROL ( GuiDatePicker, CreateDatePickerStyle, GuiDatePickerTemplate ); + ADD_TEMPLATE_CONTROL_2 ( GuiDateComboBox, CreateComboBoxStyle, CreateStandardDataPicker, GuiDateComboBoxTemplate ); + + ADD_VIRTUAL_CONTROL (GroupBox, GuiControl, CreateGroupBoxStyle, GuiControlTemplate ); + ADD_VIRTUAL_CONTROL (MenuSplitter, GuiControl, CreateMenuSplitterStyle, GuiControlTemplate ); + ADD_VIRTUAL_CONTROL (MenuBarButton, GuiToolstripButton, CreateMenuBarButtonStyle, GuiToolstripButtonTemplate ); + ADD_VIRTUAL_CONTROL (MenuItemButton, GuiToolstripButton, CreateMenuItemButtonStyle, GuiToolstripButtonTemplate ); + ADD_VIRTUAL_CONTROL (ToolstripDropdownButton, GuiToolstripButton, CreateToolBarDropdownButtonStyle, GuiToolstripButtonTemplate ); + ADD_VIRTUAL_CONTROL (ToolstripSplitButton, GuiToolstripButton, CreateToolBarSplitButtonStyle, GuiToolstripButtonTemplate ); + ADD_VIRTUAL_CONTROL (ToolstripSplitter, GuiControl, CreateToolBarSplitterStyle, GuiControlTemplate ); + ADD_VIRTUAL_CONTROL (CheckBox, GuiSelectableButton, CreateCheckBoxStyle, GuiSelectableButtonTemplate ); + ADD_VIRTUAL_CONTROL (RadioButton, GuiSelectableButton, CreateRadioButtonStyle, GuiSelectableButtonTemplate ); + ADD_VIRTUAL_CONTROL (HScroll, GuiScroll, CreateHScrollStyle, GuiScrollTemplate ); + ADD_VIRTUAL_CONTROL (VScroll, GuiScroll, CreateVScrollStyle, GuiScrollTemplate ); + ADD_VIRTUAL_CONTROL (DocumentTextBox, GuiDocumentLabel, CreateDocumentTextBoxStyle, GuiDocumentLabelTemplate ); + ADD_VIRTUAL_CONTROL_F (HTracker, GuiScroll, CreateHTrackerStyle, GuiScrollTemplate, InitializeTrackerProgressBar); + ADD_VIRTUAL_CONTROL_F (VTracker, GuiScroll, CreateVTrackerStyle, GuiScrollTemplate, InitializeTrackerProgressBar); + ADD_VIRTUAL_CONTROL_F (ProgressBar, GuiScroll, CreateProgressBarStyle, GuiScrollTemplate, InitializeTrackerProgressBar); + + LoadToolstripControls(manager); + LoadListControls(manager); + LoadDocumentControls(manager); + LoadCompositions(manager); + LoadTemplates(manager); + + #undef ADD_VIRTUAL_TYPE_LOADER + #undef ADD_TEMPLATE_CONTROL + #undef ADD_TEMPLATE_CONTROL_2 + #undef ADD_VIRTUAL_CONTROL + #undef ADD_VIRTUAL_CONTROL_F + #endif + } + + void Unload()override + { + } + }; + GUI_REGISTER_PLUGIN(GuiPredefinedInstanceLoadersPlugin) + } + } +} + +/*********************************************************************** +.\INSTANCELOADERS\GUIINSTANCELOADER_TEMPLATES.CPP +***********************************************************************/ + +#ifndef VCZH_DEBUG_NO_REFLECTION + +namespace vl +{ + namespace presentation + { + namespace instance_loaders + { + +/*********************************************************************** +GuiTemplateInstanceLoader +***********************************************************************/ + + class GuiTemplateInstanceLoader : public Object, public IGuiInstanceLoader + { + protected: + GlobalStringKey typeName; + + public: + GuiTemplateInstanceLoader() + { + typeName = GlobalStringKey::Get(description::TypeInfo::content.typeName); + } + + GlobalStringKey GetTypeName()override + { + return typeName; + } + + void GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + { + List tds; + tds.Add(typeInfo.typeInfo->GetTypeDescriptor()); + + for (vint i = 0; i < tds.Count(); i++) + { + auto td = tds[i]; + if (td != description::GetTypeDescriptor()) + { + vint propCount = td->GetPropertyCount(); + for (vint i = 0; i < propCount; i++) + { + auto prop = td->GetProperty(i); + if (prop->IsWritable() && INVLOC.EndsWith(prop->GetName(), L"Template", Locale::None)) + { + propertyNames.Add(GlobalStringKey::Get(prop->GetName())); + } + } + + vint baseCount = td->GetBaseTypeDescriptorCount(); + for (vint i = 0; i < baseCount; i++) + { + auto baseTd = td->GetBaseTypeDescriptor(i); + if (!tds.Contains(baseTd)) + { + tds.Add(baseTd); + } + } + } + } + } + }; + +/*********************************************************************** +Initialization +***********************************************************************/ + + void LoadTemplates(IGuiInstanceLoaderManager* manager) + { + manager->SetLoader(new GuiTemplateInstanceLoader); + } + } + } +} + +#endif + + +/*********************************************************************** +.\INSTANCELOADERS\GUIINSTANCELOADER_TOOLSTRIP.CPP +***********************************************************************/ + +#ifndef VCZH_DEBUG_NO_REFLECTION + +namespace vl +{ + namespace presentation + { + namespace instance_loaders + { + Ptr AddControlToToolstrip(GlobalStringKey variableName, IGuiInstanceLoader::ArgumentMap& arguments, GuiResourceError::List& errors) + { + auto block = MakePtr(); + + FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys()) + { + const auto& values = arguments.GetByIndex(index); + if (prop == GlobalStringKey::Empty) + { + auto value = values[0].expression; + auto td = values[0].typeInfo->GetTypeDescriptor(); + + Ptr expr; + if (td->CanConvertTo(description::GetTypeDescriptor())) + { + auto refControl = MakePtr(); + refControl->name.value = variableName.ToString(); + + auto refToolstripItems = MakePtr(); + refToolstripItems->parent = refControl; + refToolstripItems->name.value = L"ToolstripItems"; + + auto refAdd = MakePtr(); + refAdd->parent = refToolstripItems; + refAdd->name.value = L"Add"; + + auto call = MakePtr(); + call->function = refAdd; + call->arguments.Add(value); + + expr = call; + } + + if (expr) + { + auto stat = MakePtr(); + stat->expression = expr; + block->statements.Add(stat); + } + } + } + + if (block->statements.Count() > 0) + { + return block; + } + return nullptr; + } + +/*********************************************************************** +GuiToolstripInstanceLoaderBase +***********************************************************************/ + + template + class GuiToolstripInstanceLoaderBase : public TBaseType + { + public: + using ArgumentMap = IGuiInstanceLoader::ArgumentMap; + using PropertyInfo = IGuiInstanceLoader::PropertyInfo; + + GuiToolstripInstanceLoaderBase(const WString& _typeName, const WString& _styleMethod, Ptr(*_argumentFunction)(ArgumentMap&)) + :TBaseType(_typeName, _styleMethod, _argumentFunction) + { + } + + GuiToolstripInstanceLoaderBase(const WString& _typeName, const WString& _styleMethod) + :TBaseType(_typeName, _styleMethod) + { + } + + void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + { + propertyNames.Add(GlobalStringKey::Empty); + TBaseType::GetPropertyNames(typeInfo, propertyNames); + } + + Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + { + if (propertyInfo.propertyName == GlobalStringKey::Empty) + { + return GuiInstancePropertyInfo::CollectionWithParent(TypeInfoRetriver::CreateTypeInfo()); + } + return TBaseType::GetPropertyType(propertyInfo); + } + + Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override + { + if (auto statement = AddControlToToolstrip(variableName, arguments, errors)) + { + return statement; + } + else + { + return TBaseType::AssignParameters(precompileContext, resolvingResult, typeInfo, variableName, arguments, attPosition, errors); + } + } + }; + +/*********************************************************************** +GuiToolstripMenuInstanceLoader +***********************************************************************/ + +#define BASE_TYPE GuiTemplateControlInstanceLoader + class GuiToolstripMenuInstanceLoader : public GuiToolstripInstanceLoaderBase + { + public: + static Ptr ArgumentFunction(ArgumentMap&) + { + auto expr = MakePtr(); + expr->value = WfLiteralValue::Null; + return expr; + } + public: + GuiToolstripMenuInstanceLoader() + :GuiToolstripInstanceLoaderBase(description::TypeInfo::content.typeName, L"CreateMenuStyle", ArgumentFunction) + { + } + }; +#undef BASE_TYPE + +/*********************************************************************** +GuiToolstripMenuBarInstanceLoader +***********************************************************************/ + +#define BASE_TYPE GuiTemplateControlInstanceLoader + class GuiToolstripMenuBarInstanceLoader : public GuiToolstripInstanceLoaderBase + { + public: + GuiToolstripMenuBarInstanceLoader() + :GuiToolstripInstanceLoaderBase(description::TypeInfo::content.typeName, L"CreateMenuBarStyle") + { + } + }; +#undef BASE_TYPE + +/*********************************************************************** +GuiToolstripToolBarInstanceLoader +***********************************************************************/ + +#define BASE_TYPE GuiTemplateControlInstanceLoader + class GuiToolstripToolBarInstanceLoader : public GuiToolstripInstanceLoaderBase + { + public: + GuiToolstripToolBarInstanceLoader() + :GuiToolstripInstanceLoaderBase(description::TypeInfo::content.typeName, L"CreateToolBarStyle") + { + } + }; +#undef BASE_TYPE + +/*********************************************************************** +GuiToolstripButtonInstanceLoader +***********************************************************************/ + +#define BASE_TYPE GuiTemplateControlInstanceLoader + class GuiToolstripButtonInstanceLoader : public BASE_TYPE + { + protected: + GlobalStringKey _SubMenu; + + public: + GuiToolstripButtonInstanceLoader() + :BASE_TYPE(description::TypeInfo::content.typeName, L"CreateToolBarButtonStyle") + { + _SubMenu = GlobalStringKey::Get(L"SubMenu"); + } + + void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + { + propertyNames.Add(_SubMenu); + BASE_TYPE::GetPropertyNames(typeInfo, propertyNames); + } + + Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + { + if (propertyInfo.propertyName == _SubMenu) + { + return GuiInstancePropertyInfo::Set(TypeInfoRetriver::CreateTypeInfo()); + } + return BASE_TYPE::GetPropertyType(propertyInfo); + } + + Ptr GetParameter(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const PropertyInfo& propertyInfo, GlobalStringKey variableName, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override + { + if (propertyInfo.propertyName == _SubMenu) + { + auto refControl = MakePtr(); + refControl->name.value = variableName.ToString(); + + auto refEnsureToolstripSubMenu = MakePtr(); + refEnsureToolstripSubMenu->parent = refControl; + refEnsureToolstripSubMenu->name.value = L"EnsureToolstripSubMenu"; + + auto call = MakePtr(); + call->function = refEnsureToolstripSubMenu; + + return call; + } + return BASE_TYPE::GetParameter(precompileContext, resolvingResult, propertyInfo, variableName, attPosition, errors); + } + }; +#undef BASE_TYPE + +/*********************************************************************** +Initialization +***********************************************************************/ + + void LoadToolstripControls(IGuiInstanceLoaderManager* manager) + { + manager->SetLoader(new GuiToolstripMenuInstanceLoader); + manager->SetLoader(new GuiToolstripMenuBarInstanceLoader); + manager->SetLoader(new GuiToolstripToolBarInstanceLoader); + manager->SetLoader(new GuiToolstripButtonInstanceLoader); + } + } + } +} + +#endif + diff --git a/Import/GacUICompiler.h b/Import/GacUICompiler.h index e33683b8..77af0d25 100644 --- a/Import/GacUICompiler.h +++ b/Import/GacUICompiler.h @@ -2,14 +2,119 @@ THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY DEVELOPER: Zihan Chen(vczh) ***********************************************************************/ -#include "Vlpp.h" -#include "VlppWorkflow.h" -#include "VlppWorkflowCompiler.h" #include "GacUI.h" #include "GacUIReflection.h" +#include "Vlpp.h" +#include "VlppWorkflowCompiler.h" +#include "VlppWorkflow.h" /*********************************************************************** -INSTANCEQUERY\GUIINSTANCEQUERY_AST.H +.\GUIINSTANCEHELPERTYPES.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI Reflection: Instance Helper Types + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_REFLECTION_GUIINSTANCEHELPERTYPES +#define VCZH_PRESENTATION_REFLECTION_GUIINSTANCEHELPERTYPES + + +#if defined(__APPLE__) || defined(__APPLE_CC__) + +using namespace vl; +using namespace vl::presentation; +using namespace vl::presentation::elements; +using namespace vl::presentation::compositions; +using namespace vl::presentation::controls; +using namespace vl::presentation::templates; +using namespace vl::presentation::theme; + +#endif + +namespace vl +{ + namespace presentation + { + +/*********************************************************************** +Helper Types +***********************************************************************/ + + namespace helper_types + { + struct SiteValue + { + vint row = 0; + vint column = 0; + vint rowSpan = 1; + vint columnSpan = 1; + }; + } + } + +#ifndef VCZH_DEBUG_NO_REFLECTION + + namespace reflection + { + namespace description + { + +/*********************************************************************** +Type List +***********************************************************************/ + +#define GUIREFLECTIONHELPERTYPES_TYPELIST(F)\ + F(presentation::helper_types::SiteValue)\ + + GUIREFLECTIONHELPERTYPES_TYPELIST(DECL_TYPE_INFO) + } + } + +#endif +} + +#endif + +/*********************************************************************** +.\GUIINSTANCESHAREDSCRIPT.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI Reflection: Shared Script + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_REFLECTION_GUIINSTANCESHAREDSCRIPT +#define VCZH_PRESENTATION_REFLECTION_GUIINSTANCESHAREDSCRIPT + + +namespace vl +{ + namespace presentation + { + class GuiInstanceSharedScript :public Object, public Description + { + public: + WString language; + WString code; + GuiResourceTextPos codePosition; + + static Ptr LoadFromXml(Ptr resource, Ptr xml, GuiResourceError::List& errors); + Ptr SaveToXml(); + }; + } +} + +#endif + +/*********************************************************************** +.\INSTANCEQUERY\GUIINSTANCEQUERY_AST.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -166,7 +271,7 @@ namespace vl #endif /*********************************************************************** -INSTANCEQUERY\GUIINSTANCEQUERY_PARSER.H +.\INSTANCEQUERY\GUIINSTANCEQUERY_PARSER.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -197,7 +302,7 @@ namespace vl #endif /*********************************************************************** -GUIINSTANCEREPRESENTATION.H +.\GUIINSTANCEREPRESENTATION.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -437,78 +542,88 @@ Instance Style Context #endif /*********************************************************************** -GUIINSTANCEHELPERTYPES.H +.\INSTANCEQUERY\GUIINSTANCEQUERY.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 Developer: Zihan Chen(vczh) -GacUI Reflection: Instance Helper Types +GacUI Reflection: Instance Query Interfaces: ***********************************************************************/ -#ifndef VCZH_PRESENTATION_REFLECTION_GUIINSTANCEHELPERTYPES -#define VCZH_PRESENTATION_REFLECTION_GUIINSTANCEHELPERTYPES +#ifndef VCZH_PRESENTATION_REFLECTION_INSTANCEQUERY_GUIINSTANCEQUERY +#define VCZH_PRESENTATION_REFLECTION_INSTANCEQUERY_GUIINSTANCEQUERY -#if defined(__APPLE__) || defined(__APPLE_CC__) - -using namespace vl; -using namespace vl::presentation; -using namespace vl::presentation::elements; -using namespace vl::presentation::compositions; -using namespace vl::presentation::controls; -using namespace vl::presentation::templates; -using namespace vl::presentation::theme; - -#endif - namespace vl { namespace presentation { - -/*********************************************************************** -Helper Types -***********************************************************************/ - - namespace helper_types - { - struct SiteValue - { - vint row = 0; - vint column = 0; - vint rowSpan = 1; - vint columnSpan = 1; - }; - } + extern void ExecuteQuery(Ptr query, Ptr context, collections::List>& input, collections::List>& output); + extern void ExecuteQuery(Ptr query, Ptr context, collections::List>& output); + extern void ApplyStyle(Ptr style, Ptr ctor); + extern void GuiIqPrint(Ptr query, stream::StreamWriter& writer); } - -#ifndef VCZH_DEBUG_NO_REFLECTION - - namespace reflection - { - namespace description - { - -/*********************************************************************** -Type List -***********************************************************************/ - -#define GUIREFLECTIONHELPERTYPES_TYPELIST(F)\ - F(presentation::helper_types::SiteValue)\ - - GUIREFLECTIONHELPERTYPES_TYPELIST(DECL_TYPE_INFO) - } - } - -#endif } #endif /*********************************************************************** -GUIINSTANCELOADER.H +.\GUICPPGEN.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI Reflection: Instance Loader + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_REFLECTION_GUICPPGEN +#define VCZH_PRESENTATION_REFLECTION_GUICPPGEN + + +namespace vl +{ + namespace presentation + { + using namespace reflection; + + extern Ptr PrecompileAndWriteErrors( + Ptr resource, + IGuiResourcePrecompileCallback* callback, + collections::List& errors, + const filesystem::FilePath& errorPath); + + extern Ptr WriteWorkflowScript( + Ptr precompiledFolder, + const filesystem::FilePath& workflowPath); + + extern Ptr WriteCppCodesToFile( + Ptr compiled, + Ptr cppInput, + const filesystem::FilePath& cppFolder); + + extern bool WriteBinaryResource( + Ptr resource, + bool compress, + bool workflow, + const filesystem::FilePath& filePath); + + extern bool WriteEmbeddedResource(Ptr resource, + Ptr cppInput, + Ptr cppOutput, + bool compress, + const filesystem::FilePath& filePath); + } +} + +#endif#pragma once + + +/*********************************************************************** +.\GUIINSTANCELOADER.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -719,7 +834,7 @@ Instance Loader Manager #endif /*********************************************************************** -WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWCODEGEN.H +.\WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWCODEGEN.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -896,69 +1011,7 @@ WorkflowCompiler (ScriptPosition) #endif /*********************************************************************** -INSTANCEQUERY\GUIINSTANCEQUERY.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI Reflection: Instance Query - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_REFLECTION_INSTANCEQUERY_GUIINSTANCEQUERY -#define VCZH_PRESENTATION_REFLECTION_INSTANCEQUERY_GUIINSTANCEQUERY - - -namespace vl -{ - namespace presentation - { - extern void ExecuteQuery(Ptr query, Ptr context, collections::List>& input, collections::List>& output); - extern void ExecuteQuery(Ptr query, Ptr context, collections::List>& output); - extern void ApplyStyle(Ptr style, Ptr ctor); - extern void GuiIqPrint(Ptr query, stream::StreamWriter& writer); - } -} - -#endif - -/*********************************************************************** -GUIINSTANCESHAREDSCRIPT.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI Reflection: Shared Script - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_REFLECTION_GUIINSTANCESHAREDSCRIPT -#define VCZH_PRESENTATION_REFLECTION_GUIINSTANCESHAREDSCRIPT - - -namespace vl -{ - namespace presentation - { - class GuiInstanceSharedScript :public Object, public Description - { - public: - WString language; - WString code; - GuiResourceTextPos codePosition; - - static Ptr LoadFromXml(Ptr resource, Ptr xml, GuiResourceError::List& errors); - Ptr SaveToXml(); - }; - } -} - -#endif - -/*********************************************************************** -INSTANCELOADERS\GUIINSTANCELOADER_TEMPLATECONTROL.H +.\INSTANCELOADERS\GUIINSTANCELOADER_TEMPLATECONTROL.H ***********************************************************************/ #ifndef VCZH_PRESENTATION_REFLECTION_INSTANCELOADERS_GUIINSTANCELOADER_TEMPLATECONTROL @@ -1217,3 +1270,4 @@ GuiVrtualTypeInstanceLoader } } #endif + diff --git a/Import/GacUIReflection.cpp b/Import/GacUIReflection.cpp index e6f652c4..2e0605b0 100644 --- a/Import/GacUIReflection.cpp +++ b/Import/GacUIReflection.cpp @@ -5,7 +5,7 @@ DEVELOPER: Zihan Chen(vczh) #include "GacUIReflection.h" /*********************************************************************** -GUIINSTANCECOMPILEDWORKFLOW.CPP +.\GUIINSTANCECOMPILEDWORKFLOW.CPP ***********************************************************************/ namespace vl @@ -140,15 +140,13 @@ Plugin class GuiRuntimeTypeResolversPlugin : public Object, public IGuiPlugin { public: - GuiRuntimeTypeResolversPlugin() + + GUI_PLUGIN_NAME(GacUI_Compiler_WorkflowTypeResolvers) { + GUI_PLUGIN_DEPEND(GacUI_Res_ResourceResolver); } void Load()override - { - } - - void AfterLoad()override { IGuiResourceResolverManager* manager = GetResourceResolverManager(); manager->SetTypeResolver(new GuiResourceCompiledWorkflowTypeResolver); @@ -163,7 +161,7 @@ Plugin } /*********************************************************************** -TYPEDESCRIPTORS\GUIREFLECTIONBASIC.CPP +.\TYPEDESCRIPTORS\GUIREFLECTIONBASIC.CPP ***********************************************************************/ namespace vl @@ -804,7 +802,7 @@ Type Loader } /*********************************************************************** -TYPEDESCRIPTORS\GUIREFLECTIONCOMPOSITIONS.CPP +.\TYPEDESCRIPTORS\GUIREFLECTIONCOMPOSITIONS.CPP ***********************************************************************/ namespace vl @@ -1241,7 +1239,7 @@ Type Loader } /*********************************************************************** -TYPEDESCRIPTORS\GUIREFLECTIONCONTROLS.CPP +.\TYPEDESCRIPTORS\GUIREFLECTIONCONTROLS.CPP ***********************************************************************/ namespace vl @@ -1300,9 +1298,8 @@ Type Declaration BEGIN_INTERFACE_MEMBER_NOPROXY(ITheme) CLASS_MEMBER_STATIC_EXTERNALMETHOD(GetCurrentTheme, NO_PARAMETER, ITheme*(*)(), vl::presentation::theme::GetCurrentTheme) - CLASS_MEMBER_STATIC_EXTERNALMETHOD(SetCurrentTheme, {L"theme"}, void(*)(ITheme*), vl::presentation::theme::SetCurrentTheme) - CLASS_MEMBER_STATIC_EXTERNALMETHOD(CreateWin7Theme, NO_PARAMETER, Ptr(*)(), vl::reflection::description::CreateWin7Theme) - CLASS_MEMBER_STATIC_EXTERNALMETHOD(CreateWin8Theme, NO_PARAMETER, Ptr(*)(), vl::reflection::description::CreateWin8Theme) + CLASS_MEMBER_STATIC_EXTERNALMETHOD(RegisterTheme, {L"name" _ L"theme"}, bool(*)(const WString&, Ptr), vl::presentation::theme::RegisterTheme) + CLASS_MEMBER_STATIC_EXTERNALMETHOD(UnrgisterTheme, {L"name"}, Ptr(*)(const WString&), vl::presentation::theme::UnregisterTheme) CLASS_MEMBER_METHOD(CreateWindowStyle, NO_PARAMETER) CLASS_MEMBER_METHOD(CreateCustomControlStyle, NO_PARAMETER) @@ -1315,7 +1312,6 @@ Type Declaration CLASS_MEMBER_METHOD(CreateComboBoxStyle, NO_PARAMETER) CLASS_MEMBER_METHOD(CreateMultilineTextBoxStyle, NO_PARAMETER) CLASS_MEMBER_METHOD(CreateTextBoxStyle, NO_PARAMETER) - CLASS_MEMBER_METHOD(GetDefaultTextBoxColorEntry, NO_PARAMETER) CLASS_MEMBER_METHOD(CreateDocumentViewerStyle, NO_PARAMETER) CLASS_MEMBER_METHOD(CreateDocumentLabelStyle, NO_PARAMETER) CLASS_MEMBER_METHOD(CreateDocumentTextBoxStyle, NO_PARAMETER) @@ -1345,14 +1341,58 @@ Type Declaration CLASS_MEMBER_METHOD(CreateHTrackerStyle, NO_PARAMETER) CLASS_MEMBER_METHOD(CreateVTrackerStyle, NO_PARAMETER) CLASS_MEMBER_METHOD(CreateProgressBarStyle, NO_PARAMETER) - CLASS_MEMBER_METHOD(GetScrollDefaultSize, NO_PARAMETER) - CLASS_MEMBER_METHOD(GetTrackerDefaultSize, NO_PARAMETER) CLASS_MEMBER_METHOD(CreateTextListStyle, NO_PARAMETER) CLASS_MEMBER_METHOD(CreateCheckTextListItemStyle, NO_PARAMETER) CLASS_MEMBER_METHOD(CreateRadioTextListItemStyle, NO_PARAMETER) END_INTERFACE_MEMBER(ITheme) + BEGIN_CLASS_MEMBER(ThemeTemplates) + CLASS_MEMBER_BASE(GuiInstanceRootObject) + CLASS_MEMBER_CONSTRUCTOR(Ptr(), NO_PARAMETER) + + CLASS_MEMBER_FIELD(window) + CLASS_MEMBER_FIELD(customControl) + CLASS_MEMBER_FIELD(tooltip) + CLASS_MEMBER_FIELD(label) + CLASS_MEMBER_FIELD(shortcutKey) + CLASS_MEMBER_FIELD(scrollView) + CLASS_MEMBER_FIELD(groupBox) + CLASS_MEMBER_FIELD(tab) + CLASS_MEMBER_FIELD(comboBox) + CLASS_MEMBER_FIELD(multilineTextBox) + CLASS_MEMBER_FIELD(singlelineTextBox) + CLASS_MEMBER_FIELD(documentViewer) + CLASS_MEMBER_FIELD(documentLabel) + CLASS_MEMBER_FIELD(documentTextBox) + CLASS_MEMBER_FIELD(listView) + CLASS_MEMBER_FIELD(treeView) + CLASS_MEMBER_FIELD(textList) + CLASS_MEMBER_FIELD(listItemBackground) + CLASS_MEMBER_FIELD(treeItemExpander) + CLASS_MEMBER_FIELD(checkTextListItem) + CLASS_MEMBER_FIELD(radioTextListItem) + CLASS_MEMBER_FIELD(menu) + CLASS_MEMBER_FIELD(menuBar) + CLASS_MEMBER_FIELD(menuSplitter) + CLASS_MEMBER_FIELD(menuBarButton) + CLASS_MEMBER_FIELD(menuItemButton) + CLASS_MEMBER_FIELD(toolBar) + CLASS_MEMBER_FIELD(toolBarButton) + CLASS_MEMBER_FIELD(toolBarDropdownButton) + CLASS_MEMBER_FIELD(toolBarSplitButton) + CLASS_MEMBER_FIELD(toolBarSplitter) + CLASS_MEMBER_FIELD(button) + CLASS_MEMBER_FIELD(checkBox) + CLASS_MEMBER_FIELD(radioButton) + CLASS_MEMBER_FIELD(datePicker) + CLASS_MEMBER_FIELD(hScroll) + CLASS_MEMBER_FIELD(vScroll) + CLASS_MEMBER_FIELD(hTracker) + CLASS_MEMBER_FIELD(vTracker) + CLASS_MEMBER_FIELD(progressBar) + END_CLASS_MEMBER(ThemeTemplates) + BEGIN_CLASS_MEMBER(GuiDialogBase) CLASS_MEMBER_BASE(GuiComponent) END_CLASS_MEMBER(GuiDialogBase) @@ -2752,8 +2792,9 @@ Type Loader } } + /*********************************************************************** -TYPEDESCRIPTORS\GUIREFLECTIONELEMENTS.CPP +.\TYPEDESCRIPTORS\GUIREFLECTIONELEMENTS.CPP ***********************************************************************/ namespace vl @@ -3035,7 +3076,7 @@ Type Loader } /*********************************************************************** -TYPEDESCRIPTORS\GUIREFLECTIONEVENTS.CPP +.\TYPEDESCRIPTORS\GUIREFLECTIONEVENTS.CPP ***********************************************************************/ namespace vl @@ -3177,7 +3218,7 @@ Type Loader } /*********************************************************************** -TYPEDESCRIPTORS\GUIREFLECTIONPLUGIN.CPP +.\TYPEDESCRIPTORS\GUIREFLECTIONPLUGIN.CPP ***********************************************************************/ /*********************************************************************** @@ -3209,6 +3250,11 @@ namespace vl class GuiReflectionPlugin : public Object, public IGuiPlugin { public: + + GUI_PLUGIN_NAME(GacUI_Instance_Reflection) + { + } + void Load()override { LoadPredefinedTypes(); @@ -3222,10 +3268,6 @@ namespace vl LoadGuiTemplateTypes(); LoadGuiControlTypes(); } - - void AfterLoad()override - { - } void Unload()override { @@ -3237,7 +3279,7 @@ namespace vl } /*********************************************************************** -TYPEDESCRIPTORS\GUIREFLECTIONTEMPLATES.CPP +.\TYPEDESCRIPTORS\GUIREFLECTIONTEMPLATES.CPP ***********************************************************************/ namespace vl @@ -3305,8 +3347,10 @@ Type Declaration END_CLASS_MEMBER(GuiComponent) BEGIN_CLASS_MEMBER(GuiInstanceRootObject) - CLASS_MEMBER_METHOD_OVERLOAD(FinalizeInstanceRecursively, {L"thisObject"}, void(GuiInstanceRootObject::*)(GuiGraphicsComposition*)) - CLASS_MEMBER_METHOD_OVERLOAD(FinalizeInstanceRecursively, {L"thisObject"}, void(GuiInstanceRootObject::*)(GuiControl*)) + CLASS_MEMBER_METHOD_OVERLOAD(FinalizeInstanceRecursively, {L"thisObject"}, void(GuiInstanceRootObject::*)(GuiTemplate*)) + CLASS_MEMBER_METHOD_OVERLOAD(FinalizeInstanceRecursively, {L"thisObject"}, void(GuiInstanceRootObject::*)(GuiCustomControl*)) + CLASS_MEMBER_METHOD_OVERLOAD(FinalizeInstanceRecursively, {L"thisObject"}, void(GuiInstanceRootObject::*)(GuiControlHost*)) + CLASS_MEMBER_METHOD(FinalizeGeneralInstance, {L"thisObject"}) CLASS_MEMBER_METHOD(SetResourceResolver, {L"resolver"}) CLASS_MEMBER_METHOD(ResolveResource, {L"protocol" _ L"path" _ L"ensureExist"}) diff --git a/Import/GacUIReflection.h b/Import/GacUIReflection.h index 419846c4..d962dddb 100644 --- a/Import/GacUIReflection.h +++ b/Import/GacUIReflection.h @@ -2,13 +2,69 @@ THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY DEVELOPER: Zihan Chen(vczh) ***********************************************************************/ -#include "Vlpp.h" -#include "VlppWorkflow.h" -#include "VlppWorkflowCompiler.h" #include "GacUI.h" +#include "Vlpp.h" +#include "VlppWorkflowCompiler.h" +#include "VlppWorkflow.h" /*********************************************************************** -TYPEDESCRIPTORS\GUIREFLECTIONPLUGIN.H +.\GUIINSTANCECOMPILEDWORKFLOW.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI Reflection: Shared Script + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_REFLECTION_GUIINSTANCECOMPILEDWORKFLOW +#define VCZH_PRESENTATION_REFLECTION_GUIINSTANCECOMPILEDWORKFLOW + + +namespace vl +{ + namespace workflow + { + class WfModule; + } + + namespace presentation + { + class GuiInstanceCompiledWorkflow : public Object, public Description + { + public: + enum AssemblyType + { + Shared, + InstanceClass, + TemporaryClass, + }; + + struct ModuleRecord + { + Ptr module; + GuiResourceTextPos position; + bool shared = false; + }; + + collections::List modules; + Ptr metadata; + Ptr binaryToLoad; + + AssemblyType type = AssemblyType::Shared; + Ptr assembly; + Ptr context; + + void Initialize(bool initializeContext); + }; + } +} + +#endif + +/*********************************************************************** +.\TYPEDESCRIPTORS\GUIREFLECTIONPLUGIN.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -260,6 +316,7 @@ Type List (Controls) #define GUIREFLECTIONCONTROLS_TYPELIST(F)\ F(presentation::controls::GuiApplication)\ F(presentation::theme::ITheme)\ + F(presentation::theme::ThemeTemplates)\ F(presentation::controls::GuiDialogBase)\ F(presentation::controls::GuiMessageDialog)\ F(presentation::controls::GuiColorDialog)\ @@ -1109,59 +1166,3 @@ Interface Proxy (Controls) } #endif - -/*********************************************************************** -GUIINSTANCECOMPILEDWORKFLOW.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI Reflection: Shared Script - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_REFLECTION_GUIINSTANCECOMPILEDWORKFLOW -#define VCZH_PRESENTATION_REFLECTION_GUIINSTANCECOMPILEDWORKFLOW - - -namespace vl -{ - namespace workflow - { - class WfModule; - } - - namespace presentation - { - class GuiInstanceCompiledWorkflow : public Object, public Description - { - public: - enum AssemblyType - { - Shared, - InstanceClass, - TemporaryClass, - }; - - struct ModuleRecord - { - Ptr module; - GuiResourceTextPos position; - bool shared = false; - }; - - collections::List modules; - Ptr metadata; - Ptr binaryToLoad; - - AssemblyType type = AssemblyType::Shared; - Ptr assembly; - Ptr context; - - void Initialize(bool initializeContext); - }; - } -} - -#endif diff --git a/Import/GacUIWindows.cpp b/Import/GacUIWindows.cpp index 9570fd56..5d11fdba 100644 --- a/Import/GacUIWindows.cpp +++ b/Import/GacUIWindows.cpp @@ -5,1658 +5,2528 @@ DEVELOPER: Zihan Chen(vczh) #include "GacUIWindows.h" /*********************************************************************** -NATIVEWINDOW\WINDOWS\WINNATIVEWINDOW.CPP +.\GRAPHICSELEMENT\WINDOWSDIRECT2D\GUIGRAPHICSLAYOUTPROVIDERWINDOWSDIRECT2D.CPP ***********************************************************************/ -#pragma comment(lib, "Imm32.lib") -#pragma comment(lib, "Shlwapi.lib") - namespace vl { namespace presentation { - namespace windows - { - using namespace collections; + using namespace elements; + using namespace collections; - HWND GetHWNDFromNativeWindowHandle(INativeWindow* window) - { - if(!window) return NULL; - IWindowsForm* form=GetWindowsForm(window); - if(!form) return NULL; - return form->GetWindowHandle(); - } + namespace elements_windows_d2d + { /*********************************************************************** -WindowsClass +WindowsDirect2DElementInlineObject ***********************************************************************/ - class WinClass : public Object + class WindowsDirect2DElementInlineObject : public IDWriteInlineObject { + public: + class IRendererCallback : public Interface + { + public: + virtual Color GetBackgroundColor(vint textPosition) = 0; + virtual IWindowsDirect2DRenderTarget* GetDirect2DRenderTarget() = 0; + virtual Point GetParagraphOffset() = 0; + virtual IGuiGraphicsParagraphCallback* GetParagraphCallback() = 0; + }; + protected: - WString name; - WNDCLASSEX windowClass; - ATOM windowAtom; + vint counter; + IGuiGraphicsParagraph::InlineObjectProperties properties; + IRendererCallback* rendererCallback; + vint start; + vint length; public: - WinClass(WString _name, bool shadow, bool ownDC, WNDPROC procedure, HINSTANCE hInstance) + WindowsDirect2DElementInlineObject( + const IGuiGraphicsParagraph::InlineObjectProperties& _properties, + IRendererCallback* _rendererCallback, + vint _start, + vint _length + ) + :counter(1) + ,properties(_properties) + ,rendererCallback(_rendererCallback) + ,start(_start) + ,length(_length) { - name=_name; - windowClass.cbSize=sizeof(windowClass); - windowClass.style=CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | (shadow?CS_DROPSHADOW:0) | (ownDC?CS_OWNDC:0); - windowClass.lpfnWndProc=procedure; - windowClass.cbClsExtra=0; - windowClass.cbWndExtra=0; - windowClass.hInstance=hInstance; - windowClass.hIcon=LoadIcon(NULL,IDI_APPLICATION); - windowClass.hCursor=NULL;//LoadCursor(NULL,IDC_ARROW); - windowClass.hbrBackground=GetSysColorBrush(COLOR_BTNFACE); - windowClass.lpszMenuName=NULL; - windowClass.lpszClassName=name.Buffer(); - windowClass.hIconSm=NULL; - windowAtom=RegisterClassEx(&windowClass); } - bool IsAvailable() + ~WindowsDirect2DElementInlineObject() { - return windowAtom!=0; + if (properties.backgroundImage) + { + IGuiGraphicsRenderer* graphicsRenderer=properties.backgroundImage->GetRenderer(); + if(graphicsRenderer) + { + graphicsRenderer->SetRenderTarget(0); + } + } } - WString GetName() + vint GetStart() { - return name; + return start; } - ATOM GetClassAtom() + vint GetLength() { - return windowAtom; + return length; + } + + const IGuiGraphicsParagraph::InlineObjectProperties& GetProperties() + { + return properties; + } + + Ptr GetElement() + { + return properties.backgroundImage; + } + + HRESULT STDMETHODCALLTYPE QueryInterface( + REFIID riid, + void __RPC_FAR *__RPC_FAR *ppvObject + ) + { + if(ppvObject) + { + *ppvObject=NULL; + } + return E_NOINTERFACE; + } + + ULONG STDMETHODCALLTYPE AddRef(void) + { + ++counter; + return S_OK; + } + + ULONG STDMETHODCALLTYPE Release(void) + { + if(--counter==0) + { + delete this; + } + return S_OK; + } + + STDMETHOD(Draw)( + void* clientDrawingContext, + IDWriteTextRenderer* renderer, + FLOAT originX, + FLOAT originY, + BOOL isSideways, + BOOL isRightToLeft, + IUnknown* clientDrawingEffect + )override + { + Rect bounds(Point((vint)originX, (vint)originY), properties.size); + if (properties.backgroundImage) + { + IGuiGraphicsRenderer* graphicsRenderer=properties.backgroundImage->GetRenderer(); + if(graphicsRenderer) + { + graphicsRenderer->Render(bounds); + } + } + + Color color=rendererCallback->GetBackgroundColor(start); + if(color.a!=0) + { + color.a/=2; + if(IWindowsDirect2DRenderTarget* renderTarget=rendererCallback->GetDirect2DRenderTarget()) + { + ID2D1SolidColorBrush* brush=renderTarget->CreateDirect2DBrush(color); + + renderTarget->GetDirect2DRenderTarget()->FillRectangle( + D2D1::RectF(bounds.x1-0.5f, bounds.y1-0.5f, bounds.x2+0.5f, bounds.y2+0.5f), + brush + ); + + renderTarget->DestroyDirect2DBrush(color); + } + } + + if (properties.callbackId != -1) + { + if (auto callback = rendererCallback->GetParagraphCallback()) + { + auto offset = rendererCallback->GetParagraphOffset(); + auto size = callback->OnRenderInlineObject(properties.callbackId, Rect(Point(bounds.x1 - offset.x, bounds.y1 - offset.y), bounds.GetSize())); + properties.size = size; + } + } + return S_OK; + } + + STDMETHOD(GetMetrics)( + DWRITE_INLINE_OBJECT_METRICS* metrics + )override + { + metrics->width=(FLOAT)properties.size.x; + metrics->height=(FLOAT)properties.size.y; + metrics->baseline=(FLOAT)(properties.baseline==-1?properties.size.y:properties.baseline); + metrics->supportsSideways=TRUE; + return S_OK; + } + + STDMETHOD(GetOverhangMetrics)( + DWRITE_OVERHANG_METRICS* overhangs + )override + { + overhangs->left=0; + overhangs->right=0; + overhangs->top=0; + overhangs->bottom=0; + return S_OK; + } + + STDMETHOD(GetBreakConditions)( + DWRITE_BREAK_CONDITION* breakConditionBefore, + DWRITE_BREAK_CONDITION* breakConditionAfter + )override + { + switch(properties.breakCondition) + { + case IGuiGraphicsParagraph::StickToPreviousRun: + *breakConditionBefore=DWRITE_BREAK_CONDITION_MAY_NOT_BREAK; + *breakConditionAfter=DWRITE_BREAK_CONDITION_CAN_BREAK; + break; + case IGuiGraphicsParagraph::StickToNextRun: + *breakConditionBefore=DWRITE_BREAK_CONDITION_CAN_BREAK; + *breakConditionAfter=DWRITE_BREAK_CONDITION_MAY_NOT_BREAK; + break; + default: + *breakConditionBefore=DWRITE_BREAK_CONDITION_CAN_BREAK; + *breakConditionAfter=DWRITE_BREAK_CONDITION_CAN_BREAK; + } + return S_OK; } }; /*********************************************************************** -WindowsForm +WindowsDirect2DParagraph ***********************************************************************/ - class WindowsForm : public Object, public INativeWindow, public IWindowsForm + class WindowsDirect2DParagraph : public Object, public IGuiGraphicsParagraph, public WindowsDirect2DElementInlineObject::IRendererCallback { protected: - - LONG_PTR InternalGetExStyle() + struct TextRange { - return GetWindowLongPtr(handle, GWL_EXSTYLE); - } + vint start; + vint end; - void InternalSetExStyle(LONG_PTR exStyle) - { - LONG_PTR result = SetWindowLongPtr(handle, GWL_EXSTYLE, exStyle); - SetWindowPos(handle, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED); - } + TextRange(){} + TextRange(vint _start, vint _end):start(_start),end(_end){} - bool GetExStyle(LONG_PTR exStyle) - { - LONG_PTR Long=InternalGetExStyle(); - return (Long & exStyle) != 0; - } + bool operator==(const TextRange& range) const { return start==range.start; } + bool operator!=(const TextRange& range) const { return start!=range.start; } + bool operator<(const TextRange& range) const { return start(const TextRange& range) const { return start>range.start; } + bool operator>=(const TextRange& range) const { return start>=range.start; } + }; - void SetExStyle(LONG_PTR exStyle, bool available) + typedef Dictionary> InlineElementMap; + typedef Dictionary ColorMap; + typedef Dictionary GraphicsElementMap; + protected: + IGuiGraphicsLayoutProvider* provider; + ID2D1SolidColorBrush* defaultTextColor; + IDWriteFactory* dwriteFactory; + IWindowsDirect2DRenderTarget* renderTarget; + WString paragraphText; + ComPtr textLayout; + bool wrapLine; + vint maxWidth; + List usedColors; + + InlineElementMap inlineElements; + GraphicsElementMap graphicsElements; + ColorMap backgroundColors; + + vint caret; + Color caretColor; + bool caretFrontSide; + ID2D1SolidColorBrush* caretBrush; + + bool formatDataAvailable; + Array lineMetrics; + Array lineStarts; + Array lineTops; + Array clusterMetrics; + Array hitTestMetrics; + Array charHitTestMap; + + Point paragraphOffset; + IGuiGraphicsParagraphCallback* paragraphCallback; + +/*********************************************************************** +WindowsDirect2DParagraph (Ranges) +***********************************************************************/ + + template + void CutMap(Dictionary& map, vint start, vint length) { - LONG_PTR Long = InternalGetExStyle(); - if(available) + vint end=start+length; + for(vint i=map.Count()-1;i>=0;i--) { - Long |= exStyle; - } - else - { - Long &= ~exStyle; - } - InternalSetExStyle(Long); - } - - bool GetStyle(LONG_PTR style) - { - LONG_PTR Long = GetWindowLongPtr(handle, GWL_STYLE); - return (Long & style) != 0; - } - - void SetStyle(LONG_PTR style, bool available) - { - LONG_PTR Long = GetWindowLongPtr(handle, GWL_STYLE); - if(available) - { - Long |= style; - } - else - { - Long &= ~style; - } - SetWindowLongPtr(handle, GWL_STYLE, Long); - SetWindowPos(handle, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED); - } - - NativeWindowMouseInfo ConvertMouse(WPARAM wParam, LPARAM lParam, bool wheelMessage, bool nonClient) - { - NativeWindowMouseInfo info; - - info.nonClient = false; - if (nonClient) - { - switch (wParam) + TextRange key=map.Keys()[i]; + if(key.startstart?key.start:start; + vint s3=key.end + void UpdateOverlappedMap(Dictionary& map, vint start, vint length, const T& value) + { + vint end=start+length; + for(vint i=map.Count()-1;i>=0;i--) { - info.wheel=GET_WHEEL_DELTA_WPARAM(wParam); - wParam=GET_KEYSTATE_WPARAM(wParam); - } - else - { - info.wheel=0; - } - - if (nonClient) - { - info.ctrl = WinIsKeyPressing(VK_CONTROL); - info.shift = WinIsKeyPressing(VK_SHIFT); - info.left= WinIsKeyPressing(MK_LBUTTON); - info.middle= WinIsKeyPressing(MK_MBUTTON); - info.right = WinIsKeyPressing(MK_RBUTTON); - - POINTS point = MAKEPOINTS(lParam); - Point offset = GetClientBoundsInScreen().LeftTop(); - info.x = point.x - offset.x; - info.y = point.y - offset.y; - } - else - { - info.ctrl=(wParam & MK_CONTROL)!=0; - info.shift=(wParam & MK_SHIFT)!=0; - info.left=(wParam & MK_LBUTTON)!=0; - info.middle=(wParam & MK_MBUTTON)!=0; - info.right=(wParam & MK_RBUTTON)!=0; - - POINTS point = MAKEPOINTS(lParam); - - if (wheelMessage) + TextRange key=map.Keys()[i]; + if(key.start + void DefragmentMap(Dictionary& map) + { + vint lastIndex=map.Count()-1; + T lastValue=map.Values()[lastIndex]; + for(vint i=map.Count()-2;i>=-1;i--) + { + if(i==-1 || map.Values()[i]!=lastValue) + { + if(lastIndex-i>0) + { + vint start=map.Keys()[i+1].start; + vint end=map.Keys()[lastIndex].end; + TextRange key(start, end); + + for(vint j=lastIndex;j>i;j--) + { + map.Remove(map.Keys()[j]); + } + map.Add(key, lastValue); + } + lastIndex=i; + if(i!=-1) + { + lastValue=map.Values()[i]; + } + } + } + } + + template + void SetMap(Dictionary& map, vint start, vint length, const T& value) + { + CutMap(map, start, length); + UpdateOverlappedMap(map, start, length, value); + DefragmentMap(map); + } + + template + bool GetMap(Dictionary& map, vint textPosition, T& value) + { + vint start=0; + vint end=map.Count()-1; + while(start<=end) + { + vint middle=(start+end)/2; + TextRange key=map.Keys()[middle]; + if(textPosition=key.end) + { + start=middle+1; } else { - info.x = point.x; - info.y = point.y; - } - } - return info; - } - - NativeWindowKeyInfo ConvertKey(WPARAM wParam, LPARAM lParam) - { - NativeWindowKeyInfo info; - info.code=wParam; - info.ctrl=WinIsKeyPressing(VK_CONTROL); - info.shift=WinIsKeyPressing(VK_SHIFT); - info.alt=WinIsKeyPressing(VK_MENU); - info.capslock=WinIsKeyToggled(VK_CAPITAL); - return info; - } - - NativeWindowCharInfo ConvertChar(WPARAM wParam) - { - NativeWindowCharInfo info; - info.code=(wchar_t)wParam; - info.ctrl=WinIsKeyPressing(VK_CONTROL); - info.shift=WinIsKeyPressing(VK_SHIFT); - info.alt=WinIsKeyPressing(VK_MENU); - info.capslock=WinIsKeyToggled(VK_CAPITAL); - return info; - } - - void TrackMouse(bool enable) - { - TRACKMOUSEEVENT trackMouseEvent; - trackMouseEvent.cbSize=sizeof(trackMouseEvent); - trackMouseEvent.hwndTrack=handle; - trackMouseEvent.dwFlags=(enable?0:TME_CANCEL) | TME_HOVER | TME_LEAVE; - trackMouseEvent.dwHoverTime=HOVER_DEFAULT; - TrackMouseEvent(&trackMouseEvent); - } - - void UpdateCompositionForContent() - { - HIMC imc = ImmGetContext(handle); - COMPOSITIONFORM cf; - cf.dwStyle = CFS_POINT; - cf.ptCurrentPos.x = (int)caretPoint.x; - cf.ptCurrentPos.y = (int)caretPoint.y; - ImmSetCompositionWindow(imc, &cf); - ImmReleaseContext(handle, imc); - } - - bool HandleMessageInternal(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& result) - { - bool transferFocusEvent = false; - bool nonClient = false; - - switch(uMsg) - { - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_LBUTTONDBLCLK: - case WM_RBUTTONDOWN: - case WM_RBUTTONUP: - case WM_RBUTTONDBLCLK: - case WM_MBUTTONDOWN: - case WM_MBUTTONUP: - case WM_MBUTTONDBLCLK: - transferFocusEvent=true; - } - switch(uMsg) - { - // ************************************** moving and sizing - case WM_MOVING:case WM_SIZING: - { - LPRECT rawBounds=(LPRECT)lParam; - Rect bounds(rawBounds->left, rawBounds->top, rawBounds->right, rawBounds->bottom); - for(vint i=0;iMoving(bounds, false); - } - if( rawBounds->left!=bounds.Left() - || rawBounds->top!=bounds.Top() - || rawBounds->right!=bounds.Right() - || rawBounds->bottom!=bounds.Bottom()) - { - rawBounds->left=(int)bounds.Left(); - rawBounds->top=(int)bounds.Top(); - rawBounds->right=(int)bounds.Right(); - rawBounds->bottom=(int)bounds.Bottom(); - result=TRUE; - } - } - break; - case WM_MOVE:case WM_SIZE: - { - for(vint i=0;iMoved(); - } - } - break; - // ************************************** state - case WM_ENABLE: - { - for(vint i=0;iEnabled(); - } - else - { - listeners[i]->Disabled(); - } - } - } - break; - case WM_SETFOCUS: - { - for(vint i=0;iGotFocus(); - } - } - break; - case WM_KILLFOCUS: - { - for(vint i=0;iLostFocus(); - } - } - break; - case WM_ACTIVATE: - { - for(vint i=0;iActivated(); - } - else - { - listeners[i]->Deactivated(); - } - } - } - break; - case WM_SHOWWINDOW: - { - if(wParam==TRUE) - { - for(vint i=0;iOpened(); - } - } - else - { - for(vint i=0;iClosed(); - } - } - } - break; - case WM_CLOSE: - { - bool cancel=false; - for(vint i=0;iClosing(cancel); - } - return cancel; - } - break; - // ************************************** mouse - case WM_NCLBUTTONDOWN: - if (!customFrameMode) break; - nonClient = true; - case WM_LBUTTONDOWN: - { - NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, false, nonClient); - for(vint i=0;iLeftButtonDown(info); - } - } - break; - case WM_NCLBUTTONUP: - if (!customFrameMode) break; - nonClient = true; - case WM_LBUTTONUP: - { - NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, false, nonClient); - for(vint i=0;iLeftButtonUp(info); - } - } - break; - case WM_NCLBUTTONDBLCLK: - if (!customFrameMode) break; - nonClient = true; - case WM_LBUTTONDBLCLK: - { - NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, false, nonClient); - for(vint i=0;iLeftButtonDoubleClick(info); - } - } - break; - case WM_NCRBUTTONDOWN: - if (!customFrameMode) break; - nonClient = true; - case WM_RBUTTONDOWN: - { - NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, false, nonClient); - for(vint i=0;iRightButtonDown(info); - } - } - break; - case WM_NCRBUTTONUP: - if (!customFrameMode) break; - nonClient = true; - case WM_RBUTTONUP: - { - NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, false, nonClient); - for(vint i=0;iRightButtonUp(info); - } - } - break; - case WM_NCRBUTTONDBLCLK: - if (!customFrameMode) break; - nonClient = true; - case WM_RBUTTONDBLCLK: - { - NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, false, nonClient); - for(vint i=0;iRightButtonDoubleClick(info); - } - } - break; - case WM_NCMBUTTONDOWN: - if (!customFrameMode) break; - nonClient = true; - case WM_MBUTTONDOWN: - { - NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, false, nonClient); - for(vint i=0;iMiddleButtonDown(info); - } - } - break; - case WM_NCMBUTTONUP: - if (!customFrameMode) break; - nonClient = true; - case WM_MBUTTONUP: - { - NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, false, nonClient); - for(vint i=0;iMiddleButtonUp(info); - } - } - break; - case WM_NCMBUTTONDBLCLK: - if (!customFrameMode) break; - nonClient = true; - case WM_MBUTTONDBLCLK: - { - NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, false, nonClient); - for(vint i=0;iMiddleButtonDoubleClick(info); - } - } - break; - case WM_NCMOUSEMOVE: - if (!customFrameMode) break; - nonClient = true; - case WM_MOUSEMOVE: - { - NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, false, nonClient); - if(info.x!=mouseLastX || info.y!=mouseLastY) - { - if(!mouseHoving) - { - mouseHoving=true; - for(vint i=0;iMouseEntered(); - } - TrackMouse(true); - } - for(vint i=0;iMouseMoving(info); - } - } - } - break; - // ************************************** wheel - case WM_MOUSEHWHEEL: - { - NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, true, false); - for(vint i=0;iHorizontalWheel(info); - } - } - break; - case WM_MOUSEWHEEL: - { - NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, true, false); - for(vint i=0;iVerticalWheel(info); - } - } - break; - // ************************************** mouse state - case WM_NCMOUSELEAVE: - nonClient = true; - case WM_MOUSELEAVE: - if (customFrameMode == nonClient) - { - mouseLastX=-1; - mouseLastY=-1; - mouseHoving=false; - for(vint i=0;iMouseLeaved(); - } - } - break; - case WM_NCMOUSEHOVER: - case WM_MOUSEHOVER: - { - TrackMouse(true); - } - break; - // ************************************** key - case WM_KEYUP: - { - NativeWindowKeyInfo info=ConvertKey(wParam, lParam); - for(vint i=0;iKeyUp(info); - } - } - break; - case WM_KEYDOWN: - { - NativeWindowKeyInfo info=ConvertKey(wParam, lParam); - for(vint i=0;iKeyDown(info); - } - } - break; - case WM_SYSKEYUP: - { - NativeWindowKeyInfo info=ConvertKey(wParam, lParam); - if (supressingAlt && !info.ctrl && !info.shift && info.code == VK_MENU) - { - supressingAlt = false; - break; - } - for(vint i=0;iSysKeyUp(info); - } - } - break; - case WM_SYSKEYDOWN: - { - NativeWindowKeyInfo info=ConvertKey(wParam, lParam); - if (supressingAlt && !info.ctrl && !info.shift && info.code == VK_MENU) - { - break; - } - for(vint i=0;iSysKeyDown(info); - } - } - break; - case WM_CHAR: - { - NativeWindowCharInfo info=ConvertChar(wParam); - for(vint i=0;iChar(info); - } - } - break; - // ************************************** painting - case WM_PAINT: - { - for(vint i=0;iPaint(); - } - } - break; - case WM_ERASEBKGND: - result = 0; - return true; - case WM_NCPAINT: - case WM_SYNCPAINT: - if(customFrameMode) - { - result=0; + value=map.Values()[middle]; return true; } - break; - // ************************************** IME - case WM_IME_SETCONTEXT: - if(wParam==TRUE) - { - HIMC imc = ImmGetContext(handle); - ImmAssociateContext(hwnd, imc); - ImmReleaseContext(handle, imc); - } - break; - case WM_IME_STARTCOMPOSITION: - UpdateCompositionForContent(); - break; - // ************************************** hit test - case WM_NCHITTEST: - { - POINTS location=MAKEPOINTS(lParam); - Point windowLocation=GetBounds().LeftTop(); - location.x-=(SHORT)windowLocation.x; - location.y-=(SHORT)windowLocation.y; - for(vint i=0;iHitTest(Point(location.x, location.y))) - { - case INativeWindowListener::BorderNoSizing: - result=HTBORDER; - return true; - case INativeWindowListener::BorderLeft: - result=HTLEFT; - return true; - case INativeWindowListener::BorderRight: - result=HTRIGHT; - return true; - case INativeWindowListener::BorderTop: - result=HTTOP; - return true; - case INativeWindowListener::BorderBottom: - result=HTBOTTOM; - return true; - case INativeWindowListener::BorderLeftTop: - result=HTTOPLEFT; - return true; - case INativeWindowListener::BorderRightTop: - result=HTTOPRIGHT; - return true; - case INativeWindowListener::BorderLeftBottom: - result=HTBOTTOMLEFT; - return true; - case INativeWindowListener::BorderRightBottom: - result=HTBOTTOMRIGHT; - return true; - case INativeWindowListener::Title: - result=HTCAPTION; - return true; - case INativeWindowListener::ButtonMinimum: - result=HTMINBUTTON; - return true; - case INativeWindowListener::ButtonMaximum: - result=HTMAXBUTTON; - return true; - case INativeWindowListener::ButtonClose: - result=HTCLOSE; - return true; - case INativeWindowListener::Client: - result=HTCLIENT; - return true; - case INativeWindowListener::Icon: - result=HTSYSMENU; - return true; - } - } - } - break; - // ************************************** MISC - case WM_SETCURSOR: - { - DWORD hitTestResult=LOWORD(lParam); - if(hitTestResult==HTCLIENT) - { - HCURSOR cursorHandle=cursor->GetCursorHandle(); - if(GetCursor()!=cursorHandle) - { - SetCursor(cursorHandle); - } - result=TRUE; - return true; - } - } - break; - case WM_NCCALCSIZE: - if((BOOL)wParam && customFrameMode) - { - result=0; - return true; - } - break; - case WM_NCACTIVATE: - if(customFrameMode) - { - if(wParam==TRUE) - { - result=FALSE; - } - else - { - result=TRUE; - } - return true; - } - break; - } - - if(IsWindow(hwnd)!=0) - { - if(transferFocusEvent && IsFocused()) - { - WindowsForm* window=this; - while(window->parentWindow && window->alwaysPassFocusToParent) - { - window=window->parentWindow; - } - if(window!=this) - { - window->SetFocus(); - } - } - } - - if (customFrameMode) - { - switch (uMsg) - { - case WM_NCLBUTTONDOWN: - switch (wParam) - { - case HTMINBUTTON: - case HTMAXBUTTON: - case HTCLOSE: - result = 0; - return true; - } - break; - case WM_LBUTTONUP: - { - POINTS location = MAKEPOINTS(lParam); - for(vint i=0;iHitTest(Point(location.x, location.y))) - { - case INativeWindowListener::ButtonMinimum: - ShowMinimized(); - return false; - case INativeWindowListener::ButtonMaximum: - if (GetSizeState() == INativeWindow::Maximized) - { - ShowRestored(); - } - else - { - ShowMaximized(); - } - return false; - case INativeWindowListener::ButtonClose: - Hide(); - return false; - } - } - } - break; - } } return false; } - protected: - HWND handle; - WString title; - WindowsCursor* cursor; - Point caretPoint; - WindowsForm* parentWindow; - bool alwaysPassFocusToParent; - List listeners; - vint mouseLastX; - vint mouseLastY; - vint mouseHoving; - Interface* graphicsHandler; - bool customFrameMode; - List> messageHandlers; - bool supressingAlt; +/*********************************************************************** +WindowsDirect2DParagraph (Layout Retriving) +***********************************************************************/ + + void PrepareFormatData() + { + if(!formatDataAvailable) + { + formatDataAvailable=true; + { + UINT32 lineCount=0; + textLayout->GetLineMetrics(NULL, 0, &lineCount); + lineMetrics.Resize(lineCount); + if(lineCount>0) + { + textLayout->GetLineMetrics(&lineMetrics[0], lineCount, &lineCount); + } + + lineStarts.Resize(lineCount); + lineTops.Resize(lineCount); + vint start=0; + FLOAT top=0; + for(vint i=0;iGetClusterMetrics(NULL, 0, &clusterCount); + clusterMetrics.Resize(clusterCount); + if(clusterCount>0) + { + textLayout->GetClusterMetrics(&clusterMetrics[0], clusterCount, &clusterCount); + } + } + { + vint textPos=0; + hitTestMetrics.Resize(clusterMetrics.Count()); + for(vint i=0;iHitTestTextPosition((UINT32)textPos, FALSE, &x, &y, &metrics); + textPos+=metrics.length; + } + } + { + charHitTestMap.Resize(paragraphText.Length()); + for(vint i=0;iGetDirectWriteFactory()) + ,renderTarget(dynamic_cast(_renderTarget)) + ,paragraphText(_text) + ,textLayout(0) + ,wrapLine(true) + ,maxWidth(-1) + ,caret(-1) + ,caretFrontSide(false) + ,caretBrush(0) + ,formatDataAvailable(false) + ,paragraphCallback(_paragraphCallback) { - List copiedListeners; - CopyFrom(copiedListeners, listeners); - for(vint i=0;iResourceService()->GetDefaultFont(); + Direct2DTextFormatPackage* package=GetWindowsDirect2DResourceManager()->CreateDirect2DTextFormat(defaultFont); + defaultTextColor=renderTarget->CreateDirect2DBrush(Color(0, 0, 0)); + usedColors.Add(Color(0, 0, 0)); + + IDWriteTextLayout* rawTextLayout=0; + HRESULT hr=dwriteFactory->CreateTextLayout( + _text.Buffer(), + (int)_text.Length(), + package->textFormat.Obj(), + 0, + 0, + &rawTextLayout); + if(!FAILED(hr)) { - INativeWindowListener* listener=copiedListeners[i]; - if(listeners.Contains(listener)) - { - listener->Destroyed(); - } + textLayout=rawTextLayout; + textLayout->SetWordWrapping(DWRITE_WORD_WRAPPING_WRAP); } - DestroyWindow(handle); + graphicsElements.Add(TextRange(0, _text.Length()), 0); + backgroundColors.Add(TextRange(0, _text.Length()), Color(0, 0, 0, 0)); + + GetWindowsDirect2DResourceManager()->DestroyDirect2DTextFormat(defaultFont); } - void InvokeDestroying() + ~WindowsDirect2DParagraph() { - for(vint i=0;iDestroying(); + renderTarget->DestroyDirect2DBrush(color); } } - bool HandleMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& result) + IGuiGraphicsLayoutProvider* GetProvider()override { - bool skip = false; + return provider; + } + + IGuiGraphicsRenderTarget* GetRenderTarget()override + { + return renderTarget; + } + + Point GetParagraphOffset()override + { + return paragraphOffset; + } + + IGuiGraphicsParagraphCallback* GetParagraphCallback()override + { + return paragraphCallback; + } + +/*********************************************************************** +WindowsDirect2DParagraph (Formatting) +***********************************************************************/ + + bool GetWrapLine()override + { + return wrapLine; + } + + void SetWrapLine(bool value)override + { + if(wrapLine!=value) { - FOREACH(Ptr, handler, messageHandlers) - { - handler->BeforeHandle(hwnd, uMsg, wParam, lParam, skip); - } - if (skip) - { - return true; - } + wrapLine=value; + textLayout->SetWordWrapping(value?DWRITE_WORD_WRAPPING_WRAP:DWRITE_WORD_WRAPPING_NO_WRAP); + formatDataAvailable=false; } - skip = HandleMessageInternal(hwnd, uMsg, wParam, lParam, result); - if (GetWindowsFormFromHandle(hwnd)) + } + + vint GetMaxWidth()override + { + return maxWidth; + } + + void SetMaxWidth(vint value)override + { + if(maxWidth!=value) { - FOREACH(Ptr, handler, messageHandlers) - { - handler->AfterHandle(hwnd, uMsg, wParam, lParam, skip, result); - } + maxWidth=value; + textLayout->SetMaxWidth(value==-1?65536:(FLOAT)value); + formatDataAvailable=false; } - return skip; } - HWND GetWindowHandle()override + Alignment GetParagraphAlignment()override { - return handle; + switch(textLayout->GetTextAlignment()) + { + case DWRITE_TEXT_ALIGNMENT_LEADING: + return Alignment::Left; + case DWRITE_TEXT_ALIGNMENT_CENTER: + return Alignment::Center; + case DWRITE_TEXT_ALIGNMENT_TRAILING: + return Alignment::Right; + default: + return Alignment::Left; + } } - Interface* GetGraphicsHandler()override + void SetParagraphAlignment(Alignment value)override { - return graphicsHandler; + formatDataAvailable=false; + switch(value) + { + case Alignment::Left: + textLayout->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING); + break; + case Alignment::Center: + textLayout->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); + break; + case Alignment::Right: + textLayout->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_TRAILING); + break; + } } - void SetGraphicsHandler(Interface* handler)override + bool SetFont(vint start, vint length, const WString& value)override { - graphicsHandler=handler; + if(length==0) return true; + formatDataAvailable=false; + + DWRITE_TEXT_RANGE range; + range.startPosition=(int)start; + range.length=(int)length; + HRESULT hr=textLayout->SetFontFamilyName(value.Buffer(), range); + return !FAILED(hr); } - bool InstallMessageHandler(Ptr handler)override + bool SetSize(vint start, vint length, vint value)override { - if (messageHandlers.Contains(handler.Obj())) + if(length==0) return true; + formatDataAvailable=false; + + DWRITE_TEXT_RANGE range; + range.startPosition=(int)start; + range.length=(int)length; + HRESULT hr=textLayout->SetFontSize((FLOAT)value, range); + return !FAILED(hr); + } + + bool SetStyle(vint start, vint length, TextStyle value)override + { + if(length==0) return true; + formatDataAvailable=false; + + DWRITE_TEXT_RANGE range; + range.startPosition=(int)start; + range.length=(int)length; + HRESULT hr=S_OK; + + hr=textLayout->SetFontStyle(value&Italic?DWRITE_FONT_STYLE_ITALIC:DWRITE_FONT_STYLE_NORMAL, range); + if(FAILED(hr)) return false; + hr=textLayout->SetFontWeight(value&Bold?DWRITE_FONT_WEIGHT_BOLD:DWRITE_FONT_WEIGHT_NORMAL, range); + if(FAILED(hr)) return false; + hr=textLayout->SetUnderline(value&Underline?TRUE:FALSE, range); + if(FAILED(hr)) return false; + hr=textLayout->SetStrikethrough(value&Strikeline?TRUE:FALSE, range); + if(FAILED(hr)) return false; + + return true; + } + + bool SetColor(vint start, vint length, Color value)override + { + if(length==0) return true; + formatDataAvailable=false; + + ID2D1SolidColorBrush* brush=renderTarget->CreateDirect2DBrush(value); + usedColors.Add(value); + + DWRITE_TEXT_RANGE range; + range.startPosition=(int)start; + range.length=(int)length; + HRESULT hr=textLayout->SetDrawingEffect(brush, range); + return !FAILED(hr); + } + + bool SetBackgroundColor(vint start, vint length, Color value)override + { + SetMap(backgroundColors, start, length, value); + return true; + } + + bool SetInlineObject(vint start, vint length, const InlineObjectProperties& properties)override + { + if(inlineElements.Keys().Contains(properties.backgroundImage.Obj())) { return false; } - messageHandlers.Add(handler); - return true; - } - - bool UninstallMessageHandler(Ptr handler)override - { - vint index = messageHandlers.IndexOf(handler.Obj()); - if (index == -1)return false; - messageHandlers.RemoveAt(handler); - return true; - } - - Rect GetBounds() - { - RECT rect; - GetWindowRect(handle, &rect); - return Rect(rect.left, rect.top, rect.right, rect.bottom); - } - - void SetBounds(const Rect& bounds) - { - Rect newBounds=bounds; - for(vint i=0;iMoving(newBounds, true); + ComPtr inlineObject=inlineElements.Values().Get(i); + if(startGetStart()+inlineObject->GetLength() && inlineObject->GetStart() inlineObject=new WindowsDirect2DElementInlineObject(properties, this, start, length); + DWRITE_TEXT_RANGE range; + range.startPosition=(int)start; + range.length=(int)length; + HRESULT hr=textLayout->SetInlineObject(inlineObject.Obj(), range); + if(!FAILED(hr)) { - return GetBounds(); + if (properties.backgroundImage) + { + IGuiGraphicsRenderer* renderer=properties.backgroundImage->GetRenderer(); + if(renderer) + { + renderer->SetRenderTarget(renderTarget); + } + inlineElements.Add(properties.backgroundImage.Obj(), inlineObject); + } + SetMap(graphicsElements, start, length, properties.backgroundImage.Obj()); + return true; } else { - RECT required={0,0,0,0}; - RECT bounds; - GetWindowRect(handle, &bounds); - AdjustWindowRect(&required, (DWORD)GetWindowLongPtr(handle, GWL_STYLE), FALSE); - return Rect( - Point( - (bounds.left-required.left), - (bounds.top-required.top) - ), - Size( - (bounds.right-bounds.left)-(required.right-required.left), - (bounds.bottom-bounds.top)-(required.bottom-required.top) - ) + return false; + } + } + + bool ResetInlineObject(vint start, vint length)override + { + IGuiGraphicsElement* element=0; + if(GetMap(graphicsElements, start, element) && element) + { + ComPtr inlineObject=inlineElements[element]; + DWRITE_TEXT_RANGE range; + range.startPosition=(int)inlineObject->GetStart(); + range.length=(int)inlineObject->GetLength(); + HRESULT hr=textLayout->SetInlineObject(NULL, range); + if(!FAILED(hr)) + { + formatDataAvailable=false; + inlineElements.Remove(element); + SetMap(graphicsElements, inlineObject->GetStart(), inlineObject->GetLength(), (IGuiGraphicsElement*)0); + return true; + } + else + { + return false; + } + } + return false; + } + + vint GetHeight()override + { + DWRITE_TEXT_METRICS metrics; + textLayout->GetMetrics(&metrics); + return (vint)metrics.height; + } + +/*********************************************************************** +WindowsDirect2DParagraph (IRenderingCallback) +***********************************************************************/ + + Color GetBackgroundColor(vint textPosition)override + { + Color color; + if(GetMap(backgroundColors, textPosition, color)) + { + return color; + } + else + { + return Color(0, 0, 0, 0); + } + } + + IWindowsDirect2DRenderTarget* GetDirect2DRenderTarget()override + { + return renderTarget; + } + +/*********************************************************************** +WindowsDirect2DParagraph (Rendering) +***********************************************************************/ + + bool OpenCaret(vint _caret, Color _color, bool _frontSide)override + { + if(!IsValidCaret(_caret)) return false; + if(caret!=-1) CloseCaret(); + caret=_caret; + caretColor=_color; + caretFrontSide=_frontSide; + caretBrush=renderTarget->CreateDirect2DBrush(caretColor); + return true; + } + + bool CloseCaret()override + { + if(caret==-1) return false; + caret=-1; + renderTarget->DestroyDirect2DBrush(caretColor); + caretBrush=0; + return true; + } + + void Render(Rect bounds)override + { + paragraphOffset = bounds.LeftTop(); + PrepareFormatData(); + for(vint i=0;i0) + { + ID2D1SolidColorBrush* brush=renderTarget->CreateDirect2DBrush(color); + + vint start=key.start; + if(start<0) + { + start=0; + } + + while(startGetDirect2DRenderTarget()->FillRectangle( + D2D1::RectF(x1, y1, x2, y2), + brush + ); + + start=hitTest.textPosition+hitTest.length; + } + + renderTarget->DestroyDirect2DBrush(color); + } + } + + renderTarget->GetDirect2DRenderTarget()->DrawTextLayout( + D2D1::Point2F((FLOAT)bounds.Left(), (FLOAT)bounds.Top()), + textLayout.Obj(), + defaultTextColor, + D2D1_DRAW_TEXT_OPTIONS_NO_SNAP); + + if(caret!=-1) + { + Rect caretBounds=GetCaretBounds(caret, caretFrontSide); + vint x=caretBounds.x1+bounds.x1; + vint y1=caretBounds.y1+bounds.y1; + vint y2=y1+caretBounds.Height(); + + renderTarget->GetDirect2DRenderTarget()->DrawLine( + D2D1::Point2F((FLOAT)x-0.5f, (FLOAT)y1+0.5f), + D2D1::Point2F((FLOAT)x-0.5f, (FLOAT)y2+0.5f), + caretBrush + ); + renderTarget->GetDirect2DRenderTarget()->DrawLine( + D2D1::Point2F((FLOAT)x+0.5f, (FLOAT)y1+0.5f), + D2D1::Point2F((FLOAT)x+0.5f, (FLOAT)y2+0.5f), + caretBrush ); } } - WString GetTitle() - { - return title; - } - - void SetTitle(WString _title) - { - title=_title; - SetWindowText(handle, title.Buffer()); - } - - INativeCursor* GetWindowCursor() - { - return cursor; - } - - void SetWindowCursor(INativeCursor* _cursor) - { - WindowsCursor* newCursor=dynamic_cast(_cursor); - if(newCursor && cursor!=newCursor) - { - cursor=newCursor; - if(mouseHoving && IsVisible()) - { - SetCursor(cursor->GetCursorHandle()); - } - } - } - - Point GetCaretPoint() - { - return caretPoint; - } - - void SetCaretPoint(Point point) - { - caretPoint=point; - UpdateCompositionForContent(); - } - - INativeWindow* GetParent() - { - return parentWindow; - } - - void SetParent(INativeWindow* parent) - { - parentWindow=dynamic_cast(parent); - if(parentWindow) - { - SetWindowLongPtr(handle, GWLP_HWNDPARENT, (LONG_PTR)parentWindow->handle); - } - else - { - SetWindowLongPtr(handle, GWLP_HWNDPARENT, NULL); - } - } - - bool GetAlwaysPassFocusToParent() - { - return alwaysPassFocusToParent; - } - - void SetAlwaysPassFocusToParent(bool value) - { - alwaysPassFocusToParent=value; - } - - void EnableCustomFrameMode() - { - customFrameMode=true; - } - - void DisableCustomFrameMode() - { - customFrameMode=false; - } - - bool IsCustomFrameModeEnabled() - { - return customFrameMode; - } - - WindowSizeState GetSizeState() - { - if(IsIconic(handle)) - { - return INativeWindow::Minimized; - } - else if(IsZoomed(handle)) - { - return INativeWindow::Maximized; - } - else - { - return INativeWindow::Restored; - } - } - - void Show() - { - ShowWindow(handle, SW_SHOWNORMAL); - } - - void ShowDeactivated() - { - ShowWindow(handle, SW_SHOWNOACTIVATE); - SetWindowPos(handle,HWND_TOP,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); - } - - void ShowRestored() - { - ShowWindow(handle, SW_RESTORE); - } - - void ShowMaximized() - { - ShowWindow(handle, SW_SHOWMAXIMIZED); - } - - void ShowMinimized() - { - ShowWindow(handle, SW_SHOWMINIMIZED); - } - - void Hide() - { - SendMessage(handle, WM_CLOSE, NULL, NULL); - } - - bool IsVisible() - { - return IsWindowVisible(handle)!=0; - } - - void Enable() - { - EnableWindow(handle, TRUE); - } - - void Disable() - { - EnableWindow(handle, FALSE); - } - - bool IsEnabled() - { - return IsWindowEnabled(handle)!=0; - } - - void SetFocus() - { - ::SetFocus(handle); - } - - bool IsFocused() - { - return GetFocus()==handle; - } - - void SetActivate() - { - SetActiveWindow(handle); - } - - bool IsActivated() - { - return GetActiveWindow()==handle; - } - - void ShowInTaskBar() - { - SetExStyle(WS_EX_APPWINDOW, true); - } - - void HideInTaskBar() - { - SetExStyle(WS_EX_APPWINDOW, false); - } - - bool IsAppearedInTaskBar() - { - return GetExStyle(WS_EX_APPWINDOW); - } - - void EnableActivate() - { - SetExStyle(WS_EX_NOACTIVATE, false); - } - - void DisableActivate() - { - SetExStyle(WS_EX_NOACTIVATE, true); - } - - bool IsEnabledActivate() - { - return !GetExStyle(WS_EX_NOACTIVATE); - } - - bool RequireCapture() - { - SetCapture(handle); - return true; - } - - bool ReleaseCapture() - { - ::ReleaseCapture(); - return true; - } - - bool IsCapturing() - { - return GetCapture()==handle; - } - - bool GetMaximizedBox() - { - return GetStyle(WS_MAXIMIZEBOX); - } - - void SetMaximizedBox(bool visible) - { - SetStyle(WS_MAXIMIZEBOX, visible); - } - - bool GetMinimizedBox() - { - return GetStyle(WS_MINIMIZEBOX); - } - - void SetMinimizedBox(bool visible) - { - SetStyle(WS_MINIMIZEBOX, visible); - } - - bool GetBorder() - { - return GetStyle(WS_BORDER); - } - - void SetBorder(bool visible) - { - SetStyle(WS_BORDER, visible); - } - - bool GetSizeBox() - { - return GetStyle(WS_SIZEBOX); - } - - void SetSizeBox(bool visible) - { - SetStyle(WS_SIZEBOX, visible); - } - - bool GetIconVisible() - { - return GetStyle(WS_SYSMENU); - } - - void SetIconVisible(bool visible) - { - SetStyle(WS_SYSMENU, visible); - } - - bool GetTitleBar() - { - return GetStyle(WS_CAPTION); - } - - void SetTitleBar(bool visible) - { - SetStyle(WS_CAPTION, visible); - } - - bool GetTopMost() - { - return GetExStyle(WS_EX_TOPMOST); - } - - void SetTopMost(bool topmost) - { - SetWindowPos(handle, (topmost ? HWND_TOPMOST : HWND_NOTOPMOST), 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_FRAMECHANGED); - } - - void SupressAlt() - { - if (!supressingAlt) - { - supressingAlt = true; - PostMessage(handle, WM_SYSKEYDOWN, VK_MENU, 0); - PostMessage(handle, WM_SYSKEYUP, VK_MENU, 0); - } - } - - bool InstallListener(INativeWindowListener* listener) - { - if(listeners.Contains(listener)) - { - return false; - } - else - { - listeners.Add(listener); - return true; - } - } - - bool UninstallListener(INativeWindowListener* listener) - { - if(listeners.Contains(listener)) - { - listeners.Remove(listener); - return true; - } - else - { - return false; - } - } - - void RedrawContent() - { - if(graphicsHandler) - { - SendMessage(this->handle, WM_PAINT, NULL, NULL); - } - } - }; - /*********************************************************************** -WindowsController +WindowsDirect2DParagraph (Caret Helper) ***********************************************************************/ - LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - LRESULT CALLBACK GodProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - LRESULT CALLBACK MouseProc(int nCode , WPARAM wParam , LPARAM lParam); - - class WindowsController : public Object, public virtual INativeController, public virtual INativeWindowService - { - protected: - WinClass windowClass; - WinClass godClass; - HINSTANCE hInstance; - HWND godWindow; - Dictionary windows; - INativeWindow* mainWindow; - HWND mainWindowHandle; - - WindowsCallbackService callbackService; - WindowsResourceService resourceService; - WindowsAsyncService asyncService; - WindowsClipboardService clipboardService; - WindowsImageService imageService; - WindowsScreenService screenService; - WindowsInputService inputService; - WindowsDialogService dialogService; - - public: - WindowsController(HINSTANCE _hInstance) - :hInstance(_hInstance) - ,windowClass(L"VczhWindow", false, false, WndProc, _hInstance) - ,godClass(L"GodWindow", false, false, GodProc, _hInstance) - ,mainWindow(0) - ,mainWindowHandle(0) - ,screenService(&GetHWNDFromNativeWindowHandle) - ,inputService(&MouseProc) - ,dialogService(&GetHWNDFromNativeWindowHandle) + void GetLineIndexFromTextPos(vint textPos, vint& frontLineIndex, vint& backLineIndex) { - godWindow=CreateWindowEx(WS_EX_CONTROLPARENT, godClass.GetName().Buffer(), L"GodWindow", WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, NULL, NULL, hInstance, NULL); - clipboardService.SetOwnerHandle(godWindow); - inputService.SetOwnerHandle(godWindow); - } - - ~WindowsController() - { - inputService.StopTimer(); - inputService.StopHookMouse(); - clipboardService.SetOwnerHandle(NULL); - DestroyWindow(godWindow); - } - - WindowsForm* GetWindowsFormFromHandle(HWND hwnd) - { - vint index = windows.Keys().IndexOf(hwnd); - if (index == -1)return 0; - return windows.Values()[index]; - } - - bool HandleMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& result) - { - bool skipDefaultProcedure=false; - vint index=windows.Keys().IndexOf(hwnd); - if(index!=-1) + frontLineIndex=-1; + backLineIndex=-1; + vint start=0; + vint end=lineMetrics.Count()-1; + while(start<=end) { - WindowsForm* window=windows.Values().Get(index); - skipDefaultProcedure=window->HandleMessage(hwnd, uMsg, wParam, lParam, result); - switch(uMsg) + vint middle=(start+end)/2; + DWRITE_LINE_METRICS& metrics=lineMetrics[middle]; + vint lineStart=lineStarts[middle]; + vint lineEnd=lineStart+metrics.length-metrics.newlineLength; + + if(textPosGetWindowHandle(), SW_HIDE); - if(window!=mainWindow) - { - skipDefaultProcedure=true; - } - } - break; - case WM_DESTROY: - DestroyNativeWindow(window); - break; + end=middle-1; + } + else if(textPos>lineEnd) + { + start=middle+1; + } + else if(textPos==lineStart && middle!=0) + { + DWRITE_LINE_METRICS& anotherLine=lineMetrics[middle-1]; + frontLineIndex=anotherLine.newlineLength==0?middle-1:middle; + backLineIndex=middle; + return; + } + else if(textPos==lineEnd && middle!=lineMetrics.Count()-1) + { + frontLineIndex=middle; + backLineIndex=metrics.newlineLength==0?middle+1:middle; + return; + } + else + { + frontLineIndex=middle; + backLineIndex=middle; + return; } } + } - if(hwnd==mainWindowHandle && uMsg==WM_DESTROY) + Pair GetLineYRange(vint lineIndex) + { + DWRITE_LINE_METRICS& line=lineMetrics[lineIndex]; + FLOAT top=lineTops[lineIndex]; + return Pair(top, top+line.height); + } + + vint GetLineIndexFromY(vint y) + { + if(paragraphText.Length()==0) return 0; + FLOAT minY=0; + FLOAT maxY=0; { - for(vint i=0;iIsVisible()) - { - windows.Values().Get(i)->Hide(); - } - } - while(windows.Count()) - { - DestroyNativeWindow(windows.Values().Get(0)); - } - PostQuitMessage(0); + minY=hitTestMetrics[0].top; + DWRITE_HIT_TEST_METRICS& hitTest=hitTestMetrics[hitTestMetrics.Count()-1]; + maxY=hitTest.top+hitTest.height; } - return skipDefaultProcedure; - } - //======================================================================= - - INativeWindow* CreateNativeWindow() - { - WindowsForm* window=new WindowsForm(godWindow, windowClass.GetName(), hInstance); - windows.Add(window->GetWindowHandle(), window); - callbackService.InvokeNativeWindowCreated(window); - window->SetWindowCursor(resourceService.GetDefaultSystemCursor()); - return window; - } - - void DestroyNativeWindow(INativeWindow* window) - { - WindowsForm* windowsForm=dynamic_cast(window); - windowsForm->InvokeDestroying(); - if(windowsForm!=0 && windows.Keys().Contains(windowsForm->GetWindowHandle())) - { - callbackService.InvokeNativeWindowDestroyed(window); - windows.Remove(windowsForm->GetWindowHandle()); - delete windowsForm; - } - } - - INativeWindow* GetMainWindow() - { - return mainWindow; - } - - void Run(INativeWindow* window) - { - mainWindow=window; - mainWindowHandle=GetWindowsForm(window)->GetWindowHandle(); - mainWindow->Show(); - MSG message; - while(GetMessage(&message, NULL, 0, 0)) - { - TranslateMessage(&message); - DispatchMessage(&message); - asyncService.ExecuteAsyncTasks(); - } - } - - INativeWindow* GetWindow(Point location) - { - POINT p; - p.x=(int)location.x; - p.y=(int)location.y; - HWND handle=WindowFromPoint(p); - vint index=windows.Keys().IndexOf(handle); - if(index==-1) + if(y=maxY) + { + return lineMetrics.Count()-1; + } + + vint start=0; + vint end=lineMetrics.Count()-1; + while(start<=end) + { + vint middle=(start+end)/2; + Pair yRange=GetLineYRange(middle); + minY=yRange.key; + maxY=yRange.value; + + if(y=maxY) + { + start=middle+1; + } + else + { + return middle; + } + } + return -1; + } + + vint GetCaretFromXWithLine(vint x, vint lineIndex) + { + DWRITE_LINE_METRICS& line=lineMetrics[lineIndex]; + vint lineStart=lineStarts[lineIndex]; + vint lineEnd=lineStart+line.length-line.newlineLength; + + FLOAT minLineX=0; + FLOAT maxLineX=0; + + for(vint i=lineStart;iminX) minLineX=minX; + if(maxLineX=maxLineX) return lineEnd; + return lineStart; + } + +/*********************************************************************** +WindowsDirect2DParagraph (Caret) +***********************************************************************/ + + vint GetCaret(vint comparingCaret, CaretRelativePosition position, bool& preferFrontSide)override + { + PrepareFormatData(); + if(position==CaretFirst) return 0; + if(position==CaretLast) return paragraphText.Length(); + if(!IsValidCaret(comparingCaret)) return -1; + + vint frontLineIndex=-1; + vint backLineIndex=-1; + GetLineIndexFromTextPos(comparingCaret, frontLineIndex, backLineIndex); + vint lineIndex=preferFrontSide?frontLineIndex:backLineIndex; + DWRITE_LINE_METRICS& line=lineMetrics[lineIndex]; + vint lineStart=lineStarts[lineIndex]; + vint lineEnd=lineStart+line.length-line.newlineLength; + + switch(position) + { + case CaretLineFirst: + return lineStarts[lineIndex]; + case CaretLineLast: + return lineStarts[lineIndex]+line.length-line.newlineLength; + case CaretMoveLeft: + { + if(comparingCaret==0) + { + return 0; + } + else if(comparingCaret==lineStart) + { + vint offset=lineMetrics[lineIndex-1].newlineLength; + if(offset>0) + { + return lineStart-offset; + } + } + return hitTestMetrics[charHitTestMap[comparingCaret-1]].textPosition; + } + case CaretMoveRight: + { + if(comparingCaret==paragraphText.Length()) + { + return paragraphText.Length(); + } + else if(comparingCaret==lineEnd && line.newlineLength!=0) + { + return lineEnd+line.newlineLength; + } + else + { + vint index=charHitTestMap[comparingCaret]; + if(index==hitTestMetrics.Count()-1) return paragraphText.Length(); + return hitTestMetrics[index+1].textPosition; + } + } + case CaretMoveUp: + { + if(lineIndex==0) + { + return comparingCaret; + } + else + { + Rect bounds=GetCaretBounds(comparingCaret, preferFrontSide); + preferFrontSide=true; + return GetCaretFromXWithLine(bounds.x1, lineIndex-1); + } + } + case CaretMoveDown: + { + if(lineIndex==lineMetrics.Count()-1) + { + return comparingCaret; + } + else + { + Rect bounds=GetCaretBounds(comparingCaret, preferFrontSide); + preferFrontSide=false; + return GetCaretFromXWithLine(bounds.x1, lineIndex+1); + } + } + } + return -1; + } + + Rect GetCaretBounds(vint caret, bool frontSide)override + { + PrepareFormatData(); + if(!IsValidCaret(caret)) return Rect(); + if(paragraphText.Length()==0) return Rect(Point(0, 0), Size(0, GetHeight())); + + vint frontLineIndex=-1; + vint backLineIndex=-1; + GetLineIndexFromTextPos(caret, frontLineIndex, backLineIndex); + vint lineIndex=frontSide?frontLineIndex:backLineIndex; + + Pair lineYRange=GetLineYRange(lineIndex); + DWRITE_LINE_METRICS& line=lineMetrics[lineIndex]; + if(line.length-line.newlineLength==0) + { + return Rect(0, (vint)lineYRange.key, 0, (vint)lineYRange.value); + } else { - return windows.Values().Get(index); + vint lineStart=lineStarts[lineIndex]; + vint lineEnd=lineStart+line.length-line.newlineLength; + if(caret==lineStart) + { + frontSide=false; + } + else if(caret==lineEnd) + { + frontSide=true; + } + if(frontSide) + { + caret--; + } + + vint index=charHitTestMap[caret]; + DWRITE_HIT_TEST_METRICS& hitTest=hitTestMetrics[index]; + DWRITE_CLUSTER_METRICS& cluster=clusterMetrics[index]; + if(cluster.isRightToLeft) + { + frontSide=!frontSide; + } + + if(frontSide) + { + return Rect( + Point((vint)(hitTest.left+hitTest.width), (vint)hitTest.top), + Size(0, (vint)hitTest.height) + ); + } + else + { + return Rect( + Point((vint)hitTest.left, (vint)hitTest.top), + Size(0, (vint)hitTest.height) + ); + } } } - //======================================================================= - - INativeCallbackService* CallbackService() + vint GetCaretFromPoint(Point point)override { - return &callbackService; + PrepareFormatData(); + vint lineIndex=GetLineIndexFromY(point.y); + vint caret=GetCaretFromXWithLine(point.x, lineIndex); + return caret; } - INativeResourceService* ResourceService() + Nullable GetInlineObjectFromPoint(Point point, vint& start, vint& length)override { - return &resourceService; + DWRITE_HIT_TEST_METRICS metrics={0}; + BOOL trailingHit=FALSE; + BOOL inside=FALSE; + start=-1; + length=0; + HRESULT hr=textLayout->HitTestPoint((FLOAT)point.x, (FLOAT)point.y, &trailingHit, &inside, &metrics); + if(hr==S_OK) + { + IGuiGraphicsElement* element=0; + if(GetMap(graphicsElements, metrics.textPosition, element) && element) + { + ComPtr inlineObject=inlineElements[element]; + start=inlineObject->GetStart(); + length=inlineObject->GetLength(); + return inlineObject->GetProperties(); + } + } + return Nullable(); } + + vint GetNearestCaretFromTextPos(vint textPos, bool frontSide)override + { + PrepareFormatData(); + if(!IsValidTextPos(textPos)) return -1; + if(textPos==0 || textPos==paragraphText.Length()) return textPos; - INativeAsyncService* AsyncService() - { - return &asyncService; + vint index=charHitTestMap[textPos]; + DWRITE_HIT_TEST_METRICS& hitTest=hitTestMetrics[index]; + if(hitTest.textPosition==textPos) + { + return textPos; + } + else if(frontSide) + { + return hitTest.textPosition; + } + else + { + return hitTest.textPosition+hitTest.length; + } } - INativeClipboardService* ClipboardService() + bool IsValidCaret(vint caret)override { - return &clipboardService; + PrepareFormatData(); + if(!IsValidTextPos(caret)) return false; + if(caret==0 || caret==paragraphText.Length()) return true; + if(hitTestMetrics[charHitTestMap[caret]].textPosition==caret) return true; + + vint frontLineIndex=-1; + vint backLineIndex=-1; + GetLineIndexFromTextPos(caret, frontLineIndex, backLineIndex); + if(frontLineIndex==-1 && backLineIndex==-1) return false; + return false; } - INativeImageService* ImageService() + bool IsValidTextPos(vint textPos) { - return &imageService; - } - - INativeScreenService* ScreenService() - { - return &screenService; - } - - INativeWindowService* WindowService() - { - return this; - } - - INativeInputService* InputService() - { - return &inputService; - } - - INativeDialogService* DialogService() - { - return &dialogService; - } - - bool IsWindowsVersionEqualOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor) - { - OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0 }; - DWORDLONG const dwlConditionMask = - VerSetConditionMask( - VerSetConditionMask( - VerSetConditionMask( - 0, - VER_MAJORVERSION, - VER_GREATER_EQUAL - ), - VER_MINORVERSION, - VER_GREATER_EQUAL - ), - VER_SERVICEPACKMAJOR, - VER_GREATER_EQUAL - ); - - osvi.dwMajorVersion = wMajorVersion; - osvi.dwMinorVersion = wMinorVersion; - osvi.wServicePackMajor = wServicePackMajor; - - return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE; - } - - WString GetExecutablePath() - { - Array buffer(65536); - GetModuleFileName(NULL, &buffer[0], (DWORD)buffer.Count()); - return &buffer[0]; - } - - //======================================================================= - - void InvokeMouseHook(WPARAM message, Point location) - { - callbackService.InvokeMouseHook(message, location); - } - - void InvokeGlobalTimer() - { - callbackService.InvokeGlobalTimer(); - } - - void InvokeClipboardUpdated() - { - callbackService.InvokeClipboardUpdated(); + return 0<=textPos && textPos<=paragraphText.Length(); } }; /*********************************************************************** -Windows Procedure +WindowsDirect2DLayoutProvider ***********************************************************************/ - LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) + Ptr WindowsDirect2DLayoutProvider::CreateParagraph(const WString& text, IGuiGraphicsRenderTarget* renderTarget, elements::IGuiGraphicsParagraphCallback* callback) { - WindowsController* controller=dynamic_cast(GetCurrentController()); - if(controller) - { - LRESULT result=0; - if(controller->HandleMessage(hwnd, uMsg, wParam, lParam, result)) - { - return result; - } - } - return DefWindowProc(hwnd, uMsg, wParam, lParam); - } - - LRESULT CALLBACK GodProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) - { - WindowsController* controller=dynamic_cast(GetCurrentController()); - if(controller) - { - switch(uMsg) - { - case WM_TIMER: - controller->InvokeGlobalTimer(); - break; - case WM_CLIPBOARDUPDATE: - controller->InvokeClipboardUpdated(); - break; - } - } - return DefWindowProc(hwnd, uMsg, wParam, lParam); - } - - LRESULT CALLBACK MouseProc(int nCode , WPARAM wParam , LPARAM lParam) - { - WindowsController* controller=dynamic_cast(GetCurrentController()); - if(controller) - { - MSLLHOOKSTRUCT* mouseHookStruct=(MSLLHOOKSTRUCT*)lParam; - Point location(mouseHookStruct->pt.x, mouseHookStruct->pt.y); - controller->InvokeMouseHook(wParam, location); - } - return CallNextHookEx(NULL,nCode,wParam,lParam); - } - -/*********************************************************************** -Windows Platform Native Controller -***********************************************************************/ - - INativeController* CreateWindowsNativeController(HINSTANCE hInstance) - { - return new WindowsController(hInstance); - } - - IWindowsForm* GetWindowsFormFromHandle(HWND hwnd) - { - auto controller = dynamic_cast(GetCurrentController()); - if (controller) - { - return controller->GetWindowsFormFromHandle(hwnd); - } - return 0; - } - - IWindowsForm* GetWindowsForm(INativeWindow* window) - { - return dynamic_cast(window); - } - - void DestroyWindowsNativeController(INativeController* controller) - { - delete controller; - } - - void EnableCrossKernelCrashing() - { - /* - "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options" - DWORD DisableUserModeCallbackFilter = 1 - - "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\TestCppCodegen.exe" - DWORD DisableUserModeCallbackFilter = 1 - */ - typedef BOOL (WINAPI *tGetPolicy)(LPDWORD lpFlags); - typedef BOOL (WINAPI *tSetPolicy)(DWORD dwFlags); - const DWORD EXCEPTION_SWALLOWING = 0x1; - - HMODULE kernel32 = LoadLibrary(L"kernel32.dll"); - tGetPolicy pGetPolicy = (tGetPolicy)GetProcAddress(kernel32, "GetProcessUserModeExceptionPolicy"); - tSetPolicy pSetPolicy = (tSetPolicy)GetProcAddress(kernel32, "SetProcessUserModeExceptionPolicy"); - if (pGetPolicy && pSetPolicy) - { - DWORD dwFlags; - if (pGetPolicy(&dwFlags)) - { - // Turn off the filter - pSetPolicy(dwFlags & ~EXCEPTION_SWALLOWING); - } - } + return new WindowsDirect2DParagraph(this, text, renderTarget, callback); } } } } /*********************************************************************** -NATIVEWINDOW\WINDOWS\DIRECT2D\WINDIRECT2DAPPLICATION.CPP +.\GRAPHICSELEMENT\WINDOWSDIRECT2D\GUIGRAPHICSRENDERERSWINDOWSDIRECT2D.CPP +***********************************************************************/ +#include + +namespace vl +{ + namespace presentation + { + namespace elements_windows_d2d + { + using namespace collections; + +/*********************************************************************** +IMPLEMENT_BRUSH_ELEMENT_RENDERER +***********************************************************************/ + +#define IMPLEMENT_BRUSH_ELEMENT_RENDERER(TRENDERER)\ + void TRENDERER::InitializeInternal()\ + {\ + }\ + void TRENDERER::FinalizeInternal()\ + {\ + DestroyBrush(renderTarget);\ + }\ + void TRENDERER::RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget)\ + {\ + DestroyBrush(oldRenderTarget);\ + CreateBrush(newRenderTarget);\ + }\ + TRENDERER::TRENDERER()\ + :brush(0)\ + {\ + }\ + void TRENDERER::Render(Rect bounds)\ + +#define IMPLEMENT_BRUSH_ELEMENT_RENDERER_SOLID_COLOR_BRUSH(TRENDERER)\ + void TRENDERER::CreateBrush(IWindowsDirect2DRenderTarget* _renderTarget)\ + {\ + if(_renderTarget)\ + {\ + oldColor=element->GetColor();\ + brush=_renderTarget->CreateDirect2DBrush(oldColor);\ + }\ + }\ + void TRENDERER::DestroyBrush(IWindowsDirect2DRenderTarget* _renderTarget)\ + {\ + if(_renderTarget && brush)\ + {\ + _renderTarget->DestroyDirect2DBrush(oldColor);\ + brush=0;\ + }\ + }\ + void TRENDERER::OnElementStateChanged()\ + {\ + if(renderTarget)\ + {\ + Color color=element->GetColor();\ + if(oldColor!=color)\ + {\ + DestroyBrush(renderTarget);\ + CreateBrush(renderTarget);\ + }\ + }\ + }\ + +#define IMPLEMENT_BRUSH_ELEMENT_RENDERER_LINEAR_GRADIENT_BRUSH(TRENDERER)\ + void TRENDERER::CreateBrush(IWindowsDirect2DRenderTarget* _renderTarget)\ + {\ + if(_renderTarget)\ + {\ + oldColor=Pair(element->GetColor1(), element->GetColor2());\ + brush=_renderTarget->CreateDirect2DLinearBrush(oldColor.key, oldColor.value);\ + }\ + }\ + void TRENDERER::DestroyBrush(IWindowsDirect2DRenderTarget* _renderTarget)\ + {\ + if(_renderTarget && brush)\ + {\ + _renderTarget->DestroyDirect2DLinearBrush(oldColor.key, oldColor.value);\ + brush=0;\ + }\ + }\ + void TRENDERER::OnElementStateChanged()\ + {\ + if(renderTarget)\ + {\ + Pair color=Pair(element->GetColor1(), element->GetColor2());\ + if(oldColor!=color)\ + {\ + DestroyBrush(renderTarget);\ + CreateBrush(renderTarget);\ + }\ + }\ + }\ + +/*********************************************************************** +GuiSolidBorderElementRenderer +***********************************************************************/ + + IMPLEMENT_BRUSH_ELEMENT_RENDERER_SOLID_COLOR_BRUSH(GuiSolidBorderElementRenderer) + IMPLEMENT_BRUSH_ELEMENT_RENDERER(GuiSolidBorderElementRenderer) + { + ID2D1RenderTarget* d2dRenderTarget=renderTarget->GetDirect2DRenderTarget(); + switch(element->GetShape()) + { + case ElementShape::Rectangle: + d2dRenderTarget->DrawRectangle( + D2D1::RectF((FLOAT)bounds.x1+0.5f, (FLOAT)bounds.y1+0.5f, (FLOAT)bounds.x2-0.5f, (FLOAT)bounds.y2-0.5f), + brush + ); + break; + case ElementShape::Ellipse: + d2dRenderTarget->DrawEllipse( + D2D1::Ellipse(D2D1::Point2F((bounds.x1+bounds.x2)/2.0f, (bounds.y1+bounds.y2)/2.0f), bounds.Width()/2.0f, bounds.Height()/2.0f), + brush + ); + break; + } + } + +/*********************************************************************** +GuiRoundBorderElementRenderer +***********************************************************************/ + + IMPLEMENT_BRUSH_ELEMENT_RENDERER_SOLID_COLOR_BRUSH(GuiRoundBorderElementRenderer) + IMPLEMENT_BRUSH_ELEMENT_RENDERER(GuiRoundBorderElementRenderer) + { + ID2D1RenderTarget* d2dRenderTarget=renderTarget->GetDirect2DRenderTarget(); + d2dRenderTarget->DrawRoundedRectangle( + D2D1::RoundedRect( + D2D1::RectF((FLOAT)bounds.x1+0.5f, (FLOAT)bounds.y1+0.5f, (FLOAT)bounds.x2-0.5f, (FLOAT)bounds.y2-0.5f), + (FLOAT)element->GetRadius(), + (FLOAT)element->GetRadius() + ), + brush + ); + } + +/*********************************************************************** +Gui3DBorderElementRenderer +***********************************************************************/ + + void Gui3DBorderElementRenderer::CreateBrush(IWindowsDirect2DRenderTarget* _renderTarget) + { + if(_renderTarget) + { + oldColor1=element->GetColor1(); + oldColor2=element->GetColor2(); + brush1=_renderTarget->CreateDirect2DBrush(oldColor1); + brush2=_renderTarget->CreateDirect2DBrush(oldColor2); + } + } + + void Gui3DBorderElementRenderer::DestroyBrush(IWindowsDirect2DRenderTarget* _renderTarget) + { + if(_renderTarget) + { + if(brush1) + { + _renderTarget->DestroyDirect2DBrush(oldColor1); + brush1=0; + } + if(brush2) + { + _renderTarget->DestroyDirect2DBrush(oldColor2); + brush2=0; + } + } + } + + void Gui3DBorderElementRenderer::InitializeInternal() + { + } + + void Gui3DBorderElementRenderer::FinalizeInternal() + { + DestroyBrush(renderTarget); + } + + void Gui3DBorderElementRenderer::RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget) + { + DestroyBrush(oldRenderTarget); + CreateBrush(newRenderTarget); + } + + Gui3DBorderElementRenderer::Gui3DBorderElementRenderer() + :brush1(0) + ,brush2(0) + { + } + + void Gui3DBorderElementRenderer::Render(Rect bounds) + { + D2D1_RECT_F rect=D2D1::RectF((FLOAT)bounds.x1+0.5f, (FLOAT)bounds.y1+0.5f, (FLOAT)bounds.x2-0.5f, (FLOAT)bounds.y2-0.5f); + ID2D1RenderTarget* d2dRenderTarget=renderTarget->GetDirect2DRenderTarget(); + + d2dRenderTarget->DrawLine(D2D1::Point2F(rect.left, rect.top), D2D1::Point2F(rect.right, rect.top), brush1); + d2dRenderTarget->DrawLine(D2D1::Point2F(rect.left, rect.top), D2D1::Point2F(rect.left, rect.bottom), brush1); + d2dRenderTarget->DrawLine(D2D1::Point2F(rect.right, rect.bottom), D2D1::Point2F(rect.left, rect.bottom), brush2); + d2dRenderTarget->DrawLine(D2D1::Point2F(rect.right, rect.bottom), D2D1::Point2F(rect.right, rect.top), brush2); + } + + void Gui3DBorderElementRenderer::OnElementStateChanged() + { + if(renderTarget) + { + Color color1=element->GetColor1(); + Color color2=element->GetColor2(); + if(oldColor1!=color1 || oldColor2!=color2) + { + DestroyBrush(renderTarget); + CreateBrush(renderTarget); + } + } + } + +/*********************************************************************** +Gui3DSplitterElementRenderer +***********************************************************************/ + + void Gui3DSplitterElementRenderer::CreateBrush(IWindowsDirect2DRenderTarget* _renderTarget) + { + if(_renderTarget) + { + oldColor1=element->GetColor1(); + oldColor2=element->GetColor2(); + brush1=_renderTarget->CreateDirect2DBrush(oldColor1); + brush2=_renderTarget->CreateDirect2DBrush(oldColor2); + } + } + + void Gui3DSplitterElementRenderer::DestroyBrush(IWindowsDirect2DRenderTarget* _renderTarget) + { + if(_renderTarget) + { + if(brush1) + { + _renderTarget->DestroyDirect2DBrush(oldColor1); + brush1=0; + } + if(brush2) + { + _renderTarget->DestroyDirect2DBrush(oldColor2); + brush2=0; + } + } + } + + void Gui3DSplitterElementRenderer::InitializeInternal() + { + } + + void Gui3DSplitterElementRenderer::FinalizeInternal() + { + DestroyBrush(renderTarget); + } + + void Gui3DSplitterElementRenderer::RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget) + { + DestroyBrush(oldRenderTarget); + CreateBrush(newRenderTarget); + } + + Gui3DSplitterElementRenderer::Gui3DSplitterElementRenderer() + :brush1(0) + ,brush2(0) + { + } + + void Gui3DSplitterElementRenderer::Render(Rect bounds) + { + D2D1_POINT_2F p11, p12, p21, p22; + switch(element->GetDirection()) + { + case Gui3DSplitterElement::Horizontal: + { + vint y=bounds.y1+bounds.Height()/2-1; + p11=D2D1::Point2F((FLOAT)bounds.x1, (FLOAT)y+0.5f); + p12=D2D1::Point2F((FLOAT)bounds.x2, (FLOAT)y+0.5f); + p21=D2D1::Point2F((FLOAT)bounds.x1, (FLOAT)y+1.5f); + p22=D2D1::Point2F((FLOAT)bounds.x2, (FLOAT)y+1.5f); + } + break; + case Gui3DSplitterElement::Vertical: + { + vint x=bounds.x1+bounds.Width()/2-1; + p11=D2D1::Point2F((FLOAT)x+0.5f, (FLOAT)bounds.y1-0.0f); + p12=D2D1::Point2F((FLOAT)x+0.5f, (FLOAT)bounds.y2+0.0f); + p21=D2D1::Point2F((FLOAT)x+1.5f, (FLOAT)bounds.y1-0.0f); + p22=D2D1::Point2F((FLOAT)x+1.5f, (FLOAT)bounds.y2+0.0f); + } + break; + } + ID2D1RenderTarget* d2dRenderTarget=renderTarget->GetDirect2DRenderTarget(); + + d2dRenderTarget->DrawLine(p11, p12, brush1); + d2dRenderTarget->DrawLine(p21, p22, brush2); + } + + void Gui3DSplitterElementRenderer::OnElementStateChanged() + { + if(renderTarget) + { + Color color1=element->GetColor1(); + Color color2=element->GetColor2(); + if(oldColor1!=color1 || oldColor2!=color2) + { + DestroyBrush(renderTarget); + CreateBrush(renderTarget); + } + } + } + +/*********************************************************************** +GuiSolidBackgroundElementRenderer +***********************************************************************/ + + IMPLEMENT_BRUSH_ELEMENT_RENDERER_SOLID_COLOR_BRUSH(GuiSolidBackgroundElementRenderer) + IMPLEMENT_BRUSH_ELEMENT_RENDERER(GuiSolidBackgroundElementRenderer) + { + ID2D1RenderTarget* d2dRenderTarget=renderTarget->GetDirect2DRenderTarget(); + switch(element->GetShape()) + { + case ElementShape::Rectangle: + d2dRenderTarget->FillRectangle( + D2D1::RectF((FLOAT)bounds.x1, (FLOAT)bounds.y1, (FLOAT)bounds.x2, (FLOAT)bounds.y2), + brush + ); + break; + case ElementShape::Ellipse: + d2dRenderTarget->FillEllipse( + D2D1::Ellipse(D2D1::Point2F((bounds.x1+bounds.x2)/2.0f, (bounds.y1+bounds.y2)/2.0f), bounds.Width()/2.0f, bounds.Height()/2.0f), + brush + ); + break; + } + } + +/*********************************************************************** +GuiGradientBackgroundElementRenderer +***********************************************************************/ + + IMPLEMENT_BRUSH_ELEMENT_RENDERER_LINEAR_GRADIENT_BRUSH(GuiGradientBackgroundElementRenderer) + IMPLEMENT_BRUSH_ELEMENT_RENDERER(GuiGradientBackgroundElementRenderer) + { + D2D1_POINT_2F points[2]; + switch(element->GetDirection()) + { + case GuiGradientBackgroundElement::Horizontal: + { + points[0].x=(FLOAT)bounds.x1; + points[0].y=(FLOAT)bounds.y1; + points[1].x=(FLOAT)bounds.x2; + points[1].y=(FLOAT)bounds.y1; + } + break; + case GuiGradientBackgroundElement::Vertical: + { + points[0].x=(FLOAT)bounds.x1; + points[0].y=(FLOAT)bounds.y1; + points[1].x=(FLOAT)bounds.x1; + points[1].y=(FLOAT)bounds.y2; + } + break; + case GuiGradientBackgroundElement::Slash: + { + points[0].x=(FLOAT)bounds.x2; + points[0].y=(FLOAT)bounds.y1; + points[1].x=(FLOAT)bounds.x1; + points[1].y=(FLOAT)bounds.y2; + } + break; + case GuiGradientBackgroundElement::Backslash: + { + points[0].x=(FLOAT)bounds.x1; + points[0].y=(FLOAT)bounds.y1; + points[1].x=(FLOAT)bounds.x2; + points[1].y=(FLOAT)bounds.y2; + } + break; + } + + brush->SetStartPoint(points[0]); + brush->SetEndPoint(points[1]); + + ID2D1RenderTarget* d2dRenderTarget=renderTarget->GetDirect2DRenderTarget(); + switch(element->GetShape()) + { + case ElementShape::Rectangle: + d2dRenderTarget->FillRectangle( + D2D1::RectF((FLOAT)bounds.x1, (FLOAT)bounds.y1, (FLOAT)bounds.x2, (FLOAT)bounds.y2), + brush + ); + break; + case ElementShape::Ellipse: + d2dRenderTarget->FillEllipse( + D2D1::Ellipse(D2D1::Point2F((bounds.x1+bounds.x2)/2.0f, (bounds.y1+bounds.y2)/2.0f), bounds.Width()/2.0f, bounds.Height()/2.0f), + brush + ); + break; + } + } + +/*********************************************************************** +GuiSolidLabelElementRenderer +***********************************************************************/ + + void GuiSolidLabelElementRenderer::CreateBrush(IWindowsDirect2DRenderTarget* _renderTarget) + { + if(_renderTarget) + { + oldColor=element->GetColor(); + brush=_renderTarget->CreateDirect2DBrush(oldColor); + } + } + + void GuiSolidLabelElementRenderer::DestroyBrush(IWindowsDirect2DRenderTarget* _renderTarget) + { + if(_renderTarget && brush) + { + _renderTarget->DestroyDirect2DBrush(oldColor); + brush=0; + } + } + + void GuiSolidLabelElementRenderer::CreateTextFormat(IWindowsDirect2DRenderTarget* _renderTarget) + { + if(_renderTarget) + { + IWindowsDirect2DResourceManager* resourceManager=GetWindowsDirect2DResourceManager(); + oldFont=element->GetFont(); + textFormat=resourceManager->CreateDirect2DTextFormat(oldFont); + } + } + + void GuiSolidLabelElementRenderer::DestroyTextFormat(IWindowsDirect2DRenderTarget* _renderTarget) + { + if(_renderTarget && textFormat) + { + IWindowsDirect2DResourceManager* resourceManager=GetWindowsDirect2DResourceManager(); + resourceManager->DestroyDirect2DTextFormat(oldFont); + textFormat=0; + } + } + + void GuiSolidLabelElementRenderer::CreateTextLayout() + { + if(textFormat) + { + HRESULT hr=GetWindowsDirect2DObjectProvider()->GetDirectWriteFactory()->CreateTextLayout( + oldText.Buffer(), + (int)oldText.Length(), + textFormat->textFormat.Obj(), + 0, + 0, + &textLayout); + if(!FAILED(hr)) + { + if(oldFont.underline) + { + DWRITE_TEXT_RANGE textRange; + textRange.startPosition=0; + textRange.length=(int)oldText.Length(); + textLayout->SetUnderline(TRUE, textRange); + } + if(oldFont.strikeline) + { + DWRITE_TEXT_RANGE textRange; + textRange.startPosition=0; + textRange.length=(int)oldText.Length(); + textLayout->SetStrikethrough(TRUE, textRange); + } + } + else + { + textLayout=0; + } + } + } + + void GuiSolidLabelElementRenderer::DestroyTextLayout() + { + if(textLayout) + { + textLayout->Release(); + textLayout=0; + } + } + + void GuiSolidLabelElementRenderer::UpdateMinSize() + { + float maxWidth=0; + DestroyTextLayout(); + bool calculateSizeFromTextLayout=false; + if(renderTarget) + { + if(element->GetWrapLine()) + { + if(element->GetWrapLineHeightCalculation()) + { + CreateTextLayout(); + if(textLayout) + { + maxWidth=textLayout->GetMaxWidth(); + if(oldMaxWidth!=-1) + { + textLayout->SetWordWrapping(DWRITE_WORD_WRAPPING_WRAP); + textLayout->SetMaxWidth((float)oldMaxWidth); + } + calculateSizeFromTextLayout=true; + } + } + } + else + { + CreateTextLayout(); + if(textLayout) + { + maxWidth=textLayout->GetMaxWidth(); + calculateSizeFromTextLayout=true; + } + } + } + if(calculateSizeFromTextLayout) + { + DWRITE_TEXT_METRICS metrics; + HRESULT hr=textLayout->GetMetrics(&metrics); + if(!FAILED(hr)) + { + vint width=0; + if(!element->GetEllipse() && !element->GetWrapLine() && !element->GetMultiline()) + { + width=(vint)ceil(metrics.widthIncludingTrailingWhitespace); + } + minSize=Size(width, (vint)ceil(metrics.height)); + } + textLayout->SetMaxWidth(maxWidth); + } + else + { + minSize=Size(); + } + } + + void GuiSolidLabelElementRenderer::InitializeInternal() + { + } + + void GuiSolidLabelElementRenderer::FinalizeInternal() + { + DestroyTextLayout(); + DestroyBrush(renderTarget); + DestroyTextFormat(renderTarget); + } + + void GuiSolidLabelElementRenderer::RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget) + { + DestroyBrush(oldRenderTarget); + DestroyTextFormat(oldRenderTarget); + CreateBrush(newRenderTarget); + CreateTextFormat(newRenderTarget); + UpdateMinSize(); + } + + GuiSolidLabelElementRenderer::GuiSolidLabelElementRenderer() + :brush(0) + ,textFormat(0) + ,textLayout(0) + ,oldText(L"") + ,oldMaxWidth(-1) + { + } + + void GuiSolidLabelElementRenderer::Render(Rect bounds) + { + if(!textLayout) + { + CreateTextLayout(); + } + + vint x=0; + vint y=0; + switch(element->GetHorizontalAlignment()) + { + case Alignment::Left: + x=bounds.Left(); + break; + case Alignment::Center: + x=bounds.Left()+(bounds.Width()-minSize.x)/2; + break; + case Alignment::Right: + x=bounds.Right()-minSize.x; + break; + } + switch(element->GetVerticalAlignment()) + { + case Alignment::Top: + y=bounds.Top(); + break; + case Alignment::Center: + y=bounds.Top()+(bounds.Height()-minSize.y)/2; + break; + case Alignment::Bottom: + y=bounds.Bottom()-minSize.y; + break; + } + + renderTarget->SetTextAntialias(oldFont.antialias, oldFont.verticalAntialias); + + if(!element->GetEllipse() && !element->GetMultiline() && !element->GetWrapLine()) + { + ID2D1RenderTarget* d2dRenderTarget=renderTarget->GetDirect2DRenderTarget(); + d2dRenderTarget->DrawTextLayout( + D2D1::Point2F((FLOAT)x, (FLOAT)y), + textLayout, + brush, + D2D1_DRAW_TEXT_OPTIONS_NO_SNAP + ); + } + else + { + IDWriteFactory* dwriteFactory=GetWindowsDirect2DObjectProvider()->GetDirectWriteFactory(); + DWRITE_TRIMMING trimming; + IDWriteInlineObject* inlineObject; + textLayout->GetTrimming(&trimming, &inlineObject); + + textLayout->SetWordWrapping(element->GetWrapLine()?DWRITE_WORD_WRAPPING_WRAP:DWRITE_WORD_WRAPPING_NO_WRAP); + if(element->GetEllipse()) + { + textLayout->SetTrimming(&textFormat->trimming, textFormat->ellipseInlineObject.Obj()); + } + switch(element->GetHorizontalAlignment()) + { + case Alignment::Left: + textLayout->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING); + break; + case Alignment::Center: + textLayout->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); + break; + case Alignment::Right: + textLayout->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_TRAILING); + break; + } + if(!element->GetMultiline() && !element->GetWrapLine()) + { + switch(element->GetVerticalAlignment()) + { + case Alignment::Top: + textLayout->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR); + break; + case Alignment::Center: + textLayout->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); + break; + case Alignment::Bottom: + textLayout->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_FAR); + break; + } + } + + Rect textBounds=bounds; + if(element->GetEllipse() && !element->GetMultiline() && !element->GetWrapLine()) + { + textBounds=Rect(Point(textBounds.x1, y), Size(bounds.Width(), minSize.y)); + } + + textLayout->SetMaxWidth((FLOAT)textBounds.Width()); + textLayout->SetMaxHeight((FLOAT)textBounds.Height()); + + ID2D1RenderTarget* d2dRenderTarget=renderTarget->GetDirect2DRenderTarget(); + d2dRenderTarget->DrawTextLayout( + D2D1::Point2F((FLOAT)textBounds.Left(), (FLOAT)textBounds.Top()), + textLayout, + brush, + D2D1_DRAW_TEXT_OPTIONS_NO_SNAP + ); + + textLayout->SetTrimming(&trimming, inlineObject); + if(oldMaxWidth!=textBounds.Width()) + { + oldMaxWidth=textBounds.Width(); + UpdateMinSize(); + } + } + } + + void GuiSolidLabelElementRenderer::OnElementStateChanged() + { + if(renderTarget) + { + Color color=element->GetColor(); + if(oldColor!=color) + { + DestroyBrush(renderTarget); + CreateBrush(renderTarget); + } + + FontProperties font=element->GetFont(); + if(oldFont!=font) + { + DestroyTextFormat(renderTarget); + CreateTextFormat(renderTarget); + } + } + oldText=element->GetText(); + UpdateMinSize(); + } + +/*********************************************************************** +GuiImageFrameElementRenderer +***********************************************************************/ + + void GuiImageFrameElementRenderer::UpdateBitmap(IWindowsDirect2DRenderTarget* renderTarget) + { + if(renderTarget && element->GetImage()) + { + INativeImageFrame* frame=element->GetImage()->GetFrame(element->GetFrameIndex()); + bitmap=renderTarget->GetBitmap(frame, element->GetEnabled()); + + if (element->GetStretch()) + { + minSize=Size(0,0); + } + else + { + minSize=frame->GetSize(); + } + } + else + { + bitmap=0; + minSize=Size(0, 0); + } + } + + void GuiImageFrameElementRenderer::InitializeInternal() + { + } + + void GuiImageFrameElementRenderer::FinalizeInternal() + { + } + + void GuiImageFrameElementRenderer::RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget) + { + UpdateBitmap(newRenderTarget); + } + + GuiImageFrameElementRenderer::GuiImageFrameElementRenderer() + { + } + + void GuiImageFrameElementRenderer::Render(Rect bounds) + { + if(bitmap) + { + ID2D1RenderTarget* d2dRenderTarget=renderTarget->GetDirect2DRenderTarget(); + D2D1_RECT_F source=D2D1::RectF(0, 0, (FLOAT)minSize.x, (FLOAT)minSize.y); + D2D1_RECT_F destination; + if(element->GetStretch()) + { + INativeImageFrame* frame=element->GetImage()->GetFrame(element->GetFrameIndex()); + auto size = frame->GetSize(); + source = D2D1::RectF(0, 0, (FLOAT)size.x, (FLOAT)size.y); + destination=D2D1::RectF((FLOAT)bounds.x1, (FLOAT)bounds.y1, (FLOAT)bounds.x2, (FLOAT)bounds.y2); + } + else + { + vint x=0; + vint y=0; + switch(element->GetHorizontalAlignment()) + { + case Alignment::Left: + x=bounds.Left(); + break; + case Alignment::Center: + x=bounds.Left()+(bounds.Width()-minSize.x)/2; + break; + case Alignment::Right: + x=bounds.Right()-minSize.x; + break; + } + switch(element->GetVerticalAlignment()) + { + case Alignment::Top: + y=bounds.Top(); + break; + case Alignment::Center: + y=bounds.Top()+(bounds.Height()-minSize.y)/2; + break; + case Alignment::Bottom: + y=bounds.Bottom()-minSize.y; + break; + } + destination=D2D1::RectF((FLOAT)x, (FLOAT)y, (FLOAT)(x+minSize.x), (FLOAT)(y+minSize.y)); + } + + ID2D1DeviceContext* d2dDeviceContext = nullptr; + { + HRESULT hr = d2dRenderTarget->QueryInterface(&d2dDeviceContext); + if (!SUCCEEDED(hr)) + { + if (d2dDeviceContext) + { + d2dDeviceContext->Release(); + } + d2dDeviceContext = nullptr; + } + } + + if(element->GetImage()->GetFormat()==INativeImage::Gif && element->GetFrameIndex()>0) + { + vint max = element->GetFrameIndex(); + for (vint i = 0; i <= max; i++) + { + ComPtr frameBitmap=renderTarget->GetBitmap(element->GetImage()->GetFrame(i), element->GetEnabled()); + if (d2dDeviceContext) + { + d2dDeviceContext->DrawBitmap(frameBitmap.Obj(), destination, 1.0f, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC, source); + } + else + { + d2dRenderTarget->DrawBitmap(frameBitmap.Obj(), destination, 1.0f, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, source); + } + } + } + else + { + if (d2dDeviceContext) + { + d2dDeviceContext->DrawBitmap(bitmap.Obj(), destination, 1.0f, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC, source); + } + else + { + d2dRenderTarget->DrawBitmap(bitmap.Obj(), destination, 1.0f, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, source); + } + } + + if (d2dDeviceContext) + { + d2dDeviceContext->Release(); + } + } + } + + void GuiImageFrameElementRenderer::OnElementStateChanged() + { + UpdateBitmap(renderTarget); + } + +/*********************************************************************** +GuiPolygonElementRenderer +***********************************************************************/ + + void GuiPolygonElementRenderer::CreateGeometry() + { + oldPoints.Resize(element->GetPointCount()); + if(oldPoints.Count()>0) + { + memcpy(&oldPoints[0], &element->GetPoint(0), sizeof(Point)*element->GetPointCount()); + } + if(oldPoints.Count()>=3) + { + ID2D1PathGeometry* pg=0; + GetWindowsDirect2DObjectProvider()->GetDirect2DFactory()->CreatePathGeometry(&pg); + if(pg) + { + geometry=pg; + FillGeometry(Point(0, 0)); + } + } + } + + void GuiPolygonElementRenderer::DestroyGeometry() + { + if(geometry) + { + geometry=0; + } + } + + void GuiPolygonElementRenderer::FillGeometry(Point offset) + { + if(geometry) + { + ID2D1GeometrySink* pgs=0; + geometry->Open(&pgs); + if(pgs) + { + D2D1_POINT_2F p; + p.x=(FLOAT)(oldPoints[0].x+offset.x)+0.5f; + p.y=(FLOAT)(oldPoints[0].y+offset.y)+0.5f; + pgs->BeginFigure(p, D2D1_FIGURE_BEGIN_FILLED); + for(vint i=1;iAddLine(p); + } + pgs->EndFigure(D2D1_FIGURE_END_CLOSED); + pgs->Close(); + pgs->Release(); + } + } + } + + void GuiPolygonElementRenderer::RecreateResource(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget) + { + if(oldRenderTarget==newRenderTarget) + { + if(oldRenderTarget) + { + if(oldBorderColor!=element->GetBorderColor()) + { + oldRenderTarget->DestroyDirect2DBrush(oldBorderColor); + oldBorderColor=element->GetBorderColor(); + borderBrush=newRenderTarget->CreateDirect2DBrush(oldBorderColor); + } + if(oldBackgroundColor!=element->GetBackgroundColor()) + { + oldRenderTarget->DestroyDirect2DBrush(oldBackgroundColor); + oldBackgroundColor=element->GetBackgroundColor(); + backgroundBrush=newRenderTarget->CreateDirect2DBrush(oldBackgroundColor); + } + } + } + else + { + if(oldRenderTarget) + { + oldRenderTarget->DestroyDirect2DBrush(oldBorderColor); + oldRenderTarget->DestroyDirect2DBrush(oldBackgroundColor); + } + if(newRenderTarget) + { + oldBorderColor=element->GetBorderColor(); + oldBackgroundColor=element->GetBackgroundColor(); + borderBrush=newRenderTarget->CreateDirect2DBrush(oldBorderColor); + backgroundBrush=newRenderTarget->CreateDirect2DBrush(oldBackgroundColor); + } + } + } + + void GuiPolygonElementRenderer::InitializeInternal() + { + oldBorderColor=element->GetBorderColor(); + oldBackgroundColor=element->GetBackgroundColor(); + RecreateResource(0, renderTarget); + CreateGeometry(); + } + + void GuiPolygonElementRenderer::FinalizeInternal() + { + DestroyGeometry(); + RecreateResource(renderTarget, 0); + } + + void GuiPolygonElementRenderer::RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget) + { + RecreateResource(oldRenderTarget, newRenderTarget); + } + + GuiPolygonElementRenderer::GuiPolygonElementRenderer() + :borderBrush(0) + ,backgroundBrush(0) + ,geometry(0) + { + } + + void GuiPolygonElementRenderer::Render(Rect bounds) + { + if(renderTarget && geometry) + { + ID2D1RenderTarget* d2dRenderTarget=renderTarget->GetDirect2DRenderTarget(); + vint offsetX=(bounds.Width()-minSize.x)/2+bounds.x1; + vint offsetY=(bounds.Height()-minSize.y)/2+bounds.y1; + + D2D1_MATRIX_3X2_F oldT, newT; + d2dRenderTarget->GetTransform(&oldT); + newT=D2D1::Matrix3x2F::Translation((FLOAT)offsetX, (FLOAT)offsetY); + d2dRenderTarget->SetTransform(&newT); + + d2dRenderTarget->FillGeometry(geometry.Obj(), backgroundBrush); + d2dRenderTarget->DrawGeometry(geometry.Obj(), borderBrush); + d2dRenderTarget->SetTransform(&oldT); + } + } + + void GuiPolygonElementRenderer::OnElementStateChanged() + { + minSize=element->GetSize(); + RecreateResource(renderTarget, renderTarget); + + bool polygonModified=false; + if(oldPoints.Count()!=element->GetPointCount()) + { + polygonModified=true; + } + else + { + for(vint i=0;iGetPoint(i)) + { + polygonModified=true; + break; + } + } + } + if(polygonModified) + { + DestroyGeometry(); + CreateGeometry(); + } + } + +/*********************************************************************** +GuiColorizedTextElementRenderer +***********************************************************************/ + + void GuiColorizedTextElementRenderer::CreateTextBrush(IWindowsDirect2DRenderTarget* _renderTarget) + { + if(_renderTarget) + { + colors.Resize(element->GetColors().Count()); + for(vint i=0;iGetColors().Get(i); + ColorEntryResource newEntry; + + newEntry.normal.text=entry.normal.text; + newEntry.normal.textBrush=_renderTarget->CreateDirect2DBrush(newEntry.normal.text); + newEntry.normal.background=entry.normal.background; + newEntry.normal.backgroundBrush=_renderTarget->CreateDirect2DBrush(newEntry.normal.background); + newEntry.selectedFocused.text=entry.selectedFocused.text; + newEntry.selectedFocused.textBrush=_renderTarget->CreateDirect2DBrush(newEntry.selectedFocused.text); + newEntry.selectedFocused.background=entry.selectedFocused.background; + newEntry.selectedFocused.backgroundBrush=_renderTarget->CreateDirect2DBrush(newEntry.selectedFocused.background); + newEntry.selectedUnfocused.text=entry.selectedUnfocused.text; + newEntry.selectedUnfocused.textBrush=_renderTarget->CreateDirect2DBrush(newEntry.selectedUnfocused.text); + newEntry.selectedUnfocused.background=entry.selectedUnfocused.background; + newEntry.selectedUnfocused.backgroundBrush=_renderTarget->CreateDirect2DBrush(newEntry.selectedUnfocused.background); + colors[i]=newEntry; + } + } + } + + void GuiColorizedTextElementRenderer::DestroyTextBrush(IWindowsDirect2DRenderTarget* _renderTarget) + { + if(_renderTarget) + { + for(vint i=0;iDestroyDirect2DBrush(colors[i].normal.text); + _renderTarget->DestroyDirect2DBrush(colors[i].normal.background); + _renderTarget->DestroyDirect2DBrush(colors[i].selectedFocused.text); + _renderTarget->DestroyDirect2DBrush(colors[i].selectedFocused.background); + _renderTarget->DestroyDirect2DBrush(colors[i].selectedUnfocused.text); + _renderTarget->DestroyDirect2DBrush(colors[i].selectedUnfocused.background); + } + colors.Resize(0); + } + } + + void GuiColorizedTextElementRenderer::CreateCaretBrush(IWindowsDirect2DRenderTarget* _renderTarget) + { + if(_renderTarget) + { + oldCaretColor=element->GetCaretColor(); + caretBrush=_renderTarget->CreateDirect2DBrush(oldCaretColor); + } + } + + void GuiColorizedTextElementRenderer::DestroyCaretBrush(IWindowsDirect2DRenderTarget* _renderTarget) + { + if(_renderTarget) + { + if(caretBrush) + { + _renderTarget->DestroyDirect2DBrush(oldCaretColor); + caretBrush=0; + } + } + } + + void GuiColorizedTextElementRenderer::ColorChanged() + { + DestroyTextBrush(renderTarget); + CreateTextBrush(renderTarget); + } + + void GuiColorizedTextElementRenderer::FontChanged() + { + IWindowsDirect2DResourceManager* resourceManager=GetWindowsDirect2DResourceManager(); + if(textFormat) + { + resourceManager->DestroyDirect2DTextFormat(oldFont); + resourceManager->DestroyDirect2DCharMeasurer(oldFont); + } + oldFont=element->GetFont(); + textFormat=resourceManager->CreateDirect2DTextFormat(oldFont); + element->GetLines().SetCharMeasurer(resourceManager->CreateDirect2DCharMeasurer(oldFont).Obj()); + } + + text::CharMeasurer* GuiColorizedTextElementRenderer::GetCharMeasurer() + { + return 0; + } + + void GuiColorizedTextElementRenderer::InitializeInternal() + { + textFormat=0; + caretBrush=0; + element->SetCallback(this); + } + + void GuiColorizedTextElementRenderer::FinalizeInternal() + { + DestroyTextBrush(renderTarget); + DestroyCaretBrush(renderTarget); + + IWindowsDirect2DResourceManager* resourceManager=GetWindowsDirect2DResourceManager(); + if(textFormat) + { + resourceManager->DestroyDirect2DTextFormat(oldFont); + resourceManager->DestroyDirect2DCharMeasurer(oldFont); + } + } + + void GuiColorizedTextElementRenderer::RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget) + { + DestroyTextBrush(oldRenderTarget); + DestroyCaretBrush(oldRenderTarget); + CreateTextBrush(newRenderTarget); + CreateCaretBrush(newRenderTarget); + element->GetLines().SetRenderTarget(newRenderTarget); + } + + void GuiColorizedTextElementRenderer::Render(Rect bounds) + { + if(renderTarget) + { + ID2D1RenderTarget* d2dRenderTarget=renderTarget->GetDirect2DRenderTarget(); + wchar_t passwordChar=element->GetPasswordChar(); + Point viewPosition=element->GetViewPosition(); + Rect viewBounds(viewPosition, bounds.GetSize()); + vint startRow=element->GetLines().GetTextPosFromPoint(Point(viewBounds.x1, viewBounds.y1)).row; + vint endRow=element->GetLines().GetTextPosFromPoint(Point(viewBounds.x2, viewBounds.y2)).row; + TextPos selectionBegin=element->GetCaretBegin()GetCaretEnd()?element->GetCaretBegin():element->GetCaretEnd(); + TextPos selectionEnd=element->GetCaretBegin()>element->GetCaretEnd()?element->GetCaretBegin():element->GetCaretEnd(); + bool focused=element->GetFocused(); + + renderTarget->SetTextAntialias(oldFont.antialias, oldFont.verticalAntialias); + + for(vint row=startRow;row<=endRow;row++) + { + Rect startRect=element->GetLines().GetRectFromTextPos(TextPos(row, 0)); + Point startPoint=startRect.LeftTop(); + vint startColumn=element->GetLines().GetTextPosFromPoint(Point(viewBounds.x1, startPoint.y)).column; + vint endColumn=element->GetLines().GetTextPosFromPoint(Point(viewBounds.x2, startPoint.y)).column; + text::TextLine& line=element->GetLines().GetLine(row); + + vint x=startColumn==0?0:line.att[startColumn-1].rightOffset; + for(vint column=startColumn; column<=endColumn; column++) + { + bool inSelection=false; + if(selectionBegin.row==selectionEnd.row) + { + inSelection=(row==selectionBegin.row && selectionBegin.column<=column && column=colors.Count()) + { + colorIndex=0; + } + ColorItemResource& color= + !inSelection?colors[colorIndex].normal: + focused?colors[colorIndex].selectedFocused: + colors[colorIndex].selectedUnfocused; + vint x2=crlf?x+startRect.Height()/2:line.att[column].rightOffset; + vint tx=x-viewPosition.x+bounds.x1; + vint ty=startPoint.y-viewPosition.y+bounds.y1; + + if(color.background.a>0) + { + d2dRenderTarget->FillRectangle(D2D1::RectF((FLOAT)tx, (FLOAT)ty, (FLOAT)(tx+(x2-x)), (FLOAT)(ty+startRect.Height())), color.backgroundBrush); + } + if(!crlf) + { + d2dRenderTarget->DrawText( + (passwordChar?&passwordChar:&line.text[column]), + 1, + textFormat->textFormat.Obj(), + D2D1::RectF((FLOAT)tx, (FLOAT)ty, (FLOAT)tx+1, (FLOAT)ty+1), + color.textBrush, + D2D1_DRAW_TEXT_OPTIONS_NO_SNAP, + DWRITE_MEASURING_MODE_GDI_NATURAL + ); + } + x=x2; + } + } + + if(element->GetCaretVisible() && element->GetLines().IsAvailable(element->GetCaretEnd())) + { + Point caretPoint=element->GetLines().GetPointFromTextPos(element->GetCaretEnd()); + vint height=element->GetLines().GetRowHeight(); + Point p1(caretPoint.x-viewPosition.x+bounds.x1, caretPoint.y-viewPosition.y+bounds.y1+1); + Point p2(caretPoint.x-viewPosition.x+bounds.x1, caretPoint.y+height-viewPosition.y+bounds.y1-1); + d2dRenderTarget->DrawLine( + D2D1::Point2F((FLOAT)p1.x+0.5f, (FLOAT)p1.y), + D2D1::Point2F((FLOAT)p2.x+0.5f, (FLOAT)p2.y), + caretBrush + ); + d2dRenderTarget->DrawLine( + D2D1::Point2F((FLOAT)p1.x-0.5f, (FLOAT)p1.y), + D2D1::Point2F((FLOAT)p2.x-0.5f, (FLOAT)p2.y), + caretBrush + ); + } + } + } + + void GuiColorizedTextElementRenderer::OnElementStateChanged() + { + if(renderTarget) + { + Color caretColor=element->GetCaretColor(); + if(oldCaretColor!=caretColor) + { + DestroyCaretBrush(renderTarget); + CreateCaretBrush(renderTarget); + } + } + } + +/*********************************************************************** +GuiDirect2DElementRenderer +***********************************************************************/ + + void GuiDirect2DElementRenderer::InitializeInternal() + { + } + + void GuiDirect2DElementRenderer::FinalizeInternal() + { + } + + void GuiDirect2DElementRenderer::RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget) + { + IDWriteFactory* fdw=GetWindowsDirect2DObjectProvider()->GetDirectWriteFactory(); + ID2D1Factory* fd2d=GetWindowsDirect2DObjectProvider()->GetDirect2DFactory(); + if(oldRenderTarget) + { + GuiDirect2DElementEventArgs arguments(element, oldRenderTarget->GetDirect2DRenderTarget(), fdw, fd2d, Rect()); + element->BeforeRenderTargetChanged.Execute(arguments); + } + if(newRenderTarget) + { + GuiDirect2DElementEventArgs arguments(element, newRenderTarget->GetDirect2DRenderTarget(), fdw, fd2d, Rect()); + element->AfterRenderTargetChanged.Execute(arguments); + } + } + + GuiDirect2DElementRenderer::GuiDirect2DElementRenderer() + { + } + + GuiDirect2DElementRenderer::~GuiDirect2DElementRenderer() + { + } + + void GuiDirect2DElementRenderer::Render(Rect bounds) + { + if(renderTarget) + { + IDWriteFactory* fdw=GetWindowsDirect2DObjectProvider()->GetDirectWriteFactory(); + ID2D1Factory* fd2d=GetWindowsDirect2DObjectProvider()->GetDirect2DFactory(); + renderTarget->PushClipper(bounds); + if(!renderTarget->IsClipperCoverWholeTarget()) + { + ID2D1RenderTarget* rt=renderTarget->GetDirect2DRenderTarget(); + GuiDirect2DElementEventArgs arguments(element, rt, fdw, fd2d, bounds); + element->Rendering.Execute(arguments); + } + renderTarget->PopClipper(); + } + } + + void GuiDirect2DElementRenderer::OnElementStateChanged() + { + } + } + } +} + +/*********************************************************************** +.\NATIVEWINDOW\WINDOWS\DIRECT2D\WINDIRECT2DAPPLICATION.CPP ***********************************************************************/ #pragma comment(lib, "d2d1.lib") #pragma comment(lib, "dwrite.lib") @@ -2277,2841 +3147,7 @@ int SetupWindowsDirect2DRenderer() } /*********************************************************************** -NATIVEWINDOW\WINDOWS\GDI\WINGDI.CPP -***********************************************************************/ -#include - -#pragma comment(lib, "Msimg32.lib") - -namespace vl -{ - namespace presentation - { - namespace windows - { - -/********************************************************************************************************* -WinRegion -*********************************************************************************************************/ - - bool IsEqual(WinRegion::Ptr Region1, WinRegion::Ptr Region2) - { - return EqualRgn(Region1->GetHandle(), Region2->GetHandle())!=0; - } - - WinRegion::WinRegion(vint Left, vint Top, vint Right, vint Bottom, bool Rectangle) - { - if(Rectangle) - { - FHandle=CreateRectRgn((int)Left, (int)Top, (int)Right, (int)Bottom); - } - else - { - FHandle=CreateEllipticRgn((int)Left, (int)Top, (int)Right, (int)Bottom); - } - } - - WinRegion::WinRegion(RECT Rect, bool Rectangle) - { - if(Rectangle) - { - FHandle=CreateRectRgnIndirect(&Rect); - } - else - { - FHandle=CreateEllipticRgnIndirect(&Rect); - } - } - - WinRegion::WinRegion(vint Left, vint Top, vint Right, vint Bottom, vint EllipseWidth, vint EllipseHeight) - { - FHandle=CreateRoundRectRgn((int)Left, (int)Top, (int)Right, (int)Bottom, (int)EllipseWidth, (int)EllipseHeight); - } - - WinRegion::WinRegion(POINT* Points, vint Count, bool Alternate) - { - FHandle=CreatePolygonRgn(Points, (int)Count, Alternate?ALTERNATE:WINDING); - } - - WinRegion::WinRegion(WinRegion::Ptr Region) - { - FHandle=CreateRectRgn(0, 0, 1, 1); - CombineRgn(FHandle, Region->GetHandle(), Region->GetHandle(), RGN_COPY); - } - - WinRegion::WinRegion(WinRegion::Ptr Region1, WinRegion::Ptr Region2, vint CombineMode) - { - FHandle=CreateRectRgn(0, 0, 1, 1); - CombineRgn(FHandle, Region1->GetHandle(), Region2->GetHandle(), (int)CombineMode); - } - - WinRegion::WinRegion(HRGN RegionHandle) - { - FHandle=RegionHandle; - } - - WinRegion::~WinRegion() - { - DeleteObject(FHandle); - } - - HRGN WinRegion::GetHandle() - { - return FHandle; - } - - bool WinRegion::ContainPoint(POINT Point) - { - return PtInRegion(FHandle, Point.x, Point.y)!=0; - } - - bool WinRegion::ContainRect(RECT Rect) - { - return RectInRegion(FHandle, &Rect)!=0; - } - - RECT WinRegion::GetBoundRect() - { - RECT Rect={0, 0, 0, 0}; - GetRgnBox(FHandle, &Rect); - return Rect; - } - - void WinRegion::Move(vint OffsetX, vint OffsetY) - { - OffsetRgn(FHandle, (int)OffsetX, (int)OffsetY); - } - -/********************************************************************************************************* -WinTransform -*********************************************************************************************************/ - - WinTransform::WinTransform(XFORM Transform) - { - FTransform=Transform; - } - - WinTransform::WinTransform(const WinTransform& Transform) - { - FTransform=Transform.FTransform; - } - - WinTransform& WinTransform::operator=(const WinTransform& Transform) - { - FTransform=Transform.FTransform; - return *this; - } - - WinTransform WinTransform::operator*(const WinTransform& Transform) - { - XFORM Result; - CombineTransform(&Result, GetHandle(), Transform.GetHandle()); - return Result; - } - - const XFORM* WinTransform::GetHandle()const - { - return &FTransform; - } - - /*------------------------------------------------------------------------------*/ - - WinTransform WinTransform::Translate(float OffsetX, float OffsetY) - { - XFORM Transform; - Transform.eM11=1.0f; - Transform.eM12=0.0f; - Transform.eM21=0.0f; - Transform.eM22=1.0f; - Transform.eDx=OffsetX; - Transform.eDy=OffsetY; - return Transform; - } - - WinTransform WinTransform::Scale(float ScaleX, float ScaleY) - { - XFORM Transform; - Transform.eM11=ScaleX; - Transform.eM12=0.0f; - Transform.eM21=0.0f; - Transform.eM22=ScaleY; - Transform.eDx=0.0f; - Transform.eDy=0.0f; - return Transform; - } - - WinTransform WinTransform::Rotate(float Angle) - { - XFORM Transform; - Transform.eM11=(FLOAT)cos(Angle); - Transform.eM12= (FLOAT)sin(Angle); - Transform.eM21= (FLOAT)-sin(Angle); - Transform.eM22= (FLOAT)cos(Angle); - Transform.eDx=0.0f; - Transform.eDy=0.0f; - return Transform; - } - - WinTransform WinTransform::Rotate(float Cos, float Sin) - { - XFORM Transform; - Transform.eM11=Cos; - Transform.eM12=Sin; - Transform.eM21=-Sin; - Transform.eM22=Cos; - Transform.eDx=0.0f; - Transform.eDy=0.0f; - return Transform; - } - - WinTransform WinTransform::ReflectX() - { - XFORM Transform; - Transform.eM11=1.0f; - Transform.eM12=0.0f; - Transform.eM21=0.0f; - Transform.eM22=-1.0f; - Transform.eDx=0.0f; - Transform.eDy=0.0f; - return Transform; - } - - WinTransform WinTransform::ReflectY() - { - XFORM Transform; - Transform.eM11=-1.0f; - Transform.eM12=0.0f; - Transform.eM21=0.0f; - Transform.eM22=1.0f; - Transform.eDx=0.0f; - Transform.eDy=0.0f; - return Transform; - } - - WinTransform WinTransform::Reflect(float VectorX, float VectorY) - { - float Len= (FLOAT)sqrt(VectorX*VectorX+VectorY*VectorY); - float Cos=VectorX/Len; - float Sin=VectorY/Len; - - return Rotate(Cos, -Sin)*ReflectX()*Rotate(Cos, Sin); - } - - WinTransform WinTransform::Reflect(float OriginX, float OriginY, float VectorX, float VectorY) - { - float Len= (FLOAT)sqrt(VectorX*VectorX+VectorY*VectorY); - float Cos=VectorX/Len; - float Sin=VectorY/Len; - - return Translate(-OriginX, -OriginY)*Rotate(Cos, -Sin)*ReflectX()*Rotate(Cos, Sin)*Translate(OriginX, OriginY); - } - - WinTransform WinTransform::AxisV(float Xx, float Xy, float Yx, float Yy) - { - XFORM Transform; - Transform.eM11=Xx; - Transform.eM12=Xy; - Transform.eM21=Yx; - Transform.eM22=Yy; - Transform.eDx=0.0f; - Transform.eDy=0.0f; - return Transform; - } - - WinTransform WinTransform::AxisA(float AngleX, float LenX, float AngleY, float LenY) - { - XFORM Transform; - Transform.eM11=(FLOAT)cos(AngleX)*LenX; - Transform.eM12=(FLOAT)sin(AngleX)*LenX; - Transform.eM21=(FLOAT)cos(AngleY)*LenY; - Transform.eM22=(FLOAT)sin(AngleY)*LenY; - Transform.eDx=0.0f; - Transform.eDy=0.0f; - return Transform; - } - -/********************************************************************************************************* -WinMetaFileBuilder -*********************************************************************************************************/ - - void WinMetaFileBuilder::Create(vint Width, vint Height) - { - HDC hdcRef=GetDC(NULL); - vint iWidthMM = GetDeviceCaps(hdcRef, HORZSIZE); - vint iHeightMM = GetDeviceCaps(hdcRef, VERTSIZE); - vint iWidthPels = GetDeviceCaps(hdcRef, HORZRES); - vint iHeightPels = GetDeviceCaps(hdcRef, VERTRES); - ReleaseDC(NULL, hdcRef); - - RECT Rect; - Rect.left=0; - Rect.top=0; - Rect.right = (int)((Width*iWidthMM*100)/iWidthPels); - Rect.bottom = (int)((Height*iHeightMM*100)/iHeightPels); - - HDC Handle=CreateEnhMetaFile(NULL, NULL, &Rect, L"VczhLibrary++GDI\0Enhanced Meta File\0"); - FDC->Initialize(Handle); - - FWidth=Width; - FHeight=Height; - } - - void WinMetaFileBuilder::Draw(HENHMETAFILE Handle) - { - RECT Rect; - Rect.left=0; - Rect.top=0; - Rect.right=(int)FWidth; - Rect.bottom=(int)FHeight; - PlayEnhMetaFile(FDC->GetHandle(), Handle, &Rect); - } - - void WinMetaFileBuilder::Destroy() - { - DeleteEnhMetaFile(CloseEnhMetaFile(FDC->GetHandle())); - } - - WinMetaFileBuilder::WinMetaFileBuilder(vint Width, vint Height) - { - FDC=new WinProxyDC(); - Create(Width, Height); - } - - WinMetaFileBuilder::~WinMetaFileBuilder() - { - Destroy(); - delete FDC; - } - - void WinMetaFileBuilder::LoadFrom(WinMetaFile* File) - { - Destroy(); - Create(File->GetWidth(), File->GetHeight()); - Draw(File->GetHandle()); - } - - void WinMetaFileBuilder::SaveTo(WinMetaFile* File) - { - HENHMETAFILE Handle=CloseEnhMetaFile(FDC->GetHandle()); - if(File->FHandle) - { - DeleteEnhMetaFile(File->FHandle); - } - File->FHandle=Handle; - File->FWidth=FWidth; - File->FHeight=FHeight; - Create(FWidth, FHeight); - Draw(Handle); - } - - void WinMetaFileBuilder::LoadFrom(WString FileName) - { - WinMetaFile File(FileName); - Destroy(); - Create(File.GetWidth(), File.GetHeight()); - Draw(File.GetHandle()); - } - - void WinMetaFileBuilder::SaveTo(WString FileName) - { - HENHMETAFILE Handle=CloseEnhMetaFile(FDC->GetHandle()); - HENHMETAFILE NewHandle=CopyEnhMetaFile(Handle, FileName.Buffer()); - DeleteEnhMetaFile(NewHandle); - Create(FWidth, FHeight); - Draw(Handle); - DeleteEnhMetaFile(Handle); - } - - WinDC* WinMetaFileBuilder::GetWinDC() - { - return FDC; - } - - vint WinMetaFileBuilder::GetWidth() - { - return FWidth; - } - - vint WinMetaFileBuilder::GetHeight() - { - return FHeight; - } - -/********************************************************************************************************* -WinMetaFile -*********************************************************************************************************/ - - WinMetaFile::WinMetaFile(WString FileName) - { - FHandle=GetEnhMetaFile(FileName.Buffer()); - ENHMETAHEADER Header; - GetEnhMetaFileHeader(FHandle, sizeof(Header), &Header); - FWidth=(Header.rclFrame.right-Header.rclFrame.left)*Header.szlDevice.cx/(Header.szlMillimeters.cx*100); - FHeight=(Header.rclFrame.bottom-Header.rclFrame.top)*Header.szlDevice.cy/(Header.szlMillimeters.cy*100); - } - - WinMetaFile::WinMetaFile(WinMetaFileBuilder* Builder) - { - FHandle=NULL; - Builder->SaveTo(this); - } - - WinMetaFile::~WinMetaFile() - { - DeleteEnhMetaFile(FHandle); - } - - HENHMETAFILE WinMetaFile::GetHandle() - { - return FHandle; - } - - vint WinMetaFile::GetWidth() - { - return FWidth; - } - - vint WinMetaFile::GetHeight() - { - return FHeight; - } - -/********************************************************************************************************* -WinBitmap -*********************************************************************************************************/ - - vint WinBitmap::GetBitsFromBB(BitmapBits BB) - { - switch(BB) - { - case vbb32Bits: - return 32; - case vbb24Bits: - return 24; - default: - return 1; - } - } - - vint WinBitmap::GetLineBytes(vint Width, BitmapBits BB) - { - vint Bits=GetBitsFromBB(BB); - vint LineBits=Width*Bits; - vint AlignBits=sizeof(DWORD)*8; - LineBits+=(AlignBits-LineBits%AlignBits)%AlignBits; - return LineBits/8; - } - - void WinBitmap::FillBitmapInfoHeader(vint Width, vint Height, BitmapBits Bits, BITMAPINFOHEADER* Header) - { - Header->biSize=sizeof(BITMAPINFOHEADER); - Header->biWidth=(int)Width; - Header->biHeight=-(int)Height; - Header->biPlanes=1; - Header->biBitCount=(int)GetBitsFromBB(Bits); - Header->biCompression=BI_RGB; - Header->biSizeImage=0; - Header->biXPelsPerMeter=0; - Header->biYPelsPerMeter=0; - Header->biClrUsed=(Bits==vbb2Bits?2:0); - Header->biClrImportant=0; - } - - HBITMAP WinBitmap::CreateDDB(vint Width, vint Height, BitmapBits Bits) - { - if(Bits==vbb2Bits) - { - return CreateBitmap((int)Width, (int)Height, 2, (int)GetBitsFromBB(Bits), NULL); - } - else - { - WinBitmap Bitmap(1, 1, Bits, true); - return CreateCompatibleBitmap(Bitmap.GetWinDC()->GetHandle(), (int)Width, (int)Height); - } - } - - HBITMAP WinBitmap::CreateDIB(vint Width, vint Height, BitmapBits Bits, BYTE**& ScanLines) - { - BITMAPINFO* Info=(BITMAPINFO*)malloc(sizeof(BITMAPINFOHEADER)+2*sizeof(RGBQUAD)); - FillBitmapInfoHeader(Width, Height, Bits, &Info->bmiHeader); - Info->bmiColors[0].rgbBlue=0; - Info->bmiColors[0].rgbGreen=0; - Info->bmiColors[0].rgbRed=0; - Info->bmiColors[0].rgbReserved=0; - Info->bmiColors[1].rgbBlue=255; - Info->bmiColors[1].rgbGreen=255; - Info->bmiColors[1].rgbRed=255; - Info->bmiColors[1].rgbReserved=255; - - BYTE* FirstLine=0; - HBITMAP Handle=CreateDIBSection(FDC->GetHandle(), Info, DIB_RGB_COLORS, (void**)&FirstLine, NULL, 0); - ScanLines=new BYTE*[Height]; - vint LineBytes=GetLineBytes(Width, Bits); - for(vint i=0;iGetHandle(), FHandle); - if(Object) - { - DeleteObject(Object); - } - } - - WinBitmap::WinBitmap(vint Width, vint Height, BitmapBits Bits, bool DIBSections) - { - Constructor(Width, Height, Bits, DIBSections); - } - - WinBitmap::WinBitmap(WString FileName, bool Use32Bits, bool DIBSections) - { - FBits=Use32Bits?vbb32Bits:vbb24Bits; - - HBITMAP TempBmp=(HBITMAP)LoadImage(NULL, FileName.Buffer(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); - HDC TempDC=CreateCompatibleDC(NULL); - BITMAP TempRec; - - GetObject(TempBmp, sizeof(BITMAP), &TempRec); - DeleteObject(SelectObject(TempDC, TempBmp)); - - Constructor(TempRec.bmWidth, TempRec.bmHeight, FBits, DIBSections); - BitBlt(FDC->GetHandle(), 0, 0, TempRec.bmWidth, TempRec.bmHeight, TempDC, 0, 0, SRCCOPY); - - DeleteObject(TempDC); - DeleteObject(TempBmp); - } - - WinBitmap::~WinBitmap() - { - if(FScanLines) - { - delete[] FScanLines; - } - if(FHandle) - { - DeleteObject(FHandle); - } - delete FDC; - } - - void WinBitmap::SaveToFile(WString FileName) - { - if(FScanLines) - { - BITMAPFILEHEADER Header1; - BITMAPV5HEADER Header2; - { - Header1.bfType='M'*256+'B'; - Header1.bfSize=(int)(sizeof(Header1)+sizeof(Header2)+GetLineBytes()*FHeight); - Header1.bfReserved1=0; - Header1.bfReserved2=0; - Header1.bfOffBits=sizeof(Header2)+sizeof(Header1); - } - { - memset(&Header2, 0, sizeof(Header2)); - Header2.bV5Size=sizeof(Header2); - Header2.bV5Width=(int)FWidth; - Header2.bV5Height=-(int)FHeight; - Header2.bV5Planes=1; - Header2.bV5BitCount=(int)GetBitsFromBB(FBits); - Header2.bV5Compression=BI_RGB; - Header2.bV5CSType=LCS_sRGB; - Header2.bV5Intent=LCS_GM_GRAPHICS; - } - stream::FileStream Output(FileName, stream::FileStream::WriteOnly); - Output.Write(&Header1, sizeof(Header1)); - Output.Write(&Header2, sizeof(Header2)); - for(vint i=0;iCopy(0, 0, FWidth, FHeight, FDC, 0, 0); - Temp.SaveToFile(FileName); - } - } - - WinDC* WinBitmap::GetWinDC() - { - return FDC; - } - - vint WinBitmap::GetWidth() - { - return FWidth; - } - - vint WinBitmap::GetHeight() - { - return FHeight; - } - - vint WinBitmap::GetLineBytes() - { - return GetLineBytes(FWidth, FBits); - } - - BYTE** WinBitmap::GetScanLines() - { - return FScanLines; - } - - HBITMAP WinBitmap::GetBitmap() - { - return FHandle; - } - - WinBitmap::BitmapBits WinBitmap::GetBitmapBits() - { - return FBits; - } - - void WinBitmap::FillCompatibleHeader(BITMAPINFOHEADER* Header) - { - FillBitmapInfoHeader(FWidth, FHeight, FBits, Header); - } - - bool WinBitmap::CanBuildAlphaChannel() - { - return FScanLines!=0 && FBits==vbb32Bits; - } - - bool WinBitmap::IsAlphaChannelBuilt() - { - return FAlphaChannelBuilt; - } - - void WinBitmap::BuildAlphaChannel(bool autoPremultiply) - { - if(CanBuildAlphaChannel() && !FAlphaChannelBuilt) - { - FAlphaChannelBuilt=true; - if(autoPremultiply) - { - for(vint i=0;iGetWidth(), DIB->GetHeight(), WinBitmap::vbb24Bits, true); - Temp.GetWinDC()->Draw(0, 0, DIB); - vint HeaderSize=sizeof(BITMAPINFOHEADER); - FDIBMemory=new unsigned char[HeaderSize+Temp.GetHeight()*Temp.GetLineBytes()]; - Temp.FillCompatibleHeader((BITMAPINFOHEADER*)FDIBMemory); - memcpy(FDIBMemory+HeaderSize, Temp.GetScanLines()[0], Temp.GetHeight()*Temp.GetLineBytes()); - - FHandle=CreateDIBPatternBrushPt(FDIBMemory, DIB_RGB_COLORS); - DWORD Error=GetLastError(); - } - - WinBrush::~WinBrush() - { - DeleteObject(FHandle); - if(FDIBMemory) - { - delete[] FDIBMemory; - } - } - - HBRUSH WinBrush::GetHandle() - { - return FHandle; - } - -/********************************************************************************************************* -WinPen -*********************************************************************************************************/ - - WinPen::WinPen(vint Style, vint Width, COLORREF Color) - { - FDIBMemory=0; - FHandle=CreatePen((int)Style, (int)Width, (int)Color); - } - - WinPen::WinPen(vint Style, vint EndCap, vint Join, vint Width, COLORREF Color) - { - FDIBMemory=0; - LOGBRUSH Brush; - Brush.lbColor=Color; - Brush.lbStyle=BS_SOLID; - Brush.lbHatch=0; - FHandle=ExtCreatePen((int)(PS_GEOMETRIC|Style|EndCap|Join), (int)Width, &Brush, 0, 0); - } - - WinPen::WinPen(vint Style, vint EndCap, vint Join, vint Hatch, vint Width, COLORREF Color) - { - FDIBMemory=0; - LOGBRUSH Brush; - Brush.lbColor=Color; - Brush.lbStyle=BS_HATCHED; - Brush.lbHatch=Hatch; - FHandle=ExtCreatePen((int)(PS_GEOMETRIC|Style|EndCap|Join), (int)Width, &Brush, 0, 0); - } - - WinPen::WinPen(WinBitmap::Ptr DIB, vint Style, vint EndCap, vint Join, vint Width) - { - WinBitmap Temp(DIB->GetWidth(), DIB->GetHeight(), WinBitmap::vbb24Bits, true); - Temp.GetWinDC()->Draw(0, 0, DIB); - vint HeaderSize=sizeof(BITMAPINFOHEADER); - FDIBMemory=new unsigned char[HeaderSize+Temp.GetHeight()*Temp.GetLineBytes()]; - Temp.FillCompatibleHeader((BITMAPINFOHEADER*)FDIBMemory); - memcpy(FDIBMemory+HeaderSize, Temp.GetScanLines()[0], Temp.GetHeight()*Temp.GetLineBytes()); - - LOGBRUSH Brush; - Brush.lbColor=RGB(0, 0, 0); - Brush.lbStyle=BS_DIBPATTERNPT; - Brush.lbHatch=(LONG)FDIBMemory; - FHandle=ExtCreatePen((int)(PS_GEOMETRIC|Style|EndCap|Join), (int)Width, &Brush, 0, 0); - } - - WinPen::~WinPen() - { - DeleteObject(FHandle); - if(FDIBMemory) - { - delete[] FDIBMemory; - } - } - - HPEN WinPen::GetHandle() - { - return FHandle; - } - -/********************************************************************************************************* -WinFont -*********************************************************************************************************/ - - WinFont::WinFont(WString Name, vint Height, vint Width, vint Escapement, vint Orientation, vint Weight, bool Italic, bool Underline, bool StrikeOut, bool Antialise) - { - FFontInfo.lfHeight=(int)Height; - FFontInfo.lfWidth=(int)Width; - FFontInfo.lfEscapement=(int)Escapement; - FFontInfo.lfOrientation=(int)Orientation; - FFontInfo.lfWeight=(int)Weight; - FFontInfo.lfItalic=Italic?TRUE:FALSE; - FFontInfo.lfUnderline=Underline?TRUE:FALSE; - FFontInfo.lfStrikeOut=StrikeOut?TRUE:FALSE; - FFontInfo.lfCharSet=DEFAULT_CHARSET; - FFontInfo.lfOutPrecision=OUT_DEFAULT_PRECIS; - FFontInfo.lfClipPrecision=CLIP_DEFAULT_PRECIS; - FFontInfo.lfQuality=Antialise?CLEARTYPE_QUALITY:NONANTIALIASED_QUALITY; - FFontInfo.lfPitchAndFamily=DEFAULT_PITCH | FF_DONTCARE; - wcsncpy_s(FFontInfo.lfFaceName, sizeof(FFontInfo.lfFaceName)/sizeof(*FFontInfo.lfFaceName), Name.Buffer(), LF_FACESIZE-1); - FHandle=CreateFontIndirect(&FFontInfo); - } - - WinFont::WinFont(LOGFONT* FontInfo) - { - FFontInfo=*FontInfo; - FHandle=CreateFontIndirect(&FFontInfo); - } - - WinFont::~WinFont() - { - DeleteObject(FHandle); - } - - HFONT WinFont::GetHandle() - { - return FHandle; - } - - LOGFONT* WinFont::GetInfo() - { - return &FFontInfo; - } - -/********************************************************************************************************* -IWinResourceService -*********************************************************************************************************/ - - WinBrush::Ptr CreateDefaultBrush() - { - return new WinBrush(RGB(255, 255, 255)); - } - - WinPen::Ptr CreateDefaultPen() - { - return new WinPen(PS_SOLID, 0, RGB(0, 0, 0)); - } - - WinFont::Ptr CreateDefaultFont() - { - NONCLIENTMETRICS NonClientMetrics; - NonClientMetrics.cbSize=sizeof(NONCLIENTMETRICS); - SystemParametersInfo(SPI_GETNONCLIENTMETRICS, NonClientMetrics.cbSize, &NonClientMetrics, 0); - if(!*NonClientMetrics.lfMessageFont.lfFaceName) - { - NonClientMetrics.cbSize=sizeof(NONCLIENTMETRICS)-sizeof(NonClientMetrics.iPaddedBorderWidth); - SystemParametersInfo(SPI_GETNONCLIENTMETRICS, NonClientMetrics.cbSize, &NonClientMetrics, 0); - } - return new WinFont(&NonClientMetrics.lfMessageFont); - } - - class DefaultResourceService : public Object, public IWinResourceService - { - public: - static IWinResourceService* _DefaultResourceService; - - WinPen::Ptr GetDefaultPen() - { - return CreateDefaultPen(); - } - - WinBrush::Ptr GetDefaultBrush() - { - return CreateDefaultBrush(); - } - - WinFont::Ptr GetDefaultFont() - { - return CreateDefaultFont(); - } - } _DRS; - IWinResourceService* DefaultResourceService::_DefaultResourceService=&_DRS; - - IWinResourceService* GetDefaultResourceService() - { - return DefaultResourceService::_DefaultResourceService; - } - - void SetDefaultResourceService(IWinResourceService* Service) - { - DefaultResourceService::_DefaultResourceService=Service; - } - -/********************************************************************************************************* -WinDC -*********************************************************************************************************/ - - void WinDC::Init() - { - FPen=GetDefaultResourceService()->GetDefaultPen(); - FOldPen=(HPEN)SelectObject(FHandle, FPen->GetHandle()); - - FBrush=GetDefaultResourceService()->GetDefaultBrush(); - FOldBrush=(HBRUSH)SelectObject(FHandle, FBrush->GetHandle()); - - FFont=GetDefaultResourceService()->GetDefaultFont(); - FOldFont=(HFONT)SelectObject(FHandle, FFont->GetHandle()); - - SetGraphicsMode(FHandle, GM_ADVANCED); - } - - WinDC::WinDC() - { - FHandle=0; - FOldPen=0; - FOldBrush=0; - FOldFont=0; - } - - WinDC::~WinDC() - { - SelectObject(FHandle, FOldFont); - SelectObject(FHandle, FOldBrush); - SelectObject(FHandle, FOldPen); - } - - HDC WinDC::GetHandle() - { - return FHandle; - } - - WinPen::Ptr WinDC::GetPen() - { - return FPen; - } - - WinBrush::Ptr WinDC::GetBrush() - { - return FBrush; - } - - WinFont::Ptr WinDC::GetFont() - { - return FFont; - } - - void WinDC::SetPen(WinPen::Ptr Pen) - { - SelectObject(FHandle, Pen->GetHandle()); - FPen=Pen; - } - - void WinDC::SetBrush(WinBrush::Ptr Brush) - { - SelectObject(FHandle, Brush->GetHandle()); - FBrush=Brush; - } - - void WinDC::SetFont(WinFont::Ptr Font) - { - SelectObject(FHandle, Font->GetHandle()); - FFont=Font; - } - - COLORREF WinDC::GetBackColor() - { - return GetBkColor(FHandle); - } - - void WinDC::SetBackColor(COLORREF Color) - { - SetBkColor(FHandle, Color); - } - - COLORREF WinDC::GetTextColor() - { - return ::GetTextColor(FHandle); - } - - void WinDC::SetTextColor(COLORREF Color) - { - ::SetTextColor(FHandle, Color); - } - - bool WinDC::GetBackTransparent() - { - return GetBkMode(FHandle)==TRANSPARENT; - } - - void WinDC::SetBackTransparent(bool Transparent) - { - SetBkMode(FHandle, Transparent?TRANSPARENT:OPAQUE); - } - - POINT WinDC::GetBrushOrigin() - { - POINT Point; - GetBrushOrgEx(FHandle, &Point); - return Point; - } - - void WinDC::SetBrushOrigin(POINT Point) - { - SetBrushOrgEx(FHandle, Point.x, Point.y, NULL); - } - - /*------------------------------------------------------------------------------*/ - - void WinDC::DrawBuffer(vint X, vint Y, const wchar_t* Text, vint CharCount) - { - TextOut(FHandle, (int)X, (int)Y, Text, (int)CharCount); - } - - void WinDC::DrawBuffer(vint X, vint Y, const wchar_t* Text, vint CharCount, vint TabWidth, vint TabOriginX) - { - int realTabWidth=(int)TabWidth; - TabbedTextOut(FHandle, (int)X, (int)Y, Text, (int)CharCount, 1, &realTabWidth, (int)TabOriginX); - } - - void WinDC::DrawBuffer(RECT Rect, const wchar_t* Text, vint CharCount, UINT Format) - { - DrawText(FHandle, Text, (int)CharCount, &Rect, Format); - } - - void WinDC::DrawString(vint X, vint Y, WString Text) - { - DrawBuffer(X, Y, Text.Buffer(), Text.Length()); - } - - void WinDC::DrawString(vint X, vint Y, WString Text, vint TabWidth, vint TabOriginX) - { - DrawBuffer(X, Y, Text.Buffer(), Text.Length(), TabWidth, TabOriginX); - } - - void WinDC::DrawString(RECT Rect, WString Text, UINT Format) - { - DrawBuffer(Rect, Text.Buffer(), Text.Length(), Format); - } - - SIZE WinDC::MeasureString(WString Text, vint TabSize) - { - return MeasureBuffer(Text.Buffer(), Text.Length(), TabSize); - } - - SIZE WinDC::MeasureBuffer(const wchar_t* Text, vint CharCount, vint TabSize) - { - SIZE Size; - if(TabSize==-1) - { - GetTextExtentPoint32(FHandle, Text, (int)CharCount, &Size); - } - else - { - int realTabSize=(int)TabSize; - DWORD Result=GetTabbedTextExtent(FHandle, Text, (int)CharCount, 1, &realTabSize); - Size.cx=LOWORD(Result); - Size.cy=HIWORD(Result); - } - return Size; - } - - SIZE WinDC::MeasureBuffer(const wchar_t* Text, vint TabSize) - { - return MeasureBuffer(Text, wcslen(Text), TabSize); - } - - SIZE WinDC::MeasureWrapLineString(WString Text, vint MaxWidth) - { - return MeasureWrapLineBuffer(Text.Buffer(), Text.Length(), MaxWidth); - } - - SIZE WinDC::MeasureWrapLineBuffer(const wchar_t* Text, vint CharCount, vint MaxWidth) - { - SIZE size = {0}; - vint lineCount=0; - const wchar_t* reading=Text; - INT* dx=new INT[CharCount]; - while(*reading) - { - INT fit=0; - GetTextExtentExPoint(FHandle, reading, (int)(CharCount-(reading-Text)), (int)MaxWidth, &fit, dx, &size); - reading+=fit; - lineCount++; - } - delete dx; - size.cx=0; - size.cy*=(int)lineCount; - return size; - } - - SIZE WinDC::MeasureWrapLineBuffer(const wchar_t* Text, vint MaxWidth) - { - return MeasureWrapLineBuffer(Text, wcslen(Text), MaxWidth); - } - - void WinDC::FillRegion(WinRegion::Ptr Region) - { - FillRgn(FHandle, Region->GetHandle(), FBrush->GetHandle()); - } - - void WinDC::FrameRegion(WinRegion::Ptr Region, vint BlockWidth, vint BlockHeight) - { - FrameRgn(FHandle, Region->GetHandle(), FBrush->GetHandle(), (int)BlockWidth, (int)BlockHeight); - } - - void WinDC::MoveTo(vint X, vint Y) - { - ::MoveToEx(FHandle, (int)X, (int)Y, NULL); - } - - void WinDC::LineTo(vint X, vint Y) - { - ::LineTo(FHandle, (int)X, (int)Y); - } - - void WinDC::Rectangle(vint Left, vint Top, vint Right, vint Bottom) - { - ::Rectangle(FHandle, (int)Left, (int)Top, (int)Right, (int)Bottom); - } - - void WinDC::Rectangle(RECT Rect) - { - ::Rectangle(FHandle, Rect.left, Rect.top, Rect.right, Rect.bottom); - } - - void WinDC::FocusRectangle(vint Left, vint Top, vint Right, vint Bottom) - { - RECT Rect; - Rect.left=(int)Left; - Rect.top=(int)Top; - Rect.right=(int)Right; - Rect.bottom=(int)Bottom; - ::DrawFocusRect(FHandle, &Rect); - } - - void WinDC::FocusRectangle(RECT Rect) - { - ::DrawFocusRect(FHandle, &Rect); - } - - void WinDC::FillRect(vint Left, vint Top, vint Right, vint Bottom) - { - RECT Rect; - Rect.left=(int)Left; - Rect.top=(int)Top; - Rect.right=(int)Right; - Rect.bottom=(int)Bottom; - ::FillRect(FHandle, &Rect, FBrush->GetHandle()); - } - - void WinDC::FillRect(RECT Rect) - { - ::FillRect(FHandle, &Rect, FBrush->GetHandle()); - } - - void WinDC::Ellipse(vint Left, vint Top, vint Right, vint Bottom) - { - ::Ellipse(FHandle, (int)Left, (int)Top, (int)Right, (int)Bottom); - } - - void WinDC::Ellipse(RECT Rect) - { - ::Ellipse(FHandle, Rect.left, Rect.top, Rect.right, Rect.bottom); - } - - void WinDC::RoundRect(vint Left, vint Top, vint Right, vint Bottom, vint EllipseWidth, vint EllipseHeight) - { - ::RoundRect(FHandle, (int)Left, (int)Top, (int)Right, (int)Bottom, (int)EllipseWidth, (int)EllipseHeight); - } - - void WinDC::RoundRect(RECT Rect, vint EllipseWidth, vint EllipseHeight) - { - ::RoundRect(FHandle, (int)Rect.left, (int)Rect.top, (int)Rect.right, (int)Rect.bottom, (int)EllipseWidth, (int)EllipseHeight); - } - - void WinDC::PolyLine(const POINT* Points, vint Count) - { - ::Polyline(FHandle, Points, (int)Count); - } - - void WinDC::PolyLineTo(const POINT* Points, vint Count) - { - ::PolylineTo(FHandle, Points, (int)Count); - } - - void WinDC::PolyGon(const POINT* Points, vint Count) - { - ::Polygon(FHandle, Points, (int)Count); - } - - void WinDC::PolyBezier(const POINT* Points, vint Count) - { - ::PolyBezier(FHandle, Points, (int)Count); - } - - void WinDC::PolyBezierTo(const POINT* Points, vint Count) - { - ::PolyBezierTo(FHandle, Points, (int)Count); - } - - void WinDC::PolyDraw(const POINT* Points, const BYTE* Actions, vint PointCount) - { - ::PolyDraw(FHandle, Points, Actions, (int)PointCount); - } - - void WinDC::Arc(RECT Bound, POINT Start, POINT End) - { - ::Arc(FHandle, Bound.left, Bound.top, Bound.right, Bound.bottom, Start.x, Start.y, End.x, End.y); - } - - void WinDC::Arc(vint Left, vint Top, vint Right, vint Bottom, vint StartX, vint StartY, vint EndX, vint EndY) - { - ::Arc(FHandle, (int)Left, (int)Top, (int)Right, (int)Bottom, (int)StartX, (int)StartY, (int)EndX, (int)EndY); - } - - void WinDC::ArcTo(RECT Bound, POINT Start, POINT End) - { - ::ArcTo(FHandle, (int)Bound.left, (int)Bound.top, (int)Bound.right, (int)Bound.bottom, (int)Start.x, (int)Start.y, (int)End.x, (int)End.y); - } - - void WinDC::ArcTo(vint Left, vint Top, vint Right, vint Bottom, vint StartX, vint StartY, vint EndX, vint EndY) - { - ::ArcTo(FHandle, (int)Left, (int)Top, (int)Right, (int)Bottom, (int)StartX, (int)StartY, (int)EndX, (int)EndY); - } - - void WinDC::AngleArc(vint X, vint Y, vint Radius, float StartAngle, float SweepAngle) - { - ::AngleArc(FHandle, (int)X, (int)Y, (int)Radius, StartAngle, SweepAngle); - } - - void WinDC::AngleArc(vint X, vint Y, vint Radius, double StartAngle, double SweepAngle) - { - ::AngleArc(FHandle, (int)X, (int)Y, (int)Radius, (float)StartAngle, (float)SweepAngle); - } - - void WinDC::Chord(RECT Bound, POINT Start, POINT End) - { - ::Chord(FHandle, (int)Bound.left, (int)Bound.top, (int)Bound.right, (int)Bound.bottom, (int)Start.x, (int)Start.y, (int)End.x, (int)End.y); - } - - void WinDC::Chord(vint Left, vint Top, vint Right, vint Bottom, vint StartX, vint StartY, vint EndX, vint EndY) - { - ::Chord(FHandle, (int)Left, (int)Top, (int)Right, (int)Bottom, (int)StartX, (int)StartY, (int)EndX, (int)EndY); - } - - void WinDC::Pie(RECT Bound, POINT Start, POINT End) - { - ::Pie(FHandle, (int)Bound.left, (int)Bound.top, (int)Bound.right, (int)Bound.bottom, (int)Start.x, (int)Start.y, (int)End.x, (int)End.y); - } - - void WinDC::Pie(vint Left, vint Top, vint Right, vint Bottom, vint StartX, vint StartY, vint EndX, vint EndY) - { - ::Pie(FHandle, (int)Left, (int)Top, (int)Right, (int)Bottom, (int)StartX, (int)StartY, (int)EndX, (int)EndY); - } - - void WinDC::GradientTriangle(TRIVERTEX* Vertices, vint VerticesCount, GRADIENT_TRIANGLE* Triangles, vint TriangleCount) - { - GradientFill(FHandle, Vertices, (int)VerticesCount, Triangles, (int)TriangleCount, GRADIENT_FILL_TRIANGLE); - } - - /*------------------------------------------------------------------------------*/ - - void WinDC::BeginPath() - { - ::BeginPath(FHandle); - } - - void WinDC::EndPath() - { - ::EndPath(FHandle); - } - - void WinDC::ClosePath() - { - ::CloseFigure(FHandle); - } - - void WinDC::WidenPath() - { - ::WidenPath(FHandle); - } - - void WinDC::DiscardPath() - { - ::AbortPath(FHandle); - } - - void WinDC::DrawPath() - { - ::StrokePath(FHandle); - } - - void WinDC::FillPath() - { - ::FillPath(FHandle); - } - - void WinDC::DrawAndFillPath() - { - ::StrokeAndFillPath(FHandle); - } - - WinRegion::Ptr WinDC::RegionFromPath() - { - return new WinRegion(::PathToRegion(FHandle)); - } - - /*------------------------------------------------------------------------------*/ - - bool WinDC::PointInClip(POINT Point) - { - return PtVisible(FHandle, Point.x, Point.y)==TRUE; - } - - bool WinDC::RectInClip(RECT Rect) - { - return RectVisible(FHandle, &Rect)==TRUE; - } - - void WinDC::ClipPath(vint CombineMode) - { - SelectClipPath(FHandle, (int)CombineMode); - } - - void WinDC::ClipRegion(WinRegion::Ptr Region) - { - SelectClipRgn(FHandle, Region->GetHandle()); - } - - void WinDC::RemoveClip() - { - SelectClipRgn(FHandle, NULL); - } - - void WinDC::MoveClip(vint OffsetX, vint OffsetY) - { - OffsetClipRgn(FHandle, (int)OffsetX, (int)OffsetY); - } - - void WinDC::CombineClip(WinRegion::Ptr Region, vint CombineMode) - { - ExtSelectClipRgn(FHandle, Region->GetHandle(), (int)CombineMode); - } - - void WinDC::IntersetClipRect(RECT Rect) - { - ::IntersectClipRect(FHandle, Rect.left, Rect.top, Rect.right, Rect.bottom); - } - - void WinDC::ExcludeClipRect(RECT Rect) - { - ::ExcludeClipRect(FHandle, Rect.left, Rect.top, Rect.right, Rect.bottom); - } - - WinRegion::Ptr WinDC::GetClipRegion() - { - HRGN Handle=CreateRectRgn(0, 0, 1, 1); - GetClipRgn(FHandle, Handle); - return new WinRegion(Handle); - } - - RECT WinDC::GetClipBoundRect() - { - RECT Rect; - GetClipBox(FHandle, &Rect); - return Rect; - } - - /*------------------------------------------------------------------------------*/ - - WinTransform WinDC::GetTransform() - { - XFORM Transform; - GetWorldTransform(FHandle, &Transform); - return Transform; - } - - void WinDC::SetTransform(const WinTransform& Transform) - { - SetWorldTransform(FHandle, Transform.GetHandle()); - } - - /*------------------------------------------------------------------------------*/ - - void WinDC::Copy(vint dstX, vint dstY, vint dstW, vint dstH, WinDC* Source, vint srcX, vint srcY, DWORD DrawROP) - { - HDC SourceHandle=Source?Source->GetHandle():0; - BitBlt(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, SourceHandle, (int)srcX, (int)srcY, (int)DrawROP); - } - - void WinDC::Copy(RECT dstRect, WinDC* Source, POINT srcPos, DWORD DrawROP) - { - HDC SourceHandle=Source?Source->GetHandle():0; - BitBlt(FHandle, dstRect.left, dstRect.top, dstRect.right-dstRect.left, dstRect.bottom-dstRect.top, SourceHandle, srcPos.x, srcPos.y, DrawROP); - } - - void WinDC::Copy(vint dstX, vint dstY, vint dstW, vint dstH, WinDC* Source, vint srcX, vint srcY , vint srcW, vint srcH, DWORD DrawROP) - { - HDC SourceHandle=Source?Source->GetHandle():0; - StretchBlt(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, SourceHandle, (int)srcX, (int)srcY, (int)srcW, (int)srcH, (int)DrawROP); - } - - void WinDC::Copy(RECT dstRect, WinDC* Source, RECT srcRect, DWORD DrawROP) - { - HDC SourceHandle=Source?Source->GetHandle():0; - StretchBlt( FHandle , dstRect.left, dstRect.top, dstRect.right-dstRect.left, dstRect.bottom-dstRect.top, - SourceHandle, srcRect.left, srcRect.top, srcRect.right-srcRect.left, srcRect.bottom-srcRect.top, - DrawROP); - } - - void WinDC::Copy(POINT UpperLeft, POINT UpperRight, POINT LowerLeft, WinDC* Source, vint srcX, vint srcY, vint srcW, vint srcH) - { - POINT Pt[3]; - Pt[0]=UpperLeft; - Pt[1]=UpperRight; - Pt[2]=LowerLeft; - PlgBlt(FHandle, Pt, Source->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, 0, 0, 0); - } - - void WinDC::Copy(POINT UpperLeft, POINT UpperRight, POINT LowerLeft, WinDC*Source, RECT srcRect) - { - POINT Pt[3]; - Pt[0]=UpperLeft; - Pt[1]=UpperRight; - Pt[2]=LowerLeft; - PlgBlt(FHandle, Pt, Source->GetHandle(), srcRect.left, srcRect.top, srcRect.right-srcRect.left, srcRect.bottom-srcRect.top, 0, 0, 0); - } - - void WinDC::CopyTrans(vint dstX, vint dstY, vint dstW, vint dstH, WinDC* Source, vint srcX, vint srcY , vint srcW, vint srcH, COLORREF Color) - { - TransparentBlt(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Source->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Color); - } - - void WinDC::CopyTrans(RECT dstRect, WinDC* Source, RECT srcRect, COLORREF Color) - { - TransparentBlt( FHandle , dstRect.left, dstRect.top, dstRect.right-dstRect.left, dstRect.bottom-dstRect.top, - Source->GetHandle() , srcRect.left, srcRect.top, srcRect.right-srcRect.left, srcRect.bottom-srcRect.top, - Color); - } - - /*------------------------------------------------------------------------------*/ - - void WinDC::Draw(vint dstX, vint dstY, WinMetaFile* MetaFile) - { - Draw(dstX, dstY, MetaFile->GetWidth(), MetaFile->GetHeight(), MetaFile); - } - - void WinDC::Draw(POINT Pos, WinMetaFile* MetaFile) - { - Draw(Pos.x, Pos.y, MetaFile->GetWidth(), MetaFile->GetHeight(), MetaFile); - } - - void WinDC::Draw(vint dstX, vint dstY, vint dstW, vint dstH, WinMetaFile* MetaFile) - { - RECT Rect; - Rect.left=(int)dstX; - Rect.top=(int)dstY; - Rect.right=(int)(dstX+dstW); - Rect.bottom=(int)(dstY+dstH); - Draw(Rect, MetaFile); - } - - void WinDC::Draw(RECT Rect, WinMetaFile* MetaFile) - { - PlayEnhMetaFile(FHandle, MetaFile->GetHandle(), &Rect); - } - - /*------------------------------------------------------------------------------*/ - - void WinDC::Draw(vint dstX, vint dstY, WinBitmap::Ptr Bitmap) - { - vint dstW=Bitmap->GetWidth(); - vint dstH=Bitmap->GetHeight(); - vint srcX=0; - vint srcY=0; - if(!Bitmap->IsAlphaChannelBuilt()) - { - BitBlt(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, SRCCOPY); - } - else - { - vint srcW=dstW; - vint srcH=dstH; - BLENDFUNCTION Blend; - Blend.BlendOp=AC_SRC_OVER; - Blend.BlendFlags=0; - Blend.SourceConstantAlpha=255; - Blend.AlphaFormat=AC_SRC_ALPHA; - AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); - } - } - - void WinDC::Draw(POINT Pos, WinBitmap::Ptr Bitmap) - { - vint dstX=Pos.x; - vint dstY=Pos.y; - vint dstW=Bitmap->GetWidth(); - vint dstH=Bitmap->GetHeight(); - vint srcX=0; - vint srcY=0; - if(!Bitmap->IsAlphaChannelBuilt()) - { - BitBlt(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, SRCCOPY); - } - else - { - vint srcW=dstW; - vint srcH=dstH; - BLENDFUNCTION Blend; - Blend.BlendOp=AC_SRC_OVER; - Blend.BlendFlags=0; - Blend.SourceConstantAlpha=255; - Blend.AlphaFormat=AC_SRC_ALPHA; - AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); - } - } - - void WinDC::Draw(vint dstX, vint dstY, vint dstW, vint dstH, WinBitmap::Ptr Bitmap) - { - vint srcX=0; - vint srcY=0; - vint srcW=Bitmap->GetWidth(); - vint srcH=Bitmap->GetHeight(); - if(!Bitmap->IsAlphaChannelBuilt()) - { - StretchBlt(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, SRCCOPY); - } - else - { - BLENDFUNCTION Blend; - Blend.BlendOp=AC_SRC_OVER; - Blend.BlendFlags=0; - Blend.SourceConstantAlpha=255; - Blend.AlphaFormat=AC_SRC_ALPHA; - AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); - } - } - - void WinDC::Draw(RECT Rect, WinBitmap::Ptr Bitmap) - { - vint dstX=Rect.left; - vint dstY=Rect.top; - vint dstW=Rect.right-Rect.left; - vint dstH=Rect.bottom-Rect.top; - vint srcX=0; - vint srcY=0; - vint srcW=Bitmap->GetWidth(); - vint srcH=Bitmap->GetHeight(); - if(!Bitmap->IsAlphaChannelBuilt()) - { - StretchBlt(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, SRCCOPY); - } - else - { - BLENDFUNCTION Blend; - Blend.BlendOp=AC_SRC_OVER; - Blend.BlendFlags=0; - Blend.SourceConstantAlpha=255; - Blend.AlphaFormat=AC_SRC_ALPHA; - AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); - } - } - - void WinDC::Draw(vint dstX, vint dstY, vint dstW, vint dstH, WinBitmap::Ptr Bitmap, vint srcX, vint srcY) - { - if(!Bitmap->IsAlphaChannelBuilt()) - { - BitBlt(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, SRCCOPY); - } - else - { - vint srcW=dstW; - vint srcH=dstH; - BLENDFUNCTION Blend; - Blend.BlendOp=AC_SRC_OVER; - Blend.BlendFlags=0; - Blend.SourceConstantAlpha=255; - Blend.AlphaFormat=AC_SRC_ALPHA; - AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); - } - } - - void WinDC::Draw(RECT Rect, WinBitmap::Ptr Bitmap, POINT Pos) - { - vint dstX=Rect.left; - vint dstY=Rect.top; - vint dstW=Rect.right-Rect.left; - vint dstH=Rect.bottom-Rect.top; - vint srcX=Pos.x; - vint srcY=Pos.y; - if(!Bitmap->IsAlphaChannelBuilt()) - { - BitBlt(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, SRCCOPY); - } - else - { - vint srcW=dstW; - vint srcH=dstH; - BLENDFUNCTION Blend; - Blend.BlendOp=AC_SRC_OVER; - Blend.BlendFlags=0; - Blend.SourceConstantAlpha=255; - Blend.AlphaFormat=AC_SRC_ALPHA; - AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); - } - } - - void WinDC::Draw(vint dstX, vint dstY, vint dstW, vint dstH, WinBitmap::Ptr Bitmap, vint srcX, vint srcY, vint srcW, vint srcH) - { - if(!Bitmap->IsAlphaChannelBuilt()) - { - StretchBlt(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, SRCCOPY); - } - else - { - BLENDFUNCTION Blend; - Blend.BlendOp=AC_SRC_OVER; - Blend.BlendFlags=0; - Blend.SourceConstantAlpha=255; - Blend.AlphaFormat=AC_SRC_ALPHA; - AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); - } - } - - void WinDC::Draw(RECT dstRect, WinBitmap::Ptr Bitmap, RECT srcRect) - { - vint dstX=dstRect.left; - vint dstY=dstRect.top; - vint dstW=dstRect.right-dstRect.left; - vint dstH=dstRect.bottom-dstRect.top; - vint srcX=srcRect.left; - vint srcY=srcRect.top; - vint srcW=srcRect.right-srcRect.left; - vint srcH=srcRect.bottom-srcRect.top; - if(!Bitmap->IsAlphaChannelBuilt()) - { - StretchBlt(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, SRCCOPY); - } - else - { - BLENDFUNCTION Blend; - Blend.BlendOp=AC_SRC_OVER; - Blend.BlendFlags=0; - Blend.SourceConstantAlpha=255; - Blend.AlphaFormat=AC_SRC_ALPHA; - AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); - } - } - - /*------------------------------------------------------------------------------*/ - - void WinDC::Draw(vint dstX, vint dstY, WinBitmap::Ptr Bitmap, unsigned char Alpha) - { - vint dstW=Bitmap->GetWidth(); - vint dstH=Bitmap->GetHeight(); - vint srcX=0; - vint srcY=0; - vint srcW=dstW; - vint srcH=dstH; - - BLENDFUNCTION Blend; - Blend.BlendOp=AC_SRC_OVER; - Blend.BlendFlags=0; - Blend.SourceConstantAlpha=Alpha; - Blend.AlphaFormat=Bitmap->IsAlphaChannelBuilt()?AC_SRC_ALPHA:0; - AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); - } - - void WinDC::Draw(POINT Pos, WinBitmap::Ptr Bitmap, unsigned char Alpha) - { - vint dstX=Pos.x; - vint dstY=Pos.y; - vint dstW=Bitmap->GetWidth(); - vint dstH=Bitmap->GetHeight(); - vint srcX=0; - vint srcY=0; - vint srcW=dstW; - vint srcH=dstH; - - BLENDFUNCTION Blend; - Blend.BlendOp=AC_SRC_OVER; - Blend.BlendFlags=0; - Blend.SourceConstantAlpha=Alpha; - Blend.AlphaFormat=Bitmap->IsAlphaChannelBuilt()?AC_SRC_ALPHA:0; - AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); - } - - void WinDC::Draw(vint dstX, vint dstY, vint dstW, vint dstH, WinBitmap::Ptr Bitmap, unsigned char Alpha) - { - vint srcX=0; - vint srcY=0; - vint srcW=Bitmap->GetWidth(); - vint srcH=Bitmap->GetHeight(); - - BLENDFUNCTION Blend; - Blend.BlendOp=AC_SRC_OVER; - Blend.BlendFlags=0; - Blend.SourceConstantAlpha=Alpha; - Blend.AlphaFormat=Bitmap->IsAlphaChannelBuilt()?AC_SRC_ALPHA:0; - AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); - } - - void WinDC::Draw(RECT Rect, WinBitmap::Ptr Bitmap, unsigned char Alpha) - { - vint dstX=Rect.left; - vint dstY=Rect.top; - vint dstW=Rect.right-Rect.left; - vint dstH=Rect.bottom-Rect.top; - vint srcX=0; - vint srcY=0; - vint srcW=Bitmap->GetWidth(); - vint srcH=Bitmap->GetHeight(); - - BLENDFUNCTION Blend; - Blend.BlendOp=AC_SRC_OVER; - Blend.BlendFlags=0; - Blend.SourceConstantAlpha=Alpha; - Blend.AlphaFormat=Bitmap->IsAlphaChannelBuilt()?AC_SRC_ALPHA:0; - AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); - } - - void WinDC::Draw(vint dstX, vint dstY, vint dstW, vint dstH, WinBitmap::Ptr Bitmap, vint srcX, vint srcY, unsigned char Alpha) - { - vint srcW=dstW; - vint srcH=dstH; - - BLENDFUNCTION Blend; - Blend.BlendOp=AC_SRC_OVER; - Blend.BlendFlags=0; - Blend.SourceConstantAlpha=Alpha; - Blend.AlphaFormat=Bitmap->IsAlphaChannelBuilt()?AC_SRC_ALPHA:0; - AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); - } - - void WinDC::Draw(RECT Rect, WinBitmap::Ptr Bitmap, POINT Pos, unsigned char Alpha) - { - vint dstX=Rect.left; - vint dstY=Rect.top; - vint dstW=Rect.right-Rect.left; - vint dstH=Rect.bottom-Rect.top; - vint srcX=Pos.x; - vint srcY=Pos.y; - vint srcW=dstW; - vint srcH=dstH; - - BLENDFUNCTION Blend; - Blend.BlendOp=AC_SRC_OVER; - Blend.BlendFlags=0; - Blend.SourceConstantAlpha=Alpha; - Blend.AlphaFormat=Bitmap->IsAlphaChannelBuilt()?AC_SRC_ALPHA:0; - AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); - } - - void WinDC::Draw(vint dstX, vint dstY, vint dstW, vint dstH, WinBitmap::Ptr Bitmap, vint srcX, vint srcY, vint srcW, vint srcH, unsigned char Alpha) - { - BLENDFUNCTION Blend; - Blend.BlendOp=AC_SRC_OVER; - Blend.BlendFlags=0; - Blend.SourceConstantAlpha=Alpha; - Blend.AlphaFormat=Bitmap->IsAlphaChannelBuilt()?AC_SRC_ALPHA:0; - AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); - } - - void WinDC::Draw(RECT dstRect, WinBitmap::Ptr Bitmap, RECT srcRect, unsigned char Alpha) - { - vint dstX=dstRect.left; - vint dstY=dstRect.top; - vint dstW=dstRect.right-dstRect.left; - vint dstH=dstRect.bottom-dstRect.top; - vint srcX=srcRect.left; - vint srcY=srcRect.top; - vint srcW=srcRect.right-srcRect.left; - vint srcH=srcRect.bottom-srcRect.top; - - BLENDFUNCTION Blend; - Blend.BlendOp=AC_SRC_OVER; - Blend.BlendFlags=0; - Blend.SourceConstantAlpha=Alpha; - Blend.AlphaFormat=Bitmap->IsAlphaChannelBuilt()?AC_SRC_ALPHA:0; - AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); - } - -/********************************************************************************************************* -WinControlDC -*********************************************************************************************************/ - - WinControlDC::WinControlDC(HWND Handle) - { - FControlHandle=Handle; - FHandle=GetDC(FControlHandle); - Init(); - } - - WinControlDC::~WinControlDC() - { - ReleaseDC(FControlHandle, FHandle); - } - -/********************************************************************************************************* -WinProxyDC -*********************************************************************************************************/ - - WinProxyDC::WinProxyDC() - { - FHandle=NULL; - } - - WinProxyDC::~WinProxyDC() - { - } - - void WinProxyDC::Initialize(HDC Handle) - { - FHandle=Handle; - Init(); - } - -/********************************************************************************************************* -WinImageDC -*********************************************************************************************************/ - - WinImageDC::WinImageDC() - { - FHandle=CreateCompatibleDC(NULL); - Init(); - } - - WinImageDC::~WinImageDC() - { - DeleteDC(FHandle); - } - - } - } -} - -/*********************************************************************** -NATIVEWINDOW\WINDOWS\GDI\WINGDIAPPLICATION.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace windows - { - using namespace vl::collections; - - class GdiWindowsNativeWindowListener : public Object, public INativeWindowListener - { - protected: - Ptr buffer; - INativeWindow* window; - - vint DetermineBufferLength(vint minSize, vint minBound, vint maxBound, vint currentSize) - { - if(currentSizemaxBound) - { - return minBound; - } - else - { - return currentSize; - } - } - - Size CalculateBufferSize() - { - Size windowSize=window->GetClientSize(); - Size minBounds(windowSize.x*5/4, windowSize.y*5/4); - Size maxBounds(windowSize.x*3/2, windowSize.y*3/2); - Size currentSize=buffer?Size(buffer->GetWidth(), buffer->GetHeight()):Size(0, 0); - vint newWidth=DetermineBufferLength(windowSize.x, minBounds.x, maxBounds.x, currentSize.x); - vint newHeight=DetermineBufferLength(windowSize.y, minBounds.y, maxBounds.y, currentSize.y); - return Size(newWidth, newHeight); - } - - void RebuildCanvas(Size size) - { - if(size.x<256)size.x=256; - if(size.y<256)size.y=256; - if(buffer) - { - if(buffer->GetWidth()!=size.x || buffer->GetHeight()!=size.y) - { - buffer=0; - } - } - if(!buffer) - { - buffer=new WinBitmap(size.x, size.y, WinBitmap::vbb32Bits, true); - buffer->GetWinDC()->SetBackTransparent(true); - } - } - public: - GdiWindowsNativeWindowListener(INativeWindow* _window) - :window(_window) - { - } - - void Moved() - { - RebuildCanvas(CalculateBufferSize()); - } - - void Paint() - { - IWindowsForm* form=GetWindowsForm(window); - WinControlDC controlDC(form->GetWindowHandle()); - controlDC.Draw(0, 0, buffer); - } - - WinDC* GetWinDC() - { - if(!buffer) Moved(); - return buffer->GetWinDC(); - } - }; - - class GdiWindowsNativeControllerListener : public Object, public INativeControllerListener - { - public: - Dictionary> nativeWindowListeners; - - void NativeWindowCreated(INativeWindow* window) - { - Ptr listener=new GdiWindowsNativeWindowListener(window); - window->InstallListener(listener.Obj()); - nativeWindowListeners.Add(window, listener); - } - - void NativeWindowDestroying(INativeWindow* window) - { - Ptr listener=nativeWindowListeners[window]; - nativeWindowListeners.Remove(window); - window->UninstallListener(listener.Obj()); - } - }; - - GdiWindowsNativeControllerListener* gdiListener=0; - - WinDC* GetNativeWindowDC(INativeWindow* window) - { - vint index=gdiListener->nativeWindowListeners.Keys().IndexOf(window); - return index==-1?0:gdiListener->nativeWindowListeners.Values().Get(index)->GetWinDC(); - } - - HDC GetNativeWindowHDC(INativeWindow* window) - { - WinDC* dc=GetNativeWindowDC(window); - return dc?dc->GetHandle():NULL; - } - } - - namespace elements_windows_gdi - { -/*********************************************************************** -OS Supporting -***********************************************************************/ - - class WinGDIApplicationGDIObjectProvider : public IWindowsGDIObjectProvider - { - protected: - IMLangFontLink2* mLangFontLink; - - public: - WinGDIApplicationGDIObjectProvider() - :mLangFontLink(0) - { - CoCreateInstance(CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER, IID_IMLangFontLink2, (void**)&mLangFontLink); - } - - ~WinGDIApplicationGDIObjectProvider() - { - mLangFontLink->Release(); - } - - windows::WinDC* GetNativeWindowDC(INativeWindow* window)override - { - return vl::presentation::windows::GetNativeWindowDC(window); - } - - IWindowsGDIRenderTarget* GetBindedRenderTarget(INativeWindow* window)override - { - return dynamic_cast(vl::presentation::windows::GetWindowsForm(window)->GetGraphicsHandler()); - } - - void SetBindedRenderTarget(INativeWindow* window, IWindowsGDIRenderTarget* renderTarget)override - { - vl::presentation::windows::GetWindowsForm(window)->SetGraphicsHandler(renderTarget); - } - - IWICImagingFactory* GetWICImagingFactory()override - { - return vl::presentation::windows::GetWICImagingFactory(); - } - - IWICBitmap* GetWICBitmap(INativeImageFrame* frame)override - { - return vl::presentation::windows::GetWICBitmap(frame); - } - - IMLangFontLink2* GetMLangFontLink()override - { - return mLangFontLink; - } - }; - } - } -} - -using namespace vl; -using namespace vl::presentation; -using namespace vl::presentation::windows; -using namespace vl::presentation::elements_windows_gdi; - -int WinMainGDI(HINSTANCE hInstance, void(*RendererMain)()) -{ - EnableCrossKernelCrashing(); - // create controller - INativeController* controller=CreateWindowsNativeController(hInstance); - SetCurrentController(controller); - { - // install listener - GdiWindowsNativeControllerListener listener; - controller->CallbackService()->InstallListener(&listener); - gdiListener=&listener; - // main - RendererMain(); - // uninstall listener - gdiListener=0; - controller->CallbackService()->UninstallListener(&listener); - } - // destroy controller - DestroyWindowsNativeController(controller); - return 0; -} - -int SetupWindowsGDIRenderer() -{ - CoInitializeEx(NULL, COINIT_MULTITHREADED); - HINSTANCE hInstance=(HINSTANCE)GetModuleHandle(NULL); - WinGDIApplicationGDIObjectProvider objectProvider; - SetWindowsGDIObjectProvider(&objectProvider); - return WinMainGDI(hInstance, &RendererMainGDI); -} - -/*********************************************************************** -NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSASYNCSERVICE.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace windows - { - using namespace collections; - -/*********************************************************************** -WindowsAsyncService::TaskItem -***********************************************************************/ - - WindowsAsyncService::TaskItem::TaskItem() - :semaphore(0) - { - } - - WindowsAsyncService::TaskItem::TaskItem(Semaphore* _semaphore, const Func& _proc) - :semaphore(_semaphore) - ,proc(_proc) - { - } - - WindowsAsyncService::TaskItem::~TaskItem() - { - } - -/*********************************************************************** -WindowsAsyncService::DelayItem -***********************************************************************/ - - WindowsAsyncService::DelayItem::DelayItem(WindowsAsyncService* _service, const Func& _proc, bool _executeInMainThread, vint milliseconds) - :service(_service) - ,proc(_proc) - ,status(INativeDelay::Pending) - ,executeTime(DateTime::LocalTime().Forward(milliseconds)) - ,executeInMainThread(_executeInMainThread) - { - } - - WindowsAsyncService::DelayItem::~DelayItem() - { - } - - INativeDelay::ExecuteStatus WindowsAsyncService::DelayItem::GetStatus() - { - return status; - } - - bool WindowsAsyncService::DelayItem::Delay(vint milliseconds) - { - SPIN_LOCK(service->taskListLock) - { - if(status==INativeDelay::Pending) - { - executeTime=DateTime::LocalTime().Forward(milliseconds); - return true; - } - } - return false; - } - - bool WindowsAsyncService::DelayItem::Cancel() - { - SPIN_LOCK(service->taskListLock) - { - if(status==INativeDelay::Pending) - { - if(service->delayItems.Remove(this)) - { - status=INativeDelay::Canceled; - return true; - } - } - } - return false; - } - -/*********************************************************************** -WindowsAsyncService -***********************************************************************/ - - WindowsAsyncService::WindowsAsyncService() - :mainThreadId(Thread::GetCurrentThreadId()) - { - } - - WindowsAsyncService::~WindowsAsyncService() - { - } - - void WindowsAsyncService::ExecuteAsyncTasks() - { - DateTime now=DateTime::LocalTime(); - Array items; - List> executableDelayItems; - - SPIN_LOCK(taskListLock) - { - CopyFrom(items, taskItems); - taskItems.RemoveRange(0, items.Count()); - for(vint i=delayItems.Count()-1;i>=0;i--) - { - Ptr item=delayItems[i]; - if(now.filetime>=item->executeTime.filetime) - { - item->status=INativeDelay::Executing; - executableDelayItems.Add(item); - delayItems.RemoveAt(i); - } - } - } - - FOREACH(TaskItem, item, items) - { - item.proc(); - if(item.semaphore) - { - item.semaphore->Release(); - } - } - FOREACH(Ptr, item, executableDelayItems) - { - if(item->executeInMainThread) - { - item->proc(); - item->status=INativeDelay::Executed; - } - else - { - InvokeAsync([=]() - { - item->proc(); - item->status=INativeDelay::Executed; - }); - } - } - } - - bool WindowsAsyncService::IsInMainThread() - { - return Thread::GetCurrentThreadId()==mainThreadId; - } - - void WindowsAsyncService::InvokeAsync(const Func& proc) - { - ThreadPoolLite::Queue(proc); - } - - void WindowsAsyncService::InvokeInMainThread(const Func& proc) - { - SPIN_LOCK(taskListLock) - { - TaskItem item(0, proc); - taskItems.Add(item); - } - } - - bool WindowsAsyncService::InvokeInMainThreadAndWait(const Func& proc, vint milliseconds) - { - Semaphore semaphore; - semaphore.Create(0, 1); - - SPIN_LOCK(taskListLock) - { - TaskItem item(&semaphore, proc); - taskItems.Add(item); - } - - if(milliseconds<0) - { - return semaphore.Wait(); - } - else - { - return semaphore.WaitForTime(milliseconds); - } - } - - Ptr WindowsAsyncService::DelayExecute(const Func& proc, vint milliseconds) - { - Ptr delay; - SPIN_LOCK(taskListLock) - { - delay=new DelayItem(this, proc, false, milliseconds); - delayItems.Add(delay); - } - return delay; - } - - Ptr WindowsAsyncService::DelayExecuteInMainThread(const Func& proc, vint milliseconds) - { - Ptr delay; - SPIN_LOCK(taskListLock) - { - delay=new DelayItem(this, proc, true, milliseconds); - delayItems.Add(delay); - } - return delay; - } - } - } -} - -/*********************************************************************** -NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSCALLBACKSERVICE.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace windows - { - -/*********************************************************************** -WindowsCallbackService -***********************************************************************/ - - WindowsCallbackService::WindowsCallbackService() - { - } - - bool WindowsCallbackService::InstallListener(INativeControllerListener* listener) - { - if(listeners.Contains(listener)) - { - return false; - } - else - { - listeners.Add(listener); - return true; - } - } - - bool WindowsCallbackService::UninstallListener(INativeControllerListener* listener) - { - if(listeners.Contains(listener)) - { - listeners.Remove(listener); - return true; - } - else - { - return false; - } - } - - void WindowsCallbackService::InvokeMouseHook(WPARAM message, Point location) - { - switch(message) - { - case WM_LBUTTONDOWN: - { - for(vint i=0;iLeftButtonDown(location); - } - } - break; - case WM_LBUTTONUP: - { - for(vint i=0;iLeftButtonUp(location); - } - } - break; - case WM_RBUTTONDOWN: - { - for(vint i=0;iRightButtonDown(location); - } - } - break; - case WM_RBUTTONUP: - { - for(vint i=0;iRightButtonUp(location); - } - } - break; - case WM_MOUSEMOVE: - { - for(vint i=0;iMouseMoving(location); - } - } - break; - } - } - - void WindowsCallbackService::InvokeGlobalTimer() - { - for(vint i=0;iGlobalTimer(); - } - } - - void WindowsCallbackService::InvokeClipboardUpdated() - { - for(vint i=0;iClipboardUpdated(); - } - } - - void WindowsCallbackService::InvokeNativeWindowCreated(INativeWindow* window) - { - for(vint i=0;iNativeWindowCreated(window); - } - } - - void WindowsCallbackService::InvokeNativeWindowDestroyed(INativeWindow* window) - { - for(vint i=0;iNativeWindowDestroying(window); - } - } - } - } -} - -/*********************************************************************** -NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSCLIPBOARDSERVICE.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace windows - { - -/*********************************************************************** -WindowsClipboardService -***********************************************************************/ - - WindowsClipboardService::WindowsClipboardService() - :ownerHandle(NULL) - { - } - - void WindowsClipboardService::SetOwnerHandle(HWND handle) - { - HWND oldHandle=ownerHandle; - ownerHandle=handle; - if(handle==NULL) - { - RemoveClipboardFormatListener(oldHandle); - } - else - { - AddClipboardFormatListener(ownerHandle); - } - } - - bool WindowsClipboardService::ContainsText() - { - if(OpenClipboard(ownerHandle)) - { - UINT format=0; - bool contains=false; - while(format=EnumClipboardFormats(format)) - { - if(format==CF_TEXT || format==CF_UNICODETEXT) - { - contains=true; - break; - } - } - CloseClipboard(); - return contains; - } - return false; - } - - WString WindowsClipboardService::GetText() - { - if(OpenClipboard(ownerHandle)) - { - WString result; - HANDLE handle=GetClipboardData(CF_UNICODETEXT); - if(handle!=0) - { - wchar_t* buffer=(wchar_t*)GlobalLock(handle); - result=buffer; - GlobalUnlock(handle); - } - CloseClipboard(); - return result; - } - return L""; - } - - bool WindowsClipboardService::SetText(const WString& value) - { - if(OpenClipboard(ownerHandle)) - { - EmptyClipboard(); - vint size=(value.Length()+1)*sizeof(wchar_t); - HGLOBAL data=GlobalAlloc(GMEM_MOVEABLE, size); - wchar_t* buffer=(wchar_t*)GlobalLock(data); - memcpy(buffer, value.Buffer(), size); - GlobalUnlock(data); - SetClipboardData(CF_UNICODETEXT, data); - CloseClipboard(); - return true; - } - return false; - } - } - } -} - -/*********************************************************************** -NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSDIALOGSERVICE.CPP -***********************************************************************/ -#include - -#pragma comment(lib, "Vfw32.lib") - -namespace vl -{ - namespace presentation - { - namespace windows - { - using namespace collections; - -/*********************************************************************** -WindowsDialogService -***********************************************************************/ - - WindowsDialogService::WindowsDialogService(HandleRetriver _handleRetriver) - :handleRetriver(_handleRetriver) - { - } - - INativeDialogService::MessageBoxButtonsOutput WindowsDialogService::ShowMessageBox( - INativeWindow* window, - const WString& text, - const WString& title, - MessageBoxButtonsInput buttons, - MessageBoxDefaultButton defaultButton, - MessageBoxIcons icon, - MessageBoxModalOptions modal) - { - WString realTitle=title; - if(title==L"" && window!=0) - { - realTitle=window->GetTitle(); - } - HWND hWnd=handleRetriver(window); - LPCTSTR lpText=text.Buffer(); - LPCTSTR lpCaption=realTitle.Buffer(); - UINT uType=0; - -#define MAP(A, B) case A: uType|=(B); break - switch(buttons) - { - MAP(DisplayOK, MB_OK); - MAP(DisplayOKCancel, MB_OKCANCEL); - MAP(DisplayYesNo, MB_YESNO); - MAP(DisplayYesNoCancel, MB_YESNOCANCEL); - MAP(DisplayRetryCancel, MB_RETRYCANCEL); - MAP(DisplayAbortRetryIgnore, MB_ABORTRETRYIGNORE); - MAP(DisplayCancelTryAgainContinue, MB_CANCELTRYCONTINUE); - } - switch(defaultButton) - { - MAP(DefaultFirst, MB_DEFBUTTON1); - MAP(DefaultSecond, MB_DEFBUTTON2); - MAP(DefaultThird, MB_DEFBUTTON3); - } - switch(icon) - { - MAP(IconError, MB_ICONERROR); - MAP(IconQuestion, MB_ICONQUESTION); - MAP(IconWarning, MB_ICONWARNING); - MAP(IconInformation, MB_ICONINFORMATION); - } - switch(modal) - { - MAP(ModalWindow, MB_APPLMODAL); - MAP(ModalSystem, MB_SYSTEMMODAL); - MAP(ModalTask, MB_TASKMODAL); - } -#undef MAP - - vint result=MessageBox(hWnd, lpText, lpCaption, uType); - switch(result) - { - case IDABORT: return SelectAbort; - case IDCANCEL: return SelectCancel; - case IDCONTINUE: return SelectContinue; - case IDIGNORE: return SelectIgnore; - case IDNO: return SelectNo; - case IDOK: return SelectOK; - case IDRETRY: return SelectRetry; - case IDTRYAGAIN: return SelectTryAgain; - case IDYES: return SelectYes; - default: return SelectOK; - } - } - - bool WindowsDialogService::ShowColorDialog(INativeWindow* window, Color& selection, bool selected, ColorDialogCustomColorOptions customColorOptions, Color* customColors) - { - CHOOSECOLOR chooseColor; - ZeroMemory(&chooseColor, sizeof(chooseColor)); - COLORREF customColorsBuffer[16]={0}; - if(customColors) - { - for(vint i=0;iFW_REGULAR; - selectionFont.italic=logFont.lfItalic!=FALSE; - selectionFont.underline=logFont.lfUnderline!=FALSE; - selectionFont.strikeline=logFont.lfStrikeOut!=FALSE; - selectionFont.size=-logFont.lfHeight; - - selectionColor=Color(GetRValue(chooseFont.rgbColors), GetGValue(chooseFont.rgbColors), GetBValue(chooseFont.rgbColors)); - } - return result!=FALSE; - } - - bool WindowsDialogService::ShowFileDialog(INativeWindow* window, collections::List& selectionFileNames, vint& selectionFilterIndex, FileDialogTypes dialogType, const WString& title, const WString& initialFileName, const WString& initialDirectory, const WString& defaultExtension, const WString& filter, FileDialogOptions options) - { - Array fileNamesBuffer(65536>initialFileName.Length()+1?65536:initialFileName.Length()+1); - wcscpy_s(&fileNamesBuffer[0], fileNamesBuffer.Count(), initialFileName.Buffer()); - - OPENFILENAME ofn; - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize=sizeof(ofn); - ofn.hwndOwner=handleRetriver(window); - ofn.hInstance=NULL; - ofn.lpstrCustomFilter=NULL; - ofn.nMaxCustFilter=0; - ofn.nFilterIndex=(int)selectionFilterIndex+1; - ofn.lpstrFile=&fileNamesBuffer[0]; - ofn.nMaxFile=(int)fileNamesBuffer.Count(); - ofn.lpstrFileTitle=NULL; - ofn.nMaxFileTitle=0; - ofn.lpstrInitialDir=initialDirectory==L""?NULL:initialDirectory.Buffer(); - ofn.lpstrTitle=title==L""?NULL:title.Buffer(); - ofn.lpstrDefExt=defaultExtension==L""?NULL:defaultExtension.Buffer(); - - List filterSeparators; - for(vint i=0;i filterBuffer(filter.Length()+2); - vint index=0; - for(vint i=0;i @@ -5504,438 +3540,688 @@ Helper Functions } /*********************************************************************** -NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSINPUTSERVICE.CPP +.\GRAPHICSELEMENT\WINDOWSDIRECT2D\GUIGRAPHICSWINDOWSDIRECT2D.CPP ***********************************************************************/ namespace vl { namespace presentation { - namespace windows + namespace elements { - bool WinIsKeyPressing(vint code) - { - return (GetKeyState((int)code)&0xF0)!=0; - } - - bool WinIsKeyToggled(vint code) - { - return (GetKeyState((int)code)&0x0F)!=0; - } /*********************************************************************** -WindowsInputService +GuiDirect2DElement ***********************************************************************/ - WString WindowsInputService::GetKeyNameInternal(vint code) + GuiDirect2DElement::GuiDirect2DElement() { - if (code < 8) return L"?"; - wchar_t name[256]={0}; - vint scanCode=MapVirtualKey((int)code, MAPVK_VK_TO_VSC)<<16; - switch(code) - { - case VK_INSERT: - case VK_DELETE: - case VK_HOME: - case VK_END: - case VK_PRIOR: - case VK_NEXT: - case VK_LEFT: - case VK_RIGHT: - case VK_UP: - case VK_DOWN: - scanCode|=1<<24; - break; - case VK_CLEAR: - case VK_LSHIFT: - case VK_RSHIFT: - case VK_LCONTROL: - case VK_RCONTROL: - case VK_LMENU: - case VK_RMENU: - return L"?"; - } - GetKeyNameText((int)scanCode, name, sizeof(name)/sizeof(*name)); - return name[0]?name:L"?"; - } - - void WindowsInputService::InitializeKeyNames() - { - for (vint i = 0; i < keyNames.Count(); i++) - { - keyNames[i] = GetKeyNameInternal(i); - if (keyNames[i] != L"?") - { - keys.Set(keyNames[i], i); - } - } - } - - WindowsInputService::WindowsInputService(HOOKPROC _mouseProc) - :ownerHandle(NULL) - ,mouseHook(NULL) - ,isTimerEnabled(false) - ,mouseProc(_mouseProc) - ,keyNames(146) - { - InitializeKeyNames(); - } - - void WindowsInputService::SetOwnerHandle(HWND handle) - { - ownerHandle=handle; - } - - void WindowsInputService::StartHookMouse() - { - if(!IsHookingMouse()) - { - mouseHook=SetWindowsHookEx(WH_MOUSE_LL, mouseProc, NULL, NULL); - } - } - - void WindowsInputService::StopHookMouse() - { - if(IsHookingMouse()) - { - UnhookWindowsHookEx(mouseHook); - mouseHook=NULL; - } - } - - bool WindowsInputService::IsHookingMouse() - { - return mouseHook!=NULL; - } - - void WindowsInputService::StartTimer() - { - if(!IsTimerEnabled()) - { - SetTimer(ownerHandle, 1, 16, NULL); - isTimerEnabled=true; - } - } - - void WindowsInputService::StopTimer() - { - if(IsTimerEnabled()) - { - KillTimer(ownerHandle, 1); - isTimerEnabled=false; - } - } - - bool WindowsInputService::IsTimerEnabled() - { - return isTimerEnabled; - } - - bool WindowsInputService::IsKeyPressing(vint code) - { - return WinIsKeyPressing(code); - } - - bool WindowsInputService::IsKeyToggled(vint code) - { - return WinIsKeyToggled(code); - } - - WString WindowsInputService::GetKeyName(vint code) - { - if (0 <= code && 0 < keyNames.Count()) - { - return keyNames[code]; - } - else - { - return L"?"; - } - } - - vint WindowsInputService::GetKey(const WString& name) - { - vint index = keys.Keys().IndexOf(name); - return index == -1 ? -1 : keys.Values()[index]; } } - } -} -/*********************************************************************** -NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSRESOURCESERVICE.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace windows + namespace elements_windows_d2d { + using namespace elements; + using namespace collections; -/*********************************************************************** -WindowsCursor -***********************************************************************/ - - WindowsCursor::WindowsCursor(HCURSOR _handle) - :handle(_handle) - ,isSystemCursor(false) - ,systemCursorType(INativeCursor::Arrow) + D2D1::ColorF GetD2DColor(Color color) { + return D2D1::ColorF(color.r/255.0f, color.g/255.0f, color.b/255.0f, color.a/255.0f); } - WindowsCursor::WindowsCursor(SystemCursorType type) - :handle(NULL) - ,isSystemCursor(true) - ,systemCursorType(type) +/*********************************************************************** +CachedResourceAllocator +***********************************************************************/ + + class CachedSolidBrushAllocator { - LPWSTR id=NULL; - switch(type) + DEFINE_CACHED_RESOURCE_ALLOCATOR(Color, ComPtr) + + IWindowsDirect2DRenderTarget* guiRenderTarget; + public: + CachedSolidBrushAllocator() + :guiRenderTarget(0) { - case SmallWaiting: - id=IDC_APPSTARTING; - break; - case LargeWaiting: - id=IDC_WAIT; - break; - case Arrow: - id=IDC_ARROW; - break; - case Cross: - id=IDC_CROSS; - break; - case Hand: - id=IDC_HAND; - break; - case Help: - id=IDC_HELP; - break; - case IBeam: - id=IDC_IBEAM; - break; - case SizeAll: - id=IDC_SIZEALL; - break; - case SizeNESW: - id=IDC_SIZENESW; - break; - case SizeNS: - id=IDC_SIZENS; - break; - case SizeNWSE: - id=IDC_SIZENWSE; - break; - case SizeWE: - id=IDC_SIZEWE; - break; } - handle=(HCURSOR)LoadImage(NULL, id, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE|LR_SHARED); - } - - bool WindowsCursor::IsSystemCursor() - { - return isSystemCursor; - } - INativeCursor::SystemCursorType WindowsCursor::GetSystemCursorType() - { - return systemCursorType; - } - - HCURSOR WindowsCursor::GetCursorHandle() - { - return handle; - } - -/*********************************************************************** -WindowsResourceService -***********************************************************************/ - - WindowsResourceService::WindowsResourceService() - { + void SetRenderTarget(IWindowsDirect2DRenderTarget* _guiRenderTarget) { - systemCursors.Resize(INativeCursor::SystemCursorCount); - for(vint i=0;i CreateInternal(Color color) + { + ID2D1SolidColorBrush* brush=0; + ID2D1RenderTarget* renderTarget=guiRenderTarget->GetDirect2DRenderTarget(); + HRESULT hr=renderTarget->CreateSolidColorBrush(GetD2DColor(color), &brush); + if(!FAILED(hr)) { - systemCursors[i]=new WindowsCursor((INativeCursor::SystemCursorType)i); + return brush; + } + else + { + return 0; } } + }; + + class CachedLinearBrushAllocator + { + typedef Pair ColorPair; + DEFINE_CACHED_RESOURCE_ALLOCATOR(ColorPair, ComPtr) + + IWindowsDirect2DRenderTarget* guiRenderTarget; + public: + CachedLinearBrushAllocator() + :guiRenderTarget(0) { - NONCLIENTMETRICS metrics; - metrics.cbSize=sizeof(NONCLIENTMETRICS); - SystemParametersInfo(SPI_GETNONCLIENTMETRICS, metrics.cbSize, &metrics, 0); - if(!*metrics.lfMessageFont.lfFaceName) + } + + void SetRenderTarget(IWindowsDirect2DRenderTarget* _guiRenderTarget) + { + guiRenderTarget=_guiRenderTarget; + } + + ComPtr CreateInternal(ColorPair colors) + { + ID2D1RenderTarget* renderTarget=guiRenderTarget->GetDirect2DRenderTarget(); + ID2D1GradientStopCollection* stopCollection=0; { - metrics.cbSize=sizeof(NONCLIENTMETRICS)-sizeof(metrics.iPaddedBorderWidth); - SystemParametersInfo(SPI_GETNONCLIENTMETRICS, metrics.cbSize, &metrics, 0); + D2D1_GRADIENT_STOP stops[2]; + stops[0].color=GetD2DColor(colors.key); + stops[0].position=0.0f; + stops[1].color=GetD2DColor(colors.value); + stops[1].position=1.0f; + + HRESULT hr=renderTarget->CreateGradientStopCollection( + stops, + 2, + D2D1_GAMMA_2_2, + D2D1_EXTEND_MODE_CLAMP, + &stopCollection); + if(FAILED(hr)) return 0; } - defaultFont.fontFamily=metrics.lfMessageFont.lfFaceName; - defaultFont.size=metrics.lfMessageFont.lfHeight; - if(defaultFont.size<0) + + ID2D1LinearGradientBrush* brush=0; { - defaultFont.size=-defaultFont.size; + D2D1_POINT_2F points[2]={{0, 0}, {0, 0}}; + HRESULT hr=renderTarget->CreateLinearGradientBrush( + D2D1::LinearGradientBrushProperties(points[0], points[1]), + stopCollection, + &brush); + stopCollection->Release(); + if(FAILED(hr)) return 0; + } + return brush; + } + }; + + class CachedTextFormatAllocator + { + private: + DEFINE_CACHED_RESOURCE_ALLOCATOR(FontProperties, Ptr) + public: + + static ComPtr CreateDirect2DFont(const FontProperties& fontProperties) + { + IDWriteFactory* dwriteFactory=GetWindowsDirect2DObjectProvider()->GetDirectWriteFactory(); + IDWriteTextFormat* format=0; + HRESULT hr=dwriteFactory->CreateTextFormat( + fontProperties.fontFamily.Buffer(), + NULL, + (fontProperties.bold?DWRITE_FONT_WEIGHT_BOLD:DWRITE_FONT_WEIGHT_NORMAL), + (fontProperties.italic?DWRITE_FONT_STYLE_ITALIC:DWRITE_FONT_STYLE_NORMAL), + DWRITE_FONT_STRETCH_NORMAL, + (FLOAT)fontProperties.size, + L"", + &format); + if(!FAILED(hr)) + { + format->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP); + return format; + } + else + { + return 0; } } - } - INativeCursor* WindowsResourceService::GetSystemCursor(INativeCursor::SystemCursorType type) - { - vint index=(vint)type; - if(0<=index && index CreateInternal(const FontProperties& fontProperties) { - return systemCursors[index].Obj(); + Ptr textFormat=new Direct2DTextFormatPackage; + textFormat->textFormat=CreateDirect2DFont(fontProperties); + textFormat->trimming.granularity=DWRITE_TRIMMING_GRANULARITY_CHARACTER; + textFormat->trimming.delimiter=0; + textFormat->trimming.delimiterCount=0; + + IDWriteInlineObject* ellipseInlineObject=0; + GetWindowsDirect2DObjectProvider()->GetDirectWriteFactory()->CreateEllipsisTrimmingSign(textFormat->textFormat.Obj(), &ellipseInlineObject); + textFormat->ellipseInlineObject=ellipseInlineObject; + return textFormat; } - else + }; + + class CachedCharMeasurerAllocator + { + DEFINE_CACHED_RESOURCE_ALLOCATOR(FontProperties, Ptr) + + protected: + class Direct2DCharMeasurer : public text::CharMeasurer { - return 0; - } - } + protected: + ComPtr font; + vint size; - INativeCursor* WindowsResourceService::GetDefaultSystemCursor() - { - return GetSystemCursor(INativeCursor::Arrow); - } - - FontProperties WindowsResourceService::GetDefaultFont() - { - return defaultFont; - } - - void WindowsResourceService::SetDefaultFont(const FontProperties& value) - { - defaultFont=value; - } - } - } -} - -/*********************************************************************** -NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSSCREENSERVICE.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace windows - { - -/*********************************************************************** -WindowsScreen -***********************************************************************/ - - WindowsScreen::WindowsScreen() - { - monitor=NULL; - } - - Rect WindowsScreen::GetBounds() - { - MONITORINFOEX info; - info.cbSize=sizeof(MONITORINFOEX); - GetMonitorInfo(monitor, &info); - return Rect(info.rcMonitor.left, info.rcMonitor.top, info.rcMonitor.right, info.rcMonitor.bottom); - } - - Rect WindowsScreen::GetClientBounds() - { - MONITORINFOEX info; - info.cbSize=sizeof(MONITORINFOEX); - GetMonitorInfo(monitor, &info); - return Rect(info.rcWork.left, info.rcWork.top, info.rcWork.right, info.rcWork.bottom); - } - - WString WindowsScreen::GetName() - { - MONITORINFOEX info; - info.cbSize=sizeof(MONITORINFOEX); - GetMonitorInfo(monitor, &info); - - wchar_t buffer[sizeof(info.szDevice)/sizeof(*info.szDevice)+1]; - memset(buffer, 0, sizeof(buffer)); - memcpy(buffer, info.szDevice, sizeof(info.szDevice)); - return buffer; - } - - bool WindowsScreen::IsPrimary() - { - MONITORINFOEX info; - info.cbSize=sizeof(MONITORINFOEX); - GetMonitorInfo(monitor, &info); - return info.dwFlags==MONITORINFOF_PRIMARY; - } - -/*********************************************************************** -WindowsScreenService -***********************************************************************/ - - WindowsScreenService::WindowsScreenService(HandleRetriver _handleRetriver) - :handleRetriver(_handleRetriver) - { - } - - BOOL CALLBACK WindowsScreenService::MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) - { - MonitorEnumProcData* data=(MonitorEnumProcData*)dwData; - if(data->currentScreen==data->screenService->screens.Count()) - { - data->screenService->screens.Add(new WindowsScreen()); - } - data->screenService->screens[data->currentScreen]->monitor=hMonitor; - data->currentScreen++; - return TRUE; - } - - void WindowsScreenService::RefreshScreenInformation() - { - for(vint i=0;imonitor=NULL; - } - MonitorEnumProcData data; - data.screenService=this; - data.currentScreen=0; - EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM)(&data)); - } - - vint WindowsScreenService::GetScreenCount() - { - RefreshScreenInformation(); - return GetSystemMetrics(SM_CMONITORS); - } - - INativeScreen* WindowsScreenService::GetScreen(vint index) - { - RefreshScreenInformation(); - return screens[index].Obj(); - } - - INativeScreen* WindowsScreenService::GetScreen(INativeWindow* window) - { - RefreshScreenInformation(); - HWND hwnd=handleRetriver(window); - if(hwnd) - { - HMONITOR monitor=MonitorFromWindow(hwnd, MONITOR_DEFAULTTONULL); - if(monitor!=NULL) + Size MeasureInternal(wchar_t character, IGuiGraphicsRenderTarget* renderTarget) { - for(vint i=0;iGetDirectWriteFactory()->CreateTextLayout( + &character, + 1, + font.Obj(), + 0, + 0, + &textLayout); + if(!FAILED(hr)) { - if(screens[i]->monitor==monitor) + DWRITE_TEXT_METRICS metrics; + hr=textLayout->GetMetrics(&metrics); + if(!FAILED(hr)) { - return screens[i].Obj(); + charSize=Size((vint)ceil(metrics.widthIncludingTrailingWhitespace), (vint)ceil(metrics.height)); } + textLayout->Release(); + } + return charSize; + } + + vint MeasureWidthInternal(wchar_t character, IGuiGraphicsRenderTarget* renderTarget) + { + return MeasureInternal(character, renderTarget).x; + } + + vint GetRowHeightInternal(IGuiGraphicsRenderTarget* renderTarget) + { + return MeasureInternal(L' ', renderTarget).y; + } + public: + Direct2DCharMeasurer(ComPtr _font, vint _size) + :text::CharMeasurer(_size) + ,size(_size) + ,font(_font) + { + } + }; + public: + Ptr CreateInternal(const FontProperties& value) + { + return new Direct2DCharMeasurer(CachedTextFormatAllocator::CreateDirect2DFont(value), value.size); + } + }; + +/*********************************************************************** +WindowsDirect2DRenderTarget +***********************************************************************/ + + class WindowsDirect2DImageFrameCache : public Object, public INativeImageFrameCache + { + protected: + IWindowsDirect2DRenderTarget* renderTarget; + INativeImageFrame* cachedFrame; + ComPtr bitmap; + ComPtr disabledBitmap; + public: + WindowsDirect2DImageFrameCache(IWindowsDirect2DRenderTarget* _renderTarget) + :renderTarget(_renderTarget) + { + } + + ~WindowsDirect2DImageFrameCache() + { + } + + void OnAttach(INativeImageFrame* frame)override + { + cachedFrame=frame; + ID2D1Bitmap* d2dBitmap=0; + HRESULT hr=renderTarget->GetDirect2DRenderTarget()->CreateBitmapFromWicBitmap( + GetWindowsDirect2DObjectProvider()->GetWICBitmap(frame), + &d2dBitmap + ); + if(SUCCEEDED(hr)) + { + bitmap=d2dBitmap; + } + } + + void OnDetach(INativeImageFrame* frame)override + { + renderTarget->DestroyBitmapCache(cachedFrame); + } + + INativeImageFrame* GetFrame() + { + return cachedFrame; + } + + ComPtr GetBitmap(bool enabled) + { + if(enabled) + { + return bitmap; + } + else + { + if(!disabledBitmap) + { + IWICBitmap* frameBitmap=GetWindowsDirect2DObjectProvider()->GetWICBitmap(cachedFrame); + ID2D1Bitmap* d2dBitmap=0; + HRESULT hr=renderTarget->GetDirect2DRenderTarget()->CreateBitmapFromWicBitmap( + frameBitmap, + &d2dBitmap + ); + if(SUCCEEDED(hr)) + { + disabledBitmap=d2dBitmap; + + WICRect rect; + rect.X=0; + rect.Y=0; + rect.Width=bitmap->GetPixelSize().width; + rect.Height=bitmap->GetPixelSize().height; + BYTE* buffer=new BYTE[rect.Width*rect.Height*4]; + hr=frameBitmap->CopyPixels(&rect, rect.Width*4, rect.Width*rect.Height*4, buffer); + if(SUCCEEDED(hr)) + { + vint count=rect.Width*rect.Height; + BYTE* read=buffer; + for(vint i=0;iCopyFromMemory(&d2dRect, buffer, rect.Width*4); + } + delete[] buffer; + } + } + return disabledBitmap; + } + } + }; + + class WindowsDirect2DRenderTarget : public Object, public IWindowsDirect2DRenderTarget + { + typedef SortedList> ImageCacheList; + protected: + INativeWindow* window; + ID2D1RenderTarget* d2dRenderTarget = nullptr; + List clippers; + vint clipperCoverWholeTargetCounter = 0; + + CachedSolidBrushAllocator solidBrushes; + CachedLinearBrushAllocator linearBrushes; + ImageCacheList imageCaches; + + ComPtr noAntialiasParams; + ComPtr horizontalAntialiasParams; + ComPtr bidirectionalAntialiasParams; + + ComPtr CreateRenderingParams(DWRITE_RENDERING_MODE renderingMode, IDWriteRenderingParams* defaultParams, IDWriteFactory* dwriteFactory) + { + IDWriteRenderingParams* renderingParams=0; + FLOAT gamma=defaultParams->GetGamma(); + FLOAT enhancedContrast=defaultParams->GetEnhancedContrast(); + FLOAT clearTypeLevel=defaultParams->GetClearTypeLevel(); + DWRITE_PIXEL_GEOMETRY pixelGeometry=defaultParams->GetPixelGeometry(); + HRESULT hr=dwriteFactory->CreateCustomRenderingParams( + gamma, + enhancedContrast, + clearTypeLevel, + pixelGeometry, + renderingMode, + &renderingParams); + if(!FAILED(hr)) + { + return renderingParams; + } + else + { + return 0; + } + } + public: + WindowsDirect2DRenderTarget(INativeWindow* _window) + :window(_window) + { + solidBrushes.SetRenderTarget(this); + linearBrushes.SetRenderTarget(this); + + IDWriteFactory* dwriteFactory=GetWindowsDirect2DObjectProvider()->GetDirectWriteFactory(); + IDWriteRenderingParams* defaultParams=0; + HRESULT hr=dwriteFactory->CreateRenderingParams(&defaultParams); + if(!FAILED(hr)) + { + noAntialiasParams=CreateRenderingParams(DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL, defaultParams, dwriteFactory); + horizontalAntialiasParams=CreateRenderingParams(DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL, defaultParams, dwriteFactory); + bidirectionalAntialiasParams=CreateRenderingParams(DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC, defaultParams, dwriteFactory); + defaultParams->Release(); + } + } + + ~WindowsDirect2DRenderTarget() + { + while(imageCaches.Count()) + { + Ptr cache=imageCaches[imageCaches.Count()-1]; + cache->GetFrame()->RemoveCache(this); + } + } + + ID2D1RenderTarget* GetDirect2DRenderTarget()override + { + return d2dRenderTarget ? d2dRenderTarget : GetWindowsDirect2DObjectProvider()->GetNativeWindowDirect2DRenderTarget(window); + } + + ComPtr GetBitmap(INativeImageFrame* frame, bool enabled)override + { + Ptr cache=frame->GetCache(this); + if(cache) + { + return cache.Cast()->GetBitmap(enabled); + } + else + { + Ptr d2dCache=new WindowsDirect2DImageFrameCache(this); + if(frame->SetCache(this, d2dCache)) + { + imageCaches.Add(d2dCache); + return d2dCache->GetBitmap(enabled); + } + else + { + return 0; } } } - return 0; + + void DestroyBitmapCache(INativeImageFrame* frame)override + { + WindowsDirect2DImageFrameCache* cache=frame->GetCache(this).Cast().Obj(); + imageCaches.Remove(cache); + } + + void SetTextAntialias(bool antialias, bool verticalAntialias)override + { + ComPtr params; + if(!antialias) + { + params=noAntialiasParams; + } + else if(!verticalAntialias) + { + params=horizontalAntialiasParams; + } + else + { + params=bidirectionalAntialiasParams; + } + if(params && d2dRenderTarget) + { + d2dRenderTarget->SetTextRenderingParams(params.Obj()); + } + } + + void StartRendering()override + { + d2dRenderTarget = GetWindowsDirect2DObjectProvider()->GetNativeWindowDirect2DRenderTarget(window); + CHECK_ERROR(d2dRenderTarget, L"vl::presentation::elements_windows_d2d::WindowsDirect2DRenderTarget::StartRendering()#Invalid render target."); + + GetWindowsDirect2DObjectProvider()->StartRendering(window); + } + + RenderTargetFailure StopRendering()override + { + CHECK_ERROR(d2dRenderTarget, L"vl::presentation::elements_windows_d2d::WindowsDirect2DRenderTarget::StartRendering()#Invalid render target."); + auto result = GetWindowsDirect2DObjectProvider()->StopRenderingAndPresent(window); + d2dRenderTarget = nullptr; + return result; + } + + void PushClipper(Rect clipper)override + { + if(clipperCoverWholeTargetCounter>0) + { + clipperCoverWholeTargetCounter++; + } + else + { + Rect previousClipper=GetClipper(); + Rect currentClipper; + + currentClipper.x1=(previousClipper.x1>clipper.x1?previousClipper.x1:clipper.x1); + currentClipper.y1=(previousClipper.y1>clipper.y1?previousClipper.y1:clipper.y1); + currentClipper.x2=(previousClipper.x2PushAxisAlignedClip( + D2D1::RectF((FLOAT)currentClipper.x1, (FLOAT)currentClipper.y1, (FLOAT)currentClipper.x2, (FLOAT)currentClipper.y2), + D2D1_ANTIALIAS_MODE_PER_PRIMITIVE + ); + } + else + { + clipperCoverWholeTargetCounter++; + } + } + } + + void PopClipper()override + { + if(clipperCoverWholeTargetCounter>0) + { + clipperCoverWholeTargetCounter--; + } + else if(clippers.Count()>0) + { + clippers.RemoveAt(clippers.Count()-1); + d2dRenderTarget->PopAxisAlignedClip(); + } + } + + Rect GetClipper()override + { + if(clippers.Count()==0) + { + return Rect(Point(0, 0), window->GetClientSize()); + } + else + { + return clippers[clippers.Count()-1]; + } + } + + bool IsClipperCoverWholeTarget()override + { + return clipperCoverWholeTargetCounter>0; + } + + ID2D1SolidColorBrush* CreateDirect2DBrush(Color color)override + { + return solidBrushes.Create(color).Obj(); + } + + void DestroyDirect2DBrush(Color color)override + { + solidBrushes.Destroy(color); + } + + ID2D1LinearGradientBrush* CreateDirect2DLinearBrush(Color c1, Color c2)override + { + return linearBrushes.Create(Pair(c1, c2)).Obj(); + } + + void DestroyDirect2DLinearBrush(Color c1, Color c2)override + { + linearBrushes.Destroy(Pair(c1, c2)); + } + }; + +/*********************************************************************** +WindowsGDIResourceManager +***********************************************************************/ + + class WindowsDirect2DResourceManager : public GuiGraphicsResourceManager, public IWindowsDirect2DResourceManager, public INativeControllerListener + { + protected: + SortedList> renderTargets; + Ptr layoutProvider; + + CachedTextFormatAllocator textFormats; + CachedCharMeasurerAllocator charMeasurers; + public: + WindowsDirect2DResourceManager() + { + layoutProvider=new WindowsDirect2DLayoutProvider; + } + + IGuiGraphicsRenderTarget* GetRenderTarget(INativeWindow* window)override + { + return GetWindowsDirect2DObjectProvider()->GetBindedRenderTarget(window); + } + + void RecreateRenderTarget(INativeWindow* window)override + { + NativeWindowDestroying(window); + GetWindowsDirect2DObjectProvider()->RecreateRenderTarget(window); + NativeWindowCreated(window); + } + + void ResizeRenderTarget(INativeWindow* window) + { + GetWindowsDirect2DObjectProvider()->ResizeRenderTarget(window); + } + + IGuiGraphicsLayoutProvider* GetLayoutProvider()override + { + return layoutProvider.Obj(); + } + + void NativeWindowCreated(INativeWindow* window)override + { + WindowsDirect2DRenderTarget* renderTarget=new WindowsDirect2DRenderTarget(window); + renderTargets.Add(renderTarget); + GetWindowsDirect2DObjectProvider()->SetBindedRenderTarget(window, renderTarget); + } + + void NativeWindowDestroying(INativeWindow* window)override + { + WindowsDirect2DRenderTarget* renderTarget=dynamic_cast(GetWindowsDirect2DObjectProvider()->GetBindedRenderTarget(window)); + GetWindowsDirect2DObjectProvider()->SetBindedRenderTarget(window, 0); + renderTargets.Remove(renderTarget); + } + + Direct2DTextFormatPackage* CreateDirect2DTextFormat(const FontProperties& fontProperties)override + { + return textFormats.Create(fontProperties).Obj(); + } + + void DestroyDirect2DTextFormat(const FontProperties& fontProperties)override + { + textFormats.Destroy(fontProperties); + } + + Ptr CreateDirect2DCharMeasurer(const FontProperties& fontProperties)override + { + return charMeasurers.Create(fontProperties); + } + + void DestroyDirect2DCharMeasurer(const FontProperties& fontProperties)override + { + charMeasurers.Destroy(fontProperties); + } + }; + } + + namespace elements_windows_d2d + { + IWindowsDirect2DResourceManager* windowsDirect2DResourceManager=0; + + IWindowsDirect2DResourceManager* GetWindowsDirect2DResourceManager() + { + return windowsDirect2DResourceManager; + } + + void SetWindowsDirect2DResourceManager(IWindowsDirect2DResourceManager* resourceManager) + { + windowsDirect2DResourceManager=resourceManager; + } + +/*********************************************************************** +OS Supporting +***********************************************************************/ + + IWindowsDirect2DObjectProvider* windowsDirect2DObjectProvider=0; + + IWindowsDirect2DObjectProvider* GetWindowsDirect2DObjectProvider() + { + return windowsDirect2DObjectProvider; + } + + void SetWindowsDirect2DObjectProvider(IWindowsDirect2DObjectProvider* provider) + { + windowsDirect2DObjectProvider=provider; } } } } /*********************************************************************** -GRAPHICSELEMENT\WINDOWSGDI\GUIGRAPHICSLAYOUTPROVIDERWINDOWSGDI.CPP +NativeMain +***********************************************************************/ + +using namespace vl::presentation; +using namespace vl::presentation::elements; + +void RendererMainDirect2D() +{ + elements_windows_d2d::WindowsDirect2DResourceManager resourceManager; + SetGuiGraphicsResourceManager(&resourceManager); + elements_windows_d2d::SetWindowsDirect2DResourceManager(&resourceManager); + GetCurrentController()->CallbackService()->InstallListener(&resourceManager); + + elements_windows_d2d::GuiSolidBorderElementRenderer::Register(); + elements_windows_d2d::GuiRoundBorderElementRenderer::Register(); + elements_windows_d2d::Gui3DBorderElementRenderer::Register(); + elements_windows_d2d::Gui3DSplitterElementRenderer::Register(); + elements_windows_d2d::GuiSolidBackgroundElementRenderer::Register(); + elements_windows_d2d::GuiGradientBackgroundElementRenderer::Register(); + elements_windows_d2d::GuiSolidLabelElementRenderer::Register(); + elements_windows_d2d::GuiImageFrameElementRenderer::Register(); + elements_windows_d2d::GuiPolygonElementRenderer::Register(); + elements_windows_d2d::GuiColorizedTextElementRenderer::Register(); + elements_windows_d2d::GuiDirect2DElementRenderer::Register(); + elements::GuiDocumentElement::GuiDocumentElementRenderer::Register(); + + GuiApplicationMain(); + elements_windows_d2d::SetWindowsDirect2DResourceManager(0); + SetGuiGraphicsResourceManager(0); +} + +/*********************************************************************** +.\GRAPHICSELEMENT\WINDOWSGDI\GUIGRAPHICSLAYOUTPROVIDERWINDOWSGDI.CPP ***********************************************************************/ namespace vl @@ -6271,1020 +4557,7 @@ WindowsGDILayoutProvider } /*********************************************************************** -GRAPHICSELEMENT\WINDOWSGDI\GUIGRAPHICSRENDERERSWINDOWSGDI.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace elements_windows_gdi - { - using namespace windows; - using namespace collections; - -/*********************************************************************** -GuiSolidBorderElementRenderer -***********************************************************************/ - - void GuiSolidBorderElementRenderer::InitializeInternal() - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - oldColor=element->GetColor(); - pen=resourceManager->CreateGdiPen(oldColor); - brush=resourceManager->CreateGdiBrush(Color(0, 0, 0, 0)); - } - - void GuiSolidBorderElementRenderer::FinalizeInternal() - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - resourceManager->DestroyGdiPen(oldColor); - resourceManager->DestroyGdiBrush(Color(0, 0, 0, 0)); - } - - void GuiSolidBorderElementRenderer::RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget) - { - } - - void GuiSolidBorderElementRenderer::Render(Rect bounds) - { - if(oldColor.a>0) - { - renderTarget->GetDC()->SetBrush(brush); - renderTarget->GetDC()->SetPen(pen); - switch(element->GetShape()) - { - case ElementShape::Rectangle: - renderTarget->GetDC()->Rectangle(bounds.Left(), bounds.Top(), bounds.Right()-1, bounds.Bottom()-1); - break; - case ElementShape::Ellipse: - renderTarget->GetDC()->Ellipse(bounds.Left(), bounds.Top(), bounds.Right()-1, bounds.Bottom()-1); - break; - } - } - } - - void GuiSolidBorderElementRenderer::OnElementStateChanged() - { - Color color=element->GetColor(); - if(oldColor!=color) - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - resourceManager->DestroyGdiPen(oldColor); - oldColor=color; - pen=resourceManager->CreateGdiPen(oldColor); - } - } - -/*********************************************************************** -GuiRoundBorderElementRenderer -***********************************************************************/ - - void GuiRoundBorderElementRenderer::InitializeInternal() - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - oldColor=element->GetColor(); - pen=resourceManager->CreateGdiPen(oldColor); - brush=resourceManager->CreateGdiBrush(Color(0, 0, 0, 0)); - } - - void GuiRoundBorderElementRenderer::FinalizeInternal() - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - resourceManager->DestroyGdiPen(oldColor); - resourceManager->DestroyGdiBrush(Color(0, 0, 0, 0)); - } - - void GuiRoundBorderElementRenderer::RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget) - { - } - - void GuiRoundBorderElementRenderer::Render(Rect bounds) - { - if(oldColor.a>0) - { - vint ellipse=element->GetRadius()*2; - renderTarget->GetDC()->SetBrush(brush); - renderTarget->GetDC()->SetPen(pen); - renderTarget->GetDC()->RoundRect(bounds.Left(), bounds.Top(), bounds.Right()-1, bounds.Bottom()-1, ellipse, ellipse); - } - } - - void GuiRoundBorderElementRenderer::OnElementStateChanged() - { - Color color=element->GetColor(); - if(oldColor!=color) - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - resourceManager->DestroyGdiPen(oldColor); - oldColor=color; - pen=resourceManager->CreateGdiPen(oldColor); - } - } - -/*********************************************************************** -Gui3DBorderElementRenderer -***********************************************************************/ - - void Gui3DBorderElementRenderer::InitializeInternal() - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - oldColor1=element->GetColor1(); - oldColor2=element->GetColor2(); - pen1=resourceManager->CreateGdiPen(oldColor1); - pen2=resourceManager->CreateGdiPen(oldColor2); - } - - void Gui3DBorderElementRenderer::FinalizeInternal() - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - resourceManager->DestroyGdiPen(oldColor1); - resourceManager->DestroyGdiPen(oldColor2); - } - - void Gui3DBorderElementRenderer::RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget) - { - } - - void Gui3DBorderElementRenderer::Render(Rect bounds) - { - if(oldColor1.a>0) - { - renderTarget->GetDC()->SetPen(pen1); - renderTarget->GetDC()->MoveTo(bounds.x1, bounds.y1); - renderTarget->GetDC()->LineTo(bounds.x2, bounds.y1); - renderTarget->GetDC()->MoveTo(bounds.x1, bounds.y1); - renderTarget->GetDC()->LineTo(bounds.x1, bounds.y2); - } - if(oldColor2.a>0) - { - renderTarget->GetDC()->SetPen(pen2); - renderTarget->GetDC()->MoveTo(bounds.x2-1, bounds.y2-1); - renderTarget->GetDC()->LineTo(bounds.x1, bounds.y2-1); - renderTarget->GetDC()->MoveTo(bounds.x2-1, bounds.y2-1); - renderTarget->GetDC()->LineTo(bounds.x2-1, bounds.y1); - } - } - - void Gui3DBorderElementRenderer::OnElementStateChanged() - { - Color color1=element->GetColor1(); - if(oldColor1!=color1) - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - resourceManager->DestroyGdiPen(oldColor1); - oldColor1=color1; - pen1=resourceManager->CreateGdiPen(oldColor1); - } - - Color color2=element->GetColor2(); - if(oldColor2!=color2) - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - resourceManager->DestroyGdiPen(oldColor2); - oldColor2=color2; - pen2=resourceManager->CreateGdiPen(oldColor2); - } - } - -/*********************************************************************** -Gui3DSplitterElementRenderer -***********************************************************************/ - - void Gui3DSplitterElementRenderer::InitializeInternal() - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - oldColor1=element->GetColor1(); - oldColor2=element->GetColor2(); - pen1=resourceManager->CreateGdiPen(oldColor1); - pen2=resourceManager->CreateGdiPen(oldColor2); - } - - void Gui3DSplitterElementRenderer::FinalizeInternal() - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - resourceManager->DestroyGdiPen(oldColor1); - resourceManager->DestroyGdiPen(oldColor2); - } - - void Gui3DSplitterElementRenderer::RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget) - { - } - - void Gui3DSplitterElementRenderer::Render(Rect bounds) - { - Point p11, p12, p21, p22; - switch(element->GetDirection()) - { - case Gui3DSplitterElement::Horizontal: - { - vint y=bounds.y1+bounds.Height()/2-1; - p11=Point(bounds.x1, y); - p12=Point(bounds.x2, y); - p21=Point(bounds.x1, y+1); - p22=Point(bounds.x2, y+1); - } - break; - case Gui3DSplitterElement::Vertical: - { - vint x=bounds.x1+bounds.Width()/2-1; - p11=Point(x, bounds.y1); - p12=Point(x, bounds.y2); - p21=Point(x+1, bounds.y1); - p22=Point(x+1, bounds.y2); - } - break; - } - if(oldColor1.a>0) - { - renderTarget->GetDC()->SetPen(pen1); - renderTarget->GetDC()->MoveTo(p11.x, p11.y); - renderTarget->GetDC()->LineTo(p12.x, p12.y); - } - if(oldColor2.a>0) - { - renderTarget->GetDC()->SetPen(pen2); - renderTarget->GetDC()->MoveTo(p21.x, p21.y); - renderTarget->GetDC()->LineTo(p22.x, p22.y); - } - } - - void Gui3DSplitterElementRenderer::OnElementStateChanged() - { - Color color1=element->GetColor1(); - if(oldColor1!=color1) - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - resourceManager->DestroyGdiPen(oldColor1); - oldColor1=color1; - pen1=resourceManager->CreateGdiPen(oldColor1); - } - - Color color2=element->GetColor2(); - if(oldColor2!=color2) - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - resourceManager->DestroyGdiPen(oldColor2); - oldColor2=color2; - pen2=resourceManager->CreateGdiPen(oldColor2); - } - } - -/*********************************************************************** -GuiSolidBackgroundElementRenderer -***********************************************************************/ - - void GuiSolidBackgroundElementRenderer::InitializeInternal() - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - oldColor=element->GetColor(); - pen=resourceManager->CreateGdiPen(oldColor); - brush=resourceManager->CreateGdiBrush(oldColor); - } - - void GuiSolidBackgroundElementRenderer::FinalizeInternal() - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - resourceManager->DestroyGdiPen(oldColor); - resourceManager->DestroyGdiBrush(oldColor); - } - - void GuiSolidBackgroundElementRenderer::RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget) - { - } - - void GuiSolidBackgroundElementRenderer::Render(Rect bounds) - { - if(oldColor.a>0) - { - renderTarget->GetDC()->SetPen(pen); - renderTarget->GetDC()->SetBrush(brush); - switch(element->GetShape()) - { - case ElementShape::Rectangle: - renderTarget->GetDC()->FillRect(bounds.Left(), bounds.Top(), bounds.Right(), bounds.Bottom()); - break; - case ElementShape::Ellipse: - renderTarget->GetDC()->Ellipse(bounds.Left(), bounds.Top(), bounds.Right()-1, bounds.Bottom()-1); - break; - } - } - } - - void GuiSolidBackgroundElementRenderer::OnElementStateChanged() - { - Color color=element->GetColor(); - if(oldColor!=color) - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - resourceManager->DestroyGdiPen(oldColor); - resourceManager->DestroyGdiBrush(oldColor); - oldColor=color; - pen=resourceManager->CreateGdiPen(oldColor); - brush=resourceManager->CreateGdiBrush(oldColor); - } - } - -/*********************************************************************** -GuiGradientBackgroundElementRenderer -***********************************************************************/ - - void GuiGradientBackgroundElementRenderer::InitializeInternal() - { - } - - void GuiGradientBackgroundElementRenderer::FinalizeInternal() - { - } - - void GuiGradientBackgroundElementRenderer::RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget) - { - } - - void GuiGradientBackgroundElementRenderer::Render(Rect bounds) - { - Color color1=element->GetColor1(); - Color color2=element->GetColor2(); - if(color1.a>0 || color2.a>0) - { - TRIVERTEX vertices[4]; - GRADIENT_TRIANGLE triangles[2]; - - vertices[0].x=(int)bounds.x1; - vertices[0].y=(int)bounds.y1; - vertices[1].x=(int)bounds.x1; - vertices[1].y=(int)bounds.y2; - vertices[2].x=(int)bounds.x2; - vertices[2].y=(int)bounds.y2; - vertices[3].x=(int)bounds.x2; - vertices[3].y=(int)bounds.y1; - - triangles[0].Vertex1=0; - triangles[0].Vertex2=1; - triangles[0].Vertex3=2; - triangles[1].Vertex1=0; - triangles[1].Vertex2=2; - triangles[1].Vertex3=3; - - if(element->GetDirection()==GuiGradientBackgroundElement::Horizontal) - { - vertices[0].Red=color1.r<<8; - vertices[0].Green=color1.g<<8; - vertices[0].Blue=color1.b<<8; - vertices[0].Alpha=0xFF00; - - vertices[1].Red=color1.r<<8; - vertices[1].Green=color1.g<<8; - vertices[1].Blue=color1.b<<8; - vertices[1].Alpha=0xFF00; - - vertices[2].Red=color2.r<<8; - vertices[2].Green=color2.g<<8; - vertices[2].Blue=color2.b<<8; - vertices[2].Alpha=0xFF00; - - vertices[3].Red=color2.r<<8; - vertices[3].Green=color2.g<<8; - vertices[3].Blue=color2.b<<8; - vertices[3].Alpha=0xFF00; - } - else - { - vertices[0].Red=color1.r<<8; - vertices[0].Green=color1.g<<8; - vertices[0].Blue=color1.b<<8; - vertices[0].Alpha=0xFF00; - - vertices[1].Red=color2.r<<8; - vertices[1].Green=color2.g<<8; - vertices[1].Blue=color2.b<<8; - vertices[1].Alpha=0xFF00; - - vertices[2].Red=color2.r<<8; - vertices[2].Green=color2.g<<8; - vertices[2].Blue=color2.b<<8; - vertices[2].Alpha=0xFF00; - - vertices[3].Red=color1.r<<8; - vertices[3].Green=color1.g<<8; - vertices[3].Blue=color1.b<<8; - vertices[3].Alpha=0xFF00; - } - - switch(element->GetShape()) - { - case ElementShape::Rectangle: - { - renderTarget->GetDC()->GradientTriangle(vertices, 6, triangles, 2); - } - break; - case ElementShape::Ellipse: - { - Ptr ellipseRegion=new WinRegion(bounds.x1, bounds.y1, bounds.x2+1, bounds.y2+1, false); - Ptr oldRegion=renderTarget->GetDC()->GetClipRegion(); - Ptr newRegion=new WinRegion(oldRegion, ellipseRegion, RGN_AND); - renderTarget->GetDC()->ClipRegion(newRegion); - renderTarget->GetDC()->GradientTriangle(vertices, 6, triangles, 2); - renderTarget->GetDC()->ClipRegion(oldRegion); - } - break; - } - } - } - - void GuiGradientBackgroundElementRenderer::OnElementStateChanged() - { - } - -/*********************************************************************** -GuiSolidLabelElementRenderer -***********************************************************************/ - - void GuiSolidLabelElementRenderer::UpdateMinSize() - { - if(renderTarget) - { - renderTarget->GetDC()->SetFont(font); - SIZE size={0}; - const WString& text=element->GetText(); - if(element->GetWrapLine()) - { - if(element->GetWrapLineHeightCalculation()) - { - if(oldMaxWidth==-1 || text.Length()==0) - { - size=renderTarget->GetDC()->MeasureBuffer(L" "); - } - else - { - size=renderTarget->GetDC()->MeasureWrapLineString(text, oldMaxWidth); - } - } - } - else - { - size=text.Length()==0 - ?renderTarget->GetDC()->MeasureBuffer(L" ") - :renderTarget->GetDC()->MeasureString(text) - ; - } - minSize=Size((element->GetEllipse()?0:size.cx), size.cy); - } - else - { - minSize=Size(); - } - } - - void GuiSolidLabelElementRenderer::InitializeInternal() - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - oldFont=element->GetFont(); - font=resourceManager->CreateGdiFont(oldFont); - } - - void GuiSolidLabelElementRenderer::FinalizeInternal() - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - resourceManager->DestroyGdiFont(oldFont); - } - - void GuiSolidLabelElementRenderer::RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget) - { - UpdateMinSize(); - } - - GuiSolidLabelElementRenderer::GuiSolidLabelElementRenderer() - :oldMaxWidth(-1) - { - } - - void GuiSolidLabelElementRenderer::Render(Rect bounds) - { - Color color=element->GetColor(); - if(color.a>0) - { - renderTarget->GetDC()->SetFont(font); - renderTarget->GetDC()->SetTextColor(RGB(color.r, color.g, color.b)); - - UINT format=DT_NOPREFIX; - RECT rect; - rect.left=(int)bounds.Left(); - rect.top=(int)bounds.Top(); - rect.right=(int)bounds.Right(); - rect.bottom=(int)bounds.Bottom(); - - if(element->GetMultiline() || element->GetWrapLine()) - { - format|=DT_EDITCONTROL; - } - else - { - format|=DT_SINGLELINE; - switch(element->GetVerticalAlignment()) - { - case Alignment::Top: - format|=DT_TOP; - break; - case Alignment::Center: - format|=DT_VCENTER; - break; - case Alignment::Bottom: - format|=DT_BOTTOM; - break; - } - } - - switch(element->GetHorizontalAlignment()) - { - case Alignment::Left: - format|=DT_LEFT; - break; - case Alignment::Center: - format|=DT_CENTER; - break; - case Alignment::Right: - format|=DT_RIGHT; - break; - } - - if(element->GetWrapLine()) - { - format|=DT_WORDBREAK; - } - if(element->GetEllipse()) - { - format|=DT_END_ELLIPSIS; - } - renderTarget->GetDC()->DrawString(rect, element->GetText(), format); - if(oldMaxWidth!=bounds.Width()) - { - oldMaxWidth=bounds.Width(); - UpdateMinSize(); - } - } - } - - void GuiSolidLabelElementRenderer::OnElementStateChanged() - { - FontProperties fontProperties=element->GetFont(); - if(oldFont!=fontProperties) - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - resourceManager->DestroyGdiFont(oldFont); - oldFont=fontProperties; - font=resourceManager->CreateGdiFont(oldFont); - } - UpdateMinSize(); - } - -/*********************************************************************** -GuiImageFrameElementRenderer -***********************************************************************/ - - void GuiImageFrameElementRenderer::UpdateBitmap() - { - if(element->GetImage()) - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - INativeImageFrame* frame=element->GetImage()->GetFrame(element->GetFrameIndex()); - bitmap=resourceManager->GetBitmap(frame, element->GetEnabled()); - - if (element->GetStretch()) - { - minSize=Size(0,0); - } - else - { - minSize=frame->GetSize(); - } - } - else - { - bitmap=0; - minSize=Size(0, 0); - } - } - - void GuiImageFrameElementRenderer::InitializeInternal() - { - UpdateBitmap(); - } - - void GuiImageFrameElementRenderer::FinalizeInternal() - { - } - - void GuiImageFrameElementRenderer::RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget) - { - } - - GuiImageFrameElementRenderer::GuiImageFrameElementRenderer() - { - } - - void GuiImageFrameElementRenderer::Render(Rect bounds) - { - if(bitmap) - { - WinDC* dc=renderTarget->GetDC(); - Rect source(0, 0, minSize.x, minSize.y); - Rect destination; - if(element->GetStretch()) - { - INativeImageFrame* frame=element->GetImage()->GetFrame(element->GetFrameIndex()); - source = Rect(Point(0, 0), frame->GetSize()); - destination=Rect(bounds.x1, bounds.y1, bounds.x2, bounds.y2); - } - else - { - vint x=0; - vint y=0; - switch(element->GetHorizontalAlignment()) - { - case Alignment::Left: - x=bounds.Left(); - break; - case Alignment::Center: - x=bounds.Left()+(bounds.Width()-minSize.x)/2; - break; - case Alignment::Right: - x=bounds.Right()-minSize.x; - break; - } - switch(element->GetVerticalAlignment()) - { - case Alignment::Top: - y=bounds.Top(); - break; - case Alignment::Center: - y=bounds.Top()+(bounds.Height()-minSize.y)/2; - break; - case Alignment::Bottom: - y=bounds.Bottom()-minSize.y; - break; - } - destination=Rect(x, y, x+minSize.x, y+minSize.y); - } - if(element->GetImage()->GetFormat()==INativeImage::Gif && element->GetFrameIndex()>0) - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - vint max=element->GetFrameIndex(); - for(vint i=0;i<=max;i++) - { - Ptr frameBitmap=resourceManager->GetBitmap(element->GetImage()->GetFrame(i), element->GetEnabled()); - dc->Draw( - destination.Left(), destination.Top(), destination.Width(), destination.Height(), - frameBitmap, - source.Left(), source.Top(), source.Width(), source.Height() - ); - } - } - else - { - dc->Draw( - destination.Left(), destination.Top(), destination.Width(), destination.Height(), - bitmap, - source.Left(), source.Top(), source.Width(), source.Height() - ); - } - } - } - - void GuiImageFrameElementRenderer::OnElementStateChanged() - { - UpdateBitmap(); - } - -/*********************************************************************** -GuiPolygonElementRenderer -***********************************************************************/ - - void GuiPolygonElementRenderer::InitializeInternal() - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - pen=resourceManager->CreateGdiPen(oldPenColor); - brush=resourceManager->CreateGdiBrush(oldBrushColor); - } - - void GuiPolygonElementRenderer::FinalizeInternal() - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - resourceManager->DestroyGdiPen(oldPenColor); - resourceManager->DestroyGdiBrush(oldBrushColor); - } - - void GuiPolygonElementRenderer::RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget) - { - } - - GuiPolygonElementRenderer::GuiPolygonElementRenderer() - :points(0) - ,pointCount(0) - ,oldPenColor(0, 0, 0, 0) - ,oldBrushColor(0, 0, 0, 0) - { - } - - GuiPolygonElementRenderer::~GuiPolygonElementRenderer() - { - if(points) delete[] points; - } - - void GuiPolygonElementRenderer::Render(Rect bounds) - { - if(pointCount>=3 && (oldPenColor.a || oldBrushColor.a)) - { - vint offsetX=(bounds.Width()-minSize.x)/2+bounds.x1; - vint offsetY=(bounds.Height()-minSize.y)/2+bounds.y1; - for(vint i=0;iGetDC()->SetPen(pen); - renderTarget->GetDC()->SetBrush(brush); - renderTarget->GetDC()->PolyGon(points, pointCount); - for(vint i=0;iGetSize(); - { - if(points) - { - delete[] points; - points=0; - } - pointCount=element->GetPointCount(); - if(pointCount>0) - { - points=new POINT[pointCount]; - for(vint i=0;iGetPoint(i); - points[i].x=(int)p.x; - points[i].y=(int)p.y; - } - } - } - - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - if(oldPenColor!=element->GetBorderColor() || !pen) - { - resourceManager->DestroyGdiPen(oldPenColor); - oldPenColor=element->GetBorderColor(); - pen=resourceManager->CreateGdiPen(oldPenColor); - } - if(oldBrushColor!=element->GetBackgroundColor() || !brush) - { - resourceManager->DestroyGdiPen(oldBrushColor); - oldBrushColor=element->GetBackgroundColor(); - brush=resourceManager->CreateGdiBrush(oldBrushColor); - } - } - -/*********************************************************************** -GuiColorizedTextElementRenderer -***********************************************************************/ - - void GuiColorizedTextElementRenderer::DestroyColors() - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - for(vint i=0;iDestroyGdiBrush(colors[i].normal.background); - resourceManager->DestroyGdiBrush(colors[i].selectedFocused.background); - resourceManager->DestroyGdiBrush(colors[i].selectedUnfocused.background); - } - } - - void GuiColorizedTextElementRenderer::ColorChanged() - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - ColorArray newColors; - newColors.Resize(element->GetColors().Count()); - for(vint i=0;iGetColors().Get(i); - ColorEntryResource newEntry; - - newEntry.normal.text=entry.normal.text; - newEntry.normal.background=entry.normal.background; - newEntry.normal.backgroundBrush=resourceManager->CreateGdiBrush(newEntry.normal.background); - newEntry.selectedFocused.text=entry.selectedFocused.text; - newEntry.selectedFocused.background=entry.selectedFocused.background; - newEntry.selectedFocused.backgroundBrush=resourceManager->CreateGdiBrush(newEntry.selectedFocused.background); - newEntry.selectedUnfocused.text=entry.selectedUnfocused.text; - newEntry.selectedUnfocused.background=entry.selectedUnfocused.background; - newEntry.selectedUnfocused.backgroundBrush=resourceManager->CreateGdiBrush(newEntry.selectedUnfocused.background); - newColors[i]=newEntry; - } - - DestroyColors(); - CopyFrom(colors, newColors); - } - - void GuiColorizedTextElementRenderer::FontChanged() - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - if(font) - { - element->GetLines().SetCharMeasurer(0); - resourceManager->DestroyGdiFont(oldFont); - resourceManager->DestroyCharMeasurer(oldFont); - font=0; - } - oldFont=element->GetFont(); - font=resourceManager->CreateGdiFont(oldFont); - element->GetLines().SetCharMeasurer(resourceManager->CreateCharMeasurer(oldFont).Obj()); - } - - void GuiColorizedTextElementRenderer::InitializeInternal() - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - element->SetCallback(this); - oldCaretColor=element->GetCaretColor(); - caretPen=resourceManager->CreateGdiPen(oldCaretColor); - } - - void GuiColorizedTextElementRenderer::FinalizeInternal() - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - if(font) - { - resourceManager->DestroyGdiFont(oldFont); - resourceManager->DestroyCharMeasurer(oldFont); - } - resourceManager->DestroyGdiPen(oldCaretColor); - DestroyColors(); - } - - void GuiColorizedTextElementRenderer::RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget) - { - element->GetLines().SetRenderTarget(newRenderTarget); - } - - void GuiColorizedTextElementRenderer::Render(Rect bounds) - { - if(renderTarget) - { - WinDC* dc=renderTarget->GetDC(); - dc->SetFont(font); - - wchar_t passwordChar=element->GetPasswordChar(); - Point viewPosition=element->GetViewPosition(); - Rect viewBounds(viewPosition, bounds.GetSize()); - vint startRow=element->GetLines().GetTextPosFromPoint(Point(viewBounds.x1, viewBounds.y1)).row; - vint endRow=element->GetLines().GetTextPosFromPoint(Point(viewBounds.x2, viewBounds.y2)).row; - TextPos selectionBegin=element->GetCaretBegin()GetCaretEnd()?element->GetCaretBegin():element->GetCaretEnd(); - TextPos selectionEnd=element->GetCaretBegin()>element->GetCaretEnd()?element->GetCaretBegin():element->GetCaretEnd(); - bool focused=element->GetFocused(); - Ptr lastBrush=0; - - for(vint row=startRow;row<=endRow;row++) - { - Rect startRect=element->GetLines().GetRectFromTextPos(TextPos(row, 0)); - Point startPoint=startRect.LeftTop(); - vint startColumn=element->GetLines().GetTextPosFromPoint(Point(viewBounds.x1, startPoint.y)).column; - vint endColumn=element->GetLines().GetTextPosFromPoint(Point(viewBounds.x2, startPoint.y)).column; - text::TextLine& line=element->GetLines().GetLine(row); - - vint x=startColumn==0?0:line.att[startColumn-1].rightOffset; - for(vint column=startColumn; column<=endColumn; column++) - { - bool inSelection=false; - if(selectionBegin.row==selectionEnd.row) - { - inSelection=(row==selectionBegin.row && selectionBegin.column<=column && column=colors.Count()) - { - colorIndex=0; - } - ColorItemResource& color= - !inSelection?colors[colorIndex].normal: - focused?colors[colorIndex].selectedFocused: - colors[colorIndex].selectedUnfocused; - vint x2=crlf?x+startRect.Height()/2:line.att[column].rightOffset; - vint tx=x-viewPosition.x+bounds.x1; - vint ty=startPoint.y-viewPosition.y+bounds.y1; - - if(color.background.a) - { - if(lastBrush!=color.backgroundBrush) - { - lastBrush=color.backgroundBrush; - dc->SetBrush(lastBrush); - } - dc->FillRect(tx, ty, tx+(x2-x), ty+startRect.Height()); - } - if(!crlf) - { - if(color.text.a) - { - dc->SetTextColor(RGB(color.text.r, color.text.g, color.text.b)); - dc->DrawBuffer(tx, ty, (passwordChar?&passwordChar:&line.text[column]), 1); - } - } - x=x2; - } - } - - if(element->GetCaretVisible() && element->GetLines().IsAvailable(element->GetCaretEnd())) - { - Point caretPoint=element->GetLines().GetPointFromTextPos(element->GetCaretEnd()); - vint height=element->GetLines().GetRowHeight(); - dc->SetPen(caretPen); - dc->MoveTo(caretPoint.x-viewPosition.x+bounds.x1, caretPoint.y-viewPosition.y+bounds.y1+1); - dc->LineTo(caretPoint.x-viewPosition.x+bounds.x1, caretPoint.y+height-viewPosition.y+bounds.y1-1); - dc->MoveTo(caretPoint.x-1-viewPosition.x+bounds.x1, caretPoint.y-viewPosition.y+bounds.y1+1); - dc->LineTo(caretPoint.x-1-viewPosition.x+bounds.x1, caretPoint.y+height-viewPosition.y+bounds.y1-1); - } - } - } - - void GuiColorizedTextElementRenderer::OnElementStateChanged() - { - Color caretColor=element->GetCaretColor(); - if(oldCaretColor!=caretColor) - { - IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); - resourceManager->DestroyGdiPen(oldCaretColor); - oldCaretColor=caretColor; - caretPen=resourceManager->CreateGdiPen(oldCaretColor); - } - } - -/*********************************************************************** -GuiGDIElementRenderer -***********************************************************************/ - - void GuiGDIElementRenderer::InitializeInternal() - { - } - - void GuiGDIElementRenderer::FinalizeInternal() - { - } - - void GuiGDIElementRenderer::RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget) - { - } - - GuiGDIElementRenderer::GuiGDIElementRenderer() - { - } - - GuiGDIElementRenderer::~GuiGDIElementRenderer() - { - } - - void GuiGDIElementRenderer::Render(Rect bounds) - { - if(renderTarget) - { - renderTarget->PushClipper(bounds); - if(!renderTarget->IsClipperCoverWholeTarget()) - { - WinDC* dc=renderTarget->GetDC(); - GuiGDIElementEventArgs arguments(element, dc, bounds); - element->Rendering.Execute(arguments); - } - renderTarget->PopClipper(); - } - } - - void GuiGDIElementRenderer::OnElementStateChanged() - { - } - } - } -} - -/*********************************************************************** -GRAPHICSELEMENT\WINDOWSGDI\GUIGRAPHICSUNISCRIBE.CPP +.\GRAPHICSELEMENT\WINDOWSGDI\GUIGRAPHICSUNISCRIBE.CPP ***********************************************************************/ #pragma comment(lib, "usp10.lib") @@ -9773,7 +7046,2939 @@ UniscribeParagraph (Caret) } /*********************************************************************** -GRAPHICSELEMENT\WINDOWSGDI\GUIGRAPHICSWINDOWSGDI.CPP +.\NATIVEWINDOW\WINDOWS\GDI\WINGDI.CPP +***********************************************************************/ + +#pragma comment(lib, "Msimg32.lib") + +namespace vl +{ + namespace presentation + { + namespace windows + { + +/********************************************************************************************************* +WinRegion +*********************************************************************************************************/ + + bool IsEqual(WinRegion::Ptr Region1, WinRegion::Ptr Region2) + { + return EqualRgn(Region1->GetHandle(), Region2->GetHandle())!=0; + } + + WinRegion::WinRegion(vint Left, vint Top, vint Right, vint Bottom, bool Rectangle) + { + if(Rectangle) + { + FHandle=CreateRectRgn((int)Left, (int)Top, (int)Right, (int)Bottom); + } + else + { + FHandle=CreateEllipticRgn((int)Left, (int)Top, (int)Right, (int)Bottom); + } + } + + WinRegion::WinRegion(RECT Rect, bool Rectangle) + { + if(Rectangle) + { + FHandle=CreateRectRgnIndirect(&Rect); + } + else + { + FHandle=CreateEllipticRgnIndirect(&Rect); + } + } + + WinRegion::WinRegion(vint Left, vint Top, vint Right, vint Bottom, vint EllipseWidth, vint EllipseHeight) + { + FHandle=CreateRoundRectRgn((int)Left, (int)Top, (int)Right, (int)Bottom, (int)EllipseWidth, (int)EllipseHeight); + } + + WinRegion::WinRegion(POINT* Points, vint Count, bool Alternate) + { + FHandle=CreatePolygonRgn(Points, (int)Count, Alternate?ALTERNATE:WINDING); + } + + WinRegion::WinRegion(WinRegion::Ptr Region) + { + FHandle=CreateRectRgn(0, 0, 1, 1); + CombineRgn(FHandle, Region->GetHandle(), Region->GetHandle(), RGN_COPY); + } + + WinRegion::WinRegion(WinRegion::Ptr Region1, WinRegion::Ptr Region2, vint CombineMode) + { + FHandle=CreateRectRgn(0, 0, 1, 1); + CombineRgn(FHandle, Region1->GetHandle(), Region2->GetHandle(), (int)CombineMode); + } + + WinRegion::WinRegion(HRGN RegionHandle) + { + FHandle=RegionHandle; + } + + WinRegion::~WinRegion() + { + DeleteObject(FHandle); + } + + HRGN WinRegion::GetHandle() + { + return FHandle; + } + + bool WinRegion::ContainPoint(POINT Point) + { + return PtInRegion(FHandle, Point.x, Point.y)!=0; + } + + bool WinRegion::ContainRect(RECT Rect) + { + return RectInRegion(FHandle, &Rect)!=0; + } + + RECT WinRegion::GetBoundRect() + { + RECT Rect={0, 0, 0, 0}; + GetRgnBox(FHandle, &Rect); + return Rect; + } + + void WinRegion::Move(vint OffsetX, vint OffsetY) + { + OffsetRgn(FHandle, (int)OffsetX, (int)OffsetY); + } + +/********************************************************************************************************* +WinTransform +*********************************************************************************************************/ + + WinTransform::WinTransform(XFORM Transform) + { + FTransform=Transform; + } + + WinTransform::WinTransform(const WinTransform& Transform) + { + FTransform=Transform.FTransform; + } + + WinTransform& WinTransform::operator=(const WinTransform& Transform) + { + FTransform=Transform.FTransform; + return *this; + } + + WinTransform WinTransform::operator*(const WinTransform& Transform) + { + XFORM Result; + CombineTransform(&Result, GetHandle(), Transform.GetHandle()); + return Result; + } + + const XFORM* WinTransform::GetHandle()const + { + return &FTransform; + } + + /*------------------------------------------------------------------------------*/ + + WinTransform WinTransform::Translate(float OffsetX, float OffsetY) + { + XFORM Transform; + Transform.eM11=1.0f; + Transform.eM12=0.0f; + Transform.eM21=0.0f; + Transform.eM22=1.0f; + Transform.eDx=OffsetX; + Transform.eDy=OffsetY; + return Transform; + } + + WinTransform WinTransform::Scale(float ScaleX, float ScaleY) + { + XFORM Transform; + Transform.eM11=ScaleX; + Transform.eM12=0.0f; + Transform.eM21=0.0f; + Transform.eM22=ScaleY; + Transform.eDx=0.0f; + Transform.eDy=0.0f; + return Transform; + } + + WinTransform WinTransform::Rotate(float Angle) + { + XFORM Transform; + Transform.eM11=(FLOAT)cos(Angle); + Transform.eM12= (FLOAT)sin(Angle); + Transform.eM21= (FLOAT)-sin(Angle); + Transform.eM22= (FLOAT)cos(Angle); + Transform.eDx=0.0f; + Transform.eDy=0.0f; + return Transform; + } + + WinTransform WinTransform::Rotate(float Cos, float Sin) + { + XFORM Transform; + Transform.eM11=Cos; + Transform.eM12=Sin; + Transform.eM21=-Sin; + Transform.eM22=Cos; + Transform.eDx=0.0f; + Transform.eDy=0.0f; + return Transform; + } + + WinTransform WinTransform::ReflectX() + { + XFORM Transform; + Transform.eM11=1.0f; + Transform.eM12=0.0f; + Transform.eM21=0.0f; + Transform.eM22=-1.0f; + Transform.eDx=0.0f; + Transform.eDy=0.0f; + return Transform; + } + + WinTransform WinTransform::ReflectY() + { + XFORM Transform; + Transform.eM11=-1.0f; + Transform.eM12=0.0f; + Transform.eM21=0.0f; + Transform.eM22=1.0f; + Transform.eDx=0.0f; + Transform.eDy=0.0f; + return Transform; + } + + WinTransform WinTransform::Reflect(float VectorX, float VectorY) + { + float Len= (FLOAT)sqrt(VectorX*VectorX+VectorY*VectorY); + float Cos=VectorX/Len; + float Sin=VectorY/Len; + + return Rotate(Cos, -Sin)*ReflectX()*Rotate(Cos, Sin); + } + + WinTransform WinTransform::Reflect(float OriginX, float OriginY, float VectorX, float VectorY) + { + float Len= (FLOAT)sqrt(VectorX*VectorX+VectorY*VectorY); + float Cos=VectorX/Len; + float Sin=VectorY/Len; + + return Translate(-OriginX, -OriginY)*Rotate(Cos, -Sin)*ReflectX()*Rotate(Cos, Sin)*Translate(OriginX, OriginY); + } + + WinTransform WinTransform::AxisV(float Xx, float Xy, float Yx, float Yy) + { + XFORM Transform; + Transform.eM11=Xx; + Transform.eM12=Xy; + Transform.eM21=Yx; + Transform.eM22=Yy; + Transform.eDx=0.0f; + Transform.eDy=0.0f; + return Transform; + } + + WinTransform WinTransform::AxisA(float AngleX, float LenX, float AngleY, float LenY) + { + XFORM Transform; + Transform.eM11=(FLOAT)cos(AngleX)*LenX; + Transform.eM12=(FLOAT)sin(AngleX)*LenX; + Transform.eM21=(FLOAT)cos(AngleY)*LenY; + Transform.eM22=(FLOAT)sin(AngleY)*LenY; + Transform.eDx=0.0f; + Transform.eDy=0.0f; + return Transform; + } + +/********************************************************************************************************* +WinMetaFileBuilder +*********************************************************************************************************/ + + void WinMetaFileBuilder::Create(vint Width, vint Height) + { + HDC hdcRef=GetDC(NULL); + vint iWidthMM = GetDeviceCaps(hdcRef, HORZSIZE); + vint iHeightMM = GetDeviceCaps(hdcRef, VERTSIZE); + vint iWidthPels = GetDeviceCaps(hdcRef, HORZRES); + vint iHeightPels = GetDeviceCaps(hdcRef, VERTRES); + ReleaseDC(NULL, hdcRef); + + RECT Rect; + Rect.left=0; + Rect.top=0; + Rect.right = (int)((Width*iWidthMM*100)/iWidthPels); + Rect.bottom = (int)((Height*iHeightMM*100)/iHeightPels); + + HDC Handle=CreateEnhMetaFile(NULL, NULL, &Rect, L"VczhLibrary++GDI\0Enhanced Meta File\0"); + FDC->Initialize(Handle); + + FWidth=Width; + FHeight=Height; + } + + void WinMetaFileBuilder::Draw(HENHMETAFILE Handle) + { + RECT Rect; + Rect.left=0; + Rect.top=0; + Rect.right=(int)FWidth; + Rect.bottom=(int)FHeight; + PlayEnhMetaFile(FDC->GetHandle(), Handle, &Rect); + } + + void WinMetaFileBuilder::Destroy() + { + DeleteEnhMetaFile(CloseEnhMetaFile(FDC->GetHandle())); + } + + WinMetaFileBuilder::WinMetaFileBuilder(vint Width, vint Height) + { + FDC=new WinProxyDC(); + Create(Width, Height); + } + + WinMetaFileBuilder::~WinMetaFileBuilder() + { + Destroy(); + delete FDC; + } + + void WinMetaFileBuilder::LoadFrom(WinMetaFile* File) + { + Destroy(); + Create(File->GetWidth(), File->GetHeight()); + Draw(File->GetHandle()); + } + + void WinMetaFileBuilder::SaveTo(WinMetaFile* File) + { + HENHMETAFILE Handle=CloseEnhMetaFile(FDC->GetHandle()); + if(File->FHandle) + { + DeleteEnhMetaFile(File->FHandle); + } + File->FHandle=Handle; + File->FWidth=FWidth; + File->FHeight=FHeight; + Create(FWidth, FHeight); + Draw(Handle); + } + + void WinMetaFileBuilder::LoadFrom(WString FileName) + { + WinMetaFile File(FileName); + Destroy(); + Create(File.GetWidth(), File.GetHeight()); + Draw(File.GetHandle()); + } + + void WinMetaFileBuilder::SaveTo(WString FileName) + { + HENHMETAFILE Handle=CloseEnhMetaFile(FDC->GetHandle()); + HENHMETAFILE NewHandle=CopyEnhMetaFile(Handle, FileName.Buffer()); + DeleteEnhMetaFile(NewHandle); + Create(FWidth, FHeight); + Draw(Handle); + DeleteEnhMetaFile(Handle); + } + + WinDC* WinMetaFileBuilder::GetWinDC() + { + return FDC; + } + + vint WinMetaFileBuilder::GetWidth() + { + return FWidth; + } + + vint WinMetaFileBuilder::GetHeight() + { + return FHeight; + } + +/********************************************************************************************************* +WinMetaFile +*********************************************************************************************************/ + + WinMetaFile::WinMetaFile(WString FileName) + { + FHandle=GetEnhMetaFile(FileName.Buffer()); + ENHMETAHEADER Header; + GetEnhMetaFileHeader(FHandle, sizeof(Header), &Header); + FWidth=(Header.rclFrame.right-Header.rclFrame.left)*Header.szlDevice.cx/(Header.szlMillimeters.cx*100); + FHeight=(Header.rclFrame.bottom-Header.rclFrame.top)*Header.szlDevice.cy/(Header.szlMillimeters.cy*100); + } + + WinMetaFile::WinMetaFile(WinMetaFileBuilder* Builder) + { + FHandle=NULL; + Builder->SaveTo(this); + } + + WinMetaFile::~WinMetaFile() + { + DeleteEnhMetaFile(FHandle); + } + + HENHMETAFILE WinMetaFile::GetHandle() + { + return FHandle; + } + + vint WinMetaFile::GetWidth() + { + return FWidth; + } + + vint WinMetaFile::GetHeight() + { + return FHeight; + } + +/********************************************************************************************************* +WinBitmap +*********************************************************************************************************/ + + vint WinBitmap::GetBitsFromBB(BitmapBits BB) + { + switch(BB) + { + case vbb32Bits: + return 32; + case vbb24Bits: + return 24; + default: + return 1; + } + } + + vint WinBitmap::GetLineBytes(vint Width, BitmapBits BB) + { + vint Bits=GetBitsFromBB(BB); + vint LineBits=Width*Bits; + vint AlignBits=sizeof(DWORD)*8; + LineBits+=(AlignBits-LineBits%AlignBits)%AlignBits; + return LineBits/8; + } + + void WinBitmap::FillBitmapInfoHeader(vint Width, vint Height, BitmapBits Bits, BITMAPINFOHEADER* Header) + { + Header->biSize=sizeof(BITMAPINFOHEADER); + Header->biWidth=(int)Width; + Header->biHeight=-(int)Height; + Header->biPlanes=1; + Header->biBitCount=(int)GetBitsFromBB(Bits); + Header->biCompression=BI_RGB; + Header->biSizeImage=0; + Header->biXPelsPerMeter=0; + Header->biYPelsPerMeter=0; + Header->biClrUsed=(Bits==vbb2Bits?2:0); + Header->biClrImportant=0; + } + + HBITMAP WinBitmap::CreateDDB(vint Width, vint Height, BitmapBits Bits) + { + if(Bits==vbb2Bits) + { + return CreateBitmap((int)Width, (int)Height, 2, (int)GetBitsFromBB(Bits), NULL); + } + else + { + WinBitmap Bitmap(1, 1, Bits, true); + return CreateCompatibleBitmap(Bitmap.GetWinDC()->GetHandle(), (int)Width, (int)Height); + } + } + + HBITMAP WinBitmap::CreateDIB(vint Width, vint Height, BitmapBits Bits, BYTE**& ScanLines) + { + BITMAPINFO* Info=(BITMAPINFO*)malloc(sizeof(BITMAPINFOHEADER)+2*sizeof(RGBQUAD)); + FillBitmapInfoHeader(Width, Height, Bits, &Info->bmiHeader); + Info->bmiColors[0].rgbBlue=0; + Info->bmiColors[0].rgbGreen=0; + Info->bmiColors[0].rgbRed=0; + Info->bmiColors[0].rgbReserved=0; + Info->bmiColors[1].rgbBlue=255; + Info->bmiColors[1].rgbGreen=255; + Info->bmiColors[1].rgbRed=255; + Info->bmiColors[1].rgbReserved=255; + + BYTE* FirstLine=0; + HBITMAP Handle=CreateDIBSection(FDC->GetHandle(), Info, DIB_RGB_COLORS, (void**)&FirstLine, NULL, 0); + ScanLines=new BYTE*[Height]; + vint LineBytes=GetLineBytes(Width, Bits); + for(vint i=0;iGetHandle(), FHandle); + if(Object) + { + DeleteObject(Object); + } + } + + WinBitmap::WinBitmap(vint Width, vint Height, BitmapBits Bits, bool DIBSections) + { + Constructor(Width, Height, Bits, DIBSections); + } + + WinBitmap::WinBitmap(WString FileName, bool Use32Bits, bool DIBSections) + { + FBits=Use32Bits?vbb32Bits:vbb24Bits; + + HBITMAP TempBmp=(HBITMAP)LoadImage(NULL, FileName.Buffer(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); + HDC TempDC=CreateCompatibleDC(NULL); + BITMAP TempRec; + + GetObject(TempBmp, sizeof(BITMAP), &TempRec); + DeleteObject(SelectObject(TempDC, TempBmp)); + + Constructor(TempRec.bmWidth, TempRec.bmHeight, FBits, DIBSections); + BitBlt(FDC->GetHandle(), 0, 0, TempRec.bmWidth, TempRec.bmHeight, TempDC, 0, 0, SRCCOPY); + + DeleteObject(TempDC); + DeleteObject(TempBmp); + } + + WinBitmap::~WinBitmap() + { + if(FScanLines) + { + delete[] FScanLines; + } + if(FHandle) + { + DeleteObject(FHandle); + } + delete FDC; + } + + void WinBitmap::SaveToFile(WString FileName) + { + if(FScanLines) + { + BITMAPFILEHEADER Header1; + BITMAPV5HEADER Header2; + { + Header1.bfType='M'*256+'B'; + Header1.bfSize=(int)(sizeof(Header1)+sizeof(Header2)+GetLineBytes()*FHeight); + Header1.bfReserved1=0; + Header1.bfReserved2=0; + Header1.bfOffBits=sizeof(Header2)+sizeof(Header1); + } + { + memset(&Header2, 0, sizeof(Header2)); + Header2.bV5Size=sizeof(Header2); + Header2.bV5Width=(int)FWidth; + Header2.bV5Height=-(int)FHeight; + Header2.bV5Planes=1; + Header2.bV5BitCount=(int)GetBitsFromBB(FBits); + Header2.bV5Compression=BI_RGB; + Header2.bV5CSType=LCS_sRGB; + Header2.bV5Intent=LCS_GM_GRAPHICS; + } + stream::FileStream Output(FileName, stream::FileStream::WriteOnly); + Output.Write(&Header1, sizeof(Header1)); + Output.Write(&Header2, sizeof(Header2)); + for(vint i=0;iCopy(0, 0, FWidth, FHeight, FDC, 0, 0); + Temp.SaveToFile(FileName); + } + } + + WinDC* WinBitmap::GetWinDC() + { + return FDC; + } + + vint WinBitmap::GetWidth() + { + return FWidth; + } + + vint WinBitmap::GetHeight() + { + return FHeight; + } + + vint WinBitmap::GetLineBytes() + { + return GetLineBytes(FWidth, FBits); + } + + BYTE** WinBitmap::GetScanLines() + { + return FScanLines; + } + + HBITMAP WinBitmap::GetBitmap() + { + return FHandle; + } + + WinBitmap::BitmapBits WinBitmap::GetBitmapBits() + { + return FBits; + } + + void WinBitmap::FillCompatibleHeader(BITMAPINFOHEADER* Header) + { + FillBitmapInfoHeader(FWidth, FHeight, FBits, Header); + } + + bool WinBitmap::CanBuildAlphaChannel() + { + return FScanLines!=0 && FBits==vbb32Bits; + } + + bool WinBitmap::IsAlphaChannelBuilt() + { + return FAlphaChannelBuilt; + } + + void WinBitmap::BuildAlphaChannel(bool autoPremultiply) + { + if(CanBuildAlphaChannel() && !FAlphaChannelBuilt) + { + FAlphaChannelBuilt=true; + if(autoPremultiply) + { + for(vint i=0;iGetWidth(), DIB->GetHeight(), WinBitmap::vbb24Bits, true); + Temp.GetWinDC()->Draw(0, 0, DIB); + vint HeaderSize=sizeof(BITMAPINFOHEADER); + FDIBMemory=new unsigned char[HeaderSize+Temp.GetHeight()*Temp.GetLineBytes()]; + Temp.FillCompatibleHeader((BITMAPINFOHEADER*)FDIBMemory); + memcpy(FDIBMemory+HeaderSize, Temp.GetScanLines()[0], Temp.GetHeight()*Temp.GetLineBytes()); + + FHandle=CreateDIBPatternBrushPt(FDIBMemory, DIB_RGB_COLORS); + DWORD Error=GetLastError(); + } + + WinBrush::~WinBrush() + { + DeleteObject(FHandle); + if(FDIBMemory) + { + delete[] FDIBMemory; + } + } + + HBRUSH WinBrush::GetHandle() + { + return FHandle; + } + +/********************************************************************************************************* +WinPen +*********************************************************************************************************/ + + WinPen::WinPen(vint Style, vint Width, COLORREF Color) + { + FDIBMemory=0; + FHandle=CreatePen((int)Style, (int)Width, (int)Color); + } + + WinPen::WinPen(vint Style, vint EndCap, vint Join, vint Width, COLORREF Color) + { + FDIBMemory=0; + LOGBRUSH Brush; + Brush.lbColor=Color; + Brush.lbStyle=BS_SOLID; + Brush.lbHatch=0; + FHandle=ExtCreatePen((int)(PS_GEOMETRIC|Style|EndCap|Join), (int)Width, &Brush, 0, 0); + } + + WinPen::WinPen(vint Style, vint EndCap, vint Join, vint Hatch, vint Width, COLORREF Color) + { + FDIBMemory=0; + LOGBRUSH Brush; + Brush.lbColor=Color; + Brush.lbStyle=BS_HATCHED; + Brush.lbHatch=Hatch; + FHandle=ExtCreatePen((int)(PS_GEOMETRIC|Style|EndCap|Join), (int)Width, &Brush, 0, 0); + } + + WinPen::WinPen(WinBitmap::Ptr DIB, vint Style, vint EndCap, vint Join, vint Width) + { + WinBitmap Temp(DIB->GetWidth(), DIB->GetHeight(), WinBitmap::vbb24Bits, true); + Temp.GetWinDC()->Draw(0, 0, DIB); + vint HeaderSize=sizeof(BITMAPINFOHEADER); + FDIBMemory=new unsigned char[HeaderSize+Temp.GetHeight()*Temp.GetLineBytes()]; + Temp.FillCompatibleHeader((BITMAPINFOHEADER*)FDIBMemory); + memcpy(FDIBMemory+HeaderSize, Temp.GetScanLines()[0], Temp.GetHeight()*Temp.GetLineBytes()); + + LOGBRUSH Brush; + Brush.lbColor=RGB(0, 0, 0); + Brush.lbStyle=BS_DIBPATTERNPT; + Brush.lbHatch=(ULONG_PTR)FDIBMemory; + FHandle=ExtCreatePen((int)(PS_GEOMETRIC|Style|EndCap|Join), (int)Width, &Brush, 0, 0); + } + + WinPen::~WinPen() + { + DeleteObject(FHandle); + if(FDIBMemory) + { + delete[] FDIBMemory; + } + } + + HPEN WinPen::GetHandle() + { + return FHandle; + } + +/********************************************************************************************************* +WinFont +*********************************************************************************************************/ + + WinFont::WinFont(WString Name, vint Height, vint Width, vint Escapement, vint Orientation, vint Weight, bool Italic, bool Underline, bool StrikeOut, bool Antialise) + { + FFontInfo.lfHeight=(int)Height; + FFontInfo.lfWidth=(int)Width; + FFontInfo.lfEscapement=(int)Escapement; + FFontInfo.lfOrientation=(int)Orientation; + FFontInfo.lfWeight=(int)Weight; + FFontInfo.lfItalic=Italic?TRUE:FALSE; + FFontInfo.lfUnderline=Underline?TRUE:FALSE; + FFontInfo.lfStrikeOut=StrikeOut?TRUE:FALSE; + FFontInfo.lfCharSet=DEFAULT_CHARSET; + FFontInfo.lfOutPrecision=OUT_DEFAULT_PRECIS; + FFontInfo.lfClipPrecision=CLIP_DEFAULT_PRECIS; + FFontInfo.lfQuality=Antialise?CLEARTYPE_QUALITY:NONANTIALIASED_QUALITY; + FFontInfo.lfPitchAndFamily=DEFAULT_PITCH | FF_DONTCARE; + wcsncpy_s(FFontInfo.lfFaceName, sizeof(FFontInfo.lfFaceName)/sizeof(*FFontInfo.lfFaceName), Name.Buffer(), LF_FACESIZE-1); + FHandle=CreateFontIndirect(&FFontInfo); + } + + WinFont::WinFont(LOGFONT* FontInfo) + { + FFontInfo=*FontInfo; + FHandle=CreateFontIndirect(&FFontInfo); + } + + WinFont::~WinFont() + { + DeleteObject(FHandle); + } + + HFONT WinFont::GetHandle() + { + return FHandle; + } + + LOGFONT* WinFont::GetInfo() + { + return &FFontInfo; + } + +/********************************************************************************************************* +IWinResourceService +*********************************************************************************************************/ + + WinBrush::Ptr CreateDefaultBrush() + { + return new WinBrush(RGB(255, 255, 255)); + } + + WinPen::Ptr CreateDefaultPen() + { + return new WinPen(PS_SOLID, 0, RGB(0, 0, 0)); + } + + WinFont::Ptr CreateDefaultFont() + { + NONCLIENTMETRICS NonClientMetrics; + NonClientMetrics.cbSize=sizeof(NONCLIENTMETRICS); + SystemParametersInfo(SPI_GETNONCLIENTMETRICS, NonClientMetrics.cbSize, &NonClientMetrics, 0); + if(!*NonClientMetrics.lfMessageFont.lfFaceName) + { + NonClientMetrics.cbSize=sizeof(NONCLIENTMETRICS)-sizeof(NonClientMetrics.iPaddedBorderWidth); + SystemParametersInfo(SPI_GETNONCLIENTMETRICS, NonClientMetrics.cbSize, &NonClientMetrics, 0); + } + return new WinFont(&NonClientMetrics.lfMessageFont); + } + + class DefaultResourceService : public Object, public IWinResourceService + { + public: + static IWinResourceService* _DefaultResourceService; + + WinPen::Ptr GetDefaultPen() + { + return CreateDefaultPen(); + } + + WinBrush::Ptr GetDefaultBrush() + { + return CreateDefaultBrush(); + } + + WinFont::Ptr GetDefaultFont() + { + return CreateDefaultFont(); + } + } _DRS; + IWinResourceService* DefaultResourceService::_DefaultResourceService=&_DRS; + + IWinResourceService* GetDefaultResourceService() + { + return DefaultResourceService::_DefaultResourceService; + } + + void SetDefaultResourceService(IWinResourceService* Service) + { + DefaultResourceService::_DefaultResourceService=Service; + } + +/********************************************************************************************************* +WinDC +*********************************************************************************************************/ + + void WinDC::Init() + { + FPen=GetDefaultResourceService()->GetDefaultPen(); + FOldPen=(HPEN)SelectObject(FHandle, FPen->GetHandle()); + + FBrush=GetDefaultResourceService()->GetDefaultBrush(); + FOldBrush=(HBRUSH)SelectObject(FHandle, FBrush->GetHandle()); + + FFont=GetDefaultResourceService()->GetDefaultFont(); + FOldFont=(HFONT)SelectObject(FHandle, FFont->GetHandle()); + + SetGraphicsMode(FHandle, GM_ADVANCED); + } + + WinDC::WinDC() + { + FHandle=0; + FOldPen=0; + FOldBrush=0; + FOldFont=0; + } + + WinDC::~WinDC() + { + SelectObject(FHandle, FOldFont); + SelectObject(FHandle, FOldBrush); + SelectObject(FHandle, FOldPen); + } + + HDC WinDC::GetHandle() + { + return FHandle; + } + + WinPen::Ptr WinDC::GetPen() + { + return FPen; + } + + WinBrush::Ptr WinDC::GetBrush() + { + return FBrush; + } + + WinFont::Ptr WinDC::GetFont() + { + return FFont; + } + + void WinDC::SetPen(WinPen::Ptr Pen) + { + SelectObject(FHandle, Pen->GetHandle()); + FPen=Pen; + } + + void WinDC::SetBrush(WinBrush::Ptr Brush) + { + SelectObject(FHandle, Brush->GetHandle()); + FBrush=Brush; + } + + void WinDC::SetFont(WinFont::Ptr Font) + { + SelectObject(FHandle, Font->GetHandle()); + FFont=Font; + } + + COLORREF WinDC::GetBackColor() + { + return GetBkColor(FHandle); + } + + void WinDC::SetBackColor(COLORREF Color) + { + SetBkColor(FHandle, Color); + } + + COLORREF WinDC::GetTextColor() + { + return ::GetTextColor(FHandle); + } + + void WinDC::SetTextColor(COLORREF Color) + { + ::SetTextColor(FHandle, Color); + } + + bool WinDC::GetBackTransparent() + { + return GetBkMode(FHandle)==TRANSPARENT; + } + + void WinDC::SetBackTransparent(bool Transparent) + { + SetBkMode(FHandle, Transparent?TRANSPARENT:OPAQUE); + } + + POINT WinDC::GetBrushOrigin() + { + POINT Point; + GetBrushOrgEx(FHandle, &Point); + return Point; + } + + void WinDC::SetBrushOrigin(POINT Point) + { + SetBrushOrgEx(FHandle, Point.x, Point.y, NULL); + } + + /*------------------------------------------------------------------------------*/ + + void WinDC::DrawBuffer(vint X, vint Y, const wchar_t* Text, vint CharCount) + { + TextOut(FHandle, (int)X, (int)Y, Text, (int)CharCount); + } + + void WinDC::DrawBuffer(vint X, vint Y, const wchar_t* Text, vint CharCount, vint TabWidth, vint TabOriginX) + { + int realTabWidth=(int)TabWidth; + TabbedTextOut(FHandle, (int)X, (int)Y, Text, (int)CharCount, 1, &realTabWidth, (int)TabOriginX); + } + + void WinDC::DrawBuffer(RECT Rect, const wchar_t* Text, vint CharCount, UINT Format) + { + DrawText(FHandle, Text, (int)CharCount, &Rect, Format); + } + + void WinDC::DrawString(vint X, vint Y, WString Text) + { + DrawBuffer(X, Y, Text.Buffer(), Text.Length()); + } + + void WinDC::DrawString(vint X, vint Y, WString Text, vint TabWidth, vint TabOriginX) + { + DrawBuffer(X, Y, Text.Buffer(), Text.Length(), TabWidth, TabOriginX); + } + + void WinDC::DrawString(RECT Rect, WString Text, UINT Format) + { + DrawBuffer(Rect, Text.Buffer(), Text.Length(), Format); + } + + SIZE WinDC::MeasureString(WString Text, vint TabSize) + { + return MeasureBuffer(Text.Buffer(), Text.Length(), TabSize); + } + + SIZE WinDC::MeasureBuffer(const wchar_t* Text, vint CharCount, vint TabSize) + { + SIZE Size; + if(TabSize==-1) + { + GetTextExtentPoint32(FHandle, Text, (int)CharCount, &Size); + } + else + { + int realTabSize=(int)TabSize; + DWORD Result=GetTabbedTextExtent(FHandle, Text, (int)CharCount, 1, &realTabSize); + Size.cx=LOWORD(Result); + Size.cy=HIWORD(Result); + } + return Size; + } + + SIZE WinDC::MeasureBuffer(const wchar_t* Text, vint TabSize) + { + return MeasureBuffer(Text, wcslen(Text), TabSize); + } + + SIZE WinDC::MeasureWrapLineString(WString Text, vint MaxWidth) + { + return MeasureWrapLineBuffer(Text.Buffer(), Text.Length(), MaxWidth); + } + + SIZE WinDC::MeasureWrapLineBuffer(const wchar_t* Text, vint CharCount, vint MaxWidth) + { + SIZE size = {0}; + vint lineCount=0; + const wchar_t* reading=Text; + INT* dx=new INT[CharCount]; + while(*reading) + { + INT fit=0; + GetTextExtentExPoint(FHandle, reading, (int)(CharCount-(reading-Text)), (int)MaxWidth, &fit, dx, &size); + reading+=fit; + lineCount++; + } + delete dx; + size.cx=0; + size.cy*=(int)lineCount; + return size; + } + + SIZE WinDC::MeasureWrapLineBuffer(const wchar_t* Text, vint MaxWidth) + { + return MeasureWrapLineBuffer(Text, wcslen(Text), MaxWidth); + } + + void WinDC::FillRegion(WinRegion::Ptr Region) + { + FillRgn(FHandle, Region->GetHandle(), FBrush->GetHandle()); + } + + void WinDC::FrameRegion(WinRegion::Ptr Region, vint BlockWidth, vint BlockHeight) + { + FrameRgn(FHandle, Region->GetHandle(), FBrush->GetHandle(), (int)BlockWidth, (int)BlockHeight); + } + + void WinDC::MoveTo(vint X, vint Y) + { + ::MoveToEx(FHandle, (int)X, (int)Y, NULL); + } + + void WinDC::LineTo(vint X, vint Y) + { + ::LineTo(FHandle, (int)X, (int)Y); + } + + void WinDC::Rectangle(vint Left, vint Top, vint Right, vint Bottom) + { + ::Rectangle(FHandle, (int)Left, (int)Top, (int)Right, (int)Bottom); + } + + void WinDC::Rectangle(RECT Rect) + { + ::Rectangle(FHandle, Rect.left, Rect.top, Rect.right, Rect.bottom); + } + + void WinDC::FocusRectangle(vint Left, vint Top, vint Right, vint Bottom) + { + RECT Rect; + Rect.left=(int)Left; + Rect.top=(int)Top; + Rect.right=(int)Right; + Rect.bottom=(int)Bottom; + ::DrawFocusRect(FHandle, &Rect); + } + + void WinDC::FocusRectangle(RECT Rect) + { + ::DrawFocusRect(FHandle, &Rect); + } + + void WinDC::FillRect(vint Left, vint Top, vint Right, vint Bottom) + { + RECT Rect; + Rect.left=(int)Left; + Rect.top=(int)Top; + Rect.right=(int)Right; + Rect.bottom=(int)Bottom; + ::FillRect(FHandle, &Rect, FBrush->GetHandle()); + } + + void WinDC::FillRect(RECT Rect) + { + ::FillRect(FHandle, &Rect, FBrush->GetHandle()); + } + + void WinDC::Ellipse(vint Left, vint Top, vint Right, vint Bottom) + { + ::Ellipse(FHandle, (int)Left, (int)Top, (int)Right, (int)Bottom); + } + + void WinDC::Ellipse(RECT Rect) + { + ::Ellipse(FHandle, Rect.left, Rect.top, Rect.right, Rect.bottom); + } + + void WinDC::RoundRect(vint Left, vint Top, vint Right, vint Bottom, vint EllipseWidth, vint EllipseHeight) + { + ::RoundRect(FHandle, (int)Left, (int)Top, (int)Right, (int)Bottom, (int)EllipseWidth, (int)EllipseHeight); + } + + void WinDC::RoundRect(RECT Rect, vint EllipseWidth, vint EllipseHeight) + { + ::RoundRect(FHandle, (int)Rect.left, (int)Rect.top, (int)Rect.right, (int)Rect.bottom, (int)EllipseWidth, (int)EllipseHeight); + } + + void WinDC::PolyLine(const POINT* Points, vint Count) + { + ::Polyline(FHandle, Points, (int)Count); + } + + void WinDC::PolyLineTo(const POINT* Points, vint Count) + { + ::PolylineTo(FHandle, Points, (int)Count); + } + + void WinDC::PolyGon(const POINT* Points, vint Count) + { + ::Polygon(FHandle, Points, (int)Count); + } + + void WinDC::PolyBezier(const POINT* Points, vint Count) + { + ::PolyBezier(FHandle, Points, (int)Count); + } + + void WinDC::PolyBezierTo(const POINT* Points, vint Count) + { + ::PolyBezierTo(FHandle, Points, (int)Count); + } + + void WinDC::PolyDraw(const POINT* Points, const BYTE* Actions, vint PointCount) + { + ::PolyDraw(FHandle, Points, Actions, (int)PointCount); + } + + void WinDC::Arc(RECT Bound, POINT Start, POINT End) + { + ::Arc(FHandle, Bound.left, Bound.top, Bound.right, Bound.bottom, Start.x, Start.y, End.x, End.y); + } + + void WinDC::Arc(vint Left, vint Top, vint Right, vint Bottom, vint StartX, vint StartY, vint EndX, vint EndY) + { + ::Arc(FHandle, (int)Left, (int)Top, (int)Right, (int)Bottom, (int)StartX, (int)StartY, (int)EndX, (int)EndY); + } + + void WinDC::ArcTo(RECT Bound, POINT Start, POINT End) + { + ::ArcTo(FHandle, (int)Bound.left, (int)Bound.top, (int)Bound.right, (int)Bound.bottom, (int)Start.x, (int)Start.y, (int)End.x, (int)End.y); + } + + void WinDC::ArcTo(vint Left, vint Top, vint Right, vint Bottom, vint StartX, vint StartY, vint EndX, vint EndY) + { + ::ArcTo(FHandle, (int)Left, (int)Top, (int)Right, (int)Bottom, (int)StartX, (int)StartY, (int)EndX, (int)EndY); + } + + void WinDC::AngleArc(vint X, vint Y, vint Radius, float StartAngle, float SweepAngle) + { + ::AngleArc(FHandle, (int)X, (int)Y, (int)Radius, StartAngle, SweepAngle); + } + + void WinDC::AngleArc(vint X, vint Y, vint Radius, double StartAngle, double SweepAngle) + { + ::AngleArc(FHandle, (int)X, (int)Y, (int)Radius, (float)StartAngle, (float)SweepAngle); + } + + void WinDC::Chord(RECT Bound, POINT Start, POINT End) + { + ::Chord(FHandle, (int)Bound.left, (int)Bound.top, (int)Bound.right, (int)Bound.bottom, (int)Start.x, (int)Start.y, (int)End.x, (int)End.y); + } + + void WinDC::Chord(vint Left, vint Top, vint Right, vint Bottom, vint StartX, vint StartY, vint EndX, vint EndY) + { + ::Chord(FHandle, (int)Left, (int)Top, (int)Right, (int)Bottom, (int)StartX, (int)StartY, (int)EndX, (int)EndY); + } + + void WinDC::Pie(RECT Bound, POINT Start, POINT End) + { + ::Pie(FHandle, (int)Bound.left, (int)Bound.top, (int)Bound.right, (int)Bound.bottom, (int)Start.x, (int)Start.y, (int)End.x, (int)End.y); + } + + void WinDC::Pie(vint Left, vint Top, vint Right, vint Bottom, vint StartX, vint StartY, vint EndX, vint EndY) + { + ::Pie(FHandle, (int)Left, (int)Top, (int)Right, (int)Bottom, (int)StartX, (int)StartY, (int)EndX, (int)EndY); + } + + void WinDC::GradientTriangle(TRIVERTEX* Vertices, vint VerticesCount, GRADIENT_TRIANGLE* Triangles, vint TriangleCount) + { + GradientFill(FHandle, Vertices, (int)VerticesCount, Triangles, (int)TriangleCount, GRADIENT_FILL_TRIANGLE); + } + + /*------------------------------------------------------------------------------*/ + + void WinDC::BeginPath() + { + ::BeginPath(FHandle); + } + + void WinDC::EndPath() + { + ::EndPath(FHandle); + } + + void WinDC::ClosePath() + { + ::CloseFigure(FHandle); + } + + void WinDC::WidenPath() + { + ::WidenPath(FHandle); + } + + void WinDC::DiscardPath() + { + ::AbortPath(FHandle); + } + + void WinDC::DrawPath() + { + ::StrokePath(FHandle); + } + + void WinDC::FillPath() + { + ::FillPath(FHandle); + } + + void WinDC::DrawAndFillPath() + { + ::StrokeAndFillPath(FHandle); + } + + WinRegion::Ptr WinDC::RegionFromPath() + { + return new WinRegion(::PathToRegion(FHandle)); + } + + /*------------------------------------------------------------------------------*/ + + bool WinDC::PointInClip(POINT Point) + { + return PtVisible(FHandle, Point.x, Point.y)==TRUE; + } + + bool WinDC::RectInClip(RECT Rect) + { + return RectVisible(FHandle, &Rect)==TRUE; + } + + void WinDC::ClipPath(vint CombineMode) + { + SelectClipPath(FHandle, (int)CombineMode); + } + + void WinDC::ClipRegion(WinRegion::Ptr Region) + { + SelectClipRgn(FHandle, Region->GetHandle()); + } + + void WinDC::RemoveClip() + { + SelectClipRgn(FHandle, NULL); + } + + void WinDC::MoveClip(vint OffsetX, vint OffsetY) + { + OffsetClipRgn(FHandle, (int)OffsetX, (int)OffsetY); + } + + void WinDC::CombineClip(WinRegion::Ptr Region, vint CombineMode) + { + ExtSelectClipRgn(FHandle, Region->GetHandle(), (int)CombineMode); + } + + void WinDC::IntersetClipRect(RECT Rect) + { + ::IntersectClipRect(FHandle, Rect.left, Rect.top, Rect.right, Rect.bottom); + } + + void WinDC::ExcludeClipRect(RECT Rect) + { + ::ExcludeClipRect(FHandle, Rect.left, Rect.top, Rect.right, Rect.bottom); + } + + WinRegion::Ptr WinDC::GetClipRegion() + { + HRGN Handle=CreateRectRgn(0, 0, 1, 1); + GetClipRgn(FHandle, Handle); + return new WinRegion(Handle); + } + + RECT WinDC::GetClipBoundRect() + { + RECT Rect; + GetClipBox(FHandle, &Rect); + return Rect; + } + + /*------------------------------------------------------------------------------*/ + + WinTransform WinDC::GetTransform() + { + XFORM Transform; + GetWorldTransform(FHandle, &Transform); + return Transform; + } + + void WinDC::SetTransform(const WinTransform& Transform) + { + SetWorldTransform(FHandle, Transform.GetHandle()); + } + + /*------------------------------------------------------------------------------*/ + + void WinDC::Copy(vint dstX, vint dstY, vint dstW, vint dstH, WinDC* Source, vint srcX, vint srcY, DWORD DrawROP) + { + HDC SourceHandle=Source?Source->GetHandle():0; + BitBlt(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, SourceHandle, (int)srcX, (int)srcY, (int)DrawROP); + } + + void WinDC::Copy(RECT dstRect, WinDC* Source, POINT srcPos, DWORD DrawROP) + { + HDC SourceHandle=Source?Source->GetHandle():0; + BitBlt(FHandle, dstRect.left, dstRect.top, dstRect.right-dstRect.left, dstRect.bottom-dstRect.top, SourceHandle, srcPos.x, srcPos.y, DrawROP); + } + + void WinDC::Copy(vint dstX, vint dstY, vint dstW, vint dstH, WinDC* Source, vint srcX, vint srcY , vint srcW, vint srcH, DWORD DrawROP) + { + HDC SourceHandle=Source?Source->GetHandle():0; + StretchBlt(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, SourceHandle, (int)srcX, (int)srcY, (int)srcW, (int)srcH, (int)DrawROP); + } + + void WinDC::Copy(RECT dstRect, WinDC* Source, RECT srcRect, DWORD DrawROP) + { + HDC SourceHandle=Source?Source->GetHandle():0; + StretchBlt( FHandle , dstRect.left, dstRect.top, dstRect.right-dstRect.left, dstRect.bottom-dstRect.top, + SourceHandle, srcRect.left, srcRect.top, srcRect.right-srcRect.left, srcRect.bottom-srcRect.top, + DrawROP); + } + + void WinDC::Copy(POINT UpperLeft, POINT UpperRight, POINT LowerLeft, WinDC* Source, vint srcX, vint srcY, vint srcW, vint srcH) + { + POINT Pt[3]; + Pt[0]=UpperLeft; + Pt[1]=UpperRight; + Pt[2]=LowerLeft; + PlgBlt(FHandle, Pt, Source->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, 0, 0, 0); + } + + void WinDC::Copy(POINT UpperLeft, POINT UpperRight, POINT LowerLeft, WinDC*Source, RECT srcRect) + { + POINT Pt[3]; + Pt[0]=UpperLeft; + Pt[1]=UpperRight; + Pt[2]=LowerLeft; + PlgBlt(FHandle, Pt, Source->GetHandle(), srcRect.left, srcRect.top, srcRect.right-srcRect.left, srcRect.bottom-srcRect.top, 0, 0, 0); + } + + void WinDC::CopyTrans(vint dstX, vint dstY, vint dstW, vint dstH, WinDC* Source, vint srcX, vint srcY , vint srcW, vint srcH, COLORREF Color) + { + TransparentBlt(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Source->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Color); + } + + void WinDC::CopyTrans(RECT dstRect, WinDC* Source, RECT srcRect, COLORREF Color) + { + TransparentBlt( FHandle , dstRect.left, dstRect.top, dstRect.right-dstRect.left, dstRect.bottom-dstRect.top, + Source->GetHandle() , srcRect.left, srcRect.top, srcRect.right-srcRect.left, srcRect.bottom-srcRect.top, + Color); + } + + /*------------------------------------------------------------------------------*/ + + void WinDC::Draw(vint dstX, vint dstY, WinMetaFile* MetaFile) + { + Draw(dstX, dstY, MetaFile->GetWidth(), MetaFile->GetHeight(), MetaFile); + } + + void WinDC::Draw(POINT Pos, WinMetaFile* MetaFile) + { + Draw(Pos.x, Pos.y, MetaFile->GetWidth(), MetaFile->GetHeight(), MetaFile); + } + + void WinDC::Draw(vint dstX, vint dstY, vint dstW, vint dstH, WinMetaFile* MetaFile) + { + RECT Rect; + Rect.left=(int)dstX; + Rect.top=(int)dstY; + Rect.right=(int)(dstX+dstW); + Rect.bottom=(int)(dstY+dstH); + Draw(Rect, MetaFile); + } + + void WinDC::Draw(RECT Rect, WinMetaFile* MetaFile) + { + PlayEnhMetaFile(FHandle, MetaFile->GetHandle(), &Rect); + } + + /*------------------------------------------------------------------------------*/ + + void WinDC::Draw(vint dstX, vint dstY, WinBitmap::Ptr Bitmap) + { + vint dstW=Bitmap->GetWidth(); + vint dstH=Bitmap->GetHeight(); + vint srcX=0; + vint srcY=0; + if(!Bitmap->IsAlphaChannelBuilt()) + { + BitBlt(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, SRCCOPY); + } + else + { + vint srcW=dstW; + vint srcH=dstH; + BLENDFUNCTION Blend; + Blend.BlendOp=AC_SRC_OVER; + Blend.BlendFlags=0; + Blend.SourceConstantAlpha=255; + Blend.AlphaFormat=AC_SRC_ALPHA; + AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); + } + } + + void WinDC::Draw(POINT Pos, WinBitmap::Ptr Bitmap) + { + vint dstX=Pos.x; + vint dstY=Pos.y; + vint dstW=Bitmap->GetWidth(); + vint dstH=Bitmap->GetHeight(); + vint srcX=0; + vint srcY=0; + if(!Bitmap->IsAlphaChannelBuilt()) + { + BitBlt(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, SRCCOPY); + } + else + { + vint srcW=dstW; + vint srcH=dstH; + BLENDFUNCTION Blend; + Blend.BlendOp=AC_SRC_OVER; + Blend.BlendFlags=0; + Blend.SourceConstantAlpha=255; + Blend.AlphaFormat=AC_SRC_ALPHA; + AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); + } + } + + void WinDC::Draw(vint dstX, vint dstY, vint dstW, vint dstH, WinBitmap::Ptr Bitmap) + { + vint srcX=0; + vint srcY=0; + vint srcW=Bitmap->GetWidth(); + vint srcH=Bitmap->GetHeight(); + if(!Bitmap->IsAlphaChannelBuilt()) + { + StretchBlt(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, SRCCOPY); + } + else + { + BLENDFUNCTION Blend; + Blend.BlendOp=AC_SRC_OVER; + Blend.BlendFlags=0; + Blend.SourceConstantAlpha=255; + Blend.AlphaFormat=AC_SRC_ALPHA; + AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); + } + } + + void WinDC::Draw(RECT Rect, WinBitmap::Ptr Bitmap) + { + vint dstX=Rect.left; + vint dstY=Rect.top; + vint dstW=Rect.right-Rect.left; + vint dstH=Rect.bottom-Rect.top; + vint srcX=0; + vint srcY=0; + vint srcW=Bitmap->GetWidth(); + vint srcH=Bitmap->GetHeight(); + if(!Bitmap->IsAlphaChannelBuilt()) + { + StretchBlt(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, SRCCOPY); + } + else + { + BLENDFUNCTION Blend; + Blend.BlendOp=AC_SRC_OVER; + Blend.BlendFlags=0; + Blend.SourceConstantAlpha=255; + Blend.AlphaFormat=AC_SRC_ALPHA; + AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); + } + } + + void WinDC::Draw(vint dstX, vint dstY, vint dstW, vint dstH, WinBitmap::Ptr Bitmap, vint srcX, vint srcY) + { + if(!Bitmap->IsAlphaChannelBuilt()) + { + BitBlt(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, SRCCOPY); + } + else + { + vint srcW=dstW; + vint srcH=dstH; + BLENDFUNCTION Blend; + Blend.BlendOp=AC_SRC_OVER; + Blend.BlendFlags=0; + Blend.SourceConstantAlpha=255; + Blend.AlphaFormat=AC_SRC_ALPHA; + AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); + } + } + + void WinDC::Draw(RECT Rect, WinBitmap::Ptr Bitmap, POINT Pos) + { + vint dstX=Rect.left; + vint dstY=Rect.top; + vint dstW=Rect.right-Rect.left; + vint dstH=Rect.bottom-Rect.top; + vint srcX=Pos.x; + vint srcY=Pos.y; + if(!Bitmap->IsAlphaChannelBuilt()) + { + BitBlt(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, SRCCOPY); + } + else + { + vint srcW=dstW; + vint srcH=dstH; + BLENDFUNCTION Blend; + Blend.BlendOp=AC_SRC_OVER; + Blend.BlendFlags=0; + Blend.SourceConstantAlpha=255; + Blend.AlphaFormat=AC_SRC_ALPHA; + AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); + } + } + + void WinDC::Draw(vint dstX, vint dstY, vint dstW, vint dstH, WinBitmap::Ptr Bitmap, vint srcX, vint srcY, vint srcW, vint srcH) + { + if(!Bitmap->IsAlphaChannelBuilt()) + { + StretchBlt(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, SRCCOPY); + } + else + { + BLENDFUNCTION Blend; + Blend.BlendOp=AC_SRC_OVER; + Blend.BlendFlags=0; + Blend.SourceConstantAlpha=255; + Blend.AlphaFormat=AC_SRC_ALPHA; + AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); + } + } + + void WinDC::Draw(RECT dstRect, WinBitmap::Ptr Bitmap, RECT srcRect) + { + vint dstX=dstRect.left; + vint dstY=dstRect.top; + vint dstW=dstRect.right-dstRect.left; + vint dstH=dstRect.bottom-dstRect.top; + vint srcX=srcRect.left; + vint srcY=srcRect.top; + vint srcW=srcRect.right-srcRect.left; + vint srcH=srcRect.bottom-srcRect.top; + if(!Bitmap->IsAlphaChannelBuilt()) + { + StretchBlt(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, SRCCOPY); + } + else + { + BLENDFUNCTION Blend; + Blend.BlendOp=AC_SRC_OVER; + Blend.BlendFlags=0; + Blend.SourceConstantAlpha=255; + Blend.AlphaFormat=AC_SRC_ALPHA; + AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); + } + } + + /*------------------------------------------------------------------------------*/ + + void WinDC::Draw(vint dstX, vint dstY, WinBitmap::Ptr Bitmap, unsigned char Alpha) + { + vint dstW=Bitmap->GetWidth(); + vint dstH=Bitmap->GetHeight(); + vint srcX=0; + vint srcY=0; + vint srcW=dstW; + vint srcH=dstH; + + BLENDFUNCTION Blend; + Blend.BlendOp=AC_SRC_OVER; + Blend.BlendFlags=0; + Blend.SourceConstantAlpha=Alpha; + Blend.AlphaFormat=Bitmap->IsAlphaChannelBuilt()?AC_SRC_ALPHA:0; + AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); + } + + void WinDC::Draw(POINT Pos, WinBitmap::Ptr Bitmap, unsigned char Alpha) + { + vint dstX=Pos.x; + vint dstY=Pos.y; + vint dstW=Bitmap->GetWidth(); + vint dstH=Bitmap->GetHeight(); + vint srcX=0; + vint srcY=0; + vint srcW=dstW; + vint srcH=dstH; + + BLENDFUNCTION Blend; + Blend.BlendOp=AC_SRC_OVER; + Blend.BlendFlags=0; + Blend.SourceConstantAlpha=Alpha; + Blend.AlphaFormat=Bitmap->IsAlphaChannelBuilt()?AC_SRC_ALPHA:0; + AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); + } + + void WinDC::Draw(vint dstX, vint dstY, vint dstW, vint dstH, WinBitmap::Ptr Bitmap, unsigned char Alpha) + { + vint srcX=0; + vint srcY=0; + vint srcW=Bitmap->GetWidth(); + vint srcH=Bitmap->GetHeight(); + + BLENDFUNCTION Blend; + Blend.BlendOp=AC_SRC_OVER; + Blend.BlendFlags=0; + Blend.SourceConstantAlpha=Alpha; + Blend.AlphaFormat=Bitmap->IsAlphaChannelBuilt()?AC_SRC_ALPHA:0; + AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); + } + + void WinDC::Draw(RECT Rect, WinBitmap::Ptr Bitmap, unsigned char Alpha) + { + vint dstX=Rect.left; + vint dstY=Rect.top; + vint dstW=Rect.right-Rect.left; + vint dstH=Rect.bottom-Rect.top; + vint srcX=0; + vint srcY=0; + vint srcW=Bitmap->GetWidth(); + vint srcH=Bitmap->GetHeight(); + + BLENDFUNCTION Blend; + Blend.BlendOp=AC_SRC_OVER; + Blend.BlendFlags=0; + Blend.SourceConstantAlpha=Alpha; + Blend.AlphaFormat=Bitmap->IsAlphaChannelBuilt()?AC_SRC_ALPHA:0; + AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); + } + + void WinDC::Draw(vint dstX, vint dstY, vint dstW, vint dstH, WinBitmap::Ptr Bitmap, vint srcX, vint srcY, unsigned char Alpha) + { + vint srcW=dstW; + vint srcH=dstH; + + BLENDFUNCTION Blend; + Blend.BlendOp=AC_SRC_OVER; + Blend.BlendFlags=0; + Blend.SourceConstantAlpha=Alpha; + Blend.AlphaFormat=Bitmap->IsAlphaChannelBuilt()?AC_SRC_ALPHA:0; + AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); + } + + void WinDC::Draw(RECT Rect, WinBitmap::Ptr Bitmap, POINT Pos, unsigned char Alpha) + { + vint dstX=Rect.left; + vint dstY=Rect.top; + vint dstW=Rect.right-Rect.left; + vint dstH=Rect.bottom-Rect.top; + vint srcX=Pos.x; + vint srcY=Pos.y; + vint srcW=dstW; + vint srcH=dstH; + + BLENDFUNCTION Blend; + Blend.BlendOp=AC_SRC_OVER; + Blend.BlendFlags=0; + Blend.SourceConstantAlpha=Alpha; + Blend.AlphaFormat=Bitmap->IsAlphaChannelBuilt()?AC_SRC_ALPHA:0; + AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); + } + + void WinDC::Draw(vint dstX, vint dstY, vint dstW, vint dstH, WinBitmap::Ptr Bitmap, vint srcX, vint srcY, vint srcW, vint srcH, unsigned char Alpha) + { + BLENDFUNCTION Blend; + Blend.BlendOp=AC_SRC_OVER; + Blend.BlendFlags=0; + Blend.SourceConstantAlpha=Alpha; + Blend.AlphaFormat=Bitmap->IsAlphaChannelBuilt()?AC_SRC_ALPHA:0; + AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); + } + + void WinDC::Draw(RECT dstRect, WinBitmap::Ptr Bitmap, RECT srcRect, unsigned char Alpha) + { + vint dstX=dstRect.left; + vint dstY=dstRect.top; + vint dstW=dstRect.right-dstRect.left; + vint dstH=dstRect.bottom-dstRect.top; + vint srcX=srcRect.left; + vint srcY=srcRect.top; + vint srcW=srcRect.right-srcRect.left; + vint srcH=srcRect.bottom-srcRect.top; + + BLENDFUNCTION Blend; + Blend.BlendOp=AC_SRC_OVER; + Blend.BlendFlags=0; + Blend.SourceConstantAlpha=Alpha; + Blend.AlphaFormat=Bitmap->IsAlphaChannelBuilt()?AC_SRC_ALPHA:0; + AlphaBlend(FHandle, (int)dstX, (int)dstY, (int)dstW, (int)dstH, Bitmap->GetWinDC()->GetHandle(), (int)srcX, (int)srcY, (int)srcW, (int)srcH, Blend); + } + +/********************************************************************************************************* +WinControlDC +*********************************************************************************************************/ + + WinControlDC::WinControlDC(HWND Handle) + { + FControlHandle=Handle; + FHandle=GetDC(FControlHandle); + Init(); + } + + WinControlDC::~WinControlDC() + { + ReleaseDC(FControlHandle, FHandle); + } + +/********************************************************************************************************* +WinProxyDC +*********************************************************************************************************/ + + WinProxyDC::WinProxyDC() + { + FHandle=NULL; + } + + WinProxyDC::~WinProxyDC() + { + } + + void WinProxyDC::Initialize(HDC Handle) + { + FHandle=Handle; + Init(); + } + +/********************************************************************************************************* +WinImageDC +*********************************************************************************************************/ + + WinImageDC::WinImageDC() + { + FHandle=CreateCompatibleDC(NULL); + Init(); + } + + WinImageDC::~WinImageDC() + { + DeleteDC(FHandle); + } + + } + } +} + + +/*********************************************************************** +.\GRAPHICSELEMENT\WINDOWSGDI\GUIGRAPHICSRENDERERSWINDOWSGDI.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace elements_windows_gdi + { + using namespace windows; + using namespace collections; + +/*********************************************************************** +GuiSolidBorderElementRenderer +***********************************************************************/ + + void GuiSolidBorderElementRenderer::InitializeInternal() + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + oldColor=element->GetColor(); + pen=resourceManager->CreateGdiPen(oldColor); + brush=resourceManager->CreateGdiBrush(Color(0, 0, 0, 0)); + } + + void GuiSolidBorderElementRenderer::FinalizeInternal() + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + resourceManager->DestroyGdiPen(oldColor); + resourceManager->DestroyGdiBrush(Color(0, 0, 0, 0)); + } + + void GuiSolidBorderElementRenderer::RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget) + { + } + + void GuiSolidBorderElementRenderer::Render(Rect bounds) + { + if(oldColor.a>0) + { + renderTarget->GetDC()->SetBrush(brush); + renderTarget->GetDC()->SetPen(pen); + switch(element->GetShape()) + { + case ElementShape::Rectangle: + renderTarget->GetDC()->Rectangle(bounds.Left(), bounds.Top(), bounds.Right()-1, bounds.Bottom()-1); + break; + case ElementShape::Ellipse: + renderTarget->GetDC()->Ellipse(bounds.Left(), bounds.Top(), bounds.Right()-1, bounds.Bottom()-1); + break; + } + } + } + + void GuiSolidBorderElementRenderer::OnElementStateChanged() + { + Color color=element->GetColor(); + if(oldColor!=color) + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + resourceManager->DestroyGdiPen(oldColor); + oldColor=color; + pen=resourceManager->CreateGdiPen(oldColor); + } + } + +/*********************************************************************** +GuiRoundBorderElementRenderer +***********************************************************************/ + + void GuiRoundBorderElementRenderer::InitializeInternal() + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + oldColor=element->GetColor(); + pen=resourceManager->CreateGdiPen(oldColor); + brush=resourceManager->CreateGdiBrush(Color(0, 0, 0, 0)); + } + + void GuiRoundBorderElementRenderer::FinalizeInternal() + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + resourceManager->DestroyGdiPen(oldColor); + resourceManager->DestroyGdiBrush(Color(0, 0, 0, 0)); + } + + void GuiRoundBorderElementRenderer::RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget) + { + } + + void GuiRoundBorderElementRenderer::Render(Rect bounds) + { + if(oldColor.a>0) + { + vint ellipse=element->GetRadius()*2; + renderTarget->GetDC()->SetBrush(brush); + renderTarget->GetDC()->SetPen(pen); + renderTarget->GetDC()->RoundRect(bounds.Left(), bounds.Top(), bounds.Right()-1, bounds.Bottom()-1, ellipse, ellipse); + } + } + + void GuiRoundBorderElementRenderer::OnElementStateChanged() + { + Color color=element->GetColor(); + if(oldColor!=color) + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + resourceManager->DestroyGdiPen(oldColor); + oldColor=color; + pen=resourceManager->CreateGdiPen(oldColor); + } + } + +/*********************************************************************** +Gui3DBorderElementRenderer +***********************************************************************/ + + void Gui3DBorderElementRenderer::InitializeInternal() + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + oldColor1=element->GetColor1(); + oldColor2=element->GetColor2(); + pen1=resourceManager->CreateGdiPen(oldColor1); + pen2=resourceManager->CreateGdiPen(oldColor2); + } + + void Gui3DBorderElementRenderer::FinalizeInternal() + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + resourceManager->DestroyGdiPen(oldColor1); + resourceManager->DestroyGdiPen(oldColor2); + } + + void Gui3DBorderElementRenderer::RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget) + { + } + + void Gui3DBorderElementRenderer::Render(Rect bounds) + { + if(oldColor1.a>0) + { + renderTarget->GetDC()->SetPen(pen1); + renderTarget->GetDC()->MoveTo(bounds.x1, bounds.y1); + renderTarget->GetDC()->LineTo(bounds.x2, bounds.y1); + renderTarget->GetDC()->MoveTo(bounds.x1, bounds.y1); + renderTarget->GetDC()->LineTo(bounds.x1, bounds.y2); + } + if(oldColor2.a>0) + { + renderTarget->GetDC()->SetPen(pen2); + renderTarget->GetDC()->MoveTo(bounds.x2-1, bounds.y2-1); + renderTarget->GetDC()->LineTo(bounds.x1, bounds.y2-1); + renderTarget->GetDC()->MoveTo(bounds.x2-1, bounds.y2-1); + renderTarget->GetDC()->LineTo(bounds.x2-1, bounds.y1); + } + } + + void Gui3DBorderElementRenderer::OnElementStateChanged() + { + Color color1=element->GetColor1(); + if(oldColor1!=color1) + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + resourceManager->DestroyGdiPen(oldColor1); + oldColor1=color1; + pen1=resourceManager->CreateGdiPen(oldColor1); + } + + Color color2=element->GetColor2(); + if(oldColor2!=color2) + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + resourceManager->DestroyGdiPen(oldColor2); + oldColor2=color2; + pen2=resourceManager->CreateGdiPen(oldColor2); + } + } + +/*********************************************************************** +Gui3DSplitterElementRenderer +***********************************************************************/ + + void Gui3DSplitterElementRenderer::InitializeInternal() + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + oldColor1=element->GetColor1(); + oldColor2=element->GetColor2(); + pen1=resourceManager->CreateGdiPen(oldColor1); + pen2=resourceManager->CreateGdiPen(oldColor2); + } + + void Gui3DSplitterElementRenderer::FinalizeInternal() + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + resourceManager->DestroyGdiPen(oldColor1); + resourceManager->DestroyGdiPen(oldColor2); + } + + void Gui3DSplitterElementRenderer::RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget) + { + } + + void Gui3DSplitterElementRenderer::Render(Rect bounds) + { + Point p11, p12, p21, p22; + switch(element->GetDirection()) + { + case Gui3DSplitterElement::Horizontal: + { + vint y=bounds.y1+bounds.Height()/2-1; + p11=Point(bounds.x1, y); + p12=Point(bounds.x2, y); + p21=Point(bounds.x1, y+1); + p22=Point(bounds.x2, y+1); + } + break; + case Gui3DSplitterElement::Vertical: + { + vint x=bounds.x1+bounds.Width()/2-1; + p11=Point(x, bounds.y1); + p12=Point(x, bounds.y2); + p21=Point(x+1, bounds.y1); + p22=Point(x+1, bounds.y2); + } + break; + } + if(oldColor1.a>0) + { + renderTarget->GetDC()->SetPen(pen1); + renderTarget->GetDC()->MoveTo(p11.x, p11.y); + renderTarget->GetDC()->LineTo(p12.x, p12.y); + } + if(oldColor2.a>0) + { + renderTarget->GetDC()->SetPen(pen2); + renderTarget->GetDC()->MoveTo(p21.x, p21.y); + renderTarget->GetDC()->LineTo(p22.x, p22.y); + } + } + + void Gui3DSplitterElementRenderer::OnElementStateChanged() + { + Color color1=element->GetColor1(); + if(oldColor1!=color1) + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + resourceManager->DestroyGdiPen(oldColor1); + oldColor1=color1; + pen1=resourceManager->CreateGdiPen(oldColor1); + } + + Color color2=element->GetColor2(); + if(oldColor2!=color2) + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + resourceManager->DestroyGdiPen(oldColor2); + oldColor2=color2; + pen2=resourceManager->CreateGdiPen(oldColor2); + } + } + +/*********************************************************************** +GuiSolidBackgroundElementRenderer +***********************************************************************/ + + void GuiSolidBackgroundElementRenderer::InitializeInternal() + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + oldColor=element->GetColor(); + pen=resourceManager->CreateGdiPen(oldColor); + brush=resourceManager->CreateGdiBrush(oldColor); + } + + void GuiSolidBackgroundElementRenderer::FinalizeInternal() + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + resourceManager->DestroyGdiPen(oldColor); + resourceManager->DestroyGdiBrush(oldColor); + } + + void GuiSolidBackgroundElementRenderer::RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget) + { + } + + void GuiSolidBackgroundElementRenderer::Render(Rect bounds) + { + if(oldColor.a>0) + { + renderTarget->GetDC()->SetPen(pen); + renderTarget->GetDC()->SetBrush(brush); + switch(element->GetShape()) + { + case ElementShape::Rectangle: + renderTarget->GetDC()->FillRect(bounds.Left(), bounds.Top(), bounds.Right(), bounds.Bottom()); + break; + case ElementShape::Ellipse: + renderTarget->GetDC()->Ellipse(bounds.Left(), bounds.Top(), bounds.Right()-1, bounds.Bottom()-1); + break; + } + } + } + + void GuiSolidBackgroundElementRenderer::OnElementStateChanged() + { + Color color=element->GetColor(); + if(oldColor!=color) + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + resourceManager->DestroyGdiPen(oldColor); + resourceManager->DestroyGdiBrush(oldColor); + oldColor=color; + pen=resourceManager->CreateGdiPen(oldColor); + brush=resourceManager->CreateGdiBrush(oldColor); + } + } + +/*********************************************************************** +GuiGradientBackgroundElementRenderer +***********************************************************************/ + + void GuiGradientBackgroundElementRenderer::InitializeInternal() + { + } + + void GuiGradientBackgroundElementRenderer::FinalizeInternal() + { + } + + void GuiGradientBackgroundElementRenderer::RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget) + { + } + + void GuiGradientBackgroundElementRenderer::Render(Rect bounds) + { + Color color1=element->GetColor1(); + Color color2=element->GetColor2(); + if(color1.a>0 || color2.a>0) + { + TRIVERTEX vertices[4]; + GRADIENT_TRIANGLE triangles[2]; + + vertices[0].x=(int)bounds.x1; + vertices[0].y=(int)bounds.y1; + vertices[1].x=(int)bounds.x1; + vertices[1].y=(int)bounds.y2; + vertices[2].x=(int)bounds.x2; + vertices[2].y=(int)bounds.y2; + vertices[3].x=(int)bounds.x2; + vertices[3].y=(int)bounds.y1; + + triangles[0].Vertex1=0; + triangles[0].Vertex2=1; + triangles[0].Vertex3=2; + triangles[1].Vertex1=0; + triangles[1].Vertex2=2; + triangles[1].Vertex3=3; + + if(element->GetDirection()==GuiGradientBackgroundElement::Horizontal) + { + vertices[0].Red=color1.r<<8; + vertices[0].Green=color1.g<<8; + vertices[0].Blue=color1.b<<8; + vertices[0].Alpha=0xFF00; + + vertices[1].Red=color1.r<<8; + vertices[1].Green=color1.g<<8; + vertices[1].Blue=color1.b<<8; + vertices[1].Alpha=0xFF00; + + vertices[2].Red=color2.r<<8; + vertices[2].Green=color2.g<<8; + vertices[2].Blue=color2.b<<8; + vertices[2].Alpha=0xFF00; + + vertices[3].Red=color2.r<<8; + vertices[3].Green=color2.g<<8; + vertices[3].Blue=color2.b<<8; + vertices[3].Alpha=0xFF00; + } + else + { + vertices[0].Red=color1.r<<8; + vertices[0].Green=color1.g<<8; + vertices[0].Blue=color1.b<<8; + vertices[0].Alpha=0xFF00; + + vertices[1].Red=color2.r<<8; + vertices[1].Green=color2.g<<8; + vertices[1].Blue=color2.b<<8; + vertices[1].Alpha=0xFF00; + + vertices[2].Red=color2.r<<8; + vertices[2].Green=color2.g<<8; + vertices[2].Blue=color2.b<<8; + vertices[2].Alpha=0xFF00; + + vertices[3].Red=color1.r<<8; + vertices[3].Green=color1.g<<8; + vertices[3].Blue=color1.b<<8; + vertices[3].Alpha=0xFF00; + } + + switch(element->GetShape()) + { + case ElementShape::Rectangle: + { + renderTarget->GetDC()->GradientTriangle(vertices, 6, triangles, 2); + } + break; + case ElementShape::Ellipse: + { + Ptr ellipseRegion=new WinRegion(bounds.x1, bounds.y1, bounds.x2+1, bounds.y2+1, false); + Ptr oldRegion=renderTarget->GetDC()->GetClipRegion(); + Ptr newRegion=new WinRegion(oldRegion, ellipseRegion, RGN_AND); + renderTarget->GetDC()->ClipRegion(newRegion); + renderTarget->GetDC()->GradientTriangle(vertices, 6, triangles, 2); + renderTarget->GetDC()->ClipRegion(oldRegion); + } + break; + } + } + } + + void GuiGradientBackgroundElementRenderer::OnElementStateChanged() + { + } + +/*********************************************************************** +GuiSolidLabelElementRenderer +***********************************************************************/ + + void GuiSolidLabelElementRenderer::UpdateMinSize() + { + if(renderTarget) + { + renderTarget->GetDC()->SetFont(font); + SIZE size={0}; + const WString& text=element->GetText(); + if(element->GetWrapLine()) + { + if(element->GetWrapLineHeightCalculation()) + { + if(oldMaxWidth==-1 || text.Length()==0) + { + size=renderTarget->GetDC()->MeasureBuffer(L" "); + } + else + { + size=renderTarget->GetDC()->MeasureWrapLineString(text, oldMaxWidth); + } + } + } + else + { + size=text.Length()==0 + ?renderTarget->GetDC()->MeasureBuffer(L" ") + :renderTarget->GetDC()->MeasureString(text) + ; + } + minSize=Size((element->GetEllipse()?0:size.cx), size.cy); + } + else + { + minSize=Size(); + } + } + + void GuiSolidLabelElementRenderer::InitializeInternal() + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + oldFont=element->GetFont(); + font=resourceManager->CreateGdiFont(oldFont); + } + + void GuiSolidLabelElementRenderer::FinalizeInternal() + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + resourceManager->DestroyGdiFont(oldFont); + } + + void GuiSolidLabelElementRenderer::RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget) + { + UpdateMinSize(); + } + + GuiSolidLabelElementRenderer::GuiSolidLabelElementRenderer() + :oldMaxWidth(-1) + { + } + + void GuiSolidLabelElementRenderer::Render(Rect bounds) + { + Color color=element->GetColor(); + if(color.a>0) + { + renderTarget->GetDC()->SetFont(font); + renderTarget->GetDC()->SetTextColor(RGB(color.r, color.g, color.b)); + + UINT format=DT_NOPREFIX; + RECT rect; + rect.left=(int)bounds.Left(); + rect.top=(int)bounds.Top(); + rect.right=(int)bounds.Right(); + rect.bottom=(int)bounds.Bottom(); + + if(element->GetMultiline() || element->GetWrapLine()) + { + format|=DT_EDITCONTROL; + } + else + { + format|=DT_SINGLELINE; + switch(element->GetVerticalAlignment()) + { + case Alignment::Top: + format|=DT_TOP; + break; + case Alignment::Center: + format|=DT_VCENTER; + break; + case Alignment::Bottom: + format|=DT_BOTTOM; + break; + } + } + + switch(element->GetHorizontalAlignment()) + { + case Alignment::Left: + format|=DT_LEFT; + break; + case Alignment::Center: + format|=DT_CENTER; + break; + case Alignment::Right: + format|=DT_RIGHT; + break; + } + + if(element->GetWrapLine()) + { + format|=DT_WORDBREAK; + } + if(element->GetEllipse()) + { + format|=DT_END_ELLIPSIS; + } + renderTarget->GetDC()->DrawString(rect, element->GetText(), format); + if(oldMaxWidth!=bounds.Width()) + { + oldMaxWidth=bounds.Width(); + UpdateMinSize(); + } + } + } + + void GuiSolidLabelElementRenderer::OnElementStateChanged() + { + FontProperties fontProperties=element->GetFont(); + if(oldFont!=fontProperties) + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + resourceManager->DestroyGdiFont(oldFont); + oldFont=fontProperties; + font=resourceManager->CreateGdiFont(oldFont); + } + UpdateMinSize(); + } + +/*********************************************************************** +GuiImageFrameElementRenderer +***********************************************************************/ + + void GuiImageFrameElementRenderer::UpdateBitmap() + { + if(element->GetImage()) + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + INativeImageFrame* frame=element->GetImage()->GetFrame(element->GetFrameIndex()); + bitmap=resourceManager->GetBitmap(frame, element->GetEnabled()); + + if (element->GetStretch()) + { + minSize=Size(0,0); + } + else + { + minSize=frame->GetSize(); + } + } + else + { + bitmap=0; + minSize=Size(0, 0); + } + } + + void GuiImageFrameElementRenderer::InitializeInternal() + { + UpdateBitmap(); + } + + void GuiImageFrameElementRenderer::FinalizeInternal() + { + } + + void GuiImageFrameElementRenderer::RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget) + { + } + + GuiImageFrameElementRenderer::GuiImageFrameElementRenderer() + { + } + + void GuiImageFrameElementRenderer::Render(Rect bounds) + { + if(bitmap) + { + WinDC* dc=renderTarget->GetDC(); + Rect source(0, 0, minSize.x, minSize.y); + Rect destination; + if(element->GetStretch()) + { + INativeImageFrame* frame=element->GetImage()->GetFrame(element->GetFrameIndex()); + source = Rect(Point(0, 0), frame->GetSize()); + destination=Rect(bounds.x1, bounds.y1, bounds.x2, bounds.y2); + } + else + { + vint x=0; + vint y=0; + switch(element->GetHorizontalAlignment()) + { + case Alignment::Left: + x=bounds.Left(); + break; + case Alignment::Center: + x=bounds.Left()+(bounds.Width()-minSize.x)/2; + break; + case Alignment::Right: + x=bounds.Right()-minSize.x; + break; + } + switch(element->GetVerticalAlignment()) + { + case Alignment::Top: + y=bounds.Top(); + break; + case Alignment::Center: + y=bounds.Top()+(bounds.Height()-minSize.y)/2; + break; + case Alignment::Bottom: + y=bounds.Bottom()-minSize.y; + break; + } + destination=Rect(x, y, x+minSize.x, y+minSize.y); + } + if(element->GetImage()->GetFormat()==INativeImage::Gif && element->GetFrameIndex()>0) + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + vint max=element->GetFrameIndex(); + for(vint i=0;i<=max;i++) + { + Ptr frameBitmap=resourceManager->GetBitmap(element->GetImage()->GetFrame(i), element->GetEnabled()); + dc->Draw( + destination.Left(), destination.Top(), destination.Width(), destination.Height(), + frameBitmap, + source.Left(), source.Top(), source.Width(), source.Height() + ); + } + } + else + { + dc->Draw( + destination.Left(), destination.Top(), destination.Width(), destination.Height(), + bitmap, + source.Left(), source.Top(), source.Width(), source.Height() + ); + } + } + } + + void GuiImageFrameElementRenderer::OnElementStateChanged() + { + UpdateBitmap(); + } + +/*********************************************************************** +GuiPolygonElementRenderer +***********************************************************************/ + + void GuiPolygonElementRenderer::InitializeInternal() + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + pen=resourceManager->CreateGdiPen(oldPenColor); + brush=resourceManager->CreateGdiBrush(oldBrushColor); + } + + void GuiPolygonElementRenderer::FinalizeInternal() + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + resourceManager->DestroyGdiPen(oldPenColor); + resourceManager->DestroyGdiBrush(oldBrushColor); + } + + void GuiPolygonElementRenderer::RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget) + { + } + + GuiPolygonElementRenderer::GuiPolygonElementRenderer() + :points(0) + ,pointCount(0) + ,oldPenColor(0, 0, 0, 0) + ,oldBrushColor(0, 0, 0, 0) + { + } + + GuiPolygonElementRenderer::~GuiPolygonElementRenderer() + { + if(points) delete[] points; + } + + void GuiPolygonElementRenderer::Render(Rect bounds) + { + if(pointCount>=3 && (oldPenColor.a || oldBrushColor.a)) + { + vint offsetX=(bounds.Width()-minSize.x)/2+bounds.x1; + vint offsetY=(bounds.Height()-minSize.y)/2+bounds.y1; + for(vint i=0;iGetDC()->SetPen(pen); + renderTarget->GetDC()->SetBrush(brush); + renderTarget->GetDC()->PolyGon(points, pointCount); + for(vint i=0;iGetSize(); + { + if(points) + { + delete[] points; + points=0; + } + pointCount=element->GetPointCount(); + if(pointCount>0) + { + points=new POINT[pointCount]; + for(vint i=0;iGetPoint(i); + points[i].x=(int)p.x; + points[i].y=(int)p.y; + } + } + } + + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + if(oldPenColor!=element->GetBorderColor() || !pen) + { + resourceManager->DestroyGdiPen(oldPenColor); + oldPenColor=element->GetBorderColor(); + pen=resourceManager->CreateGdiPen(oldPenColor); + } + if(oldBrushColor!=element->GetBackgroundColor() || !brush) + { + resourceManager->DestroyGdiPen(oldBrushColor); + oldBrushColor=element->GetBackgroundColor(); + brush=resourceManager->CreateGdiBrush(oldBrushColor); + } + } + +/*********************************************************************** +GuiColorizedTextElementRenderer +***********************************************************************/ + + void GuiColorizedTextElementRenderer::DestroyColors() + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + for(vint i=0;iDestroyGdiBrush(colors[i].normal.background); + resourceManager->DestroyGdiBrush(colors[i].selectedFocused.background); + resourceManager->DestroyGdiBrush(colors[i].selectedUnfocused.background); + } + } + + void GuiColorizedTextElementRenderer::ColorChanged() + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + ColorArray newColors; + newColors.Resize(element->GetColors().Count()); + for(vint i=0;iGetColors().Get(i); + ColorEntryResource newEntry; + + newEntry.normal.text=entry.normal.text; + newEntry.normal.background=entry.normal.background; + newEntry.normal.backgroundBrush=resourceManager->CreateGdiBrush(newEntry.normal.background); + newEntry.selectedFocused.text=entry.selectedFocused.text; + newEntry.selectedFocused.background=entry.selectedFocused.background; + newEntry.selectedFocused.backgroundBrush=resourceManager->CreateGdiBrush(newEntry.selectedFocused.background); + newEntry.selectedUnfocused.text=entry.selectedUnfocused.text; + newEntry.selectedUnfocused.background=entry.selectedUnfocused.background; + newEntry.selectedUnfocused.backgroundBrush=resourceManager->CreateGdiBrush(newEntry.selectedUnfocused.background); + newColors[i]=newEntry; + } + + DestroyColors(); + CopyFrom(colors, newColors); + } + + void GuiColorizedTextElementRenderer::FontChanged() + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + if(font) + { + element->GetLines().SetCharMeasurer(0); + resourceManager->DestroyGdiFont(oldFont); + resourceManager->DestroyCharMeasurer(oldFont); + font=0; + } + oldFont=element->GetFont(); + font=resourceManager->CreateGdiFont(oldFont); + element->GetLines().SetCharMeasurer(resourceManager->CreateCharMeasurer(oldFont).Obj()); + } + + void GuiColorizedTextElementRenderer::InitializeInternal() + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + element->SetCallback(this); + oldCaretColor=element->GetCaretColor(); + caretPen=resourceManager->CreateGdiPen(oldCaretColor); + } + + void GuiColorizedTextElementRenderer::FinalizeInternal() + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + if(font) + { + resourceManager->DestroyGdiFont(oldFont); + resourceManager->DestroyCharMeasurer(oldFont); + } + resourceManager->DestroyGdiPen(oldCaretColor); + DestroyColors(); + } + + void GuiColorizedTextElementRenderer::RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget) + { + element->GetLines().SetRenderTarget(newRenderTarget); + } + + void GuiColorizedTextElementRenderer::Render(Rect bounds) + { + if(renderTarget) + { + WinDC* dc=renderTarget->GetDC(); + dc->SetFont(font); + + wchar_t passwordChar=element->GetPasswordChar(); + Point viewPosition=element->GetViewPosition(); + Rect viewBounds(viewPosition, bounds.GetSize()); + vint startRow=element->GetLines().GetTextPosFromPoint(Point(viewBounds.x1, viewBounds.y1)).row; + vint endRow=element->GetLines().GetTextPosFromPoint(Point(viewBounds.x2, viewBounds.y2)).row; + TextPos selectionBegin=element->GetCaretBegin()GetCaretEnd()?element->GetCaretBegin():element->GetCaretEnd(); + TextPos selectionEnd=element->GetCaretBegin()>element->GetCaretEnd()?element->GetCaretBegin():element->GetCaretEnd(); + bool focused=element->GetFocused(); + Ptr lastBrush=0; + + for(vint row=startRow;row<=endRow;row++) + { + Rect startRect=element->GetLines().GetRectFromTextPos(TextPos(row, 0)); + Point startPoint=startRect.LeftTop(); + vint startColumn=element->GetLines().GetTextPosFromPoint(Point(viewBounds.x1, startPoint.y)).column; + vint endColumn=element->GetLines().GetTextPosFromPoint(Point(viewBounds.x2, startPoint.y)).column; + text::TextLine& line=element->GetLines().GetLine(row); + + vint x=startColumn==0?0:line.att[startColumn-1].rightOffset; + for(vint column=startColumn; column<=endColumn; column++) + { + bool inSelection=false; + if(selectionBegin.row==selectionEnd.row) + { + inSelection=(row==selectionBegin.row && selectionBegin.column<=column && column=colors.Count()) + { + colorIndex=0; + } + ColorItemResource& color= + !inSelection?colors[colorIndex].normal: + focused?colors[colorIndex].selectedFocused: + colors[colorIndex].selectedUnfocused; + vint x2=crlf?x+startRect.Height()/2:line.att[column].rightOffset; + vint tx=x-viewPosition.x+bounds.x1; + vint ty=startPoint.y-viewPosition.y+bounds.y1; + + if(color.background.a) + { + if(lastBrush!=color.backgroundBrush) + { + lastBrush=color.backgroundBrush; + dc->SetBrush(lastBrush); + } + dc->FillRect(tx, ty, tx+(x2-x), ty+startRect.Height()); + } + if(!crlf) + { + if(color.text.a) + { + dc->SetTextColor(RGB(color.text.r, color.text.g, color.text.b)); + dc->DrawBuffer(tx, ty, (passwordChar?&passwordChar:&line.text[column]), 1); + } + } + x=x2; + } + } + + if(element->GetCaretVisible() && element->GetLines().IsAvailable(element->GetCaretEnd())) + { + Point caretPoint=element->GetLines().GetPointFromTextPos(element->GetCaretEnd()); + vint height=element->GetLines().GetRowHeight(); + dc->SetPen(caretPen); + dc->MoveTo(caretPoint.x-viewPosition.x+bounds.x1, caretPoint.y-viewPosition.y+bounds.y1+1); + dc->LineTo(caretPoint.x-viewPosition.x+bounds.x1, caretPoint.y+height-viewPosition.y+bounds.y1-1); + dc->MoveTo(caretPoint.x-1-viewPosition.x+bounds.x1, caretPoint.y-viewPosition.y+bounds.y1+1); + dc->LineTo(caretPoint.x-1-viewPosition.x+bounds.x1, caretPoint.y+height-viewPosition.y+bounds.y1-1); + } + } + } + + void GuiColorizedTextElementRenderer::OnElementStateChanged() + { + Color caretColor=element->GetCaretColor(); + if(oldCaretColor!=caretColor) + { + IWindowsGDIResourceManager* resourceManager=GetWindowsGDIResourceManager(); + resourceManager->DestroyGdiPen(oldCaretColor); + oldCaretColor=caretColor; + caretPen=resourceManager->CreateGdiPen(oldCaretColor); + } + } + +/*********************************************************************** +GuiGDIElementRenderer +***********************************************************************/ + + void GuiGDIElementRenderer::InitializeInternal() + { + } + + void GuiGDIElementRenderer::FinalizeInternal() + { + } + + void GuiGDIElementRenderer::RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget) + { + } + + GuiGDIElementRenderer::GuiGDIElementRenderer() + { + } + + GuiGDIElementRenderer::~GuiGDIElementRenderer() + { + } + + void GuiGDIElementRenderer::Render(Rect bounds) + { + if(renderTarget) + { + renderTarget->PushClipper(bounds); + if(!renderTarget->IsClipperCoverWholeTarget()) + { + WinDC* dc=renderTarget->GetDC(); + GuiGDIElementEventArgs arguments(element, dc, bounds); + element->Rendering.Execute(arguments); + } + renderTarget->PopClipper(); + } + } + + void GuiGDIElementRenderer::OnElementStateChanged() + { + } + } + } +} + +/*********************************************************************** +.\GRAPHICSELEMENT\WINDOWSGDI\GUIGRAPHICSWINDOWSGDI.CPP ***********************************************************************/ namespace vl @@ -10276,688 +10481,2619 @@ void RendererMainGDI() } /*********************************************************************** -GRAPHICSELEMENT\WINDOWSDIRECT2D\GUIGRAPHICSLAYOUTPROVIDERWINDOWSDIRECT2D.CPP +.\NATIVEWINDOW\WINDOWS\GDI\WINGDIAPPLICATION.CPP ***********************************************************************/ namespace vl { namespace presentation { - using namespace elements; - using namespace collections; + namespace windows + { + using namespace vl::collections; - namespace elements_windows_d2d + class GdiWindowsNativeWindowListener : public Object, public INativeWindowListener + { + protected: + Ptr buffer; + INativeWindow* window; + + vint DetermineBufferLength(vint minSize, vint minBound, vint maxBound, vint currentSize) + { + if(currentSizemaxBound) + { + return minBound; + } + else + { + return currentSize; + } + } + + Size CalculateBufferSize() + { + Size windowSize=window->GetClientSize(); + Size minBounds(windowSize.x*5/4, windowSize.y*5/4); + Size maxBounds(windowSize.x*3/2, windowSize.y*3/2); + Size currentSize=buffer?Size(buffer->GetWidth(), buffer->GetHeight()):Size(0, 0); + vint newWidth=DetermineBufferLength(windowSize.x, minBounds.x, maxBounds.x, currentSize.x); + vint newHeight=DetermineBufferLength(windowSize.y, minBounds.y, maxBounds.y, currentSize.y); + return Size(newWidth, newHeight); + } + + void RebuildCanvas(Size size) + { + if(size.x<256)size.x=256; + if(size.y<256)size.y=256; + if(buffer) + { + if(buffer->GetWidth()!=size.x || buffer->GetHeight()!=size.y) + { + buffer=0; + } + } + if(!buffer) + { + buffer=new WinBitmap(size.x, size.y, WinBitmap::vbb32Bits, true); + buffer->GetWinDC()->SetBackTransparent(true); + } + } + public: + GdiWindowsNativeWindowListener(INativeWindow* _window) + :window(_window) + { + } + + void Moved() + { + RebuildCanvas(CalculateBufferSize()); + } + + void Paint() + { + IWindowsForm* form=GetWindowsForm(window); + WinControlDC controlDC(form->GetWindowHandle()); + controlDC.Draw(0, 0, buffer); + } + + WinDC* GetWinDC() + { + if(!buffer) Moved(); + return buffer->GetWinDC(); + } + }; + + class GdiWindowsNativeControllerListener : public Object, public INativeControllerListener + { + public: + Dictionary> nativeWindowListeners; + + void NativeWindowCreated(INativeWindow* window) + { + Ptr listener=new GdiWindowsNativeWindowListener(window); + window->InstallListener(listener.Obj()); + nativeWindowListeners.Add(window, listener); + } + + void NativeWindowDestroying(INativeWindow* window) + { + Ptr listener=nativeWindowListeners[window]; + nativeWindowListeners.Remove(window); + window->UninstallListener(listener.Obj()); + } + }; + + GdiWindowsNativeControllerListener* gdiListener=0; + + WinDC* GetNativeWindowDC(INativeWindow* window) + { + vint index=gdiListener->nativeWindowListeners.Keys().IndexOf(window); + return index==-1?0:gdiListener->nativeWindowListeners.Values().Get(index)->GetWinDC(); + } + + HDC GetNativeWindowHDC(INativeWindow* window) + { + WinDC* dc=GetNativeWindowDC(window); + return dc?dc->GetHandle():NULL; + } + } + + namespace elements_windows_gdi + { +/*********************************************************************** +OS Supporting +***********************************************************************/ + + class WinGDIApplicationGDIObjectProvider : public IWindowsGDIObjectProvider + { + protected: + IMLangFontLink2* mLangFontLink; + + public: + WinGDIApplicationGDIObjectProvider() + :mLangFontLink(0) + { + CoCreateInstance(CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER, IID_IMLangFontLink2, (void**)&mLangFontLink); + } + + ~WinGDIApplicationGDIObjectProvider() + { + mLangFontLink->Release(); + } + + windows::WinDC* GetNativeWindowDC(INativeWindow* window)override + { + return vl::presentation::windows::GetNativeWindowDC(window); + } + + IWindowsGDIRenderTarget* GetBindedRenderTarget(INativeWindow* window)override + { + return dynamic_cast(vl::presentation::windows::GetWindowsForm(window)->GetGraphicsHandler()); + } + + void SetBindedRenderTarget(INativeWindow* window, IWindowsGDIRenderTarget* renderTarget)override + { + vl::presentation::windows::GetWindowsForm(window)->SetGraphicsHandler(renderTarget); + } + + IWICImagingFactory* GetWICImagingFactory()override + { + return vl::presentation::windows::GetWICImagingFactory(); + } + + IWICBitmap* GetWICBitmap(INativeImageFrame* frame)override + { + return vl::presentation::windows::GetWICBitmap(frame); + } + + IMLangFontLink2* GetMLangFontLink()override + { + return mLangFontLink; + } + }; + } + } +} + +using namespace vl; +using namespace vl::presentation; +using namespace vl::presentation::windows; +using namespace vl::presentation::elements_windows_gdi; + +int WinMainGDI(HINSTANCE hInstance, void(*RendererMain)()) +{ + EnableCrossKernelCrashing(); + // create controller + INativeController* controller=CreateWindowsNativeController(hInstance); + SetCurrentController(controller); + { + // install listener + GdiWindowsNativeControllerListener listener; + controller->CallbackService()->InstallListener(&listener); + gdiListener=&listener; + // main + RendererMain(); + // uninstall listener + gdiListener=0; + controller->CallbackService()->UninstallListener(&listener); + } + // destroy controller + DestroyWindowsNativeController(controller); + return 0; +} + +int SetupWindowsGDIRenderer() +{ + CoInitializeEx(NULL, COINIT_MULTITHREADED); + HINSTANCE hInstance=(HINSTANCE)GetModuleHandle(NULL); + WinGDIApplicationGDIObjectProvider objectProvider; + SetWindowsGDIObjectProvider(&objectProvider); + return WinMainGDI(hInstance, &RendererMainGDI); +} + +/*********************************************************************** +.\NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSASYNCSERVICE.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace windows + { + using namespace collections; + +/*********************************************************************** +WindowsAsyncService::TaskItem +***********************************************************************/ + + WindowsAsyncService::TaskItem::TaskItem() + :semaphore(0) + { + } + + WindowsAsyncService::TaskItem::TaskItem(Semaphore* _semaphore, const Func& _proc) + :semaphore(_semaphore) + ,proc(_proc) + { + } + + WindowsAsyncService::TaskItem::~TaskItem() + { + } + +/*********************************************************************** +WindowsAsyncService::DelayItem +***********************************************************************/ + + WindowsAsyncService::DelayItem::DelayItem(WindowsAsyncService* _service, const Func& _proc, bool _executeInMainThread, vint milliseconds) + :service(_service) + ,proc(_proc) + ,status(INativeDelay::Pending) + ,executeTime(DateTime::LocalTime().Forward(milliseconds)) + ,executeInMainThread(_executeInMainThread) + { + } + + WindowsAsyncService::DelayItem::~DelayItem() + { + } + + INativeDelay::ExecuteStatus WindowsAsyncService::DelayItem::GetStatus() + { + return status; + } + + bool WindowsAsyncService::DelayItem::Delay(vint milliseconds) + { + SPIN_LOCK(service->taskListLock) + { + if(status==INativeDelay::Pending) + { + executeTime=DateTime::LocalTime().Forward(milliseconds); + return true; + } + } + return false; + } + + bool WindowsAsyncService::DelayItem::Cancel() + { + SPIN_LOCK(service->taskListLock) + { + if(status==INativeDelay::Pending) + { + if(service->delayItems.Remove(this)) + { + status=INativeDelay::Canceled; + return true; + } + } + } + return false; + } + +/*********************************************************************** +WindowsAsyncService +***********************************************************************/ + + WindowsAsyncService::WindowsAsyncService() + :mainThreadId(Thread::GetCurrentThreadId()) + { + } + + WindowsAsyncService::~WindowsAsyncService() + { + } + + void WindowsAsyncService::ExecuteAsyncTasks() + { + DateTime now=DateTime::LocalTime(); + Array items; + List> executableDelayItems; + + SPIN_LOCK(taskListLock) + { + CopyFrom(items, taskItems); + taskItems.RemoveRange(0, items.Count()); + for(vint i=delayItems.Count()-1;i>=0;i--) + { + Ptr item=delayItems[i]; + if(now.filetime>=item->executeTime.filetime) + { + item->status=INativeDelay::Executing; + executableDelayItems.Add(item); + delayItems.RemoveAt(i); + } + } + } + + FOREACH(TaskItem, item, items) + { + item.proc(); + if(item.semaphore) + { + item.semaphore->Release(); + } + } + FOREACH(Ptr, item, executableDelayItems) + { + if(item->executeInMainThread) + { + item->proc(); + item->status=INativeDelay::Executed; + } + else + { + InvokeAsync([=]() + { + item->proc(); + item->status=INativeDelay::Executed; + }); + } + } + } + + bool WindowsAsyncService::IsInMainThread() + { + return Thread::GetCurrentThreadId()==mainThreadId; + } + + void WindowsAsyncService::InvokeAsync(const Func& proc) + { + ThreadPoolLite::Queue(proc); + } + + void WindowsAsyncService::InvokeInMainThread(const Func& proc) + { + SPIN_LOCK(taskListLock) + { + TaskItem item(0, proc); + taskItems.Add(item); + } + } + + bool WindowsAsyncService::InvokeInMainThreadAndWait(const Func& proc, vint milliseconds) + { + Semaphore semaphore; + semaphore.Create(0, 1); + + SPIN_LOCK(taskListLock) + { + TaskItem item(&semaphore, proc); + taskItems.Add(item); + } + + if(milliseconds<0) + { + return semaphore.Wait(); + } + else + { + return semaphore.WaitForTime(milliseconds); + } + } + + Ptr WindowsAsyncService::DelayExecute(const Func& proc, vint milliseconds) + { + Ptr delay; + SPIN_LOCK(taskListLock) + { + delay=new DelayItem(this, proc, false, milliseconds); + delayItems.Add(delay); + } + return delay; + } + + Ptr WindowsAsyncService::DelayExecuteInMainThread(const Func& proc, vint milliseconds) + { + Ptr delay; + SPIN_LOCK(taskListLock) + { + delay=new DelayItem(this, proc, true, milliseconds); + delayItems.Add(delay); + } + return delay; + } + } + } +} + +/*********************************************************************** +.\NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSCALLBACKSERVICE.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace windows { /*********************************************************************** -WindowsDirect2DElementInlineObject +WindowsCallbackService ***********************************************************************/ - class WindowsDirect2DElementInlineObject : public IDWriteInlineObject + WindowsCallbackService::WindowsCallbackService() { - public: - class IRendererCallback : public Interface - { - public: - virtual Color GetBackgroundColor(vint textPosition) = 0; - virtual IWindowsDirect2DRenderTarget* GetDirect2DRenderTarget() = 0; - virtual Point GetParagraphOffset() = 0; - virtual IGuiGraphicsParagraphCallback* GetParagraphCallback() = 0; - }; + } + bool WindowsCallbackService::InstallListener(INativeControllerListener* listener) + { + if(listeners.Contains(listener)) + { + return false; + } + else + { + listeners.Add(listener); + return true; + } + } + + bool WindowsCallbackService::UninstallListener(INativeControllerListener* listener) + { + if(listeners.Contains(listener)) + { + listeners.Remove(listener); + return true; + } + else + { + return false; + } + } + + void WindowsCallbackService::InvokeMouseHook(WPARAM message, Point location) + { + switch(message) + { + case WM_LBUTTONDOWN: + { + for(vint i=0;iLeftButtonDown(location); + } + } + break; + case WM_LBUTTONUP: + { + for(vint i=0;iLeftButtonUp(location); + } + } + break; + case WM_RBUTTONDOWN: + { + for(vint i=0;iRightButtonDown(location); + } + } + break; + case WM_RBUTTONUP: + { + for(vint i=0;iRightButtonUp(location); + } + } + break; + case WM_MOUSEMOVE: + { + for(vint i=0;iMouseMoving(location); + } + } + break; + } + } + + void WindowsCallbackService::InvokeGlobalTimer() + { + for(vint i=0;iGlobalTimer(); + } + } + + void WindowsCallbackService::InvokeClipboardUpdated() + { + for(vint i=0;iClipboardUpdated(); + } + } + + void WindowsCallbackService::InvokeNativeWindowCreated(INativeWindow* window) + { + for(vint i=0;iNativeWindowCreated(window); + } + } + + void WindowsCallbackService::InvokeNativeWindowDestroyed(INativeWindow* window) + { + for(vint i=0;iNativeWindowDestroying(window); + } + } + } + } +} + +/*********************************************************************** +.\NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSCLIPBOARDSERVICE.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace windows + { + +/*********************************************************************** +WindowsClipboardService +***********************************************************************/ + + WindowsClipboardService::WindowsClipboardService() + :ownerHandle(NULL) + { + } + + void WindowsClipboardService::SetOwnerHandle(HWND handle) + { + HWND oldHandle=ownerHandle; + ownerHandle=handle; + if(handle==NULL) + { + RemoveClipboardFormatListener(oldHandle); + } + else + { + AddClipboardFormatListener(ownerHandle); + } + } + + bool WindowsClipboardService::ContainsText() + { + if(OpenClipboard(ownerHandle)) + { + UINT format=0; + bool contains=false; + while(format=EnumClipboardFormats(format)) + { + if(format==CF_TEXT || format==CF_UNICODETEXT) + { + contains=true; + break; + } + } + CloseClipboard(); + return contains; + } + return false; + } + + WString WindowsClipboardService::GetText() + { + if(OpenClipboard(ownerHandle)) + { + WString result; + HANDLE handle=GetClipboardData(CF_UNICODETEXT); + if(handle!=0) + { + wchar_t* buffer=(wchar_t*)GlobalLock(handle); + result=buffer; + GlobalUnlock(handle); + } + CloseClipboard(); + return result; + } + return L""; + } + + bool WindowsClipboardService::SetText(const WString& value) + { + if(OpenClipboard(ownerHandle)) + { + EmptyClipboard(); + vint size=(value.Length()+1)*sizeof(wchar_t); + HGLOBAL data=GlobalAlloc(GMEM_MOVEABLE, size); + wchar_t* buffer=(wchar_t*)GlobalLock(data); + memcpy(buffer, value.Buffer(), size); + GlobalUnlock(data); + SetClipboardData(CF_UNICODETEXT, data); + CloseClipboard(); + return true; + } + return false; + } + } + } +} + +/*********************************************************************** +.\NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSDIALOGSERVICE.CPP +***********************************************************************/ +#include + +#pragma comment(lib, "Vfw32.lib") + +namespace vl +{ + namespace presentation + { + namespace windows + { + using namespace collections; + +/*********************************************************************** +WindowsDialogService +***********************************************************************/ + + WindowsDialogService::WindowsDialogService(HandleRetriver _handleRetriver) + :handleRetriver(_handleRetriver) + { + } + + INativeDialogService::MessageBoxButtonsOutput WindowsDialogService::ShowMessageBox( + INativeWindow* window, + const WString& text, + const WString& title, + MessageBoxButtonsInput buttons, + MessageBoxDefaultButton defaultButton, + MessageBoxIcons icon, + MessageBoxModalOptions modal) + { + WString realTitle=title; + if(title==L"" && window!=0) + { + realTitle=window->GetTitle(); + } + HWND hWnd=handleRetriver(window); + LPCTSTR lpText=text.Buffer(); + LPCTSTR lpCaption=realTitle.Buffer(); + UINT uType=0; + +#define MAP(A, B) case A: uType|=(B); break + switch(buttons) + { + MAP(DisplayOK, MB_OK); + MAP(DisplayOKCancel, MB_OKCANCEL); + MAP(DisplayYesNo, MB_YESNO); + MAP(DisplayYesNoCancel, MB_YESNOCANCEL); + MAP(DisplayRetryCancel, MB_RETRYCANCEL); + MAP(DisplayAbortRetryIgnore, MB_ABORTRETRYIGNORE); + MAP(DisplayCancelTryAgainContinue, MB_CANCELTRYCONTINUE); + } + switch(defaultButton) + { + MAP(DefaultFirst, MB_DEFBUTTON1); + MAP(DefaultSecond, MB_DEFBUTTON2); + MAP(DefaultThird, MB_DEFBUTTON3); + } + switch(icon) + { + MAP(IconError, MB_ICONERROR); + MAP(IconQuestion, MB_ICONQUESTION); + MAP(IconWarning, MB_ICONWARNING); + MAP(IconInformation, MB_ICONINFORMATION); + } + switch(modal) + { + MAP(ModalWindow, MB_APPLMODAL); + MAP(ModalSystem, MB_SYSTEMMODAL); + MAP(ModalTask, MB_TASKMODAL); + } +#undef MAP + + vint result=MessageBox(hWnd, lpText, lpCaption, uType); + switch(result) + { + case IDABORT: return SelectAbort; + case IDCANCEL: return SelectCancel; + case IDCONTINUE: return SelectContinue; + case IDIGNORE: return SelectIgnore; + case IDNO: return SelectNo; + case IDOK: return SelectOK; + case IDRETRY: return SelectRetry; + case IDTRYAGAIN: return SelectTryAgain; + case IDYES: return SelectYes; + default: return SelectOK; + } + } + + bool WindowsDialogService::ShowColorDialog(INativeWindow* window, Color& selection, bool selected, ColorDialogCustomColorOptions customColorOptions, Color* customColors) + { + CHOOSECOLOR chooseColor; + ZeroMemory(&chooseColor, sizeof(chooseColor)); + COLORREF customColorsBuffer[16]={0}; + if(customColors) + { + for(vint i=0;iFW_REGULAR; + selectionFont.italic=logFont.lfItalic!=FALSE; + selectionFont.underline=logFont.lfUnderline!=FALSE; + selectionFont.strikeline=logFont.lfStrikeOut!=FALSE; + selectionFont.size=-logFont.lfHeight; + + selectionColor=Color(GetRValue(chooseFont.rgbColors), GetGValue(chooseFont.rgbColors), GetBValue(chooseFont.rgbColors)); + } + return result!=FALSE; + } + + bool WindowsDialogService::ShowFileDialog(INativeWindow* window, collections::List& selectionFileNames, vint& selectionFilterIndex, FileDialogTypes dialogType, const WString& title, const WString& initialFileName, const WString& initialDirectory, const WString& defaultExtension, const WString& filter, FileDialogOptions options) + { + Array fileNamesBuffer(65536>initialFileName.Length()+1?65536:initialFileName.Length()+1); + wcscpy_s(&fileNamesBuffer[0], fileNamesBuffer.Count(), initialFileName.Buffer()); + + OPENFILENAME ofn; + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize=sizeof(ofn); + ofn.hwndOwner=handleRetriver(window); + ofn.hInstance=NULL; + ofn.lpstrCustomFilter=NULL; + ofn.nMaxCustFilter=0; + ofn.nFilterIndex=(int)selectionFilterIndex+1; + ofn.lpstrFile=&fileNamesBuffer[0]; + ofn.nMaxFile=(int)fileNamesBuffer.Count(); + ofn.lpstrFileTitle=NULL; + ofn.nMaxFileTitle=0; + ofn.lpstrInitialDir=initialDirectory==L""?NULL:initialDirectory.Buffer(); + ofn.lpstrTitle=title==L""?NULL:title.Buffer(); + ofn.lpstrDefExt=defaultExtension==L""?NULL:defaultExtension.Buffer(); + + List filterSeparators; + for(vint i=0;i filterBuffer(filter.Length()+2); + vint index=0; + for(vint i=0;icurrentScreen==data->screenService->screens.Count()) + { + data->screenService->screens.Add(new WindowsScreen()); + } + data->screenService->screens[data->currentScreen]->monitor=hMonitor; + data->currentScreen++; + return TRUE; + } + + void WindowsScreenService::RefreshScreenInformation() + { + for(vint i=0;imonitor=NULL; + } + MonitorEnumProcData data; + data.screenService=this; + data.currentScreen=0; + EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM)(&data)); + } + + vint WindowsScreenService::GetScreenCount() + { + RefreshScreenInformation(); + return GetSystemMetrics(SM_CMONITORS); + } + + INativeScreen* WindowsScreenService::GetScreen(vint index) + { + RefreshScreenInformation(); + return screens[index].Obj(); + } + + INativeScreen* WindowsScreenService::GetScreen(INativeWindow* window) + { + RefreshScreenInformation(); + HWND hwnd=handleRetriver(window); + if(hwnd) + { + HMONITOR monitor=MonitorFromWindow(hwnd, MONITOR_DEFAULTTONULL); + if(monitor!=NULL) + { + for(vint i=0;imonitor==monitor) + { + return screens[i].Obj(); + } + } + } + } + return 0; + } + } + } +} + +/*********************************************************************** +.\NATIVEWINDOW\WINDOWS\WINNATIVEWINDOW.CPP +***********************************************************************/ + +#pragma comment(lib, "Imm32.lib") +#pragma comment(lib, "Shlwapi.lib") + +namespace vl +{ + namespace presentation + { + namespace windows + { + using namespace collections; + + HWND GetHWNDFromNativeWindowHandle(INativeWindow* window) + { + if(!window) return NULL; + IWindowsForm* form=GetWindowsForm(window); + if(!form) return NULL; + return form->GetWindowHandle(); + } + +/*********************************************************************** +WindowsClass +***********************************************************************/ + + class WinClass : public Object + { protected: - vint counter; - IGuiGraphicsParagraph::InlineObjectProperties properties; - IRendererCallback* rendererCallback; - vint start; - vint length; + WString name; + WNDCLASSEX windowClass; + ATOM windowAtom; public: - WindowsDirect2DElementInlineObject( - const IGuiGraphicsParagraph::InlineObjectProperties& _properties, - IRendererCallback* _rendererCallback, - vint _start, - vint _length - ) - :counter(1) - ,properties(_properties) - ,rendererCallback(_rendererCallback) - ,start(_start) - ,length(_length) + WinClass(WString _name, bool shadow, bool ownDC, WNDPROC procedure, HINSTANCE hInstance) { + name=_name; + windowClass.cbSize=sizeof(windowClass); + windowClass.style=CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | (shadow?CS_DROPSHADOW:0) | (ownDC?CS_OWNDC:0); + windowClass.lpfnWndProc=procedure; + windowClass.cbClsExtra=0; + windowClass.cbWndExtra=0; + windowClass.hInstance=hInstance; + windowClass.hIcon=LoadIcon(NULL,IDI_APPLICATION); + windowClass.hCursor=NULL;//LoadCursor(NULL,IDC_ARROW); + windowClass.hbrBackground=GetSysColorBrush(COLOR_BTNFACE); + windowClass.lpszMenuName=NULL; + windowClass.lpszClassName=name.Buffer(); + windowClass.hIconSm=NULL; + windowAtom=RegisterClassEx(&windowClass); } - ~WindowsDirect2DElementInlineObject() + bool IsAvailable() { - if (properties.backgroundImage) - { - IGuiGraphicsRenderer* graphicsRenderer=properties.backgroundImage->GetRenderer(); - if(graphicsRenderer) - { - graphicsRenderer->SetRenderTarget(0); - } - } + return windowAtom!=0; } - vint GetStart() + WString GetName() { - return start; + return name; } - vint GetLength() + ATOM GetClassAtom() { - return length; - } - - const IGuiGraphicsParagraph::InlineObjectProperties& GetProperties() - { - return properties; - } - - Ptr GetElement() - { - return properties.backgroundImage; - } - - HRESULT STDMETHODCALLTYPE QueryInterface( - REFIID riid, - void __RPC_FAR *__RPC_FAR *ppvObject - ) - { - if(ppvObject) - { - *ppvObject=NULL; - } - return E_NOINTERFACE; - } - - ULONG STDMETHODCALLTYPE AddRef(void) - { - ++counter; - return S_OK; - } - - ULONG STDMETHODCALLTYPE Release(void) - { - if(--counter==0) - { - delete this; - } - return S_OK; - } - - STDMETHOD(Draw)( - void* clientDrawingContext, - IDWriteTextRenderer* renderer, - FLOAT originX, - FLOAT originY, - BOOL isSideways, - BOOL isRightToLeft, - IUnknown* clientDrawingEffect - )override - { - Rect bounds(Point((vint)originX, (vint)originY), properties.size); - if (properties.backgroundImage) - { - IGuiGraphicsRenderer* graphicsRenderer=properties.backgroundImage->GetRenderer(); - if(graphicsRenderer) - { - graphicsRenderer->Render(bounds); - } - } - - Color color=rendererCallback->GetBackgroundColor(start); - if(color.a!=0) - { - color.a/=2; - if(IWindowsDirect2DRenderTarget* renderTarget=rendererCallback->GetDirect2DRenderTarget()) - { - ID2D1SolidColorBrush* brush=renderTarget->CreateDirect2DBrush(color); - - renderTarget->GetDirect2DRenderTarget()->FillRectangle( - D2D1::RectF(bounds.x1-0.5f, bounds.y1-0.5f, bounds.x2+0.5f, bounds.y2+0.5f), - brush - ); - - renderTarget->DestroyDirect2DBrush(color); - } - } - - if (properties.callbackId != -1) - { - if (auto callback = rendererCallback->GetParagraphCallback()) - { - auto offset = rendererCallback->GetParagraphOffset(); - auto size = callback->OnRenderInlineObject(properties.callbackId, Rect(Point(bounds.x1 - offset.x, bounds.y1 - offset.y), bounds.GetSize())); - properties.size = size; - } - } - return S_OK; - } - - STDMETHOD(GetMetrics)( - DWRITE_INLINE_OBJECT_METRICS* metrics - )override - { - metrics->width=(FLOAT)properties.size.x; - metrics->height=(FLOAT)properties.size.y; - metrics->baseline=(FLOAT)(properties.baseline==-1?properties.size.y:properties.baseline); - metrics->supportsSideways=TRUE; - return S_OK; - } - - STDMETHOD(GetOverhangMetrics)( - DWRITE_OVERHANG_METRICS* overhangs - )override - { - overhangs->left=0; - overhangs->right=0; - overhangs->top=0; - overhangs->bottom=0; - return S_OK; - } - - STDMETHOD(GetBreakConditions)( - DWRITE_BREAK_CONDITION* breakConditionBefore, - DWRITE_BREAK_CONDITION* breakConditionAfter - )override - { - switch(properties.breakCondition) - { - case IGuiGraphicsParagraph::StickToPreviousRun: - *breakConditionBefore=DWRITE_BREAK_CONDITION_MAY_NOT_BREAK; - *breakConditionAfter=DWRITE_BREAK_CONDITION_CAN_BREAK; - break; - case IGuiGraphicsParagraph::StickToNextRun: - *breakConditionBefore=DWRITE_BREAK_CONDITION_CAN_BREAK; - *breakConditionAfter=DWRITE_BREAK_CONDITION_MAY_NOT_BREAK; - break; - default: - *breakConditionBefore=DWRITE_BREAK_CONDITION_CAN_BREAK; - *breakConditionAfter=DWRITE_BREAK_CONDITION_CAN_BREAK; - } - return S_OK; + return windowAtom; } }; /*********************************************************************** -WindowsDirect2DParagraph +WindowsForm ***********************************************************************/ - class WindowsDirect2DParagraph : public Object, public IGuiGraphicsParagraph, public WindowsDirect2DElementInlineObject::IRendererCallback + class WindowsForm : public Object, public INativeWindow, public IWindowsForm { protected: - struct TextRange + + LONG_PTR InternalGetExStyle() { - vint start; - vint end; + return GetWindowLongPtr(handle, GWL_EXSTYLE); + } - TextRange(){} - TextRange(vint _start, vint _end):start(_start),end(_end){} - - bool operator==(const TextRange& range) const { return start==range.start; } - bool operator!=(const TextRange& range) const { return start!=range.start; } - bool operator<(const TextRange& range) const { return start(const TextRange& range) const { return start>range.start; } - bool operator>=(const TextRange& range) const { return start>=range.start; } - }; - - typedef Dictionary> InlineElementMap; - typedef Dictionary ColorMap; - typedef Dictionary GraphicsElementMap; - protected: - IGuiGraphicsLayoutProvider* provider; - ID2D1SolidColorBrush* defaultTextColor; - IDWriteFactory* dwriteFactory; - IWindowsDirect2DRenderTarget* renderTarget; - WString paragraphText; - ComPtr textLayout; - bool wrapLine; - vint maxWidth; - List usedColors; - - InlineElementMap inlineElements; - GraphicsElementMap graphicsElements; - ColorMap backgroundColors; - - vint caret; - Color caretColor; - bool caretFrontSide; - ID2D1SolidColorBrush* caretBrush; - - bool formatDataAvailable; - Array lineMetrics; - Array lineStarts; - Array lineTops; - Array clusterMetrics; - Array hitTestMetrics; - Array charHitTestMap; - - Point paragraphOffset; - IGuiGraphicsParagraphCallback* paragraphCallback; - -/*********************************************************************** -WindowsDirect2DParagraph (Ranges) -***********************************************************************/ - - template - void CutMap(Dictionary& map, vint start, vint length) + void InternalSetExStyle(LONG_PTR exStyle) { - vint end=start+length; - for(vint i=map.Count()-1;i>=0;i--) + LONG_PTR result = SetWindowLongPtr(handle, GWL_EXSTYLE, exStyle); + SetWindowPos(handle, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED); + } + + bool GetExStyle(LONG_PTR exStyle) + { + LONG_PTR Long=InternalGetExStyle(); + return (Long & exStyle) != 0; + } + + void SetExStyle(LONG_PTR exStyle, bool available) + { + LONG_PTR Long = InternalGetExStyle(); + if(available) { - TextRange key=map.Keys()[i]; - if(key.startstart?key.start:start; - vint s3=key.end - void UpdateOverlappedMap(Dictionary& map, vint start, vint length, const T& value) - { - vint end=start+length; - for(vint i=map.Count()-1;i>=0;i--) - { - TextRange key=map.Keys()[i]; - if(key.start - void DefragmentMap(Dictionary& map) - { - vint lastIndex=map.Count()-1; - T lastValue=map.Values()[lastIndex]; - for(vint i=map.Count()-2;i>=-1;i--) - { - if(i==-1 || map.Values()[i]!=lastValue) - { - if(lastIndex-i>0) - { - vint start=map.Keys()[i+1].start; - vint end=map.Keys()[lastIndex].end; - TextRange key(start, end); - for(vint j=lastIndex;j>i;j--) - { - map.Remove(map.Keys()[j]); - } - map.Add(key, lastValue); - } - lastIndex=i; - if(i!=-1) - { - lastValue=map.Values()[i]; - } - } - } - } - - template - void SetMap(Dictionary& map, vint start, vint length, const T& value) - { - CutMap(map, start, length); - UpdateOverlappedMap(map, start, length, value); - DefragmentMap(map); - } - - template - bool GetMap(Dictionary& map, vint textPosition, T& value) - { - vint start=0; - vint end=map.Count()-1; - while(start<=end) + if(wheelMessage) { - vint middle=(start+end)/2; - TextRange key=map.Keys()[middle]; - if(textPosition=key.end) - { - start=middle+1; + Point offset = GetClientBoundsInScreen().LeftTop(); + info.x = point.x - offset.x; + info.y = point.y - offset.y; } else { - value=map.Values()[middle]; + info.x = point.x; + info.y = point.y; + } + } + return info; + } + + NativeWindowKeyInfo ConvertKey(WPARAM wParam, LPARAM lParam) + { + NativeWindowKeyInfo info; + info.code=wParam; + info.ctrl=WinIsKeyPressing(VK_CONTROL); + info.shift=WinIsKeyPressing(VK_SHIFT); + info.alt=WinIsKeyPressing(VK_MENU); + info.capslock=WinIsKeyToggled(VK_CAPITAL); + return info; + } + + NativeWindowCharInfo ConvertChar(WPARAM wParam) + { + NativeWindowCharInfo info; + info.code=(wchar_t)wParam; + info.ctrl=WinIsKeyPressing(VK_CONTROL); + info.shift=WinIsKeyPressing(VK_SHIFT); + info.alt=WinIsKeyPressing(VK_MENU); + info.capslock=WinIsKeyToggled(VK_CAPITAL); + return info; + } + + void TrackMouse(bool enable) + { + TRACKMOUSEEVENT trackMouseEvent; + trackMouseEvent.cbSize=sizeof(trackMouseEvent); + trackMouseEvent.hwndTrack=handle; + trackMouseEvent.dwFlags=(enable?0:TME_CANCEL) | TME_HOVER | TME_LEAVE; + trackMouseEvent.dwHoverTime=HOVER_DEFAULT; + TrackMouseEvent(&trackMouseEvent); + } + + void UpdateCompositionForContent() + { + HIMC imc = ImmGetContext(handle); + COMPOSITIONFORM cf; + cf.dwStyle = CFS_POINT; + cf.ptCurrentPos.x = (int)caretPoint.x; + cf.ptCurrentPos.y = (int)caretPoint.y; + ImmSetCompositionWindow(imc, &cf); + ImmReleaseContext(handle, imc); + } + + bool HandleMessageInternal(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& result) + { + bool transferFocusEvent = false; + bool nonClient = false; + + switch(uMsg) + { + case WM_LBUTTONDOWN: + case WM_LBUTTONUP: + case WM_LBUTTONDBLCLK: + case WM_RBUTTONDOWN: + case WM_RBUTTONUP: + case WM_RBUTTONDBLCLK: + case WM_MBUTTONDOWN: + case WM_MBUTTONUP: + case WM_MBUTTONDBLCLK: + transferFocusEvent=true; + } + switch(uMsg) + { + // ************************************** moving and sizing + case WM_MOVING:case WM_SIZING: + { + LPRECT rawBounds=(LPRECT)lParam; + Rect bounds(rawBounds->left, rawBounds->top, rawBounds->right, rawBounds->bottom); + for(vint i=0;iMoving(bounds, false); + } + if( rawBounds->left!=bounds.Left() + || rawBounds->top!=bounds.Top() + || rawBounds->right!=bounds.Right() + || rawBounds->bottom!=bounds.Bottom()) + { + rawBounds->left=(int)bounds.Left(); + rawBounds->top=(int)bounds.Top(); + rawBounds->right=(int)bounds.Right(); + rawBounds->bottom=(int)bounds.Bottom(); + result=TRUE; + } + } + break; + case WM_MOVE:case WM_SIZE: + { + for(vint i=0;iMoved(); + } + } + break; + // ************************************** state + case WM_ENABLE: + { + for(vint i=0;iEnabled(); + } + else + { + listeners[i]->Disabled(); + } + } + } + break; + case WM_SETFOCUS: + { + for(vint i=0;iGotFocus(); + } + } + break; + case WM_KILLFOCUS: + { + for(vint i=0;iLostFocus(); + } + } + break; + case WM_ACTIVATE: + { + for(vint i=0;iActivated(); + } + else + { + listeners[i]->Deactivated(); + } + } + } + break; + case WM_SHOWWINDOW: + { + if(wParam==TRUE) + { + for(vint i=0;iOpened(); + } + } + else + { + for(vint i=0;iClosed(); + } + } + } + break; + case WM_CLOSE: + { + bool cancel=false; + for(vint i=0;iClosing(cancel); + } + return cancel; + } + break; + // ************************************** mouse + case WM_NCLBUTTONDOWN: + if (!customFrameMode) break; + nonClient = true; + case WM_LBUTTONDOWN: + { + NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, false, nonClient); + for(vint i=0;iLeftButtonDown(info); + } + } + break; + case WM_NCLBUTTONUP: + if (!customFrameMode) break; + nonClient = true; + case WM_LBUTTONUP: + { + NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, false, nonClient); + for(vint i=0;iLeftButtonUp(info); + } + } + break; + case WM_NCLBUTTONDBLCLK: + if (!customFrameMode) break; + nonClient = true; + case WM_LBUTTONDBLCLK: + { + NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, false, nonClient); + for(vint i=0;iLeftButtonDoubleClick(info); + } + } + break; + case WM_NCRBUTTONDOWN: + if (!customFrameMode) break; + nonClient = true; + case WM_RBUTTONDOWN: + { + NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, false, nonClient); + for(vint i=0;iRightButtonDown(info); + } + } + break; + case WM_NCRBUTTONUP: + if (!customFrameMode) break; + nonClient = true; + case WM_RBUTTONUP: + { + NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, false, nonClient); + for(vint i=0;iRightButtonUp(info); + } + } + break; + case WM_NCRBUTTONDBLCLK: + if (!customFrameMode) break; + nonClient = true; + case WM_RBUTTONDBLCLK: + { + NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, false, nonClient); + for(vint i=0;iRightButtonDoubleClick(info); + } + } + break; + case WM_NCMBUTTONDOWN: + if (!customFrameMode) break; + nonClient = true; + case WM_MBUTTONDOWN: + { + NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, false, nonClient); + for(vint i=0;iMiddleButtonDown(info); + } + } + break; + case WM_NCMBUTTONUP: + if (!customFrameMode) break; + nonClient = true; + case WM_MBUTTONUP: + { + NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, false, nonClient); + for(vint i=0;iMiddleButtonUp(info); + } + } + break; + case WM_NCMBUTTONDBLCLK: + if (!customFrameMode) break; + nonClient = true; + case WM_MBUTTONDBLCLK: + { + NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, false, nonClient); + for(vint i=0;iMiddleButtonDoubleClick(info); + } + } + break; + case WM_NCMOUSEMOVE: + if (!customFrameMode) break; + nonClient = true; + case WM_MOUSEMOVE: + { + NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, false, nonClient); + if(info.x!=mouseLastX || info.y!=mouseLastY) + { + if(!mouseHoving) + { + mouseHoving=true; + for(vint i=0;iMouseEntered(); + } + TrackMouse(true); + } + for(vint i=0;iMouseMoving(info); + } + } + } + break; + // ************************************** wheel + case WM_MOUSEHWHEEL: + { + NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, true, false); + for(vint i=0;iHorizontalWheel(info); + } + } + break; + case WM_MOUSEWHEEL: + { + NativeWindowMouseInfo info=ConvertMouse(wParam, lParam, true, false); + for(vint i=0;iVerticalWheel(info); + } + } + break; + // ************************************** mouse state + case WM_NCMOUSELEAVE: + nonClient = true; + case WM_MOUSELEAVE: + if (customFrameMode == nonClient) + { + mouseLastX=-1; + mouseLastY=-1; + mouseHoving=false; + for(vint i=0;iMouseLeaved(); + } + } + break; + case WM_NCMOUSEHOVER: + case WM_MOUSEHOVER: + { + TrackMouse(true); + } + break; + // ************************************** key + case WM_KEYUP: + { + NativeWindowKeyInfo info=ConvertKey(wParam, lParam); + for(vint i=0;iKeyUp(info); + } + } + break; + case WM_KEYDOWN: + { + NativeWindowKeyInfo info=ConvertKey(wParam, lParam); + for(vint i=0;iKeyDown(info); + } + } + break; + case WM_SYSKEYUP: + { + NativeWindowKeyInfo info=ConvertKey(wParam, lParam); + if (supressingAlt && !info.ctrl && !info.shift && info.code == VK_MENU) + { + supressingAlt = false; + break; + } + for(vint i=0;iSysKeyUp(info); + } + } + break; + case WM_SYSKEYDOWN: + { + NativeWindowKeyInfo info=ConvertKey(wParam, lParam); + if (supressingAlt && !info.ctrl && !info.shift && info.code == VK_MENU) + { + break; + } + for(vint i=0;iSysKeyDown(info); + } + } + break; + case WM_CHAR: + { + NativeWindowCharInfo info=ConvertChar(wParam); + for(vint i=0;iChar(info); + } + } + break; + // ************************************** painting + case WM_PAINT: + { + for(vint i=0;iPaint(); + } + } + break; + case WM_ERASEBKGND: + result = 0; + return true; + case WM_NCPAINT: + case WM_SYNCPAINT: + if(customFrameMode) + { + result=0; return true; } + break; + // ************************************** IME + case WM_IME_SETCONTEXT: + if(wParam==TRUE) + { + HIMC imc = ImmGetContext(handle); + ImmAssociateContext(hwnd, imc); + ImmReleaseContext(handle, imc); + } + break; + case WM_IME_STARTCOMPOSITION: + UpdateCompositionForContent(); + break; + // ************************************** hit test + case WM_NCHITTEST: + { + POINTS location=MAKEPOINTS(lParam); + Point windowLocation=GetBounds().LeftTop(); + location.x-=(SHORT)windowLocation.x; + location.y-=(SHORT)windowLocation.y; + for(vint i=0;iHitTest(Point(location.x, location.y))) + { + case INativeWindowListener::BorderNoSizing: + result=HTBORDER; + return true; + case INativeWindowListener::BorderLeft: + result=HTLEFT; + return true; + case INativeWindowListener::BorderRight: + result=HTRIGHT; + return true; + case INativeWindowListener::BorderTop: + result=HTTOP; + return true; + case INativeWindowListener::BorderBottom: + result=HTBOTTOM; + return true; + case INativeWindowListener::BorderLeftTop: + result=HTTOPLEFT; + return true; + case INativeWindowListener::BorderRightTop: + result=HTTOPRIGHT; + return true; + case INativeWindowListener::BorderLeftBottom: + result=HTBOTTOMLEFT; + return true; + case INativeWindowListener::BorderRightBottom: + result=HTBOTTOMRIGHT; + return true; + case INativeWindowListener::Title: + result=HTCAPTION; + return true; + case INativeWindowListener::ButtonMinimum: + result=HTMINBUTTON; + return true; + case INativeWindowListener::ButtonMaximum: + result=HTMAXBUTTON; + return true; + case INativeWindowListener::ButtonClose: + result=HTCLOSE; + return true; + case INativeWindowListener::Client: + result=HTCLIENT; + return true; + case INativeWindowListener::Icon: + result=HTSYSMENU; + return true; + } + } + } + break; + // ************************************** MISC + case WM_SETCURSOR: + { + DWORD hitTestResult=LOWORD(lParam); + if(hitTestResult==HTCLIENT) + { + HCURSOR cursorHandle=cursor->GetCursorHandle(); + if(GetCursor()!=cursorHandle) + { + SetCursor(cursorHandle); + } + result=TRUE; + return true; + } + } + break; + case WM_NCCALCSIZE: + if((BOOL)wParam && customFrameMode) + { + result=0; + return true; + } + break; + case WM_NCACTIVATE: + if(customFrameMode) + { + if(wParam==TRUE) + { + result=FALSE; + } + else + { + result=TRUE; + } + return true; + } + break; + } + + if(IsWindow(hwnd)!=0) + { + if(transferFocusEvent && IsFocused()) + { + WindowsForm* window=this; + while(window->parentWindow && window->alwaysPassFocusToParent) + { + window=window->parentWindow; + } + if(window!=this) + { + window->SetFocus(); + } + } + } + + if (customFrameMode) + { + switch (uMsg) + { + case WM_NCLBUTTONDOWN: + switch (wParam) + { + case HTMINBUTTON: + case HTMAXBUTTON: + case HTCLOSE: + result = 0; + return true; + } + break; + case WM_LBUTTONUP: + { + POINTS location = MAKEPOINTS(lParam); + for(vint i=0;iHitTest(Point(location.x, location.y))) + { + case INativeWindowListener::ButtonMinimum: + ShowMinimized(); + return false; + case INativeWindowListener::ButtonMaximum: + if (GetSizeState() == INativeWindow::Maximized) + { + ShowRestored(); + } + else + { + ShowMaximized(); + } + return false; + case INativeWindowListener::ButtonClose: + Hide(); + return false; + } + } + } + break; + } } return false; } + protected: + HWND handle; + WString title; + WindowsCursor* cursor; + Point caretPoint; + WindowsForm* parentWindow; + bool alwaysPassFocusToParent; + List listeners; + vint mouseLastX; + vint mouseLastY; + vint mouseHoving; + Interface* graphicsHandler; + bool customFrameMode; + List> messageHandlers; + bool supressingAlt; -/*********************************************************************** -WindowsDirect2DParagraph (Layout Retriving) -***********************************************************************/ - - void PrepareFormatData() - { - if(!formatDataAvailable) - { - formatDataAvailable=true; - { - UINT32 lineCount=0; - textLayout->GetLineMetrics(NULL, 0, &lineCount); - lineMetrics.Resize(lineCount); - if(lineCount>0) - { - textLayout->GetLineMetrics(&lineMetrics[0], lineCount, &lineCount); - } - - lineStarts.Resize(lineCount); - lineTops.Resize(lineCount); - vint start=0; - FLOAT top=0; - for(vint i=0;iGetClusterMetrics(NULL, 0, &clusterCount); - clusterMetrics.Resize(clusterCount); - if(clusterCount>0) - { - textLayout->GetClusterMetrics(&clusterMetrics[0], clusterCount, &clusterCount); - } - } - { - vint textPos=0; - hitTestMetrics.Resize(clusterMetrics.Count()); - for(vint i=0;iHitTestTextPosition((UINT32)textPos, FALSE, &x, &y, &metrics); - textPos+=metrics.length; - } - } - { - charHitTestMap.Resize(paragraphText.Length()); - for(vint i=0;iGetDirectWriteFactory()) - ,renderTarget(dynamic_cast(_renderTarget)) - ,paragraphText(_text) - ,textLayout(0) - ,wrapLine(true) - ,maxWidth(-1) - ,caret(-1) - ,caretFrontSide(false) - ,caretBrush(0) - ,formatDataAvailable(false) - ,paragraphCallback(_paragraphCallback) + WindowsForm(HWND parent, WString className, HINSTANCE hInstance) + :cursor(0) + ,parentWindow(0) + ,alwaysPassFocusToParent(false) + ,mouseLastX(-1) + ,mouseLastY(-1) + ,mouseHoving(false) + ,graphicsHandler(0) + ,customFrameMode(false) + ,supressingAlt(false) { - FontProperties defaultFont=GetCurrentController()->ResourceService()->GetDefaultFont(); - Direct2DTextFormatPackage* package=GetWindowsDirect2DResourceManager()->CreateDirect2DTextFormat(defaultFont); - defaultTextColor=renderTarget->CreateDirect2DBrush(Color(0, 0, 0)); - usedColors.Add(Color(0, 0, 0)); - - IDWriteTextLayout* rawTextLayout=0; - HRESULT hr=dwriteFactory->CreateTextLayout( - _text.Buffer(), - (int)_text.Length(), - package->textFormat.Obj(), - 0, - 0, - &rawTextLayout); - if(!FAILED(hr)) - { - textLayout=rawTextLayout; - textLayout->SetWordWrapping(DWRITE_WORD_WRAPPING_WRAP); - } - graphicsElements.Add(TextRange(0, _text.Length()), 0); - backgroundColors.Add(TextRange(0, _text.Length()), Color(0, 0, 0, 0)); - - GetWindowsDirect2DResourceManager()->DestroyDirect2DTextFormat(defaultFont); + DWORD exStyle = WS_EX_APPWINDOW | WS_EX_CONTROLPARENT; + DWORD style = WS_BORDER | WS_CAPTION | WS_SIZEBOX | WS_SYSMENU | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_MAXIMIZEBOX | WS_MINIMIZEBOX; + handle=CreateWindowEx(exStyle, className.Buffer(), L"", style, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, parent, NULL, hInstance, NULL); } - ~WindowsDirect2DParagraph() + ~WindowsForm() { - CloseCaret(); - FOREACH(Color, color, usedColors) + List copiedListeners; + CopyFrom(copiedListeners, listeners); + for(vint i=0;iDestroyDirect2DBrush(color); + INativeWindowListener* listener=copiedListeners[i]; + if(listeners.Contains(listener)) + { + listener->Destroyed(); + } + } + DestroyWindow(handle); + } + + void InvokeDestroying() + { + for(vint i=0;iDestroying(); } } - IGuiGraphicsLayoutProvider* GetProvider()override + bool HandleMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& result) { - return provider; - } - - IGuiGraphicsRenderTarget* GetRenderTarget()override - { - return renderTarget; - } - - Point GetParagraphOffset()override - { - return paragraphOffset; - } - - IGuiGraphicsParagraphCallback* GetParagraphCallback()override - { - return paragraphCallback; - } - -/*********************************************************************** -WindowsDirect2DParagraph (Formatting) -***********************************************************************/ - - bool GetWrapLine()override - { - return wrapLine; - } - - void SetWrapLine(bool value)override - { - if(wrapLine!=value) + bool skip = false; { - wrapLine=value; - textLayout->SetWordWrapping(value?DWRITE_WORD_WRAPPING_WRAP:DWRITE_WORD_WRAPPING_NO_WRAP); - formatDataAvailable=false; + FOREACH(Ptr, handler, messageHandlers) + { + handler->BeforeHandle(hwnd, uMsg, wParam, lParam, skip); + } + if (skip) + { + return true; + } } - } - - vint GetMaxWidth()override - { - return maxWidth; - } - - void SetMaxWidth(vint value)override - { - if(maxWidth!=value) + skip = HandleMessageInternal(hwnd, uMsg, wParam, lParam, result); + if (GetWindowsFormFromHandle(hwnd)) { - maxWidth=value; - textLayout->SetMaxWidth(value==-1?65536:(FLOAT)value); - formatDataAvailable=false; + FOREACH(Ptr, handler, messageHandlers) + { + handler->AfterHandle(hwnd, uMsg, wParam, lParam, skip, result); + } } + return skip; } - Alignment GetParagraphAlignment()override + HWND GetWindowHandle()override { - switch(textLayout->GetTextAlignment()) - { - case DWRITE_TEXT_ALIGNMENT_LEADING: - return Alignment::Left; - case DWRITE_TEXT_ALIGNMENT_CENTER: - return Alignment::Center; - case DWRITE_TEXT_ALIGNMENT_TRAILING: - return Alignment::Right; - default: - return Alignment::Left; - } + return handle; } - void SetParagraphAlignment(Alignment value)override + Interface* GetGraphicsHandler()override { - formatDataAvailable=false; - switch(value) - { - case Alignment::Left: - textLayout->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING); - break; - case Alignment::Center: - textLayout->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); - break; - case Alignment::Right: - textLayout->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_TRAILING); - break; - } + return graphicsHandler; } - bool SetFont(vint start, vint length, const WString& value)override + void SetGraphicsHandler(Interface* handler)override { - if(length==0) return true; - formatDataAvailable=false; - - DWRITE_TEXT_RANGE range; - range.startPosition=(int)start; - range.length=(int)length; - HRESULT hr=textLayout->SetFontFamilyName(value.Buffer(), range); - return !FAILED(hr); + graphicsHandler=handler; } - bool SetSize(vint start, vint length, vint value)override + bool InstallMessageHandler(Ptr handler)override { - if(length==0) return true; - formatDataAvailable=false; - - DWRITE_TEXT_RANGE range; - range.startPosition=(int)start; - range.length=(int)length; - HRESULT hr=textLayout->SetFontSize((FLOAT)value, range); - return !FAILED(hr); - } - - bool SetStyle(vint start, vint length, TextStyle value)override - { - if(length==0) return true; - formatDataAvailable=false; - - DWRITE_TEXT_RANGE range; - range.startPosition=(int)start; - range.length=(int)length; - HRESULT hr=S_OK; - - hr=textLayout->SetFontStyle(value&Italic?DWRITE_FONT_STYLE_ITALIC:DWRITE_FONT_STYLE_NORMAL, range); - if(FAILED(hr)) return false; - hr=textLayout->SetFontWeight(value&Bold?DWRITE_FONT_WEIGHT_BOLD:DWRITE_FONT_WEIGHT_NORMAL, range); - if(FAILED(hr)) return false; - hr=textLayout->SetUnderline(value&Underline?TRUE:FALSE, range); - if(FAILED(hr)) return false; - hr=textLayout->SetStrikethrough(value&Strikeline?TRUE:FALSE, range); - if(FAILED(hr)) return false; - - return true; - } - - bool SetColor(vint start, vint length, Color value)override - { - if(length==0) return true; - formatDataAvailable=false; - - ID2D1SolidColorBrush* brush=renderTarget->CreateDirect2DBrush(value); - usedColors.Add(value); - - DWRITE_TEXT_RANGE range; - range.startPosition=(int)start; - range.length=(int)length; - HRESULT hr=textLayout->SetDrawingEffect(brush, range); - return !FAILED(hr); - } - - bool SetBackgroundColor(vint start, vint length, Color value)override - { - SetMap(backgroundColors, start, length, value); - return true; - } - - bool SetInlineObject(vint start, vint length, const InlineObjectProperties& properties)override - { - if(inlineElements.Keys().Contains(properties.backgroundImage.Obj())) + if (messageHandlers.Contains(handler.Obj())) { return false; } - for(vint i=0;i handler)override + { + vint index = messageHandlers.IndexOf(handler.Obj()); + if (index == -1)return false; + messageHandlers.RemoveAt(handler); + return true; + } + + Rect GetBounds() + { + RECT rect; + GetWindowRect(handle, &rect); + return Rect(rect.left, rect.top, rect.right, rect.bottom); + } + + void SetBounds(const Rect& bounds) + { + Rect newBounds=bounds; + for(vint i=0;i inlineObject=inlineElements.Values().Get(i); - if(startGetStart()+inlineObject->GetLength() && inlineObject->GetStart()Moving(newBounds, true); + } + MoveWindow(handle, (int)newBounds.Left(), (int)newBounds.Top(), (int)newBounds.Width(), (int)newBounds.Height(), FALSE); + } + + Size GetClientSize() + { + return GetClientBoundsInScreen().GetSize(); + } + + void SetClientSize(Size size) + { + RECT required={0,0,(int)size.x,(int)size.y}; + RECT bounds; + GetWindowRect(handle, &bounds); + AdjustWindowRect(&required, (DWORD)GetWindowLongPtr(handle, GWL_STYLE), FALSE); + SetBounds(Rect(Point(bounds.left, bounds.top), Size(required.right-required.left, required.bottom-required.top))); + } + + Rect GetClientBoundsInScreen() + { + if(customFrameMode) + { + return GetBounds(); + } + else + { + RECT required={0,0,0,0}; + RECT bounds; + GetWindowRect(handle, &bounds); + AdjustWindowRect(&required, (DWORD)GetWindowLongPtr(handle, GWL_STYLE), FALSE); + return Rect( + Point( + (bounds.left-required.left), + (bounds.top-required.top) + ), + Size( + (bounds.right-bounds.left)-(required.right-required.left), + (bounds.bottom-bounds.top)-(required.bottom-required.top) + ) + ); + } + } + + WString GetTitle() + { + return title; + } + + void SetTitle(WString _title) + { + title=_title; + SetWindowText(handle, title.Buffer()); + } + + INativeCursor* GetWindowCursor() + { + return cursor; + } + + void SetWindowCursor(INativeCursor* _cursor) + { + WindowsCursor* newCursor=dynamic_cast(_cursor); + if(newCursor && cursor!=newCursor) + { + cursor=newCursor; + if(mouseHoving && IsVisible()) { - return false; + SetCursor(cursor->GetCursorHandle()); } } - formatDataAvailable=false; + } + + Point GetCaretPoint() + { + return caretPoint; + } - ComPtr inlineObject=new WindowsDirect2DElementInlineObject(properties, this, start, length); - DWRITE_TEXT_RANGE range; - range.startPosition=(int)start; - range.length=(int)length; - HRESULT hr=textLayout->SetInlineObject(inlineObject.Obj(), range); - if(!FAILED(hr)) + void SetCaretPoint(Point point) + { + caretPoint=point; + UpdateCompositionForContent(); + } + + INativeWindow* GetParent() + { + return parentWindow; + } + + void SetParent(INativeWindow* parent) + { + parentWindow=dynamic_cast(parent); + if(parentWindow) { - if (properties.backgroundImage) - { - IGuiGraphicsRenderer* renderer=properties.backgroundImage->GetRenderer(); - if(renderer) - { - renderer->SetRenderTarget(renderTarget); - } - inlineElements.Add(properties.backgroundImage.Obj(), inlineObject); - } - SetMap(graphicsElements, start, length, properties.backgroundImage.Obj()); + SetWindowLongPtr(handle, GWLP_HWNDPARENT, (LONG_PTR)parentWindow->handle); + } + else + { + SetWindowLongPtr(handle, GWLP_HWNDPARENT, NULL); + } + } + + bool GetAlwaysPassFocusToParent() + { + return alwaysPassFocusToParent; + } + + void SetAlwaysPassFocusToParent(bool value) + { + alwaysPassFocusToParent=value; + } + + void EnableCustomFrameMode() + { + customFrameMode=true; + } + + void DisableCustomFrameMode() + { + customFrameMode=false; + } + + bool IsCustomFrameModeEnabled() + { + return customFrameMode; + } + + WindowSizeState GetSizeState() + { + if(IsIconic(handle)) + { + return INativeWindow::Minimized; + } + else if(IsZoomed(handle)) + { + return INativeWindow::Maximized; + } + else + { + return INativeWindow::Restored; + } + } + + void Show() + { + ShowWindow(handle, SW_SHOWNORMAL); + } + + void ShowDeactivated() + { + ShowWindow(handle, SW_SHOWNOACTIVATE); + SetWindowPos(handle,HWND_TOP,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); + } + + void ShowRestored() + { + ShowWindow(handle, SW_RESTORE); + } + + void ShowMaximized() + { + ShowWindow(handle, SW_SHOWMAXIMIZED); + } + + void ShowMinimized() + { + ShowWindow(handle, SW_SHOWMINIMIZED); + } + + void Hide() + { + SendMessage(handle, WM_CLOSE, NULL, NULL); + } + + bool IsVisible() + { + return IsWindowVisible(handle)!=0; + } + + void Enable() + { + EnableWindow(handle, TRUE); + } + + void Disable() + { + EnableWindow(handle, FALSE); + } + + bool IsEnabled() + { + return IsWindowEnabled(handle)!=0; + } + + void SetFocus() + { + ::SetFocus(handle); + } + + bool IsFocused() + { + return GetFocus()==handle; + } + + void SetActivate() + { + SetActiveWindow(handle); + } + + bool IsActivated() + { + return GetActiveWindow()==handle; + } + + void ShowInTaskBar() + { + SetExStyle(WS_EX_APPWINDOW, true); + } + + void HideInTaskBar() + { + SetExStyle(WS_EX_APPWINDOW, false); + } + + bool IsAppearedInTaskBar() + { + return GetExStyle(WS_EX_APPWINDOW); + } + + void EnableActivate() + { + SetExStyle(WS_EX_NOACTIVATE, false); + } + + void DisableActivate() + { + SetExStyle(WS_EX_NOACTIVATE, true); + } + + bool IsEnabledActivate() + { + return !GetExStyle(WS_EX_NOACTIVATE); + } + + bool RequireCapture() + { + SetCapture(handle); + return true; + } + + bool ReleaseCapture() + { + ::ReleaseCapture(); + return true; + } + + bool IsCapturing() + { + return GetCapture()==handle; + } + + bool GetMaximizedBox() + { + return GetStyle(WS_MAXIMIZEBOX); + } + + void SetMaximizedBox(bool visible) + { + SetStyle(WS_MAXIMIZEBOX, visible); + } + + bool GetMinimizedBox() + { + return GetStyle(WS_MINIMIZEBOX); + } + + void SetMinimizedBox(bool visible) + { + SetStyle(WS_MINIMIZEBOX, visible); + } + + bool GetBorder() + { + return GetStyle(WS_BORDER); + } + + void SetBorder(bool visible) + { + SetStyle(WS_BORDER, visible); + } + + bool GetSizeBox() + { + return GetStyle(WS_SIZEBOX); + } + + void SetSizeBox(bool visible) + { + SetStyle(WS_SIZEBOX, visible); + } + + bool GetIconVisible() + { + return GetStyle(WS_SYSMENU); + } + + void SetIconVisible(bool visible) + { + SetStyle(WS_SYSMENU, visible); + } + + bool GetTitleBar() + { + return GetStyle(WS_CAPTION); + } + + void SetTitleBar(bool visible) + { + SetStyle(WS_CAPTION, visible); + } + + bool GetTopMost() + { + return GetExStyle(WS_EX_TOPMOST); + } + + void SetTopMost(bool topmost) + { + SetWindowPos(handle, (topmost ? HWND_TOPMOST : HWND_NOTOPMOST), 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_FRAMECHANGED); + } + + void SupressAlt() + { + if (!supressingAlt) + { + supressingAlt = true; + PostMessage(handle, WM_SYSKEYDOWN, VK_MENU, 0); + PostMessage(handle, WM_SYSKEYUP, VK_MENU, 0); + } + } + + bool InstallListener(INativeWindowListener* listener) + { + if(listeners.Contains(listener)) + { + return false; + } + else + { + listeners.Add(listener); + return true; + } + } + + bool UninstallListener(INativeWindowListener* listener) + { + if(listeners.Contains(listener)) + { + listeners.Remove(listener); return true; } else @@ -10966,2512 +13102,352 @@ WindowsDirect2DParagraph (Formatting) } } - bool ResetInlineObject(vint start, vint length)override + void RedrawContent() { - IGuiGraphicsElement* element=0; - if(GetMap(graphicsElements, start, element) && element) + if(graphicsHandler) { - ComPtr inlineObject=inlineElements[element]; - DWRITE_TEXT_RANGE range; - range.startPosition=(int)inlineObject->GetStart(); - range.length=(int)inlineObject->GetLength(); - HRESULT hr=textLayout->SetInlineObject(NULL, range); - if(!FAILED(hr)) - { - formatDataAvailable=false; - inlineElements.Remove(element); - SetMap(graphicsElements, inlineObject->GetStart(), inlineObject->GetLength(), (IGuiGraphicsElement*)0); - return true; - } - else - { - return false; - } + SendMessage(this->handle, WM_PAINT, NULL, NULL); } - return false; - } - - vint GetHeight()override - { - DWRITE_TEXT_METRICS metrics; - textLayout->GetMetrics(&metrics); - return (vint)metrics.height; - } - -/*********************************************************************** -WindowsDirect2DParagraph (IRenderingCallback) -***********************************************************************/ - - Color GetBackgroundColor(vint textPosition)override - { - Color color; - if(GetMap(backgroundColors, textPosition, color)) - { - return color; - } - else - { - return Color(0, 0, 0, 0); - } - } - - IWindowsDirect2DRenderTarget* GetDirect2DRenderTarget()override - { - return renderTarget; - } - -/*********************************************************************** -WindowsDirect2DParagraph (Rendering) -***********************************************************************/ - - bool OpenCaret(vint _caret, Color _color, bool _frontSide)override - { - if(!IsValidCaret(_caret)) return false; - if(caret!=-1) CloseCaret(); - caret=_caret; - caretColor=_color; - caretFrontSide=_frontSide; - caretBrush=renderTarget->CreateDirect2DBrush(caretColor); - return true; - } - - bool CloseCaret()override - { - if(caret==-1) return false; - caret=-1; - renderTarget->DestroyDirect2DBrush(caretColor); - caretBrush=0; - return true; - } - - void Render(Rect bounds)override - { - paragraphOffset = bounds.LeftTop(); - PrepareFormatData(); - for(vint i=0;i0) - { - ID2D1SolidColorBrush* brush=renderTarget->CreateDirect2DBrush(color); - - vint start=key.start; - if(start<0) - { - start=0; - } - - while(startGetDirect2DRenderTarget()->FillRectangle( - D2D1::RectF(x1, y1, x2, y2), - brush - ); - - start=hitTest.textPosition+hitTest.length; - } - - renderTarget->DestroyDirect2DBrush(color); - } - } - - renderTarget->GetDirect2DRenderTarget()->DrawTextLayout( - D2D1::Point2F((FLOAT)bounds.Left(), (FLOAT)bounds.Top()), - textLayout.Obj(), - defaultTextColor, - D2D1_DRAW_TEXT_OPTIONS_NO_SNAP); - - if(caret!=-1) - { - Rect caretBounds=GetCaretBounds(caret, caretFrontSide); - vint x=caretBounds.x1+bounds.x1; - vint y1=caretBounds.y1+bounds.y1; - vint y2=y1+caretBounds.Height(); - - renderTarget->GetDirect2DRenderTarget()->DrawLine( - D2D1::Point2F((FLOAT)x-0.5f, (FLOAT)y1+0.5f), - D2D1::Point2F((FLOAT)x-0.5f, (FLOAT)y2+0.5f), - caretBrush - ); - renderTarget->GetDirect2DRenderTarget()->DrawLine( - D2D1::Point2F((FLOAT)x+0.5f, (FLOAT)y1+0.5f), - D2D1::Point2F((FLOAT)x+0.5f, (FLOAT)y2+0.5f), - caretBrush - ); - } - } - -/*********************************************************************** -WindowsDirect2DParagraph (Caret Helper) -***********************************************************************/ - - void GetLineIndexFromTextPos(vint textPos, vint& frontLineIndex, vint& backLineIndex) - { - frontLineIndex=-1; - backLineIndex=-1; - vint start=0; - vint end=lineMetrics.Count()-1; - while(start<=end) - { - vint middle=(start+end)/2; - DWRITE_LINE_METRICS& metrics=lineMetrics[middle]; - vint lineStart=lineStarts[middle]; - vint lineEnd=lineStart+metrics.length-metrics.newlineLength; - - if(textPoslineEnd) - { - start=middle+1; - } - else if(textPos==lineStart && middle!=0) - { - DWRITE_LINE_METRICS& anotherLine=lineMetrics[middle-1]; - frontLineIndex=anotherLine.newlineLength==0?middle-1:middle; - backLineIndex=middle; - return; - } - else if(textPos==lineEnd && middle!=lineMetrics.Count()-1) - { - frontLineIndex=middle; - backLineIndex=metrics.newlineLength==0?middle+1:middle; - return; - } - else - { - frontLineIndex=middle; - backLineIndex=middle; - return; - } - } - } - - Pair GetLineYRange(vint lineIndex) - { - DWRITE_LINE_METRICS& line=lineMetrics[lineIndex]; - FLOAT top=lineTops[lineIndex]; - return Pair(top, top+line.height); - } - - vint GetLineIndexFromY(vint y) - { - if(paragraphText.Length()==0) return 0; - FLOAT minY=0; - FLOAT maxY=0; - { - minY=hitTestMetrics[0].top; - DWRITE_HIT_TEST_METRICS& hitTest=hitTestMetrics[hitTestMetrics.Count()-1]; - maxY=hitTest.top+hitTest.height; - } - - if(y=maxY) - { - return lineMetrics.Count()-1; - } - - vint start=0; - vint end=lineMetrics.Count()-1; - while(start<=end) - { - vint middle=(start+end)/2; - Pair yRange=GetLineYRange(middle); - minY=yRange.key; - maxY=yRange.value; - - if(y=maxY) - { - start=middle+1; - } - else - { - return middle; - } - } - return -1; - } - - vint GetCaretFromXWithLine(vint x, vint lineIndex) - { - DWRITE_LINE_METRICS& line=lineMetrics[lineIndex]; - vint lineStart=lineStarts[lineIndex]; - vint lineEnd=lineStart+line.length-line.newlineLength; - - FLOAT minLineX=0; - FLOAT maxLineX=0; - - for(vint i=lineStart;iminX) minLineX=minX; - if(maxLineX=maxLineX) return lineEnd; - return lineStart; - } - -/*********************************************************************** -WindowsDirect2DParagraph (Caret) -***********************************************************************/ - - vint GetCaret(vint comparingCaret, CaretRelativePosition position, bool& preferFrontSide)override - { - PrepareFormatData(); - if(position==CaretFirst) return 0; - if(position==CaretLast) return paragraphText.Length(); - if(!IsValidCaret(comparingCaret)) return -1; - - vint frontLineIndex=-1; - vint backLineIndex=-1; - GetLineIndexFromTextPos(comparingCaret, frontLineIndex, backLineIndex); - vint lineIndex=preferFrontSide?frontLineIndex:backLineIndex; - DWRITE_LINE_METRICS& line=lineMetrics[lineIndex]; - vint lineStart=lineStarts[lineIndex]; - vint lineEnd=lineStart+line.length-line.newlineLength; - - switch(position) - { - case CaretLineFirst: - return lineStarts[lineIndex]; - case CaretLineLast: - return lineStarts[lineIndex]+line.length-line.newlineLength; - case CaretMoveLeft: - { - if(comparingCaret==0) - { - return 0; - } - else if(comparingCaret==lineStart) - { - vint offset=lineMetrics[lineIndex-1].newlineLength; - if(offset>0) - { - return lineStart-offset; - } - } - return hitTestMetrics[charHitTestMap[comparingCaret-1]].textPosition; - } - case CaretMoveRight: - { - if(comparingCaret==paragraphText.Length()) - { - return paragraphText.Length(); - } - else if(comparingCaret==lineEnd && line.newlineLength!=0) - { - return lineEnd+line.newlineLength; - } - else - { - vint index=charHitTestMap[comparingCaret]; - if(index==hitTestMetrics.Count()-1) return paragraphText.Length(); - return hitTestMetrics[index+1].textPosition; - } - } - case CaretMoveUp: - { - if(lineIndex==0) - { - return comparingCaret; - } - else - { - Rect bounds=GetCaretBounds(comparingCaret, preferFrontSide); - preferFrontSide=true; - return GetCaretFromXWithLine(bounds.x1, lineIndex-1); - } - } - case CaretMoveDown: - { - if(lineIndex==lineMetrics.Count()-1) - { - return comparingCaret; - } - else - { - Rect bounds=GetCaretBounds(comparingCaret, preferFrontSide); - preferFrontSide=false; - return GetCaretFromXWithLine(bounds.x1, lineIndex+1); - } - } - } - return -1; - } - - Rect GetCaretBounds(vint caret, bool frontSide)override - { - PrepareFormatData(); - if(!IsValidCaret(caret)) return Rect(); - if(paragraphText.Length()==0) return Rect(Point(0, 0), Size(0, GetHeight())); - - vint frontLineIndex=-1; - vint backLineIndex=-1; - GetLineIndexFromTextPos(caret, frontLineIndex, backLineIndex); - vint lineIndex=frontSide?frontLineIndex:backLineIndex; - - Pair lineYRange=GetLineYRange(lineIndex); - DWRITE_LINE_METRICS& line=lineMetrics[lineIndex]; - if(line.length-line.newlineLength==0) - { - return Rect(0, (vint)lineYRange.key, 0, (vint)lineYRange.value); - } - else - { - vint lineStart=lineStarts[lineIndex]; - vint lineEnd=lineStart+line.length-line.newlineLength; - if(caret==lineStart) - { - frontSide=false; - } - else if(caret==lineEnd) - { - frontSide=true; - } - if(frontSide) - { - caret--; - } - - vint index=charHitTestMap[caret]; - DWRITE_HIT_TEST_METRICS& hitTest=hitTestMetrics[index]; - DWRITE_CLUSTER_METRICS& cluster=clusterMetrics[index]; - if(cluster.isRightToLeft) - { - frontSide=!frontSide; - } - - if(frontSide) - { - return Rect( - Point((vint)(hitTest.left+hitTest.width), (vint)hitTest.top), - Size(0, (vint)hitTest.height) - ); - } - else - { - return Rect( - Point((vint)hitTest.left, (vint)hitTest.top), - Size(0, (vint)hitTest.height) - ); - } - } - } - - vint GetCaretFromPoint(Point point)override - { - PrepareFormatData(); - vint lineIndex=GetLineIndexFromY(point.y); - vint caret=GetCaretFromXWithLine(point.x, lineIndex); - return caret; - } - - Nullable GetInlineObjectFromPoint(Point point, vint& start, vint& length)override - { - DWRITE_HIT_TEST_METRICS metrics={0}; - BOOL trailingHit=FALSE; - BOOL inside=FALSE; - start=-1; - length=0; - HRESULT hr=textLayout->HitTestPoint((FLOAT)point.x, (FLOAT)point.y, &trailingHit, &inside, &metrics); - if(hr==S_OK) - { - IGuiGraphicsElement* element=0; - if(GetMap(graphicsElements, metrics.textPosition, element) && element) - { - ComPtr inlineObject=inlineElements[element]; - start=inlineObject->GetStart(); - length=inlineObject->GetLength(); - return inlineObject->GetProperties(); - } - } - return Nullable(); - } - - vint GetNearestCaretFromTextPos(vint textPos, bool frontSide)override - { - PrepareFormatData(); - if(!IsValidTextPos(textPos)) return -1; - if(textPos==0 || textPos==paragraphText.Length()) return textPos; - - vint index=charHitTestMap[textPos]; - DWRITE_HIT_TEST_METRICS& hitTest=hitTestMetrics[index]; - if(hitTest.textPosition==textPos) - { - return textPos; - } - else if(frontSide) - { - return hitTest.textPosition; - } - else - { - return hitTest.textPosition+hitTest.length; - } - } - - bool IsValidCaret(vint caret)override - { - PrepareFormatData(); - if(!IsValidTextPos(caret)) return false; - if(caret==0 || caret==paragraphText.Length()) return true; - if(hitTestMetrics[charHitTestMap[caret]].textPosition==caret) return true; - - vint frontLineIndex=-1; - vint backLineIndex=-1; - GetLineIndexFromTextPos(caret, frontLineIndex, backLineIndex); - if(frontLineIndex==-1 && backLineIndex==-1) return false; - return false; - } - - bool IsValidTextPos(vint textPos) - { - return 0<=textPos && textPos<=paragraphText.Length(); } }; /*********************************************************************** -WindowsDirect2DLayoutProvider +WindowsController ***********************************************************************/ - Ptr WindowsDirect2DLayoutProvider::CreateParagraph(const WString& text, IGuiGraphicsRenderTarget* renderTarget, elements::IGuiGraphicsParagraphCallback* callback) + LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + LRESULT CALLBACK GodProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + LRESULT CALLBACK MouseProc(int nCode , WPARAM wParam , LPARAM lParam); + + class WindowsController : public Object, public virtual INativeController, public virtual INativeWindowService { - return new WindowsDirect2DParagraph(this, text, renderTarget, callback); - } - } - } -} + protected: + WinClass windowClass; + WinClass godClass; + HINSTANCE hInstance; + HWND godWindow; + Dictionary windows; + INativeWindow* mainWindow; + HWND mainWindowHandle; -/*********************************************************************** -GRAPHICSELEMENT\WINDOWSDIRECT2D\GUIGRAPHICSRENDERERSWINDOWSDIRECT2D.CPP -***********************************************************************/ + WindowsCallbackService callbackService; + WindowsResourceService resourceService; + WindowsAsyncService asyncService; + WindowsClipboardService clipboardService; + WindowsImageService imageService; + WindowsScreenService screenService; + WindowsInputService inputService; + WindowsDialogService dialogService; -namespace vl -{ - namespace presentation - { - namespace elements_windows_d2d - { - using namespace collections; - -/*********************************************************************** -IMPLEMENT_BRUSH_ELEMENT_RENDERER -***********************************************************************/ - -#define IMPLEMENT_BRUSH_ELEMENT_RENDERER(TRENDERER)\ - void TRENDERER::InitializeInternal()\ - {\ - }\ - void TRENDERER::FinalizeInternal()\ - {\ - DestroyBrush(renderTarget);\ - }\ - void TRENDERER::RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget)\ - {\ - DestroyBrush(oldRenderTarget);\ - CreateBrush(newRenderTarget);\ - }\ - TRENDERER::TRENDERER()\ - :brush(0)\ - {\ - }\ - void TRENDERER::Render(Rect bounds)\ - -#define IMPLEMENT_BRUSH_ELEMENT_RENDERER_SOLID_COLOR_BRUSH(TRENDERER)\ - void TRENDERER::CreateBrush(IWindowsDirect2DRenderTarget* _renderTarget)\ - {\ - if(_renderTarget)\ - {\ - oldColor=element->GetColor();\ - brush=_renderTarget->CreateDirect2DBrush(oldColor);\ - }\ - }\ - void TRENDERER::DestroyBrush(IWindowsDirect2DRenderTarget* _renderTarget)\ - {\ - if(_renderTarget && brush)\ - {\ - _renderTarget->DestroyDirect2DBrush(oldColor);\ - brush=0;\ - }\ - }\ - void TRENDERER::OnElementStateChanged()\ - {\ - if(renderTarget)\ - {\ - Color color=element->GetColor();\ - if(oldColor!=color)\ - {\ - DestroyBrush(renderTarget);\ - CreateBrush(renderTarget);\ - }\ - }\ - }\ - -#define IMPLEMENT_BRUSH_ELEMENT_RENDERER_LINEAR_GRADIENT_BRUSH(TRENDERER)\ - void TRENDERER::CreateBrush(IWindowsDirect2DRenderTarget* _renderTarget)\ - {\ - if(_renderTarget)\ - {\ - oldColor=Pair(element->GetColor1(), element->GetColor2());\ - brush=_renderTarget->CreateDirect2DLinearBrush(oldColor.key, oldColor.value);\ - }\ - }\ - void TRENDERER::DestroyBrush(IWindowsDirect2DRenderTarget* _renderTarget)\ - {\ - if(_renderTarget && brush)\ - {\ - _renderTarget->DestroyDirect2DLinearBrush(oldColor.key, oldColor.value);\ - brush=0;\ - }\ - }\ - void TRENDERER::OnElementStateChanged()\ - {\ - if(renderTarget)\ - {\ - Pair color=Pair(element->GetColor1(), element->GetColor2());\ - if(oldColor!=color)\ - {\ - DestroyBrush(renderTarget);\ - CreateBrush(renderTarget);\ - }\ - }\ - }\ - -/*********************************************************************** -GuiSolidBorderElementRenderer -***********************************************************************/ - - IMPLEMENT_BRUSH_ELEMENT_RENDERER_SOLID_COLOR_BRUSH(GuiSolidBorderElementRenderer) - IMPLEMENT_BRUSH_ELEMENT_RENDERER(GuiSolidBorderElementRenderer) - { - ID2D1RenderTarget* d2dRenderTarget=renderTarget->GetDirect2DRenderTarget(); - switch(element->GetShape()) + public: + WindowsController(HINSTANCE _hInstance) + :hInstance(_hInstance) + ,windowClass(L"VczhWindow", false, false, WndProc, _hInstance) + ,godClass(L"GodWindow", false, false, GodProc, _hInstance) + ,mainWindow(0) + ,mainWindowHandle(0) + ,screenService(&GetHWNDFromNativeWindowHandle) + ,inputService(&MouseProc) + ,dialogService(&GetHWNDFromNativeWindowHandle) { - case ElementShape::Rectangle: - d2dRenderTarget->DrawRectangle( - D2D1::RectF((FLOAT)bounds.x1+0.5f, (FLOAT)bounds.y1+0.5f, (FLOAT)bounds.x2-0.5f, (FLOAT)bounds.y2-0.5f), - brush - ); - break; - case ElementShape::Ellipse: - d2dRenderTarget->DrawEllipse( - D2D1::Ellipse(D2D1::Point2F((bounds.x1+bounds.x2)/2.0f, (bounds.y1+bounds.y2)/2.0f), bounds.Width()/2.0f, bounds.Height()/2.0f), - brush - ); - break; + godWindow=CreateWindowEx(WS_EX_CONTROLPARENT, godClass.GetName().Buffer(), L"GodWindow", WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, NULL, NULL, hInstance, NULL); + clipboardService.SetOwnerHandle(godWindow); + inputService.SetOwnerHandle(godWindow); } - } -/*********************************************************************** -GuiRoundBorderElementRenderer -***********************************************************************/ - - IMPLEMENT_BRUSH_ELEMENT_RENDERER_SOLID_COLOR_BRUSH(GuiRoundBorderElementRenderer) - IMPLEMENT_BRUSH_ELEMENT_RENDERER(GuiRoundBorderElementRenderer) - { - ID2D1RenderTarget* d2dRenderTarget=renderTarget->GetDirect2DRenderTarget(); - d2dRenderTarget->DrawRoundedRectangle( - D2D1::RoundedRect( - D2D1::RectF((FLOAT)bounds.x1+0.5f, (FLOAT)bounds.y1+0.5f, (FLOAT)bounds.x2-0.5f, (FLOAT)bounds.y2-0.5f), - (FLOAT)element->GetRadius(), - (FLOAT)element->GetRadius() - ), - brush - ); - } - -/*********************************************************************** -Gui3DBorderElementRenderer -***********************************************************************/ - - void Gui3DBorderElementRenderer::CreateBrush(IWindowsDirect2DRenderTarget* _renderTarget) - { - if(_renderTarget) + ~WindowsController() { - oldColor1=element->GetColor1(); - oldColor2=element->GetColor2(); - brush1=_renderTarget->CreateDirect2DBrush(oldColor1); - brush2=_renderTarget->CreateDirect2DBrush(oldColor2); + inputService.StopTimer(); + inputService.StopHookMouse(); + clipboardService.SetOwnerHandle(NULL); + DestroyWindow(godWindow); } - } - void Gui3DBorderElementRenderer::DestroyBrush(IWindowsDirect2DRenderTarget* _renderTarget) - { - if(_renderTarget) + WindowsForm* GetWindowsFormFromHandle(HWND hwnd) { - if(brush1) + vint index = windows.Keys().IndexOf(hwnd); + if (index == -1)return 0; + return windows.Values()[index]; + } + + bool HandleMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& result) + { + bool skipDefaultProcedure=false; + vint index=windows.Keys().IndexOf(hwnd); + if(index!=-1) { - _renderTarget->DestroyDirect2DBrush(oldColor1); - brush1=0; - } - if(brush2) - { - _renderTarget->DestroyDirect2DBrush(oldColor2); - brush2=0; - } - } - } - - void Gui3DBorderElementRenderer::InitializeInternal() - { - } - - void Gui3DBorderElementRenderer::FinalizeInternal() - { - DestroyBrush(renderTarget); - } - - void Gui3DBorderElementRenderer::RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget) - { - DestroyBrush(oldRenderTarget); - CreateBrush(newRenderTarget); - } - - Gui3DBorderElementRenderer::Gui3DBorderElementRenderer() - :brush1(0) - ,brush2(0) - { - } - - void Gui3DBorderElementRenderer::Render(Rect bounds) - { - D2D1_RECT_F rect=D2D1::RectF((FLOAT)bounds.x1+0.5f, (FLOAT)bounds.y1+0.5f, (FLOAT)bounds.x2-0.5f, (FLOAT)bounds.y2-0.5f); - ID2D1RenderTarget* d2dRenderTarget=renderTarget->GetDirect2DRenderTarget(); - - d2dRenderTarget->DrawLine(D2D1::Point2F(rect.left, rect.top), D2D1::Point2F(rect.right, rect.top), brush1); - d2dRenderTarget->DrawLine(D2D1::Point2F(rect.left, rect.top), D2D1::Point2F(rect.left, rect.bottom), brush1); - d2dRenderTarget->DrawLine(D2D1::Point2F(rect.right, rect.bottom), D2D1::Point2F(rect.left, rect.bottom), brush2); - d2dRenderTarget->DrawLine(D2D1::Point2F(rect.right, rect.bottom), D2D1::Point2F(rect.right, rect.top), brush2); - } - - void Gui3DBorderElementRenderer::OnElementStateChanged() - { - if(renderTarget) - { - Color color1=element->GetColor1(); - Color color2=element->GetColor2(); - if(oldColor1!=color1 || oldColor2!=color2) - { - DestroyBrush(renderTarget); - CreateBrush(renderTarget); - } - } - } - -/*********************************************************************** -Gui3DSplitterElementRenderer -***********************************************************************/ - - void Gui3DSplitterElementRenderer::CreateBrush(IWindowsDirect2DRenderTarget* _renderTarget) - { - if(_renderTarget) - { - oldColor1=element->GetColor1(); - oldColor2=element->GetColor2(); - brush1=_renderTarget->CreateDirect2DBrush(oldColor1); - brush2=_renderTarget->CreateDirect2DBrush(oldColor2); - } - } - - void Gui3DSplitterElementRenderer::DestroyBrush(IWindowsDirect2DRenderTarget* _renderTarget) - { - if(_renderTarget) - { - if(brush1) - { - _renderTarget->DestroyDirect2DBrush(oldColor1); - brush1=0; - } - if(brush2) - { - _renderTarget->DestroyDirect2DBrush(oldColor2); - brush2=0; - } - } - } - - void Gui3DSplitterElementRenderer::InitializeInternal() - { - } - - void Gui3DSplitterElementRenderer::FinalizeInternal() - { - DestroyBrush(renderTarget); - } - - void Gui3DSplitterElementRenderer::RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget) - { - DestroyBrush(oldRenderTarget); - CreateBrush(newRenderTarget); - } - - Gui3DSplitterElementRenderer::Gui3DSplitterElementRenderer() - :brush1(0) - ,brush2(0) - { - } - - void Gui3DSplitterElementRenderer::Render(Rect bounds) - { - D2D1_POINT_2F p11, p12, p21, p22; - switch(element->GetDirection()) - { - case Gui3DSplitterElement::Horizontal: - { - vint y=bounds.y1+bounds.Height()/2-1; - p11=D2D1::Point2F((FLOAT)bounds.x1, (FLOAT)y+0.5f); - p12=D2D1::Point2F((FLOAT)bounds.x2, (FLOAT)y+0.5f); - p21=D2D1::Point2F((FLOAT)bounds.x1, (FLOAT)y+1.5f); - p22=D2D1::Point2F((FLOAT)bounds.x2, (FLOAT)y+1.5f); - } - break; - case Gui3DSplitterElement::Vertical: - { - vint x=bounds.x1+bounds.Width()/2-1; - p11=D2D1::Point2F((FLOAT)x+0.5f, (FLOAT)bounds.y1-0.0f); - p12=D2D1::Point2F((FLOAT)x+0.5f, (FLOAT)bounds.y2+0.0f); - p21=D2D1::Point2F((FLOAT)x+1.5f, (FLOAT)bounds.y1-0.0f); - p22=D2D1::Point2F((FLOAT)x+1.5f, (FLOAT)bounds.y2+0.0f); - } - break; - } - ID2D1RenderTarget* d2dRenderTarget=renderTarget->GetDirect2DRenderTarget(); - - d2dRenderTarget->DrawLine(p11, p12, brush1); - d2dRenderTarget->DrawLine(p21, p22, brush2); - } - - void Gui3DSplitterElementRenderer::OnElementStateChanged() - { - if(renderTarget) - { - Color color1=element->GetColor1(); - Color color2=element->GetColor2(); - if(oldColor1!=color1 || oldColor2!=color2) - { - DestroyBrush(renderTarget); - CreateBrush(renderTarget); - } - } - } - -/*********************************************************************** -GuiSolidBackgroundElementRenderer -***********************************************************************/ - - IMPLEMENT_BRUSH_ELEMENT_RENDERER_SOLID_COLOR_BRUSH(GuiSolidBackgroundElementRenderer) - IMPLEMENT_BRUSH_ELEMENT_RENDERER(GuiSolidBackgroundElementRenderer) - { - ID2D1RenderTarget* d2dRenderTarget=renderTarget->GetDirect2DRenderTarget(); - switch(element->GetShape()) - { - case ElementShape::Rectangle: - d2dRenderTarget->FillRectangle( - D2D1::RectF((FLOAT)bounds.x1, (FLOAT)bounds.y1, (FLOAT)bounds.x2, (FLOAT)bounds.y2), - brush - ); - break; - case ElementShape::Ellipse: - d2dRenderTarget->FillEllipse( - D2D1::Ellipse(D2D1::Point2F((bounds.x1+bounds.x2)/2.0f, (bounds.y1+bounds.y2)/2.0f), bounds.Width()/2.0f, bounds.Height()/2.0f), - brush - ); - break; - } - } - -/*********************************************************************** -GuiGradientBackgroundElementRenderer -***********************************************************************/ - - IMPLEMENT_BRUSH_ELEMENT_RENDERER_LINEAR_GRADIENT_BRUSH(GuiGradientBackgroundElementRenderer) - IMPLEMENT_BRUSH_ELEMENT_RENDERER(GuiGradientBackgroundElementRenderer) - { - D2D1_POINT_2F points[2]; - switch(element->GetDirection()) - { - case GuiGradientBackgroundElement::Horizontal: - { - points[0].x=(FLOAT)bounds.x1; - points[0].y=(FLOAT)bounds.y1; - points[1].x=(FLOAT)bounds.x2; - points[1].y=(FLOAT)bounds.y1; - } - break; - case GuiGradientBackgroundElement::Vertical: - { - points[0].x=(FLOAT)bounds.x1; - points[0].y=(FLOAT)bounds.y1; - points[1].x=(FLOAT)bounds.x1; - points[1].y=(FLOAT)bounds.y2; - } - break; - case GuiGradientBackgroundElement::Slash: - { - points[0].x=(FLOAT)bounds.x2; - points[0].y=(FLOAT)bounds.y1; - points[1].x=(FLOAT)bounds.x1; - points[1].y=(FLOAT)bounds.y2; - } - break; - case GuiGradientBackgroundElement::Backslash: - { - points[0].x=(FLOAT)bounds.x1; - points[0].y=(FLOAT)bounds.y1; - points[1].x=(FLOAT)bounds.x2; - points[1].y=(FLOAT)bounds.y2; - } - break; - } - - brush->SetStartPoint(points[0]); - brush->SetEndPoint(points[1]); - - ID2D1RenderTarget* d2dRenderTarget=renderTarget->GetDirect2DRenderTarget(); - switch(element->GetShape()) - { - case ElementShape::Rectangle: - d2dRenderTarget->FillRectangle( - D2D1::RectF((FLOAT)bounds.x1, (FLOAT)bounds.y1, (FLOAT)bounds.x2, (FLOAT)bounds.y2), - brush - ); - break; - case ElementShape::Ellipse: - d2dRenderTarget->FillEllipse( - D2D1::Ellipse(D2D1::Point2F((bounds.x1+bounds.x2)/2.0f, (bounds.y1+bounds.y2)/2.0f), bounds.Width()/2.0f, bounds.Height()/2.0f), - brush - ); - break; - } - } - -/*********************************************************************** -GuiSolidLabelElementRenderer -***********************************************************************/ - - void GuiSolidLabelElementRenderer::CreateBrush(IWindowsDirect2DRenderTarget* _renderTarget) - { - if(_renderTarget) - { - oldColor=element->GetColor(); - brush=_renderTarget->CreateDirect2DBrush(oldColor); - } - } - - void GuiSolidLabelElementRenderer::DestroyBrush(IWindowsDirect2DRenderTarget* _renderTarget) - { - if(_renderTarget && brush) - { - _renderTarget->DestroyDirect2DBrush(oldColor); - brush=0; - } - } - - void GuiSolidLabelElementRenderer::CreateTextFormat(IWindowsDirect2DRenderTarget* _renderTarget) - { - if(_renderTarget) - { - IWindowsDirect2DResourceManager* resourceManager=GetWindowsDirect2DResourceManager(); - oldFont=element->GetFont(); - textFormat=resourceManager->CreateDirect2DTextFormat(oldFont); - } - } - - void GuiSolidLabelElementRenderer::DestroyTextFormat(IWindowsDirect2DRenderTarget* _renderTarget) - { - if(_renderTarget && textFormat) - { - IWindowsDirect2DResourceManager* resourceManager=GetWindowsDirect2DResourceManager(); - resourceManager->DestroyDirect2DTextFormat(oldFont); - textFormat=0; - } - } - - void GuiSolidLabelElementRenderer::CreateTextLayout() - { - if(textFormat) - { - HRESULT hr=GetWindowsDirect2DObjectProvider()->GetDirectWriteFactory()->CreateTextLayout( - oldText.Buffer(), - (int)oldText.Length(), - textFormat->textFormat.Obj(), - 0, - 0, - &textLayout); - if(!FAILED(hr)) - { - if(oldFont.underline) + WindowsForm* window=windows.Values().Get(index); + skipDefaultProcedure=window->HandleMessage(hwnd, uMsg, wParam, lParam, result); + switch(uMsg) { - DWRITE_TEXT_RANGE textRange; - textRange.startPosition=0; - textRange.length=(int)oldText.Length(); - textLayout->SetUnderline(TRUE, textRange); - } - if(oldFont.strikeline) - { - DWRITE_TEXT_RANGE textRange; - textRange.startPosition=0; - textRange.length=(int)oldText.Length(); - textLayout->SetStrikethrough(TRUE, textRange); - } - } - else - { - textLayout=0; - } - } - } - - void GuiSolidLabelElementRenderer::DestroyTextLayout() - { - if(textLayout) - { - textLayout->Release(); - textLayout=0; - } - } - - void GuiSolidLabelElementRenderer::UpdateMinSize() - { - float maxWidth=0; - DestroyTextLayout(); - bool calculateSizeFromTextLayout=false; - if(renderTarget) - { - if(element->GetWrapLine()) - { - if(element->GetWrapLineHeightCalculation()) - { - CreateTextLayout(); - if(textLayout) + case WM_CLOSE: + if(!skipDefaultProcedure) { - maxWidth=textLayout->GetMaxWidth(); - if(oldMaxWidth!=-1) + ShowWindow(window->GetWindowHandle(), SW_HIDE); + if(window!=mainWindow) { - textLayout->SetWordWrapping(DWRITE_WORD_WRAPPING_WRAP); - textLayout->SetMaxWidth((float)oldMaxWidth); + skipDefaultProcedure=true; } - calculateSizeFromTextLayout=true; + } + break; + case WM_DESTROY: + DestroyNativeWindow(window); + break; + } + } + + if(hwnd==mainWindowHandle && uMsg==WM_DESTROY) + { + for(vint i=0;iIsVisible()) + { + windows.Values().Get(i)->Hide(); } } + while(windows.Count()) + { + DestroyNativeWindow(windows.Values().Get(0)); + } + PostQuitMessage(0); + } + return skipDefaultProcedure; + } + + //======================================================================= + + INativeWindow* CreateNativeWindow() + { + WindowsForm* window=new WindowsForm(godWindow, windowClass.GetName(), hInstance); + windows.Add(window->GetWindowHandle(), window); + callbackService.InvokeNativeWindowCreated(window); + window->SetWindowCursor(resourceService.GetDefaultSystemCursor()); + return window; + } + + void DestroyNativeWindow(INativeWindow* window) + { + WindowsForm* windowsForm=dynamic_cast(window); + windowsForm->InvokeDestroying(); + if(windowsForm!=0 && windows.Keys().Contains(windowsForm->GetWindowHandle())) + { + callbackService.InvokeNativeWindowDestroyed(window); + windows.Remove(windowsForm->GetWindowHandle()); + delete windowsForm; + } + } + + INativeWindow* GetMainWindow() + { + return mainWindow; + } + + void Run(INativeWindow* window) + { + mainWindow=window; + mainWindowHandle=GetWindowsForm(window)->GetWindowHandle(); + mainWindow->Show(); + MSG message; + while(GetMessage(&message, NULL, 0, 0)) + { + TranslateMessage(&message); + DispatchMessage(&message); + asyncService.ExecuteAsyncTasks(); + } + } + + INativeWindow* GetWindow(Point location) + { + POINT p; + p.x=(int)location.x; + p.y=(int)location.y; + HWND handle=WindowFromPoint(p); + vint index=windows.Keys().IndexOf(handle); + if(index==-1) + { + return 0; } else { - CreateTextLayout(); - if(textLayout) - { - maxWidth=textLayout->GetMaxWidth(); - calculateSizeFromTextLayout=true; - } + return windows.Values().Get(index); } } - if(calculateSizeFromTextLayout) + + //======================================================================= + + INativeCallbackService* CallbackService() { - DWRITE_TEXT_METRICS metrics; - HRESULT hr=textLayout->GetMetrics(&metrics); - if(!FAILED(hr)) + return &callbackService; + } + + INativeResourceService* ResourceService() + { + return &resourceService; + } + + INativeAsyncService* AsyncService() + { + return &asyncService; + } + + INativeClipboardService* ClipboardService() + { + return &clipboardService; + } + + INativeImageService* ImageService() + { + return &imageService; + } + + INativeScreenService* ScreenService() + { + return &screenService; + } + + INativeWindowService* WindowService() + { + return this; + } + + INativeInputService* InputService() + { + return &inputService; + } + + INativeDialogService* DialogService() + { + return &dialogService; + } + + WString GetExecutablePath() + { + Array buffer(65536); + GetModuleFileName(NULL, &buffer[0], (DWORD)buffer.Count()); + return &buffer[0]; + } + + //======================================================================= + + void InvokeMouseHook(WPARAM message, Point location) + { + callbackService.InvokeMouseHook(message, location); + } + + void InvokeGlobalTimer() + { + callbackService.InvokeGlobalTimer(); + } + + void InvokeClipboardUpdated() + { + callbackService.InvokeClipboardUpdated(); + } + }; + +/*********************************************************************** +Windows Procedure +***********************************************************************/ + + LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) + { + WindowsController* controller=dynamic_cast(GetCurrentController()); + if(controller) + { + LRESULT result=0; + if(controller->HandleMessage(hwnd, uMsg, wParam, lParam, result)) { - vint width=0; - if(!element->GetEllipse() && !element->GetWrapLine() && !element->GetMultiline()) - { - width=(vint)ceil(metrics.widthIncludingTrailingWhitespace); - } - minSize=Size(width, (vint)ceil(metrics.height)); + return result; } - textLayout->SetMaxWidth(maxWidth); - } - else - { - minSize=Size(); } + return DefWindowProc(hwnd, uMsg, wParam, lParam); } - void GuiSolidLabelElementRenderer::InitializeInternal() + LRESULT CALLBACK GodProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - } - - void GuiSolidLabelElementRenderer::FinalizeInternal() - { - DestroyTextLayout(); - DestroyBrush(renderTarget); - DestroyTextFormat(renderTarget); - } - - void GuiSolidLabelElementRenderer::RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget) - { - DestroyBrush(oldRenderTarget); - DestroyTextFormat(oldRenderTarget); - CreateBrush(newRenderTarget); - CreateTextFormat(newRenderTarget); - UpdateMinSize(); - } - - GuiSolidLabelElementRenderer::GuiSolidLabelElementRenderer() - :brush(0) - ,textFormat(0) - ,textLayout(0) - ,oldText(L"") - ,oldMaxWidth(-1) - { - } - - void GuiSolidLabelElementRenderer::Render(Rect bounds) - { - if(!textLayout) + WindowsController* controller=dynamic_cast(GetCurrentController()); + if(controller) { - CreateTextLayout(); - } - - vint x=0; - vint y=0; - switch(element->GetHorizontalAlignment()) - { - case Alignment::Left: - x=bounds.Left(); - break; - case Alignment::Center: - x=bounds.Left()+(bounds.Width()-minSize.x)/2; - break; - case Alignment::Right: - x=bounds.Right()-minSize.x; - break; - } - switch(element->GetVerticalAlignment()) - { - case Alignment::Top: - y=bounds.Top(); - break; - case Alignment::Center: - y=bounds.Top()+(bounds.Height()-minSize.y)/2; - break; - case Alignment::Bottom: - y=bounds.Bottom()-minSize.y; - break; - } - - renderTarget->SetTextAntialias(oldFont.antialias, oldFont.verticalAntialias); - - if(!element->GetEllipse() && !element->GetMultiline() && !element->GetWrapLine()) - { - ID2D1RenderTarget* d2dRenderTarget=renderTarget->GetDirect2DRenderTarget(); - d2dRenderTarget->DrawTextLayout( - D2D1::Point2F((FLOAT)x, (FLOAT)y), - textLayout, - brush, - D2D1_DRAW_TEXT_OPTIONS_NO_SNAP - ); - } - else - { - IDWriteFactory* dwriteFactory=GetWindowsDirect2DObjectProvider()->GetDirectWriteFactory(); - DWRITE_TRIMMING trimming; - IDWriteInlineObject* inlineObject; - textLayout->GetTrimming(&trimming, &inlineObject); - - textLayout->SetWordWrapping(element->GetWrapLine()?DWRITE_WORD_WRAPPING_WRAP:DWRITE_WORD_WRAPPING_NO_WRAP); - if(element->GetEllipse()) + switch(uMsg) { - textLayout->SetTrimming(&textFormat->trimming, textFormat->ellipseInlineObject.Obj()); - } - switch(element->GetHorizontalAlignment()) - { - case Alignment::Left: - textLayout->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING); + case WM_TIMER: + controller->InvokeGlobalTimer(); break; - case Alignment::Center: - textLayout->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); - break; - case Alignment::Right: - textLayout->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_TRAILING); + case WM_CLIPBOARDUPDATE: + controller->InvokeClipboardUpdated(); break; } - if(!element->GetMultiline() && !element->GetWrapLine()) - { - switch(element->GetVerticalAlignment()) - { - case Alignment::Top: - textLayout->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR); - break; - case Alignment::Center: - textLayout->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); - break; - case Alignment::Bottom: - textLayout->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_FAR); - break; - } - } - - Rect textBounds=bounds; - if(element->GetEllipse() && !element->GetMultiline() && !element->GetWrapLine()) - { - textBounds=Rect(Point(textBounds.x1, y), Size(bounds.Width(), minSize.y)); - } - - textLayout->SetMaxWidth((FLOAT)textBounds.Width()); - textLayout->SetMaxHeight((FLOAT)textBounds.Height()); - - ID2D1RenderTarget* d2dRenderTarget=renderTarget->GetDirect2DRenderTarget(); - d2dRenderTarget->DrawTextLayout( - D2D1::Point2F((FLOAT)textBounds.Left(), (FLOAT)textBounds.Top()), - textLayout, - brush, - D2D1_DRAW_TEXT_OPTIONS_NO_SNAP - ); - - textLayout->SetTrimming(&trimming, inlineObject); - if(oldMaxWidth!=textBounds.Width()) - { - oldMaxWidth=textBounds.Width(); - UpdateMinSize(); - } } + return DefWindowProc(hwnd, uMsg, wParam, lParam); } - void GuiSolidLabelElementRenderer::OnElementStateChanged() + LRESULT CALLBACK MouseProc(int nCode , WPARAM wParam , LPARAM lParam) { - if(renderTarget) + WindowsController* controller=dynamic_cast(GetCurrentController()); + if(controller) { - Color color=element->GetColor(); - if(oldColor!=color) - { - DestroyBrush(renderTarget); - CreateBrush(renderTarget); - } - - FontProperties font=element->GetFont(); - if(oldFont!=font) - { - DestroyTextFormat(renderTarget); - CreateTextFormat(renderTarget); - } + MSLLHOOKSTRUCT* mouseHookStruct=(MSLLHOOKSTRUCT*)lParam; + Point location(mouseHookStruct->pt.x, mouseHookStruct->pt.y); + controller->InvokeMouseHook(wParam, location); } - oldText=element->GetText(); - UpdateMinSize(); + return CallNextHookEx(NULL,nCode,wParam,lParam); } /*********************************************************************** -GuiImageFrameElementRenderer +Windows Platform Native Controller ***********************************************************************/ - void GuiImageFrameElementRenderer::UpdateBitmap(IWindowsDirect2DRenderTarget* renderTarget) + INativeController* CreateWindowsNativeController(HINSTANCE hInstance) { - if(renderTarget && element->GetImage()) + return new WindowsController(hInstance); + } + + IWindowsForm* GetWindowsFormFromHandle(HWND hwnd) + { + auto controller = dynamic_cast(GetCurrentController()); + if (controller) { - INativeImageFrame* frame=element->GetImage()->GetFrame(element->GetFrameIndex()); - bitmap=renderTarget->GetBitmap(frame, element->GetEnabled()); - - if (element->GetStretch()) - { - minSize=Size(0,0); - } - else - { - minSize=frame->GetSize(); - } + return controller->GetWindowsFormFromHandle(hwnd); } - else - { - bitmap=0; - minSize=Size(0, 0); - } - } - - void GuiImageFrameElementRenderer::InitializeInternal() - { - } - - void GuiImageFrameElementRenderer::FinalizeInternal() - { - } - - void GuiImageFrameElementRenderer::RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget) - { - UpdateBitmap(newRenderTarget); - } - - GuiImageFrameElementRenderer::GuiImageFrameElementRenderer() - { - } - - void GuiImageFrameElementRenderer::Render(Rect bounds) - { - if(bitmap) - { - ID2D1RenderTarget* d2dRenderTarget=renderTarget->GetDirect2DRenderTarget(); - D2D1_RECT_F source=D2D1::RectF(0, 0, (FLOAT)minSize.x, (FLOAT)minSize.y); - D2D1_RECT_F destination; - if(element->GetStretch()) - { - INativeImageFrame* frame=element->GetImage()->GetFrame(element->GetFrameIndex()); - auto size = frame->GetSize(); - source = D2D1::RectF(0, 0, (FLOAT)size.x, (FLOAT)size.y); - destination=D2D1::RectF((FLOAT)bounds.x1, (FLOAT)bounds.y1, (FLOAT)bounds.x2, (FLOAT)bounds.y2); - } - else - { - vint x=0; - vint y=0; - switch(element->GetHorizontalAlignment()) - { - case Alignment::Left: - x=bounds.Left(); - break; - case Alignment::Center: - x=bounds.Left()+(bounds.Width()-minSize.x)/2; - break; - case Alignment::Right: - x=bounds.Right()-minSize.x; - break; - } - switch(element->GetVerticalAlignment()) - { - case Alignment::Top: - y=bounds.Top(); - break; - case Alignment::Center: - y=bounds.Top()+(bounds.Height()-minSize.y)/2; - break; - case Alignment::Bottom: - y=bounds.Bottom()-minSize.y; - break; - } - destination=D2D1::RectF((FLOAT)x, (FLOAT)y, (FLOAT)(x+minSize.x), (FLOAT)(y+minSize.y)); - } - - ID2D1DeviceContext* d2dDeviceContext = nullptr; - { - HRESULT hr = d2dRenderTarget->QueryInterface(&d2dDeviceContext); - if (!SUCCEEDED(hr)) - { - if (d2dDeviceContext) - { - d2dDeviceContext->Release(); - } - d2dDeviceContext = nullptr; - } - } - - if(element->GetImage()->GetFormat()==INativeImage::Gif && element->GetFrameIndex()>0) - { - vint max = element->GetFrameIndex(); - for (vint i = 0; i <= max; i++) - { - ComPtr frameBitmap=renderTarget->GetBitmap(element->GetImage()->GetFrame(i), element->GetEnabled()); - if (d2dDeviceContext) - { - d2dDeviceContext->DrawBitmap(frameBitmap.Obj(), destination, 1.0f, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC, source); - } - else - { - d2dRenderTarget->DrawBitmap(frameBitmap.Obj(), destination, 1.0f, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, source); - } - } - } - else - { - if (d2dDeviceContext) - { - d2dDeviceContext->DrawBitmap(bitmap.Obj(), destination, 1.0f, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC, source); - } - else - { - d2dRenderTarget->DrawBitmap(bitmap.Obj(), destination, 1.0f, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, source); - } - } - - if (d2dDeviceContext) - { - d2dDeviceContext->Release(); - } - } - } - - void GuiImageFrameElementRenderer::OnElementStateChanged() - { - UpdateBitmap(renderTarget); - } - -/*********************************************************************** -GuiPolygonElementRenderer -***********************************************************************/ - - void GuiPolygonElementRenderer::CreateGeometry() - { - oldPoints.Resize(element->GetPointCount()); - if(oldPoints.Count()>0) - { - memcpy(&oldPoints[0], &element->GetPoint(0), sizeof(Point)*element->GetPointCount()); - } - if(oldPoints.Count()>=3) - { - ID2D1PathGeometry* pg=0; - GetWindowsDirect2DObjectProvider()->GetDirect2DFactory()->CreatePathGeometry(&pg); - if(pg) - { - geometry=pg; - FillGeometry(Point(0, 0)); - } - } - } - - void GuiPolygonElementRenderer::DestroyGeometry() - { - if(geometry) - { - geometry=0; - } - } - - void GuiPolygonElementRenderer::FillGeometry(Point offset) - { - if(geometry) - { - ID2D1GeometrySink* pgs=0; - geometry->Open(&pgs); - if(pgs) - { - D2D1_POINT_2F p; - p.x=(FLOAT)(oldPoints[0].x+offset.x)+0.5f; - p.y=(FLOAT)(oldPoints[0].y+offset.y)+0.5f; - pgs->BeginFigure(p, D2D1_FIGURE_BEGIN_FILLED); - for(vint i=1;iAddLine(p); - } - pgs->EndFigure(D2D1_FIGURE_END_CLOSED); - pgs->Close(); - pgs->Release(); - } - } - } - - void GuiPolygonElementRenderer::RecreateResource(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget) - { - if(oldRenderTarget==newRenderTarget) - { - if(oldRenderTarget) - { - if(oldBorderColor!=element->GetBorderColor()) - { - oldRenderTarget->DestroyDirect2DBrush(oldBorderColor); - oldBorderColor=element->GetBorderColor(); - borderBrush=newRenderTarget->CreateDirect2DBrush(oldBorderColor); - } - if(oldBackgroundColor!=element->GetBackgroundColor()) - { - oldRenderTarget->DestroyDirect2DBrush(oldBackgroundColor); - oldBackgroundColor=element->GetBackgroundColor(); - backgroundBrush=newRenderTarget->CreateDirect2DBrush(oldBackgroundColor); - } - } - } - else - { - if(oldRenderTarget) - { - oldRenderTarget->DestroyDirect2DBrush(oldBorderColor); - oldRenderTarget->DestroyDirect2DBrush(oldBackgroundColor); - } - if(newRenderTarget) - { - oldBorderColor=element->GetBorderColor(); - oldBackgroundColor=element->GetBackgroundColor(); - borderBrush=newRenderTarget->CreateDirect2DBrush(oldBorderColor); - backgroundBrush=newRenderTarget->CreateDirect2DBrush(oldBackgroundColor); - } - } - } - - void GuiPolygonElementRenderer::InitializeInternal() - { - oldBorderColor=element->GetBorderColor(); - oldBackgroundColor=element->GetBackgroundColor(); - RecreateResource(0, renderTarget); - CreateGeometry(); - } - - void GuiPolygonElementRenderer::FinalizeInternal() - { - DestroyGeometry(); - RecreateResource(renderTarget, 0); - } - - void GuiPolygonElementRenderer::RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget) - { - RecreateResource(oldRenderTarget, newRenderTarget); - } - - GuiPolygonElementRenderer::GuiPolygonElementRenderer() - :borderBrush(0) - ,backgroundBrush(0) - ,geometry(0) - { - } - - void GuiPolygonElementRenderer::Render(Rect bounds) - { - if(renderTarget && geometry) - { - ID2D1RenderTarget* d2dRenderTarget=renderTarget->GetDirect2DRenderTarget(); - vint offsetX=(bounds.Width()-minSize.x)/2+bounds.x1; - vint offsetY=(bounds.Height()-minSize.y)/2+bounds.y1; - - D2D1_MATRIX_3X2_F oldT, newT; - d2dRenderTarget->GetTransform(&oldT); - newT=D2D1::Matrix3x2F::Translation((FLOAT)offsetX, (FLOAT)offsetY); - d2dRenderTarget->SetTransform(&newT); - - d2dRenderTarget->FillGeometry(geometry.Obj(), backgroundBrush); - d2dRenderTarget->DrawGeometry(geometry.Obj(), borderBrush); - d2dRenderTarget->SetTransform(&oldT); - } - } - - void GuiPolygonElementRenderer::OnElementStateChanged() - { - minSize=element->GetSize(); - RecreateResource(renderTarget, renderTarget); - - bool polygonModified=false; - if(oldPoints.Count()!=element->GetPointCount()) - { - polygonModified=true; - } - else - { - for(vint i=0;iGetPoint(i)) - { - polygonModified=true; - break; - } - } - } - if(polygonModified) - { - DestroyGeometry(); - CreateGeometry(); - } - } - -/*********************************************************************** -GuiColorizedTextElementRenderer -***********************************************************************/ - - void GuiColorizedTextElementRenderer::CreateTextBrush(IWindowsDirect2DRenderTarget* _renderTarget) - { - if(_renderTarget) - { - colors.Resize(element->GetColors().Count()); - for(vint i=0;iGetColors().Get(i); - ColorEntryResource newEntry; - - newEntry.normal.text=entry.normal.text; - newEntry.normal.textBrush=_renderTarget->CreateDirect2DBrush(newEntry.normal.text); - newEntry.normal.background=entry.normal.background; - newEntry.normal.backgroundBrush=_renderTarget->CreateDirect2DBrush(newEntry.normal.background); - newEntry.selectedFocused.text=entry.selectedFocused.text; - newEntry.selectedFocused.textBrush=_renderTarget->CreateDirect2DBrush(newEntry.selectedFocused.text); - newEntry.selectedFocused.background=entry.selectedFocused.background; - newEntry.selectedFocused.backgroundBrush=_renderTarget->CreateDirect2DBrush(newEntry.selectedFocused.background); - newEntry.selectedUnfocused.text=entry.selectedUnfocused.text; - newEntry.selectedUnfocused.textBrush=_renderTarget->CreateDirect2DBrush(newEntry.selectedUnfocused.text); - newEntry.selectedUnfocused.background=entry.selectedUnfocused.background; - newEntry.selectedUnfocused.backgroundBrush=_renderTarget->CreateDirect2DBrush(newEntry.selectedUnfocused.background); - colors[i]=newEntry; - } - } - } - - void GuiColorizedTextElementRenderer::DestroyTextBrush(IWindowsDirect2DRenderTarget* _renderTarget) - { - if(_renderTarget) - { - for(vint i=0;iDestroyDirect2DBrush(colors[i].normal.text); - _renderTarget->DestroyDirect2DBrush(colors[i].normal.background); - _renderTarget->DestroyDirect2DBrush(colors[i].selectedFocused.text); - _renderTarget->DestroyDirect2DBrush(colors[i].selectedFocused.background); - _renderTarget->DestroyDirect2DBrush(colors[i].selectedUnfocused.text); - _renderTarget->DestroyDirect2DBrush(colors[i].selectedUnfocused.background); - } - colors.Resize(0); - } - } - - void GuiColorizedTextElementRenderer::CreateCaretBrush(IWindowsDirect2DRenderTarget* _renderTarget) - { - if(_renderTarget) - { - oldCaretColor=element->GetCaretColor(); - caretBrush=_renderTarget->CreateDirect2DBrush(oldCaretColor); - } - } - - void GuiColorizedTextElementRenderer::DestroyCaretBrush(IWindowsDirect2DRenderTarget* _renderTarget) - { - if(_renderTarget) - { - if(caretBrush) - { - _renderTarget->DestroyDirect2DBrush(oldCaretColor); - caretBrush=0; - } - } - } - - void GuiColorizedTextElementRenderer::ColorChanged() - { - DestroyTextBrush(renderTarget); - CreateTextBrush(renderTarget); - } - - void GuiColorizedTextElementRenderer::FontChanged() - { - IWindowsDirect2DResourceManager* resourceManager=GetWindowsDirect2DResourceManager(); - if(textFormat) - { - resourceManager->DestroyDirect2DTextFormat(oldFont); - resourceManager->DestroyDirect2DCharMeasurer(oldFont); - } - oldFont=element->GetFont(); - textFormat=resourceManager->CreateDirect2DTextFormat(oldFont); - element->GetLines().SetCharMeasurer(resourceManager->CreateDirect2DCharMeasurer(oldFont).Obj()); - } - - text::CharMeasurer* GuiColorizedTextElementRenderer::GetCharMeasurer() - { return 0; } - void GuiColorizedTextElementRenderer::InitializeInternal() + IWindowsForm* GetWindowsForm(INativeWindow* window) { - textFormat=0; - caretBrush=0; - element->SetCallback(this); + return dynamic_cast(window); } - void GuiColorizedTextElementRenderer::FinalizeInternal() + void DestroyWindowsNativeController(INativeController* controller) { - DestroyTextBrush(renderTarget); - DestroyCaretBrush(renderTarget); - - IWindowsDirect2DResourceManager* resourceManager=GetWindowsDirect2DResourceManager(); - if(textFormat) - { - resourceManager->DestroyDirect2DTextFormat(oldFont); - resourceManager->DestroyDirect2DCharMeasurer(oldFont); - } + delete controller; } - void GuiColorizedTextElementRenderer::RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget) + void EnableCrossKernelCrashing() { - DestroyTextBrush(oldRenderTarget); - DestroyCaretBrush(oldRenderTarget); - CreateTextBrush(newRenderTarget); - CreateCaretBrush(newRenderTarget); - element->GetLines().SetRenderTarget(newRenderTarget); - } + /* + "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options" + DWORD DisableUserModeCallbackFilter = 1 - void GuiColorizedTextElementRenderer::Render(Rect bounds) - { - if(renderTarget) - { - ID2D1RenderTarget* d2dRenderTarget=renderTarget->GetDirect2DRenderTarget(); - wchar_t passwordChar=element->GetPasswordChar(); - Point viewPosition=element->GetViewPosition(); - Rect viewBounds(viewPosition, bounds.GetSize()); - vint startRow=element->GetLines().GetTextPosFromPoint(Point(viewBounds.x1, viewBounds.y1)).row; - vint endRow=element->GetLines().GetTextPosFromPoint(Point(viewBounds.x2, viewBounds.y2)).row; - TextPos selectionBegin=element->GetCaretBegin()GetCaretEnd()?element->GetCaretBegin():element->GetCaretEnd(); - TextPos selectionEnd=element->GetCaretBegin()>element->GetCaretEnd()?element->GetCaretBegin():element->GetCaretEnd(); - bool focused=element->GetFocused(); - - renderTarget->SetTextAntialias(oldFont.antialias, oldFont.verticalAntialias); - - for(vint row=startRow;row<=endRow;row++) - { - Rect startRect=element->GetLines().GetRectFromTextPos(TextPos(row, 0)); - Point startPoint=startRect.LeftTop(); - vint startColumn=element->GetLines().GetTextPosFromPoint(Point(viewBounds.x1, startPoint.y)).column; - vint endColumn=element->GetLines().GetTextPosFromPoint(Point(viewBounds.x2, startPoint.y)).column; - text::TextLine& line=element->GetLines().GetLine(row); - - vint x=startColumn==0?0:line.att[startColumn-1].rightOffset; - for(vint column=startColumn; column<=endColumn; column++) - { - bool inSelection=false; - if(selectionBegin.row==selectionEnd.row) - { - inSelection=(row==selectionBegin.row && selectionBegin.column<=column && column=colors.Count()) - { - colorIndex=0; - } - ColorItemResource& color= - !inSelection?colors[colorIndex].normal: - focused?colors[colorIndex].selectedFocused: - colors[colorIndex].selectedUnfocused; - vint x2=crlf?x+startRect.Height()/2:line.att[column].rightOffset; - vint tx=x-viewPosition.x+bounds.x1; - vint ty=startPoint.y-viewPosition.y+bounds.y1; - - if(color.background.a>0) - { - d2dRenderTarget->FillRectangle(D2D1::RectF((FLOAT)tx, (FLOAT)ty, (FLOAT)(tx+(x2-x)), (FLOAT)(ty+startRect.Height())), color.backgroundBrush); - } - if(!crlf) - { - d2dRenderTarget->DrawText( - (passwordChar?&passwordChar:&line.text[column]), - 1, - textFormat->textFormat.Obj(), - D2D1::RectF((FLOAT)tx, (FLOAT)ty, (FLOAT)tx+1, (FLOAT)ty+1), - color.textBrush, - D2D1_DRAW_TEXT_OPTIONS_NO_SNAP, - DWRITE_MEASURING_MODE_GDI_NATURAL - ); - } - x=x2; - } - } - - if(element->GetCaretVisible() && element->GetLines().IsAvailable(element->GetCaretEnd())) - { - Point caretPoint=element->GetLines().GetPointFromTextPos(element->GetCaretEnd()); - vint height=element->GetLines().GetRowHeight(); - Point p1(caretPoint.x-viewPosition.x+bounds.x1, caretPoint.y-viewPosition.y+bounds.y1+1); - Point p2(caretPoint.x-viewPosition.x+bounds.x1, caretPoint.y+height-viewPosition.y+bounds.y1-1); - d2dRenderTarget->DrawLine( - D2D1::Point2F((FLOAT)p1.x+0.5f, (FLOAT)p1.y), - D2D1::Point2F((FLOAT)p2.x+0.5f, (FLOAT)p2.y), - caretBrush - ); - d2dRenderTarget->DrawLine( - D2D1::Point2F((FLOAT)p1.x-0.5f, (FLOAT)p1.y), - D2D1::Point2F((FLOAT)p2.x-0.5f, (FLOAT)p2.y), - caretBrush - ); - } - } - } - - void GuiColorizedTextElementRenderer::OnElementStateChanged() - { - if(renderTarget) - { - Color caretColor=element->GetCaretColor(); - if(oldCaretColor!=caretColor) - { - DestroyCaretBrush(renderTarget); - CreateCaretBrush(renderTarget); - } - } - } - -/*********************************************************************** -GuiDirect2DElementRenderer -***********************************************************************/ - - void GuiDirect2DElementRenderer::InitializeInternal() - { - } - - void GuiDirect2DElementRenderer::FinalizeInternal() - { - } - - void GuiDirect2DElementRenderer::RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget) - { - IDWriteFactory* fdw=GetWindowsDirect2DObjectProvider()->GetDirectWriteFactory(); - ID2D1Factory* fd2d=GetWindowsDirect2DObjectProvider()->GetDirect2DFactory(); - if(oldRenderTarget) - { - GuiDirect2DElementEventArgs arguments(element, oldRenderTarget->GetDirect2DRenderTarget(), fdw, fd2d, Rect()); - element->BeforeRenderTargetChanged.Execute(arguments); - } - if(newRenderTarget) - { - GuiDirect2DElementEventArgs arguments(element, newRenderTarget->GetDirect2DRenderTarget(), fdw, fd2d, Rect()); - element->AfterRenderTargetChanged.Execute(arguments); - } - } - - GuiDirect2DElementRenderer::GuiDirect2DElementRenderer() - { - } - - GuiDirect2DElementRenderer::~GuiDirect2DElementRenderer() - { - } - - void GuiDirect2DElementRenderer::Render(Rect bounds) - { - if(renderTarget) - { - IDWriteFactory* fdw=GetWindowsDirect2DObjectProvider()->GetDirectWriteFactory(); - ID2D1Factory* fd2d=GetWindowsDirect2DObjectProvider()->GetDirect2DFactory(); - renderTarget->PushClipper(bounds); - if(!renderTarget->IsClipperCoverWholeTarget()) - { - ID2D1RenderTarget* rt=renderTarget->GetDirect2DRenderTarget(); - GuiDirect2DElementEventArgs arguments(element, rt, fdw, fd2d, bounds); - element->Rendering.Execute(arguments); - } - renderTarget->PopClipper(); - } - } - - void GuiDirect2DElementRenderer::OnElementStateChanged() - { + "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\TestCppCodegen.exe" + DWORD DisableUserModeCallbackFilter = 1 + */ + typedef BOOL (WINAPI *tGetPolicy)(LPDWORD lpFlags); + typedef BOOL (WINAPI *tSetPolicy)(DWORD dwFlags); + const DWORD EXCEPTION_SWALLOWING = 0x1; + + HMODULE kernel32 = LoadLibrary(L"kernel32.dll"); + tGetPolicy pGetPolicy = (tGetPolicy)GetProcAddress(kernel32, "GetProcessUserModeExceptionPolicy"); + tSetPolicy pSetPolicy = (tSetPolicy)GetProcAddress(kernel32, "SetProcessUserModeExceptionPolicy"); + if (pGetPolicy && pSetPolicy) + { + DWORD dwFlags; + if (pGetPolicy(&dwFlags)) + { + // Turn off the filter + pSetPolicy(dwFlags & ~EXCEPTION_SWALLOWING); + } + } } } } } - -/*********************************************************************** -GRAPHICSELEMENT\WINDOWSDIRECT2D\GUIGRAPHICSWINDOWSDIRECT2D.CPP -***********************************************************************/ - -namespace vl -{ - namespace presentation - { - namespace elements - { - -/*********************************************************************** -GuiDirect2DElement -***********************************************************************/ - - GuiDirect2DElement::GuiDirect2DElement() - { - } - } - - namespace elements_windows_d2d - { - using namespace elements; - using namespace collections; - - D2D1::ColorF GetD2DColor(Color color) - { - return D2D1::ColorF(color.r/255.0f, color.g/255.0f, color.b/255.0f, color.a/255.0f); - } - -/*********************************************************************** -CachedResourceAllocator -***********************************************************************/ - - class CachedSolidBrushAllocator - { - DEFINE_CACHED_RESOURCE_ALLOCATOR(Color, ComPtr) - - IWindowsDirect2DRenderTarget* guiRenderTarget; - public: - CachedSolidBrushAllocator() - :guiRenderTarget(0) - { - } - - void SetRenderTarget(IWindowsDirect2DRenderTarget* _guiRenderTarget) - { - guiRenderTarget=_guiRenderTarget; - } - - ComPtr CreateInternal(Color color) - { - ID2D1SolidColorBrush* brush=0; - ID2D1RenderTarget* renderTarget=guiRenderTarget->GetDirect2DRenderTarget(); - HRESULT hr=renderTarget->CreateSolidColorBrush(GetD2DColor(color), &brush); - if(!FAILED(hr)) - { - return brush; - } - else - { - return 0; - } - } - }; - - class CachedLinearBrushAllocator - { - typedef Pair ColorPair; - DEFINE_CACHED_RESOURCE_ALLOCATOR(ColorPair, ComPtr) - - IWindowsDirect2DRenderTarget* guiRenderTarget; - public: - CachedLinearBrushAllocator() - :guiRenderTarget(0) - { - } - - void SetRenderTarget(IWindowsDirect2DRenderTarget* _guiRenderTarget) - { - guiRenderTarget=_guiRenderTarget; - } - - ComPtr CreateInternal(ColorPair colors) - { - ID2D1RenderTarget* renderTarget=guiRenderTarget->GetDirect2DRenderTarget(); - ID2D1GradientStopCollection* stopCollection=0; - { - D2D1_GRADIENT_STOP stops[2]; - stops[0].color=GetD2DColor(colors.key); - stops[0].position=0.0f; - stops[1].color=GetD2DColor(colors.value); - stops[1].position=1.0f; - - HRESULT hr=renderTarget->CreateGradientStopCollection( - stops, - 2, - D2D1_GAMMA_2_2, - D2D1_EXTEND_MODE_CLAMP, - &stopCollection); - if(FAILED(hr)) return 0; - } - - ID2D1LinearGradientBrush* brush=0; - { - D2D1_POINT_2F points[2]={{0, 0}, {0, 0}}; - HRESULT hr=renderTarget->CreateLinearGradientBrush( - D2D1::LinearGradientBrushProperties(points[0], points[1]), - stopCollection, - &brush); - stopCollection->Release(); - if(FAILED(hr)) return 0; - } - return brush; - } - }; - - class CachedTextFormatAllocator - { - private: - DEFINE_CACHED_RESOURCE_ALLOCATOR(FontProperties, Ptr) - public: - - static ComPtr CreateDirect2DFont(const FontProperties& fontProperties) - { - IDWriteFactory* dwriteFactory=GetWindowsDirect2DObjectProvider()->GetDirectWriteFactory(); - IDWriteTextFormat* format=0; - HRESULT hr=dwriteFactory->CreateTextFormat( - fontProperties.fontFamily.Buffer(), - NULL, - (fontProperties.bold?DWRITE_FONT_WEIGHT_BOLD:DWRITE_FONT_WEIGHT_NORMAL), - (fontProperties.italic?DWRITE_FONT_STYLE_ITALIC:DWRITE_FONT_STYLE_NORMAL), - DWRITE_FONT_STRETCH_NORMAL, - (FLOAT)fontProperties.size, - L"", - &format); - if(!FAILED(hr)) - { - format->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP); - return format; - } - else - { - return 0; - } - } - - Ptr CreateInternal(const FontProperties& fontProperties) - { - Ptr textFormat=new Direct2DTextFormatPackage; - textFormat->textFormat=CreateDirect2DFont(fontProperties); - textFormat->trimming.granularity=DWRITE_TRIMMING_GRANULARITY_CHARACTER; - textFormat->trimming.delimiter=0; - textFormat->trimming.delimiterCount=0; - - IDWriteInlineObject* ellipseInlineObject=0; - GetWindowsDirect2DObjectProvider()->GetDirectWriteFactory()->CreateEllipsisTrimmingSign(textFormat->textFormat.Obj(), &ellipseInlineObject); - textFormat->ellipseInlineObject=ellipseInlineObject; - return textFormat; - } - }; - - class CachedCharMeasurerAllocator - { - DEFINE_CACHED_RESOURCE_ALLOCATOR(FontProperties, Ptr) - - protected: - class Direct2DCharMeasurer : public text::CharMeasurer - { - protected: - ComPtr font; - vint size; - - Size MeasureInternal(wchar_t character, IGuiGraphicsRenderTarget* renderTarget) - { - Size charSize(0, 0); - IDWriteTextLayout* textLayout=0; - HRESULT hr=GetWindowsDirect2DObjectProvider()->GetDirectWriteFactory()->CreateTextLayout( - &character, - 1, - font.Obj(), - 0, - 0, - &textLayout); - if(!FAILED(hr)) - { - DWRITE_TEXT_METRICS metrics; - hr=textLayout->GetMetrics(&metrics); - if(!FAILED(hr)) - { - charSize=Size((vint)ceil(metrics.widthIncludingTrailingWhitespace), (vint)ceil(metrics.height)); - } - textLayout->Release(); - } - return charSize; - } - - vint MeasureWidthInternal(wchar_t character, IGuiGraphicsRenderTarget* renderTarget) - { - return MeasureInternal(character, renderTarget).x; - } - - vint GetRowHeightInternal(IGuiGraphicsRenderTarget* renderTarget) - { - return MeasureInternal(L' ', renderTarget).y; - } - public: - Direct2DCharMeasurer(ComPtr _font, vint _size) - :text::CharMeasurer(_size) - ,size(_size) - ,font(_font) - { - } - }; - public: - Ptr CreateInternal(const FontProperties& value) - { - return new Direct2DCharMeasurer(CachedTextFormatAllocator::CreateDirect2DFont(value), value.size); - } - }; - -/*********************************************************************** -WindowsDirect2DRenderTarget -***********************************************************************/ - - class WindowsDirect2DImageFrameCache : public Object, public INativeImageFrameCache - { - protected: - IWindowsDirect2DRenderTarget* renderTarget; - INativeImageFrame* cachedFrame; - ComPtr bitmap; - ComPtr disabledBitmap; - public: - WindowsDirect2DImageFrameCache(IWindowsDirect2DRenderTarget* _renderTarget) - :renderTarget(_renderTarget) - { - } - - ~WindowsDirect2DImageFrameCache() - { - } - - void OnAttach(INativeImageFrame* frame)override - { - cachedFrame=frame; - ID2D1Bitmap* d2dBitmap=0; - HRESULT hr=renderTarget->GetDirect2DRenderTarget()->CreateBitmapFromWicBitmap( - GetWindowsDirect2DObjectProvider()->GetWICBitmap(frame), - &d2dBitmap - ); - if(SUCCEEDED(hr)) - { - bitmap=d2dBitmap; - } - } - - void OnDetach(INativeImageFrame* frame)override - { - renderTarget->DestroyBitmapCache(cachedFrame); - } - - INativeImageFrame* GetFrame() - { - return cachedFrame; - } - - ComPtr GetBitmap(bool enabled) - { - if(enabled) - { - return bitmap; - } - else - { - if(!disabledBitmap) - { - IWICBitmap* frameBitmap=GetWindowsDirect2DObjectProvider()->GetWICBitmap(cachedFrame); - ID2D1Bitmap* d2dBitmap=0; - HRESULT hr=renderTarget->GetDirect2DRenderTarget()->CreateBitmapFromWicBitmap( - frameBitmap, - &d2dBitmap - ); - if(SUCCEEDED(hr)) - { - disabledBitmap=d2dBitmap; - - WICRect rect; - rect.X=0; - rect.Y=0; - rect.Width=bitmap->GetPixelSize().width; - rect.Height=bitmap->GetPixelSize().height; - BYTE* buffer=new BYTE[rect.Width*rect.Height*4]; - hr=frameBitmap->CopyPixels(&rect, rect.Width*4, rect.Width*rect.Height*4, buffer); - if(SUCCEEDED(hr)) - { - vint count=rect.Width*rect.Height; - BYTE* read=buffer; - for(vint i=0;iCopyFromMemory(&d2dRect, buffer, rect.Width*4); - } - delete[] buffer; - } - } - return disabledBitmap; - } - } - }; - - class WindowsDirect2DRenderTarget : public Object, public IWindowsDirect2DRenderTarget - { - typedef SortedList> ImageCacheList; - protected: - INativeWindow* window; - ID2D1RenderTarget* d2dRenderTarget = nullptr; - List clippers; - vint clipperCoverWholeTargetCounter = 0; - - CachedSolidBrushAllocator solidBrushes; - CachedLinearBrushAllocator linearBrushes; - ImageCacheList imageCaches; - - ComPtr noAntialiasParams; - ComPtr horizontalAntialiasParams; - ComPtr bidirectionalAntialiasParams; - - ComPtr CreateRenderingParams(DWRITE_RENDERING_MODE renderingMode, IDWriteRenderingParams* defaultParams, IDWriteFactory* dwriteFactory) - { - IDWriteRenderingParams* renderingParams=0; - FLOAT gamma=defaultParams->GetGamma(); - FLOAT enhancedContrast=defaultParams->GetEnhancedContrast(); - FLOAT clearTypeLevel=defaultParams->GetClearTypeLevel(); - DWRITE_PIXEL_GEOMETRY pixelGeometry=defaultParams->GetPixelGeometry(); - HRESULT hr=dwriteFactory->CreateCustomRenderingParams( - gamma, - enhancedContrast, - clearTypeLevel, - pixelGeometry, - renderingMode, - &renderingParams); - if(!FAILED(hr)) - { - return renderingParams; - } - else - { - return 0; - } - } - public: - WindowsDirect2DRenderTarget(INativeWindow* _window) - :window(_window) - { - solidBrushes.SetRenderTarget(this); - linearBrushes.SetRenderTarget(this); - - IDWriteFactory* dwriteFactory=GetWindowsDirect2DObjectProvider()->GetDirectWriteFactory(); - IDWriteRenderingParams* defaultParams=0; - HRESULT hr=dwriteFactory->CreateRenderingParams(&defaultParams); - if(!FAILED(hr)) - { - noAntialiasParams=CreateRenderingParams(DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL, defaultParams, dwriteFactory); - horizontalAntialiasParams=CreateRenderingParams(DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL, defaultParams, dwriteFactory); - bidirectionalAntialiasParams=CreateRenderingParams(DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC, defaultParams, dwriteFactory); - defaultParams->Release(); - } - } - - ~WindowsDirect2DRenderTarget() - { - while(imageCaches.Count()) - { - Ptr cache=imageCaches[imageCaches.Count()-1]; - cache->GetFrame()->RemoveCache(this); - } - } - - ID2D1RenderTarget* GetDirect2DRenderTarget()override - { - return d2dRenderTarget ? d2dRenderTarget : GetWindowsDirect2DObjectProvider()->GetNativeWindowDirect2DRenderTarget(window); - } - - ComPtr GetBitmap(INativeImageFrame* frame, bool enabled)override - { - Ptr cache=frame->GetCache(this); - if(cache) - { - return cache.Cast()->GetBitmap(enabled); - } - else - { - Ptr d2dCache=new WindowsDirect2DImageFrameCache(this); - if(frame->SetCache(this, d2dCache)) - { - imageCaches.Add(d2dCache); - return d2dCache->GetBitmap(enabled); - } - else - { - return 0; - } - } - } - - void DestroyBitmapCache(INativeImageFrame* frame)override - { - WindowsDirect2DImageFrameCache* cache=frame->GetCache(this).Cast().Obj(); - imageCaches.Remove(cache); - } - - void SetTextAntialias(bool antialias, bool verticalAntialias)override - { - ComPtr params; - if(!antialias) - { - params=noAntialiasParams; - } - else if(!verticalAntialias) - { - params=horizontalAntialiasParams; - } - else - { - params=bidirectionalAntialiasParams; - } - if(params && d2dRenderTarget) - { - d2dRenderTarget->SetTextRenderingParams(params.Obj()); - } - } - - void StartRendering()override - { - d2dRenderTarget = GetWindowsDirect2DObjectProvider()->GetNativeWindowDirect2DRenderTarget(window); - CHECK_ERROR(d2dRenderTarget, L"vl::presentation::elements_windows_d2d::WindowsDirect2DRenderTarget::StartRendering()#Invalid render target."); - - GetWindowsDirect2DObjectProvider()->StartRendering(window); - } - - RenderTargetFailure StopRendering()override - { - CHECK_ERROR(d2dRenderTarget, L"vl::presentation::elements_windows_d2d::WindowsDirect2DRenderTarget::StartRendering()#Invalid render target."); - auto result = GetWindowsDirect2DObjectProvider()->StopRenderingAndPresent(window); - d2dRenderTarget = nullptr; - return result; - } - - void PushClipper(Rect clipper)override - { - if(clipperCoverWholeTargetCounter>0) - { - clipperCoverWholeTargetCounter++; - } - else - { - Rect previousClipper=GetClipper(); - Rect currentClipper; - - currentClipper.x1=(previousClipper.x1>clipper.x1?previousClipper.x1:clipper.x1); - currentClipper.y1=(previousClipper.y1>clipper.y1?previousClipper.y1:clipper.y1); - currentClipper.x2=(previousClipper.x2PushAxisAlignedClip( - D2D1::RectF((FLOAT)currentClipper.x1, (FLOAT)currentClipper.y1, (FLOAT)currentClipper.x2, (FLOAT)currentClipper.y2), - D2D1_ANTIALIAS_MODE_PER_PRIMITIVE - ); - } - else - { - clipperCoverWholeTargetCounter++; - } - } - } - - void PopClipper()override - { - if(clipperCoverWholeTargetCounter>0) - { - clipperCoverWholeTargetCounter--; - } - else if(clippers.Count()>0) - { - clippers.RemoveAt(clippers.Count()-1); - d2dRenderTarget->PopAxisAlignedClip(); - } - } - - Rect GetClipper()override - { - if(clippers.Count()==0) - { - return Rect(Point(0, 0), window->GetClientSize()); - } - else - { - return clippers[clippers.Count()-1]; - } - } - - bool IsClipperCoverWholeTarget()override - { - return clipperCoverWholeTargetCounter>0; - } - - ID2D1SolidColorBrush* CreateDirect2DBrush(Color color)override - { - return solidBrushes.Create(color).Obj(); - } - - void DestroyDirect2DBrush(Color color)override - { - solidBrushes.Destroy(color); - } - - ID2D1LinearGradientBrush* CreateDirect2DLinearBrush(Color c1, Color c2)override - { - return linearBrushes.Create(Pair(c1, c2)).Obj(); - } - - void DestroyDirect2DLinearBrush(Color c1, Color c2)override - { - linearBrushes.Destroy(Pair(c1, c2)); - } - }; - -/*********************************************************************** -WindowsGDIResourceManager -***********************************************************************/ - - class WindowsDirect2DResourceManager : public GuiGraphicsResourceManager, public IWindowsDirect2DResourceManager, public INativeControllerListener - { - protected: - SortedList> renderTargets; - Ptr layoutProvider; - - CachedTextFormatAllocator textFormats; - CachedCharMeasurerAllocator charMeasurers; - public: - WindowsDirect2DResourceManager() - { - layoutProvider=new WindowsDirect2DLayoutProvider; - } - - IGuiGraphicsRenderTarget* GetRenderTarget(INativeWindow* window)override - { - return GetWindowsDirect2DObjectProvider()->GetBindedRenderTarget(window); - } - - void RecreateRenderTarget(INativeWindow* window)override - { - NativeWindowDestroying(window); - GetWindowsDirect2DObjectProvider()->RecreateRenderTarget(window); - NativeWindowCreated(window); - } - - void ResizeRenderTarget(INativeWindow* window) - { - GetWindowsDirect2DObjectProvider()->ResizeRenderTarget(window); - } - - IGuiGraphicsLayoutProvider* GetLayoutProvider()override - { - return layoutProvider.Obj(); - } - - void NativeWindowCreated(INativeWindow* window)override - { - WindowsDirect2DRenderTarget* renderTarget=new WindowsDirect2DRenderTarget(window); - renderTargets.Add(renderTarget); - GetWindowsDirect2DObjectProvider()->SetBindedRenderTarget(window, renderTarget); - } - - void NativeWindowDestroying(INativeWindow* window)override - { - WindowsDirect2DRenderTarget* renderTarget=dynamic_cast(GetWindowsDirect2DObjectProvider()->GetBindedRenderTarget(window)); - GetWindowsDirect2DObjectProvider()->SetBindedRenderTarget(window, 0); - renderTargets.Remove(renderTarget); - } - - Direct2DTextFormatPackage* CreateDirect2DTextFormat(const FontProperties& fontProperties)override - { - return textFormats.Create(fontProperties).Obj(); - } - - void DestroyDirect2DTextFormat(const FontProperties& fontProperties)override - { - textFormats.Destroy(fontProperties); - } - - Ptr CreateDirect2DCharMeasurer(const FontProperties& fontProperties)override - { - return charMeasurers.Create(fontProperties); - } - - void DestroyDirect2DCharMeasurer(const FontProperties& fontProperties)override - { - charMeasurers.Destroy(fontProperties); - } - }; - } - - namespace elements_windows_d2d - { - IWindowsDirect2DResourceManager* windowsDirect2DResourceManager=0; - - IWindowsDirect2DResourceManager* GetWindowsDirect2DResourceManager() - { - return windowsDirect2DResourceManager; - } - - void SetWindowsDirect2DResourceManager(IWindowsDirect2DResourceManager* resourceManager) - { - windowsDirect2DResourceManager=resourceManager; - } - -/*********************************************************************** -OS Supporting -***********************************************************************/ - - IWindowsDirect2DObjectProvider* windowsDirect2DObjectProvider=0; - - IWindowsDirect2DObjectProvider* GetWindowsDirect2DObjectProvider() - { - return windowsDirect2DObjectProvider; - } - - void SetWindowsDirect2DObjectProvider(IWindowsDirect2DObjectProvider* provider) - { - windowsDirect2DObjectProvider=provider; - } - } - } -} - -/*********************************************************************** -NativeMain -***********************************************************************/ - -using namespace vl::presentation; -using namespace vl::presentation::elements; - -void RendererMainDirect2D() -{ - elements_windows_d2d::WindowsDirect2DResourceManager resourceManager; - SetGuiGraphicsResourceManager(&resourceManager); - elements_windows_d2d::SetWindowsDirect2DResourceManager(&resourceManager); - GetCurrentController()->CallbackService()->InstallListener(&resourceManager); - - elements_windows_d2d::GuiSolidBorderElementRenderer::Register(); - elements_windows_d2d::GuiRoundBorderElementRenderer::Register(); - elements_windows_d2d::Gui3DBorderElementRenderer::Register(); - elements_windows_d2d::Gui3DSplitterElementRenderer::Register(); - elements_windows_d2d::GuiSolidBackgroundElementRenderer::Register(); - elements_windows_d2d::GuiGradientBackgroundElementRenderer::Register(); - elements_windows_d2d::GuiSolidLabelElementRenderer::Register(); - elements_windows_d2d::GuiImageFrameElementRenderer::Register(); - elements_windows_d2d::GuiPolygonElementRenderer::Register(); - elements_windows_d2d::GuiColorizedTextElementRenderer::Register(); - elements_windows_d2d::GuiDirect2DElementRenderer::Register(); - elements::GuiDocumentElement::GuiDocumentElementRenderer::Register(); - - GuiApplicationMain(); - elements_windows_d2d::SetWindowsDirect2DResourceManager(0); - SetGuiGraphicsResourceManager(0); -} diff --git a/Import/GacUIWindows.h b/Import/GacUIWindows.h index a8e4882d..d62c5190 100644 --- a/Import/GacUIWindows.h +++ b/Import/GacUIWindows.h @@ -2,11 +2,75 @@ THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY DEVELOPER: Zihan Chen(vczh) ***********************************************************************/ -#include "Vlpp.h" #include "GacUI.h" +#include "Vlpp.h" /*********************************************************************** -NATIVEWINDOW\WINDOWS\GDI\WINGDI.H +.\GRAPHICSELEMENT\WINDOWSDIRECT2D\GUIGRAPHICSLAYOUTPROVIDERWINDOWSDIRECT2D.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Native Window::Direct2D Provider for Windows Implementation::Renderer + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSLAYOUTPROVIDERWINDOWSDIRECT2D +#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSLAYOUTPROVIDERWINDOWSDIRECT2D + + +namespace vl +{ + namespace presentation + { + namespace elements_windows_d2d + { + class WindowsDirect2DLayoutProvider : public Object, public elements::IGuiGraphicsLayoutProvider + { + public: + Ptr CreateParagraph(const WString& text, elements::IGuiGraphicsRenderTarget* renderTarget, elements::IGuiGraphicsParagraphCallback* callback)override; + }; + } + } +} + +#endif + +/*********************************************************************** +.\GRAPHICSELEMENT\WINDOWSGDI\GUIGRAPHICSLAYOUTPROVIDERWINDOWSGDI.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Native Window::GDI Provider for Windows Implementation::Renderer + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSLAYOUTPROVIDERWINDOWSGDI +#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSLAYOUTPROVIDERWINDOWSGDI + + +namespace vl +{ + namespace presentation + { + namespace elements_windows_gdi + { + class WindowsGDILayoutProvider : public Object, public elements::IGuiGraphicsLayoutProvider + { + public: + Ptr CreateParagraph(const WString& text, elements::IGuiGraphicsRenderTarget* renderTarget, elements::IGuiGraphicsParagraphCallback* callback)override; + }; + } + } +} + +#endif + +/*********************************************************************** +.\NATIVEWINDOW\WINDOWS\GDI\WINGDI.H ***********************************************************************/ /******************************************************************************* Vczh Library++ 3.0 @@ -473,7 +537,204 @@ namespace vl #endif /*********************************************************************** -NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSIMAGESERVICE.H +.\NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSASYNCSERVICE.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Native Window::Windows Implementation + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_WINDOWS_SERVICESIMPL_WINDOWSASYNCSERVICE +#define VCZH_PRESENTATION_WINDOWS_SERVICESIMPL_WINDOWSASYNCSERVICE + + +namespace vl +{ + namespace presentation + { + namespace windows + { + class WindowsAsyncService : public INativeAsyncService + { + protected: + struct TaskItem + { + Semaphore* semaphore; + Func proc; + + TaskItem(); + TaskItem(Semaphore* _semaphore, const Func& _proc); + ~TaskItem(); + }; + + class DelayItem : public Object, public INativeDelay + { + public: + DelayItem(WindowsAsyncService* _service, const Func& _proc, bool _executeInMainThread, vint milliseconds); + ~DelayItem(); + + WindowsAsyncService* service; + Func proc; + ExecuteStatus status; + DateTime executeTime; + bool executeInMainThread; + + ExecuteStatus GetStatus()override; + bool Delay(vint milliseconds)override; + bool Cancel()override; + }; + protected: + vint mainThreadId; + SpinLock taskListLock; + collections::List taskItems; + collections::List> delayItems; + public: + WindowsAsyncService(); + ~WindowsAsyncService(); + + void ExecuteAsyncTasks(); + bool IsInMainThread()override; + void InvokeAsync(const Func& proc)override; + void InvokeInMainThread(const Func& proc)override; + bool InvokeInMainThreadAndWait(const Func& proc, vint milliseconds)override; + Ptr DelayExecute(const Func& proc, vint milliseconds)override; + Ptr DelayExecuteInMainThread(const Func& proc, vint milliseconds)override; + }; + } + } +} + +#endif + +/*********************************************************************** +.\NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSCALLBACKSERVICE.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Native Window::Windows Implementation + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_WINDOWS_SERVICESIMPL_WINDOWSCALLBACKSERVICE +#define VCZH_PRESENTATION_WINDOWS_SERVICESIMPL_WINDOWSCALLBACKSERVICE + + +namespace vl +{ + namespace presentation + { + namespace windows + { + class WindowsCallbackService : public Object, public INativeCallbackService + { + protected: + collections::List listeners; + + public: + WindowsCallbackService(); + + bool InstallListener(INativeControllerListener* listener)override; + bool UninstallListener(INativeControllerListener* listener)override; + + void InvokeMouseHook(WPARAM message, Point location); + void InvokeGlobalTimer(); + void InvokeClipboardUpdated(); + void InvokeNativeWindowCreated(INativeWindow* window); + void InvokeNativeWindowDestroyed(INativeWindow* window); + }; + } + } +} + +#endif + +/*********************************************************************** +.\NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSCLIPBOARDSERVICE.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Native Window::Windows Implementation + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_WINDOWS_SERVICESIMPL_WINDOWSCLIPBOARDSERVICE +#define VCZH_PRESENTATION_WINDOWS_SERVICESIMPL_WINDOWSCLIPBOARDSERVICE + + +namespace vl +{ + namespace presentation + { + namespace windows + { + class WindowsClipboardService : public Object, public INativeClipboardService + { + protected: + HWND ownerHandle; + public: + WindowsClipboardService(); + + void SetOwnerHandle(HWND handle); + bool ContainsText()override; + WString GetText()override; + bool SetText(const WString& value)override; + }; + } + } +} + +#endif + +/*********************************************************************** +.\NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSDIALOGSERVICE.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Native Window::Windows Implementation + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_WINDOWS_SERVICESIMPL_WINDOWSDIALOGSERVICE +#define VCZH_PRESENTATION_WINDOWS_SERVICESIMPL_WINDOWSDIALOGSERVICE + + +namespace vl +{ + namespace presentation + { + namespace windows + { + class WindowsDialogService : public INativeDialogService + { + typedef HWND (*HandleRetriver)(INativeWindow*); + protected: + HandleRetriver handleRetriver; + + public: + WindowsDialogService(HandleRetriver _handleRetriver); + + MessageBoxButtonsOutput ShowMessageBox(INativeWindow* window, const WString& text, const WString& title, MessageBoxButtonsInput buttons, MessageBoxDefaultButton defaultButton, MessageBoxIcons icon, MessageBoxModalOptions modal)override; + bool ShowColorDialog(INativeWindow* window, Color& selection, bool selected, ColorDialogCustomColorOptions customColorOptions, Color* customColors)override; + bool ShowFontDialog(INativeWindow* window, FontProperties& selectionFont, Color& selectionColor, bool selected, bool showEffect, bool forceFontExist)override; + bool ShowFileDialog(INativeWindow* window, collections::List& selectionFileNames, vint& selectionFilterIndex, FileDialogTypes dialogType, const WString& title, const WString& initialFileName, const WString& initialDirectory, const WString& defaultExtension, const WString& filter, FileDialogOptions options)override; + }; + } + } +} + +#endif + +/*********************************************************************** +.\NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSIMAGESERVICE.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -574,7 +835,7 @@ namespace vl #endif /*********************************************************************** -NATIVEWINDOW\WINDOWS\WINNATIVEWINDOW.H +.\NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSINPUTSERVICE.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -584,8 +845,8 @@ GacUI::Native Window::Windows Implementation Interfaces: ***********************************************************************/ -#ifndef VCZH_PRESENTATION_WINDOWS_WINNATIVEWINDOW -#define VCZH_PRESENTATION_WINDOWS_WINNATIVEWINDOW +#ifndef VCZH_PRESENTATION_WINDOWS_SERVICESIMPL_WINDOWSINPUTSERVICE +#define VCZH_PRESENTATION_WINDOWS_SERVICESIMPL_WINDOWSINPUTSERVICE namespace vl @@ -594,33 +855,37 @@ namespace vl { namespace windows { - -/*********************************************************************** -Windows Platform Native Controller -***********************************************************************/ - - class INativeMessageHandler : public Interface + class WindowsInputService : public Object, public INativeInputService { + protected: + HWND ownerHandle; + HHOOK mouseHook; + bool isTimerEnabled; + HOOKPROC mouseProc; + + collections::Array keyNames; + collections::Dictionary keys; + + WString GetKeyNameInternal(vint code); + void InitializeKeyNames(); public: - virtual void BeforeHandle(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool& skip) = 0; - virtual void AfterHandle(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool& skip, LRESULT& result) = 0; + WindowsInputService(HOOKPROC _mouseProc); + + void SetOwnerHandle(HWND handle); + void StartHookMouse()override; + void StopHookMouse()override; + bool IsHookingMouse()override; + void StartTimer()override; + void StopTimer()override; + bool IsTimerEnabled()override; + bool IsKeyPressing(vint code)override; + bool IsKeyToggled(vint code)override; + WString GetKeyName(vint code)override; + vint GetKey(const WString& name)override; }; - class IWindowsForm : public Interface - { - public: - virtual HWND GetWindowHandle() = 0; - virtual Interface* GetGraphicsHandler() = 0; - virtual void SetGraphicsHandler(Interface* handler) = 0; - virtual bool InstallMessageHandler(Ptr handler) = 0; - virtual bool UninstallMessageHandler(Ptr handler) = 0; - }; - - extern INativeController* CreateWindowsNativeController(HINSTANCE hInstance); - extern IWindowsForm* GetWindowsFormFromHandle(HWND hwnd); - extern IWindowsForm* GetWindowsForm(INativeWindow* window); - extern void DestroyWindowsNativeController(INativeController* controller); - extern void EnableCrossKernelCrashing(); + extern bool WinIsKeyPressing(vint code); + extern bool WinIsKeyToggled(vint code); } } } @@ -628,41 +893,7 @@ Windows Platform Native Controller #endif /*********************************************************************** -NATIVEWINDOW\WINDOWS\DIRECT2D\WINDIRECT2DAPPLICATION.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Native Window::Direct2D Provider for Windows Implementation - -Interfaces: -***********************************************************************/ -#ifndef VCZH_PRESENTATION_WINDOWS_GDI_WINDIRECT2DAPPLICATION -#define VCZH_PRESENTATION_WINDOWS_GDI_WINDIRECT2DAPPLICATION - -#include -#include -#include - -namespace vl -{ - namespace presentation - { - namespace windows - { - extern ID2D1Factory* GetDirect2DFactory(); - extern IDWriteFactory* GetDirectWriteFactory(); - extern ID3D11Device* GetD3D11Device(); - } - } -} - -extern int WinMainDirect2D(HINSTANCE hInstance, void(*RendererMain)()); - -#endif - -/*********************************************************************** -NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSRESOURCESERVICE.H +.\NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSRESOURCESERVICE.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -717,119 +948,7 @@ namespace vl #endif /*********************************************************************** -NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSCLIPBOARDSERVICE.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Native Window::Windows Implementation - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_WINDOWS_SERVICESIMPL_WINDOWSCLIPBOARDSERVICE -#define VCZH_PRESENTATION_WINDOWS_SERVICESIMPL_WINDOWSCLIPBOARDSERVICE - - -namespace vl -{ - namespace presentation - { - namespace windows - { - class WindowsClipboardService : public Object, public INativeClipboardService - { - protected: - HWND ownerHandle; - public: - WindowsClipboardService(); - - void SetOwnerHandle(HWND handle); - bool ContainsText()override; - WString GetText()override; - bool SetText(const WString& value)override; - }; - } - } -} - -#endif - -/*********************************************************************** -NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSASYNCSERVICE.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Native Window::Windows Implementation - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_WINDOWS_SERVICESIMPL_WINDOWSASYNCSERVICE -#define VCZH_PRESENTATION_WINDOWS_SERVICESIMPL_WINDOWSASYNCSERVICE - - -namespace vl -{ - namespace presentation - { - namespace windows - { - class WindowsAsyncService : public INativeAsyncService - { - protected: - struct TaskItem - { - Semaphore* semaphore; - Func proc; - - TaskItem(); - TaskItem(Semaphore* _semaphore, const Func& _proc); - ~TaskItem(); - }; - - class DelayItem : public Object, public INativeDelay - { - public: - DelayItem(WindowsAsyncService* _service, const Func& _proc, bool _executeInMainThread, vint milliseconds); - ~DelayItem(); - - WindowsAsyncService* service; - Func proc; - ExecuteStatus status; - DateTime executeTime; - bool executeInMainThread; - - ExecuteStatus GetStatus()override; - bool Delay(vint milliseconds)override; - bool Cancel()override; - }; - protected: - vint mainThreadId; - SpinLock taskListLock; - collections::List taskItems; - collections::List> delayItems; - public: - WindowsAsyncService(); - ~WindowsAsyncService(); - - void ExecuteAsyncTasks(); - bool IsInMainThread()override; - void InvokeAsync(const Func& proc)override; - void InvokeInMainThread(const Func& proc)override; - bool InvokeInMainThreadAndWait(const Func& proc, vint milliseconds)override; - Ptr DelayExecute(const Func& proc, vint milliseconds)override; - Ptr DelayExecuteInMainThread(const Func& proc, vint milliseconds)override; - }; - } - } -} - -#endif - -/*********************************************************************** -NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSSCREENSERVICE.H +.\NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSSCREENSERVICE.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -892,7 +1011,7 @@ namespace vl #endif /*********************************************************************** -NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSCALLBACKSERVICE.H +.\NATIVEWINDOW\WINDOWS\WINNATIVEWINDOW.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -902,8 +1021,8 @@ GacUI::Native Window::Windows Implementation Interfaces: ***********************************************************************/ -#ifndef VCZH_PRESENTATION_WINDOWS_SERVICESIMPL_WINDOWSCALLBACKSERVICE -#define VCZH_PRESENTATION_WINDOWS_SERVICESIMPL_WINDOWSCALLBACKSERVICE +#ifndef VCZH_PRESENTATION_WINDOWS_WINNATIVEWINDOW +#define VCZH_PRESENTATION_WINDOWS_WINNATIVEWINDOW namespace vl @@ -912,23 +1031,33 @@ namespace vl { namespace windows { - class WindowsCallbackService : public Object, public INativeCallbackService + +/*********************************************************************** +Windows Platform Native Controller +***********************************************************************/ + + class INativeMessageHandler : public Interface { - protected: - collections::List listeners; - public: - WindowsCallbackService(); - - bool InstallListener(INativeControllerListener* listener)override; - bool UninstallListener(INativeControllerListener* listener)override; - - void InvokeMouseHook(WPARAM message, Point location); - void InvokeGlobalTimer(); - void InvokeClipboardUpdated(); - void InvokeNativeWindowCreated(INativeWindow* window); - void InvokeNativeWindowDestroyed(INativeWindow* window); + virtual void BeforeHandle(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool& skip) = 0; + virtual void AfterHandle(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool& skip, LRESULT& result) = 0; }; + + class IWindowsForm : public Interface + { + public: + virtual HWND GetWindowHandle() = 0; + virtual Interface* GetGraphicsHandler() = 0; + virtual void SetGraphicsHandler(Interface* handler) = 0; + virtual bool InstallMessageHandler(Ptr handler) = 0; + virtual bool UninstallMessageHandler(Ptr handler) = 0; + }; + + extern INativeController* CreateWindowsNativeController(HINSTANCE hInstance); + extern IWindowsForm* GetWindowsFormFromHandle(HWND hwnd); + extern IWindowsForm* GetWindowsForm(INativeWindow* window); + extern void DestroyWindowsNativeController(INativeController* controller); + extern void EnableCrossKernelCrashing(); } } } @@ -936,19 +1065,21 @@ namespace vl #endif /*********************************************************************** -NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSINPUTSERVICE.H +.\NATIVEWINDOW\WINDOWS\DIRECT2D\WINDIRECT2DAPPLICATION.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 Developer: Zihan Chen(vczh) -GacUI::Native Window::Windows Implementation +GacUI::Native Window::Direct2D Provider for Windows Implementation Interfaces: ***********************************************************************/ +#ifndef VCZH_PRESENTATION_WINDOWS_GDI_WINDIRECT2DAPPLICATION +#define VCZH_PRESENTATION_WINDOWS_GDI_WINDIRECT2DAPPLICATION -#ifndef VCZH_PRESENTATION_WINDOWS_SERVICESIMPL_WINDOWSINPUTSERVICE -#define VCZH_PRESENTATION_WINDOWS_SERVICESIMPL_WINDOWSINPUTSERVICE - +#include +#include +#include namespace vl { @@ -956,86 +1087,19 @@ namespace vl { namespace windows { - class WindowsInputService : public Object, public INativeInputService - { - protected: - HWND ownerHandle; - HHOOK mouseHook; - bool isTimerEnabled; - HOOKPROC mouseProc; - - collections::Array keyNames; - collections::Dictionary keys; - - WString GetKeyNameInternal(vint code); - void InitializeKeyNames(); - public: - WindowsInputService(HOOKPROC _mouseProc); - - void SetOwnerHandle(HWND handle); - void StartHookMouse()override; - void StopHookMouse()override; - bool IsHookingMouse()override; - void StartTimer()override; - void StopTimer()override; - bool IsTimerEnabled()override; - bool IsKeyPressing(vint code)override; - bool IsKeyToggled(vint code)override; - WString GetKeyName(vint code)override; - vint GetKey(const WString& name)override; - }; - - extern bool WinIsKeyPressing(vint code); - extern bool WinIsKeyToggled(vint code); + extern ID2D1Factory* GetDirect2DFactory(); + extern IDWriteFactory* GetDirectWriteFactory(); + extern ID3D11Device* GetD3D11Device(); } } } -#endif - -/*********************************************************************** -NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSDIALOGSERVICE.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Native Window::Windows Implementation - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_WINDOWS_SERVICESIMPL_WINDOWSDIALOGSERVICE -#define VCZH_PRESENTATION_WINDOWS_SERVICESIMPL_WINDOWSDIALOGSERVICE - - -namespace vl -{ - namespace presentation - { - namespace windows - { - class WindowsDialogService : public INativeDialogService - { - typedef HWND (*HandleRetriver)(INativeWindow*); - protected: - HandleRetriver handleRetriver; - - public: - WindowsDialogService(HandleRetriver _handleRetriver); - - MessageBoxButtonsOutput ShowMessageBox(INativeWindow* window, const WString& text, const WString& title, MessageBoxButtonsInput buttons, MessageBoxDefaultButton defaultButton, MessageBoxIcons icon, MessageBoxModalOptions modal)override; - bool ShowColorDialog(INativeWindow* window, Color& selection, bool selected, ColorDialogCustomColorOptions customColorOptions, Color* customColors)override; - bool ShowFontDialog(INativeWindow* window, FontProperties& selectionFont, Color& selectionColor, bool selected, bool showEffect, bool forceFontExist)override; - bool ShowFileDialog(INativeWindow* window, collections::List& selectionFileNames, vint& selectionFilterIndex, FileDialogTypes dialogType, const WString& title, const WString& initialFileName, const WString& initialDirectory, const WString& defaultExtension, const WString& filter, FileDialogOptions options)override; - }; - } - } -} +extern int WinMainDirect2D(HINSTANCE hInstance, void(*RendererMain)()); #endif /*********************************************************************** -NATIVEWINDOW\WINDOWS\GDI\WINGDIAPPLICATION.H +.\NATIVEWINDOW\WINDOWS\GDI\WINGDIAPPLICATION.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -1065,7 +1129,399 @@ extern int WinMainGDI(HINSTANCE hInstance, void(*RendererMain)()); #endif /*********************************************************************** -GRAPHICSELEMENT\WINDOWSGDI\GUIGRAPHICSWINDOWSGDI.H +.\GRAPHICSELEMENT\WINDOWSDIRECT2D\GUIGRAPHICSWINDOWSDIRECT2D.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Native Window::Direct2D Provider for Windows Implementation::Renderer + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSWINDOWSDIRECT2D +#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSWINDOWSDIRECT2D + + +namespace vl +{ + namespace presentation + { + namespace elements + { + +/*********************************************************************** +Raw API Rendering Element +***********************************************************************/ + + class GuiDirect2DElement; + + /// Direct2D Rendering event arguments. + struct GuiDirect2DElementEventArgs : compositions::GuiEventArgs + { + public: + /// The element that raised this event. + GuiDirect2DElement* element; + /// Direct2D render target object. + ID2D1RenderTarget* rt; + /// DirectWrite factory object. + IDWriteFactory* factoryDWrite; + /// Direct2D factory object. + ID2D1Factory* factoryD2D; + /// The range for rendering. + Rect bounds; + + GuiDirect2DElementEventArgs(GuiDirect2DElement* _element, ID2D1RenderTarget* _rt, IDWriteFactory* _fdw, ID2D1Factory* _fd2d, Rect _bounds) + :element(_element) + ,rt(_rt) + ,factoryDWrite(_fdw) + ,factoryD2D(_fd2d) + ,bounds(_bounds) + { + } + }; + + /// + /// Defines an element for customized rendering using Direct2D. + /// + class GuiDirect2DElement : public GuiElementBase + { + DEFINE_GUI_GRAPHICS_ELEMENT(GuiDirect2DElement, L"Direct2DElement") + protected: + GuiDirect2DElement(); + public: + /// Render target changed (before) event. Resources that binded to the render target can be released at this moment. + compositions::GuiGraphicsEvent BeforeRenderTargetChanged; + /// Render target changed (after) event. Resources that binded to the render target can be recreated at this moment. + compositions::GuiGraphicsEvent AfterRenderTargetChanged; + /// Rendering event. + compositions::GuiGraphicsEvent Rendering; + }; + } + + namespace elements_windows_d2d + { + +/*********************************************************************** +Functionality +***********************************************************************/ + + class IWindowsDirect2DRenderTarget : public elements::IGuiGraphicsRenderTarget + { + public: + virtual ID2D1RenderTarget* GetDirect2DRenderTarget()=0; + virtual ComPtr GetBitmap(INativeImageFrame* frame, bool enabled)=0; + virtual void DestroyBitmapCache(INativeImageFrame* frame)=0; + virtual void SetTextAntialias(bool antialias, bool verticalAntialias)=0; + + virtual ID2D1SolidColorBrush* CreateDirect2DBrush(Color color)=0; + virtual void DestroyDirect2DBrush(Color color)=0; + virtual ID2D1LinearGradientBrush* CreateDirect2DLinearBrush(Color c1, Color c2)=0; + virtual void DestroyDirect2DLinearBrush(Color c1, Color c2)=0; + }; + + class Direct2DTextFormatPackage + { + public: + ComPtr textFormat; + DWRITE_TRIMMING trimming; + ComPtr ellipseInlineObject; + }; + + class IWindowsDirect2DResourceManager : public Interface + { + public: + virtual Direct2DTextFormatPackage* CreateDirect2DTextFormat(const FontProperties& fontProperties)=0; + virtual void DestroyDirect2DTextFormat(const FontProperties& fontProperties)=0; + virtual Ptr CreateDirect2DCharMeasurer(const FontProperties& fontProperties)=0; + virtual void DestroyDirect2DCharMeasurer(const FontProperties& fontProperties)=0; + }; + + extern IWindowsDirect2DResourceManager* GetWindowsDirect2DResourceManager(); + extern D2D1::ColorF GetD2DColor(Color color); + +/*********************************************************************** +OS Supporting +***********************************************************************/ + + class IWindowsDirect2DObjectProvider : public Interface + { + public: + virtual void RecreateRenderTarget(INativeWindow* window) = 0; + virtual void ResizeRenderTarget(INativeWindow* window) = 0; + virtual ID2D1RenderTarget* GetNativeWindowDirect2DRenderTarget(INativeWindow* window) = 0; + virtual void StartRendering(INativeWindow* window) = 0; + virtual elements::RenderTargetFailure StopRenderingAndPresent(INativeWindow* window) = 0; + + virtual ID2D1Factory* GetDirect2DFactory() = 0; + virtual IDWriteFactory* GetDirectWriteFactory() = 0; + virtual IWindowsDirect2DRenderTarget* GetBindedRenderTarget(INativeWindow* window) = 0; + virtual void SetBindedRenderTarget(INativeWindow* window, IWindowsDirect2DRenderTarget* renderTarget) = 0; + virtual IWICImagingFactory* GetWICImagingFactory() = 0; + virtual IWICBitmap* GetWICBitmap(INativeImageFrame* frame) = 0; + }; + + extern IWindowsDirect2DObjectProvider* GetWindowsDirect2DObjectProvider(); + extern void SetWindowsDirect2DObjectProvider(IWindowsDirect2DObjectProvider* provider); + } + } +} + +extern void RendererMainDirect2D(); + +#endif + +/*********************************************************************** +.\GRAPHICSELEMENT\WINDOWSDIRECT2D\GUIGRAPHICSRENDERERSWINDOWSDIRECT2D.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Native Window::Direct2D Provider for Windows Implementation::Renderer + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSRENDERERSWINDOWSDIRECT2D +#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSRENDERERSWINDOWSDIRECT2D + + +namespace vl +{ + namespace presentation + { + namespace elements_windows_d2d + { + using namespace elements; + +#define DEFINE_BRUSH_ELEMENT_RENDERER(TELEMENT, TRENDERER, TBRUSH, TBRUSHPROPERTY)\ + DEFINE_GUI_GRAPHICS_RENDERER(TELEMENT, TRENDERER, IWindowsDirect2DRenderTarget)\ + protected:\ + TBRUSHPROPERTY oldColor;\ + TBRUSH* brush;\ + void CreateBrush(IWindowsDirect2DRenderTarget* _renderTarget);\ + void DestroyBrush(IWindowsDirect2DRenderTarget* _renderTarget);\ + void InitializeInternal();\ + void FinalizeInternal();\ + void RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget);\ + public:\ + TRENDERER();\ + void Render(Rect bounds)override;\ + void OnElementStateChanged()override;\ + +/*********************************************************************** +Renderers +***********************************************************************/ + + + class GuiSolidBorderElementRenderer : public Object, public IGuiGraphicsRenderer + { + DEFINE_BRUSH_ELEMENT_RENDERER(GuiSolidBorderElement, GuiSolidBorderElementRenderer, ID2D1SolidColorBrush, Color) + }; + + class GuiRoundBorderElementRenderer : public Object, public IGuiGraphicsRenderer + { + DEFINE_BRUSH_ELEMENT_RENDERER(GuiRoundBorderElement, GuiRoundBorderElementRenderer, ID2D1SolidColorBrush, Color) + }; + + class Gui3DBorderElementRenderer : public Object, public IGuiGraphicsRenderer + { + DEFINE_GUI_GRAPHICS_RENDERER(Gui3DBorderElement, Gui3DBorderElementRenderer, IWindowsDirect2DRenderTarget) + protected: + Color oldColor1; + Color oldColor2; + ID2D1SolidColorBrush* brush1; + ID2D1SolidColorBrush* brush2; + + void CreateBrush(IWindowsDirect2DRenderTarget* _renderTarget); + void DestroyBrush(IWindowsDirect2DRenderTarget* _renderTarget); + void InitializeInternal(); + void FinalizeInternal(); + void RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget); + public: + Gui3DBorderElementRenderer(); + + void Render(Rect bounds)override; + void OnElementStateChanged()override; + }; + + class Gui3DSplitterElementRenderer : public Object, public IGuiGraphicsRenderer + { + DEFINE_GUI_GRAPHICS_RENDERER(Gui3DSplitterElement, Gui3DSplitterElementRenderer, IWindowsDirect2DRenderTarget) + protected: + Color oldColor1; + Color oldColor2; + ID2D1SolidColorBrush* brush1; + ID2D1SolidColorBrush* brush2; + + void CreateBrush(IWindowsDirect2DRenderTarget* _renderTarget); + void DestroyBrush(IWindowsDirect2DRenderTarget* _renderTarget); + void InitializeInternal(); + void FinalizeInternal(); + void RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget); + public: + Gui3DSplitterElementRenderer(); + + void Render(Rect bounds)override; + void OnElementStateChanged()override; + }; + + class GuiSolidBackgroundElementRenderer : public Object, public IGuiGraphicsRenderer + { + DEFINE_BRUSH_ELEMENT_RENDERER(GuiSolidBackgroundElement, GuiSolidBackgroundElementRenderer, ID2D1SolidColorBrush, Color) + }; + + class GuiGradientBackgroundElementRenderer : public Object, public IGuiGraphicsRenderer + { + typedef collections::Pair ColorPair; + DEFINE_BRUSH_ELEMENT_RENDERER(GuiGradientBackgroundElement, GuiGradientBackgroundElementRenderer, ID2D1LinearGradientBrush, ColorPair) + }; + + class GuiSolidLabelElementRenderer : public Object, public IGuiGraphicsRenderer + { + DEFINE_GUI_GRAPHICS_RENDERER(GuiSolidLabelElement, GuiSolidLabelElementRenderer, IWindowsDirect2DRenderTarget) + protected: + Color oldColor; + FontProperties oldFont; + WString oldText; + ID2D1SolidColorBrush* brush; + Direct2DTextFormatPackage* textFormat; + IDWriteTextLayout* textLayout; + vint oldMaxWidth; + + void CreateBrush(IWindowsDirect2DRenderTarget* _renderTarget); + void DestroyBrush(IWindowsDirect2DRenderTarget* _renderTarget); + void CreateTextFormat(IWindowsDirect2DRenderTarget* _renderTarget); + void DestroyTextFormat(IWindowsDirect2DRenderTarget* _renderTarget); + void CreateTextLayout(); + void DestroyTextLayout(); + void UpdateMinSize(); + + void InitializeInternal(); + void FinalizeInternal(); + void RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget); + public: + GuiSolidLabelElementRenderer(); + + void Render(Rect bounds)override; + void OnElementStateChanged()override; + }; + + class GuiImageFrameElementRenderer : public Object, public IGuiGraphicsRenderer + { + DEFINE_GUI_GRAPHICS_RENDERER(GuiImageFrameElement, GuiImageFrameElementRenderer, IWindowsDirect2DRenderTarget) + protected: + ComPtr bitmap; + + void UpdateBitmap(IWindowsDirect2DRenderTarget* renderTarget); + + void InitializeInternal(); + void FinalizeInternal(); + void RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget); + public: + GuiImageFrameElementRenderer(); + + void Render(Rect bounds)override; + void OnElementStateChanged()override; + }; + + class GuiPolygonElementRenderer : public Object, public IGuiGraphicsRenderer + { + DEFINE_GUI_GRAPHICS_RENDERER(GuiPolygonElement, GuiPolygonElementRenderer, IWindowsDirect2DRenderTarget) + protected: + Color oldBorderColor; + Color oldBackgroundColor; + ID2D1SolidColorBrush* borderBrush; + ID2D1SolidColorBrush* backgroundBrush; + collections::Array oldPoints; + ComPtr geometry; + + void CreateGeometry(); + void DestroyGeometry(); + void FillGeometry(Point offset); + void RecreateResource(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget); + void InitializeInternal(); + void FinalizeInternal(); + void RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget); + public: + GuiPolygonElementRenderer(); + + void Render(Rect bounds)override; + void OnElementStateChanged()override; + }; + + class GuiColorizedTextElementRenderer : public Object, public IGuiGraphicsRenderer, protected GuiColorizedTextElement::ICallback + { + DEFINE_GUI_GRAPHICS_RENDERER(GuiColorizedTextElement, GuiColorizedTextElementRenderer, IWindowsDirect2DRenderTarget) + + public: + struct ColorItemResource + { + Color text; + ID2D1SolidColorBrush* textBrush; + Color background; + ID2D1SolidColorBrush* backgroundBrush; + }; + + struct ColorEntryResource + { + ColorItemResource normal; + ColorItemResource selectedFocused; + ColorItemResource selectedUnfocused; + + bool operator==(const ColorEntryResource& value){return false;} + bool operator!=(const ColorEntryResource& value){return true;} + }; + + typedef collections::Array ColorArray; + protected: + FontProperties oldFont; + Direct2DTextFormatPackage* textFormat; + ColorArray colors; + Color oldCaretColor; + ID2D1SolidColorBrush* caretBrush; + + void CreateTextBrush(IWindowsDirect2DRenderTarget* _renderTarget); + void DestroyTextBrush(IWindowsDirect2DRenderTarget* _renderTarget); + void CreateCaretBrush(IWindowsDirect2DRenderTarget* _renderTarget); + void DestroyCaretBrush(IWindowsDirect2DRenderTarget* _renderTarget); + + void ColorChanged(); + void FontChanged(); + text::CharMeasurer* GetCharMeasurer(); + + void InitializeInternal(); + void FinalizeInternal(); + void RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget); + public: + void Render(Rect bounds)override; + void OnElementStateChanged()override; + }; + + class GuiDirect2DElementRenderer : public Object, public IGuiGraphicsRenderer + { + DEFINE_GUI_GRAPHICS_RENDERER(GuiDirect2DElement, GuiDirect2DElementRenderer, IWindowsDirect2DRenderTarget) + + protected: + + void InitializeInternal(); + void FinalizeInternal(); + void RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget); + public: + GuiDirect2DElementRenderer(); + ~GuiDirect2DElementRenderer(); + + void Render(Rect bounds)override; + void OnElementStateChanged()override; + }; + } + } +} + +#endif + +/*********************************************************************** +.\GRAPHICSELEMENT\WINDOWSGDI\GUIGRAPHICSWINDOWSGDI.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -1183,7 +1639,7 @@ extern void RendererMainGDI(); #endif /*********************************************************************** -GRAPHICSELEMENT\WINDOWSGDI\GUIGRAPHICSLAYOUTPROVIDERWINDOWSGDI.H +.\GRAPHICSELEMENT\WINDOWSGDI\GUIGRAPHICSRENDERERSWINDOWSGDI.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -1193,8 +1649,8 @@ GacUI::Native Window::GDI Provider for Windows Implementation::Renderer Interfaces: ***********************************************************************/ -#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSLAYOUTPROVIDERWINDOWSGDI -#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSLAYOUTPROVIDERWINDOWSGDI +#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSRENDERERSWINDOWSGDI +#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSRENDERERSWINDOWSGDI namespace vl @@ -1203,10 +1659,223 @@ namespace vl { namespace elements_windows_gdi { - class WindowsGDILayoutProvider : public Object, public elements::IGuiGraphicsLayoutProvider + using namespace elements; + +/*********************************************************************** +Renderers +***********************************************************************/ + + class GuiSolidBorderElementRenderer : public Object, public IGuiGraphicsRenderer { + DEFINE_GUI_GRAPHICS_RENDERER(GuiSolidBorderElement, GuiSolidBorderElementRenderer, IWindowsGDIRenderTarget) + protected: + Color oldColor; + Ptr pen; + Ptr brush; + + void InitializeInternal(); + void FinalizeInternal(); + void RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget); public: - Ptr CreateParagraph(const WString& text, elements::IGuiGraphicsRenderTarget* renderTarget, elements::IGuiGraphicsParagraphCallback* callback)override; + void Render(Rect bounds)override; + void OnElementStateChanged()override; + }; + + class GuiRoundBorderElementRenderer : public Object, public IGuiGraphicsRenderer + { + DEFINE_GUI_GRAPHICS_RENDERER(GuiRoundBorderElement, GuiRoundBorderElementRenderer, IWindowsGDIRenderTarget) + protected: + Color oldColor; + Ptr pen; + Ptr brush; + + void InitializeInternal(); + void FinalizeInternal(); + void RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget); + public: + void Render(Rect bounds)override; + void OnElementStateChanged()override; + }; + + class Gui3DBorderElementRenderer : public Object, public IGuiGraphicsRenderer + { + DEFINE_GUI_GRAPHICS_RENDERER(Gui3DBorderElement, Gui3DBorderElementRenderer, IWindowsGDIRenderTarget) + protected: + Color oldColor1; + Color oldColor2; + Ptr pen1; + Ptr pen2; + + void InitializeInternal(); + void FinalizeInternal(); + void RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget); + public: + void Render(Rect bounds)override; + void OnElementStateChanged()override; + }; + + class Gui3DSplitterElementRenderer : public Object, public IGuiGraphicsRenderer + { + DEFINE_GUI_GRAPHICS_RENDERER(Gui3DSplitterElement, Gui3DSplitterElementRenderer, IWindowsGDIRenderTarget) + protected: + Color oldColor1; + Color oldColor2; + Ptr pen1; + Ptr pen2; + + void InitializeInternal(); + void FinalizeInternal(); + void RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget); + public: + void Render(Rect bounds)override; + void OnElementStateChanged()override; + }; + + class GuiSolidBackgroundElementRenderer : public Object, public IGuiGraphicsRenderer + { + DEFINE_GUI_GRAPHICS_RENDERER(GuiSolidBackgroundElement, GuiSolidBackgroundElementRenderer, IWindowsGDIRenderTarget) + protected: + Color oldColor; + Ptr pen; + Ptr brush; + + void InitializeInternal(); + void FinalizeInternal(); + void RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget); + public: + void Render(Rect bounds)override; + void OnElementStateChanged()override; + }; + + class GuiGradientBackgroundElementRenderer : public Object, public IGuiGraphicsRenderer + { + DEFINE_GUI_GRAPHICS_RENDERER(GuiGradientBackgroundElement, GuiGradientBackgroundElementRenderer, IWindowsGDIRenderTarget) + protected: + void InitializeInternal(); + void FinalizeInternal(); + void RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget); + public: + void Render(Rect bounds)override; + void OnElementStateChanged()override; + }; + + class GuiSolidLabelElementRenderer : public Object, public IGuiGraphicsRenderer + { + DEFINE_GUI_GRAPHICS_RENDERER(GuiSolidLabelElement, GuiSolidLabelElementRenderer, IWindowsGDIRenderTarget) + protected: + FontProperties oldFont; + Ptr font; + vint oldMaxWidth; + + void UpdateMinSize(); + + void InitializeInternal(); + void FinalizeInternal(); + void RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget); + public: + GuiSolidLabelElementRenderer(); + + void Render(Rect bounds)override; + void OnElementStateChanged()override; + }; + + class GuiImageFrameElementRenderer : public Object, public IGuiGraphicsRenderer + { + DEFINE_GUI_GRAPHICS_RENDERER(GuiImageFrameElement, GuiImageFrameElementRenderer, IWindowsGDIRenderTarget) + protected: + Ptr bitmap; + + void UpdateBitmap(); + + void InitializeInternal(); + void FinalizeInternal(); + void RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget); + public: + GuiImageFrameElementRenderer(); + + void Render(Rect bounds)override; + void OnElementStateChanged()override; + }; + + class GuiPolygonElementRenderer : public Object, public IGuiGraphicsRenderer + { + DEFINE_GUI_GRAPHICS_RENDERER(GuiPolygonElement, GuiPolygonElementRenderer, IWindowsGDIRenderTarget) + protected: + POINT* points; + vint pointCount; + Color oldPenColor; + Color oldBrushColor; + Ptr pen; + Ptr brush; + + void InitializeInternal(); + void FinalizeInternal(); + void RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget); + public: + GuiPolygonElementRenderer(); + ~GuiPolygonElementRenderer(); + + void Render(Rect bounds)override; + void OnElementStateChanged()override; + }; + + class GuiColorizedTextElementRenderer : public Object, public IGuiGraphicsRenderer, protected GuiColorizedTextElement::ICallback + { + DEFINE_GUI_GRAPHICS_RENDERER(GuiColorizedTextElement, GuiColorizedTextElementRenderer, IWindowsGDIRenderTarget) + + public: + struct ColorItemResource + { + Color text; + Color background; + Ptr backgroundBrush; + }; + + struct ColorEntryResource + { + ColorItemResource normal; + ColorItemResource selectedFocused; + ColorItemResource selectedUnfocused; + + bool operator==(const ColorEntryResource& value){return false;} + bool operator!=(const ColorEntryResource& value){return true;} + }; + + typedef collections::Array ColorArray; + protected: + FontProperties oldFont; + Ptr font; + ColorArray colors; + Color oldCaretColor; + Ptr caretPen; + + void DestroyColors(); + void ColorChanged(); + void FontChanged(); + + void InitializeInternal(); + void FinalizeInternal(); + void RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget); + public: + void Render(Rect bounds)override; + void OnElementStateChanged()override; + }; + + class GuiGDIElementRenderer : public Object, public IGuiGraphicsRenderer + { + DEFINE_GUI_GRAPHICS_RENDERER(GuiGDIElement, GuiGDIElementRenderer, IWindowsGDIRenderTarget) + + protected: + + void InitializeInternal(); + void FinalizeInternal(); + void RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget); + public: + GuiGDIElementRenderer(); + ~GuiGDIElementRenderer(); + + void Render(Rect bounds)override; + void OnElementStateChanged()override; }; } } @@ -1215,7 +1884,7 @@ namespace vl #endif /*********************************************************************** -GRAPHICSELEMENT\WINDOWSGDI\GUIGRAPHICSUNISCRIBE.H +.\GRAPHICSELEMENT\WINDOWSGDI\GUIGRAPHICSUNISCRIBE.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -1567,672 +2236,3 @@ UniscribeParagraph } #endif - -/*********************************************************************** -GRAPHICSELEMENT\WINDOWSGDI\GUIGRAPHICSRENDERERSWINDOWSGDI.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Native Window::GDI Provider for Windows Implementation::Renderer - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSRENDERERSWINDOWSGDI -#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSRENDERERSWINDOWSGDI - - -namespace vl -{ - namespace presentation - { - namespace elements_windows_gdi - { - using namespace elements; - -/*********************************************************************** -Renderers -***********************************************************************/ - - class GuiSolidBorderElementRenderer : public Object, public IGuiGraphicsRenderer - { - DEFINE_GUI_GRAPHICS_RENDERER(GuiSolidBorderElement, GuiSolidBorderElementRenderer, IWindowsGDIRenderTarget) - protected: - Color oldColor; - Ptr pen; - Ptr brush; - - void InitializeInternal(); - void FinalizeInternal(); - void RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget); - public: - void Render(Rect bounds)override; - void OnElementStateChanged()override; - }; - - class GuiRoundBorderElementRenderer : public Object, public IGuiGraphicsRenderer - { - DEFINE_GUI_GRAPHICS_RENDERER(GuiRoundBorderElement, GuiRoundBorderElementRenderer, IWindowsGDIRenderTarget) - protected: - Color oldColor; - Ptr pen; - Ptr brush; - - void InitializeInternal(); - void FinalizeInternal(); - void RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget); - public: - void Render(Rect bounds)override; - void OnElementStateChanged()override; - }; - - class Gui3DBorderElementRenderer : public Object, public IGuiGraphicsRenderer - { - DEFINE_GUI_GRAPHICS_RENDERER(Gui3DBorderElement, Gui3DBorderElementRenderer, IWindowsGDIRenderTarget) - protected: - Color oldColor1; - Color oldColor2; - Ptr pen1; - Ptr pen2; - - void InitializeInternal(); - void FinalizeInternal(); - void RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget); - public: - void Render(Rect bounds)override; - void OnElementStateChanged()override; - }; - - class Gui3DSplitterElementRenderer : public Object, public IGuiGraphicsRenderer - { - DEFINE_GUI_GRAPHICS_RENDERER(Gui3DSplitterElement, Gui3DSplitterElementRenderer, IWindowsGDIRenderTarget) - protected: - Color oldColor1; - Color oldColor2; - Ptr pen1; - Ptr pen2; - - void InitializeInternal(); - void FinalizeInternal(); - void RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget); - public: - void Render(Rect bounds)override; - void OnElementStateChanged()override; - }; - - class GuiSolidBackgroundElementRenderer : public Object, public IGuiGraphicsRenderer - { - DEFINE_GUI_GRAPHICS_RENDERER(GuiSolidBackgroundElement, GuiSolidBackgroundElementRenderer, IWindowsGDIRenderTarget) - protected: - Color oldColor; - Ptr pen; - Ptr brush; - - void InitializeInternal(); - void FinalizeInternal(); - void RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget); - public: - void Render(Rect bounds)override; - void OnElementStateChanged()override; - }; - - class GuiGradientBackgroundElementRenderer : public Object, public IGuiGraphicsRenderer - { - DEFINE_GUI_GRAPHICS_RENDERER(GuiGradientBackgroundElement, GuiGradientBackgroundElementRenderer, IWindowsGDIRenderTarget) - protected: - void InitializeInternal(); - void FinalizeInternal(); - void RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget); - public: - void Render(Rect bounds)override; - void OnElementStateChanged()override; - }; - - class GuiSolidLabelElementRenderer : public Object, public IGuiGraphicsRenderer - { - DEFINE_GUI_GRAPHICS_RENDERER(GuiSolidLabelElement, GuiSolidLabelElementRenderer, IWindowsGDIRenderTarget) - protected: - FontProperties oldFont; - Ptr font; - vint oldMaxWidth; - - void UpdateMinSize(); - - void InitializeInternal(); - void FinalizeInternal(); - void RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget); - public: - GuiSolidLabelElementRenderer(); - - void Render(Rect bounds)override; - void OnElementStateChanged()override; - }; - - class GuiImageFrameElementRenderer : public Object, public IGuiGraphicsRenderer - { - DEFINE_GUI_GRAPHICS_RENDERER(GuiImageFrameElement, GuiImageFrameElementRenderer, IWindowsGDIRenderTarget) - protected: - Ptr bitmap; - - void UpdateBitmap(); - - void InitializeInternal(); - void FinalizeInternal(); - void RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget); - public: - GuiImageFrameElementRenderer(); - - void Render(Rect bounds)override; - void OnElementStateChanged()override; - }; - - class GuiPolygonElementRenderer : public Object, public IGuiGraphicsRenderer - { - DEFINE_GUI_GRAPHICS_RENDERER(GuiPolygonElement, GuiPolygonElementRenderer, IWindowsGDIRenderTarget) - protected: - POINT* points; - vint pointCount; - Color oldPenColor; - Color oldBrushColor; - Ptr pen; - Ptr brush; - - void InitializeInternal(); - void FinalizeInternal(); - void RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget); - public: - GuiPolygonElementRenderer(); - ~GuiPolygonElementRenderer(); - - void Render(Rect bounds)override; - void OnElementStateChanged()override; - }; - - class GuiColorizedTextElementRenderer : public Object, public IGuiGraphicsRenderer, protected GuiColorizedTextElement::ICallback - { - DEFINE_GUI_GRAPHICS_RENDERER(GuiColorizedTextElement, GuiColorizedTextElementRenderer, IWindowsGDIRenderTarget) - - public: - struct ColorItemResource - { - Color text; - Color background; - Ptr backgroundBrush; - }; - - struct ColorEntryResource - { - ColorItemResource normal; - ColorItemResource selectedFocused; - ColorItemResource selectedUnfocused; - - bool operator==(const ColorEntryResource& value){return false;} - bool operator!=(const ColorEntryResource& value){return true;} - }; - - typedef collections::Array ColorArray; - protected: - FontProperties oldFont; - Ptr font; - ColorArray colors; - Color oldCaretColor; - Ptr caretPen; - - void DestroyColors(); - void ColorChanged(); - void FontChanged(); - - void InitializeInternal(); - void FinalizeInternal(); - void RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget); - public: - void Render(Rect bounds)override; - void OnElementStateChanged()override; - }; - - class GuiGDIElementRenderer : public Object, public IGuiGraphicsRenderer - { - DEFINE_GUI_GRAPHICS_RENDERER(GuiGDIElement, GuiGDIElementRenderer, IWindowsGDIRenderTarget) - - protected: - - void InitializeInternal(); - void FinalizeInternal(); - void RenderTargetChangedInternal(IWindowsGDIRenderTarget* oldRenderTarget, IWindowsGDIRenderTarget* newRenderTarget); - public: - GuiGDIElementRenderer(); - ~GuiGDIElementRenderer(); - - void Render(Rect bounds)override; - void OnElementStateChanged()override; - }; - } - } -} - -#endif - -/*********************************************************************** -GRAPHICSELEMENT\WINDOWSDIRECT2D\GUIGRAPHICSWINDOWSDIRECT2D.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Native Window::Direct2D Provider for Windows Implementation::Renderer - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSWINDOWSDIRECT2D -#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSWINDOWSDIRECT2D - - -namespace vl -{ - namespace presentation - { - namespace elements - { - -/*********************************************************************** -Raw API Rendering Element -***********************************************************************/ - - class GuiDirect2DElement; - - /// Direct2D Rendering event arguments. - struct GuiDirect2DElementEventArgs : compositions::GuiEventArgs - { - public: - /// The element that raised this event. - GuiDirect2DElement* element; - /// Direct2D render target object. - ID2D1RenderTarget* rt; - /// DirectWrite factory object. - IDWriteFactory* factoryDWrite; - /// Direct2D factory object. - ID2D1Factory* factoryD2D; - /// The range for rendering. - Rect bounds; - - GuiDirect2DElementEventArgs(GuiDirect2DElement* _element, ID2D1RenderTarget* _rt, IDWriteFactory* _fdw, ID2D1Factory* _fd2d, Rect _bounds) - :element(_element) - ,rt(_rt) - ,factoryDWrite(_fdw) - ,factoryD2D(_fd2d) - ,bounds(_bounds) - { - } - }; - - /// - /// Defines an element for customized rendering using Direct2D. - /// - class GuiDirect2DElement : public GuiElementBase - { - DEFINE_GUI_GRAPHICS_ELEMENT(GuiDirect2DElement, L"Direct2DElement") - protected: - GuiDirect2DElement(); - public: - /// Render target changed (before) event. Resources that binded to the render target can be released at this moment. - compositions::GuiGraphicsEvent BeforeRenderTargetChanged; - /// Render target changed (after) event. Resources that binded to the render target can be recreated at this moment. - compositions::GuiGraphicsEvent AfterRenderTargetChanged; - /// Rendering event. - compositions::GuiGraphicsEvent Rendering; - }; - } - - namespace elements_windows_d2d - { - -/*********************************************************************** -Functionality -***********************************************************************/ - - class IWindowsDirect2DRenderTarget : public elements::IGuiGraphicsRenderTarget - { - public: - virtual ID2D1RenderTarget* GetDirect2DRenderTarget()=0; - virtual ComPtr GetBitmap(INativeImageFrame* frame, bool enabled)=0; - virtual void DestroyBitmapCache(INativeImageFrame* frame)=0; - virtual void SetTextAntialias(bool antialias, bool verticalAntialias)=0; - - virtual ID2D1SolidColorBrush* CreateDirect2DBrush(Color color)=0; - virtual void DestroyDirect2DBrush(Color color)=0; - virtual ID2D1LinearGradientBrush* CreateDirect2DLinearBrush(Color c1, Color c2)=0; - virtual void DestroyDirect2DLinearBrush(Color c1, Color c2)=0; - }; - - class Direct2DTextFormatPackage - { - public: - ComPtr textFormat; - DWRITE_TRIMMING trimming; - ComPtr ellipseInlineObject; - }; - - class IWindowsDirect2DResourceManager : public Interface - { - public: - virtual Direct2DTextFormatPackage* CreateDirect2DTextFormat(const FontProperties& fontProperties)=0; - virtual void DestroyDirect2DTextFormat(const FontProperties& fontProperties)=0; - virtual Ptr CreateDirect2DCharMeasurer(const FontProperties& fontProperties)=0; - virtual void DestroyDirect2DCharMeasurer(const FontProperties& fontProperties)=0; - }; - - extern IWindowsDirect2DResourceManager* GetWindowsDirect2DResourceManager(); - extern D2D1::ColorF GetD2DColor(Color color); - -/*********************************************************************** -OS Supporting -***********************************************************************/ - - class IWindowsDirect2DObjectProvider : public Interface - { - public: - virtual void RecreateRenderTarget(INativeWindow* window) = 0; - virtual void ResizeRenderTarget(INativeWindow* window) = 0; - virtual ID2D1RenderTarget* GetNativeWindowDirect2DRenderTarget(INativeWindow* window) = 0; - virtual void StartRendering(INativeWindow* window) = 0; - virtual elements::RenderTargetFailure StopRenderingAndPresent(INativeWindow* window) = 0; - - virtual ID2D1Factory* GetDirect2DFactory() = 0; - virtual IDWriteFactory* GetDirectWriteFactory() = 0; - virtual IWindowsDirect2DRenderTarget* GetBindedRenderTarget(INativeWindow* window) = 0; - virtual void SetBindedRenderTarget(INativeWindow* window, IWindowsDirect2DRenderTarget* renderTarget) = 0; - virtual IWICImagingFactory* GetWICImagingFactory() = 0; - virtual IWICBitmap* GetWICBitmap(INativeImageFrame* frame) = 0; - }; - - extern IWindowsDirect2DObjectProvider* GetWindowsDirect2DObjectProvider(); - extern void SetWindowsDirect2DObjectProvider(IWindowsDirect2DObjectProvider* provider); - } - } -} - -extern void RendererMainDirect2D(); - -#endif - -/*********************************************************************** -GRAPHICSELEMENT\WINDOWSDIRECT2D\GUIGRAPHICSLAYOUTPROVIDERWINDOWSDIRECT2D.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Native Window::Direct2D Provider for Windows Implementation::Renderer - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSLAYOUTPROVIDERWINDOWSDIRECT2D -#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSLAYOUTPROVIDERWINDOWSDIRECT2D - - -namespace vl -{ - namespace presentation - { - namespace elements_windows_d2d - { - class WindowsDirect2DLayoutProvider : public Object, public elements::IGuiGraphicsLayoutProvider - { - public: - Ptr CreateParagraph(const WString& text, elements::IGuiGraphicsRenderTarget* renderTarget, elements::IGuiGraphicsParagraphCallback* callback)override; - }; - } - } -} - -#endif - -/*********************************************************************** -GRAPHICSELEMENT\WINDOWSDIRECT2D\GUIGRAPHICSRENDERERSWINDOWSDIRECT2D.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -GacUI::Native Window::Direct2D Provider for Windows Implementation::Renderer - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSRENDERERSWINDOWSDIRECT2D -#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSRENDERERSWINDOWSDIRECT2D - - -namespace vl -{ - namespace presentation - { - namespace elements_windows_d2d - { - using namespace elements; - -#define DEFINE_BRUSH_ELEMENT_RENDERER(TELEMENT, TRENDERER, TBRUSH, TBRUSHPROPERTY)\ - DEFINE_GUI_GRAPHICS_RENDERER(TELEMENT, TRENDERER, IWindowsDirect2DRenderTarget)\ - protected:\ - TBRUSHPROPERTY oldColor;\ - TBRUSH* brush;\ - void CreateBrush(IWindowsDirect2DRenderTarget* _renderTarget);\ - void DestroyBrush(IWindowsDirect2DRenderTarget* _renderTarget);\ - void InitializeInternal();\ - void FinalizeInternal();\ - void RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget);\ - public:\ - TRENDERER();\ - void Render(Rect bounds)override;\ - void OnElementStateChanged()override;\ - -/*********************************************************************** -Renderers -***********************************************************************/ - - - class GuiSolidBorderElementRenderer : public Object, public IGuiGraphicsRenderer - { - DEFINE_BRUSH_ELEMENT_RENDERER(GuiSolidBorderElement, GuiSolidBorderElementRenderer, ID2D1SolidColorBrush, Color) - }; - - class GuiRoundBorderElementRenderer : public Object, public IGuiGraphicsRenderer - { - DEFINE_BRUSH_ELEMENT_RENDERER(GuiRoundBorderElement, GuiRoundBorderElementRenderer, ID2D1SolidColorBrush, Color) - }; - - class Gui3DBorderElementRenderer : public Object, public IGuiGraphicsRenderer - { - DEFINE_GUI_GRAPHICS_RENDERER(Gui3DBorderElement, Gui3DBorderElementRenderer, IWindowsDirect2DRenderTarget) - protected: - Color oldColor1; - Color oldColor2; - ID2D1SolidColorBrush* brush1; - ID2D1SolidColorBrush* brush2; - - void CreateBrush(IWindowsDirect2DRenderTarget* _renderTarget); - void DestroyBrush(IWindowsDirect2DRenderTarget* _renderTarget); - void InitializeInternal(); - void FinalizeInternal(); - void RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget); - public: - Gui3DBorderElementRenderer(); - - void Render(Rect bounds)override; - void OnElementStateChanged()override; - }; - - class Gui3DSplitterElementRenderer : public Object, public IGuiGraphicsRenderer - { - DEFINE_GUI_GRAPHICS_RENDERER(Gui3DSplitterElement, Gui3DSplitterElementRenderer, IWindowsDirect2DRenderTarget) - protected: - Color oldColor1; - Color oldColor2; - ID2D1SolidColorBrush* brush1; - ID2D1SolidColorBrush* brush2; - - void CreateBrush(IWindowsDirect2DRenderTarget* _renderTarget); - void DestroyBrush(IWindowsDirect2DRenderTarget* _renderTarget); - void InitializeInternal(); - void FinalizeInternal(); - void RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget); - public: - Gui3DSplitterElementRenderer(); - - void Render(Rect bounds)override; - void OnElementStateChanged()override; - }; - - class GuiSolidBackgroundElementRenderer : public Object, public IGuiGraphicsRenderer - { - DEFINE_BRUSH_ELEMENT_RENDERER(GuiSolidBackgroundElement, GuiSolidBackgroundElementRenderer, ID2D1SolidColorBrush, Color) - }; - - class GuiGradientBackgroundElementRenderer : public Object, public IGuiGraphicsRenderer - { - typedef collections::Pair ColorPair; - DEFINE_BRUSH_ELEMENT_RENDERER(GuiGradientBackgroundElement, GuiGradientBackgroundElementRenderer, ID2D1LinearGradientBrush, ColorPair) - }; - - class GuiSolidLabelElementRenderer : public Object, public IGuiGraphicsRenderer - { - DEFINE_GUI_GRAPHICS_RENDERER(GuiSolidLabelElement, GuiSolidLabelElementRenderer, IWindowsDirect2DRenderTarget) - protected: - Color oldColor; - FontProperties oldFont; - WString oldText; - ID2D1SolidColorBrush* brush; - Direct2DTextFormatPackage* textFormat; - IDWriteTextLayout* textLayout; - vint oldMaxWidth; - - void CreateBrush(IWindowsDirect2DRenderTarget* _renderTarget); - void DestroyBrush(IWindowsDirect2DRenderTarget* _renderTarget); - void CreateTextFormat(IWindowsDirect2DRenderTarget* _renderTarget); - void DestroyTextFormat(IWindowsDirect2DRenderTarget* _renderTarget); - void CreateTextLayout(); - void DestroyTextLayout(); - void UpdateMinSize(); - - void InitializeInternal(); - void FinalizeInternal(); - void RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget); - public: - GuiSolidLabelElementRenderer(); - - void Render(Rect bounds)override; - void OnElementStateChanged()override; - }; - - class GuiImageFrameElementRenderer : public Object, public IGuiGraphicsRenderer - { - DEFINE_GUI_GRAPHICS_RENDERER(GuiImageFrameElement, GuiImageFrameElementRenderer, IWindowsDirect2DRenderTarget) - protected: - ComPtr bitmap; - - void UpdateBitmap(IWindowsDirect2DRenderTarget* renderTarget); - - void InitializeInternal(); - void FinalizeInternal(); - void RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget); - public: - GuiImageFrameElementRenderer(); - - void Render(Rect bounds)override; - void OnElementStateChanged()override; - }; - - class GuiPolygonElementRenderer : public Object, public IGuiGraphicsRenderer - { - DEFINE_GUI_GRAPHICS_RENDERER(GuiPolygonElement, GuiPolygonElementRenderer, IWindowsDirect2DRenderTarget) - protected: - Color oldBorderColor; - Color oldBackgroundColor; - ID2D1SolidColorBrush* borderBrush; - ID2D1SolidColorBrush* backgroundBrush; - collections::Array oldPoints; - ComPtr geometry; - - void CreateGeometry(); - void DestroyGeometry(); - void FillGeometry(Point offset); - void RecreateResource(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget); - void InitializeInternal(); - void FinalizeInternal(); - void RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget); - public: - GuiPolygonElementRenderer(); - - void Render(Rect bounds)override; - void OnElementStateChanged()override; - }; - - class GuiColorizedTextElementRenderer : public Object, public IGuiGraphicsRenderer, protected GuiColorizedTextElement::ICallback - { - DEFINE_GUI_GRAPHICS_RENDERER(GuiColorizedTextElement, GuiColorizedTextElementRenderer, IWindowsDirect2DRenderTarget) - - public: - struct ColorItemResource - { - Color text; - ID2D1SolidColorBrush* textBrush; - Color background; - ID2D1SolidColorBrush* backgroundBrush; - }; - - struct ColorEntryResource - { - ColorItemResource normal; - ColorItemResource selectedFocused; - ColorItemResource selectedUnfocused; - - bool operator==(const ColorEntryResource& value){return false;} - bool operator!=(const ColorEntryResource& value){return true;} - }; - - typedef collections::Array ColorArray; - protected: - FontProperties oldFont; - Direct2DTextFormatPackage* textFormat; - ColorArray colors; - Color oldCaretColor; - ID2D1SolidColorBrush* caretBrush; - - void CreateTextBrush(IWindowsDirect2DRenderTarget* _renderTarget); - void DestroyTextBrush(IWindowsDirect2DRenderTarget* _renderTarget); - void CreateCaretBrush(IWindowsDirect2DRenderTarget* _renderTarget); - void DestroyCaretBrush(IWindowsDirect2DRenderTarget* _renderTarget); - - void ColorChanged(); - void FontChanged(); - text::CharMeasurer* GetCharMeasurer(); - - void InitializeInternal(); - void FinalizeInternal(); - void RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget); - public: - void Render(Rect bounds)override; - void OnElementStateChanged()override; - }; - - class GuiDirect2DElementRenderer : public Object, public IGuiGraphicsRenderer - { - DEFINE_GUI_GRAPHICS_RENDERER(GuiDirect2DElement, GuiDirect2DElementRenderer, IWindowsDirect2DRenderTarget) - - protected: - - void InitializeInternal(); - void FinalizeInternal(); - void RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget); - public: - GuiDirect2DElementRenderer(); - ~GuiDirect2DElementRenderer(); - - void Render(Rect bounds)override; - void OnElementStateChanged()override; - }; - } - } -} - -#endif diff --git a/Import/Import.bat b/Import/Import.bat index eb83e4ba..574d4353 100644 --- a/Import/Import.bat +++ b/Import/Import.bat @@ -1,6 +1,9 @@ +mkdir Skins +mkdir Skins\DarkSkin copy ..\..\Vlpp\Release\*.h . copy ..\..\Vlpp\Release\*.cpp . copy ..\..\Workflow\Release\*.h . copy ..\..\Workflow\Release\*.cpp . -copy ..\..\GacUI\Release\*.h . -copy ..\..\GacUI\Release\*.cpp . \ No newline at end of file +copy ..\..\GacUI\Release\Gac*.h . +copy ..\..\GacUI\Release\Gac*.cpp . +copy ..\..\GacUI\Release\DarkSkin* .\Skins\DarkSkin\ \ No newline at end of file diff --git a/Import/Skins/DarkSkin/DarkSkin.cpp b/Import/Skins/DarkSkin/DarkSkin.cpp new file mode 100644 index 00000000..24c4f4a4 --- /dev/null +++ b/Import/Skins/DarkSkin/DarkSkin.cpp @@ -0,0 +1,16664 @@ +/*********************************************************************** +THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY +DEVELOPER: Zihan Chen(vczh) +***********************************************************************/ +#include "DarkSkin.h" +#ifndef VCZH_DEBUG_NO_REFLECTION +#include "DarkSkinReflection.h" +#endif + +/*********************************************************************** +.\DARKSKINPARTIALCLASSES.CPP +***********************************************************************/ +/*********************************************************************** +!!!!!! DO NOT MODIFY !!!!!! + +GacGen.exe Resource.xml + +This file is generated by Workflow compiler +https://github.com/vczh-libraries +***********************************************************************/ + + +#if defined( _MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#elif defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wparentheses-equality" +#elif defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wparentheses-equality" +#endif + +#define GLOBAL_SYMBOL ::vl_workflow_global::DarkSkin:: +#define GLOBAL_NAME ::vl_workflow_global::DarkSkin::Instance(). +#define GLOBAL_OBJ &::vl_workflow_global::DarkSkin::Instance() +#define USERIMPL(...) + +/*********************************************************************** +Global Variables +***********************************************************************/ + +BEGIN_GLOBAL_STORAGE_CLASS(vl_workflow_global_DarkSkin) + vl_workflow_global::DarkSkin instance; + INITIALIZE_GLOBAL_STORAGE_CLASS + FINALIZE_GLOBAL_STORAGE_CLASS +END_GLOBAL_STORAGE_CLASS(vl_workflow_global_DarkSkin) + +namespace vl_workflow_global +{ +/*********************************************************************** +Global Functions +***********************************************************************/ + + DarkSkin& DarkSkin::Instance() + { + return Getvl_workflow_global_DarkSkin().instance; + } + +/*********************************************************************** +Closures +***********************************************************************/ + + //------------------------------------------------------------------- + + __vwsnf100_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf100_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::LeftScrollButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf100_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->GetBackgroundColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->SetBackgroundColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf101_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__::__vwsnf101_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiMenuTemplate* __vwsnf101_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiMenuTemplate*>(new ::darkskin::ToolstripMenuTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf102_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__::__vwsnf102_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiSelectableButtonTemplate* __vwsnf102_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiSelectableButtonTemplate*>(new ::darkskin::ToolstripSplitArrowTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf103_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__::__vwsnf103_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf103_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf104_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__::__vwsnf104_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf104_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_7.Obj())->GetText(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::WString>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_7.Obj())->SetText(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf105_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__::__vwsnf105_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf105_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_7.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_7.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf106_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__::__vwsnf106_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf106_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_7.Obj())->GetFont(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::FontProperties>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_7.Obj())->SetFont(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf107_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__::__vwsnf107_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf107_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->buttonArrow)->GetVisible(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->buttonArrow)->SetVisible(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf108_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__::__vwsnf108_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf108_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->buttonArrow)->GetSelected(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->buttonArrow)->SetSelected(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf109_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__::__vwsnf109_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiListViewColumnHeaderTemplate* __vwsnf109_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiListViewColumnHeaderTemplate*>(new ::darkskin::ListViewColumnHeaderTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__::__vwsnf10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_7.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_7.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf110_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__::__vwsnf110_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiSelectableButtonTemplate* __vwsnf110_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiSelectableButtonTemplate*>(new ::darkskin::ItemBackgroundTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf111_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__::__vwsnf111_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiScrollTemplate* __vwsnf111_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiScrollTemplate*>(new ::darkskin::VScrollTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf112_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__::__vwsnf112_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiScrollTemplate* __vwsnf112_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiScrollTemplate*>(new ::darkskin::HScrollTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf113_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf113_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuBarButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiMenuTemplate* __vwsnf113_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiMenuTemplate*>(new ::darkskin::ToolstripMenuTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf114_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf114_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuBarButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf114_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf115_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf115_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuBarButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf115_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->GetText(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::WString>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->SetText(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf116_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf116_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuBarButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf116_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf117_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf117_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuBarButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf117_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->GetFont(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::FontProperties>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->SetFont(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf118_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf118_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiMenuTemplate* __vwsnf118_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiMenuTemplate*>(new ::darkskin::ToolstripMenuTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf119_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf119_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf119_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf11_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__::__vwsnf11_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf11_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_6)->GetVisible(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_6)->SetVisible(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf120_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf120_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf120_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->GetImage(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::Ptr<::vl::presentation::INativeImage>>(__vwsn_value_); + if ((__vwsn_old_.Obj() == __vwsn_new_.Obj())) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->SetImage(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf121_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf121_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf121_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->GetFrameIndex(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::vint>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->SetFrameIndex(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf122_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf122_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf122_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->GetEnabled(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->SetEnabled(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf123_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf123_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf123_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_6.Obj())->GetText(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::WString>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_6.Obj())->SetText(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf124_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf124_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf124_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_6.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_6.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf125_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf125_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf125_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_6.Obj())->GetFont(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::FontProperties>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_6.Obj())->SetFont(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf126_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf126_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf126_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_9.Obj())->GetText(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::WString>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_9.Obj())->SetText(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf127_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf127_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf127_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_9.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_9.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf128_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf128_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf128_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_9.Obj())->GetFont(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::FontProperties>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_9.Obj())->SetFont(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf129_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf129_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf129_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_11.Obj())->GetBorderColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_11.Obj())->SetBorderColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf12_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__::__vwsnf12_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf12_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_10.Obj())->GetText(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::WString>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_10.Obj())->SetText(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf130_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf130_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf130_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_11.Obj())->GetBackgroundColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_11.Obj())->SetBackgroundColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf131_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf131_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf131_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_10)->GetVisible(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_10)->SetVisible(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf132_DarkSkin_darkskin_MultilineTextBoxTemplateConstructor___vwsn_initialize_instance__::__vwsnf132_DarkSkin_darkskin_MultilineTextBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::MultilineTextBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiScrollTemplate* __vwsnf132_DarkSkin_darkskin_MultilineTextBoxTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiScrollTemplate*>(new ::darkskin::VScrollTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf133_DarkSkin_darkskin_MultilineTextBoxTemplateConstructor___vwsn_initialize_instance__::__vwsnf133_DarkSkin_darkskin_MultilineTextBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::MultilineTextBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiScrollTemplate* __vwsnf133_DarkSkin_darkskin_MultilineTextBoxTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiScrollTemplate*>(new ::darkskin::HScrollTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf134_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance__::__vwsnf134_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance__(::darkskin::ProgressBarTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf134_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3)->GetAlignmentToParent(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Margin>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3)->SetAlignmentToParent(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf135_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf135_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf135_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf136_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf136_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf136_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_5.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_5.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf137_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf137_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf137_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_7.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_7.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf138_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf138_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf138_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_6)->GetVisible(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_6)->SetVisible(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf139_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf139_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf139_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_10.Obj())->GetText(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::WString>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_10.Obj())->SetText(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf13_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__::__vwsnf13_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf13_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_10.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_10.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf140_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf140_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf140_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_10.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_10.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf141_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf141_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf141_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_10.Obj())->GetFont(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::FontProperties>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_10.Obj())->SetFont(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf142_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf142_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::RightScrollButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf142_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->GetBorderColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->SetBorderColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf143_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf143_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::RightScrollButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf143_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->GetBackgroundColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->SetBackgroundColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf144_DarkSkin_darkskin_ScrollViewTemplateConstructor___vwsn_initialize_instance__::__vwsnf144_DarkSkin_darkskin_ScrollViewTemplateConstructor___vwsn_initialize_instance__(::darkskin::ScrollViewTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiScrollTemplate* __vwsnf144_DarkSkin_darkskin_ScrollViewTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiScrollTemplate*>(new ::darkskin::VScrollTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf145_DarkSkin_darkskin_ScrollViewTemplateConstructor___vwsn_initialize_instance__::__vwsnf145_DarkSkin_darkskin_ScrollViewTemplateConstructor___vwsn_initialize_instance__(::darkskin::ScrollViewTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiScrollTemplate* __vwsnf145_DarkSkin_darkskin_ScrollViewTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiScrollTemplate*>(new ::darkskin::HScrollTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf146_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__::__vwsnf146_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__(::darkskin::ShortcutKeyTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf146_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->GetText(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::WString>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->SetText(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf147_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__::__vwsnf147_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__(::darkskin::ShortcutKeyTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf147_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf148_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__::__vwsnf148_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__(::darkskin::ShortcutKeyTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf148_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->GetFont(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::FontProperties>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->SetFont(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf149_DarkSkin_darkskin_TabDropdownTemplateConstructor___vwsn_initialize_instance__::__vwsnf149_DarkSkin_darkskin_TabDropdownTemplateConstructor___vwsn_initialize_instance__(::darkskin::TabDropdownTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf149_DarkSkin_darkskin_TabDropdownTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf14_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__::__vwsnf14_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf14_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_10.Obj())->GetFont(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::FontProperties>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_10.Obj())->SetFont(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf150_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__::__vwsnf150_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::TabHeaderTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf150_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf151_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__::__vwsnf151_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::TabHeaderTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf151_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->GetText(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::WString>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->SetText(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf152_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__::__vwsnf152_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::TabHeaderTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf152_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf153_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__::__vwsnf153_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::TabHeaderTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf153_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->GetFont(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::FontProperties>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->SetFont(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf154_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__::__vwsnf154_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__(::darkskin::TabTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiToolstripButtonTemplate* __vwsnf154_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiToolstripButtonTemplate*>(new ::darkskin::MenuItemButtonTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf155_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__::__vwsnf155_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__(::darkskin::TabTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiMenuTemplate* __vwsnf155_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiMenuTemplate*>(new ::darkskin::ToolstripMenuTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf156_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__::__vwsnf156_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__(::darkskin::TabTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiButtonTemplate* __vwsnf156_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiButtonTemplate*>(new ::darkskin::TabDropdownTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf157_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__::__vwsnf157_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__(::darkskin::TabTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiSelectableButtonTemplate* __vwsnf157_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiSelectableButtonTemplate*>(new ::darkskin::TabHeaderTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf158_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__::__vwsnf158_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__(::darkskin::TextListTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiSelectableButtonTemplate* __vwsnf158_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiSelectableButtonTemplate*>(new ::darkskin::RadioButtonTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf159_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__::__vwsnf159_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__(::darkskin::TextListTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiSelectableButtonTemplate* __vwsnf159_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiSelectableButtonTemplate*>(new ::darkskin::CheckBoxTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance__::__vwsnf15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance__(::darkskin::CheckItemBackgroundTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf160_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__::__vwsnf160_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__(::darkskin::TextListTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiSelectableButtonTemplate* __vwsnf160_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiSelectableButtonTemplate*>(new ::darkskin::ItemBackgroundTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf161_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__::__vwsnf161_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__(::darkskin::TextListTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiScrollTemplate* __vwsnf161_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiScrollTemplate*>(new ::darkskin::VScrollTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf162_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__::__vwsnf162_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__(::darkskin::TextListTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiScrollTemplate* __vwsnf162_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiScrollTemplate*>(new ::darkskin::HScrollTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf163_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__::__vwsnf163_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitArrowTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf163_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_1.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_1.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf164_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__::__vwsnf164_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitArrowTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf164_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->GetBorderColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->SetBorderColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf165_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__::__vwsnf165_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitArrowTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf165_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->GetBackgroundColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->SetBackgroundColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf166_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf166_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiMenuTemplate* __vwsnf166_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiMenuTemplate*>(new ::darkskin::ToolstripMenuTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf167_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf167_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf167_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_1.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_1.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf168_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf168_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf168_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf169_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf169_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf169_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->GetImage(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::Ptr<::vl::presentation::INativeImage>>(__vwsn_value_); + if ((__vwsn_old_.Obj() == __vwsn_new_.Obj())) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->SetImage(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__::__vwsnf16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiDatePickerTemplate* __vwsnf16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiDatePickerTemplate*>(new ::darkskin::DatePickerTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf170_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf170_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf170_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->GetFrameIndex(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::vint>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->SetFrameIndex(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf171_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf171_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf171_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->GetEnabled(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->SetEnabled(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf172_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf172_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiMenuTemplate* __vwsnf172_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiMenuTemplate*>(new ::darkskin::ToolstripMenuTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf173_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf173_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf173_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_1.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_1.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf174_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf174_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf174_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf175_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf175_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf175_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->GetImage(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::Ptr<::vl::presentation::INativeImage>>(__vwsn_value_); + if ((__vwsn_old_.Obj() == __vwsn_new_.Obj())) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->SetImage(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf176_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf176_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf176_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->GetFrameIndex(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::vint>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->SetFrameIndex(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf177_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf177_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf177_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->GetEnabled(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->SetEnabled(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf178_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf178_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf178_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_6.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_6.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf179_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf179_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf179_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_8.Obj())->GetBorderColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_8.Obj())->SetBorderColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf17_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__::__vwsnf17_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiMenuTemplate* __vwsnf17_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiMenuTemplate*>(new ::darkskin::ToolstripMenuTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf180_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf180_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf180_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_8.Obj())->GetBackgroundColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_8.Obj())->SetBackgroundColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf181_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf181_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiMenuTemplate* __vwsnf181_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiMenuTemplate*>(new ::darkskin::ToolstripMenuTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf182_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf182_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiSelectableButtonTemplate* __vwsnf182_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiSelectableButtonTemplate*>(new ::darkskin::ToolstripSplitArrowTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf183_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf183_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf183_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_1.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_1.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf184_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf184_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf184_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf185_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf185_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf185_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->GetImage(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::Ptr<::vl::presentation::INativeImage>>(__vwsn_value_); + if ((__vwsn_old_.Obj() == __vwsn_new_.Obj())) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->SetImage(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf186_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf186_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf186_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->GetFrameIndex(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::vint>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->SetFrameIndex(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf187_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf187_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf187_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->GetEnabled(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->SetEnabled(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf188_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf188_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf188_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_7.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_7.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf189_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf189_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf189_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->buttonArrow)->GetSelected(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->buttonArrow)->SetSelected(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__::__vwsnf18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf190_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf190_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::TopScrollButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf190_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->GetBorderColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->SetBorderColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf191_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf191_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::TopScrollButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf191_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->GetBackgroundColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->SetBackgroundColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf192_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__::__vwsnf192_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__(::darkskin::TreeViewTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiSelectableButtonTemplate* __vwsnf192_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiSelectableButtonTemplate*>(new ::darkskin::ExpandingDecoratorTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf193_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__::__vwsnf193_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__(::darkskin::TreeViewTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiSelectableButtonTemplate* __vwsnf193_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiSelectableButtonTemplate*>(new ::darkskin::ItemBackgroundTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf194_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__::__vwsnf194_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__(::darkskin::TreeViewTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiScrollTemplate* __vwsnf194_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiScrollTemplate*>(new ::darkskin::VScrollTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf195_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__::__vwsnf195_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__(::darkskin::TreeViewTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiScrollTemplate* __vwsnf195_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiScrollTemplate*>(new ::darkskin::HScrollTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf196_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance__::__vwsnf196_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollHandleTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf196_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_1.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_1.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf197_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf197_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiButtonTemplate* __vwsnf197_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiButtonTemplate*>(new ::darkskin::TopScrollButtonTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf198_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf198_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiButtonTemplate* __vwsnf198_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiButtonTemplate*>(new ::darkskin::BottomScrollButtonTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf199_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf199_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiButtonTemplate* __vwsnf199_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiButtonTemplate*>(new ::darkskin::VScrollHandleTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf19_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__::__vwsnf19_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf19_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->GetText(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::WString>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->SetText(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::BottomScrollButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->GetBorderColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->SetBorderColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf200_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf200_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf200_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiEventArgs* arguments) const + { + ::vl::__vwsn::This(::vl::__vwsn::This(__vwsnthis_0->self)->GetCommands())->SmallDecrease(); + } + + //------------------------------------------------------------------- + + __vwsnf201_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf201_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf201_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiEventArgs* arguments) const + { + ::vl::__vwsn::This(::vl::__vwsn::This(__vwsnthis_0->self)->GetCommands())->SmallIncrease(); + } + + //------------------------------------------------------------------- + + __vwsnf202_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf202_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf202_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_7)->GetAlignmentToParent(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Margin>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_7)->SetAlignmentToParent(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf203_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf203_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf203_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const + { + if (::vl::__vwsn::This(::vl::__vwsn::This(__vwsnthis_0->handleContainer)->GetRelatedControl())->GetVisuallyEnabled()) + { + ::vl::__vwsn::This(::vl::__vwsn::This(__vwsnthis_0->self)->GetCommands())->BigDecrease(); + } + } + + //------------------------------------------------------------------- + + __vwsnf204_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf204_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf204_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_8)->GetAlignmentToParent(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Margin>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_8)->SetAlignmentToParent(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf205_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf205_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf205_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const + { + if (::vl::__vwsn::This(::vl::__vwsn::This(__vwsnthis_0->handleContainer)->GetRelatedControl())->GetVisuallyEnabled()) + { + ::vl::__vwsn::This(::vl::__vwsn::This(__vwsnthis_0->self)->GetCommands())->BigIncrease(); + } + } + + //------------------------------------------------------------------- + + __vwsnf206_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf206_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf206_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->handle)->GetHeightPageSize(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->handle)->SetHeightPageSize(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf207_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf207_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf207_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->handle)->GetHeightRatio(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->handle)->SetHeightRatio(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf208_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf208_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf208_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const + { + if (::vl::__vwsn::This(__vwsnthis_0->self)->GetVisuallyEnabled()) + { + (::vl::__vwsn::This(__vwsnthis_0->self)->draggingHandle = true); + (::vl::__vwsn::This(__vwsnthis_0->self)->draggingStartLocation = [&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = ::vl::__vwsn::This(arguments)->x; __vwsn_temp__.y = ::vl::__vwsn::This(arguments)->y; return __vwsn_temp__; }()); + } + } + + //------------------------------------------------------------------- + + __vwsnf209_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf209_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf209_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const + { + (::vl::__vwsn::This(__vwsnthis_0->self)->draggingHandle = false); + } + + //------------------------------------------------------------------- + + __vwsnf20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__::__vwsnf20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf210_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf210_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf210_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__::operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const + { + if (::vl::__vwsn::This(__vwsnthis_0->self)->draggingHandle) + { + auto bounds = ::vl::__vwsn::This(::vl::__vwsn::This(__vwsnthis_0->handle)->GetParent())->GetBounds(); + auto totalPixels = (bounds.y2 - bounds.y1); + auto currentOffset = ::vl::__vwsn::This(__vwsnthis_0->handle)->GetBounds().y1; + auto newOffset = (currentOffset + (::vl::__vwsn::This(arguments)->y - ::vl::__vwsn::This(__vwsnthis_0->self)->draggingStartLocation.y)); + ::ScrollTemplateScript::SetScroll(totalPixels, newOffset, static_cast<::vl::presentation::templates::GuiScrollTemplate*>(__vwsnthis_0->self)); + } + } + + //------------------------------------------------------------------- + + __vwsnf211_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__::__vwsnf211_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__(::darkskin::VTrackerTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiButtonTemplate* __vwsnf211_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiButtonTemplate*>(new ::darkskin::ButtonTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf212_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__::__vwsnf212_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__(::darkskin::VTrackerTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf212_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->handle)->GetAlignmentToParent(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Margin>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->handle)->SetAlignmentToParent(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf213_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__::__vwsnf213_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__(::darkskin::VTrackerTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf213_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__::operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const + { + if (::vl::__vwsn::This(__vwsnthis_0->self)->GetVisuallyEnabled()) + { + (::vl::__vwsn::This(__vwsnthis_0->self)->draggingHandle = true); + (::vl::__vwsn::This(__vwsnthis_0->self)->draggingStartLocation = [&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = ::vl::__vwsn::This(arguments)->x; __vwsn_temp__.y = ::vl::__vwsn::This(arguments)->y; return __vwsn_temp__; }()); + } + } + + //------------------------------------------------------------------- + + __vwsnf214_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__::__vwsnf214_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__(::darkskin::VTrackerTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf214_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__::operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const + { + (::vl::__vwsn::This(__vwsnthis_0->self)->draggingHandle = false); + } + + //------------------------------------------------------------------- + + __vwsnf215_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__::__vwsnf215_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__(::darkskin::VTrackerTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf215_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__::operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const + { + if (::vl::__vwsn::This(__vwsnthis_0->self)->draggingHandle) + { + auto bounds = ::vl::__vwsn::This(::vl::__vwsn::This(__vwsnthis_0->handle)->GetParent())->GetBounds(); + auto totalPixels = (bounds.y2 - bounds.y1); + auto currentOffset = ::vl::__vwsn::This(__vwsnthis_0->handle)->GetBounds().y1; + auto newOffset = (currentOffset + (::vl::__vwsn::This(arguments)->y - ::vl::__vwsn::This(__vwsnthis_0->self)->draggingStartLocation.y)); + ::ScrollTemplateScript::SetScroll(totalPixels, newOffset, static_cast<::vl::presentation::templates::GuiScrollTemplate*>(__vwsnthis_0->self)); + } + } + + //------------------------------------------------------------------- + + __vwsnf216_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__::__vwsnf216_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__(::darkskin::WindowTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiWindowTemplate* __vwsnf216_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiWindowTemplate*>(new ::darkskin::TooltipTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf217_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__::__vwsnf217_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__(::darkskin::WindowTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiButtonTemplate* __vwsnf217_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiButtonTemplate*>(new ::darkskin::ButtonTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf218_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__::__vwsnf218_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__(::darkskin::WindowTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiButtonTemplate* __vwsnf218_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiButtonTemplate*>(new ::darkskin::ButtonTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf219_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__::__vwsnf219_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__(::darkskin::WindowTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiButtonTemplate* __vwsnf219_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiButtonTemplate*>(new ::darkskin::ButtonTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__::__vwsnf21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->GetFont(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::FontProperties>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->SetFont(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf220_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__::__vwsnf220_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__(::darkskin::WindowTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf220_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_16)->GetText(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::WString>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_16)->SetText(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf221_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__::__vwsnf221_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__(::darkskin::WindowTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf221_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_23.Obj())->GetText(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::WString>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_23.Obj())->SetText(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__::__vwsnf22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_6.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_6.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf23_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__::__vwsnf23_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf23_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_8.Obj())->GetBorderColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_8.Obj())->SetBorderColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf24_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__::__vwsnf24_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf24_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_8.Obj())->GetBackgroundColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_8.Obj())->SetBackgroundColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf25_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf25_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiScrollTemplate* __vwsnf25_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiScrollTemplate*>(new ::darkskin::ProgressBarTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf26_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf26_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiScrollTemplate* __vwsnf26_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiScrollTemplate*>(new ::darkskin::VTrackerTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf27_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf27_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiScrollTemplate* __vwsnf27_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiScrollTemplate*>(new ::darkskin::HTrackerTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf28_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf28_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiScrollTemplate* __vwsnf28_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiScrollTemplate*>(new ::darkskin::VScrollTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf29_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf29_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiScrollTemplate* __vwsnf29_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiScrollTemplate*>(new ::darkskin::HScrollTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::BottomScrollButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->GetBackgroundColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->SetBackgroundColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf30_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf30_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiDatePickerTemplate* __vwsnf30_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiDatePickerTemplate*>(new ::darkskin::DatePickerTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf31_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf31_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiSelectableButtonTemplate* __vwsnf31_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiSelectableButtonTemplate*>(new ::darkskin::RadioButtonTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf32_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf32_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiSelectableButtonTemplate* __vwsnf32_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiSelectableButtonTemplate*>(new ::darkskin::CheckBoxTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf33_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf33_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiButtonTemplate* __vwsnf33_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiButtonTemplate*>(new ::darkskin::ButtonTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf34_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf34_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiControlTemplate* __vwsnf34_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiControlTemplate*>(new ::darkskin::ToolstripSplitterTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf35_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf35_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiToolstripButtonTemplate* __vwsnf35_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiToolstripButtonTemplate*>(new ::darkskin::ToolstripSplitButtonTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf36_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf36_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiToolstripButtonTemplate* __vwsnf36_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiToolstripButtonTemplate*>(new ::darkskin::ToolstripDropdownButtonTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf37_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf37_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiToolstripButtonTemplate* __vwsnf37_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiToolstripButtonTemplate*>(new ::darkskin::ToolstripButtonTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf38_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf38_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiControlTemplate* __vwsnf38_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiControlTemplate*>(new ::darkskin::ToolstripTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf39_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf39_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiToolstripButtonTemplate* __vwsnf39_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiToolstripButtonTemplate*>(new ::darkskin::MenuItemButtonTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf40_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf40_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiToolstripButtonTemplate* __vwsnf40_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiToolstripButtonTemplate*>(new ::darkskin::MenuBarButtonTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf41_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf41_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiControlTemplate* __vwsnf41_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiControlTemplate*>(new ::darkskin::MenuSplitterTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf42_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf42_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiControlTemplate* __vwsnf42_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiControlTemplate*>(new ::darkskin::ToolstripTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf43_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf43_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiMenuTemplate* __vwsnf43_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiMenuTemplate*>(new ::darkskin::ToolstripMenuTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf44_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf44_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiTextListTemplate* __vwsnf44_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiTextListTemplate*>(new ::darkskin::TextListTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf45_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf45_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiTreeViewTemplate* __vwsnf45_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiTreeViewTemplate*>(new ::darkskin::TreeViewTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf46_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf46_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiListViewTemplate* __vwsnf46_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiListViewTemplate*>(new ::darkskin::ListViewTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf47_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf47_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiDocumentLabelTemplate* __vwsnf47_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiDocumentLabelTemplate*>(new ::darkskin::DocumentTextBoxTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf48_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf48_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiDocumentLabelTemplate* __vwsnf48_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiDocumentLabelTemplate*>(new ::darkskin::DocumentLabelTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf49_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf49_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiDocumentViewerTemplate* __vwsnf49_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiDocumentViewerTemplate*>(new ::darkskin::DocumentViewerTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf50_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf50_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiSinglelineTextBoxTemplate* __vwsnf50_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiSinglelineTextBoxTemplate*>(new ::darkskin::SinglelineTextBoxTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf51_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf51_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiMultilineTextBoxTemplate* __vwsnf51_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiMultilineTextBoxTemplate*>(new ::darkskin::MultilineTextBoxTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf52_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf52_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiComboBoxTemplate* __vwsnf52_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiComboBoxTemplate*>(new ::darkskin::ComboBoxTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf53_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf53_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiTabTemplate* __vwsnf53_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiTabTemplate*>(new ::darkskin::TabTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf54_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf54_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiControlTemplate* __vwsnf54_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiControlTemplate*>(new ::darkskin::GroupBoxTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf55_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf55_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiScrollViewTemplate* __vwsnf55_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiScrollViewTemplate*>(new ::darkskin::ScrollViewTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf56_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf56_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiLabelTemplate* __vwsnf56_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiLabelTemplate*>(new ::darkskin::ShortcutKeyTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf57_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf57_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiLabelTemplate* __vwsnf57_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiLabelTemplate*>(new ::darkskin::LabelTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf58_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf58_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiWindowTemplate* __vwsnf58_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiWindowTemplate*>(new ::darkskin::TooltipTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf59_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf59_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiControlTemplate* __vwsnf59_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiControlTemplate*>(new ::darkskin::CustomControlTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf5_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf5_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf5_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->GetText(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::WString>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->SetText(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf60_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::__vwsnf60_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiWindowTemplate* __vwsnf60_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiWindowTemplate*>(new ::darkskin::WindowTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf61_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__::__vwsnf61_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__(::darkskin::DatePickerTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiComboBoxTemplate* __vwsnf61_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiComboBoxTemplate*>(new ::darkskin::ComboBoxTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf62_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__::__vwsnf62_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__(::darkskin::DatePickerTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiTextListTemplate* __vwsnf62_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiTextListTemplate*>(new ::darkskin::TextListTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf63_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__::__vwsnf63_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__(::darkskin::DatePickerTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiSelectableButtonTemplate* __vwsnf63_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiSelectableButtonTemplate*>(new ::darkskin::ItemBackgroundTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf64_DarkSkin_darkskin_DocumentViewerTemplateConstructor___vwsn_initialize_instance__::__vwsnf64_DarkSkin_darkskin_DocumentViewerTemplateConstructor___vwsn_initialize_instance__(::darkskin::DocumentViewerTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiScrollTemplate* __vwsnf64_DarkSkin_darkskin_DocumentViewerTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiScrollTemplate*>(new ::darkskin::VScrollTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf65_DarkSkin_darkskin_DocumentViewerTemplateConstructor___vwsn_initialize_instance__::__vwsnf65_DarkSkin_darkskin_DocumentViewerTemplateConstructor___vwsn_initialize_instance__(::darkskin::DocumentViewerTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiScrollTemplate* __vwsnf65_DarkSkin_darkskin_DocumentViewerTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiScrollTemplate*>(new ::darkskin::HScrollTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf66_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__::__vwsnf66_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf66_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->GetBorderColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->SetBorderColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf67_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__::__vwsnf67_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf67_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->GetBackgroundColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->SetBackgroundColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf68_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__::__vwsnf68_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf68_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2)->GetVisible(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2)->SetVisible(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf69_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__::__vwsnf69_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf69_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_5.Obj())->GetBorderColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_5.Obj())->SetBorderColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf70_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__::__vwsnf70_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf70_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_5.Obj())->GetBackgroundColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_5.Obj())->SetBackgroundColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf71_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__::__vwsnf71_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf71_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4)->GetVisible(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4)->SetVisible(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf72_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__::__vwsnf72_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::GroupBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf72_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_1)->GetAlignmentToParent(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Margin>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_1)->SetAlignmentToParent(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf73_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__::__vwsnf73_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::GroupBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf73_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_5.Obj())->GetText(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::WString>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_5.Obj())->SetText(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf74_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__::__vwsnf74_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::GroupBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf74_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_5.Obj())->GetFont(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::FontProperties>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_5.Obj())->SetFont(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf75_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance__::__vwsnf75_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollHandleTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf75_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_1.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_1.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf76_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf76_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiButtonTemplate* __vwsnf76_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiButtonTemplate*>(new ::darkskin::LeftScrollButtonTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf77_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf77_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiButtonTemplate* __vwsnf77_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiButtonTemplate*>(new ::darkskin::RightScrollButtonTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf78_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf78_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiButtonTemplate* __vwsnf78_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiButtonTemplate*>(new ::darkskin::HScrollHandleTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf79_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf79_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf79_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiEventArgs* arguments) const + { + ::vl::__vwsn::This(::vl::__vwsn::This(__vwsnthis_0->self)->GetCommands())->SmallDecrease(); + } + + //------------------------------------------------------------------- + + __vwsnf7_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf7_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf7_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->GetFont(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::FontProperties>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_4.Obj())->SetFont(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf80_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf80_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf80_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiEventArgs* arguments) const + { + ::vl::__vwsn::This(::vl::__vwsn::This(__vwsnthis_0->self)->GetCommands())->SmallIncrease(); + } + + //------------------------------------------------------------------- + + __vwsnf81_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf81_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf81_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_7)->GetAlignmentToParent(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Margin>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_7)->SetAlignmentToParent(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf82_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf82_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf82_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const + { + if (::vl::__vwsn::This(::vl::__vwsn::This(__vwsnthis_0->handleContainer)->GetRelatedControl())->GetVisuallyEnabled()) + { + ::vl::__vwsn::This(::vl::__vwsn::This(__vwsnthis_0->self)->GetCommands())->BigDecrease(); + } + } + + //------------------------------------------------------------------- + + __vwsnf83_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf83_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf83_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_8)->GetAlignmentToParent(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Margin>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_8)->SetAlignmentToParent(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf84_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf84_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf84_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const + { + if (::vl::__vwsn::This(::vl::__vwsn::This(__vwsnthis_0->handleContainer)->GetRelatedControl())->GetVisuallyEnabled()) + { + ::vl::__vwsn::This(::vl::__vwsn::This(__vwsnthis_0->self)->GetCommands())->BigIncrease(); + } + } + + //------------------------------------------------------------------- + + __vwsnf85_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf85_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf85_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->handle)->GetWidthPageSize(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->handle)->SetWidthPageSize(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf86_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf86_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf86_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->handle)->GetWidthRatio(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->handle)->SetWidthRatio(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf87_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf87_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf87_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const + { + if (::vl::__vwsn::This(__vwsnthis_0->self)->GetVisuallyEnabled()) + { + (::vl::__vwsn::This(__vwsnthis_0->self)->draggingHandle = true); + (::vl::__vwsn::This(__vwsnthis_0->self)->draggingStartLocation = [&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = ::vl::__vwsn::This(arguments)->x; __vwsn_temp__.y = ::vl::__vwsn::This(arguments)->y; return __vwsn_temp__; }()); + } + } + + //------------------------------------------------------------------- + + __vwsnf88_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf88_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf88_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const + { + (::vl::__vwsn::This(__vwsnthis_0->self)->draggingHandle = false); + } + + //------------------------------------------------------------------- + + __vwsnf89_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::__vwsnf89_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf89_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__::operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const + { + if (::vl::__vwsn::This(__vwsnthis_0->self)->draggingHandle) + { + auto bounds = ::vl::__vwsn::This(::vl::__vwsn::This(__vwsnthis_0->handle)->GetParent())->GetBounds(); + auto totalPixels = (bounds.x2 - bounds.x1); + auto currentOffset = ::vl::__vwsn::This(__vwsnthis_0->handle)->GetBounds().x1; + auto newOffset = (currentOffset + (::vl::__vwsn::This(arguments)->x - ::vl::__vwsn::This(__vwsnthis_0->self)->draggingStartLocation.x)); + ::ScrollTemplateScript::SetScroll(totalPixels, newOffset, static_cast<::vl::presentation::templates::GuiScrollTemplate*>(__vwsnthis_0->self)); + } + } + + //------------------------------------------------------------------- + + __vwsnf8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__::__vwsnf8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_3.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf90_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__::__vwsnf90_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__(::darkskin::HTrackerTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + ::vl::presentation::templates::GuiButtonTemplate* __vwsnf90_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const + { + { + return static_cast<::vl::presentation::templates::GuiButtonTemplate*>(new ::darkskin::ButtonTemplate()); + } + } + + //------------------------------------------------------------------- + + __vwsnf91_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__::__vwsnf91_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__(::darkskin::HTrackerTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf91_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->handle)->GetAlignmentToParent(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Margin>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->handle)->SetAlignmentToParent(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf92_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__::__vwsnf92_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__(::darkskin::HTrackerTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf92_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__::operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const + { + if (::vl::__vwsn::This(__vwsnthis_0->self)->GetVisuallyEnabled()) + { + (::vl::__vwsn::This(__vwsnthis_0->self)->draggingHandle = true); + (::vl::__vwsn::This(__vwsnthis_0->self)->draggingStartLocation = [&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = ::vl::__vwsn::This(arguments)->x; __vwsn_temp__.y = ::vl::__vwsn::This(arguments)->y; return __vwsn_temp__; }()); + } + } + + //------------------------------------------------------------------- + + __vwsnf93_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__::__vwsnf93_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__(::darkskin::HTrackerTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf93_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__::operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const + { + (::vl::__vwsn::This(__vwsnthis_0->self)->draggingHandle = false); + } + + //------------------------------------------------------------------- + + __vwsnf94_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__::__vwsnf94_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__(::darkskin::HTrackerTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf94_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__::operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const + { + if (::vl::__vwsn::This(__vwsnthis_0->self)->draggingHandle) + { + auto bounds = ::vl::__vwsn::This(::vl::__vwsn::This(__vwsnthis_0->handle)->GetParent())->GetBounds(); + auto totalPixels = (bounds.x2 - bounds.x1); + auto currentOffset = ::vl::__vwsn::This(__vwsnthis_0->handle)->GetBounds().x1; + auto newOffset = (currentOffset + (::vl::__vwsn::This(arguments)->x - ::vl::__vwsn::This(__vwsnthis_0->self)->draggingStartLocation.x)); + ::ScrollTemplateScript::SetScroll(totalPixels, newOffset, static_cast<::vl::presentation::templates::GuiScrollTemplate*>(__vwsnthis_0->self)); + } + } + + //------------------------------------------------------------------- + + __vwsnf95_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance__::__vwsnf95_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance__(::darkskin::ItemBackgroundTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf95_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf96_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__::__vwsnf96_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__(::darkskin::LabelTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf96_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->GetText(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::WString>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->SetText(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf97_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__::__vwsnf97_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__(::darkskin::LabelTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf97_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf98_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__::__vwsnf98_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__(::darkskin::LabelTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf98_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->GetFont(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::FontProperties>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_0.Obj())->SetFont(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf99_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance__::__vwsnf99_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::LeftScrollButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf99_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->GetBorderColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_2.Obj())->SetBorderColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnf9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__::__vwsnf9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + } + + void __vwsnf9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__::operator()(const ::vl::reflection::description::Value& __vwsn_value_) const + { + auto __vwsn_old_ = ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_5.Obj())->GetColor(); + auto __vwsn_new_ = ::vl::__vwsn::Unbox<::vl::presentation::Color>(__vwsn_value_); + if ((__vwsn_old_ == __vwsn_new_)) + { + return; + } + ::vl::__vwsn::This(__vwsnthis_0->__vwsn_precompile_5.Obj())->SetColor(__vwsn_new_); + } + + //------------------------------------------------------------------- + + __vwsnc100_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc100_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc100_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#555558", false) : (((state == ::vl::presentation::controls::ButtonState::Pressed) || ::vl::__vwsn::This(__vwsn_bind_cache_2)->GetSubMenuOpening()) ? ::vl::WString(L"#FFFFFF", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#1997EA", false) : ::vl::WString(L"#999999", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc100_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc100_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc100_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc100_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc100_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc100_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, ::vl::Func(this, &__vwsnc100_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc100_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc100_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc101_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc101_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripSplitButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripSplitButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc101_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetSelected()) ? ::vl::WString(L"#00000000", false) : ::vl::WString(L"#007ACC", false)); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc101_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc101_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc101_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc101_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->SelectedChanged, ::vl::Func(this, &__vwsnc101_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc101_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc101_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->SelectedChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripSplitButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripSplitButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc102_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc102_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripSplitButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripSplitButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::darkskin::ToolstripSplitButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc102_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#00000000", false) : (((state == ::vl::presentation::controls::ButtonState::Pressed) || ::vl::__vwsn::This(__vwsn_bind_cache_2)->GetSubMenuOpening()) ? ::vl::WString(L"#007ACC", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#54545C", false) : ::vl::WString(L"#00000000", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc102_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc102_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc102_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc102_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc102_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc102_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, ::vl::Func(this, &__vwsnc102_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc102_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc102_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripSplitButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripSplitButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::darkskin::ToolstripSplitButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc103_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc103_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripSplitButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc103_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = [&](){ try{ return ::vl::__vwsn::This(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetImage().Obj())->GetImage(); } catch(...){ return ::vl::Ptr<::vl::presentation::INativeImage>(); } }(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc103_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc103_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->ImageChanged, ::vl::Func(this, &__vwsnc103_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc103_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc103_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->ImageChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripSplitButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc104_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc104_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripSplitButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc104_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = [&](){ try{ return ::vl::__vwsn::This(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetImage().Obj())->GetFrameIndex(); } catch(...){ return static_cast<::vl::vint>(0); } }(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc104_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc104_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->ImageChanged, ::vl::Func(this, &__vwsnc104_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc104_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc104_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->ImageChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripSplitButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc105_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc105_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripSplitButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc105_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetVisuallyEnabled(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc105_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc105_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc105_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc105_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc105_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->VisuallyEnabledChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripSplitButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc106_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc106_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripSplitButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripSplitButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc106_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#00000000", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#54545C", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#54545C", false) : ::vl::WString(L"#00000000", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc106_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc106_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc106_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc106_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc106_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc106_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc106_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripSplitButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripSplitButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc107_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc107_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripSplitButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc107_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetSubMenuOpening(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc107_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc107_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->SubMenuOpeningChanged, ::vl::Func(this, &__vwsnc107_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc107_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc107_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->SubMenuOpeningChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripSplitButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc108_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc108_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::TopScrollButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::TopScrollButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::TopScrollButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc108_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#555558", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#1997EA", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#007ACC", false) : ::vl::WString(L"#999999", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc108_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc108_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc108_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc108_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc108_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc108_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc108_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::TopScrollButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::TopScrollButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc109_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc109_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::TopScrollButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::TopScrollButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::TopScrollButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc109_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#555558", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#1997EA", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#007ACC", false) : ::vl::WString(L"#999999", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc109_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc109_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc109_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc109_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc109_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc109_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc109_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::TopScrollButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::TopScrollButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::CheckBoxTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::CheckBoxTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#6D6D6D", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#F1F1F1", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#FFFFFF", false) : ::vl::WString(L"#F1F1F1", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::CheckBoxTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::CheckBoxTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc110_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc110_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::VScrollHandleTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::VScrollHandleTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::VScrollHandleTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc110_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#3D3D42", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#9E9E9E", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#EFEBEF", false) : ::vl::WString(L"#686868", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc110_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc110_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc110_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc110_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc110_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc110_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc110_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::VScrollHandleTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::VScrollHandleTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc111_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc111_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::vl::presentation::compositions::GuiPartialViewComposition*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc111_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = [&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = ((::vl::__vwsn::This(__vwsn_bind_cache_0)->GetBounds().y2 - ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetBounds().y1) - ::vl::__vwsn::This(__vwsn_bind_cache_2)->GetBounds().y1); return __vwsn_temp__; }(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc111_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc111_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc111_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc111_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->handleContainer); + (__vwsn_bind_cache_1 = __vwsnthis_0->handleContainer); + (__vwsn_bind_cache_2 = __vwsnthis_0->handle); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->BoundsChanged, ::vl::Func(this, &__vwsnc111_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->BoundsChanged, ::vl::Func(this, &__vwsnc111_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->BoundsChanged, ::vl::Func(this, &__vwsnc111_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc111_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc111_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->BoundsChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->BoundsChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->BoundsChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::vl::presentation::compositions::GuiPartialViewComposition*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc112_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc112_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::vl::presentation::compositions::GuiPartialViewComposition*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc112_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = [&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetBounds().y2; __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc112_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc112_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->handle); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->BoundsChanged, ::vl::Func(this, &__vwsnc112_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc112_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc112_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->BoundsChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::vl::presentation::compositions::GuiPartialViewComposition*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc113_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc113_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::VScrollTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::VScrollTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc113_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = (static_cast(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetPageSize()) / static_cast(::vl::__vwsn::This(__vwsn_bind_cache_1)->GetTotalSize())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc113_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc113_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc113_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->PageSizeChanged, ::vl::Func(this, &__vwsnc113_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->TotalSizeChanged, ::vl::Func(this, &__vwsnc113_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc113_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc113_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->PageSizeChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->TotalSizeChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::VScrollTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::VScrollTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc114_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc114_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::VScrollTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::VScrollTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc114_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = (static_cast(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetPosition()) / static_cast(::vl::__vwsn::This(__vwsn_bind_cache_1)->GetTotalSize())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc114_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc114_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc114_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->PositionChanged, ::vl::Func(this, &__vwsnc114_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->TotalSizeChanged, ::vl::Func(this, &__vwsnc114_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc114_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc114_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->PositionChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->TotalSizeChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::VScrollTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::VScrollTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::VTrackerTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::VTrackerTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::VTrackerTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + this->__vwsn_bind_cache_3 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + this->__vwsn_bind_cache_4 = static_cast<::darkskin::VTrackerTemplate*>(nullptr); + this->__vwsn_bind_cache_5 = static_cast<::darkskin::VTrackerTemplate*>(nullptr); + this->__vwsn_bind_cache_6 = static_cast<::darkskin::VTrackerTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_3_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_4_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_5_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_6_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = [&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = [&](auto height, auto max){ return ((max == static_cast<::vl::vint>(0)) ? static_cast<::vl::vint>(0) : ((height * ::vl::__vwsn::This(__vwsn_bind_cache_6)->GetPosition()) / max)); }(((::vl::__vwsn::This(__vwsn_bind_cache_0)->GetBounds().y2 - ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetBounds().y1) - (::vl::__vwsn::This(__vwsn_bind_cache_2)->GetBounds().y2 - ::vl::__vwsn::This(__vwsn_bind_cache_3)->GetBounds().y1)), (::vl::__vwsn::This(__vwsn_bind_cache_4)->GetTotalSize() - ::vl::__vwsn::This(__vwsn_bind_cache_5)->GetPageSize())); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = (- static_cast<::vl::vint>(1)); return __vwsn_temp__; }(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_3_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_4_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_5_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_6_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->handle); + (__vwsn_bind_cache_3 = __vwsnthis_0->handle); + (__vwsn_bind_cache_4 = __vwsnthis_0->self); + (__vwsn_bind_cache_5 = __vwsnthis_0->self); + (__vwsn_bind_cache_6 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->BoundsChanged, ::vl::Func(this, &__vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->BoundsChanged, ::vl::Func(this, &__vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->BoundsChanged, ::vl::Func(this, &__vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + (__vwsn_bind_handler_3_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_3)->BoundsChanged, ::vl::Func(this, &__vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_3_0))); + (__vwsn_bind_handler_4_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_4)->TotalSizeChanged, ::vl::Func(this, &__vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_4_0))); + (__vwsn_bind_handler_5_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_5)->PageSizeChanged, ::vl::Func(this, &__vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_5_0))); + (__vwsn_bind_handler_6_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_6)->PositionChanged, ::vl::Func(this, &__vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_6_0))); + return true; + } + return false; + } + + bool __vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->BoundsChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->BoundsChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->BoundsChanged, __vwsn_bind_handler_2_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_3)->BoundsChanged, __vwsn_bind_handler_3_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_4)->TotalSizeChanged, __vwsn_bind_handler_4_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_5)->PageSizeChanged, __vwsn_bind_handler_5_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_6)->PositionChanged, __vwsn_bind_handler_6_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::VTrackerTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::VTrackerTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr)); + (__vwsn_bind_cache_3 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr)); + (__vwsn_bind_cache_4 = static_cast<::darkskin::VTrackerTemplate*>(nullptr)); + (__vwsn_bind_cache_5 = static_cast<::darkskin::VTrackerTemplate*>(nullptr)); + (__vwsn_bind_cache_6 = static_cast<::darkskin::VTrackerTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_3_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_4_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_5_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_6_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc116_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc116_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::WindowTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::WindowTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc116_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = (::vl::__vwsn::This(__vwsn_bind_cache_0)->GetMaximized() ? ::vl::WString(L" 1 ", false) : ::vl::WString(L" 2 ", false)); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc116_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc116_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->MaximizedChanged, ::vl::Func(this, &__vwsnc116_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc116_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc116_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->MaximizedChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::WindowTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc117_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc117_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::WindowTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::WindowTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc117_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetText(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc117_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc117_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, ::vl::Func(this, &__vwsnc117_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc117_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc117_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::WindowTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc11_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc11_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::CheckBoxTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc11_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetSelected(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc11_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc11_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->SelectedChanged, ::vl::Func(this, &__vwsnc11_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc11_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc11_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->SelectedChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::CheckBoxTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc12_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc12_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::CheckBoxTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc12_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetText(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc12_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc12_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, ::vl::Func(this, &__vwsnc12_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc12_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc12_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::CheckBoxTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc13_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc13_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::CheckBoxTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc13_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>(((! ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetVisuallyEnabled()) ? ::vl::WString(L"#6D6D6D", false) : ::vl::WString(L"#F1F1F1", false))); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc13_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc13_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc13_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc13_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc13_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->VisuallyEnabledChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::CheckBoxTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc14_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc14_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::CheckBoxTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc14_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetFont(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc14_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc14_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, ::vl::Func(this, &__vwsnc14_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc14_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc14_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::CheckBoxTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::CheckItemBackgroundTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::CheckItemBackgroundTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::CheckItemBackgroundTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::darkskin::CheckItemBackgroundTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#00000000", false) : ((::vl::__vwsn::This(__vwsn_bind_cache_2)->GetSelected() || (state == ::vl::presentation::controls::ButtonState::Pressed)) ? ::vl::WString(L"#3399FF", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#3F3F46", false) : ::vl::WString(L"#00000000", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SelectedChanged, ::vl::Func(this, &__vwsnc15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SelectedChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::CheckItemBackgroundTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::CheckItemBackgroundTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::darkskin::CheckItemBackgroundTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#2D2D30", false) : (((state == ::vl::presentation::controls::ButtonState::Pressed) || ::vl::__vwsn::This(__vwsn_bind_cache_2)->GetSubMenuOpening()) ? ::vl::WString(L"#3F3F46", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#3F3F46", false) : ::vl::WString(L"#333337", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, ::vl::Func(this, &__vwsnc16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc17_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc17_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc17_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetText(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc17_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc17_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, ::vl::Func(this, &__vwsnc17_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc17_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc17_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#65655C", false) : ::vl::WString(L"#F1F1F1", false)); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc19_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc19_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc19_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetFont(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc19_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc19_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, ::vl::Func(this, &__vwsnc19_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc19_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc19_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::BottomScrollButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::BottomScrollButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::BottomScrollButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#555558", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#1997EA", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#007ACC", false) : ::vl::WString(L"#999999", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::BottomScrollButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::BottomScrollButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#00000000", false) : (((state == ::vl::presentation::controls::ButtonState::Pressed) || ::vl::__vwsn::This(__vwsn_bind_cache_2)->GetSubMenuOpening()) ? ::vl::WString(L"#007ACC", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#1F1F20", false) : ::vl::WString(L"#00000000", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, ::vl::Func(this, &__vwsnc20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#999999", false) : (((state == ::vl::presentation::controls::ButtonState::Pressed) || ::vl::__vwsn::This(__vwsn_bind_cache_2)->GetSubMenuOpening()) ? ::vl::WString(L"#FFFFFF", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#007ACC", false) : ::vl::WString(L"#999999", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, ::vl::Func(this, &__vwsnc21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#2D2D30", false) : (((state == ::vl::presentation::controls::ButtonState::Pressed) || ::vl::__vwsn::This(__vwsn_bind_cache_2)->GetSubMenuOpening()) ? ::vl::WString(L"#3F3F46", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#3F3F46", false) : ::vl::WString(L"#434346", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, ::vl::Func(this, &__vwsnc22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::darkskin::ComboBoxTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc23_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc23_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc23_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#6D6D6D", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#0A75B9", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#0A75B9", false) : ::vl::WString(L"#F1F1F1", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc23_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc23_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc23_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc23_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc23_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc23_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc23_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc24_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc24_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc24_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetSelected()) ? ::vl::WString(L"#00000000", false) : ((! ::vl::__vwsn::This(__vwsn_bind_cache_2)->GetVisuallyEnabled()) ? ::vl::WString(L"#6D6D6D", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#0A75B9", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#0A75B9", false) : ::vl::WString(L"#F1F1F1", false))))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc24_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc24_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc24_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc24_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc24_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->SelectedChanged, ::vl::Func(this, &__vwsnc24_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc24_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc24_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc24_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->SelectedChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->VisuallyEnabledChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc25_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc25_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc25_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = (! ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetSelected()); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc25_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc25_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->SelectedChanged, ::vl::Func(this, &__vwsnc25_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc25_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc25_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->SelectedChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc26_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc26_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc26_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#6D6D6D", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#0A75B9", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#0A75B9", false) : ::vl::WString(L"#F1F1F1", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc26_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc26_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc26_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc26_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc26_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc26_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc26_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc27_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc27_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc27_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetSelected()) ? ::vl::WString(L"#00000000", false) : ((! ::vl::__vwsn::This(__vwsn_bind_cache_2)->GetVisuallyEnabled()) ? ::vl::WString(L"#6D6D6D", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#0A75B9", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#0A75B9", false) : ::vl::WString(L"#F1F1F1", false))))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc27_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc27_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc27_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc27_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc27_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->SelectedChanged, ::vl::Func(this, &__vwsnc27_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc27_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc27_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc27_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->SelectedChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->VisuallyEnabledChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc28_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc28_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc28_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetSelected(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc28_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc28_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->SelectedChanged, ::vl::Func(this, &__vwsnc28_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc28_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc28_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->SelectedChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc29_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc29_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::GroupBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc29_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = [&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = (::vl::__vwsn::This(__vwsn_bind_cache_0)->GetBounds().y2 / static_cast<::vl::vint>(2)); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc29_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc29_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->titleBounds); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->BoundsChanged, ::vl::Func(this, &__vwsnc29_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc29_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc29_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->BoundsChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::BottomScrollButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::BottomScrollButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::BottomScrollButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#555558", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#1997EA", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#007ACC", false) : ::vl::WString(L"#999999", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::BottomScrollButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::BottomScrollButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc30_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc30_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::GroupBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::GroupBoxTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc30_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetText(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc30_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc30_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, ::vl::Func(this, &__vwsnc30_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc30_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc30_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::GroupBoxTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc31_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc31_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::GroupBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::GroupBoxTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc31_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetFont(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc31_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc31_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, ::vl::Func(this, &__vwsnc31_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc31_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc31_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::GroupBoxTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc32_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc32_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::HScrollHandleTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::HScrollHandleTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::HScrollHandleTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc32_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#3D3D42", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#9E9E9E", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#EFEBEF", false) : ::vl::WString(L"#686868", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc32_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc32_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc32_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc32_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc32_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc32_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc32_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::HScrollHandleTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::HScrollHandleTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc33_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc33_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::vl::presentation::compositions::GuiPartialViewComposition*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc33_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = [&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = ((::vl::__vwsn::This(__vwsn_bind_cache_0)->GetBounds().x2 - ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetBounds().x1) - ::vl::__vwsn::This(__vwsn_bind_cache_2)->GetBounds().x1); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc33_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc33_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc33_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc33_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->handleContainer); + (__vwsn_bind_cache_1 = __vwsnthis_0->handleContainer); + (__vwsn_bind_cache_2 = __vwsnthis_0->handle); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->BoundsChanged, ::vl::Func(this, &__vwsnc33_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->BoundsChanged, ::vl::Func(this, &__vwsnc33_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->BoundsChanged, ::vl::Func(this, &__vwsnc33_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc33_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc33_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->BoundsChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->BoundsChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->BoundsChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::vl::presentation::compositions::GuiPartialViewComposition*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc34_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc34_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::vl::presentation::compositions::GuiPartialViewComposition*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc34_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = [&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetBounds().x2; __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc34_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc34_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->handle); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->BoundsChanged, ::vl::Func(this, &__vwsnc34_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc34_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc34_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->BoundsChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::vl::presentation::compositions::GuiPartialViewComposition*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc35_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc35_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::HScrollTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::HScrollTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc35_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = (static_cast(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetPageSize()) / static_cast(::vl::__vwsn::This(__vwsn_bind_cache_1)->GetTotalSize())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc35_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc35_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc35_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->PageSizeChanged, ::vl::Func(this, &__vwsnc35_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->TotalSizeChanged, ::vl::Func(this, &__vwsnc35_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc35_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc35_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->PageSizeChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->TotalSizeChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::HScrollTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::HScrollTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc36_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc36_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::HScrollTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::HScrollTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc36_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = (static_cast(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetPosition()) / static_cast(::vl::__vwsn::This(__vwsn_bind_cache_1)->GetTotalSize())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc36_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc36_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc36_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->PositionChanged, ::vl::Func(this, &__vwsnc36_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->TotalSizeChanged, ::vl::Func(this, &__vwsnc36_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc36_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc36_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->PositionChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->TotalSizeChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::HScrollTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::HScrollTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::HTrackerTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::HTrackerTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::HTrackerTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + this->__vwsn_bind_cache_3 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + this->__vwsn_bind_cache_4 = static_cast<::darkskin::HTrackerTemplate*>(nullptr); + this->__vwsn_bind_cache_5 = static_cast<::darkskin::HTrackerTemplate*>(nullptr); + this->__vwsn_bind_cache_6 = static_cast<::darkskin::HTrackerTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_3_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_4_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_5_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_6_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = [&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = [&](auto width, auto max){ return ((max == static_cast<::vl::vint>(0)) ? static_cast<::vl::vint>(0) : ((width * ::vl::__vwsn::This(__vwsn_bind_cache_6)->GetPosition()) / max)); }(((::vl::__vwsn::This(__vwsn_bind_cache_0)->GetBounds().x2 - ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetBounds().x1) - (::vl::__vwsn::This(__vwsn_bind_cache_2)->GetBounds().x2 - ::vl::__vwsn::This(__vwsn_bind_cache_3)->GetBounds().x1)), (::vl::__vwsn::This(__vwsn_bind_cache_4)->GetTotalSize() - ::vl::__vwsn::This(__vwsn_bind_cache_5)->GetPageSize())); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = (- static_cast<::vl::vint>(1)); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_3_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_4_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_5_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_6_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->handle); + (__vwsn_bind_cache_3 = __vwsnthis_0->handle); + (__vwsn_bind_cache_4 = __vwsnthis_0->self); + (__vwsn_bind_cache_5 = __vwsnthis_0->self); + (__vwsn_bind_cache_6 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->BoundsChanged, ::vl::Func(this, &__vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->BoundsChanged, ::vl::Func(this, &__vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->BoundsChanged, ::vl::Func(this, &__vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + (__vwsn_bind_handler_3_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_3)->BoundsChanged, ::vl::Func(this, &__vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_3_0))); + (__vwsn_bind_handler_4_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_4)->TotalSizeChanged, ::vl::Func(this, &__vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_4_0))); + (__vwsn_bind_handler_5_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_5)->PageSizeChanged, ::vl::Func(this, &__vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_5_0))); + (__vwsn_bind_handler_6_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_6)->PositionChanged, ::vl::Func(this, &__vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_6_0))); + return true; + } + return false; + } + + bool __vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->BoundsChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->BoundsChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->BoundsChanged, __vwsn_bind_handler_2_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_3)->BoundsChanged, __vwsn_bind_handler_3_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_4)->TotalSizeChanged, __vwsn_bind_handler_4_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_5)->PageSizeChanged, __vwsn_bind_handler_5_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_6)->PositionChanged, __vwsn_bind_handler_6_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::HTrackerTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::HTrackerTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr)); + (__vwsn_bind_cache_3 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr)); + (__vwsn_bind_cache_4 = static_cast<::darkskin::HTrackerTemplate*>(nullptr)); + (__vwsn_bind_cache_5 = static_cast<::darkskin::HTrackerTemplate*>(nullptr)); + (__vwsn_bind_cache_6 = static_cast<::darkskin::HTrackerTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_3_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_4_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_5_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_6_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc38_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc38_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ItemBackgroundTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ItemBackgroundTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ItemBackgroundTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::darkskin::ItemBackgroundTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc38_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#00000000", false) : ((::vl::__vwsn::This(__vwsn_bind_cache_2)->GetSelected() || (state == ::vl::presentation::controls::ButtonState::Pressed)) ? ::vl::WString(L"#3399FF", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#3F3F46", false) : ::vl::WString(L"#00000000", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc38_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc38_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc38_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc38_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc38_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc38_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SelectedChanged, ::vl::Func(this, &__vwsnc38_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc38_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc38_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SelectedChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ItemBackgroundTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ItemBackgroundTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::darkskin::ItemBackgroundTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc39_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc39_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::LabelTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::LabelTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc39_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetText(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc39_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc39_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, ::vl::Func(this, &__vwsnc39_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc39_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc39_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::LabelTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#252526", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#54545C", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#007ACC", false) : ::vl::WString(L"#3F3F46", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc40_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc40_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::LabelTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::LabelTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::LabelTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc40_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>(((! ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetVisuallyEnabled()) ? ::vl::WString(L"#6D6D6D", false) : ::vl::__vwsn::ToString(::vl::__vwsn::This(__vwsn_bind_cache_1)->GetTextColor()))); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc40_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc40_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc40_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc40_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->TextColorChanged, ::vl::Func(this, &__vwsnc40_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc40_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc40_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->VisuallyEnabledChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->TextColorChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::LabelTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::LabelTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc41_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc41_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::LabelTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::LabelTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc41_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetFont(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc41_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc41_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, ::vl::Func(this, &__vwsnc41_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc41_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc41_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::LabelTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc42_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc42_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::LeftScrollButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::LeftScrollButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::LeftScrollButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc42_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#555558", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#1997EA", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#007ACC", false) : ::vl::WString(L"#999999", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc42_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc42_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc42_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc42_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc42_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc42_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc42_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::LeftScrollButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::LeftScrollButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc43_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc43_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::LeftScrollButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::LeftScrollButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::LeftScrollButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc43_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#555558", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#1997EA", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#007ACC", false) : ::vl::WString(L"#999999", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc43_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc43_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc43_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc43_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc43_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc43_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc43_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::LeftScrollButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::LeftScrollButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc44_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc44_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ListViewColumnHeaderTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ListViewColumnHeaderTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::darkskin::ListViewColumnHeaderTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc44_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#3E3E40", false) : (((state == ::vl::presentation::controls::ButtonState::Pressed) || ::vl::__vwsn::This(__vwsn_bind_cache_2)->GetSubMenuOpening()) ? ::vl::WString(L"#007ACC", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#3E3E40", false) : ::vl::WString(L"#252527", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc44_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc44_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc44_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc44_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc44_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc44_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, ::vl::Func(this, &__vwsnc44_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc44_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc44_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ListViewColumnHeaderTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ListViewColumnHeaderTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::darkskin::ListViewColumnHeaderTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc45_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc45_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ListViewColumnHeaderTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc45_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetText(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc45_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc45_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, ::vl::Func(this, &__vwsnc45_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc45_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc45_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ListViewColumnHeaderTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc46_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc46_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ListViewColumnHeaderTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ListViewColumnHeaderTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc46_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#6D6D6D", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#F1F1F1", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#FFFFFF", false) : ::vl::WString(L"#F1F1F1", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc46_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc46_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc46_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc46_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc46_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc46_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc46_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ListViewColumnHeaderTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ListViewColumnHeaderTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc47_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc47_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ListViewColumnHeaderTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc47_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetFont(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc47_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc47_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, ::vl::Func(this, &__vwsnc47_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc47_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc47_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ListViewColumnHeaderTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc48_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc48_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ListViewColumnHeaderTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc48_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetSubMenuExisting(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc48_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc48_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->SubMenuExistingChanged, ::vl::Func(this, &__vwsnc48_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc48_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc48_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->SubMenuExistingChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ListViewColumnHeaderTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc49_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc49_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ListViewColumnHeaderTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc49_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetSubMenuOpening(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc49_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc49_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->SubMenuOpeningChanged, ::vl::Func(this, &__vwsnc49_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc49_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc49_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->SubMenuOpeningChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ListViewColumnHeaderTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#434346", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#6A6A75", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#1C97EA", false) : ::vl::WString(L"#54545C", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc50_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc50_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuBarButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::MenuBarButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::MenuBarButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::darkskin::MenuBarButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc50_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#00000000", false) : (((state == ::vl::presentation::controls::ButtonState::Pressed) || ::vl::__vwsn::This(__vwsn_bind_cache_2)->GetSubMenuOpening()) ? ::vl::WString(L"#1B1B1C", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#3D3D40", false) : ::vl::WString(L"#00000000", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc50_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc50_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc50_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc50_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc50_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc50_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, ::vl::Func(this, &__vwsnc50_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc50_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc50_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::MenuBarButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::MenuBarButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::darkskin::MenuBarButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc51_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc51_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuBarButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::MenuBarButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc51_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetText(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc51_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc51_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, ::vl::Func(this, &__vwsnc51_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc51_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc51_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::MenuBarButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc52_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc52_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuBarButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::MenuBarButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::MenuBarButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc52_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#6D6D6D", false) : ::vl::WString(L"#FFFFFF", false)); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc52_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc52_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc52_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc52_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc52_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc52_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc52_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::MenuBarButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::MenuBarButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc53_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc53_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuBarButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::MenuBarButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc53_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetFont(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc53_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc53_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, ::vl::Func(this, &__vwsnc53_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc53_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc53_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::MenuBarButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc54_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc54_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc54_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#00000000", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#3D3D40", false) : (((state == ::vl::presentation::controls::ButtonState::Active) || ::vl::__vwsn::This(__vwsn_bind_cache_2)->GetSubMenuOpening()) ? ::vl::WString(L"#3D3D40", false) : ::vl::WString(L"#00000000", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc54_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc54_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc54_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc54_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc54_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc54_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, ::vl::Func(this, &__vwsnc54_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc54_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc54_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc55_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc55_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc55_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = [&](){ try{ return ::vl::__vwsn::This(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetImage().Obj())->GetImage(); } catch(...){ return ::vl::Ptr<::vl::presentation::INativeImage>(); } }(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc55_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc55_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->ImageChanged, ::vl::Func(this, &__vwsnc55_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc55_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc55_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->ImageChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc56_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc56_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc56_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = [&](){ try{ return ::vl::__vwsn::This(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetImage().Obj())->GetFrameIndex(); } catch(...){ return static_cast<::vl::vint>(0); } }(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc56_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc56_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->ImageChanged, ::vl::Func(this, &__vwsnc56_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc56_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc56_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->ImageChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc57_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc57_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc57_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetVisuallyEnabled(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc57_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc57_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc57_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc57_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc57_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->VisuallyEnabledChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc58_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc58_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc58_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetText(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc58_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc58_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, ::vl::Func(this, &__vwsnc58_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc58_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc58_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc59_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc59_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc59_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#6D6D6D", false) : ::vl::WString(L"#FFFFFF", false)); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc59_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc59_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc59_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc59_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc59_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc59_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc59_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc5_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc5_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc5_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetText(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc5_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc5_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, ::vl::Func(this, &__vwsnc5_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc5_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc5_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc60_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc60_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc60_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetFont(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc60_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc60_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, ::vl::Func(this, &__vwsnc60_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc60_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc60_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc61_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc61_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc61_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetShortcutText(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc61_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc61_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->ShortcutTextChanged, ::vl::Func(this, &__vwsnc61_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc61_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc61_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->ShortcutTextChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc62_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc62_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc62_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#6D6D6D", false) : ::vl::WString(L"#FFFFFF", false)); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc62_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc62_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc62_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc62_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc62_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc62_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc62_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc63_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc63_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc63_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetFont(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc63_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc63_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, ::vl::Func(this, &__vwsnc63_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc63_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc63_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc64_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc64_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc64_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#555558", false) : (((state == ::vl::presentation::controls::ButtonState::Active) || ::vl::__vwsn::This(__vwsn_bind_cache_2)->GetSubMenuOpening()) ? ::vl::WString(L"#1997EA", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#007ACC", false) : ::vl::WString(L"#999999", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc64_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc64_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc64_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc64_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc64_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc64_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, ::vl::Func(this, &__vwsnc64_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc64_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc64_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc65_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc65_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc65_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#555558", false) : (((state == ::vl::presentation::controls::ButtonState::Active) || ::vl::__vwsn::This(__vwsn_bind_cache_2)->GetSubMenuOpening()) ? ::vl::WString(L"#1997EA", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#007ACC", false) : ::vl::WString(L"#999999", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc65_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc65_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc65_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc65_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc65_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc65_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, ::vl::Func(this, &__vwsnc65_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc65_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc65_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc66_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc66_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc66_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetSubMenuExisting(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc66_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc66_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->SubMenuExistingChanged, ::vl::Func(this, &__vwsnc66_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc66_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc66_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->SubMenuExistingChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc67_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc67_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ProgressBarTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::darkskin::ProgressBarTemplate*>(nullptr); + this->__vwsn_bind_cache_3 = static_cast<::darkskin::ProgressBarTemplate*>(nullptr); + this->__vwsn_bind_cache_4 = static_cast<::darkskin::ProgressBarTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_3_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_4_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc67_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = [&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = [&](auto width, auto max){ return ((max == static_cast<::vl::vint>(0)) ? static_cast<::vl::vint>(0) : (width - ((width * ::vl::__vwsn::This(__vwsn_bind_cache_4)->GetPosition()) / max))); }((::vl::__vwsn::This(__vwsn_bind_cache_0)->GetBounds().x2 - ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetBounds().x1), (::vl::__vwsn::This(__vwsn_bind_cache_2)->GetTotalSize() - ::vl::__vwsn::This(__vwsn_bind_cache_3)->GetPageSize())); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc67_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc67_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc67_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc67_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_3_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc67_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_4_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc67_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->container); + (__vwsn_bind_cache_1 = __vwsnthis_0->container); + (__vwsn_bind_cache_2 = __vwsnthis_0->self); + (__vwsn_bind_cache_3 = __vwsnthis_0->self); + (__vwsn_bind_cache_4 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->BoundsChanged, ::vl::Func(this, &__vwsnc67_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->BoundsChanged, ::vl::Func(this, &__vwsnc67_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->TotalSizeChanged, ::vl::Func(this, &__vwsnc67_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + (__vwsn_bind_handler_3_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_3)->PageSizeChanged, ::vl::Func(this, &__vwsnc67_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_3_0))); + (__vwsn_bind_handler_4_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_4)->PositionChanged, ::vl::Func(this, &__vwsnc67_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_4_0))); + return true; + } + return false; + } + + bool __vwsnc67_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc67_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->BoundsChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->BoundsChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->TotalSizeChanged, __vwsn_bind_handler_2_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_3)->PageSizeChanged, __vwsn_bind_handler_3_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_4)->PositionChanged, __vwsn_bind_handler_4_0); + (__vwsn_bind_cache_0 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::darkskin::ProgressBarTemplate*>(nullptr)); + (__vwsn_bind_cache_3 = static_cast<::darkskin::ProgressBarTemplate*>(nullptr)); + (__vwsn_bind_cache_4 = static_cast<::darkskin::ProgressBarTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_3_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_4_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc68_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc68_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::RadioButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::RadioButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc68_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#252526", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#54545C", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#007ACC", false) : ::vl::WString(L"#3F3F46", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc68_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc68_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc68_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc68_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc68_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc68_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc68_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::RadioButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::RadioButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc69_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc69_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::RadioButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::RadioButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc69_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#434346", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#6A6A75", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#1C97EA", false) : ::vl::WString(L"#54545C", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc69_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc69_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc69_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc69_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc69_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc69_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc69_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::RadioButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::RadioButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#6D6D6D", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#F1F1F1", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#FFFFFF", false) : ::vl::WString(L"#F1F1F1", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc70_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc70_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::RadioButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::RadioButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc70_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#6D6D6D", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#F1F1F1", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#FFFFFF", false) : ::vl::WString(L"#F1F1F1", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc70_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc70_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc70_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc70_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc70_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc70_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc70_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::RadioButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::RadioButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc71_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc71_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::RadioButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc71_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetSelected(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc71_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc71_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->SelectedChanged, ::vl::Func(this, &__vwsnc71_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc71_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc71_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->SelectedChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::RadioButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc72_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc72_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::RadioButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc72_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetText(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc72_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc72_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, ::vl::Func(this, &__vwsnc72_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc72_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc72_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::RadioButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc73_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc73_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::RadioButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc73_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>(((! ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetVisuallyEnabled()) ? ::vl::WString(L"#6D6D6D", false) : ::vl::WString(L"#F1F1F1", false))); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc73_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc73_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc73_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc73_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc73_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->VisuallyEnabledChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::RadioButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc74_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc74_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::RadioButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc74_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetFont(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc74_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc74_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, ::vl::Func(this, &__vwsnc74_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc74_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc74_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::RadioButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc75_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc75_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::RightScrollButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::RightScrollButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::RightScrollButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc75_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#555558", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#1997EA", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#007ACC", false) : ::vl::WString(L"#999999", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc75_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc75_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc75_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc75_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc75_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc75_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc75_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::RightScrollButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::RightScrollButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc76_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc76_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::RightScrollButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::RightScrollButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::RightScrollButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc76_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#555558", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#1997EA", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#007ACC", false) : ::vl::WString(L"#999999", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc76_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc76_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc76_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc76_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc76_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc76_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc76_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::RightScrollButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::RightScrollButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc77_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc77_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ShortcutKeyTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ShortcutKeyTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc77_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetText(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc77_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc77_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, ::vl::Func(this, &__vwsnc77_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc77_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc77_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ShortcutKeyTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc78_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc78_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ShortcutKeyTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ShortcutKeyTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc78_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetTextColor(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc78_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc78_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextColorChanged, ::vl::Func(this, &__vwsnc78_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc78_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc78_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextColorChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ShortcutKeyTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc79_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc79_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ShortcutKeyTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ShortcutKeyTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc79_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetFont(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc79_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc79_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, ::vl::Func(this, &__vwsnc79_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc79_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc79_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ShortcutKeyTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc7_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc7_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc7_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetFont(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc7_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc7_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, ::vl::Func(this, &__vwsnc7_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc7_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc7_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc80_DarkSkin_darkskin_TabDropdownTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc80_DarkSkin_darkskin_TabDropdownTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::TabDropdownTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::TabDropdownTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc80_DarkSkin_darkskin_TabDropdownTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#1C97EA", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#1C97EA", false) : ::vl::WString(L"#434346", false))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc80_DarkSkin_darkskin_TabDropdownTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc80_DarkSkin_darkskin_TabDropdownTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc80_DarkSkin_darkskin_TabDropdownTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc80_DarkSkin_darkskin_TabDropdownTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc80_DarkSkin_darkskin_TabDropdownTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::TabDropdownTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc81_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc81_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::TabHeaderTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::TabHeaderTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::TabHeaderTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc81_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return (::vl::__vwsn::This(__vwsn_bind_cache_1)->GetSelected() ? ::vl::WString(L"#007ACC", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#1C97EA", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#1C97EA", false) : ::vl::WString(L"#434346", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc81_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc81_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc81_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc81_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->SelectedChanged, ::vl::Func(this, &__vwsnc81_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc81_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc81_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->SelectedChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::TabHeaderTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::TabHeaderTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc82_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc82_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::TabHeaderTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::TabHeaderTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc82_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetText(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc82_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc82_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, ::vl::Func(this, &__vwsnc82_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc82_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc82_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->TextChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::TabHeaderTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc83_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc83_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::TabHeaderTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::TabHeaderTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::TabHeaderTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc83_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#6D6D6D", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#F1F1F1", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#FFFFFF", false) : ::vl::WString(L"#F1F1F1", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc83_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc83_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc83_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc83_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc83_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc83_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc83_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::TabHeaderTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::TabHeaderTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc84_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc84_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::TabHeaderTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::TabHeaderTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc84_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetFont(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc84_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc84_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, ::vl::Func(this, &__vwsnc84_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc84_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc84_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->FontChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::TabHeaderTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc85_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc85_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripSplitArrowTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripSplitArrowTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripSplitArrowTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::darkskin::ToolstripSplitArrowTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc85_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#00000000", false) : (((state == ::vl::presentation::controls::ButtonState::Pressed) || ::vl::__vwsn::This(__vwsn_bind_cache_2)->GetSelected()) ? ::vl::WString(L"#007ACC", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#54545C", false) : ::vl::WString(L"#00000000", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc85_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc85_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc85_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc85_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc85_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc85_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SelectedChanged, ::vl::Func(this, &__vwsnc85_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc85_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc85_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SelectedChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripSplitArrowTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripSplitArrowTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::darkskin::ToolstripSplitArrowTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc86_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc86_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripSplitArrowTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripSplitArrowTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripSplitArrowTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::darkskin::ToolstripSplitArrowTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc86_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#555558", false) : (((state == ::vl::presentation::controls::ButtonState::Pressed) || ::vl::__vwsn::This(__vwsn_bind_cache_2)->GetSelected()) ? ::vl::WString(L"#FFFFFF", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#1997EA", false) : ::vl::WString(L"#999999", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc86_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc86_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc86_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc86_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc86_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc86_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SelectedChanged, ::vl::Func(this, &__vwsnc86_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc86_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc86_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SelectedChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripSplitArrowTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripSplitArrowTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::darkskin::ToolstripSplitArrowTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc87_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc87_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripSplitArrowTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripSplitArrowTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripSplitArrowTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::darkskin::ToolstripSplitArrowTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc87_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#555558", false) : (((state == ::vl::presentation::controls::ButtonState::Pressed) || ::vl::__vwsn::This(__vwsn_bind_cache_2)->GetSelected()) ? ::vl::WString(L"#FFFFFF", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#1997EA", false) : ::vl::WString(L"#999999", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc87_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc87_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc87_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc87_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc87_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc87_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SelectedChanged, ::vl::Func(this, &__vwsnc87_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc87_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc87_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SelectedChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripSplitArrowTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripSplitArrowTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::darkskin::ToolstripSplitArrowTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc88_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc88_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc88_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetSelected()) ? ::vl::WString(L"#00000000", false) : ::vl::WString(L"#007ACC", false)); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc88_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc88_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc88_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc88_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->SelectedChanged, ::vl::Func(this, &__vwsnc88_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc88_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc88_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->SelectedChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc89_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc89_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::darkskin::ToolstripButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc89_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#00000000", false) : (((state == ::vl::presentation::controls::ButtonState::Pressed) || ::vl::__vwsn::This(__vwsn_bind_cache_2)->GetSubMenuOpening()) ? ::vl::WString(L"#007ACC", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#54545C", false) : ::vl::WString(L"#00000000", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc89_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc89_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc89_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc89_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc89_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc89_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, ::vl::Func(this, &__vwsnc89_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc89_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc89_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::darkskin::ToolstripButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::CheckBoxTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::CheckBoxTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#252526", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#54545C", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#007ACC", false) : ::vl::WString(L"#3F3F46", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::CheckBoxTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::CheckBoxTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc90_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc90_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc90_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = [&](){ try{ return ::vl::__vwsn::This(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetImage().Obj())->GetImage(); } catch(...){ return ::vl::Ptr<::vl::presentation::INativeImage>(); } }(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc90_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc90_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->ImageChanged, ::vl::Func(this, &__vwsnc90_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc90_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc90_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->ImageChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc91_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc91_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc91_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = [&](){ try{ return ::vl::__vwsn::This(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetImage().Obj())->GetFrameIndex(); } catch(...){ return static_cast<::vl::vint>(0); } }(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc91_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc91_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->ImageChanged, ::vl::Func(this, &__vwsnc91_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc91_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc91_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->ImageChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc92_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc92_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc92_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetVisuallyEnabled(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc92_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc92_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc92_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc92_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc92_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->VisuallyEnabledChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc93_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc93_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc93_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetSelected()) ? ::vl::WString(L"#00000000", false) : ::vl::WString(L"#007ACC", false)); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc93_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc93_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc93_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc93_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->SelectedChanged, ::vl::Func(this, &__vwsnc93_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc93_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc93_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->SelectedChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc94_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc94_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc94_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#00000000", false) : (((state == ::vl::presentation::controls::ButtonState::Pressed) || ::vl::__vwsn::This(__vwsn_bind_cache_2)->GetSubMenuOpening()) ? ::vl::WString(L"#007ACC", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#54545C", false) : ::vl::WString(L"#00000000", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc94_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc94_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc94_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc94_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc94_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc94_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, ::vl::Func(this, &__vwsnc94_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc94_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc94_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc95_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc95_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc95_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = [&](){ try{ return ::vl::__vwsn::This(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetImage().Obj())->GetImage(); } catch(...){ return ::vl::Ptr<::vl::presentation::INativeImage>(); } }(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc95_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc95_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->ImageChanged, ::vl::Func(this, &__vwsnc95_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc95_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc95_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->ImageChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc96_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc96_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc96_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = [&](){ try{ return ::vl::__vwsn::This(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetImage().Obj())->GetFrameIndex(); } catch(...){ return static_cast<::vl::vint>(0); } }(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc96_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc96_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->ImageChanged, ::vl::Func(this, &__vwsnc96_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc96_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc96_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->ImageChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc97_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc97_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc97_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::This(__vwsn_bind_cache_0)->GetVisuallyEnabled(); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc97_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc97_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc97_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + return true; + } + return false; + } + + bool __vwsnc97_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc97_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->VisuallyEnabledChanged, __vwsn_bind_handler_0_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc98_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc98_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc98_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#00000000", false) : (((state == ::vl::presentation::controls::ButtonState::Pressed) || ::vl::__vwsn::This(__vwsn_bind_cache_2)->GetSubMenuOpening()) ? ::vl::WString(L"#007ACC", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#54545C", false) : ::vl::WString(L"#00000000", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc98_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc98_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc98_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc98_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc98_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc98_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, ::vl::Func(this, &__vwsnc98_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc98_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc98_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc99_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc99_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr); + this->__vwsn_bind_cache_2 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc99_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#555558", false) : (((state == ::vl::presentation::controls::ButtonState::Pressed) || ::vl::__vwsn::This(__vwsn_bind_cache_2)->GetSubMenuOpening()) ? ::vl::WString(L"#FFFFFF", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#1997EA", false) : ::vl::WString(L"#999999", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc99_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc99_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc99_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc99_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_cache_2 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc99_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc99_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + (__vwsn_bind_handler_2_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, ::vl::Func(this, &__vwsnc99_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_2_0))); + return true; + } + return false; + } + + bool __vwsnc99_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc99_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_2)->SubMenuOpeningChanged, __vwsn_bind_handler_2_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr)); + (__vwsn_bind_cache_2 = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_2_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + + //------------------------------------------------------------------- + + __vwsnc9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsnc9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0) + :__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0)) + { + this->__vwsn_bind_cache_0 = static_cast<::darkskin::CheckBoxTemplate*>(nullptr); + this->__vwsn_bind_cache_1 = static_cast<::darkskin::CheckBoxTemplate*>(nullptr); + this->__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>(); + this->__vwsn_bind_opened_ = false; + this->__vwsn_bind_closed_ = false; + } + + void __vwsnc9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_activator_() + { + auto __vwsn_bind_activator_result_ = ::vl::__vwsn::Parse<::vl::presentation::Color>([&](auto state){ return ((! ::vl::__vwsn::This(__vwsn_bind_cache_1)->GetVisuallyEnabled()) ? ::vl::WString(L"#434346", false) : ((state == ::vl::presentation::controls::ButtonState::Active) ? ::vl::WString(L"#6A6A75", false) : ((state == ::vl::presentation::controls::ButtonState::Pressed) ? ::vl::WString(L"#1C97EA", false) : ::vl::WString(L"#54545C", false)))); }(::vl::__vwsn::This(__vwsn_bind_cache_0)->GetState())); + ::vl::__vwsn::EventInvoke(this->ValueChanged)(::vl::__vwsn::Box(__vwsn_bind_activator_result_)); + } + + void __vwsnc9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + void __vwsnc9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1) + { + this->__vwsn_bind_activator_(); + } + + bool __vwsnc9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Open() + { + if ((! __vwsn_bind_opened_)) + { + (__vwsn_bind_opened_ = true); + (__vwsn_bind_cache_0 = __vwsnthis_0->self); + (__vwsn_bind_cache_1 = __vwsnthis_0->self); + (__vwsn_bind_handler_0_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, ::vl::Func(this, &__vwsnc9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_0_0))); + (__vwsn_bind_handler_1_0 = ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, ::vl::Func(this, &__vwsnc9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::__vwsn_bind_callback_1_0))); + return true; + } + return false; + } + + bool __vwsnc9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Update() + { + if ((__vwsn_bind_opened_ && (! __vwsn_bind_closed_))) + { + this->__vwsn_bind_activator_(); + return true; + } + return false; + } + + bool __vwsnc9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription::Close() + { + if ((! __vwsn_bind_closed_)) + { + (__vwsn_bind_closed_ = true); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_0)->StateChanged, __vwsn_bind_handler_0_0); + ::vl::__vwsn::EventDetach(::vl::__vwsn::This(__vwsn_bind_cache_1)->VisuallyEnabledChanged, __vwsn_bind_handler_1_0); + (__vwsn_bind_cache_0 = static_cast<::darkskin::CheckBoxTemplate*>(nullptr)); + (__vwsn_bind_cache_1 = static_cast<::darkskin::CheckBoxTemplate*>(nullptr)); + (__vwsn_bind_handler_0_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + (__vwsn_bind_handler_1_0 = ::vl::Ptr<::vl::reflection::description::IEventHandler>()); + return true; + } + return false; + } + +} + +/*********************************************************************** +Class (::darkskin::BottomScrollButtonTemplateConstructor) +***********************************************************************/ + +namespace darkskin +{ + void BottomScrollButtonTemplateConstructor::__vwsn_initialize_instance_(::darkskin::BottomScrollButtonTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = new ::vl::presentation::compositions::GuiTableComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowsAndColumns(static_cast<::vl::vint>(3), static_cast<::vl::vint>(3)); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetColumnOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetColumnOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(9); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetColumnOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + } + (this->__vwsn_precompile_1 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + (this->__vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiPolygonElement>())); + { + [&]()->decltype(auto){ auto __vwsn_temp_x0 = ::vl::__vwsn::Box(::vl::Ptr<::vl::reflection::description::IValueReadonlyList>((::vl::__vwsn::CreateList().Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(0); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }()).Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(4); __vwsn_temp__.y = static_cast<::vl::vint>(4); return __vwsn_temp__; }()).Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(8); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }())).list)); ::vl::collections::Array<::vl::presentation::Point> __vwsn_temp_0; ::vl::reflection::description::UnboxParameter(__vwsn_temp_x0, __vwsn_temp_0); return ::vl::__vwsn::This(this->__vwsn_precompile_2.Obj())->SetPointsArray(__vwsn_temp_0); }(); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2.Obj())->SetSize([&](){ ::vl::presentation::Size __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(9); __vwsn_temp__.y = static_cast<::vl::vint>(5); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_2)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_1)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_0)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + } + + BottomScrollButtonTemplateConstructor::BottomScrollButtonTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::BottomScrollButtonTemplate) +***********************************************************************/ + + BottomScrollButtonTemplate::BottomScrollButtonTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::BottomScrollButtonTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + BottomScrollButtonTemplate::~BottomScrollButtonTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::ButtonTemplateConstructor) +***********************************************************************/ + + void ButtonTemplateConstructor::__vwsn_initialize_instance_(::darkskin::ButtonTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->__vwsn_precompile_1 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_2)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_1)); + } + (this->__vwsn_precompile_3 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(3); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(3); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_4 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidLabelElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_4.Obj())->SetVerticalAlignment(::vl::presentation::Alignment::Center); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_4.Obj())->SetHorizontalAlignment(::vl::presentation::Alignment::Center); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_4)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_3)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc5_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf5_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc7_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf7_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + } + + ButtonTemplateConstructor::ButtonTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::ButtonTemplate) +***********************************************************************/ + + ButtonTemplate::ButtonTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::ButtonTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + ButtonTemplate::~ButtonTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::CheckBoxTemplateConstructor) +***********************************************************************/ + + void CheckBoxTemplateConstructor::__vwsn_initialize_instance_(::darkskin::CheckBoxTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = new ::vl::presentation::compositions::GuiTableComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowsAndColumns(static_cast<::vl::vint>(3), static_cast<::vl::vint>(2)); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(1.0); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(17); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(1.0); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetColumnOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(17); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetColumnOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(1.0); return __vwsn_temp__; }()); + } + (this->__vwsn_precompile_1 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(0), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + (this->__vwsn_precompile_2 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(2); __vwsn_temp__.top = static_cast<::vl::vint>(2); __vwsn_temp__.right = static_cast<::vl::vint>(2); __vwsn_temp__.bottom = static_cast<::vl::vint>(2); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_3)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_2)); + } + (this->__vwsn_precompile_4 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(2); __vwsn_temp__.top = static_cast<::vl::vint>(2); __vwsn_temp__.right = static_cast<::vl::vint>(2); __vwsn_temp__.bottom = static_cast<::vl::vint>(2); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_5 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_5)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_4)); + } + (this->__vwsn_precompile_6 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_6)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_6)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_7 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidLabelElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_7.Obj())->SetVerticalAlignment(::vl::presentation::Alignment::Center); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_7.Obj())->SetHorizontalAlignment(::vl::presentation::Alignment::Center); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_7.Obj())->SetFont([&](){ ::vl::presentation::FontProperties __vwsn_temp__; __vwsn_temp__.fontFamily = ::vl::WString(L"Webdings", false); __vwsn_temp__.size = static_cast<::vl::vint>(16); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_7.Obj())->SetText(::vl::WString(L"a", false)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_6)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_7)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_6)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_1)); + } + (this->__vwsn_precompile_8 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_8)->SetSite(static_cast<::vl::vint>(0), static_cast<::vl::vint>(1), static_cast<::vl::vint>(3), static_cast<::vl::vint>(1)); + } + (this->__vwsn_precompile_9 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_9)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(3); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(3); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_9)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_10 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidLabelElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_10.Obj())->SetVerticalAlignment(::vl::presentation::Alignment::Center); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_10.Obj())->SetHorizontalAlignment(::vl::presentation::Alignment::Left); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_9)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_10)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_8)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_9)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_8)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_0)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc11_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf11_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc12_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf12_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc13_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf13_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc14_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf14_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + } + + CheckBoxTemplateConstructor::CheckBoxTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::CheckBoxTemplate) +***********************************************************************/ + + CheckBoxTemplate::CheckBoxTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::CheckBoxTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + CheckBoxTemplate::~CheckBoxTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::CheckItemBackgroundTemplateConstructor) +***********************************************************************/ + + void CheckItemBackgroundTemplateConstructor::__vwsn_initialize_instance_(::darkskin::CheckItemBackgroundTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->container = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->container)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(2); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + ::vl::__vwsn::This(this->self)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + } + + CheckItemBackgroundTemplateConstructor::CheckItemBackgroundTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::CheckItemBackgroundTemplate) +***********************************************************************/ + + CheckItemBackgroundTemplate::CheckItemBackgroundTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::CheckItemBackgroundTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + CheckItemBackgroundTemplate::~CheckItemBackgroundTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::ComboBoxTemplateConstructor) +***********************************************************************/ + + void ComboBoxTemplateConstructor::__vwsn_initialize_instance_(::darkskin::ComboBoxTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetDatePickerTemplate(LAMBDA(::vl_workflow_global::__vwsnf16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetSubMenuTemplate(LAMBDA(::vl_workflow_global::__vwsnf17_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->__vwsn_precompile_1 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#434346", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_2)); + } + (this->container = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->container)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(1); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(11); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_3 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(2); __vwsn_temp__.top = static_cast<::vl::vint>(2); __vwsn_temp__.right = static_cast<::vl::vint>(2); __vwsn_temp__.bottom = static_cast<::vl::vint>(2); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_4 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidLabelElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_4.Obj())->SetEllipse(::vl::__vwsn::Parse(::vl::WString(L"true", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_4.Obj())->SetVerticalAlignment(::vl::presentation::Alignment::Center); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_4.Obj())->SetHorizontalAlignment(::vl::presentation::Alignment::Left); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_4)); + } + { + ::vl::__vwsn::This(this->container)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_3)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + (this->__vwsn_precompile_5 = new ::vl::presentation::compositions::GuiTableComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetPreferredMinSize([&](){ ::vl::presentation::Size __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(9); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = (- static_cast<::vl::vint>(1)); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(1); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetRowsAndColumns(static_cast<::vl::vint>(3), static_cast<::vl::vint>(3)); + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetRowOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetRowOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(3); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetRowOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetColumnOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetColumnOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetColumnOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + } + (this->__vwsn_precompile_6 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_6)); + } + (this->__vwsn_precompile_7 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_7)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + (this->__vwsn_precompile_8 = ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiPolygonElement>())); + { + [&]()->decltype(auto){ auto __vwsn_temp_x0 = ::vl::__vwsn::Box(::vl::Ptr<::vl::reflection::description::IValueReadonlyList>((::vl::__vwsn::CreateList().Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(0); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }()).Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(2); __vwsn_temp__.y = static_cast<::vl::vint>(2); return __vwsn_temp__; }()).Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(4); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }())).list)); ::vl::collections::Array<::vl::presentation::Point> __vwsn_temp_0; ::vl::reflection::description::UnboxParameter(__vwsn_temp_x0, __vwsn_temp_0); return ::vl::__vwsn::This(this->__vwsn_precompile_8.Obj())->SetPointsArray(__vwsn_temp_0); }(); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_8.Obj())->SetSize([&](){ ::vl::presentation::Size __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(5); __vwsn_temp__.y = static_cast<::vl::vint>(3); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_7)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_8)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_7)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_5)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_1)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc17_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf19_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc19_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf23_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf24_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + ::vl::__vwsn::This(this->self)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + } + + ComboBoxTemplateConstructor::ComboBoxTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::ComboBoxTemplate) +***********************************************************************/ + + ComboBoxTemplate::ComboBoxTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::ComboBoxTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + ComboBoxTemplate::~ComboBoxTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::CustomControlTemplateConstructor) +***********************************************************************/ + + void CustomControlTemplateConstructor::__vwsn_initialize_instance_(::darkskin::CustomControlTemplate* __vwsn_this_) + { + (this->__vwsn_precompile_0 = __vwsn_this_); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + } + + CustomControlTemplateConstructor::CustomControlTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::CustomControlTemplate) +***********************************************************************/ + + CustomControlTemplate::CustomControlTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::CustomControlTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + CustomControlTemplate::~CustomControlTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::ThemeConstructor) +***********************************************************************/ + + void ThemeConstructor::__vwsn_initialize_instance_(::darkskin::Theme* __vwsn_this_) + { + (this->__vwsn_precompile_0 = __vwsn_this_); + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->progressBar = LAMBDA(::vl_workflow_global::__vwsnf25_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->vTracker = LAMBDA(::vl_workflow_global::__vwsnf26_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->hTracker = LAMBDA(::vl_workflow_global::__vwsnf27_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->vScroll = LAMBDA(::vl_workflow_global::__vwsnf28_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->hScroll = LAMBDA(::vl_workflow_global::__vwsnf29_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->datePicker = LAMBDA(::vl_workflow_global::__vwsnf30_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->radioButton = LAMBDA(::vl_workflow_global::__vwsnf31_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->checkBox = LAMBDA(::vl_workflow_global::__vwsnf32_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->button = LAMBDA(::vl_workflow_global::__vwsnf33_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->toolBarSplitter = LAMBDA(::vl_workflow_global::__vwsnf34_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->toolBarSplitButton = LAMBDA(::vl_workflow_global::__vwsnf35_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->toolBarDropdownButton = LAMBDA(::vl_workflow_global::__vwsnf36_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->toolBarButton = LAMBDA(::vl_workflow_global::__vwsnf37_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->toolBar = LAMBDA(::vl_workflow_global::__vwsnf38_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->menuItemButton = LAMBDA(::vl_workflow_global::__vwsnf39_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->menuBarButton = LAMBDA(::vl_workflow_global::__vwsnf40_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->menuSplitter = LAMBDA(::vl_workflow_global::__vwsnf41_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->menuBar = LAMBDA(::vl_workflow_global::__vwsnf42_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->menu = LAMBDA(::vl_workflow_global::__vwsnf43_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->textList = LAMBDA(::vl_workflow_global::__vwsnf44_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->treeView = LAMBDA(::vl_workflow_global::__vwsnf45_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->listView = LAMBDA(::vl_workflow_global::__vwsnf46_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->documentTextBox = LAMBDA(::vl_workflow_global::__vwsnf47_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->documentLabel = LAMBDA(::vl_workflow_global::__vwsnf48_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->documentViewer = LAMBDA(::vl_workflow_global::__vwsnf49_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->singlelineTextBox = LAMBDA(::vl_workflow_global::__vwsnf50_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->multilineTextBox = LAMBDA(::vl_workflow_global::__vwsnf51_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->comboBox = LAMBDA(::vl_workflow_global::__vwsnf52_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->tab = LAMBDA(::vl_workflow_global::__vwsnf53_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->groupBox = LAMBDA(::vl_workflow_global::__vwsnf54_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->scrollView = LAMBDA(::vl_workflow_global::__vwsnf55_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->shortcutKey = LAMBDA(::vl_workflow_global::__vwsnf56_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->label = LAMBDA(::vl_workflow_global::__vwsnf57_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->tooltip = LAMBDA(::vl_workflow_global::__vwsnf58_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->customControl = LAMBDA(::vl_workflow_global::__vwsnf59_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + { + (::vl::__vwsn::This(this->__vwsn_precompile_0)->window = LAMBDA(::vl_workflow_global::__vwsnf60_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(this))); + } + } + + ThemeConstructor::ThemeConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::Theme) +***********************************************************************/ + + Theme::Theme() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::Theme", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + Theme::~Theme() + { + this->FinalizeGeneralInstance(static_cast<::vl::presentation::controls::GuiInstanceRootObject*>(this)); + } + +/*********************************************************************** +Class (::darkskin::DatePickerTemplateConstructor) +***********************************************************************/ + + void DatePickerTemplateConstructor::__vwsn_initialize_instance_(::darkskin::DatePickerTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetSecondaryTextColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#999999", false))); + } + { + ::vl::__vwsn::This(this->self)->SetPrimaryTextColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#FFFFFF", false))); + } + { + ::vl::__vwsn::This(this->self)->SetDateComboBoxTemplate(LAMBDA(::vl_workflow_global::__vwsnf61_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetDateTextListTemplate(LAMBDA(::vl_workflow_global::__vwsnf62_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetDateButtonTemplate(LAMBDA(::vl_workflow_global::__vwsnf63_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetBackgroundColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#2D2D30", false))); + } + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + } + + DatePickerTemplateConstructor::DatePickerTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::DatePickerTemplate) +***********************************************************************/ + + DatePickerTemplate::DatePickerTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::DatePickerTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + DatePickerTemplate::~DatePickerTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::DocumentLabelTemplateConstructor) +***********************************************************************/ + + void DocumentLabelTemplateConstructor::__vwsn_initialize_instance_(::darkskin::DocumentLabelTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetCaretColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#FFFFFF", false))); + } + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->self)->SetBaselineDocument(::vl::__vwsn::Ensure(::vl::__vwsn::SharedPtrCast<::vl::presentation::DocumentModel>(::vl::__vwsn::This(__vwsn_this_)->ResolveResource(::vl::WString(L"res", false), ::vl::WString(L"DarkSkin/BaselineDocument", false), true).Obj()))); + } + } + + DocumentLabelTemplateConstructor::DocumentLabelTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::DocumentLabelTemplate) +***********************************************************************/ + + DocumentLabelTemplate::DocumentLabelTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::DocumentLabelTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + DocumentLabelTemplate::~DocumentLabelTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::DocumentTextBoxTemplateConstructor) +***********************************************************************/ + + void DocumentTextBoxTemplateConstructor::__vwsn_initialize_instance_(::darkskin::DocumentTextBoxTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetCaretColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#FFFFFF", false))); + } + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#252526", false))); + } + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->container = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->container)->SetInternalMargin([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(1); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(1); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#3F3F46", false))); + } + { + ::vl::__vwsn::This(this->container)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_1)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + { + ::vl::__vwsn::This(this->self)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + { + ::vl::__vwsn::This(this->self)->SetBaselineDocument(::vl::__vwsn::Ensure(::vl::__vwsn::SharedPtrCast<::vl::presentation::DocumentModel>(::vl::__vwsn::This(__vwsn_this_)->ResolveResource(::vl::WString(L"res", false), ::vl::WString(L"DarkSkin/BaselineDocument", false), true).Obj()))); + } + } + + DocumentTextBoxTemplateConstructor::DocumentTextBoxTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::DocumentTextBoxTemplate) +***********************************************************************/ + + DocumentTextBoxTemplate::DocumentTextBoxTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::DocumentTextBoxTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + DocumentTextBoxTemplate::~DocumentTextBoxTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::DocumentViewerTemplateConstructor) +***********************************************************************/ + + void DocumentViewerTemplateConstructor::__vwsn_initialize_instance_(::darkskin::DocumentViewerTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetDefaultScrollSize(::vl::__vwsn::Parse<::vl::vint>(::vl::WString(L"20", false))); + } + { + ::vl::__vwsn::This(this->self)->SetVScrollTemplate(LAMBDA(::vl_workflow_global::__vwsnf64_DarkSkin_darkskin_DocumentViewerTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetHScrollTemplate(LAMBDA(::vl_workflow_global::__vwsnf65_DarkSkin_darkskin_DocumentViewerTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetCaretColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#FFFFFF", false))); + } + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#252526", false))); + } + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->container = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->container)->SetInternalMargin([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(1); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(1); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#3F3F46", false))); + } + { + ::vl::__vwsn::This(this->container)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_1)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + { + ::vl::__vwsn::This(this->self)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + { + ::vl::__vwsn::This(this->self)->SetBaselineDocument(::vl::__vwsn::Ensure(::vl::__vwsn::SharedPtrCast<::vl::presentation::DocumentModel>(::vl::__vwsn::This(__vwsn_this_)->ResolveResource(::vl::WString(L"res", false), ::vl::WString(L"DarkSkin/BaselineDocument", false), true).Obj()))); + } + } + + DocumentViewerTemplateConstructor::DocumentViewerTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::DocumentViewerTemplate) +***********************************************************************/ + + DocumentViewerTemplate::DocumentViewerTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::DocumentViewerTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + DocumentViewerTemplate::~DocumentViewerTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::ExpandingDecoratorTemplateConstructor) +***********************************************************************/ + + void ExpandingDecoratorTemplateConstructor::__vwsn_initialize_instance_(::darkskin::ExpandingDecoratorTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = new ::vl::presentation::compositions::GuiTableComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowsAndColumns(static_cast<::vl::vint>(3), static_cast<::vl::vint>(3)); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(9); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetColumnOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetColumnOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(7); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetColumnOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + } + (this->__vwsn_precompile_1 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + (this->__vwsn_precompile_2 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiPolygonElement>())); + { + [&]()->decltype(auto){ auto __vwsn_temp_x0 = ::vl::__vwsn::Box(::vl::Ptr<::vl::reflection::description::IValueReadonlyList>((::vl::__vwsn::CreateList().Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(1); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }()).Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(5); __vwsn_temp__.y = static_cast<::vl::vint>(4); return __vwsn_temp__; }()).Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(1); __vwsn_temp__.y = static_cast<::vl::vint>(8); return __vwsn_temp__; }())).list)); ::vl::collections::Array<::vl::presentation::Point> __vwsn_temp_0; ::vl::reflection::description::UnboxParameter(__vwsn_temp_x0, __vwsn_temp_0); return ::vl::__vwsn::This(this->__vwsn_precompile_3.Obj())->SetPointsArray(__vwsn_temp_0); }(); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3.Obj())->SetSize([&](){ ::vl::presentation::Size __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(7); __vwsn_temp__.y = static_cast<::vl::vint>(9); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_3)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_2)); + } + (this->__vwsn_precompile_4 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_5 = ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiPolygonElement>())); + { + [&]()->decltype(auto){ auto __vwsn_temp_x0 = ::vl::__vwsn::Box(::vl::Ptr<::vl::reflection::description::IValueReadonlyList>((::vl::__vwsn::CreateList().Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(5); __vwsn_temp__.y = static_cast<::vl::vint>(2); return __vwsn_temp__; }()).Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(5); __vwsn_temp__.y = static_cast<::vl::vint>(7); return __vwsn_temp__; }()).Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(0); __vwsn_temp__.y = static_cast<::vl::vint>(7); return __vwsn_temp__; }())).list)); ::vl::collections::Array<::vl::presentation::Point> __vwsn_temp_0; ::vl::reflection::description::UnboxParameter(__vwsn_temp_x0, __vwsn_temp_0); return ::vl::__vwsn::This(this->__vwsn_precompile_5.Obj())->SetPointsArray(__vwsn_temp_0); }(); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_5.Obj())->SetSize([&](){ ::vl::presentation::Size __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(7); __vwsn_temp__.y = static_cast<::vl::vint>(9); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_5)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_4)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_1)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_0)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc23_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf66_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc24_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf67_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc25_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf68_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc26_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf69_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc27_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf70_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc28_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf71_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + } + + ExpandingDecoratorTemplateConstructor::ExpandingDecoratorTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::ExpandingDecoratorTemplate) +***********************************************************************/ + + ExpandingDecoratorTemplate::ExpandingDecoratorTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::ExpandingDecoratorTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + ExpandingDecoratorTemplate::~ExpandingDecoratorTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::GroupBoxTemplateConstructor) +***********************************************************************/ + + void GroupBoxTemplateConstructor::__vwsn_initialize_instance_(::darkskin::GroupBoxTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#2D2D30", false))); + } + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->__vwsn_precompile_1 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#3F3F46", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_2)); + } + (this->container = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->container)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(1); __vwsn_temp__.top = static_cast<::vl::vint>(5); __vwsn_temp__.right = static_cast<::vl::vint>(1); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_1)); + } + (this->titleBounds = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->titleBounds)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(5); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = (- static_cast<::vl::vint>(1)); __vwsn_temp__.bottom = (- static_cast<::vl::vint>(1)); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->titleBounds)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_3.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#2D2D30", false))); + } + { + ::vl::__vwsn::This(this->titleBounds)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_3)); + } + (this->__vwsn_precompile_4 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(2); __vwsn_temp__.top = static_cast<::vl::vint>(2); __vwsn_temp__.right = static_cast<::vl::vint>(2); __vwsn_temp__.bottom = static_cast<::vl::vint>(2); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_5 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidLabelElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_5.Obj())->SetVerticalAlignment(::vl::presentation::Alignment::Center); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_5.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#C7C7C7", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_5)); + } + { + ::vl::__vwsn::This(this->titleBounds)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_4)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->titleBounds)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc29_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf72_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc30_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf73_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc31_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf74_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + ::vl::__vwsn::This(this->self)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + } + + GroupBoxTemplateConstructor::GroupBoxTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::GroupBoxTemplate) +***********************************************************************/ + + GroupBoxTemplate::GroupBoxTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::GroupBoxTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + GroupBoxTemplate::~GroupBoxTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::HScrollHandleTemplateConstructor) +***********************************************************************/ + + void HScrollHandleTemplateConstructor::__vwsn_initialize_instance_(::darkskin::HScrollHandleTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(4); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(4); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_1)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_0)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc32_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf75_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + } + + HScrollHandleTemplateConstructor::HScrollHandleTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::HScrollHandleTemplate) +***********************************************************************/ + + HScrollHandleTemplate::HScrollHandleTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::HScrollHandleTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + HScrollHandleTemplate::~HScrollHandleTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::HScrollTemplateConstructor) +***********************************************************************/ + + void HScrollTemplateConstructor::__vwsn_initialize_instance_(::darkskin::HScrollTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#3D3D42", false))); + } + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->__vwsn_precompile_1 = new ::vl::presentation::compositions::GuiSideAlignedComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetMaxRatio(::vl::__vwsn::Parse(::vl::WString(L"0.5", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetMaxLength(::vl::__vwsn::Parse<::vl::vint>(::vl::WString(L"20", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetDirection(::vl::presentation::compositions::GuiSideAlignedComposition::Direction::Left); + } + { + auto __vwsn_controlStyle_ = new ::vl::presentation::templates::GuiButtonTemplate_StyleProvider(LAMBDA(::vl_workflow_global::__vwsnf76_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(this))); + (this->__vwsn_precompile_2 = new ::vl::presentation::controls::GuiButton(__vwsn_controlStyle_)); + } + (this->__vwsn_precompile_3 = ::vl::__vwsn::This(this->__vwsn_precompile_2)->GetBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(::vl::__vwsn::This(this->__vwsn_precompile_2)->GetBoundsComposition())); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_1)); + } + (this->__vwsn_precompile_4 = new ::vl::presentation::compositions::GuiSideAlignedComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetMaxRatio(::vl::__vwsn::Parse(::vl::WString(L"0.5", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetMaxLength(::vl::__vwsn::Parse<::vl::vint>(::vl::WString(L"20", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetDirection(::vl::presentation::compositions::GuiSideAlignedComposition::Direction::Right); + } + { + auto __vwsn_controlStyle_ = new ::vl::presentation::templates::GuiButtonTemplate_StyleProvider(LAMBDA(::vl_workflow_global::__vwsnf77_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(this))); + (this->__vwsn_precompile_5 = new ::vl::presentation::controls::GuiButton(__vwsn_controlStyle_)); + } + (this->__vwsn_precompile_6 = ::vl::__vwsn::This(this->__vwsn_precompile_5)->GetBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_6)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(::vl::__vwsn::This(this->__vwsn_precompile_5)->GetBoundsComposition())); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_4)); + } + (this->handleContainer = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->handleContainer)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(20); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(20); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->handleContainer)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_7 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_7)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->handleContainer)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_7)); + } + (this->__vwsn_precompile_8 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_8)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->handleContainer)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_8)); + } + (this->handle = new ::vl::presentation::compositions::GuiPartialViewComposition()); + { + auto __vwsn_controlStyle_ = new ::vl::presentation::templates::GuiButtonTemplate_StyleProvider(LAMBDA(::vl_workflow_global::__vwsnf78_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(this))); + (this->__vwsn_precompile_9 = new ::vl::presentation::controls::GuiButton(__vwsn_controlStyle_)); + } + (this->__vwsn_precompile_10 = ::vl::__vwsn::This(this->__vwsn_precompile_9)->GetBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_10)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->handle)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(::vl::__vwsn::This(this->__vwsn_precompile_9)->GetBoundsComposition())); + } + { + ::vl::__vwsn::This(this->handleContainer)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->handle)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->handleContainer)); + } + { + auto __vwsn_event_handler_ = LAMBDA(::vl_workflow_global::__vwsnf79_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(this->__vwsn_precompile_2)->Clicked, __vwsn_event_handler_); + } + { + auto __vwsn_event_handler_ = LAMBDA(::vl_workflow_global::__vwsnf80_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(this->__vwsn_precompile_5)->Clicked, __vwsn_event_handler_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc33_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf81_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_event_handler_ = LAMBDA(::vl_workflow_global::__vwsnf82_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(this->__vwsn_precompile_7)->GetEventReceiver()->leftButtonDown, __vwsn_event_handler_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc34_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf83_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_event_handler_ = LAMBDA(::vl_workflow_global::__vwsnf84_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(this->__vwsn_precompile_8)->GetEventReceiver()->leftButtonDown, __vwsn_event_handler_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc35_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf85_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc36_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf86_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_event_handler_ = LAMBDA(::vl_workflow_global::__vwsnf87_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(this->handle)->GetEventReceiver()->leftButtonDown, __vwsn_event_handler_); + } + { + auto __vwsn_event_handler_ = LAMBDA(::vl_workflow_global::__vwsnf88_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(this->handle)->GetEventReceiver()->leftButtonUp, __vwsn_event_handler_); + } + { + auto __vwsn_event_handler_ = LAMBDA(::vl_workflow_global::__vwsnf89_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(this->handle)->GetEventReceiver()->mouseMove, __vwsn_event_handler_); + } + { + ::vl::__vwsn::This(this->self)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->self)); + } + } + + HScrollTemplateConstructor::HScrollTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::HScrollTemplate) +***********************************************************************/ + + HScrollTemplate::HScrollTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::HScrollTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + HScrollTemplate::~HScrollTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::HTrackerTemplateConstructor) +***********************************************************************/ + + void HTrackerTemplateConstructor::__vwsn_initialize_instance_(::darkskin::HTrackerTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#3F3F47", false))); + } + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->__vwsn_precompile_1 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#55545A", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_2)); + } + (this->__vwsn_precompile_3 = new ::vl::presentation::compositions::GuiTableComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(6); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(6); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetRowsAndColumns(static_cast<::vl::vint>(3), static_cast<::vl::vint>(1)); + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetRowOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetRowOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(4); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetRowOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetColumnOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(1.0); return __vwsn_temp__; }()); + } + (this->__vwsn_precompile_4 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(0), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + (this->__vwsn_precompile_5 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_5.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#55545A", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_5)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_4)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_3)); + } + (this->handle = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->handle)->SetPreferredMinSize([&](){ ::vl::presentation::Size __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(12); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->handle)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + auto __vwsn_controlStyle_ = new ::vl::presentation::templates::GuiButtonTemplate_StyleProvider(LAMBDA(::vl_workflow_global::__vwsnf90_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__(this))); + (this->__vwsn_precompile_6 = new ::vl::presentation::controls::GuiButton(__vwsn_controlStyle_)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_6)->SetFont([&](){ ::vl::presentation::FontProperties __vwsn_temp__; __vwsn_temp__.size = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + (this->__vwsn_precompile_7 = ::vl::__vwsn::This(this->__vwsn_precompile_6)->GetBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_7)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->handle)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(::vl::__vwsn::This(this->__vwsn_precompile_6)->GetBoundsComposition())); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->handle)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_1)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf91_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_event_handler_ = LAMBDA(::vl_workflow_global::__vwsnf92_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(this->handle)->GetEventReceiver()->leftButtonDown, __vwsn_event_handler_); + } + { + auto __vwsn_event_handler_ = LAMBDA(::vl_workflow_global::__vwsnf93_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(this->handle)->GetEventReceiver()->leftButtonUp, __vwsn_event_handler_); + } + { + auto __vwsn_event_handler_ = LAMBDA(::vl_workflow_global::__vwsnf94_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(this->handle)->GetEventReceiver()->mouseMove, __vwsn_event_handler_); + } + { + ::vl::__vwsn::This(this->self)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->self)); + } + } + + HTrackerTemplateConstructor::HTrackerTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::HTrackerTemplate) +***********************************************************************/ + + HTrackerTemplate::HTrackerTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::HTrackerTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + HTrackerTemplate::~HTrackerTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::ItemBackgroundTemplateConstructor) +***********************************************************************/ + + void ItemBackgroundTemplateConstructor::__vwsn_initialize_instance_(::darkskin::ItemBackgroundTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->container = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->container)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(3); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(3); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc38_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf95_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + ::vl::__vwsn::This(this->self)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + } + + ItemBackgroundTemplateConstructor::ItemBackgroundTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::ItemBackgroundTemplate) +***********************************************************************/ + + ItemBackgroundTemplate::ItemBackgroundTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::ItemBackgroundTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + ItemBackgroundTemplate::~ItemBackgroundTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::LabelTemplateConstructor) +***********************************************************************/ + + void LabelTemplateConstructor::__vwsn_initialize_instance_(::darkskin::LabelTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetDefaultTextColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#F1F1F1", false))); + } + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidLabelElement>())); + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc39_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf96_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc40_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf97_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc41_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf98_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + } + + LabelTemplateConstructor::LabelTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::LabelTemplate) +***********************************************************************/ + + LabelTemplate::LabelTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::LabelTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + LabelTemplate::~LabelTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::LeftScrollButtonTemplateConstructor) +***********************************************************************/ + + void LeftScrollButtonTemplateConstructor::__vwsn_initialize_instance_(::darkskin::LeftScrollButtonTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = new ::vl::presentation::compositions::GuiTableComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowsAndColumns(static_cast<::vl::vint>(3), static_cast<::vl::vint>(3)); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(9); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetColumnOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetColumnOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetColumnOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + } + (this->__vwsn_precompile_1 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + (this->__vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiPolygonElement>())); + { + [&]()->decltype(auto){ auto __vwsn_temp_x0 = ::vl::__vwsn::Box(::vl::Ptr<::vl::reflection::description::IValueReadonlyList>((::vl::__vwsn::CreateList().Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(4); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }()).Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(0); __vwsn_temp__.y = static_cast<::vl::vint>(4); return __vwsn_temp__; }()).Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(4); __vwsn_temp__.y = static_cast<::vl::vint>(8); return __vwsn_temp__; }())).list)); ::vl::collections::Array<::vl::presentation::Point> __vwsn_temp_0; ::vl::reflection::description::UnboxParameter(__vwsn_temp_x0, __vwsn_temp_0); return ::vl::__vwsn::This(this->__vwsn_precompile_2.Obj())->SetPointsArray(__vwsn_temp_0); }(); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2.Obj())->SetSize([&](){ ::vl::presentation::Size __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(5); __vwsn_temp__.y = static_cast<::vl::vint>(9); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_2)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_1)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_0)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc42_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf99_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc43_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf100_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + } + + LeftScrollButtonTemplateConstructor::LeftScrollButtonTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::LeftScrollButtonTemplate) +***********************************************************************/ + + LeftScrollButtonTemplate::LeftScrollButtonTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::LeftScrollButtonTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + LeftScrollButtonTemplate::~LeftScrollButtonTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::ListViewColumnHeaderTemplateConstructor) +***********************************************************************/ + + void ListViewColumnHeaderTemplateConstructor::__vwsn_initialize_instance_(::darkskin::ListViewColumnHeaderTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetSubMenuTemplate(LAMBDA(::vl_workflow_global::__vwsnf101_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->__vwsn_precompile_1 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetPreferredMinSize([&](){ ::vl::presentation::Size __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(1); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = (- static_cast<::vl::vint>(1)); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#404042", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_2)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_1)); + } + (this->__vwsn_precompile_3 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetPreferredMinSize([&](){ ::vl::presentation::Size __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(0); __vwsn_temp__.y = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = (- static_cast<::vl::vint>(1)); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_4 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_4.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#404042", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_4)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_3)); + } + (this->__vwsn_precompile_5 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(1); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(11); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_6 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_6)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(8); __vwsn_temp__.top = static_cast<::vl::vint>(5); __vwsn_temp__.right = static_cast<::vl::vint>(5); __vwsn_temp__.bottom = static_cast<::vl::vint>(5); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_6)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_7 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidLabelElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_7.Obj())->SetEllipse(::vl::__vwsn::Parse(::vl::WString(L"true", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_7.Obj())->SetVerticalAlignment(::vl::presentation::Alignment::Center); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_7.Obj())->SetHorizontalAlignment(::vl::presentation::Alignment::Left); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_6)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_7)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_6)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_5)); + } + (this->__vwsn_precompile_8 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_8)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = (- static_cast<::vl::vint>(1)); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_8)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + auto __vwsn_controlStyle_ = new ::vl::presentation::templates::GuiSelectableButtonTemplate_StyleProvider(LAMBDA(::vl_workflow_global::__vwsnf102_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(this))); + (this->buttonArrow = new ::vl::presentation::controls::GuiSelectableButton(__vwsn_controlStyle_)); + } + (this->__vwsn_precompile_9 = ::vl::__vwsn::This(this->buttonArrow)->GetBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_9)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_8)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(::vl::__vwsn::This(this->buttonArrow)->GetBoundsComposition())); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_8)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc44_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf103_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc45_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf104_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc46_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf105_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc47_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf106_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc48_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf107_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc49_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf108_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + ::vl::__vwsn::This(this->self)->SetSubMenuHost(static_cast<::vl::presentation::controls::GuiButton*>(this->buttonArrow)); + } + } + + ListViewColumnHeaderTemplateConstructor::ListViewColumnHeaderTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::ListViewColumnHeaderTemplate) +***********************************************************************/ + + ListViewColumnHeaderTemplate::ListViewColumnHeaderTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::ListViewColumnHeaderTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + ListViewColumnHeaderTemplate::~ListViewColumnHeaderTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::ListViewTemplateConstructor) +***********************************************************************/ + + void ListViewTemplateConstructor::__vwsn_initialize_instance_(::darkskin::ListViewTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetItemSeparatorColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#F1F1F1", false))); + } + { + ::vl::__vwsn::This(this->self)->SetColumnHeaderTemplate(LAMBDA(::vl_workflow_global::__vwsnf109_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetSecondaryTextColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#F1F1F1", false))); + } + { + ::vl::__vwsn::This(this->self)->SetPrimaryTextColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#F1F1F1", false))); + } + { + ::vl::__vwsn::This(this->self)->SetBackgroundTemplate(LAMBDA(::vl_workflow_global::__vwsnf110_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetDefaultScrollSize(::vl::__vwsn::Parse<::vl::vint>(::vl::WString(L"20", false))); + } + { + ::vl::__vwsn::This(this->self)->SetVScrollTemplate(LAMBDA(::vl_workflow_global::__vwsnf111_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetHScrollTemplate(LAMBDA(::vl_workflow_global::__vwsnf112_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#252526", false))); + } + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->container = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->container)->SetInternalMargin([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(1); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(1); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#3F3F46", false))); + } + { + ::vl::__vwsn::This(this->container)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_1)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + { + ::vl::__vwsn::This(this->self)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + } + + ListViewTemplateConstructor::ListViewTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::ListViewTemplate) +***********************************************************************/ + + ListViewTemplate::ListViewTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::ListViewTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + ListViewTemplate::~ListViewTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::MenuBarButtonTemplateConstructor) +***********************************************************************/ + + void MenuBarButtonTemplateConstructor::__vwsn_initialize_instance_(::darkskin::MenuBarButtonTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetSubMenuTemplate(LAMBDA(::vl_workflow_global::__vwsnf113_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->__vwsn_precompile_1 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(10); __vwsn_temp__.top = static_cast<::vl::vint>(3); __vwsn_temp__.right = static_cast<::vl::vint>(10); __vwsn_temp__.bottom = static_cast<::vl::vint>(3); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidLabelElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2.Obj())->SetVerticalAlignment(::vl::presentation::Alignment::Center); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2.Obj())->SetHorizontalAlignment(::vl::presentation::Alignment::Center); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_2)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_1)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc50_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf114_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc51_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf115_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc52_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf116_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc53_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf117_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + } + + MenuBarButtonTemplateConstructor::MenuBarButtonTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::MenuBarButtonTemplate) +***********************************************************************/ + + MenuBarButtonTemplate::MenuBarButtonTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::MenuBarButtonTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + MenuBarButtonTemplate::~MenuBarButtonTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::MenuItemButtonTemplateConstructor) +***********************************************************************/ + + void MenuItemButtonTemplateConstructor::__vwsn_initialize_instance_(::darkskin::MenuItemButtonTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetSubMenuTemplate(LAMBDA(::vl_workflow_global::__vwsnf118_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->__vwsn_precompile_1 = new ::vl::presentation::compositions::GuiTableComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetRowsAndColumns(static_cast<::vl::vint>(5), static_cast<::vl::vint>(10)); + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetRowOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(4); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetRowOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetRowOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::MinSize; return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetRowOption(static_cast<::vl::vint>(3), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetRowOption(static_cast<::vl::vint>(4), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(4); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetColumnOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(2); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetColumnOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(24); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetColumnOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(8); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetColumnOption(static_cast<::vl::vint>(3), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::MinSize; return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetColumnOption(static_cast<::vl::vint>(4), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(24); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetColumnOption(static_cast<::vl::vint>(5), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(1.0); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetColumnOption(static_cast<::vl::vint>(6), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::MinSize; return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetColumnOption(static_cast<::vl::vint>(7), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(4); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetColumnOption(static_cast<::vl::vint>(8), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::MinSize; return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetColumnOption(static_cast<::vl::vint>(9), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(8); return __vwsn_temp__; }()); + } + (this->__vwsn_precompile_2 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(3), static_cast<::vl::vint>(1)); + } + (this->__vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiImageFrameElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiImageFrameElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_3)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_2)); + } + (this->__vwsn_precompile_4 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(3), static_cast<::vl::vint>(3), static_cast<::vl::vint>(1)); + } + (this->__vwsn_precompile_5 = new ::vl::presentation::compositions::GuiSharedSizeItemComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetSharedWidth(::vl::__vwsn::Parse(::vl::WString(L"true", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetGroup(::vl::WString(L"MenuItem-Text", false)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + (this->__vwsn_precompile_6 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidLabelElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_6.Obj())->SetVerticalAlignment(::vl::presentation::Alignment::Center); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_6.Obj())->SetHorizontalAlignment(::vl::presentation::Alignment::Left); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_6)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_5)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_4)); + } + (this->__vwsn_precompile_7 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_7)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(6), static_cast<::vl::vint>(3), static_cast<::vl::vint>(1)); + } + (this->__vwsn_precompile_8 = new ::vl::presentation::compositions::GuiSharedSizeItemComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_8)->SetSharedWidth(::vl::__vwsn::Parse(::vl::WString(L"true", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_8)->SetGroup(::vl::WString(L"MenuItem-Shortcut", false)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_8)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + (this->__vwsn_precompile_9 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidLabelElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_9.Obj())->SetVerticalAlignment(::vl::presentation::Alignment::Center); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_9.Obj())->SetHorizontalAlignment(::vl::presentation::Alignment::Right); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_8)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_9)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_7)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_8)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_7)); + } + (this->__vwsn_precompile_10 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_10)->SetSite(static_cast<::vl::vint>(2), static_cast<::vl::vint>(8), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + (this->__vwsn_precompile_11 = ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiPolygonElement>())); + { + [&]()->decltype(auto){ auto __vwsn_temp_x0 = ::vl::__vwsn::Box(::vl::Ptr<::vl::reflection::description::IValueReadonlyList>((::vl::__vwsn::CreateList().Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(0); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }()).Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(3); __vwsn_temp__.y = static_cast<::vl::vint>(3); return __vwsn_temp__; }()).Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(0); __vwsn_temp__.y = static_cast<::vl::vint>(6); return __vwsn_temp__; }())).list)); ::vl::collections::Array<::vl::presentation::Point> __vwsn_temp_0; ::vl::reflection::description::UnboxParameter(__vwsn_temp_x0, __vwsn_temp_0); return ::vl::__vwsn::This(this->__vwsn_precompile_11.Obj())->SetPointsArray(__vwsn_temp_0); }(); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_11.Obj())->SetSize([&](){ ::vl::presentation::Size __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(4); __vwsn_temp__.y = static_cast<::vl::vint>(7); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_10)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_11)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_10)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_1)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc54_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf119_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc55_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf120_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc56_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf121_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc57_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf122_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc58_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf123_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc59_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf124_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc60_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf125_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc61_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf126_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc62_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf127_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc63_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf128_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc64_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf129_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc65_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf130_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc66_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf131_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + } + + MenuItemButtonTemplateConstructor::MenuItemButtonTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::MenuItemButtonTemplate) +***********************************************************************/ + + MenuItemButtonTemplate::MenuItemButtonTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::MenuItemButtonTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + MenuItemButtonTemplate::~MenuItemButtonTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::MenuSplitterTemplateConstructor) +***********************************************************************/ + + void MenuSplitterTemplateConstructor::__vwsn_initialize_instance_(::darkskin::MenuSplitterTemplate* __vwsn_this_) + { + (this->__vwsn_precompile_0 = __vwsn_this_); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#1B1B1C", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_1)); + } + (this->__vwsn_precompile_2 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetPreferredMinSize([&](){ ::vl::presentation::Size __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(0); __vwsn_temp__.y = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_3.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#333337", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_3)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_2)); + } + } + + MenuSplitterTemplateConstructor::MenuSplitterTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::MenuSplitterTemplate) +***********************************************************************/ + + MenuSplitterTemplate::MenuSplitterTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::MenuSplitterTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + MenuSplitterTemplate::~MenuSplitterTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::MultilineTextBoxTemplateConstructor) +***********************************************************************/ + + void MultilineTextBoxTemplateConstructor::__vwsn_initialize_instance_(::darkskin::MultilineTextBoxTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetDefaultScrollSize(::vl::__vwsn::Parse<::vl::vint>(::vl::WString(L"20", false))); + } + { + ::vl::__vwsn::This(this->self)->SetVScrollTemplate(LAMBDA(::vl_workflow_global::__vwsnf132_DarkSkin_darkskin_MultilineTextBoxTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetHScrollTemplate(LAMBDA(::vl_workflow_global::__vwsnf133_DarkSkin_darkskin_MultilineTextBoxTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetTextColor([&](){ ::vl::presentation::elements::text::ColorEntry __vwsn_temp__; __vwsn_temp__.normal = [&](){ ::vl::presentation::elements::text::ColorItem __vwsn_temp__; __vwsn_temp__.text = ::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#FFFFFF", false)); __vwsn_temp__.background = ::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#00000000", false)); return __vwsn_temp__; }(); __vwsn_temp__.selectedFocused = [&](){ ::vl::presentation::elements::text::ColorItem __vwsn_temp__; __vwsn_temp__.text = ::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#FFFFFF", false)); __vwsn_temp__.background = ::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#007ACC", false)); return __vwsn_temp__; }(); __vwsn_temp__.selectedUnfocused = [&](){ ::vl::presentation::elements::text::ColorItem __vwsn_temp__; __vwsn_temp__.text = ::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#FFFFFF", false)); __vwsn_temp__.background = ::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#007ACC", false)); return __vwsn_temp__; }(); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->self)->SetCaretColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#FFFFFF", false))); + } + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#252526", false))); + } + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->container = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->container)->SetInternalMargin([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(1); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(1); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#3F3F46", false))); + } + { + ::vl::__vwsn::This(this->container)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_1)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + { + ::vl::__vwsn::This(this->self)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + } + + MultilineTextBoxTemplateConstructor::MultilineTextBoxTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::MultilineTextBoxTemplate) +***********************************************************************/ + + MultilineTextBoxTemplate::MultilineTextBoxTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::MultilineTextBoxTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + MultilineTextBoxTemplate::~MultilineTextBoxTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::ProgressBarTemplateConstructor) +***********************************************************************/ + + void ProgressBarTemplateConstructor::__vwsn_initialize_instance_(::darkskin::ProgressBarTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#3F3F47", false))); + } + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->__vwsn_precompile_1 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#55545A", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_2)); + } + (this->container = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->container)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(1); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(1); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_3 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_4 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_4.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#07B023", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_4)); + } + { + ::vl::__vwsn::This(this->container)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_3)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_1)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc67_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf134_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + ::vl::__vwsn::This(this->self)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + } + + ProgressBarTemplateConstructor::ProgressBarTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::ProgressBarTemplate) +***********************************************************************/ + + ProgressBarTemplate::ProgressBarTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::ProgressBarTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + ProgressBarTemplate::~ProgressBarTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::RadioButtonTemplateConstructor) +***********************************************************************/ + + void RadioButtonTemplateConstructor::__vwsn_initialize_instance_(::darkskin::RadioButtonTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = new ::vl::presentation::compositions::GuiTableComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowsAndColumns(static_cast<::vl::vint>(3), static_cast<::vl::vint>(2)); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(1.0); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(17); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(1.0); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetColumnOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(17); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetColumnOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(1.0); return __vwsn_temp__; }()); + } + (this->__vwsn_precompile_1 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(0), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + (this->__vwsn_precompile_2 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(2); __vwsn_temp__.top = static_cast<::vl::vint>(2); __vwsn_temp__.right = static_cast<::vl::vint>(2); __vwsn_temp__.bottom = static_cast<::vl::vint>(2); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_3.Obj())->SetShape(::vl::presentation::elements::ElementShape::Ellipse); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_3)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_2)); + } + (this->__vwsn_precompile_4 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(2); __vwsn_temp__.top = static_cast<::vl::vint>(2); __vwsn_temp__.right = static_cast<::vl::vint>(2); __vwsn_temp__.bottom = static_cast<::vl::vint>(2); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_5 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_5.Obj())->SetShape(::vl::presentation::elements::ElementShape::Ellipse); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_5)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_4)); + } + (this->__vwsn_precompile_6 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_6)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(5); __vwsn_temp__.top = static_cast<::vl::vint>(5); __vwsn_temp__.right = static_cast<::vl::vint>(5); __vwsn_temp__.bottom = static_cast<::vl::vint>(5); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_6)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_7 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_7.Obj())->SetShape(::vl::presentation::elements::ElementShape::Ellipse); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_6)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_7)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_6)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_1)); + } + (this->__vwsn_precompile_8 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_8)->SetSite(static_cast<::vl::vint>(0), static_cast<::vl::vint>(1), static_cast<::vl::vint>(3), static_cast<::vl::vint>(1)); + } + (this->__vwsn_precompile_9 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_9)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(3); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(3); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_9)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_10 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidLabelElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_10.Obj())->SetVerticalAlignment(::vl::presentation::Alignment::Center); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_10.Obj())->SetHorizontalAlignment(::vl::presentation::Alignment::Left); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_9)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_10)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_8)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_9)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_8)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_0)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc68_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf135_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc69_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf136_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc70_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf137_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc71_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf138_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc72_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf139_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc73_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf140_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc74_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf141_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + } + + RadioButtonTemplateConstructor::RadioButtonTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::RadioButtonTemplate) +***********************************************************************/ + + RadioButtonTemplate::RadioButtonTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::RadioButtonTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + RadioButtonTemplate::~RadioButtonTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::RightScrollButtonTemplateConstructor) +***********************************************************************/ + + void RightScrollButtonTemplateConstructor::__vwsn_initialize_instance_(::darkskin::RightScrollButtonTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = new ::vl::presentation::compositions::GuiTableComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowsAndColumns(static_cast<::vl::vint>(3), static_cast<::vl::vint>(3)); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(9); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetColumnOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetColumnOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetColumnOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + } + (this->__vwsn_precompile_1 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + (this->__vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiPolygonElement>())); + { + [&]()->decltype(auto){ auto __vwsn_temp_x0 = ::vl::__vwsn::Box(::vl::Ptr<::vl::reflection::description::IValueReadonlyList>((::vl::__vwsn::CreateList().Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(0); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }()).Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(4); __vwsn_temp__.y = static_cast<::vl::vint>(4); return __vwsn_temp__; }()).Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(0); __vwsn_temp__.y = static_cast<::vl::vint>(8); return __vwsn_temp__; }())).list)); ::vl::collections::Array<::vl::presentation::Point> __vwsn_temp_0; ::vl::reflection::description::UnboxParameter(__vwsn_temp_x0, __vwsn_temp_0); return ::vl::__vwsn::This(this->__vwsn_precompile_2.Obj())->SetPointsArray(__vwsn_temp_0); }(); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2.Obj())->SetSize([&](){ ::vl::presentation::Size __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(5); __vwsn_temp__.y = static_cast<::vl::vint>(9); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_2)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_1)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_0)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc75_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf142_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc76_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf143_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + } + + RightScrollButtonTemplateConstructor::RightScrollButtonTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::RightScrollButtonTemplate) +***********************************************************************/ + + RightScrollButtonTemplate::RightScrollButtonTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::RightScrollButtonTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + RightScrollButtonTemplate::~RightScrollButtonTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::ScrollViewTemplateConstructor) +***********************************************************************/ + + void ScrollViewTemplateConstructor::__vwsn_initialize_instance_(::darkskin::ScrollViewTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetDefaultScrollSize(::vl::__vwsn::Parse<::vl::vint>(::vl::WString(L"20", false))); + } + { + ::vl::__vwsn::This(this->self)->SetVScrollTemplate(LAMBDA(::vl_workflow_global::__vwsnf144_DarkSkin_darkskin_ScrollViewTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetHScrollTemplate(LAMBDA(::vl_workflow_global::__vwsnf145_DarkSkin_darkskin_ScrollViewTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#252526", false))); + } + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->container = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->container)->SetInternalMargin([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(1); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(1); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#3F3F46", false))); + } + { + ::vl::__vwsn::This(this->container)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_1)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + { + ::vl::__vwsn::This(this->self)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + } + + ScrollViewTemplateConstructor::ScrollViewTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::ScrollViewTemplate) +***********************************************************************/ + + ScrollViewTemplate::ScrollViewTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::ScrollViewTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + ScrollViewTemplate::~ScrollViewTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::ShortcutKeyTemplateConstructor) +***********************************************************************/ + + void ShortcutKeyTemplateConstructor::__vwsn_initialize_instance_(::darkskin::ShortcutKeyTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetDefaultTextColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#F1F1F1", false))); + } + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#3F3F46", false))); + } + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->__vwsn_precompile_1 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(1); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(1); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#252526", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_2)); + } + (this->__vwsn_precompile_3 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(1); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_4 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidLabelElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_4)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_3)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_1)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc77_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf146_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc78_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf147_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc79_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf148_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + } + + ShortcutKeyTemplateConstructor::ShortcutKeyTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::ShortcutKeyTemplate) +***********************************************************************/ + + ShortcutKeyTemplate::ShortcutKeyTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::ShortcutKeyTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + ShortcutKeyTemplate::~ShortcutKeyTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::SinglelineTextBoxTemplateConstructor) +***********************************************************************/ + + void SinglelineTextBoxTemplateConstructor::__vwsn_initialize_instance_(::darkskin::SinglelineTextBoxTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetTextColor([&](){ ::vl::presentation::elements::text::ColorEntry __vwsn_temp__; __vwsn_temp__.normal = [&](){ ::vl::presentation::elements::text::ColorItem __vwsn_temp__; __vwsn_temp__.text = ::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#FFFFFF", false)); __vwsn_temp__.background = ::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#00000000", false)); return __vwsn_temp__; }(); __vwsn_temp__.selectedFocused = [&](){ ::vl::presentation::elements::text::ColorItem __vwsn_temp__; __vwsn_temp__.text = ::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#FFFFFF", false)); __vwsn_temp__.background = ::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#007ACC", false)); return __vwsn_temp__; }(); __vwsn_temp__.selectedUnfocused = [&](){ ::vl::presentation::elements::text::ColorItem __vwsn_temp__; __vwsn_temp__.text = ::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#FFFFFF", false)); __vwsn_temp__.background = ::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#007ACC", false)); return __vwsn_temp__; }(); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->self)->SetCaretColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#FFFFFF", false))); + } + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#252526", false))); + } + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->container = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->container)->SetInternalMargin([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(1); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(1); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#3F3F46", false))); + } + { + ::vl::__vwsn::This(this->container)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_1)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + { + ::vl::__vwsn::This(this->self)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + } + + SinglelineTextBoxTemplateConstructor::SinglelineTextBoxTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::SinglelineTextBoxTemplate) +***********************************************************************/ + + SinglelineTextBoxTemplate::SinglelineTextBoxTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::SinglelineTextBoxTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + SinglelineTextBoxTemplate::~SinglelineTextBoxTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::TabDropdownTemplateConstructor) +***********************************************************************/ + + void TabDropdownTemplateConstructor::__vwsn_initialize_instance_(::darkskin::TabDropdownTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->__vwsn_precompile_1 = new ::vl::presentation::compositions::GuiTableComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetRowsAndColumns(static_cast<::vl::vint>(3), static_cast<::vl::vint>(3)); + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetRowOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetRowOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetRowOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetColumnOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetColumnOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(9); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetColumnOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + } + (this->__vwsn_precompile_2 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + (this->__vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiPolygonElement>())); + { + [&]()->decltype(auto){ auto __vwsn_temp_x0 = ::vl::__vwsn::Box(::vl::Ptr<::vl::reflection::description::IValueReadonlyList>((::vl::__vwsn::CreateList().Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(0); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }()).Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(4); __vwsn_temp__.y = static_cast<::vl::vint>(4); return __vwsn_temp__; }()).Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(8); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }())).list)); ::vl::collections::Array<::vl::presentation::Point> __vwsn_temp_0; ::vl::reflection::description::UnboxParameter(__vwsn_temp_x0, __vwsn_temp_0); return ::vl::__vwsn::This(this->__vwsn_precompile_3.Obj())->SetPointsArray(__vwsn_temp_0); }(); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3.Obj())->SetSize([&](){ ::vl::presentation::Size __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(9); __vwsn_temp__.y = static_cast<::vl::vint>(5); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3.Obj())->SetBackgroundColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#FFFFFF", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3.Obj())->SetBorderColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#FFFFFF", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_3)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_2)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_1)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc80_DarkSkin_darkskin_TabDropdownTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf149_DarkSkin_darkskin_TabDropdownTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + } + + TabDropdownTemplateConstructor::TabDropdownTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::TabDropdownTemplate) +***********************************************************************/ + + TabDropdownTemplate::TabDropdownTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::TabDropdownTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + TabDropdownTemplate::~TabDropdownTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::TabHeaderTemplateConstructor) +***********************************************************************/ + + void TabHeaderTemplateConstructor::__vwsn_initialize_instance_(::darkskin::TabHeaderTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->__vwsn_precompile_1 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(6); __vwsn_temp__.top = static_cast<::vl::vint>(3); __vwsn_temp__.right = static_cast<::vl::vint>(6); __vwsn_temp__.bottom = static_cast<::vl::vint>(3); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidLabelElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2.Obj())->SetVerticalAlignment(::vl::presentation::Alignment::Center); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2.Obj())->SetHorizontalAlignment(::vl::presentation::Alignment::Center); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_2)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_1)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc81_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf150_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc82_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf151_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc83_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf152_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc84_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf153_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + } + + TabHeaderTemplateConstructor::TabHeaderTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::TabHeaderTemplate) +***********************************************************************/ + + TabHeaderTemplate::TabHeaderTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::TabHeaderTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + TabHeaderTemplate::~TabHeaderTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::TabTemplateConstructor) +***********************************************************************/ + + void TabTemplateConstructor::__vwsn_initialize_instance_(::darkskin::TabTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetHeaderPadding(::vl::__vwsn::Parse<::vl::vint>(::vl::WString(L"2", false))); + } + { + ::vl::__vwsn::This(this->self)->SetMenuItemTemplate(LAMBDA(::vl_workflow_global::__vwsnf154_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetMenuTemplate(LAMBDA(::vl_workflow_global::__vwsnf155_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetDropdownTemplate(LAMBDA(::vl_workflow_global::__vwsnf156_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetHeaderTemplate(LAMBDA(::vl_workflow_global::__vwsnf157_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = new ::vl::presentation::compositions::GuiTableComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowsAndColumns(static_cast<::vl::vint>(3), static_cast<::vl::vint>(1)); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::MinSize; return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(2); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(1.0); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetColumnOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(1.0); return __vwsn_temp__; }()); + } + (this->__vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#2D2D30", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_1)); + } + (this->__vwsn_precompile_2 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetSite(static_cast<::vl::vint>(0), static_cast<::vl::vint>(0), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + (this->header = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->header)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->header)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->header)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_2)); + } + (this->__vwsn_precompile_3 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(0), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + (this->__vwsn_precompile_4 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_4.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#007ACC", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_4)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_3)); + } + (this->__vwsn_precompile_5 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetSite(static_cast<::vl::vint>(2), static_cast<::vl::vint>(0), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + (this->__vwsn_precompile_6 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_6.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#434346", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_6)); + } + (this->container = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->container)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(1); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(1); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_5)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_0)); + } + { + ::vl::__vwsn::This(this->self)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + { + ::vl::__vwsn::This(this->self)->SetHeaderComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->header)); + } + } + + TabTemplateConstructor::TabTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::TabTemplate) +***********************************************************************/ + + TabTemplate::TabTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::TabTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + TabTemplate::~TabTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::TextListTemplateConstructor) +***********************************************************************/ + + void TextListTemplateConstructor::__vwsn_initialize_instance_(::darkskin::TextListTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetRadioBulletTemplate(LAMBDA(::vl_workflow_global::__vwsnf158_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetCheckBulletTemplate(LAMBDA(::vl_workflow_global::__vwsnf159_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetBackgroundTemplate(LAMBDA(::vl_workflow_global::__vwsnf160_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetDefaultScrollSize(::vl::__vwsn::Parse<::vl::vint>(::vl::WString(L"20", false))); + } + { + ::vl::__vwsn::This(this->self)->SetVScrollTemplate(LAMBDA(::vl_workflow_global::__vwsnf161_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetHScrollTemplate(LAMBDA(::vl_workflow_global::__vwsnf162_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetTextColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#F1F1F1", false))); + } + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#252526", false))); + } + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->container = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->container)->SetInternalMargin([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(1); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(1); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#3F3F46", false))); + } + { + ::vl::__vwsn::This(this->container)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_1)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + { + ::vl::__vwsn::This(this->self)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + } + + TextListTemplateConstructor::TextListTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::TextListTemplate) +***********************************************************************/ + + TextListTemplate::TextListTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::TextListTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + TextListTemplate::~TextListTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::ToolstripSplitArrowTemplateConstructor) +***********************************************************************/ + + void ToolstripSplitArrowTemplateConstructor::__vwsn_initialize_instance_(::darkskin::ToolstripSplitArrowTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = new ::vl::presentation::compositions::GuiTableComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetPreferredMinSize([&](){ ::vl::presentation::Size __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(9); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(1); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(1); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowsAndColumns(static_cast<::vl::vint>(3), static_cast<::vl::vint>(3)); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(3); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetColumnOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetColumnOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetColumnOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + } + (this->__vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_1)); + } + (this->__vwsn_precompile_2 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + (this->__vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiPolygonElement>())); + { + [&]()->decltype(auto){ auto __vwsn_temp_x0 = ::vl::__vwsn::Box(::vl::Ptr<::vl::reflection::description::IValueReadonlyList>((::vl::__vwsn::CreateList().Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(0); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }()).Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(2); __vwsn_temp__.y = static_cast<::vl::vint>(2); return __vwsn_temp__; }()).Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(4); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }())).list)); ::vl::collections::Array<::vl::presentation::Point> __vwsn_temp_0; ::vl::reflection::description::UnboxParameter(__vwsn_temp_x0, __vwsn_temp_0); return ::vl::__vwsn::This(this->__vwsn_precompile_3.Obj())->SetPointsArray(__vwsn_temp_0); }(); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3.Obj())->SetSize([&](){ ::vl::presentation::Size __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(5); __vwsn_temp__.y = static_cast<::vl::vint>(3); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_3)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_2)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_0)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc85_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf163_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc86_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf164_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc87_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf165_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + } + + ToolstripSplitArrowTemplateConstructor::ToolstripSplitArrowTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::ToolstripSplitArrowTemplate) +***********************************************************************/ + + ToolstripSplitArrowTemplate::ToolstripSplitArrowTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::ToolstripSplitArrowTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + ToolstripSplitArrowTemplate::~ToolstripSplitArrowTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::ToolstripButtonTemplateConstructor) +***********************************************************************/ + + void ToolstripButtonTemplateConstructor::__vwsn_initialize_instance_(::darkskin::ToolstripButtonTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetSubMenuTemplate(LAMBDA(::vl_workflow_global::__vwsnf166_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_1)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_0)); + } + (this->__vwsn_precompile_2 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(1); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(1); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_3)); + } + (this->container = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->container)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(3); __vwsn_temp__.top = static_cast<::vl::vint>(3); __vwsn_temp__.right = static_cast<::vl::vint>(3); __vwsn_temp__.bottom = static_cast<::vl::vint>(3); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_4 = ::vl::Ptr<::vl::presentation::elements::GuiImageFrameElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiImageFrameElement>())); + { + ::vl::__vwsn::This(this->container)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_4)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_2)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc88_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf167_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc89_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf168_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc90_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf169_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc91_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf170_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc92_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf171_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + ::vl::__vwsn::This(this->self)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + } + + ToolstripButtonTemplateConstructor::ToolstripButtonTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::ToolstripButtonTemplate) +***********************************************************************/ + + ToolstripButtonTemplate::ToolstripButtonTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::ToolstripButtonTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + ToolstripButtonTemplate::~ToolstripButtonTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::ToolstripDropdownButtonTemplateConstructor) +***********************************************************************/ + + void ToolstripDropdownButtonTemplateConstructor::__vwsn_initialize_instance_(::darkskin::ToolstripDropdownButtonTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetSubMenuTemplate(LAMBDA(::vl_workflow_global::__vwsnf172_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_1)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_0)); + } + (this->__vwsn_precompile_2 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(1); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(11); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_3)); + } + (this->container = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->container)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(3); __vwsn_temp__.top = static_cast<::vl::vint>(3); __vwsn_temp__.right = static_cast<::vl::vint>(3); __vwsn_temp__.bottom = static_cast<::vl::vint>(3); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_4 = ::vl::Ptr<::vl::presentation::elements::GuiImageFrameElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiImageFrameElement>())); + { + ::vl::__vwsn::This(this->container)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_4)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_2)); + } + (this->__vwsn_precompile_5 = new ::vl::presentation::compositions::GuiTableComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetPreferredMinSize([&](){ ::vl::presentation::Size __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(9); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = (- static_cast<::vl::vint>(1)); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(1); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetRowsAndColumns(static_cast<::vl::vint>(3), static_cast<::vl::vint>(3)); + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetRowOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetRowOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(3); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetRowOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetColumnOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetColumnOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetColumnOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + } + (this->__vwsn_precompile_6 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_6)); + } + (this->__vwsn_precompile_7 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_7)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + (this->__vwsn_precompile_8 = ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiPolygonElement>())); + { + [&]()->decltype(auto){ auto __vwsn_temp_x0 = ::vl::__vwsn::Box(::vl::Ptr<::vl::reflection::description::IValueReadonlyList>((::vl::__vwsn::CreateList().Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(0); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }()).Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(2); __vwsn_temp__.y = static_cast<::vl::vint>(2); return __vwsn_temp__; }()).Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(4); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }())).list)); ::vl::collections::Array<::vl::presentation::Point> __vwsn_temp_0; ::vl::reflection::description::UnboxParameter(__vwsn_temp_x0, __vwsn_temp_0); return ::vl::__vwsn::This(this->__vwsn_precompile_8.Obj())->SetPointsArray(__vwsn_temp_0); }(); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_8.Obj())->SetSize([&](){ ::vl::presentation::Size __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(5); __vwsn_temp__.y = static_cast<::vl::vint>(3); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_7)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_8)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_7)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_5)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc93_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf173_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc94_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf174_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc95_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf175_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc96_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf176_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc97_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf177_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc98_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf178_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc99_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf179_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc100_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf180_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + ::vl::__vwsn::This(this->self)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + } + + ToolstripDropdownButtonTemplateConstructor::ToolstripDropdownButtonTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::ToolstripDropdownButtonTemplate) +***********************************************************************/ + + ToolstripDropdownButtonTemplate::ToolstripDropdownButtonTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::ToolstripDropdownButtonTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + ToolstripDropdownButtonTemplate::~ToolstripDropdownButtonTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::ToolstripMenuTemplateConstructor) +***********************************************************************/ + + void ToolstripMenuTemplateConstructor::__vwsn_initialize_instance_(::darkskin::ToolstripMenuTemplate* __vwsn_this_) + { + (this->__vwsn_precompile_0 = __vwsn_this_); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#1B1B1C", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_1)); + } + (this->container = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->container)->SetInternalMargin([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(3); __vwsn_temp__.top = static_cast<::vl::vint>(3); __vwsn_temp__.right = static_cast<::vl::vint>(3); __vwsn_temp__.bottom = static_cast<::vl::vint>(3); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#333337", false))); + } + { + ::vl::__vwsn::This(this->container)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_2)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + } + + ToolstripMenuTemplateConstructor::ToolstripMenuTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::ToolstripMenuTemplate) +***********************************************************************/ + + ToolstripMenuTemplate::ToolstripMenuTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::ToolstripMenuTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + ToolstripMenuTemplate::~ToolstripMenuTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::ToolstripSplitButtonTemplateConstructor) +***********************************************************************/ + + void ToolstripSplitButtonTemplateConstructor::__vwsn_initialize_instance_(::darkskin::ToolstripSplitButtonTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetSubMenuTemplate(LAMBDA(::vl_workflow_global::__vwsnf181_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_1)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_0)); + } + (this->__vwsn_precompile_2 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(1); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(11); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_3)); + } + (this->container = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->container)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(3); __vwsn_temp__.top = static_cast<::vl::vint>(3); __vwsn_temp__.right = static_cast<::vl::vint>(3); __vwsn_temp__.bottom = static_cast<::vl::vint>(3); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_4 = ::vl::Ptr<::vl::presentation::elements::GuiImageFrameElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiImageFrameElement>())); + { + ::vl::__vwsn::This(this->container)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_4)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_2)); + } + (this->__vwsn_precompile_5 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = (- static_cast<::vl::vint>(1)); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_6 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_6)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(1); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(1); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_6)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_7 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_6)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_7)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_6)); + } + { + auto __vwsn_controlStyle_ = new ::vl::presentation::templates::GuiSelectableButtonTemplate_StyleProvider(LAMBDA(::vl_workflow_global::__vwsnf182_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(this))); + (this->buttonArrow = new ::vl::presentation::controls::GuiSelectableButton(__vwsn_controlStyle_)); + } + (this->__vwsn_precompile_8 = ::vl::__vwsn::This(this->buttonArrow)->GetBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_8)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(::vl::__vwsn::This(this->buttonArrow)->GetBoundsComposition())); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_5)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc101_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf183_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc102_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf184_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc103_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf185_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc104_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf186_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc105_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf187_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc106_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf188_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc107_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf189_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + ::vl::__vwsn::This(this->self)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + { + ::vl::__vwsn::This(this->self)->SetSubMenuHost(static_cast<::vl::presentation::controls::GuiButton*>(this->buttonArrow)); + } + } + + ToolstripSplitButtonTemplateConstructor::ToolstripSplitButtonTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::ToolstripSplitButtonTemplate) +***********************************************************************/ + + ToolstripSplitButtonTemplate::ToolstripSplitButtonTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::ToolstripSplitButtonTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + ToolstripSplitButtonTemplate::~ToolstripSplitButtonTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::ToolstripSplitterTemplateConstructor) +***********************************************************************/ + + void ToolstripSplitterTemplateConstructor::__vwsn_initialize_instance_(::darkskin::ToolstripSplitterTemplate* __vwsn_this_) + { + (this->__vwsn_precompile_0 = __vwsn_this_); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#2D2D30", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_1)); + } + (this->__vwsn_precompile_2 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(3); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(3); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::Gui3DSplitterElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::Gui3DSplitterElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_3.Obj())->SetColor2(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#464648", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3.Obj())->SetColor1(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#222224", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3.Obj())->SetDirection(::vl::presentation::elements::Gui3DSplitterElement::Direction::Vertical); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_3)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_2)); + } + } + + ToolstripSplitterTemplateConstructor::ToolstripSplitterTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::ToolstripSplitterTemplate) +***********************************************************************/ + + ToolstripSplitterTemplate::ToolstripSplitterTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::ToolstripSplitterTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + ToolstripSplitterTemplate::~ToolstripSplitterTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::ToolstripTemplateConstructor) +***********************************************************************/ + + void ToolstripTemplateConstructor::__vwsn_initialize_instance_(::darkskin::ToolstripTemplate* __vwsn_this_) + { + (this->__vwsn_precompile_0 = __vwsn_this_); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetInternalMargin([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(2); __vwsn_temp__.top = static_cast<::vl::vint>(2); __vwsn_temp__.right = static_cast<::vl::vint>(2); __vwsn_temp__.bottom = static_cast<::vl::vint>(2); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#2D2D30", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_1)); + } + } + + ToolstripTemplateConstructor::ToolstripTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::ToolstripTemplate) +***********************************************************************/ + + ToolstripTemplate::ToolstripTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::ToolstripTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + ToolstripTemplate::~ToolstripTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::TooltipTemplateConstructor) +***********************************************************************/ + + void TooltipTemplateConstructor::__vwsn_initialize_instance_(::darkskin::TooltipTemplate* __vwsn_this_) + { + (this->__vwsn_precompile_0 = __vwsn_this_); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#2D2D30", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_1)); + } + (this->__vwsn_precompile_2 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_3.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#017ACC", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_3)); + } + (this->container = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->container)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(1); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(1); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_2)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + } + + TooltipTemplateConstructor::TooltipTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::TooltipTemplate) +***********************************************************************/ + + TooltipTemplate::TooltipTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::TooltipTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + TooltipTemplate::~TooltipTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::TopScrollButtonTemplateConstructor) +***********************************************************************/ + + void TopScrollButtonTemplateConstructor::__vwsn_initialize_instance_(::darkskin::TopScrollButtonTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = new ::vl::presentation::compositions::GuiTableComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowsAndColumns(static_cast<::vl::vint>(3), static_cast<::vl::vint>(3)); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetRowOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetColumnOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetColumnOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(9); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetColumnOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + } + (this->__vwsn_precompile_1 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + (this->__vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiPolygonElement>())); + { + [&]()->decltype(auto){ auto __vwsn_temp_x0 = ::vl::__vwsn::Box(::vl::Ptr<::vl::reflection::description::IValueReadonlyList>((::vl::__vwsn::CreateList().Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(0); __vwsn_temp__.y = static_cast<::vl::vint>(4); return __vwsn_temp__; }()).Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(4); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }()).Add([&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(8); __vwsn_temp__.y = static_cast<::vl::vint>(4); return __vwsn_temp__; }())).list)); ::vl::collections::Array<::vl::presentation::Point> __vwsn_temp_0; ::vl::reflection::description::UnboxParameter(__vwsn_temp_x0, __vwsn_temp_0); return ::vl::__vwsn::This(this->__vwsn_precompile_2.Obj())->SetPointsArray(__vwsn_temp_0); }(); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_2.Obj())->SetSize([&](){ ::vl::presentation::Size __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(9); __vwsn_temp__.y = static_cast<::vl::vint>(5); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_2)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_1)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_0)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc108_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf190_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc109_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf191_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + } + + TopScrollButtonTemplateConstructor::TopScrollButtonTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::TopScrollButtonTemplate) +***********************************************************************/ + + TopScrollButtonTemplate::TopScrollButtonTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::TopScrollButtonTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + TopScrollButtonTemplate::~TopScrollButtonTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::TreeViewTemplateConstructor) +***********************************************************************/ + + void TreeViewTemplateConstructor::__vwsn_initialize_instance_(::darkskin::TreeViewTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetExpandingDecoratorTemplate(LAMBDA(::vl_workflow_global::__vwsnf192_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetBackgroundTemplate(LAMBDA(::vl_workflow_global::__vwsnf193_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetDefaultScrollSize(::vl::__vwsn::Parse<::vl::vint>(::vl::WString(L"20", false))); + } + { + ::vl::__vwsn::This(this->self)->SetVScrollTemplate(LAMBDA(::vl_workflow_global::__vwsnf194_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetHScrollTemplate(LAMBDA(::vl_workflow_global::__vwsnf195_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetTextColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#F1F1F1", false))); + } + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#252526", false))); + } + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->container = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->container)->SetInternalMargin([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(1); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(1); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#3F3F46", false))); + } + { + ::vl::__vwsn::This(this->container)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_1)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + { + ::vl::__vwsn::This(this->self)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + } + + TreeViewTemplateConstructor::TreeViewTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::TreeViewTemplate) +***********************************************************************/ + + TreeViewTemplate::TreeViewTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::TreeViewTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + TreeViewTemplate::~TreeViewTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::VScrollHandleTemplateConstructor) +***********************************************************************/ + + void VScrollHandleTemplateConstructor::__vwsn_initialize_instance_(::darkskin::VScrollHandleTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(4); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(4); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_1)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_0)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc110_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf196_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + } + + VScrollHandleTemplateConstructor::VScrollHandleTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::VScrollHandleTemplate) +***********************************************************************/ + + VScrollHandleTemplate::VScrollHandleTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::VScrollHandleTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + VScrollHandleTemplate::~VScrollHandleTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::VScrollTemplateConstructor) +***********************************************************************/ + + void VScrollTemplateConstructor::__vwsn_initialize_instance_(::darkskin::VScrollTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#3D3D42", false))); + } + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->__vwsn_precompile_1 = new ::vl::presentation::compositions::GuiSideAlignedComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetMaxRatio(::vl::__vwsn::Parse(::vl::WString(L"0.5", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetMaxLength(::vl::__vwsn::Parse<::vl::vint>(::vl::WString(L"20", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetDirection(::vl::presentation::compositions::GuiSideAlignedComposition::Direction::Top); + } + { + auto __vwsn_controlStyle_ = new ::vl::presentation::templates::GuiButtonTemplate_StyleProvider(LAMBDA(::vl_workflow_global::__vwsnf197_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(this))); + (this->__vwsn_precompile_2 = new ::vl::presentation::controls::GuiButton(__vwsn_controlStyle_)); + } + (this->__vwsn_precompile_3 = ::vl::__vwsn::This(this->__vwsn_precompile_2)->GetBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(::vl::__vwsn::This(this->__vwsn_precompile_2)->GetBoundsComposition())); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_1)); + } + (this->__vwsn_precompile_4 = new ::vl::presentation::compositions::GuiSideAlignedComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetMaxRatio(::vl::__vwsn::Parse(::vl::WString(L"0.5", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetMaxLength(::vl::__vwsn::Parse<::vl::vint>(::vl::WString(L"20", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetDirection(::vl::presentation::compositions::GuiSideAlignedComposition::Direction::Bottom); + } + { + auto __vwsn_controlStyle_ = new ::vl::presentation::templates::GuiButtonTemplate_StyleProvider(LAMBDA(::vl_workflow_global::__vwsnf198_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(this))); + (this->__vwsn_precompile_5 = new ::vl::presentation::controls::GuiButton(__vwsn_controlStyle_)); + } + (this->__vwsn_precompile_6 = ::vl::__vwsn::This(this->__vwsn_precompile_5)->GetBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_6)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(::vl::__vwsn::This(this->__vwsn_precompile_5)->GetBoundsComposition())); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_4)); + } + (this->handleContainer = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->handleContainer)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(20); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(20); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->handleContainer)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_7 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_7)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->handleContainer)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_7)); + } + (this->__vwsn_precompile_8 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_8)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->handleContainer)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_8)); + } + (this->handle = new ::vl::presentation::compositions::GuiPartialViewComposition()); + { + auto __vwsn_controlStyle_ = new ::vl::presentation::templates::GuiButtonTemplate_StyleProvider(LAMBDA(::vl_workflow_global::__vwsnf199_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(this))); + (this->__vwsn_precompile_9 = new ::vl::presentation::controls::GuiButton(__vwsn_controlStyle_)); + } + (this->__vwsn_precompile_10 = ::vl::__vwsn::This(this->__vwsn_precompile_9)->GetBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_10)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->handle)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(::vl::__vwsn::This(this->__vwsn_precompile_9)->GetBoundsComposition())); + } + { + ::vl::__vwsn::This(this->handleContainer)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->handle)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->handleContainer)); + } + { + auto __vwsn_event_handler_ = LAMBDA(::vl_workflow_global::__vwsnf200_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(this->__vwsn_precompile_2)->Clicked, __vwsn_event_handler_); + } + { + auto __vwsn_event_handler_ = LAMBDA(::vl_workflow_global::__vwsnf201_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(this->__vwsn_precompile_5)->Clicked, __vwsn_event_handler_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc111_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf202_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_event_handler_ = LAMBDA(::vl_workflow_global::__vwsnf203_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(this->__vwsn_precompile_7)->GetEventReceiver()->leftButtonDown, __vwsn_event_handler_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc112_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf204_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_event_handler_ = LAMBDA(::vl_workflow_global::__vwsnf205_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(this->__vwsn_precompile_8)->GetEventReceiver()->leftButtonDown, __vwsn_event_handler_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc113_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf206_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc114_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf207_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_event_handler_ = LAMBDA(::vl_workflow_global::__vwsnf208_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(this->handle)->GetEventReceiver()->leftButtonDown, __vwsn_event_handler_); + } + { + auto __vwsn_event_handler_ = LAMBDA(::vl_workflow_global::__vwsnf209_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(this->handle)->GetEventReceiver()->leftButtonUp, __vwsn_event_handler_); + } + { + auto __vwsn_event_handler_ = LAMBDA(::vl_workflow_global::__vwsnf210_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(this->handle)->GetEventReceiver()->mouseMove, __vwsn_event_handler_); + } + { + ::vl::__vwsn::This(this->self)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->self)); + } + } + + VScrollTemplateConstructor::VScrollTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::VScrollTemplate) +***********************************************************************/ + + VScrollTemplate::VScrollTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::VScrollTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + VScrollTemplate::~VScrollTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::VTrackerTemplateConstructor) +***********************************************************************/ + + void VTrackerTemplateConstructor::__vwsn_initialize_instance_(::darkskin::VTrackerTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#3F3F47", false))); + } + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->__vwsn_precompile_1 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#55545A", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_2)); + } + (this->__vwsn_precompile_3 = new ::vl::presentation::compositions::GuiTableComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(6); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(6); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetRowsAndColumns(static_cast<::vl::vint>(1), static_cast<::vl::vint>(3)); + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetRowOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(1.0); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetColumnOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetColumnOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(4); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetColumnOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(0.5); return __vwsn_temp__; }()); + } + (this->__vwsn_precompile_4 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetSite(static_cast<::vl::vint>(0), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + (this->__vwsn_precompile_5 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_5.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#55545A", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_5)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_4)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_3)); + } + (this->handle = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->handle)->SetPreferredMinSize([&](){ ::vl::presentation::Size __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(0); __vwsn_temp__.y = static_cast<::vl::vint>(12); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->handle)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + auto __vwsn_controlStyle_ = new ::vl::presentation::templates::GuiButtonTemplate_StyleProvider(LAMBDA(::vl_workflow_global::__vwsnf211_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__(this))); + (this->__vwsn_precompile_6 = new ::vl::presentation::controls::GuiButton(__vwsn_controlStyle_)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_6)->SetFont([&](){ ::vl::presentation::FontProperties __vwsn_temp__; __vwsn_temp__.size = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + (this->__vwsn_precompile_7 = ::vl::__vwsn::This(this->__vwsn_precompile_6)->GetBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_7)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->handle)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(::vl::__vwsn::This(this->__vwsn_precompile_6)->GetBoundsComposition())); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->handle)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_1)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf212_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_event_handler_ = LAMBDA(::vl_workflow_global::__vwsnf213_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(this->handle)->GetEventReceiver()->leftButtonDown, __vwsn_event_handler_); + } + { + auto __vwsn_event_handler_ = LAMBDA(::vl_workflow_global::__vwsnf214_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(this->handle)->GetEventReceiver()->leftButtonUp, __vwsn_event_handler_); + } + { + auto __vwsn_event_handler_ = LAMBDA(::vl_workflow_global::__vwsnf215_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(this->handle)->GetEventReceiver()->mouseMove, __vwsn_event_handler_); + } + { + ::vl::__vwsn::This(this->self)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->self)); + } + } + + VTrackerTemplateConstructor::VTrackerTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::VTrackerTemplate) +***********************************************************************/ + + VTrackerTemplate::VTrackerTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::VTrackerTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + VTrackerTemplate::~VTrackerTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::darkskin::WindowTemplateConstructor) +***********************************************************************/ + + void WindowTemplateConstructor::__vwsn_initialize_instance_(::darkskin::WindowTemplate* __vwsn_this_) + { + (this->self = __vwsn_this_); + { + ::vl::__vwsn::This(this->self)->SetTooltipTemplate(LAMBDA(::vl_workflow_global::__vwsnf216_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__(this))); + } + { + ::vl::__vwsn::This(this->self)->SetCustomizedBorder(::vl::__vwsn::Parse(::vl::WString(L"true", false))); + } + { + ::vl::__vwsn::This(this->self)->SetTitleBarOption(::vl::presentation::templates::BoolOption::AlwaysTrue); + } + { + ::vl::__vwsn::This(this->self)->SetIconVisibleOption(::vl::presentation::templates::BoolOption::AlwaysTrue); + } + { + ::vl::__vwsn::This(this->self)->SetSizeBoxOption(::vl::presentation::templates::BoolOption::AlwaysTrue); + } + { + ::vl::__vwsn::This(this->self)->SetBorderOption(::vl::presentation::templates::BoolOption::AlwaysTrue); + } + { + ::vl::__vwsn::This(this->self)->SetMinimizedBoxOption(::vl::presentation::templates::BoolOption::AlwaysTrue); + } + { + ::vl::__vwsn::This(this->self)->SetMaximizedBoxOption(::vl::presentation::templates::BoolOption::AlwaysTrue); + } + { + ::vl::__vwsn::This(this->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBackgroundElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_0.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#2D2D30", false))); + } + { + ::vl::__vwsn::This(this->self)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_0)); + } + (this->__vwsn_precompile_1 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidBorderElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_2.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#017ACC", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_2)); + } + (this->__vwsn_precompile_3 = new ::vl::presentation::compositions::GuiTableComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetRowsAndColumns(static_cast<::vl::vint>(4), static_cast<::vl::vint>(6)); + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetRowOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(8); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetRowOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::MinSize; return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetRowOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(1.0); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetRowOption(static_cast<::vl::vint>(3), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(8); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetColumnOption(static_cast<::vl::vint>(0), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(8); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetColumnOption(static_cast<::vl::vint>(1), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Percentage; __vwsn_temp__.percentage = static_cast(1.0); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetColumnOption(static_cast<::vl::vint>(2), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::MinSize; return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetColumnOption(static_cast<::vl::vint>(3), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::MinSize; return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetColumnOption(static_cast<::vl::vint>(4), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::MinSize; return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetColumnOption(static_cast<::vl::vint>(5), [&](){ ::vl::presentation::compositions::GuiCellOption __vwsn_temp__; __vwsn_temp__.composeType = ::vl::presentation::compositions::GuiCellOption::ComposeType::Absolute; __vwsn_temp__.absolute = static_cast<::vl::vint>(8); return __vwsn_temp__; }()); + } + (this->__vwsn_precompile_4 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetAssociatedHitTestResult(::vl::presentation::INativeWindowListener::HitTestResult::BorderLeftTop); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_4)->SetSite(static_cast<::vl::vint>(0), static_cast<::vl::vint>(0), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_4)); + } + (this->__vwsn_precompile_5 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetAssociatedHitTestResult(::vl::presentation::INativeWindowListener::HitTestResult::BorderRightTop); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_5)->SetSite(static_cast<::vl::vint>(0), static_cast<::vl::vint>(5), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_5)); + } + (this->__vwsn_precompile_6 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_6)->SetAssociatedHitTestResult(::vl::presentation::INativeWindowListener::HitTestResult::BorderLeftBottom); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_6)->SetSite(static_cast<::vl::vint>(3), static_cast<::vl::vint>(0), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_6)); + } + (this->__vwsn_precompile_7 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_7)->SetAssociatedHitTestResult(::vl::presentation::INativeWindowListener::HitTestResult::BorderRightBottom); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_7)->SetSite(static_cast<::vl::vint>(3), static_cast<::vl::vint>(5), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_7)); + } + (this->__vwsn_precompile_8 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_8)->SetAssociatedHitTestResult(::vl::presentation::INativeWindowListener::HitTestResult::BorderLeft); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_8)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(0), static_cast<::vl::vint>(2), static_cast<::vl::vint>(1)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_8)); + } + (this->__vwsn_precompile_9 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_9)->SetAssociatedHitTestResult(::vl::presentation::INativeWindowListener::HitTestResult::BorderRight); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_9)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(5), static_cast<::vl::vint>(2), static_cast<::vl::vint>(1)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_9)); + } + (this->__vwsn_precompile_10 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_10)->SetAssociatedHitTestResult(::vl::presentation::INativeWindowListener::HitTestResult::BorderTop); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_10)->SetSite(static_cast<::vl::vint>(0), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(4)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_10)); + } + (this->__vwsn_precompile_11 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_11)->SetAssociatedHitTestResult(::vl::presentation::INativeWindowListener::HitTestResult::BorderBottom); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_11)->SetSite(static_cast<::vl::vint>(3), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(4)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_11)); + } + (this->__vwsn_precompile_12 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_12)->SetAssociatedHitTestResult(::vl::presentation::INativeWindowListener::HitTestResult::ButtonMinimum); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_12)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(2), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + { + auto __vwsn_controlStyle_ = new ::vl::presentation::templates::GuiButtonTemplate_StyleProvider(LAMBDA(::vl_workflow_global::__vwsnf217_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__(this))); + (this->__vwsn_precompile_13 = new ::vl::presentation::controls::GuiButton(__vwsn_controlStyle_)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_13)->SetFont([&](){ ::vl::presentation::FontProperties __vwsn_temp__; __vwsn_temp__.fontFamily = ::vl::WString(L"Webdings", false); __vwsn_temp__.size = static_cast<::vl::vint>(16); return __vwsn_temp__; }()); + } + (this->__vwsn_precompile_14 = ::vl::__vwsn::This(this->__vwsn_precompile_13)->GetBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_14)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(1); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(1); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_13)->SetText(::vl::WString(L" 0 ", false)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_12)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(::vl::__vwsn::This(this->__vwsn_precompile_13)->GetBoundsComposition())); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_12)); + } + (this->__vwsn_precompile_15 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_15)->SetAssociatedHitTestResult(::vl::presentation::INativeWindowListener::HitTestResult::ButtonMaximum); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_15)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(3), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + { + auto __vwsn_controlStyle_ = new ::vl::presentation::templates::GuiButtonTemplate_StyleProvider(LAMBDA(::vl_workflow_global::__vwsnf218_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__(this))); + (this->__vwsn_precompile_16 = new ::vl::presentation::controls::GuiButton(__vwsn_controlStyle_)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_16)->SetFont([&](){ ::vl::presentation::FontProperties __vwsn_temp__; __vwsn_temp__.fontFamily = ::vl::WString(L"Webdings", false); __vwsn_temp__.size = static_cast<::vl::vint>(16); return __vwsn_temp__; }()); + } + (this->__vwsn_precompile_17 = ::vl::__vwsn::This(this->__vwsn_precompile_16)->GetBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_17)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(1); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(1); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_15)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(::vl::__vwsn::This(this->__vwsn_precompile_16)->GetBoundsComposition())); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_15)); + } + (this->__vwsn_precompile_18 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_18)->SetAssociatedHitTestResult(::vl::presentation::INativeWindowListener::HitTestResult::ButtonClose); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_18)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(4), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + { + auto __vwsn_controlStyle_ = new ::vl::presentation::templates::GuiButtonTemplate_StyleProvider(LAMBDA(::vl_workflow_global::__vwsnf219_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__(this))); + (this->__vwsn_precompile_19 = new ::vl::presentation::controls::GuiButton(__vwsn_controlStyle_)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_19)->SetFont([&](){ ::vl::presentation::FontProperties __vwsn_temp__; __vwsn_temp__.fontFamily = ::vl::WString(L"Webdings", false); __vwsn_temp__.size = static_cast<::vl::vint>(16); return __vwsn_temp__; }()); + } + (this->__vwsn_precompile_20 = ::vl::__vwsn::This(this->__vwsn_precompile_19)->GetBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_20)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(1); __vwsn_temp__.top = static_cast<::vl::vint>(1); __vwsn_temp__.right = static_cast<::vl::vint>(1); __vwsn_temp__.bottom = static_cast<::vl::vint>(1); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_19)->SetText(::vl::WString(L" r ", false)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_18)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(::vl::__vwsn::This(this->__vwsn_precompile_19)->GetBoundsComposition())); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_18)); + } + (this->__vwsn_precompile_21 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_21)->SetAssociatedHitTestResult(::vl::presentation::INativeWindowListener::HitTestResult::Title); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_21)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + } + (this->__vwsn_precompile_22 = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_22)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(5); __vwsn_temp__.top = static_cast<::vl::vint>(5); __vwsn_temp__.right = static_cast<::vl::vint>(5); __vwsn_temp__.bottom = static_cast<::vl::vint>(5); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_22)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + (this->__vwsn_precompile_23 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(::vl::reflection::description::Element_Constructor<::vl::presentation::elements::GuiSolidLabelElement>())); + { + ::vl::__vwsn::This(this->__vwsn_precompile_23.Obj())->SetFont([&](){ ::vl::presentation::FontProperties __vwsn_temp__; __vwsn_temp__.fontFamily = ::vl::WString(L"Segoe WP SemiLight", false); __vwsn_temp__.size = static_cast<::vl::vint>(14); __vwsn_temp__.antialias = true; return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_23.Obj())->SetColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#999999", false))); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_22)->SetOwnedElement(::vl::Ptr<::vl::presentation::elements::IGuiGraphicsElement>(this->__vwsn_precompile_23)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_21)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_22)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_21)); + } + (this->__vwsn_precompile_24 = new ::vl::presentation::compositions::GuiCellComposition()); + { + ::vl::__vwsn::This(this->__vwsn_precompile_24)->SetAssociatedHitTestResult(::vl::presentation::INativeWindowListener::HitTestResult::Client); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_24)->SetSite(static_cast<::vl::vint>(2), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(4)); + } + (this->container = new ::vl::presentation::compositions::GuiBoundsComposition()); + { + ::vl::__vwsn::This(this->container)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + } + { + ::vl::__vwsn::This(this->container)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_24)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_3)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_24)); + } + { + ::vl::__vwsn::This(this->__vwsn_precompile_1)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_3)); + } + { + ::vl::__vwsn::This(this->self)->AddChild(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->__vwsn_precompile_1)); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc116_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf220_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + auto __vwsn_created_subscription_ = ::vl::Ptr<::vl::reflection::description::IValueSubscription>(new ::vl_workflow_global::__vwsnc117_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(this)); + ::vl::__vwsn::EventAttach(::vl::__vwsn::This(__vwsn_created_subscription_.Obj())->ValueChanged, LAMBDA(::vl_workflow_global::__vwsnf221_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__(this))); + ::vl::__vwsn::This(__vwsn_this_)->AddSubscription(__vwsn_created_subscription_); + } + { + ::vl::__vwsn::This(this->self)->SetContainerComposition(static_cast<::vl::presentation::compositions::GuiGraphicsComposition*>(this->container)); + } + } + + WindowTemplateConstructor::WindowTemplateConstructor() + { + } + +/*********************************************************************** +Class (::darkskin::WindowTemplate) +***********************************************************************/ + + WindowTemplate::WindowTemplate() + { + auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"darkskin::WindowTemplate", false)); + auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); + ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); + ::vl::__vwsn::This(this)->__vwsn_initialize_instance_(this); + } + + WindowTemplate::~WindowTemplate() + { + this->FinalizeInstanceRecursively(static_cast<::vl::presentation::templates::GuiTemplate*>(this)); + } + +/*********************************************************************** +Class (::ScrollTemplateScript) +***********************************************************************/ + +} +void ScrollTemplateScript::SetScroll(::vl::vint totalPixels, ::vl::vint newOffset, ::vl::presentation::templates::GuiScrollTemplate* scrollTemplate) +{ + auto totalSize = ::vl::__vwsn::This(scrollTemplate)->GetTotalSize(); + auto ratio = (static_cast(newOffset) / static_cast(totalPixels)); + auto newPosition = static_cast<::vl::vint>(::vl::reflection::description::Math::Round((ratio * static_cast(totalSize)))); + auto offset1 = static_cast<::vl::vint>(::vl::reflection::description::Math::Round(((static_cast(newPosition) / static_cast(totalSize)) * static_cast(totalPixels)))); + auto offset2 = static_cast<::vl::vint>(::vl::reflection::description::Math::Round(((static_cast((newPosition + static_cast<::vl::vint>(1))) / static_cast(totalSize)) * static_cast(totalPixels)))); + auto delta1 = (offset1 - newOffset); + auto delta2 = (offset2 - newOffset); + if ((delta1 < static_cast<::vl::vint>(0))) + { + (delta1 = (- delta1)); + } + if ((delta2 < static_cast<::vl::vint>(0))) + { + (delta2 = (- delta2)); + } + if ((delta1 < delta2)) + { + ::vl::__vwsn::This(::vl::__vwsn::This(scrollTemplate)->GetCommands())->SetPosition(newPosition); + } + else + { + ::vl::__vwsn::This(::vl::__vwsn::This(scrollTemplate)->GetCommands())->SetPosition((newPosition + static_cast<::vl::vint>(1))); + } +} + +ScrollTemplateScript::ScrollTemplateScript() +{ +} + +#undef GLOBAL_SYMBOL +#undef GLOBAL_NAME +#undef GLOBAL_OBJ +#undef USERIMPL + +#if defined( _MSC_VER) +#pragma warning(pop) +#elif defined(__GNUC__) +#pragma GCC diagnostic pop +#elif defined(__clang__) +#pragma clang diagnostic pop +#endif + + +/*********************************************************************** +.\DARKSKINRESOURCE.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace user_resource + { + using namespace collections; + using namespace stream; + using namespace controls; + + class DarkSkinResourceReader + { + public: + static const vint parserBufferLength = 2949; // 2949 bytes before compressing + static const vint parserBufferBlock = 1024; + static const vint parserBufferRemain = 901; + static const vint parserBufferRows = 3; + static const char* parserBuffer[3]; + + static void ReadToStream(vl::stream::MemoryStream& stream) + { + DecompressStream(parserBuffer, false, parserBufferRows, parserBufferBlock, parserBufferRemain, stream); + } + }; + + const char* DarkSkinResourceReader::parserBuffer[] = { + "\x06\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x44\x6F\x63\x08\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x49\x6E\x73\x74\x61\x6E\x63\x65\x06\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x53\x63\x72\x69\x70\x74\x0D\x00\x00\x00\x00\x00\x00\x00\x0D\x00\x00\x00\x49\x6E\x73\x74\x61\x6E\x63\x65\x53\x74\x79\x6C\x65\x04\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x54\x65\x78\x74\x0F\x00\x00\x00\x00\x00\x00\x00\x0F\x00\x00\x00\x43\x6C\x61\x73\x73\x4E\x61\x6D\x65\x52\x65\x63\x6F\x72\x64\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x44\x61\x72\x6B\x53\x6B\x69\x6E\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x42\x61\x73\x65\x6C\x69\x6E\x65\x44\x6F\x63\x75\x6D\x65\x6E\x74\xBE\x00\x00\x00\x00\x00\x00\x00\xBE\x00\x00\x00\x3C\x44\x6F\x63\x3E\x3C\x43\x6F\x6E\x74\x65\x6E\x74\x2F\x3E\x3C\x53\x74\x79\x6C\x65\x73\x3E\x3C\x53\x74\x79\x6C\x65\x20\x6E\x61\x6D\x65\x3D\x22\x23\x44\x65\x66\x61\x75\x6C\x74\x2D\x4F\x76\x65\x72\x72\x69\x64\x65\x22\x3E\x3C\x63\x6F\x6C\x6F\x72\x3E\x23\x46\x46\x46\x46\x46\x46\x3C\x2F\x63\x6F\x6C\x6F\x72\x3E\x3C\x2F\x53\x74\x79\x6C\x65\x3E\x3C\x53\x74\x79\x6C\x65\x20\x6E\x61\x6D\x65\x3D\x22\x23\x53\x65\x6C\x65\x63\x74\x69\x6F\x6E\x2D\x4F\x76\x65\x72\x72\x69\x64\x65\x22\x3E\x3C\x63\x6F\x6C\x6F\x72\x3E\x23\x46\x46\x46\x46\x46\x46\x3C\x2F\x63\x6F\x6C\x6F\x72\x3E\x3C\x62\x6B\x63\x6F\x6C\x6F\x72\x3E\x23\x30\x30\x37\x41\x43\x43\x3C\x2F\x62\x6B\x63\x6F\x6C\x6F\x72\x3E\x3C\x2F\x53\x74\x79\x6C\x65\x3E\x3C\x2F\x53\x74\x79\x6C\x65\x73\x3E\x3C\x2F\x44\x6F\x63\x3E\x00\x00\x00\x00\x00\x00\x00\x00\x0C\x00\x00\x00\x00\x00\x00\x00\x0C\x00\x00\x00\x47\x61\x63\x47\x65\x6E\x43\x6F\x6E\x66\x69\x67\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x43\x70\x70\x05\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x0D\x00\x00\x00\x00\x00\x00\x00\x0D\x00\x00\x00\x43\x70\x70\x43\x6F\x6D\x70\x72\x65\x73\x73\x65\x64\x14\x00\x00\x00\x00\x00\x00\x00\x14\x00\x00\x00\x44\x61\x72\x6B\x53\x6B\x69\x6E\x52\x65\x73\x6F\x75\x72\x63\x65\x2E\x63\x70\x70\x04\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x4E\x61\x6D\x65\x08\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x44\x61\x72\x6B\x53\x6B\x69\x6E\x04\x00\x00\x00\x00\x00\x00\x00\x0D\x00\x00\x00\x00\x00\x00\x00\x0D\x00\x00\x00\x4E\x6F\x72\x6D\x61\x6C\x49\x6E\x63\x6C\x75\x64\x65\x10\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x2E\x2E\x2F\x2E\x2E\x2F\x2E\x2E\x2F\x47\x61\x63\x55\x49\x2E\x68\x04\x00\x00\x00\x00\x00\x00\x00\x11\x00\x00\x00\x00\x00\x00\x00\x11\x00\x00\x00\x52\x65\x66\x6C\x65\x63\x74\x69\x6F\x6E\x49\x6E\x63\x6C\x75\x64\x65\x39\x00\x00\x00\x00\x00\x00\x00\x39\x00\x00\x00\x2E\x2E\x2F\x2E\x2E\x2F\x2E\x2E\x2F\x52\x65\x66\x6C\x65\x63\x74\x69\x6F\x6E\x2F\x54\x79\x70\x65\x44\x65\x73\x63\x72\x69\x70\x74\x6F\x72\x73\x2F\x47\x75\x69\x52\x65\x66\x6C\x65\x63\x74\x69\x6F\x6E\x50\x6C\x75\x67\x69\x6E\x2E\x68\x04\x00\x00\x00\x00\x00\x00\x00\x0C\x00\x00\x00\x00\x00\x00\x00\x0C\x00\x00\x00\x53\x6F\x75\x72\x63\x65\x46\x6F\x6C\x64\x65\x72\x06\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x53\x6F\x75\x72\x63\x65\x00\x00\x00\x00\x00\x00\x00\x00\x0B\x00\x00\x00\x00\x00\x00\x00\x0B\x00\x00\x00\x50\x72\x65\x63\x6F\x6D\x70\x69\x6C\x65\x64\x01\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x0F\x00\x00\x00\x00\x00\x00\x00\x0F\x00\x00\x00\x43\x6C\x61\x73\x73\x4E\x61\x6D\x65\x52\x65\x63\x6F\x72\x64\x31\x00\x00\x00\x00\x00\x00\x00\x24\x00\x00\x00\x00\x00\x00\x00\x24\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x42\x6F\x74\x74\x6F\x6D\x53\x63\x72\x6F\x6C\x6C\x42\x75\x74\x74\x6F\x6E\x54\x65\x6D\x70\x6C\x61\x74\x65\x18\x00\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x42\x75\x74\x74\x6F\x6E\x54\x65\x6D\x70\x6C\x61\x74\x65\x1A\x00\x00\x00\x00\x00\x00\x00\x1A\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x43\x68\x65\x63\x6B\x42\x6F\x78\x54\x65\x6D\x70\x6C\x61\x74\x65\x25\x00\x00\x00\x00\x00\x00\x00\x25\x00\x00\x00", + "\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x43\x68\x65\x63\x6B\x49\x74\x65\x6D\x42\x61\x63\x6B\x67\x72\x6F\x75\x6E\x64\x54\x65\x6D\x70\x6C\x61\x74\x65\x1A\x00\x00\x00\x00\x00\x00\x00\x1A\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x43\x6F\x6D\x62\x6F\x42\x6F\x78\x54\x65\x6D\x70\x6C\x61\x74\x65\x1F\x00\x00\x00\x00\x00\x00\x00\x1F\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x43\x75\x73\x74\x6F\x6D\x43\x6F\x6E\x74\x72\x6F\x6C\x54\x65\x6D\x70\x6C\x61\x74\x65\x0F\x00\x00\x00\x00\x00\x00\x00\x0F\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x54\x68\x65\x6D\x65\x1C\x00\x00\x00\x00\x00\x00\x00\x1C\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x44\x61\x74\x65\x50\x69\x63\x6B\x65\x72\x54\x65\x6D\x70\x6C\x61\x74\x65\x1F\x00\x00\x00\x00\x00\x00\x00\x1F\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x44\x6F\x63\x75\x6D\x65\x6E\x74\x4C\x61\x62\x65\x6C\x54\x65\x6D\x70\x6C\x61\x74\x65\x21\x00\x00\x00\x00\x00\x00\x00\x21\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x44\x6F\x63\x75\x6D\x65\x6E\x74\x54\x65\x78\x74\x42\x6F\x78\x54\x65\x6D\x70\x6C\x61\x74\x65\x20\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x44\x6F\x63\x75\x6D\x65\x6E\x74\x56\x69\x65\x77\x65\x72\x54\x65\x6D\x70\x6C\x61\x74\x65\x24\x00\x00\x00\x00\x00\x00\x00\x24\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x45\x78\x70\x61\x6E\x64\x69\x6E\x67\x44\x65\x63\x6F\x72\x61\x74\x6F\x72\x54\x65\x6D\x70\x6C\x61\x74\x65\x1A\x00\x00\x00\x00\x00\x00\x00\x1A\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x47\x72\x6F\x75\x70\x42\x6F\x78\x54\x65\x6D\x70\x6C\x61\x74\x65\x1F\x00\x00\x00\x00\x00\x00\x00\x1F\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x48\x53\x63\x72\x6F\x6C\x6C\x48\x61\x6E\x64\x6C\x65\x54\x65\x6D\x70\x6C\x61\x74\x65\x19\x00\x00\x00\x00\x00\x00\x00\x19\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x48\x53\x63\x72\x6F\x6C\x6C\x54\x65\x6D\x70\x6C\x61\x74\x65\x1A\x00\x00\x00\x00\x00\x00\x00\x1A\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x48\x54\x72\x61\x63\x6B\x65\x72\x54\x65\x6D\x70\x6C\x61\x74\x65\x20\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x49\x74\x65\x6D\x42\x61\x63\x6B\x67\x72\x6F\x75\x6E\x64\x54\x65\x6D\x70\x6C\x61\x74\x65\x17\x00\x00\x00\x00\x00\x00\x00\x17\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x4C\x61\x62\x65\x6C\x54\x65\x6D\x70\x6C\x61\x74\x65\x22\x00\x00\x00\x00\x00\x00\x00\x22\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x4C\x65\x66\x74\x53\x63\x72\x6F\x6C\x6C\x42\x75\x74\x74\x6F\x6E\x54\x65\x6D\x70\x6C\x61\x74\x65\x26\x00\x00\x00\x00\x00\x00\x00\x26\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x4C\x69\x73\x74\x56\x69\x65\x77\x43\x6F\x6C\x75\x6D\x6E\x48\x65\x61\x64\x65\x72\x54\x65\x6D\x70\x6C\x61\x74\x65\x1A\x00\x00\x00\x00\x00\x00\x00\x1A\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x4C\x69\x73\x74\x56\x69\x65\x77\x54\x65\x6D\x70\x6C\x61\x74\x65\x1F\x00\x00\x00\x00\x00\x00\x00\x1F\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x4D\x65\x6E\x75\x42\x61\x72\x42\x75\x74\x74\x6F\x6E\x54\x65\x6D\x70\x6C\x61\x74\x65\x20\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x4D\x65\x6E\x75\x49\x74\x65\x6D\x42\x75\x74\x74\x6F\x6E\x54\x65\x6D\x70\x6C\x61\x74\x65\x1E\x00\x00\x00\x00\x00\x00\x00\x1E\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x4D\x65\x6E\x75\x53\x70\x6C\x69\x74\x74\x65\x72\x54\x65\x6D\x70\x6C\x61\x74\x65\x22\x00\x00\x00\x00\x00\x00\x00\x22\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x4D\x75\x6C\x74\x69\x6C\x69\x6E\x65\x54\x65\x78\x74\x42\x6F\x78\x54\x65\x6D\x70\x6C\x61\x74\x65\x1D\x00\x00\x00\x00\x00\x00\x00\x1D\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x50\x72\x6F\x67\x72\x65\x73\x73\x42\x61\x72\x54\x65\x6D\x70\x6C\x61\x74\x65\x1D\x00\x00\x00\x00\x00\x00\x00\x1D\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x52\x61\x64\x69\x6F\x42\x75\x74\x74\x6F\x6E\x54\x65\x6D\x70\x6C\x61\x74\x65\x23\x00\x00\x00\x00\x00\x00\x00\x23\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x52\x69\x67\x68\x74\x53\x63\x72\x6F\x6C\x6C", + "\x42\x75\x74\x74\x6F\x6E\x54\x65\x6D\x70\x6C\x61\x74\x65\x1C\x00\x00\x00\x00\x00\x00\x00\x1C\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x53\x63\x72\x6F\x6C\x6C\x56\x69\x65\x77\x54\x65\x6D\x70\x6C\x61\x74\x65\x1D\x00\x00\x00\x00\x00\x00\x00\x1D\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x53\x68\x6F\x72\x74\x63\x75\x74\x4B\x65\x79\x54\x65\x6D\x70\x6C\x61\x74\x65\x23\x00\x00\x00\x00\x00\x00\x00\x23\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x53\x69\x6E\x67\x6C\x65\x6C\x69\x6E\x65\x54\x65\x78\x74\x42\x6F\x78\x54\x65\x6D\x70\x6C\x61\x74\x65\x1D\x00\x00\x00\x00\x00\x00\x00\x1D\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x54\x61\x62\x44\x72\x6F\x70\x64\x6F\x77\x6E\x54\x65\x6D\x70\x6C\x61\x74\x65\x1B\x00\x00\x00\x00\x00\x00\x00\x1B\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x54\x61\x62\x48\x65\x61\x64\x65\x72\x54\x65\x6D\x70\x6C\x61\x74\x65\x15\x00\x00\x00\x00\x00\x00\x00\x15\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x54\x61\x62\x54\x65\x6D\x70\x6C\x61\x74\x65\x1A\x00\x00\x00\x00\x00\x00\x00\x1A\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x54\x65\x78\x74\x4C\x69\x73\x74\x54\x65\x6D\x70\x6C\x61\x74\x65\x25\x00\x00\x00\x00\x00\x00\x00\x25\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x54\x6F\x6F\x6C\x73\x74\x72\x69\x70\x53\x70\x6C\x69\x74\x41\x72\x72\x6F\x77\x54\x65\x6D\x70\x6C\x61\x74\x65\x21\x00\x00\x00\x00\x00\x00\x00\x21\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x54\x6F\x6F\x6C\x73\x74\x72\x69\x70\x42\x75\x74\x74\x6F\x6E\x54\x65\x6D\x70\x6C\x61\x74\x65\x29\x00\x00\x00\x00\x00\x00\x00\x29\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x54\x6F\x6F\x6C\x73\x74\x72\x69\x70\x44\x72\x6F\x70\x64\x6F\x77\x6E\x42\x75\x74\x74\x6F\x6E\x54\x65\x6D\x70\x6C\x61\x74\x65\x1F\x00\x00\x00\x00\x00\x00\x00\x1F\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x54\x6F\x6F\x6C\x73\x74\x72\x69\x70\x4D\x65\x6E\x75\x54\x65\x6D\x70\x6C\x61\x74\x65\x26\x00\x00\x00\x00\x00\x00\x00\x26\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x54\x6F\x6F\x6C\x73\x74\x72\x69\x70\x53\x70\x6C\x69\x74\x42\x75\x74\x74\x6F\x6E\x54\x65\x6D\x70\x6C\x61\x74\x65\x23\x00\x00\x00\x00\x00\x00\x00\x23\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x54\x6F\x6F\x6C\x73\x74\x72\x69\x70\x53\x70\x6C\x69\x74\x74\x65\x72\x54\x65\x6D\x70\x6C\x61\x74\x65\x1B\x00\x00\x00\x00\x00\x00\x00\x1B\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x54\x6F\x6F\x6C\x73\x74\x72\x69\x70\x54\x65\x6D\x70\x6C\x61\x74\x65\x19\x00\x00\x00\x00\x00\x00\x00\x19\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x54\x6F\x6F\x6C\x74\x69\x70\x54\x65\x6D\x70\x6C\x61\x74\x65\x21\x00\x00\x00\x00\x00\x00\x00\x21\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x54\x6F\x70\x53\x63\x72\x6F\x6C\x6C\x42\x75\x74\x74\x6F\x6E\x54\x65\x6D\x70\x6C\x61\x74\x65\x1A\x00\x00\x00\x00\x00\x00\x00\x1A\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x54\x72\x65\x65\x56\x69\x65\x77\x54\x65\x6D\x70\x6C\x61\x74\x65\x1F\x00\x00\x00\x00\x00\x00\x00\x1F\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x56\x53\x63\x72\x6F\x6C\x6C\x48\x61\x6E\x64\x6C\x65\x54\x65\x6D\x70\x6C\x61\x74\x65\x19\x00\x00\x00\x00\x00\x00\x00\x19\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x56\x53\x63\x72\x6F\x6C\x6C\x54\x65\x6D\x70\x6C\x61\x74\x65\x1A\x00\x00\x00\x00\x00\x00\x00\x1A\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x56\x54\x72\x61\x63\x6B\x65\x72\x54\x65\x6D\x70\x6C\x61\x74\x65\x18\x00\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00\x64\x61\x72\x6B\x73\x6B\x69\x6E\x3A\x3A\x57\x69\x6E\x64\x6F\x77\x54\x65\x6D\x70\x6C\x61\x74\x65\x00\x00\x00\x00\x00\x00\x00\x00", + }; + + class DarkSkinResourceLoaderPlugin : public Object, public IGuiPlugin + { + public: + + GUI_PLUGIN_NAME(GacGen_DarkSkinResourceLoader) + { + GUI_PLUGIN_DEPEND(GacUI_Res_Resource); + GUI_PLUGIN_DEPEND(GacUI_Res_TypeResolvers); +#ifndef VCZH_DEBUG_NO_REFLECTION + GUI_PLUGIN_DEPEND(GacUI_Instance_Reflection); + GUI_PLUGIN_DEPEND(GacUI_Compiler_WorkflowTypeResolvers); +#endif + } + + void Load()override + { + List errors; + MemoryStream resourceStream; + DarkSkinResourceReader::ReadToStream(resourceStream); + resourceStream.SeekFromBegin(0); + auto resource = GuiResource::LoadPrecompiledBinary(resourceStream, errors); + GetResourceManager()->SetResource(L"DarkSkin", resource, GuiResourceUsage::InstanceClass); + } + + void Unload()override + { + } + }; + GUI_REGISTER_PLUGIN(DarkSkinResourceLoaderPlugin) + } + } +} + diff --git a/Import/Skins/DarkSkin/DarkSkin.h b/Import/Skins/DarkSkin/DarkSkin.h new file mode 100644 index 00000000..7a19ab4a --- /dev/null +++ b/Import/Skins/DarkSkin/DarkSkin.h @@ -0,0 +1,7016 @@ +/*********************************************************************** +THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY +DEVELOPER: Zihan Chen(vczh) +***********************************************************************/ +#include "GacUI.h" +#include "Vlpp.h" + +/*********************************************************************** +.\DARKSKINPARTIALCLASSES.H +***********************************************************************/ +/*********************************************************************** +!!!!!! DO NOT MODIFY !!!!!! + +GacGen.exe Resource.xml + +This file is generated by Workflow compiler +https://github.com/vczh-libraries +***********************************************************************/ + +#ifndef VCZH_WORKFLOW_COMPILER_GENERATED_DARKSKINPARTIALCLASSES +#define VCZH_WORKFLOW_COMPILER_GENERATED_DARKSKINPARTIALCLASSES + + +#if defined( _MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#elif defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wparentheses-equality" +#elif defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wparentheses-equality" +#endif + +namespace vl_workflow_global +{ + struct __vwsnf100_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf101_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf102_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf103_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf104_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf105_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf106_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf107_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf108_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf109_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf110_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf111_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf112_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf113_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf114_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf115_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf116_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf117_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf118_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf119_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf11_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf120_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf121_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf122_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf123_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf124_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf125_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf126_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf127_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf128_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf129_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf12_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf130_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf131_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf132_DarkSkin_darkskin_MultilineTextBoxTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf133_DarkSkin_darkskin_MultilineTextBoxTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf134_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf135_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf136_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf137_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf138_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf139_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf13_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf140_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf141_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf142_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf143_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf144_DarkSkin_darkskin_ScrollViewTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf145_DarkSkin_darkskin_ScrollViewTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf146_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf147_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf148_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf149_DarkSkin_darkskin_TabDropdownTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf14_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf150_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf151_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf152_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf153_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf154_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf155_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf156_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf157_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf158_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf159_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf160_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf161_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf162_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf163_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf164_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf165_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf166_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf167_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf168_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf169_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf170_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf171_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf172_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf173_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf174_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf175_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf176_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf177_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf178_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf179_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf17_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf180_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf181_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf182_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf183_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf184_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf185_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf186_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf187_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf188_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf189_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf190_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf191_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf192_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf193_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf194_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf195_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf196_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf197_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf198_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf199_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf19_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf200_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf201_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf202_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf203_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf204_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf205_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf206_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf207_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf208_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf209_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf210_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf211_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf212_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf213_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf214_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf215_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf216_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf217_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf218_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf219_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf220_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf221_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf23_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf24_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf25_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf26_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf27_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf28_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf29_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf30_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf31_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf32_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf33_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf34_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf35_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf36_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf37_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf38_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf39_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf40_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf41_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf42_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf43_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf44_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf45_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf46_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf47_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf48_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf49_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf50_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf51_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf52_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf53_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf54_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf55_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf56_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf57_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf58_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf59_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf5_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf60_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + struct __vwsnf61_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf62_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf63_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf64_DarkSkin_darkskin_DocumentViewerTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf65_DarkSkin_darkskin_DocumentViewerTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf66_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf67_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf68_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf69_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf70_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf71_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf72_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf73_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf74_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf75_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf76_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf77_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf78_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf79_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf7_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf80_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf81_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf82_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf83_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf84_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf85_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf86_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf87_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf88_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf89_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf90_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf91_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf92_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf93_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf94_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf95_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf96_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf97_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf98_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf99_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance__; + struct __vwsnf9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__; + class __vwsnc100_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc101_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc102_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc103_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc104_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc105_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc106_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc107_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc108_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc109_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc110_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc111_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc112_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc113_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc114_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc116_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc117_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc11_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc12_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc13_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc14_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc17_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc19_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc23_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc24_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc25_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc26_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc27_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc28_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc29_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc30_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc31_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc32_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc33_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc34_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc35_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc36_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc38_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc39_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc40_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc41_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc42_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc43_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc44_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc45_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc46_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc47_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc48_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc49_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc50_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc51_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc52_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc53_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc54_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc55_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc56_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc57_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc58_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc59_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc5_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc60_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc61_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc62_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc63_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc64_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc65_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc66_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc67_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc68_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc69_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc70_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc71_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc72_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc73_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc74_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc75_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc76_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc77_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc78_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc79_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc7_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc80_DarkSkin_darkskin_TabDropdownTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc81_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc82_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc83_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc84_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc85_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc86_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc87_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc88_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc89_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc90_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc91_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc92_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc93_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc94_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc95_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc96_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc97_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc98_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc99_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + class __vwsnc9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; +} + +namespace darkskin +{ + class BottomScrollButtonTemplateConstructor; + class BottomScrollButtonTemplate; + class ButtonTemplateConstructor; + class ButtonTemplate; + class CheckBoxTemplateConstructor; + class CheckBoxTemplate; + class CheckItemBackgroundTemplateConstructor; + class CheckItemBackgroundTemplate; + class ComboBoxTemplateConstructor; + class ComboBoxTemplate; + class CustomControlTemplateConstructor; + class CustomControlTemplate; + class ThemeConstructor; + class Theme; + class DatePickerTemplateConstructor; + class DatePickerTemplate; + class DocumentLabelTemplateConstructor; + class DocumentLabelTemplate; + class DocumentTextBoxTemplateConstructor; + class DocumentTextBoxTemplate; + class DocumentViewerTemplateConstructor; + class DocumentViewerTemplate; + class ExpandingDecoratorTemplateConstructor; + class ExpandingDecoratorTemplate; + class GroupBoxTemplateConstructor; + class GroupBoxTemplate; + class HScrollHandleTemplateConstructor; + class HScrollHandleTemplate; + class HScrollTemplateConstructor; + class HScrollTemplate; + class HTrackerTemplateConstructor; + class HTrackerTemplate; + class ItemBackgroundTemplateConstructor; + class ItemBackgroundTemplate; + class LabelTemplateConstructor; + class LabelTemplate; + class LeftScrollButtonTemplateConstructor; + class LeftScrollButtonTemplate; + class ListViewColumnHeaderTemplateConstructor; + class ListViewColumnHeaderTemplate; + class ListViewTemplateConstructor; + class ListViewTemplate; + class MenuBarButtonTemplateConstructor; + class MenuBarButtonTemplate; + class MenuItemButtonTemplateConstructor; + class MenuItemButtonTemplate; + class MenuSplitterTemplateConstructor; + class MenuSplitterTemplate; + class MultilineTextBoxTemplateConstructor; + class MultilineTextBoxTemplate; + class ProgressBarTemplateConstructor; + class ProgressBarTemplate; + class RadioButtonTemplateConstructor; + class RadioButtonTemplate; + class RightScrollButtonTemplateConstructor; + class RightScrollButtonTemplate; + class ScrollViewTemplateConstructor; + class ScrollViewTemplate; + class ShortcutKeyTemplateConstructor; + class ShortcutKeyTemplate; + class SinglelineTextBoxTemplateConstructor; + class SinglelineTextBoxTemplate; + class TabDropdownTemplateConstructor; + class TabDropdownTemplate; + class TabHeaderTemplateConstructor; + class TabHeaderTemplate; + class TabTemplateConstructor; + class TabTemplate; + class TextListTemplateConstructor; + class TextListTemplate; + class ToolstripSplitArrowTemplateConstructor; + class ToolstripSplitArrowTemplate; + class ToolstripButtonTemplateConstructor; + class ToolstripButtonTemplate; + class ToolstripDropdownButtonTemplateConstructor; + class ToolstripDropdownButtonTemplate; + class ToolstripMenuTemplateConstructor; + class ToolstripMenuTemplate; + class ToolstripSplitButtonTemplateConstructor; + class ToolstripSplitButtonTemplate; + class ToolstripSplitterTemplateConstructor; + class ToolstripSplitterTemplate; + class ToolstripTemplateConstructor; + class ToolstripTemplate; + class TooltipTemplateConstructor; + class TooltipTemplate; + class TopScrollButtonTemplateConstructor; + class TopScrollButtonTemplate; + class TreeViewTemplateConstructor; + class TreeViewTemplate; + class VScrollHandleTemplateConstructor; + class VScrollHandleTemplate; + class VScrollTemplateConstructor; + class VScrollTemplate; + class VTrackerTemplateConstructor; + class VTrackerTemplate; + class WindowTemplateConstructor; + class WindowTemplate; +} +class ScrollTemplateScript; + +namespace darkskin +{ + class BottomScrollButtonTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::BottomScrollButtonTemplate* self = static_cast<::darkskin::BottomScrollButtonTemplate*>(nullptr); + ::vl::presentation::compositions::GuiTableComposition* __vwsn_precompile_0 = static_cast<::vl::presentation::compositions::GuiTableComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_1 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement> __vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement>(); + void __vwsn_initialize_instance_(::darkskin::BottomScrollButtonTemplate* __vwsn_this_); + public: + BottomScrollButtonTemplateConstructor(); + }; + + class BottomScrollButtonTemplate : public ::vl::presentation::templates::GuiButtonTemplate, public ::darkskin::BottomScrollButtonTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::BottomScrollButtonTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + BottomScrollButtonTemplate(); + ~BottomScrollButtonTemplate(); + }; + + class ButtonTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc5_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc7_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf5_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf7_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::ButtonTemplate* self = static_cast<::darkskin::ButtonTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_1 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_3 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement> __vwsn_precompile_4 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(); + void __vwsn_initialize_instance_(::darkskin::ButtonTemplate* __vwsn_this_); + public: + ButtonTemplateConstructor(); + }; + + class ButtonTemplate : public ::vl::presentation::templates::GuiButtonTemplate, public ::darkskin::ButtonTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::ButtonTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc5_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc7_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf5_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf7_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + ButtonTemplate(); + ~ButtonTemplate(); + }; + + class CheckBoxTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc11_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc12_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc13_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc14_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf11_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf12_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf13_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf14_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::CheckBoxTemplate* self = static_cast<::darkskin::CheckBoxTemplate*>(nullptr); + ::vl::presentation::compositions::GuiTableComposition* __vwsn_precompile_0 = static_cast<::vl::presentation::compositions::GuiTableComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_1 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_2 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_4 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_5 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_6 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement> __vwsn_precompile_7 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_8 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_9 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement> __vwsn_precompile_10 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(); + void __vwsn_initialize_instance_(::darkskin::CheckBoxTemplate* __vwsn_this_); + public: + CheckBoxTemplateConstructor(); + }; + + class CheckBoxTemplate : public ::vl::presentation::templates::GuiSelectableButtonTemplate, public ::darkskin::CheckBoxTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::CheckBoxTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc11_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc12_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc13_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc14_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf11_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf12_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf13_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf14_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + CheckBoxTemplate(); + ~CheckBoxTemplate(); + }; + + class CheckItemBackgroundTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::vl::presentation::compositions::GuiBoundsComposition* container = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::darkskin::CheckItemBackgroundTemplate* self = static_cast<::darkskin::CheckItemBackgroundTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + void __vwsn_initialize_instance_(::darkskin::CheckItemBackgroundTemplate* __vwsn_this_); + public: + CheckItemBackgroundTemplateConstructor(); + }; + + class CheckItemBackgroundTemplate : public ::vl::presentation::templates::GuiSelectableButtonTemplate, public ::darkskin::CheckItemBackgroundTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::CheckItemBackgroundTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + CheckItemBackgroundTemplate(); + ~CheckItemBackgroundTemplate(); + }; + + class ComboBoxTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc17_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc19_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf17_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf19_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf23_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf24_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::vl::presentation::compositions::GuiBoundsComposition* container = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::darkskin::ComboBoxTemplate* self = static_cast<::darkskin::ComboBoxTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_1 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_3 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement> __vwsn_precompile_4 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(); + ::vl::presentation::compositions::GuiTableComposition* __vwsn_precompile_5 = static_cast<::vl::presentation::compositions::GuiTableComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_6 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_7 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement> __vwsn_precompile_8 = ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement>(); + void __vwsn_initialize_instance_(::darkskin::ComboBoxTemplate* __vwsn_this_); + public: + ComboBoxTemplateConstructor(); + }; + + class ComboBoxTemplate : public ::vl::presentation::templates::GuiDateComboBoxTemplate, public ::darkskin::ComboBoxTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::ComboBoxTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc17_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc19_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf17_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf19_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf23_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf24_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + ComboBoxTemplate(); + ~ComboBoxTemplate(); + }; + + class CustomControlTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::CustomControlTemplate* __vwsn_precompile_0 = static_cast<::darkskin::CustomControlTemplate*>(nullptr); + void __vwsn_initialize_instance_(::darkskin::CustomControlTemplate* __vwsn_this_); + public: + CustomControlTemplateConstructor(); + }; + + class CustomControlTemplate : public ::vl::presentation::templates::GuiControlTemplate, public ::darkskin::CustomControlTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::CustomControlTemplateConstructor; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + CustomControlTemplate(); + ~CustomControlTemplate(); + }; + + class ThemeConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend struct ::vl_workflow_global::__vwsnf25_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf26_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf27_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf28_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf29_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf30_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf31_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf32_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf33_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf34_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf35_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf36_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf37_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf38_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf39_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf40_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf41_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf42_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf43_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf44_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf45_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf46_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf47_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf48_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf49_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf50_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf51_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf52_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf53_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf54_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf55_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf56_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf57_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf58_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf59_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf60_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::Theme* __vwsn_precompile_0 = static_cast<::darkskin::Theme*>(nullptr); + void __vwsn_initialize_instance_(::darkskin::Theme* __vwsn_this_); + public: + ThemeConstructor(); + }; + + class Theme : public ::vl::presentation::theme::ThemeTemplates, public ::darkskin::ThemeConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::ThemeConstructor; + friend struct ::vl_workflow_global::__vwsnf25_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf26_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf27_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf28_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf29_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf30_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf31_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf32_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf33_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf34_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf35_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf36_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf37_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf38_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf39_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf40_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf41_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf42_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf43_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf44_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf45_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf46_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf47_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf48_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf49_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf50_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf51_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf52_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf53_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf54_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf55_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf56_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf57_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf58_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf59_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf60_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + Theme(); + ~Theme(); + }; + + class DatePickerTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend struct ::vl_workflow_global::__vwsnf61_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf62_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf63_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::DatePickerTemplate* self = static_cast<::darkskin::DatePickerTemplate*>(nullptr); + void __vwsn_initialize_instance_(::darkskin::DatePickerTemplate* __vwsn_this_); + public: + DatePickerTemplateConstructor(); + }; + + class DatePickerTemplate : public ::vl::presentation::templates::GuiDatePickerTemplate, public ::darkskin::DatePickerTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::DatePickerTemplateConstructor; + friend struct ::vl_workflow_global::__vwsnf61_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf62_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf63_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + DatePickerTemplate(); + ~DatePickerTemplate(); + }; + + class DocumentLabelTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::DocumentLabelTemplate* self = static_cast<::darkskin::DocumentLabelTemplate*>(nullptr); + void __vwsn_initialize_instance_(::darkskin::DocumentLabelTemplate* __vwsn_this_); + public: + DocumentLabelTemplateConstructor(); + }; + + class DocumentLabelTemplate : public ::vl::presentation::templates::GuiDocumentLabelTemplate, public ::darkskin::DocumentLabelTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::DocumentLabelTemplateConstructor; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + DocumentLabelTemplate(); + ~DocumentLabelTemplate(); + }; + + class DocumentTextBoxTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::vl::presentation::compositions::GuiBoundsComposition* container = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::darkskin::DocumentTextBoxTemplate* self = static_cast<::darkskin::DocumentTextBoxTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + void __vwsn_initialize_instance_(::darkskin::DocumentTextBoxTemplate* __vwsn_this_); + public: + DocumentTextBoxTemplateConstructor(); + }; + + class DocumentTextBoxTemplate : public ::vl::presentation::templates::GuiDocumentLabelTemplate, public ::darkskin::DocumentTextBoxTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::DocumentTextBoxTemplateConstructor; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + DocumentTextBoxTemplate(); + ~DocumentTextBoxTemplate(); + }; + + class DocumentViewerTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend struct ::vl_workflow_global::__vwsnf64_DarkSkin_darkskin_DocumentViewerTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf65_DarkSkin_darkskin_DocumentViewerTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::vl::presentation::compositions::GuiBoundsComposition* container = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::darkskin::DocumentViewerTemplate* self = static_cast<::darkskin::DocumentViewerTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + void __vwsn_initialize_instance_(::darkskin::DocumentViewerTemplate* __vwsn_this_); + public: + DocumentViewerTemplateConstructor(); + }; + + class DocumentViewerTemplate : public ::vl::presentation::templates::GuiDocumentViewerTemplate, public ::darkskin::DocumentViewerTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::DocumentViewerTemplateConstructor; + friend struct ::vl_workflow_global::__vwsnf64_DarkSkin_darkskin_DocumentViewerTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf65_DarkSkin_darkskin_DocumentViewerTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + DocumentViewerTemplate(); + ~DocumentViewerTemplate(); + }; + + class ExpandingDecoratorTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc23_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc24_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc25_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc26_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc27_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc28_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf66_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf67_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf68_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf69_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf70_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf71_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::ExpandingDecoratorTemplate* self = static_cast<::darkskin::ExpandingDecoratorTemplate*>(nullptr); + ::vl::presentation::compositions::GuiTableComposition* __vwsn_precompile_0 = static_cast<::vl::presentation::compositions::GuiTableComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_1 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_2 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement> __vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_4 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement> __vwsn_precompile_5 = ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement>(); + void __vwsn_initialize_instance_(::darkskin::ExpandingDecoratorTemplate* __vwsn_this_); + public: + ExpandingDecoratorTemplateConstructor(); + }; + + class ExpandingDecoratorTemplate : public ::vl::presentation::templates::GuiSelectableButtonTemplate, public ::darkskin::ExpandingDecoratorTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::ExpandingDecoratorTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc23_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc24_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc25_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc26_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc27_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc28_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf66_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf67_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf68_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf69_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf70_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf71_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + ExpandingDecoratorTemplate(); + ~ExpandingDecoratorTemplate(); + }; + + class GroupBoxTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc29_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc30_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc31_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf72_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf73_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf74_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::vl::presentation::compositions::GuiBoundsComposition* container = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::darkskin::GroupBoxTemplate* self = static_cast<::darkskin::GroupBoxTemplate*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* titleBounds = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_1 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_4 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement> __vwsn_precompile_5 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(); + void __vwsn_initialize_instance_(::darkskin::GroupBoxTemplate* __vwsn_this_); + public: + GroupBoxTemplateConstructor(); + }; + + class GroupBoxTemplate : public ::vl::presentation::templates::GuiControlTemplate, public ::darkskin::GroupBoxTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::GroupBoxTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc29_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc30_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc31_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf72_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf73_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf74_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + GroupBoxTemplate(); + ~GroupBoxTemplate(); + }; + + class HScrollHandleTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc32_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf75_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::HScrollHandleTemplate* self = static_cast<::darkskin::HScrollHandleTemplate*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_0 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + void __vwsn_initialize_instance_(::darkskin::HScrollHandleTemplate* __vwsn_this_); + public: + HScrollHandleTemplateConstructor(); + }; + + class HScrollHandleTemplate : public ::vl::presentation::templates::GuiButtonTemplate, public ::darkskin::HScrollHandleTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::HScrollHandleTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc32_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf75_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + HScrollHandleTemplate(); + ~HScrollHandleTemplate(); + }; + + class HScrollTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc33_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc34_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc35_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc36_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf76_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf77_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf78_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf79_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf80_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf81_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf82_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf83_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf84_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf85_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf86_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf87_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf88_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf89_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::HScrollTemplate* self = static_cast<::darkskin::HScrollTemplate*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* handleContainer = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::presentation::compositions::GuiPartialViewComposition* handle = static_cast<::vl::presentation::compositions::GuiPartialViewComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiSideAlignedComposition* __vwsn_precompile_1 = static_cast<::vl::presentation::compositions::GuiSideAlignedComposition*>(nullptr); + ::vl::presentation::controls::GuiButton* __vwsn_precompile_2 = static_cast<::vl::presentation::controls::GuiButton*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_3 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::presentation::compositions::GuiSideAlignedComposition* __vwsn_precompile_4 = static_cast<::vl::presentation::compositions::GuiSideAlignedComposition*>(nullptr); + ::vl::presentation::controls::GuiButton* __vwsn_precompile_5 = static_cast<::vl::presentation::controls::GuiButton*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_6 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_7 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_8 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::presentation::controls::GuiButton* __vwsn_precompile_9 = static_cast<::vl::presentation::controls::GuiButton*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_10 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + void __vwsn_initialize_instance_(::darkskin::HScrollTemplate* __vwsn_this_); + public: + HScrollTemplateConstructor(); + }; + + class HScrollTemplate : public ::vl::presentation::templates::GuiScrollTemplate, public ::darkskin::HScrollTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::HScrollTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc33_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc34_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc35_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc36_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf76_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf77_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf78_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf79_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf80_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf81_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf82_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf83_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf84_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf85_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf86_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf87_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf88_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf89_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + bool draggingHandle = false; + ::vl::presentation::Point draggingStartLocation = [&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(0); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }(); + public: + HScrollTemplate(); + ~HScrollTemplate(); + }; + + class HTrackerTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf90_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf91_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf92_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf93_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf94_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::HTrackerTemplate* self = static_cast<::darkskin::HTrackerTemplate*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* handle = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_1 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + ::vl::presentation::compositions::GuiTableComposition* __vwsn_precompile_3 = static_cast<::vl::presentation::compositions::GuiTableComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_4 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_5 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + ::vl::presentation::controls::GuiButton* __vwsn_precompile_6 = static_cast<::vl::presentation::controls::GuiButton*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_7 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + void __vwsn_initialize_instance_(::darkskin::HTrackerTemplate* __vwsn_this_); + public: + HTrackerTemplateConstructor(); + }; + + class HTrackerTemplate : public ::vl::presentation::templates::GuiScrollTemplate, public ::darkskin::HTrackerTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::HTrackerTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf90_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf91_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf92_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf93_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf94_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + bool draggingHandle = false; + ::vl::presentation::Point draggingStartLocation = [&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(0); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }(); + public: + HTrackerTemplate(); + ~HTrackerTemplate(); + }; + + class ItemBackgroundTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc38_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf95_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::vl::presentation::compositions::GuiBoundsComposition* container = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::darkskin::ItemBackgroundTemplate* self = static_cast<::darkskin::ItemBackgroundTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + void __vwsn_initialize_instance_(::darkskin::ItemBackgroundTemplate* __vwsn_this_); + public: + ItemBackgroundTemplateConstructor(); + }; + + class ItemBackgroundTemplate : public ::vl::presentation::templates::GuiSelectableButtonTemplate, public ::darkskin::ItemBackgroundTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::ItemBackgroundTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc38_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf95_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + ItemBackgroundTemplate(); + ~ItemBackgroundTemplate(); + }; + + class LabelTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc39_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc40_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc41_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf96_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf97_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf98_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::LabelTemplate* self = static_cast<::darkskin::LabelTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(); + void __vwsn_initialize_instance_(::darkskin::LabelTemplate* __vwsn_this_); + public: + LabelTemplateConstructor(); + }; + + class LabelTemplate : public ::vl::presentation::templates::GuiLabelTemplate, public ::darkskin::LabelTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::LabelTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc39_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc40_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc41_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf96_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf97_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf98_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + LabelTemplate(); + ~LabelTemplate(); + }; + + class LeftScrollButtonTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc42_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc43_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf100_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf99_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::LeftScrollButtonTemplate* self = static_cast<::darkskin::LeftScrollButtonTemplate*>(nullptr); + ::vl::presentation::compositions::GuiTableComposition* __vwsn_precompile_0 = static_cast<::vl::presentation::compositions::GuiTableComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_1 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement> __vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement>(); + void __vwsn_initialize_instance_(::darkskin::LeftScrollButtonTemplate* __vwsn_this_); + public: + LeftScrollButtonTemplateConstructor(); + }; + + class LeftScrollButtonTemplate : public ::vl::presentation::templates::GuiButtonTemplate, public ::darkskin::LeftScrollButtonTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::LeftScrollButtonTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc42_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc43_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf100_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf99_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + LeftScrollButtonTemplate(); + ~LeftScrollButtonTemplate(); + }; + + class ListViewColumnHeaderTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc44_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc45_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc46_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc47_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc48_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc49_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf101_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf102_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf103_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf104_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf105_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf106_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf107_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf108_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::ListViewColumnHeaderTemplate* self = static_cast<::darkskin::ListViewColumnHeaderTemplate*>(nullptr); + ::vl::presentation::controls::GuiSelectableButton* buttonArrow = static_cast<::vl::presentation::controls::GuiSelectableButton*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_1 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_3 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_4 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_5 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_6 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement> __vwsn_precompile_7 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_8 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_9 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + void __vwsn_initialize_instance_(::darkskin::ListViewColumnHeaderTemplate* __vwsn_this_); + public: + ListViewColumnHeaderTemplateConstructor(); + }; + + class ListViewColumnHeaderTemplate : public ::vl::presentation::templates::GuiListViewColumnHeaderTemplate, public ::darkskin::ListViewColumnHeaderTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::ListViewColumnHeaderTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc44_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc45_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc46_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc47_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc48_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc49_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf101_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf102_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf103_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf104_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf105_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf106_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf107_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf108_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + ListViewColumnHeaderTemplate(); + ~ListViewColumnHeaderTemplate(); + }; + + class ListViewTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend struct ::vl_workflow_global::__vwsnf109_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf110_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf111_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf112_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::vl::presentation::compositions::GuiBoundsComposition* container = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::darkskin::ListViewTemplate* self = static_cast<::darkskin::ListViewTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + void __vwsn_initialize_instance_(::darkskin::ListViewTemplate* __vwsn_this_); + public: + ListViewTemplateConstructor(); + }; + + class ListViewTemplate : public ::vl::presentation::templates::GuiListViewTemplate, public ::darkskin::ListViewTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::ListViewTemplateConstructor; + friend struct ::vl_workflow_global::__vwsnf109_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf110_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf111_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf112_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + ListViewTemplate(); + ~ListViewTemplate(); + }; + + class MenuBarButtonTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc50_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc51_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc52_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc53_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf113_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf114_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf115_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf116_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf117_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::MenuBarButtonTemplate* self = static_cast<::darkskin::MenuBarButtonTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_1 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement> __vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(); + void __vwsn_initialize_instance_(::darkskin::MenuBarButtonTemplate* __vwsn_this_); + public: + MenuBarButtonTemplateConstructor(); + }; + + class MenuBarButtonTemplate : public ::vl::presentation::templates::GuiToolstripButtonTemplate, public ::darkskin::MenuBarButtonTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::MenuBarButtonTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc50_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc51_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc52_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc53_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf113_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf114_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf115_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf116_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf117_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + MenuBarButtonTemplate(); + ~MenuBarButtonTemplate(); + }; + + class MenuItemButtonTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc54_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc55_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc56_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc57_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc58_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc59_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc60_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc61_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc62_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc63_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc64_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc65_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc66_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf118_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf119_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf120_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf121_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf122_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf123_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf124_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf125_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf126_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf127_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf128_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf129_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf130_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf131_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::MenuItemButtonTemplate* self = static_cast<::darkskin::MenuItemButtonTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiTableComposition* __vwsn_precompile_1 = static_cast<::vl::presentation::compositions::GuiTableComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_2 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiImageFrameElement> __vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiImageFrameElement>(); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_4 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::presentation::compositions::GuiSharedSizeItemComposition* __vwsn_precompile_5 = static_cast<::vl::presentation::compositions::GuiSharedSizeItemComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement> __vwsn_precompile_6 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_7 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::presentation::compositions::GuiSharedSizeItemComposition* __vwsn_precompile_8 = static_cast<::vl::presentation::compositions::GuiSharedSizeItemComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement> __vwsn_precompile_9 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_10 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement> __vwsn_precompile_11 = ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement>(); + void __vwsn_initialize_instance_(::darkskin::MenuItemButtonTemplate* __vwsn_this_); + public: + MenuItemButtonTemplateConstructor(); + }; + + class MenuItemButtonTemplate : public ::vl::presentation::templates::GuiToolstripButtonTemplate, public ::darkskin::MenuItemButtonTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::MenuItemButtonTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc54_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc55_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc56_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc57_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc58_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc59_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc60_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc61_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc62_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc63_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc64_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc65_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc66_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf118_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf119_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf120_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf121_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf122_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf123_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf124_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf125_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf126_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf127_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf128_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf129_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf130_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf131_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + MenuItemButtonTemplate(); + ~MenuItemButtonTemplate(); + }; + + class MenuSplitterTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::MenuSplitterTemplate* __vwsn_precompile_0 = static_cast<::darkskin::MenuSplitterTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_2 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + void __vwsn_initialize_instance_(::darkskin::MenuSplitterTemplate* __vwsn_this_); + public: + MenuSplitterTemplateConstructor(); + }; + + class MenuSplitterTemplate : public ::vl::presentation::templates::GuiControlTemplate, public ::darkskin::MenuSplitterTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::MenuSplitterTemplateConstructor; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + MenuSplitterTemplate(); + ~MenuSplitterTemplate(); + }; + + class MultilineTextBoxTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend struct ::vl_workflow_global::__vwsnf132_DarkSkin_darkskin_MultilineTextBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf133_DarkSkin_darkskin_MultilineTextBoxTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::vl::presentation::compositions::GuiBoundsComposition* container = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::darkskin::MultilineTextBoxTemplate* self = static_cast<::darkskin::MultilineTextBoxTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + void __vwsn_initialize_instance_(::darkskin::MultilineTextBoxTemplate* __vwsn_this_); + public: + MultilineTextBoxTemplateConstructor(); + }; + + class MultilineTextBoxTemplate : public ::vl::presentation::templates::GuiMultilineTextBoxTemplate, public ::darkskin::MultilineTextBoxTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::MultilineTextBoxTemplateConstructor; + friend struct ::vl_workflow_global::__vwsnf132_DarkSkin_darkskin_MultilineTextBoxTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf133_DarkSkin_darkskin_MultilineTextBoxTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + MultilineTextBoxTemplate(); + ~MultilineTextBoxTemplate(); + }; + + class ProgressBarTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc67_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf134_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::vl::presentation::compositions::GuiBoundsComposition* container = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::darkskin::ProgressBarTemplate* self = static_cast<::darkskin::ProgressBarTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_1 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_3 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_4 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + void __vwsn_initialize_instance_(::darkskin::ProgressBarTemplate* __vwsn_this_); + public: + ProgressBarTemplateConstructor(); + }; + + class ProgressBarTemplate : public ::vl::presentation::templates::GuiScrollTemplate, public ::darkskin::ProgressBarTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::ProgressBarTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc67_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf134_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + ProgressBarTemplate(); + ~ProgressBarTemplate(); + }; + + class RadioButtonTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc68_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc69_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc70_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc71_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc72_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc73_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc74_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf135_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf136_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf137_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf138_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf139_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf140_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf141_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::RadioButtonTemplate* self = static_cast<::darkskin::RadioButtonTemplate*>(nullptr); + ::vl::presentation::compositions::GuiTableComposition* __vwsn_precompile_0 = static_cast<::vl::presentation::compositions::GuiTableComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_1 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_2 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_4 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_5 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_6 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_7 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_8 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_9 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement> __vwsn_precompile_10 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(); + void __vwsn_initialize_instance_(::darkskin::RadioButtonTemplate* __vwsn_this_); + public: + RadioButtonTemplateConstructor(); + }; + + class RadioButtonTemplate : public ::vl::presentation::templates::GuiSelectableButtonTemplate, public ::darkskin::RadioButtonTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::RadioButtonTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc68_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc69_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc70_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc71_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc72_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc73_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc74_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf135_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf136_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf137_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf138_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf139_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf140_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf141_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + RadioButtonTemplate(); + ~RadioButtonTemplate(); + }; + + class RightScrollButtonTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc75_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc76_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf142_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf143_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::RightScrollButtonTemplate* self = static_cast<::darkskin::RightScrollButtonTemplate*>(nullptr); + ::vl::presentation::compositions::GuiTableComposition* __vwsn_precompile_0 = static_cast<::vl::presentation::compositions::GuiTableComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_1 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement> __vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement>(); + void __vwsn_initialize_instance_(::darkskin::RightScrollButtonTemplate* __vwsn_this_); + public: + RightScrollButtonTemplateConstructor(); + }; + + class RightScrollButtonTemplate : public ::vl::presentation::templates::GuiButtonTemplate, public ::darkskin::RightScrollButtonTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::RightScrollButtonTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc75_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc76_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf142_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf143_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + RightScrollButtonTemplate(); + ~RightScrollButtonTemplate(); + }; + + class ScrollViewTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend struct ::vl_workflow_global::__vwsnf144_DarkSkin_darkskin_ScrollViewTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf145_DarkSkin_darkskin_ScrollViewTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::vl::presentation::compositions::GuiBoundsComposition* container = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::darkskin::ScrollViewTemplate* self = static_cast<::darkskin::ScrollViewTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + void __vwsn_initialize_instance_(::darkskin::ScrollViewTemplate* __vwsn_this_); + public: + ScrollViewTemplateConstructor(); + }; + + class ScrollViewTemplate : public ::vl::presentation::templates::GuiScrollViewTemplate, public ::darkskin::ScrollViewTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::ScrollViewTemplateConstructor; + friend struct ::vl_workflow_global::__vwsnf144_DarkSkin_darkskin_ScrollViewTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf145_DarkSkin_darkskin_ScrollViewTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + ScrollViewTemplate(); + ~ScrollViewTemplate(); + }; + + class ShortcutKeyTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc77_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc78_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc79_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf146_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf147_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf148_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::ShortcutKeyTemplate* self = static_cast<::darkskin::ShortcutKeyTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_1 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_3 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement> __vwsn_precompile_4 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(); + void __vwsn_initialize_instance_(::darkskin::ShortcutKeyTemplate* __vwsn_this_); + public: + ShortcutKeyTemplateConstructor(); + }; + + class ShortcutKeyTemplate : public ::vl::presentation::templates::GuiLabelTemplate, public ::darkskin::ShortcutKeyTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::ShortcutKeyTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc77_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc78_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc79_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf146_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf147_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf148_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + ShortcutKeyTemplate(); + ~ShortcutKeyTemplate(); + }; + + class SinglelineTextBoxTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::vl::presentation::compositions::GuiBoundsComposition* container = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::darkskin::SinglelineTextBoxTemplate* self = static_cast<::darkskin::SinglelineTextBoxTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + void __vwsn_initialize_instance_(::darkskin::SinglelineTextBoxTemplate* __vwsn_this_); + public: + SinglelineTextBoxTemplateConstructor(); + }; + + class SinglelineTextBoxTemplate : public ::vl::presentation::templates::GuiSinglelineTextBoxTemplate, public ::darkskin::SinglelineTextBoxTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::SinglelineTextBoxTemplateConstructor; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + SinglelineTextBoxTemplate(); + ~SinglelineTextBoxTemplate(); + }; + + class TabDropdownTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc80_DarkSkin_darkskin_TabDropdownTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf149_DarkSkin_darkskin_TabDropdownTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::TabDropdownTemplate* self = static_cast<::darkskin::TabDropdownTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiTableComposition* __vwsn_precompile_1 = static_cast<::vl::presentation::compositions::GuiTableComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_2 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement> __vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement>(); + void __vwsn_initialize_instance_(::darkskin::TabDropdownTemplate* __vwsn_this_); + public: + TabDropdownTemplateConstructor(); + }; + + class TabDropdownTemplate : public ::vl::presentation::templates::GuiButtonTemplate, public ::darkskin::TabDropdownTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::TabDropdownTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc80_DarkSkin_darkskin_TabDropdownTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf149_DarkSkin_darkskin_TabDropdownTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + TabDropdownTemplate(); + ~TabDropdownTemplate(); + }; + + class TabHeaderTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc81_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc82_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc83_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc84_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf150_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf151_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf152_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf153_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::TabHeaderTemplate* self = static_cast<::darkskin::TabHeaderTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_1 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement> __vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(); + void __vwsn_initialize_instance_(::darkskin::TabHeaderTemplate* __vwsn_this_); + public: + TabHeaderTemplateConstructor(); + }; + + class TabHeaderTemplate : public ::vl::presentation::templates::GuiSelectableButtonTemplate, public ::darkskin::TabHeaderTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::TabHeaderTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc81_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc82_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc83_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc84_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf150_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf151_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf152_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf153_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + TabHeaderTemplate(); + ~TabHeaderTemplate(); + }; + + class TabTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend struct ::vl_workflow_global::__vwsnf154_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf155_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf156_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf157_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::vl::presentation::compositions::GuiBoundsComposition* container = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::darkskin::TabTemplate* self = static_cast<::darkskin::TabTemplate*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* header = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::presentation::compositions::GuiTableComposition* __vwsn_precompile_0 = static_cast<::vl::presentation::compositions::GuiTableComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_2 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_3 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_4 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_5 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_6 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + void __vwsn_initialize_instance_(::darkskin::TabTemplate* __vwsn_this_); + public: + TabTemplateConstructor(); + }; + + class TabTemplate : public ::vl::presentation::templates::GuiTabTemplate, public ::darkskin::TabTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::TabTemplateConstructor; + friend struct ::vl_workflow_global::__vwsnf154_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf155_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf156_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf157_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + TabTemplate(); + ~TabTemplate(); + }; + + class TextListTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend struct ::vl_workflow_global::__vwsnf158_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf159_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf160_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf161_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf162_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::vl::presentation::compositions::GuiBoundsComposition* container = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::darkskin::TextListTemplate* self = static_cast<::darkskin::TextListTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + void __vwsn_initialize_instance_(::darkskin::TextListTemplate* __vwsn_this_); + public: + TextListTemplateConstructor(); + }; + + class TextListTemplate : public ::vl::presentation::templates::GuiTextListTemplate, public ::darkskin::TextListTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::TextListTemplateConstructor; + friend struct ::vl_workflow_global::__vwsnf158_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf159_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf160_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf161_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf162_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + TextListTemplate(); + ~TextListTemplate(); + }; + + class ToolstripSplitArrowTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc85_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc86_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc87_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf163_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf164_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf165_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::ToolstripSplitArrowTemplate* self = static_cast<::darkskin::ToolstripSplitArrowTemplate*>(nullptr); + ::vl::presentation::compositions::GuiTableComposition* __vwsn_precompile_0 = static_cast<::vl::presentation::compositions::GuiTableComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_2 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement> __vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement>(); + void __vwsn_initialize_instance_(::darkskin::ToolstripSplitArrowTemplate* __vwsn_this_); + public: + ToolstripSplitArrowTemplateConstructor(); + }; + + class ToolstripSplitArrowTemplate : public ::vl::presentation::templates::GuiSelectableButtonTemplate, public ::darkskin::ToolstripSplitArrowTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::ToolstripSplitArrowTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc85_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc86_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc87_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf163_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf164_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf165_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + ToolstripSplitArrowTemplate(); + ~ToolstripSplitArrowTemplate(); + }; + + class ToolstripButtonTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc88_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc89_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc90_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc91_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc92_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf166_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf167_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf168_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf169_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf170_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf171_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::vl::presentation::compositions::GuiBoundsComposition* container = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::darkskin::ToolstripButtonTemplate* self = static_cast<::darkskin::ToolstripButtonTemplate*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_0 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_2 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::Ptr<::vl::presentation::elements::GuiImageFrameElement> __vwsn_precompile_4 = ::vl::Ptr<::vl::presentation::elements::GuiImageFrameElement>(); + void __vwsn_initialize_instance_(::darkskin::ToolstripButtonTemplate* __vwsn_this_); + public: + ToolstripButtonTemplateConstructor(); + }; + + class ToolstripButtonTemplate : public ::vl::presentation::templates::GuiToolstripButtonTemplate, public ::darkskin::ToolstripButtonTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::ToolstripButtonTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc88_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc89_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc90_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc91_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc92_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf166_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf167_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf168_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf169_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf170_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf171_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + ToolstripButtonTemplate(); + ~ToolstripButtonTemplate(); + }; + + class ToolstripDropdownButtonTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc100_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc93_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc94_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc95_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc96_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc97_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc98_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc99_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf172_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf173_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf174_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf175_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf176_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf177_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf178_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf179_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf180_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::vl::presentation::compositions::GuiBoundsComposition* container = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::darkskin::ToolstripDropdownButtonTemplate* self = static_cast<::darkskin::ToolstripDropdownButtonTemplate*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_0 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_2 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::Ptr<::vl::presentation::elements::GuiImageFrameElement> __vwsn_precompile_4 = ::vl::Ptr<::vl::presentation::elements::GuiImageFrameElement>(); + ::vl::presentation::compositions::GuiTableComposition* __vwsn_precompile_5 = static_cast<::vl::presentation::compositions::GuiTableComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_6 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_7 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement> __vwsn_precompile_8 = ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement>(); + void __vwsn_initialize_instance_(::darkskin::ToolstripDropdownButtonTemplate* __vwsn_this_); + public: + ToolstripDropdownButtonTemplateConstructor(); + }; + + class ToolstripDropdownButtonTemplate : public ::vl::presentation::templates::GuiToolstripButtonTemplate, public ::darkskin::ToolstripDropdownButtonTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::ToolstripDropdownButtonTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc100_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc93_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc94_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc95_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc96_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc97_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc98_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc99_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf172_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf173_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf174_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf175_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf176_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf177_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf178_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf179_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf180_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + ToolstripDropdownButtonTemplate(); + ~ToolstripDropdownButtonTemplate(); + }; + + class ToolstripMenuTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::vl::presentation::compositions::GuiBoundsComposition* container = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::darkskin::ToolstripMenuTemplate* __vwsn_precompile_0 = static_cast<::darkskin::ToolstripMenuTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + void __vwsn_initialize_instance_(::darkskin::ToolstripMenuTemplate* __vwsn_this_); + public: + ToolstripMenuTemplateConstructor(); + }; + + class ToolstripMenuTemplate : public ::vl::presentation::templates::GuiMenuTemplate, public ::darkskin::ToolstripMenuTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::ToolstripMenuTemplateConstructor; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + ToolstripMenuTemplate(); + ~ToolstripMenuTemplate(); + }; + + class ToolstripSplitButtonTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc101_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc102_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc103_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc104_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc105_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc106_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc107_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf181_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf182_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf183_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf184_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf185_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf186_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf187_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf188_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf189_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::vl::presentation::compositions::GuiBoundsComposition* container = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::darkskin::ToolstripSplitButtonTemplate* self = static_cast<::darkskin::ToolstripSplitButtonTemplate*>(nullptr); + ::vl::presentation::controls::GuiSelectableButton* buttonArrow = static_cast<::vl::presentation::controls::GuiSelectableButton*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_0 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_2 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::Ptr<::vl::presentation::elements::GuiImageFrameElement> __vwsn_precompile_4 = ::vl::Ptr<::vl::presentation::elements::GuiImageFrameElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_5 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_6 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_7 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_8 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + void __vwsn_initialize_instance_(::darkskin::ToolstripSplitButtonTemplate* __vwsn_this_); + public: + ToolstripSplitButtonTemplateConstructor(); + }; + + class ToolstripSplitButtonTemplate : public ::vl::presentation::templates::GuiToolstripButtonTemplate, public ::darkskin::ToolstripSplitButtonTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::ToolstripSplitButtonTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc101_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc102_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc103_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc104_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc105_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc106_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc107_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf181_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf182_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf183_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf184_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf185_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf186_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf187_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf188_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf189_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + ToolstripSplitButtonTemplate(); + ~ToolstripSplitButtonTemplate(); + }; + + class ToolstripSplitterTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::ToolstripSplitterTemplate* __vwsn_precompile_0 = static_cast<::darkskin::ToolstripSplitterTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_2 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::Gui3DSplitterElement> __vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::Gui3DSplitterElement>(); + void __vwsn_initialize_instance_(::darkskin::ToolstripSplitterTemplate* __vwsn_this_); + public: + ToolstripSplitterTemplateConstructor(); + }; + + class ToolstripSplitterTemplate : public ::vl::presentation::templates::GuiControlTemplate, public ::darkskin::ToolstripSplitterTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::ToolstripSplitterTemplateConstructor; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + ToolstripSplitterTemplate(); + ~ToolstripSplitterTemplate(); + }; + + class ToolstripTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::ToolstripTemplate* __vwsn_precompile_0 = static_cast<::darkskin::ToolstripTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + void __vwsn_initialize_instance_(::darkskin::ToolstripTemplate* __vwsn_this_); + public: + ToolstripTemplateConstructor(); + }; + + class ToolstripTemplate : public ::vl::presentation::templates::GuiControlTemplate, public ::darkskin::ToolstripTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::ToolstripTemplateConstructor; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + ToolstripTemplate(); + ~ToolstripTemplate(); + }; + + class TooltipTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::vl::presentation::compositions::GuiBoundsComposition* container = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::darkskin::TooltipTemplate* __vwsn_precompile_0 = static_cast<::darkskin::TooltipTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_2 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_3 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + void __vwsn_initialize_instance_(::darkskin::TooltipTemplate* __vwsn_this_); + public: + TooltipTemplateConstructor(); + }; + + class TooltipTemplate : public ::vl::presentation::templates::GuiWindowTemplate, public ::darkskin::TooltipTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::TooltipTemplateConstructor; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + TooltipTemplate(); + ~TooltipTemplate(); + }; + + class TopScrollButtonTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc108_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc109_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf190_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf191_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::TopScrollButtonTemplate* self = static_cast<::darkskin::TopScrollButtonTemplate*>(nullptr); + ::vl::presentation::compositions::GuiTableComposition* __vwsn_precompile_0 = static_cast<::vl::presentation::compositions::GuiTableComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_1 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement> __vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiPolygonElement>(); + void __vwsn_initialize_instance_(::darkskin::TopScrollButtonTemplate* __vwsn_this_); + public: + TopScrollButtonTemplateConstructor(); + }; + + class TopScrollButtonTemplate : public ::vl::presentation::templates::GuiButtonTemplate, public ::darkskin::TopScrollButtonTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::TopScrollButtonTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc108_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc109_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf190_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf191_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + TopScrollButtonTemplate(); + ~TopScrollButtonTemplate(); + }; + + class TreeViewTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend struct ::vl_workflow_global::__vwsnf192_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf193_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf194_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf195_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::vl::presentation::compositions::GuiBoundsComposition* container = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::darkskin::TreeViewTemplate* self = static_cast<::darkskin::TreeViewTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + void __vwsn_initialize_instance_(::darkskin::TreeViewTemplate* __vwsn_this_); + public: + TreeViewTemplateConstructor(); + }; + + class TreeViewTemplate : public ::vl::presentation::templates::GuiTreeViewTemplate, public ::darkskin::TreeViewTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::TreeViewTemplateConstructor; + friend struct ::vl_workflow_global::__vwsnf192_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf193_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf194_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf195_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + TreeViewTemplate(); + ~TreeViewTemplate(); + }; + + class VScrollHandleTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc110_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf196_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::VScrollHandleTemplate* self = static_cast<::darkskin::VScrollHandleTemplate*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_0 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_1 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + void __vwsn_initialize_instance_(::darkskin::VScrollHandleTemplate* __vwsn_this_); + public: + VScrollHandleTemplateConstructor(); + }; + + class VScrollHandleTemplate : public ::vl::presentation::templates::GuiButtonTemplate, public ::darkskin::VScrollHandleTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::VScrollHandleTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc110_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf196_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + VScrollHandleTemplate(); + ~VScrollHandleTemplate(); + }; + + class VScrollTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc111_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc112_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc113_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc114_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf197_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf198_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf199_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf200_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf201_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf202_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf203_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf204_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf205_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf206_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf207_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf208_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf209_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf210_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::VScrollTemplate* self = static_cast<::darkskin::VScrollTemplate*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* handleContainer = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::presentation::compositions::GuiPartialViewComposition* handle = static_cast<::vl::presentation::compositions::GuiPartialViewComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiSideAlignedComposition* __vwsn_precompile_1 = static_cast<::vl::presentation::compositions::GuiSideAlignedComposition*>(nullptr); + ::vl::presentation::controls::GuiButton* __vwsn_precompile_2 = static_cast<::vl::presentation::controls::GuiButton*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_3 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::presentation::compositions::GuiSideAlignedComposition* __vwsn_precompile_4 = static_cast<::vl::presentation::compositions::GuiSideAlignedComposition*>(nullptr); + ::vl::presentation::controls::GuiButton* __vwsn_precompile_5 = static_cast<::vl::presentation::controls::GuiButton*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_6 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_7 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_8 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::presentation::controls::GuiButton* __vwsn_precompile_9 = static_cast<::vl::presentation::controls::GuiButton*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_10 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + void __vwsn_initialize_instance_(::darkskin::VScrollTemplate* __vwsn_this_); + public: + VScrollTemplateConstructor(); + }; + + class VScrollTemplate : public ::vl::presentation::templates::GuiScrollTemplate, public ::darkskin::VScrollTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::VScrollTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc111_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc112_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc113_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc114_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf197_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf198_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf199_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf200_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf201_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf202_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf203_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf204_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf205_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf206_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf207_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf208_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf209_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf210_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + bool draggingHandle = false; + ::vl::presentation::Point draggingStartLocation = [&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(0); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }(); + public: + VScrollTemplate(); + ~VScrollTemplate(); + }; + + class VTrackerTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf211_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf212_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf213_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf214_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf215_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::darkskin::VTrackerTemplate* self = static_cast<::darkskin::VTrackerTemplate*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* handle = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_1 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + ::vl::presentation::compositions::GuiTableComposition* __vwsn_precompile_3 = static_cast<::vl::presentation::compositions::GuiTableComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_4 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_5 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + ::vl::presentation::controls::GuiButton* __vwsn_precompile_6 = static_cast<::vl::presentation::controls::GuiButton*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_7 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + void __vwsn_initialize_instance_(::darkskin::VTrackerTemplate* __vwsn_this_); + public: + VTrackerTemplateConstructor(); + }; + + class VTrackerTemplate : public ::vl::presentation::templates::GuiScrollTemplate, public ::darkskin::VTrackerTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::VTrackerTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf211_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf212_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf213_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf214_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf215_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + bool draggingHandle = false; + ::vl::presentation::Point draggingStartLocation = [&](){ ::vl::presentation::Point __vwsn_temp__; __vwsn_temp__.x = static_cast<::vl::vint>(0); __vwsn_temp__.y = static_cast<::vl::vint>(0); return __vwsn_temp__; }(); + public: + VTrackerTemplate(); + ~VTrackerTemplate(); + }; + + class WindowTemplateConstructor : public ::vl::Object, public ::vl::reflection::Description + { + friend class ::vl_workflow_global::__vwsnc116_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc117_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf216_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf217_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf218_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf219_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf220_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf221_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + protected: + ::vl::presentation::compositions::GuiBoundsComposition* container = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::darkskin::WindowTemplate* self = static_cast<::darkskin::WindowTemplate*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement> __vwsn_precompile_0 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBackgroundElement>(); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_1 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement> __vwsn_precompile_2 = ::vl::Ptr<::vl::presentation::elements::GuiSolidBorderElement>(); + ::vl::presentation::compositions::GuiTableComposition* __vwsn_precompile_3 = static_cast<::vl::presentation::compositions::GuiTableComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_4 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_5 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_6 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_7 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_8 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_9 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_10 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_11 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_12 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::presentation::controls::GuiButton* __vwsn_precompile_13 = static_cast<::vl::presentation::controls::GuiButton*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_14 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_15 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::presentation::controls::GuiButton* __vwsn_precompile_16 = static_cast<::vl::presentation::controls::GuiButton*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_17 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_18 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::presentation::controls::GuiButton* __vwsn_precompile_19 = static_cast<::vl::presentation::controls::GuiButton*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_20 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_21 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_precompile_22 = static_cast<::vl::presentation::compositions::GuiBoundsComposition*>(nullptr); + ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement> __vwsn_precompile_23 = ::vl::Ptr<::vl::presentation::elements::GuiSolidLabelElement>(); + ::vl::presentation::compositions::GuiCellComposition* __vwsn_precompile_24 = static_cast<::vl::presentation::compositions::GuiCellComposition*>(nullptr); + void __vwsn_initialize_instance_(::darkskin::WindowTemplate* __vwsn_this_); + public: + WindowTemplateConstructor(); + }; + + class WindowTemplate : public ::vl::presentation::templates::GuiWindowTemplate, public ::darkskin::WindowTemplateConstructor, public ::vl::reflection::Description + { + friend class ::darkskin::WindowTemplateConstructor; + friend class ::vl_workflow_global::__vwsnc116_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend class ::vl_workflow_global::__vwsnc117_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription; + friend struct ::vl_workflow_global::__vwsnf216_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf217_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf218_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf219_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf220_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__; + friend struct ::vl_workflow_global::__vwsnf221_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__; +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif + public: + WindowTemplate(); + ~WindowTemplate(); + }; + +} +class ScrollTemplateScript : public ::vl::Object, public ::vl::reflection::Description +{ +#ifndef VCZH_DEBUG_NO_REFLECTION + friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; +#endif +public: + static void SetScroll(::vl::vint totalPixels, ::vl::vint newOffset, ::vl::presentation::templates::GuiScrollTemplate* scrollTemplate); + ScrollTemplateScript(); +}; + +/*********************************************************************** +Global Variables and Functions +***********************************************************************/ + +namespace vl_workflow_global +{ + class DarkSkin + { + public: + + static DarkSkin& Instance(); + }; + +/*********************************************************************** +Closures +***********************************************************************/ + + struct __vwsnf100_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::LeftScrollButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf100_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::LeftScrollButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf101_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnthis_0; + + __vwsnf101_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiMenuTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf102_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnthis_0; + + __vwsnf102_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiSelectableButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf103_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnthis_0; + + __vwsnf103_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf104_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnthis_0; + + __vwsnf104_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf105_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnthis_0; + + __vwsnf105_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf106_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnthis_0; + + __vwsnf106_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf107_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnthis_0; + + __vwsnf107_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf108_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnthis_0; + + __vwsnf108_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf109_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ListViewTemplateConstructor* __vwsnthis_0; + + __vwsnf109_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiListViewColumnHeaderTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::CheckBoxTemplateConstructor* __vwsnthis_0; + + __vwsnf10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf110_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ListViewTemplateConstructor* __vwsnthis_0; + + __vwsnf110_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiSelectableButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf111_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ListViewTemplateConstructor* __vwsnthis_0; + + __vwsnf111_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiScrollTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf112_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ListViewTemplateConstructor* __vwsnthis_0; + + __vwsnf112_DarkSkin_darkskin_ListViewTemplateConstructor___vwsn_initialize_instance__(::darkskin::ListViewTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiScrollTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf113_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::MenuBarButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf113_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuBarButtonTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiMenuTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf114_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::MenuBarButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf114_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuBarButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf115_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::MenuBarButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf115_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuBarButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf116_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::MenuBarButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf116_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuBarButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf117_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::MenuBarButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf117_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuBarButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf118_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf118_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiMenuTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf119_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf119_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf11_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::CheckBoxTemplateConstructor* __vwsnthis_0; + + __vwsnf11_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf120_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf120_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf121_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf121_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf122_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf122_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf123_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf123_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf124_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf124_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf125_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf125_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf126_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf126_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf127_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf127_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf128_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf128_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf129_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf129_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf12_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::CheckBoxTemplateConstructor* __vwsnthis_0; + + __vwsnf12_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf130_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf130_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf131_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf131_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf132_DarkSkin_darkskin_MultilineTextBoxTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::MultilineTextBoxTemplateConstructor* __vwsnthis_0; + + __vwsnf132_DarkSkin_darkskin_MultilineTextBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::MultilineTextBoxTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiScrollTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf133_DarkSkin_darkskin_MultilineTextBoxTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::MultilineTextBoxTemplateConstructor* __vwsnthis_0; + + __vwsnf133_DarkSkin_darkskin_MultilineTextBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::MultilineTextBoxTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiScrollTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf134_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ProgressBarTemplateConstructor* __vwsnthis_0; + + __vwsnf134_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance__(::darkskin::ProgressBarTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf135_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::RadioButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf135_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf136_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::RadioButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf136_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf137_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::RadioButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf137_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf138_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::RadioButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf138_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf139_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::RadioButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf139_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf13_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::CheckBoxTemplateConstructor* __vwsnthis_0; + + __vwsnf13_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf140_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::RadioButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf140_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf141_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::RadioButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf141_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf142_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::RightScrollButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf142_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::RightScrollButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf143_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::RightScrollButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf143_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::RightScrollButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf144_DarkSkin_darkskin_ScrollViewTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ScrollViewTemplateConstructor* __vwsnthis_0; + + __vwsnf144_DarkSkin_darkskin_ScrollViewTemplateConstructor___vwsn_initialize_instance__(::darkskin::ScrollViewTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiScrollTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf145_DarkSkin_darkskin_ScrollViewTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ScrollViewTemplateConstructor* __vwsnthis_0; + + __vwsnf145_DarkSkin_darkskin_ScrollViewTemplateConstructor___vwsn_initialize_instance__(::darkskin::ScrollViewTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiScrollTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf146_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ShortcutKeyTemplateConstructor* __vwsnthis_0; + + __vwsnf146_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__(::darkskin::ShortcutKeyTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf147_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ShortcutKeyTemplateConstructor* __vwsnthis_0; + + __vwsnf147_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__(::darkskin::ShortcutKeyTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf148_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ShortcutKeyTemplateConstructor* __vwsnthis_0; + + __vwsnf148_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance__(::darkskin::ShortcutKeyTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf149_DarkSkin_darkskin_TabDropdownTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::TabDropdownTemplateConstructor* __vwsnthis_0; + + __vwsnf149_DarkSkin_darkskin_TabDropdownTemplateConstructor___vwsn_initialize_instance__(::darkskin::TabDropdownTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf14_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::CheckBoxTemplateConstructor* __vwsnthis_0; + + __vwsnf14_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf150_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::TabHeaderTemplateConstructor* __vwsnthis_0; + + __vwsnf150_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::TabHeaderTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf151_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::TabHeaderTemplateConstructor* __vwsnthis_0; + + __vwsnf151_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::TabHeaderTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf152_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::TabHeaderTemplateConstructor* __vwsnthis_0; + + __vwsnf152_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::TabHeaderTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf153_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::TabHeaderTemplateConstructor* __vwsnthis_0; + + __vwsnf153_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance__(::darkskin::TabHeaderTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf154_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::TabTemplateConstructor* __vwsnthis_0; + + __vwsnf154_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__(::darkskin::TabTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiToolstripButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf155_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::TabTemplateConstructor* __vwsnthis_0; + + __vwsnf155_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__(::darkskin::TabTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiMenuTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf156_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::TabTemplateConstructor* __vwsnthis_0; + + __vwsnf156_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__(::darkskin::TabTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf157_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::TabTemplateConstructor* __vwsnthis_0; + + __vwsnf157_DarkSkin_darkskin_TabTemplateConstructor___vwsn_initialize_instance__(::darkskin::TabTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiSelectableButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf158_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::TextListTemplateConstructor* __vwsnthis_0; + + __vwsnf158_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__(::darkskin::TextListTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiSelectableButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf159_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::TextListTemplateConstructor* __vwsnthis_0; + + __vwsnf159_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__(::darkskin::TextListTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiSelectableButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::CheckItemBackgroundTemplateConstructor* __vwsnthis_0; + + __vwsnf15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance__(::darkskin::CheckItemBackgroundTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf160_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::TextListTemplateConstructor* __vwsnthis_0; + + __vwsnf160_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__(::darkskin::TextListTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiSelectableButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf161_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::TextListTemplateConstructor* __vwsnthis_0; + + __vwsnf161_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__(::darkskin::TextListTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiScrollTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf162_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::TextListTemplateConstructor* __vwsnthis_0; + + __vwsnf162_DarkSkin_darkskin_TextListTemplateConstructor___vwsn_initialize_instance__(::darkskin::TextListTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiScrollTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf163_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripSplitArrowTemplateConstructor* __vwsnthis_0; + + __vwsnf163_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitArrowTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf164_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripSplitArrowTemplateConstructor* __vwsnthis_0; + + __vwsnf164_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitArrowTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf165_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripSplitArrowTemplateConstructor* __vwsnthis_0; + + __vwsnf165_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitArrowTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf166_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf166_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripButtonTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiMenuTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf167_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf167_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf168_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf168_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf169_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf169_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ComboBoxTemplateConstructor* __vwsnthis_0; + + __vwsnf16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiDatePickerTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf170_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf170_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf171_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf171_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf172_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf172_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiMenuTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf173_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf173_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf174_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf174_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf175_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf175_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf176_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf176_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf177_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf177_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf178_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf178_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf179_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf179_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf17_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ComboBoxTemplateConstructor* __vwsnthis_0; + + __vwsnf17_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiMenuTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf180_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf180_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf181_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf181_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiMenuTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf182_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf182_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiSelectableButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf183_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf183_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf184_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf184_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf185_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf185_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf186_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf186_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf187_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf187_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf188_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf188_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf189_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf189_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ComboBoxTemplateConstructor* __vwsnthis_0; + + __vwsnf18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf190_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::TopScrollButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf190_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::TopScrollButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf191_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::TopScrollButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf191_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::TopScrollButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf192_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::TreeViewTemplateConstructor* __vwsnthis_0; + + __vwsnf192_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__(::darkskin::TreeViewTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiSelectableButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf193_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::TreeViewTemplateConstructor* __vwsnthis_0; + + __vwsnf193_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__(::darkskin::TreeViewTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiSelectableButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf194_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::TreeViewTemplateConstructor* __vwsnthis_0; + + __vwsnf194_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__(::darkskin::TreeViewTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiScrollTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf195_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::TreeViewTemplateConstructor* __vwsnthis_0; + + __vwsnf195_DarkSkin_darkskin_TreeViewTemplateConstructor___vwsn_initialize_instance__(::darkskin::TreeViewTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiScrollTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf196_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::VScrollHandleTemplateConstructor* __vwsnthis_0; + + __vwsnf196_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollHandleTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf197_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::VScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf197_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf198_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::VScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf198_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf199_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::VScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf199_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf19_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ComboBoxTemplateConstructor* __vwsnthis_0; + + __vwsnf19_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::BottomScrollButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::BottomScrollButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf200_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::VScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf200_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0); + + void operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiEventArgs* arguments) const; + }; + + struct __vwsnf201_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::VScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf201_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0); + + void operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiEventArgs* arguments) const; + }; + + struct __vwsnf202_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::VScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf202_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf203_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::VScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf203_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0); + + void operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const; + }; + + struct __vwsnf204_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::VScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf204_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf205_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::VScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf205_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0); + + void operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const; + }; + + struct __vwsnf206_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::VScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf206_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf207_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::VScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf207_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf208_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::VScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf208_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0); + + void operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const; + }; + + struct __vwsnf209_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::VScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf209_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0); + + void operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const; + }; + + struct __vwsnf20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ComboBoxTemplateConstructor* __vwsnthis_0; + + __vwsnf20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf210_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::VScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf210_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0); + + void operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const; + }; + + struct __vwsnf211_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::VTrackerTemplateConstructor* __vwsnthis_0; + + __vwsnf211_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__(::darkskin::VTrackerTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf212_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::VTrackerTemplateConstructor* __vwsnthis_0; + + __vwsnf212_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__(::darkskin::VTrackerTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf213_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::VTrackerTemplateConstructor* __vwsnthis_0; + + __vwsnf213_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__(::darkskin::VTrackerTemplateConstructor* __vwsnctorthis_0); + + void operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const; + }; + + struct __vwsnf214_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::VTrackerTemplateConstructor* __vwsnthis_0; + + __vwsnf214_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__(::darkskin::VTrackerTemplateConstructor* __vwsnctorthis_0); + + void operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const; + }; + + struct __vwsnf215_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::VTrackerTemplateConstructor* __vwsnthis_0; + + __vwsnf215_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance__(::darkskin::VTrackerTemplateConstructor* __vwsnctorthis_0); + + void operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const; + }; + + struct __vwsnf216_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::WindowTemplateConstructor* __vwsnthis_0; + + __vwsnf216_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__(::darkskin::WindowTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiWindowTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf217_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::WindowTemplateConstructor* __vwsnthis_0; + + __vwsnf217_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__(::darkskin::WindowTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf218_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::WindowTemplateConstructor* __vwsnthis_0; + + __vwsnf218_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__(::darkskin::WindowTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf219_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::WindowTemplateConstructor* __vwsnthis_0; + + __vwsnf219_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__(::darkskin::WindowTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ComboBoxTemplateConstructor* __vwsnthis_0; + + __vwsnf21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf220_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::WindowTemplateConstructor* __vwsnthis_0; + + __vwsnf220_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__(::darkskin::WindowTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf221_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::WindowTemplateConstructor* __vwsnthis_0; + + __vwsnf221_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance__(::darkskin::WindowTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ComboBoxTemplateConstructor* __vwsnthis_0; + + __vwsnf22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf23_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ComboBoxTemplateConstructor* __vwsnthis_0; + + __vwsnf23_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf24_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ComboBoxTemplateConstructor* __vwsnthis_0; + + __vwsnf24_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf25_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf25_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiScrollTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf26_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf26_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiScrollTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf27_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf27_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiScrollTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf28_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf28_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiScrollTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf29_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf29_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiScrollTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::BottomScrollButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::BottomScrollButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf30_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf30_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiDatePickerTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf31_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf31_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiSelectableButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf32_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf32_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiSelectableButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf33_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf33_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf34_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf34_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiControlTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf35_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf35_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiToolstripButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf36_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf36_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiToolstripButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf37_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf37_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiToolstripButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf38_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf38_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiControlTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf39_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf39_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiToolstripButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf40_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf40_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiToolstripButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf41_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf41_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiControlTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf42_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf42_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiControlTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf43_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf43_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiMenuTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf44_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf44_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiTextListTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf45_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf45_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiTreeViewTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf46_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf46_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiListViewTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf47_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf47_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiDocumentLabelTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf48_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf48_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiDocumentLabelTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf49_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf49_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiDocumentViewerTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf50_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf50_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiSinglelineTextBoxTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf51_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf51_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiMultilineTextBoxTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf52_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf52_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiComboBoxTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf53_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf53_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiTabTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf54_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf54_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiControlTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf55_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf55_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiScrollViewTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf56_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf56_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiLabelTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf57_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf57_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiLabelTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf58_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf58_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiWindowTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf59_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf59_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiControlTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf5_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf5_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf60_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__ + { + ::darkskin::ThemeConstructor* __vwsnthis_0; + + __vwsnf60_DarkSkin_darkskin_ThemeConstructor___vwsn_initialize_instance__(::darkskin::ThemeConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiWindowTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf61_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::DatePickerTemplateConstructor* __vwsnthis_0; + + __vwsnf61_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__(::darkskin::DatePickerTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiComboBoxTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf62_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::DatePickerTemplateConstructor* __vwsnthis_0; + + __vwsnf62_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__(::darkskin::DatePickerTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiTextListTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf63_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::DatePickerTemplateConstructor* __vwsnthis_0; + + __vwsnf63_DarkSkin_darkskin_DatePickerTemplateConstructor___vwsn_initialize_instance__(::darkskin::DatePickerTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiSelectableButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf64_DarkSkin_darkskin_DocumentViewerTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::DocumentViewerTemplateConstructor* __vwsnthis_0; + + __vwsnf64_DarkSkin_darkskin_DocumentViewerTemplateConstructor___vwsn_initialize_instance__(::darkskin::DocumentViewerTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiScrollTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf65_DarkSkin_darkskin_DocumentViewerTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::DocumentViewerTemplateConstructor* __vwsnthis_0; + + __vwsnf65_DarkSkin_darkskin_DocumentViewerTemplateConstructor___vwsn_initialize_instance__(::darkskin::DocumentViewerTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiScrollTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf66_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnthis_0; + + __vwsnf66_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf67_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnthis_0; + + __vwsnf67_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf68_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnthis_0; + + __vwsnf68_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf69_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnthis_0; + + __vwsnf69_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf70_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnthis_0; + + __vwsnf70_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf71_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnthis_0; + + __vwsnf71_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance__(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf72_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::GroupBoxTemplateConstructor* __vwsnthis_0; + + __vwsnf72_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::GroupBoxTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf73_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::GroupBoxTemplateConstructor* __vwsnthis_0; + + __vwsnf73_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::GroupBoxTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf74_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::GroupBoxTemplateConstructor* __vwsnthis_0; + + __vwsnf74_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::GroupBoxTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf75_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::HScrollHandleTemplateConstructor* __vwsnthis_0; + + __vwsnf75_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollHandleTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf76_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::HScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf76_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf77_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::HScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf77_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf78_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::HScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf78_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf79_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::HScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf79_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0); + + void operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiEventArgs* arguments) const; + }; + + struct __vwsnf7_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf7_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::ButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf80_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::HScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf80_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0); + + void operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiEventArgs* arguments) const; + }; + + struct __vwsnf81_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::HScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf81_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf82_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::HScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf82_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0); + + void operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const; + }; + + struct __vwsnf83_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::HScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf83_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf84_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::HScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf84_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0); + + void operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const; + }; + + struct __vwsnf85_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::HScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf85_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf86_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::HScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf86_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf87_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::HScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf87_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0); + + void operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const; + }; + + struct __vwsnf88_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::HScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf88_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0); + + void operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const; + }; + + struct __vwsnf89_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::HScrollTemplateConstructor* __vwsnthis_0; + + __vwsnf89_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance__(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0); + + void operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const; + }; + + struct __vwsnf8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::CheckBoxTemplateConstructor* __vwsnthis_0; + + __vwsnf8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf90_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::HTrackerTemplateConstructor* __vwsnthis_0; + + __vwsnf90_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__(::darkskin::HTrackerTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::templates::GuiButtonTemplate* operator()(const ::vl::reflection::description::Value& __vwsn_viewModel_) const; + }; + + struct __vwsnf91_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::HTrackerTemplateConstructor* __vwsnthis_0; + + __vwsnf91_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__(::darkskin::HTrackerTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf92_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::HTrackerTemplateConstructor* __vwsnthis_0; + + __vwsnf92_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__(::darkskin::HTrackerTemplateConstructor* __vwsnctorthis_0); + + void operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const; + }; + + struct __vwsnf93_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::HTrackerTemplateConstructor* __vwsnthis_0; + + __vwsnf93_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__(::darkskin::HTrackerTemplateConstructor* __vwsnctorthis_0); + + void operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const; + }; + + struct __vwsnf94_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::HTrackerTemplateConstructor* __vwsnthis_0; + + __vwsnf94_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance__(::darkskin::HTrackerTemplateConstructor* __vwsnctorthis_0); + + void operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiMouseEventArgs* arguments) const; + }; + + struct __vwsnf95_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::ItemBackgroundTemplateConstructor* __vwsnthis_0; + + __vwsnf95_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance__(::darkskin::ItemBackgroundTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf96_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::LabelTemplateConstructor* __vwsnthis_0; + + __vwsnf96_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__(::darkskin::LabelTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf97_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::LabelTemplateConstructor* __vwsnthis_0; + + __vwsnf97_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__(::darkskin::LabelTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf98_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::LabelTemplateConstructor* __vwsnthis_0; + + __vwsnf98_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance__(::darkskin::LabelTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf99_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::LeftScrollButtonTemplateConstructor* __vwsnthis_0; + + __vwsnf99_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance__(::darkskin::LeftScrollButtonTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + struct __vwsnf9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__ + { + ::darkskin::CheckBoxTemplateConstructor* __vwsnthis_0; + + __vwsnf9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance__(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0); + + void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const; + }; + + class __vwsnc100_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc100_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ToolstripDropdownButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ToolstripDropdownButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::darkskin::ToolstripDropdownButtonTemplate* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc101_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc101_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ToolstripSplitButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ToolstripSplitButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc102_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc102_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ToolstripSplitButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ToolstripSplitButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::darkskin::ToolstripSplitButtonTemplate* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc103_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc103_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ToolstripSplitButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc104_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc104_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ToolstripSplitButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc105_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc105_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ToolstripSplitButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc106_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc106_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ToolstripSplitButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ToolstripSplitButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc107_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc107_DarkSkin_darkskin_ToolstripSplitButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripSplitButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ToolstripSplitButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc108_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::TopScrollButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc108_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::TopScrollButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::TopScrollButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::TopScrollButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc109_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::TopScrollButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc109_DarkSkin_darkskin_TopScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::TopScrollButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::TopScrollButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::TopScrollButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::CheckBoxTemplateConstructor* __vwsnthis_0; + + __vwsnc10_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::CheckBoxTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::CheckBoxTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc110_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::VScrollHandleTemplateConstructor* __vwsnthis_0; + + __vwsnc110_DarkSkin_darkskin_VScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::VScrollHandleTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::VScrollHandleTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::VScrollHandleTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc111_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::VScrollTemplateConstructor* __vwsnthis_0; + + __vwsnc111_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_bind_cache_0 = nullptr; + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_bind_cache_1 = nullptr; + ::vl::presentation::compositions::GuiPartialViewComposition* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc112_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::VScrollTemplateConstructor* __vwsnthis_0; + + __vwsnc112_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::compositions::GuiPartialViewComposition* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc113_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::VScrollTemplateConstructor* __vwsnthis_0; + + __vwsnc113_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::VScrollTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::VScrollTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc114_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::VScrollTemplateConstructor* __vwsnthis_0; + + __vwsnc114_DarkSkin_darkskin_VScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::VScrollTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::VScrollTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::VScrollTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::VTrackerTemplateConstructor* __vwsnthis_0; + + __vwsnc115_DarkSkin_darkskin_VTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::VTrackerTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::VTrackerTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::VTrackerTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_bind_cache_2 = nullptr; + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_bind_cache_3 = nullptr; + ::darkskin::VTrackerTemplate* __vwsn_bind_cache_4 = nullptr; + ::darkskin::VTrackerTemplate* __vwsn_bind_cache_5 = nullptr; + ::darkskin::VTrackerTemplate* __vwsn_bind_cache_6 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_3_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_4_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_5_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_6_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_3_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_4_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_5_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_6_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc116_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::WindowTemplateConstructor* __vwsnthis_0; + + __vwsnc116_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::WindowTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::WindowTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc117_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::WindowTemplateConstructor* __vwsnthis_0; + + __vwsnc117_DarkSkin_darkskin_WindowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::WindowTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::WindowTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc11_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::CheckBoxTemplateConstructor* __vwsnthis_0; + + __vwsnc11_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::CheckBoxTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc12_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::CheckBoxTemplateConstructor* __vwsnthis_0; + + __vwsnc12_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::CheckBoxTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc13_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::CheckBoxTemplateConstructor* __vwsnthis_0; + + __vwsnc13_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::CheckBoxTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc14_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::CheckBoxTemplateConstructor* __vwsnthis_0; + + __vwsnc14_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::CheckBoxTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::CheckItemBackgroundTemplateConstructor* __vwsnthis_0; + + __vwsnc15_DarkSkin_darkskin_CheckItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::CheckItemBackgroundTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::CheckItemBackgroundTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::CheckItemBackgroundTemplate* __vwsn_bind_cache_1 = nullptr; + ::darkskin::CheckItemBackgroundTemplate* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ComboBoxTemplateConstructor* __vwsnthis_0; + + __vwsnc16_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ComboBoxTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ComboBoxTemplate* __vwsn_bind_cache_1 = nullptr; + ::darkskin::ComboBoxTemplate* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc17_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ComboBoxTemplateConstructor* __vwsnthis_0; + + __vwsnc17_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ComboBoxTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ComboBoxTemplateConstructor* __vwsnthis_0; + + __vwsnc18_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ComboBoxTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ComboBoxTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc19_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ComboBoxTemplateConstructor* __vwsnthis_0; + + __vwsnc19_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ComboBoxTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::BottomScrollButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc1_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::BottomScrollButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::BottomScrollButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::BottomScrollButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ComboBoxTemplateConstructor* __vwsnthis_0; + + __vwsnc20_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ComboBoxTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ComboBoxTemplate* __vwsn_bind_cache_1 = nullptr; + ::darkskin::ComboBoxTemplate* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ComboBoxTemplateConstructor* __vwsnthis_0; + + __vwsnc21_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ComboBoxTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ComboBoxTemplate* __vwsn_bind_cache_1 = nullptr; + ::darkskin::ComboBoxTemplate* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ComboBoxTemplateConstructor* __vwsnthis_0; + + __vwsnc22_DarkSkin_darkskin_ComboBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ComboBoxTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ComboBoxTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ComboBoxTemplate* __vwsn_bind_cache_1 = nullptr; + ::darkskin::ComboBoxTemplate* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc23_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnthis_0; + + __vwsnc23_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ExpandingDecoratorTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ExpandingDecoratorTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc24_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnthis_0; + + __vwsnc24_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ExpandingDecoratorTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ExpandingDecoratorTemplate* __vwsn_bind_cache_1 = nullptr; + ::darkskin::ExpandingDecoratorTemplate* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc25_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnthis_0; + + __vwsnc25_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ExpandingDecoratorTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc26_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnthis_0; + + __vwsnc26_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ExpandingDecoratorTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ExpandingDecoratorTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc27_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnthis_0; + + __vwsnc27_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ExpandingDecoratorTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ExpandingDecoratorTemplate* __vwsn_bind_cache_1 = nullptr; + ::darkskin::ExpandingDecoratorTemplate* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc28_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnthis_0; + + __vwsnc28_DarkSkin_darkskin_ExpandingDecoratorTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ExpandingDecoratorTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ExpandingDecoratorTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc29_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::GroupBoxTemplateConstructor* __vwsnthis_0; + + __vwsnc29_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::GroupBoxTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::BottomScrollButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc2_DarkSkin_darkskin_BottomScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::BottomScrollButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::BottomScrollButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::BottomScrollButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc30_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::GroupBoxTemplateConstructor* __vwsnthis_0; + + __vwsnc30_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::GroupBoxTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::GroupBoxTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc31_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::GroupBoxTemplateConstructor* __vwsnthis_0; + + __vwsnc31_DarkSkin_darkskin_GroupBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::GroupBoxTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::GroupBoxTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc32_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::HScrollHandleTemplateConstructor* __vwsnthis_0; + + __vwsnc32_DarkSkin_darkskin_HScrollHandleTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::HScrollHandleTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::HScrollHandleTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::HScrollHandleTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc33_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::HScrollTemplateConstructor* __vwsnthis_0; + + __vwsnc33_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_bind_cache_0 = nullptr; + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_bind_cache_1 = nullptr; + ::vl::presentation::compositions::GuiPartialViewComposition* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc34_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::HScrollTemplateConstructor* __vwsnthis_0; + + __vwsnc34_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::compositions::GuiPartialViewComposition* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc35_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::HScrollTemplateConstructor* __vwsnthis_0; + + __vwsnc35_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::HScrollTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::HScrollTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc36_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::HScrollTemplateConstructor* __vwsnthis_0; + + __vwsnc36_DarkSkin_darkskin_HScrollTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::HScrollTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::HScrollTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::HScrollTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::HTrackerTemplateConstructor* __vwsnthis_0; + + __vwsnc37_DarkSkin_darkskin_HTrackerTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::HTrackerTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::HTrackerTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::HTrackerTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_bind_cache_2 = nullptr; + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_bind_cache_3 = nullptr; + ::darkskin::HTrackerTemplate* __vwsn_bind_cache_4 = nullptr; + ::darkskin::HTrackerTemplate* __vwsn_bind_cache_5 = nullptr; + ::darkskin::HTrackerTemplate* __vwsn_bind_cache_6 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_3_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_4_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_5_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_6_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_3_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_4_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_5_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_6_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc38_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ItemBackgroundTemplateConstructor* __vwsnthis_0; + + __vwsnc38_DarkSkin_darkskin_ItemBackgroundTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ItemBackgroundTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ItemBackgroundTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ItemBackgroundTemplate* __vwsn_bind_cache_1 = nullptr; + ::darkskin::ItemBackgroundTemplate* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc39_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::LabelTemplateConstructor* __vwsnthis_0; + + __vwsnc39_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::LabelTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::LabelTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc3_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc40_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::LabelTemplateConstructor* __vwsnthis_0; + + __vwsnc40_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::LabelTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::LabelTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::LabelTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc41_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::LabelTemplateConstructor* __vwsnthis_0; + + __vwsnc41_DarkSkin_darkskin_LabelTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::LabelTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::LabelTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc42_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::LeftScrollButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc42_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::LeftScrollButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::LeftScrollButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::LeftScrollButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc43_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::LeftScrollButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc43_DarkSkin_darkskin_LeftScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::LeftScrollButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::LeftScrollButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::LeftScrollButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc44_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnthis_0; + + __vwsnc44_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ListViewColumnHeaderTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ListViewColumnHeaderTemplate* __vwsn_bind_cache_1 = nullptr; + ::darkskin::ListViewColumnHeaderTemplate* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc45_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnthis_0; + + __vwsnc45_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ListViewColumnHeaderTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc46_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnthis_0; + + __vwsnc46_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ListViewColumnHeaderTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ListViewColumnHeaderTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc47_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnthis_0; + + __vwsnc47_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ListViewColumnHeaderTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc48_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnthis_0; + + __vwsnc48_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ListViewColumnHeaderTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc49_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnthis_0; + + __vwsnc49_DarkSkin_darkskin_ListViewColumnHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ListViewColumnHeaderTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ListViewColumnHeaderTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc4_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc50_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::MenuBarButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc50_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuBarButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::MenuBarButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::MenuBarButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::darkskin::MenuBarButtonTemplate* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc51_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::MenuBarButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc51_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuBarButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::MenuBarButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc52_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::MenuBarButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc52_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuBarButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::MenuBarButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::MenuBarButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc53_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::MenuBarButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc53_DarkSkin_darkskin_MenuBarButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuBarButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::MenuBarButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc54_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc54_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::MenuItemButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::MenuItemButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::darkskin::MenuItemButtonTemplate* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc55_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc55_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::MenuItemButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc56_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc56_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::MenuItemButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc57_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc57_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::MenuItemButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc58_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc58_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::MenuItemButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc59_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc59_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::MenuItemButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::MenuItemButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc5_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc5_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc60_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc60_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::MenuItemButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc61_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc61_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::MenuItemButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc62_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc62_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::MenuItemButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::MenuItemButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc63_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc63_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::MenuItemButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc64_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc64_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::MenuItemButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::MenuItemButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::darkskin::MenuItemButtonTemplate* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc65_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc65_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::MenuItemButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::MenuItemButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::darkskin::MenuItemButtonTemplate* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc66_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::MenuItemButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc66_DarkSkin_darkskin_MenuItemButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::MenuItemButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::MenuItemButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc67_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ProgressBarTemplateConstructor* __vwsnthis_0; + + __vwsnc67_DarkSkin_darkskin_ProgressBarTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ProgressBarTemplateConstructor* __vwsnctorthis_0); + + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_bind_cache_0 = nullptr; + ::vl::presentation::compositions::GuiBoundsComposition* __vwsn_bind_cache_1 = nullptr; + ::darkskin::ProgressBarTemplate* __vwsn_bind_cache_2 = nullptr; + ::darkskin::ProgressBarTemplate* __vwsn_bind_cache_3 = nullptr; + ::darkskin::ProgressBarTemplate* __vwsn_bind_cache_4 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_3_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_4_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_3_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_4_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc68_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::RadioButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc68_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::RadioButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::RadioButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc69_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::RadioButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc69_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::RadioButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::RadioButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc6_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc70_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::RadioButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc70_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::RadioButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::RadioButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc71_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::RadioButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc71_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::RadioButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc72_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::RadioButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc72_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::RadioButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc73_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::RadioButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc73_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::RadioButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc74_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::RadioButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc74_DarkSkin_darkskin_RadioButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::RadioButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::RadioButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc75_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::RightScrollButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc75_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::RightScrollButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::RightScrollButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::RightScrollButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc76_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::RightScrollButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc76_DarkSkin_darkskin_RightScrollButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::RightScrollButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::RightScrollButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::RightScrollButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc77_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ShortcutKeyTemplateConstructor* __vwsnthis_0; + + __vwsnc77_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ShortcutKeyTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ShortcutKeyTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc78_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ShortcutKeyTemplateConstructor* __vwsnthis_0; + + __vwsnc78_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ShortcutKeyTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ShortcutKeyTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc79_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ShortcutKeyTemplateConstructor* __vwsnthis_0; + + __vwsnc79_DarkSkin_darkskin_ShortcutKeyTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ShortcutKeyTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ShortcutKeyTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc7_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc7_DarkSkin_darkskin_ButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc80_DarkSkin_darkskin_TabDropdownTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::TabDropdownTemplateConstructor* __vwsnthis_0; + + __vwsnc80_DarkSkin_darkskin_TabDropdownTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::TabDropdownTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::TabDropdownTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc81_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::TabHeaderTemplateConstructor* __vwsnthis_0; + + __vwsnc81_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::TabHeaderTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::TabHeaderTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::TabHeaderTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc82_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::TabHeaderTemplateConstructor* __vwsnthis_0; + + __vwsnc82_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::TabHeaderTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::TabHeaderTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc83_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::TabHeaderTemplateConstructor* __vwsnthis_0; + + __vwsnc83_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::TabHeaderTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::TabHeaderTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::TabHeaderTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc84_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::TabHeaderTemplateConstructor* __vwsnthis_0; + + __vwsnc84_DarkSkin_darkskin_TabHeaderTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::TabHeaderTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::TabHeaderTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc85_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ToolstripSplitArrowTemplateConstructor* __vwsnthis_0; + + __vwsnc85_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripSplitArrowTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ToolstripSplitArrowTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ToolstripSplitArrowTemplate* __vwsn_bind_cache_1 = nullptr; + ::darkskin::ToolstripSplitArrowTemplate* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc86_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ToolstripSplitArrowTemplateConstructor* __vwsnthis_0; + + __vwsnc86_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripSplitArrowTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ToolstripSplitArrowTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ToolstripSplitArrowTemplate* __vwsn_bind_cache_1 = nullptr; + ::darkskin::ToolstripSplitArrowTemplate* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc87_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ToolstripSplitArrowTemplateConstructor* __vwsnthis_0; + + __vwsnc87_DarkSkin_darkskin_ToolstripSplitArrowTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripSplitArrowTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ToolstripSplitArrowTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ToolstripSplitArrowTemplate* __vwsn_bind_cache_1 = nullptr; + ::darkskin::ToolstripSplitArrowTemplate* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc88_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ToolstripButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc88_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ToolstripButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ToolstripButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc89_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ToolstripButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc89_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ToolstripButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ToolstripButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::darkskin::ToolstripButtonTemplate* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::CheckBoxTemplateConstructor* __vwsnthis_0; + + __vwsnc8_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::CheckBoxTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::CheckBoxTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc90_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ToolstripButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc90_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ToolstripButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc91_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ToolstripButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc91_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ToolstripButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc92_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ToolstripButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc92_DarkSkin_darkskin_ToolstripButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ToolstripButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc93_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc93_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ToolstripDropdownButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ToolstripDropdownButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc94_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc94_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ToolstripDropdownButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ToolstripDropdownButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::darkskin::ToolstripDropdownButtonTemplate* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc95_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc95_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ToolstripDropdownButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc96_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc96_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ToolstripDropdownButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc97_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc97_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ToolstripDropdownButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc98_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc98_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ToolstripDropdownButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ToolstripDropdownButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::darkskin::ToolstripDropdownButtonTemplate* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc99_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnthis_0; + + __vwsnc99_DarkSkin_darkskin_ToolstripDropdownButtonTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::ToolstripDropdownButtonTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::ToolstripDropdownButtonTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::ToolstripDropdownButtonTemplate* __vwsn_bind_cache_1 = nullptr; + ::darkskin::ToolstripDropdownButtonTemplate* __vwsn_bind_cache_2 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_2_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_2_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; + + class __vwsnc9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription : public ::vl::Object, public virtual ::vl::reflection::description::IValueSubscription + { + public: + ::darkskin::CheckBoxTemplateConstructor* __vwsnthis_0; + + __vwsnc9_DarkSkin_darkskin_CheckBoxTemplateConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription(::darkskin::CheckBoxTemplateConstructor* __vwsnctorthis_0); + + ::darkskin::CheckBoxTemplate* __vwsn_bind_cache_0 = nullptr; + ::darkskin::CheckBoxTemplate* __vwsn_bind_cache_1 = nullptr; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_0_0; + ::vl::Ptr<::vl::reflection::description::IEventHandler> __vwsn_bind_handler_1_0; + bool __vwsn_bind_opened_ = false; + bool __vwsn_bind_closed_ = false; + void __vwsn_bind_activator_(); + void __vwsn_bind_callback_0_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + void __vwsn_bind_callback_1_0(::vl::presentation::compositions::GuiGraphicsComposition* __vwsn_bind_callback_argument_0, ::vl::presentation::compositions::GuiEventArgs* __vwsn_bind_callback_argument_1); + bool Open() override; + bool Update() override; + bool Close() override; + }; +} + +#if defined( _MSC_VER) +#pragma warning(pop) +#elif defined(__GNUC__) +#pragma GCC diagnostic pop +#elif defined(__clang__) +#pragma clang diagnostic pop +#endif + +#endif + + +/*********************************************************************** +.\DARKSKIN.H +***********************************************************************/ +/*********************************************************************** +!!!!!! DO NOT MODIFY !!!!!! + +GacGen.exe Resource.xml + +This file is generated by Workflow compiler +https://github.com/vczh-libraries +***********************************************************************/ + +#ifndef VCZH_WORKFLOW_COMPILER_GENERATED_DARKSKIN +#define VCZH_WORKFLOW_COMPILER_GENERATED_DARKSKIN + + +#endif + diff --git a/Import/Skins/DarkSkin/DarkSkinReflection.cpp b/Import/Skins/DarkSkin/DarkSkinReflection.cpp new file mode 100644 index 00000000..75a99b1b --- /dev/null +++ b/Import/Skins/DarkSkin/DarkSkinReflection.cpp @@ -0,0 +1,1044 @@ +/*********************************************************************** +THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY +DEVELOPER: Zihan Chen(vczh) +***********************************************************************/ +#include "DarkSkinReflection.h" + +/*********************************************************************** +.\DARKSKINREFLECTION.CPP +***********************************************************************/ +/*********************************************************************** +!!!!!! DO NOT MODIFY !!!!!! + +GacGen.exe Resource.xml + +This file is generated by Workflow compiler +https://github.com/vczh-libraries +***********************************************************************/ + + +#if defined( _MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#elif defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wparentheses-equality" +#elif defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wparentheses-equality" +#endif + +/*********************************************************************** +Reflection +***********************************************************************/ + +namespace vl +{ + namespace reflection + { + namespace description + { +#ifndef VCZH_DEBUG_NO_REFLECTION + IMPL_CPP_TYPE_INFO(ScrollTemplateScript) + IMPL_CPP_TYPE_INFO(darkskin::BottomScrollButtonTemplate) + IMPL_CPP_TYPE_INFO(darkskin::BottomScrollButtonTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::ButtonTemplate) + IMPL_CPP_TYPE_INFO(darkskin::ButtonTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::CheckBoxTemplate) + IMPL_CPP_TYPE_INFO(darkskin::CheckBoxTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::CheckItemBackgroundTemplate) + IMPL_CPP_TYPE_INFO(darkskin::CheckItemBackgroundTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::ComboBoxTemplate) + IMPL_CPP_TYPE_INFO(darkskin::ComboBoxTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::CustomControlTemplate) + IMPL_CPP_TYPE_INFO(darkskin::CustomControlTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::DatePickerTemplate) + IMPL_CPP_TYPE_INFO(darkskin::DatePickerTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::DocumentLabelTemplate) + IMPL_CPP_TYPE_INFO(darkskin::DocumentLabelTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::DocumentTextBoxTemplate) + IMPL_CPP_TYPE_INFO(darkskin::DocumentTextBoxTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::DocumentViewerTemplate) + IMPL_CPP_TYPE_INFO(darkskin::DocumentViewerTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::ExpandingDecoratorTemplate) + IMPL_CPP_TYPE_INFO(darkskin::ExpandingDecoratorTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::GroupBoxTemplate) + IMPL_CPP_TYPE_INFO(darkskin::GroupBoxTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::HScrollHandleTemplate) + IMPL_CPP_TYPE_INFO(darkskin::HScrollHandleTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::HScrollTemplate) + IMPL_CPP_TYPE_INFO(darkskin::HScrollTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::HTrackerTemplate) + IMPL_CPP_TYPE_INFO(darkskin::HTrackerTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::ItemBackgroundTemplate) + IMPL_CPP_TYPE_INFO(darkskin::ItemBackgroundTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::LabelTemplate) + IMPL_CPP_TYPE_INFO(darkskin::LabelTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::LeftScrollButtonTemplate) + IMPL_CPP_TYPE_INFO(darkskin::LeftScrollButtonTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::ListViewColumnHeaderTemplate) + IMPL_CPP_TYPE_INFO(darkskin::ListViewColumnHeaderTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::ListViewTemplate) + IMPL_CPP_TYPE_INFO(darkskin::ListViewTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::MenuBarButtonTemplate) + IMPL_CPP_TYPE_INFO(darkskin::MenuBarButtonTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::MenuItemButtonTemplate) + IMPL_CPP_TYPE_INFO(darkskin::MenuItemButtonTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::MenuSplitterTemplate) + IMPL_CPP_TYPE_INFO(darkskin::MenuSplitterTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::MultilineTextBoxTemplate) + IMPL_CPP_TYPE_INFO(darkskin::MultilineTextBoxTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::ProgressBarTemplate) + IMPL_CPP_TYPE_INFO(darkskin::ProgressBarTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::RadioButtonTemplate) + IMPL_CPP_TYPE_INFO(darkskin::RadioButtonTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::RightScrollButtonTemplate) + IMPL_CPP_TYPE_INFO(darkskin::RightScrollButtonTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::ScrollViewTemplate) + IMPL_CPP_TYPE_INFO(darkskin::ScrollViewTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::ShortcutKeyTemplate) + IMPL_CPP_TYPE_INFO(darkskin::ShortcutKeyTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::SinglelineTextBoxTemplate) + IMPL_CPP_TYPE_INFO(darkskin::SinglelineTextBoxTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::TabDropdownTemplate) + IMPL_CPP_TYPE_INFO(darkskin::TabDropdownTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::TabHeaderTemplate) + IMPL_CPP_TYPE_INFO(darkskin::TabHeaderTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::TabTemplate) + IMPL_CPP_TYPE_INFO(darkskin::TabTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::TextListTemplate) + IMPL_CPP_TYPE_INFO(darkskin::TextListTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::Theme) + IMPL_CPP_TYPE_INFO(darkskin::ThemeConstructor) + IMPL_CPP_TYPE_INFO(darkskin::ToolstripButtonTemplate) + IMPL_CPP_TYPE_INFO(darkskin::ToolstripButtonTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::ToolstripDropdownButtonTemplate) + IMPL_CPP_TYPE_INFO(darkskin::ToolstripDropdownButtonTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::ToolstripMenuTemplate) + IMPL_CPP_TYPE_INFO(darkskin::ToolstripMenuTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::ToolstripSplitArrowTemplate) + IMPL_CPP_TYPE_INFO(darkskin::ToolstripSplitArrowTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::ToolstripSplitButtonTemplate) + IMPL_CPP_TYPE_INFO(darkskin::ToolstripSplitButtonTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::ToolstripSplitterTemplate) + IMPL_CPP_TYPE_INFO(darkskin::ToolstripSplitterTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::ToolstripTemplate) + IMPL_CPP_TYPE_INFO(darkskin::ToolstripTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::TooltipTemplate) + IMPL_CPP_TYPE_INFO(darkskin::TooltipTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::TopScrollButtonTemplate) + IMPL_CPP_TYPE_INFO(darkskin::TopScrollButtonTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::TreeViewTemplate) + IMPL_CPP_TYPE_INFO(darkskin::TreeViewTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::VScrollHandleTemplate) + IMPL_CPP_TYPE_INFO(darkskin::VScrollHandleTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::VScrollTemplate) + IMPL_CPP_TYPE_INFO(darkskin::VScrollTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::VTrackerTemplate) + IMPL_CPP_TYPE_INFO(darkskin::VTrackerTemplateConstructor) + IMPL_CPP_TYPE_INFO(darkskin::WindowTemplate) + IMPL_CPP_TYPE_INFO(darkskin::WindowTemplateConstructor) + +#define _ , + BEGIN_CLASS_MEMBER(::ScrollTemplateScript) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::ScrollTemplateScript>(), NO_PARAMETER) + CLASS_MEMBER_STATIC_METHOD(SetScroll, { L"totalPixels" _ L"newOffset" _ L"scrollTemplate" }) + END_CLASS_MEMBER(::ScrollTemplateScript) + + BEGIN_CLASS_MEMBER(::darkskin::BottomScrollButtonTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::BottomScrollButtonTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::BottomScrollButtonTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::BottomScrollButtonTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::BottomScrollButtonTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::BottomScrollButtonTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::ButtonTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::ButtonTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::ButtonTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::ButtonTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::ButtonTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + CLASS_MEMBER_FIELD(__vwsn_precompile_4) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::ButtonTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::CheckBoxTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::CheckBoxTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::CheckBoxTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::CheckBoxTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::CheckBoxTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_10) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + CLASS_MEMBER_FIELD(__vwsn_precompile_4) + CLASS_MEMBER_FIELD(__vwsn_precompile_5) + CLASS_MEMBER_FIELD(__vwsn_precompile_6) + CLASS_MEMBER_FIELD(__vwsn_precompile_7) + CLASS_MEMBER_FIELD(__vwsn_precompile_8) + CLASS_MEMBER_FIELD(__vwsn_precompile_9) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::CheckBoxTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::CheckItemBackgroundTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::CheckItemBackgroundTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::CheckItemBackgroundTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::CheckItemBackgroundTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::CheckItemBackgroundTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(container) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::CheckItemBackgroundTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::ComboBoxTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::ComboBoxTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::ComboBoxTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::ComboBoxTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::ComboBoxTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + CLASS_MEMBER_FIELD(__vwsn_precompile_4) + CLASS_MEMBER_FIELD(__vwsn_precompile_5) + CLASS_MEMBER_FIELD(__vwsn_precompile_6) + CLASS_MEMBER_FIELD(__vwsn_precompile_7) + CLASS_MEMBER_FIELD(__vwsn_precompile_8) + CLASS_MEMBER_FIELD(container) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::ComboBoxTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::CustomControlTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::CustomControlTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::CustomControlTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::CustomControlTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::CustomControlTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + END_CLASS_MEMBER(::darkskin::CustomControlTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::DatePickerTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::DatePickerTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::DatePickerTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::DatePickerTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::DatePickerTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::DatePickerTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::DocumentLabelTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::DocumentLabelTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::DocumentLabelTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::DocumentLabelTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::DocumentLabelTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::DocumentLabelTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::DocumentTextBoxTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::DocumentTextBoxTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::DocumentTextBoxTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::DocumentTextBoxTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::DocumentTextBoxTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(container) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::DocumentTextBoxTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::DocumentViewerTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::DocumentViewerTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::DocumentViewerTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::DocumentViewerTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::DocumentViewerTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(container) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::DocumentViewerTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::ExpandingDecoratorTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::ExpandingDecoratorTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::ExpandingDecoratorTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::ExpandingDecoratorTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::ExpandingDecoratorTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + CLASS_MEMBER_FIELD(__vwsn_precompile_4) + CLASS_MEMBER_FIELD(__vwsn_precompile_5) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::ExpandingDecoratorTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::GroupBoxTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::GroupBoxTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::GroupBoxTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::GroupBoxTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::GroupBoxTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + CLASS_MEMBER_FIELD(__vwsn_precompile_4) + CLASS_MEMBER_FIELD(__vwsn_precompile_5) + CLASS_MEMBER_FIELD(container) + CLASS_MEMBER_FIELD(self) + CLASS_MEMBER_FIELD(titleBounds) + END_CLASS_MEMBER(::darkskin::GroupBoxTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::HScrollHandleTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::HScrollHandleTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::HScrollHandleTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::HScrollHandleTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::HScrollHandleTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::HScrollHandleTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::HScrollTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::HScrollTemplate*(), NO_PARAMETER) + CLASS_MEMBER_FIELD(draggingHandle) + CLASS_MEMBER_FIELD(draggingStartLocation) + END_CLASS_MEMBER(::darkskin::HScrollTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::HScrollTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::HScrollTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_10) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + CLASS_MEMBER_FIELD(__vwsn_precompile_4) + CLASS_MEMBER_FIELD(__vwsn_precompile_5) + CLASS_MEMBER_FIELD(__vwsn_precompile_6) + CLASS_MEMBER_FIELD(__vwsn_precompile_7) + CLASS_MEMBER_FIELD(__vwsn_precompile_8) + CLASS_MEMBER_FIELD(__vwsn_precompile_9) + CLASS_MEMBER_FIELD(handle) + CLASS_MEMBER_FIELD(handleContainer) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::HScrollTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::HTrackerTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::HTrackerTemplate*(), NO_PARAMETER) + CLASS_MEMBER_FIELD(draggingHandle) + CLASS_MEMBER_FIELD(draggingStartLocation) + END_CLASS_MEMBER(::darkskin::HTrackerTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::HTrackerTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::HTrackerTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + CLASS_MEMBER_FIELD(__vwsn_precompile_4) + CLASS_MEMBER_FIELD(__vwsn_precompile_5) + CLASS_MEMBER_FIELD(__vwsn_precompile_6) + CLASS_MEMBER_FIELD(__vwsn_precompile_7) + CLASS_MEMBER_FIELD(handle) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::HTrackerTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::ItemBackgroundTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::ItemBackgroundTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::ItemBackgroundTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::ItemBackgroundTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::ItemBackgroundTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(container) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::ItemBackgroundTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::LabelTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::LabelTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::LabelTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::LabelTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::LabelTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::LabelTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::LeftScrollButtonTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::LeftScrollButtonTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::LeftScrollButtonTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::LeftScrollButtonTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::LeftScrollButtonTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::LeftScrollButtonTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::ListViewColumnHeaderTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::ListViewColumnHeaderTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::ListViewColumnHeaderTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::ListViewColumnHeaderTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::ListViewColumnHeaderTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + CLASS_MEMBER_FIELD(__vwsn_precompile_4) + CLASS_MEMBER_FIELD(__vwsn_precompile_5) + CLASS_MEMBER_FIELD(__vwsn_precompile_6) + CLASS_MEMBER_FIELD(__vwsn_precompile_7) + CLASS_MEMBER_FIELD(__vwsn_precompile_8) + CLASS_MEMBER_FIELD(__vwsn_precompile_9) + CLASS_MEMBER_FIELD(buttonArrow) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::ListViewColumnHeaderTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::ListViewTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::ListViewTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::ListViewTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::ListViewTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::ListViewTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(container) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::ListViewTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::MenuBarButtonTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::MenuBarButtonTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::MenuBarButtonTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::MenuBarButtonTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::MenuBarButtonTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::MenuBarButtonTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::MenuItemButtonTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::MenuItemButtonTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::MenuItemButtonTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::MenuItemButtonTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::MenuItemButtonTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_10) + CLASS_MEMBER_FIELD(__vwsn_precompile_11) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + CLASS_MEMBER_FIELD(__vwsn_precompile_4) + CLASS_MEMBER_FIELD(__vwsn_precompile_5) + CLASS_MEMBER_FIELD(__vwsn_precompile_6) + CLASS_MEMBER_FIELD(__vwsn_precompile_7) + CLASS_MEMBER_FIELD(__vwsn_precompile_8) + CLASS_MEMBER_FIELD(__vwsn_precompile_9) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::MenuItemButtonTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::MenuSplitterTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::MenuSplitterTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::MenuSplitterTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::MenuSplitterTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::MenuSplitterTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + END_CLASS_MEMBER(::darkskin::MenuSplitterTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::MultilineTextBoxTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::MultilineTextBoxTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::MultilineTextBoxTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::MultilineTextBoxTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::MultilineTextBoxTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(container) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::MultilineTextBoxTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::ProgressBarTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::ProgressBarTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::ProgressBarTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::ProgressBarTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::ProgressBarTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + CLASS_MEMBER_FIELD(__vwsn_precompile_4) + CLASS_MEMBER_FIELD(container) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::ProgressBarTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::RadioButtonTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::RadioButtonTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::RadioButtonTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::RadioButtonTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::RadioButtonTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_10) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + CLASS_MEMBER_FIELD(__vwsn_precompile_4) + CLASS_MEMBER_FIELD(__vwsn_precompile_5) + CLASS_MEMBER_FIELD(__vwsn_precompile_6) + CLASS_MEMBER_FIELD(__vwsn_precompile_7) + CLASS_MEMBER_FIELD(__vwsn_precompile_8) + CLASS_MEMBER_FIELD(__vwsn_precompile_9) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::RadioButtonTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::RightScrollButtonTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::RightScrollButtonTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::RightScrollButtonTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::RightScrollButtonTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::RightScrollButtonTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::RightScrollButtonTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::ScrollViewTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::ScrollViewTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::ScrollViewTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::ScrollViewTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::ScrollViewTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(container) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::ScrollViewTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::ShortcutKeyTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::ShortcutKeyTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::ShortcutKeyTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::ShortcutKeyTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::ShortcutKeyTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + CLASS_MEMBER_FIELD(__vwsn_precompile_4) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::ShortcutKeyTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::SinglelineTextBoxTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::SinglelineTextBoxTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::SinglelineTextBoxTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::SinglelineTextBoxTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::SinglelineTextBoxTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(container) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::SinglelineTextBoxTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::TabDropdownTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::TabDropdownTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::TabDropdownTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::TabDropdownTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::TabDropdownTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::TabDropdownTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::TabHeaderTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::TabHeaderTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::TabHeaderTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::TabHeaderTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::TabHeaderTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::TabHeaderTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::TabTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::TabTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::TabTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::TabTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::TabTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + CLASS_MEMBER_FIELD(__vwsn_precompile_4) + CLASS_MEMBER_FIELD(__vwsn_precompile_5) + CLASS_MEMBER_FIELD(__vwsn_precompile_6) + CLASS_MEMBER_FIELD(container) + CLASS_MEMBER_FIELD(header) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::TabTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::TextListTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::TextListTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::TextListTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::TextListTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::TextListTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(container) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::TextListTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::Theme) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::Theme*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::Theme) + + BEGIN_CLASS_MEMBER(::darkskin::ThemeConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::ThemeConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + END_CLASS_MEMBER(::darkskin::ThemeConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::ToolstripButtonTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::ToolstripButtonTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::ToolstripButtonTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::ToolstripButtonTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::ToolstripButtonTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + CLASS_MEMBER_FIELD(__vwsn_precompile_4) + CLASS_MEMBER_FIELD(container) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::ToolstripButtonTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::ToolstripDropdownButtonTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::ToolstripDropdownButtonTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::ToolstripDropdownButtonTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::ToolstripDropdownButtonTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::ToolstripDropdownButtonTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + CLASS_MEMBER_FIELD(__vwsn_precompile_4) + CLASS_MEMBER_FIELD(__vwsn_precompile_5) + CLASS_MEMBER_FIELD(__vwsn_precompile_6) + CLASS_MEMBER_FIELD(__vwsn_precompile_7) + CLASS_MEMBER_FIELD(__vwsn_precompile_8) + CLASS_MEMBER_FIELD(container) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::ToolstripDropdownButtonTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::ToolstripMenuTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::ToolstripMenuTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::ToolstripMenuTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::ToolstripMenuTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::ToolstripMenuTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(container) + END_CLASS_MEMBER(::darkskin::ToolstripMenuTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::ToolstripSplitArrowTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::ToolstripSplitArrowTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::ToolstripSplitArrowTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::ToolstripSplitArrowTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::ToolstripSplitArrowTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::ToolstripSplitArrowTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::ToolstripSplitButtonTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::ToolstripSplitButtonTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::ToolstripSplitButtonTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::ToolstripSplitButtonTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::ToolstripSplitButtonTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + CLASS_MEMBER_FIELD(__vwsn_precompile_4) + CLASS_MEMBER_FIELD(__vwsn_precompile_5) + CLASS_MEMBER_FIELD(__vwsn_precompile_6) + CLASS_MEMBER_FIELD(__vwsn_precompile_7) + CLASS_MEMBER_FIELD(__vwsn_precompile_8) + CLASS_MEMBER_FIELD(buttonArrow) + CLASS_MEMBER_FIELD(container) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::ToolstripSplitButtonTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::ToolstripSplitterTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::ToolstripSplitterTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::ToolstripSplitterTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::ToolstripSplitterTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::ToolstripSplitterTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + END_CLASS_MEMBER(::darkskin::ToolstripSplitterTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::ToolstripTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::ToolstripTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::ToolstripTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::ToolstripTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::ToolstripTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + END_CLASS_MEMBER(::darkskin::ToolstripTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::TooltipTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::TooltipTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::TooltipTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::TooltipTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::TooltipTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + CLASS_MEMBER_FIELD(container) + END_CLASS_MEMBER(::darkskin::TooltipTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::TopScrollButtonTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::TopScrollButtonTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::TopScrollButtonTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::TopScrollButtonTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::TopScrollButtonTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::TopScrollButtonTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::TreeViewTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::TreeViewTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::TreeViewTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::TreeViewTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::TreeViewTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(container) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::TreeViewTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::VScrollHandleTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::VScrollHandleTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::VScrollHandleTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::VScrollHandleTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::VScrollHandleTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::VScrollHandleTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::VScrollTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::VScrollTemplate*(), NO_PARAMETER) + CLASS_MEMBER_FIELD(draggingHandle) + CLASS_MEMBER_FIELD(draggingStartLocation) + END_CLASS_MEMBER(::darkskin::VScrollTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::VScrollTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::VScrollTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_10) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + CLASS_MEMBER_FIELD(__vwsn_precompile_4) + CLASS_MEMBER_FIELD(__vwsn_precompile_5) + CLASS_MEMBER_FIELD(__vwsn_precompile_6) + CLASS_MEMBER_FIELD(__vwsn_precompile_7) + CLASS_MEMBER_FIELD(__vwsn_precompile_8) + CLASS_MEMBER_FIELD(__vwsn_precompile_9) + CLASS_MEMBER_FIELD(handle) + CLASS_MEMBER_FIELD(handleContainer) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::VScrollTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::VTrackerTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::VTrackerTemplate*(), NO_PARAMETER) + CLASS_MEMBER_FIELD(draggingHandle) + CLASS_MEMBER_FIELD(draggingStartLocation) + END_CLASS_MEMBER(::darkskin::VTrackerTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::VTrackerTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::VTrackerTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + CLASS_MEMBER_FIELD(__vwsn_precompile_4) + CLASS_MEMBER_FIELD(__vwsn_precompile_5) + CLASS_MEMBER_FIELD(__vwsn_precompile_6) + CLASS_MEMBER_FIELD(__vwsn_precompile_7) + CLASS_MEMBER_FIELD(handle) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::VTrackerTemplateConstructor) + + BEGIN_CLASS_MEMBER(::darkskin::WindowTemplate) + CLASS_MEMBER_CONSTRUCTOR(::darkskin::WindowTemplate*(), NO_PARAMETER) + END_CLASS_MEMBER(::darkskin::WindowTemplate) + + BEGIN_CLASS_MEMBER(::darkskin::WindowTemplateConstructor) + CLASS_MEMBER_CONSTRUCTOR(::vl::Ptr<::darkskin::WindowTemplateConstructor>(), NO_PARAMETER) + CLASS_MEMBER_METHOD(__vwsn_initialize_instance_, { L"__vwsn_this_" }) + CLASS_MEMBER_FIELD(__vwsn_precompile_0) + CLASS_MEMBER_FIELD(__vwsn_precompile_1) + CLASS_MEMBER_FIELD(__vwsn_precompile_10) + CLASS_MEMBER_FIELD(__vwsn_precompile_11) + CLASS_MEMBER_FIELD(__vwsn_precompile_12) + CLASS_MEMBER_FIELD(__vwsn_precompile_13) + CLASS_MEMBER_FIELD(__vwsn_precompile_14) + CLASS_MEMBER_FIELD(__vwsn_precompile_15) + CLASS_MEMBER_FIELD(__vwsn_precompile_16) + CLASS_MEMBER_FIELD(__vwsn_precompile_17) + CLASS_MEMBER_FIELD(__vwsn_precompile_18) + CLASS_MEMBER_FIELD(__vwsn_precompile_19) + CLASS_MEMBER_FIELD(__vwsn_precompile_2) + CLASS_MEMBER_FIELD(__vwsn_precompile_20) + CLASS_MEMBER_FIELD(__vwsn_precompile_21) + CLASS_MEMBER_FIELD(__vwsn_precompile_22) + CLASS_MEMBER_FIELD(__vwsn_precompile_23) + CLASS_MEMBER_FIELD(__vwsn_precompile_24) + CLASS_MEMBER_FIELD(__vwsn_precompile_3) + CLASS_MEMBER_FIELD(__vwsn_precompile_4) + CLASS_MEMBER_FIELD(__vwsn_precompile_5) + CLASS_MEMBER_FIELD(__vwsn_precompile_6) + CLASS_MEMBER_FIELD(__vwsn_precompile_7) + CLASS_MEMBER_FIELD(__vwsn_precompile_8) + CLASS_MEMBER_FIELD(__vwsn_precompile_9) + CLASS_MEMBER_FIELD(container) + CLASS_MEMBER_FIELD(self) + END_CLASS_MEMBER(::darkskin::WindowTemplateConstructor) + +#undef _ + class DarkSkinTypeLoader : public Object, public ITypeLoader + { + public: + void Load(ITypeManager* manager) + { + ADD_TYPE_INFO(::ScrollTemplateScript) + ADD_TYPE_INFO(::darkskin::BottomScrollButtonTemplate) + ADD_TYPE_INFO(::darkskin::BottomScrollButtonTemplateConstructor) + ADD_TYPE_INFO(::darkskin::ButtonTemplate) + ADD_TYPE_INFO(::darkskin::ButtonTemplateConstructor) + ADD_TYPE_INFO(::darkskin::CheckBoxTemplate) + ADD_TYPE_INFO(::darkskin::CheckBoxTemplateConstructor) + ADD_TYPE_INFO(::darkskin::CheckItemBackgroundTemplate) + ADD_TYPE_INFO(::darkskin::CheckItemBackgroundTemplateConstructor) + ADD_TYPE_INFO(::darkskin::ComboBoxTemplate) + ADD_TYPE_INFO(::darkskin::ComboBoxTemplateConstructor) + ADD_TYPE_INFO(::darkskin::CustomControlTemplate) + ADD_TYPE_INFO(::darkskin::CustomControlTemplateConstructor) + ADD_TYPE_INFO(::darkskin::DatePickerTemplate) + ADD_TYPE_INFO(::darkskin::DatePickerTemplateConstructor) + ADD_TYPE_INFO(::darkskin::DocumentLabelTemplate) + ADD_TYPE_INFO(::darkskin::DocumentLabelTemplateConstructor) + ADD_TYPE_INFO(::darkskin::DocumentTextBoxTemplate) + ADD_TYPE_INFO(::darkskin::DocumentTextBoxTemplateConstructor) + ADD_TYPE_INFO(::darkskin::DocumentViewerTemplate) + ADD_TYPE_INFO(::darkskin::DocumentViewerTemplateConstructor) + ADD_TYPE_INFO(::darkskin::ExpandingDecoratorTemplate) + ADD_TYPE_INFO(::darkskin::ExpandingDecoratorTemplateConstructor) + ADD_TYPE_INFO(::darkskin::GroupBoxTemplate) + ADD_TYPE_INFO(::darkskin::GroupBoxTemplateConstructor) + ADD_TYPE_INFO(::darkskin::HScrollHandleTemplate) + ADD_TYPE_INFO(::darkskin::HScrollHandleTemplateConstructor) + ADD_TYPE_INFO(::darkskin::HScrollTemplate) + ADD_TYPE_INFO(::darkskin::HScrollTemplateConstructor) + ADD_TYPE_INFO(::darkskin::HTrackerTemplate) + ADD_TYPE_INFO(::darkskin::HTrackerTemplateConstructor) + ADD_TYPE_INFO(::darkskin::ItemBackgroundTemplate) + ADD_TYPE_INFO(::darkskin::ItemBackgroundTemplateConstructor) + ADD_TYPE_INFO(::darkskin::LabelTemplate) + ADD_TYPE_INFO(::darkskin::LabelTemplateConstructor) + ADD_TYPE_INFO(::darkskin::LeftScrollButtonTemplate) + ADD_TYPE_INFO(::darkskin::LeftScrollButtonTemplateConstructor) + ADD_TYPE_INFO(::darkskin::ListViewColumnHeaderTemplate) + ADD_TYPE_INFO(::darkskin::ListViewColumnHeaderTemplateConstructor) + ADD_TYPE_INFO(::darkskin::ListViewTemplate) + ADD_TYPE_INFO(::darkskin::ListViewTemplateConstructor) + ADD_TYPE_INFO(::darkskin::MenuBarButtonTemplate) + ADD_TYPE_INFO(::darkskin::MenuBarButtonTemplateConstructor) + ADD_TYPE_INFO(::darkskin::MenuItemButtonTemplate) + ADD_TYPE_INFO(::darkskin::MenuItemButtonTemplateConstructor) + ADD_TYPE_INFO(::darkskin::MenuSplitterTemplate) + ADD_TYPE_INFO(::darkskin::MenuSplitterTemplateConstructor) + ADD_TYPE_INFO(::darkskin::MultilineTextBoxTemplate) + ADD_TYPE_INFO(::darkskin::MultilineTextBoxTemplateConstructor) + ADD_TYPE_INFO(::darkskin::ProgressBarTemplate) + ADD_TYPE_INFO(::darkskin::ProgressBarTemplateConstructor) + ADD_TYPE_INFO(::darkskin::RadioButtonTemplate) + ADD_TYPE_INFO(::darkskin::RadioButtonTemplateConstructor) + ADD_TYPE_INFO(::darkskin::RightScrollButtonTemplate) + ADD_TYPE_INFO(::darkskin::RightScrollButtonTemplateConstructor) + ADD_TYPE_INFO(::darkskin::ScrollViewTemplate) + ADD_TYPE_INFO(::darkskin::ScrollViewTemplateConstructor) + ADD_TYPE_INFO(::darkskin::ShortcutKeyTemplate) + ADD_TYPE_INFO(::darkskin::ShortcutKeyTemplateConstructor) + ADD_TYPE_INFO(::darkskin::SinglelineTextBoxTemplate) + ADD_TYPE_INFO(::darkskin::SinglelineTextBoxTemplateConstructor) + ADD_TYPE_INFO(::darkskin::TabDropdownTemplate) + ADD_TYPE_INFO(::darkskin::TabDropdownTemplateConstructor) + ADD_TYPE_INFO(::darkskin::TabHeaderTemplate) + ADD_TYPE_INFO(::darkskin::TabHeaderTemplateConstructor) + ADD_TYPE_INFO(::darkskin::TabTemplate) + ADD_TYPE_INFO(::darkskin::TabTemplateConstructor) + ADD_TYPE_INFO(::darkskin::TextListTemplate) + ADD_TYPE_INFO(::darkskin::TextListTemplateConstructor) + ADD_TYPE_INFO(::darkskin::Theme) + ADD_TYPE_INFO(::darkskin::ThemeConstructor) + ADD_TYPE_INFO(::darkskin::ToolstripButtonTemplate) + ADD_TYPE_INFO(::darkskin::ToolstripButtonTemplateConstructor) + ADD_TYPE_INFO(::darkskin::ToolstripDropdownButtonTemplate) + ADD_TYPE_INFO(::darkskin::ToolstripDropdownButtonTemplateConstructor) + ADD_TYPE_INFO(::darkskin::ToolstripMenuTemplate) + ADD_TYPE_INFO(::darkskin::ToolstripMenuTemplateConstructor) + ADD_TYPE_INFO(::darkskin::ToolstripSplitArrowTemplate) + ADD_TYPE_INFO(::darkskin::ToolstripSplitArrowTemplateConstructor) + ADD_TYPE_INFO(::darkskin::ToolstripSplitButtonTemplate) + ADD_TYPE_INFO(::darkskin::ToolstripSplitButtonTemplateConstructor) + ADD_TYPE_INFO(::darkskin::ToolstripSplitterTemplate) + ADD_TYPE_INFO(::darkskin::ToolstripSplitterTemplateConstructor) + ADD_TYPE_INFO(::darkskin::ToolstripTemplate) + ADD_TYPE_INFO(::darkskin::ToolstripTemplateConstructor) + ADD_TYPE_INFO(::darkskin::TooltipTemplate) + ADD_TYPE_INFO(::darkskin::TooltipTemplateConstructor) + ADD_TYPE_INFO(::darkskin::TopScrollButtonTemplate) + ADD_TYPE_INFO(::darkskin::TopScrollButtonTemplateConstructor) + ADD_TYPE_INFO(::darkskin::TreeViewTemplate) + ADD_TYPE_INFO(::darkskin::TreeViewTemplateConstructor) + ADD_TYPE_INFO(::darkskin::VScrollHandleTemplate) + ADD_TYPE_INFO(::darkskin::VScrollHandleTemplateConstructor) + ADD_TYPE_INFO(::darkskin::VScrollTemplate) + ADD_TYPE_INFO(::darkskin::VScrollTemplateConstructor) + ADD_TYPE_INFO(::darkskin::VTrackerTemplate) + ADD_TYPE_INFO(::darkskin::VTrackerTemplateConstructor) + ADD_TYPE_INFO(::darkskin::WindowTemplate) + ADD_TYPE_INFO(::darkskin::WindowTemplateConstructor) + } + + void Unload(ITypeManager* manager) + { + } + }; +#endif + + bool LoadDarkSkinTypes() + { +#ifndef VCZH_DEBUG_NO_REFLECTION + if (auto manager = GetGlobalTypeManager()) + { + return manager->AddTypeLoader(MakePtr()); + } +#endif + return false; + } + } + } +} + +#if defined( _MSC_VER) +#pragma warning(pop) +#elif defined(__GNUC__) +#pragma GCC diagnostic pop +#elif defined(__clang__) +#pragma clang diagnostic pop +#endif + diff --git a/Import/Skins/DarkSkin/DarkSkinReflection.h b/Import/Skins/DarkSkin/DarkSkinReflection.h new file mode 100644 index 00000000..1fe7c330 --- /dev/null +++ b/Import/Skins/DarkSkin/DarkSkinReflection.h @@ -0,0 +1,165 @@ +/*********************************************************************** +THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY +DEVELOPER: Zihan Chen(vczh) +***********************************************************************/ +#include "DarkSkin.h" +#include "GacUI.h" +#include "GacUIReflection.h" +#include "Vlpp.h" + +/*********************************************************************** +.\DARKSKINREFLECTION.H +***********************************************************************/ +/*********************************************************************** +!!!!!! DO NOT MODIFY !!!!!! + +GacGen.exe Resource.xml + +This file is generated by Workflow compiler +https://github.com/vczh-libraries +***********************************************************************/ + +#ifndef VCZH_WORKFLOW_COMPILER_GENERATED_DARKSKINREFLECTION +#define VCZH_WORKFLOW_COMPILER_GENERATED_DARKSKINREFLECTION + +#ifndef VCZH_DEBUG_NO_REFLECTION +#endif + +#if defined( _MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#elif defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wparentheses-equality" +#elif defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wparentheses-equality" +#endif + +/*********************************************************************** +Reflection +***********************************************************************/ + +namespace vl +{ + namespace reflection + { + namespace description + { +#ifndef VCZH_DEBUG_NO_REFLECTION + DECL_TYPE_INFO(::ScrollTemplateScript) + DECL_TYPE_INFO(::darkskin::BottomScrollButtonTemplate) + DECL_TYPE_INFO(::darkskin::BottomScrollButtonTemplateConstructor) + DECL_TYPE_INFO(::darkskin::ButtonTemplate) + DECL_TYPE_INFO(::darkskin::ButtonTemplateConstructor) + DECL_TYPE_INFO(::darkskin::CheckBoxTemplate) + DECL_TYPE_INFO(::darkskin::CheckBoxTemplateConstructor) + DECL_TYPE_INFO(::darkskin::CheckItemBackgroundTemplate) + DECL_TYPE_INFO(::darkskin::CheckItemBackgroundTemplateConstructor) + DECL_TYPE_INFO(::darkskin::ComboBoxTemplate) + DECL_TYPE_INFO(::darkskin::ComboBoxTemplateConstructor) + DECL_TYPE_INFO(::darkskin::CustomControlTemplate) + DECL_TYPE_INFO(::darkskin::CustomControlTemplateConstructor) + DECL_TYPE_INFO(::darkskin::DatePickerTemplate) + DECL_TYPE_INFO(::darkskin::DatePickerTemplateConstructor) + DECL_TYPE_INFO(::darkskin::DocumentLabelTemplate) + DECL_TYPE_INFO(::darkskin::DocumentLabelTemplateConstructor) + DECL_TYPE_INFO(::darkskin::DocumentTextBoxTemplate) + DECL_TYPE_INFO(::darkskin::DocumentTextBoxTemplateConstructor) + DECL_TYPE_INFO(::darkskin::DocumentViewerTemplate) + DECL_TYPE_INFO(::darkskin::DocumentViewerTemplateConstructor) + DECL_TYPE_INFO(::darkskin::ExpandingDecoratorTemplate) + DECL_TYPE_INFO(::darkskin::ExpandingDecoratorTemplateConstructor) + DECL_TYPE_INFO(::darkskin::GroupBoxTemplate) + DECL_TYPE_INFO(::darkskin::GroupBoxTemplateConstructor) + DECL_TYPE_INFO(::darkskin::HScrollHandleTemplate) + DECL_TYPE_INFO(::darkskin::HScrollHandleTemplateConstructor) + DECL_TYPE_INFO(::darkskin::HScrollTemplate) + DECL_TYPE_INFO(::darkskin::HScrollTemplateConstructor) + DECL_TYPE_INFO(::darkskin::HTrackerTemplate) + DECL_TYPE_INFO(::darkskin::HTrackerTemplateConstructor) + DECL_TYPE_INFO(::darkskin::ItemBackgroundTemplate) + DECL_TYPE_INFO(::darkskin::ItemBackgroundTemplateConstructor) + DECL_TYPE_INFO(::darkskin::LabelTemplate) + DECL_TYPE_INFO(::darkskin::LabelTemplateConstructor) + DECL_TYPE_INFO(::darkskin::LeftScrollButtonTemplate) + DECL_TYPE_INFO(::darkskin::LeftScrollButtonTemplateConstructor) + DECL_TYPE_INFO(::darkskin::ListViewColumnHeaderTemplate) + DECL_TYPE_INFO(::darkskin::ListViewColumnHeaderTemplateConstructor) + DECL_TYPE_INFO(::darkskin::ListViewTemplate) + DECL_TYPE_INFO(::darkskin::ListViewTemplateConstructor) + DECL_TYPE_INFO(::darkskin::MenuBarButtonTemplate) + DECL_TYPE_INFO(::darkskin::MenuBarButtonTemplateConstructor) + DECL_TYPE_INFO(::darkskin::MenuItemButtonTemplate) + DECL_TYPE_INFO(::darkskin::MenuItemButtonTemplateConstructor) + DECL_TYPE_INFO(::darkskin::MenuSplitterTemplate) + DECL_TYPE_INFO(::darkskin::MenuSplitterTemplateConstructor) + DECL_TYPE_INFO(::darkskin::MultilineTextBoxTemplate) + DECL_TYPE_INFO(::darkskin::MultilineTextBoxTemplateConstructor) + DECL_TYPE_INFO(::darkskin::ProgressBarTemplate) + DECL_TYPE_INFO(::darkskin::ProgressBarTemplateConstructor) + DECL_TYPE_INFO(::darkskin::RadioButtonTemplate) + DECL_TYPE_INFO(::darkskin::RadioButtonTemplateConstructor) + DECL_TYPE_INFO(::darkskin::RightScrollButtonTemplate) + DECL_TYPE_INFO(::darkskin::RightScrollButtonTemplateConstructor) + DECL_TYPE_INFO(::darkskin::ScrollViewTemplate) + DECL_TYPE_INFO(::darkskin::ScrollViewTemplateConstructor) + DECL_TYPE_INFO(::darkskin::ShortcutKeyTemplate) + DECL_TYPE_INFO(::darkskin::ShortcutKeyTemplateConstructor) + DECL_TYPE_INFO(::darkskin::SinglelineTextBoxTemplate) + DECL_TYPE_INFO(::darkskin::SinglelineTextBoxTemplateConstructor) + DECL_TYPE_INFO(::darkskin::TabDropdownTemplate) + DECL_TYPE_INFO(::darkskin::TabDropdownTemplateConstructor) + DECL_TYPE_INFO(::darkskin::TabHeaderTemplate) + DECL_TYPE_INFO(::darkskin::TabHeaderTemplateConstructor) + DECL_TYPE_INFO(::darkskin::TabTemplate) + DECL_TYPE_INFO(::darkskin::TabTemplateConstructor) + DECL_TYPE_INFO(::darkskin::TextListTemplate) + DECL_TYPE_INFO(::darkskin::TextListTemplateConstructor) + DECL_TYPE_INFO(::darkskin::Theme) + DECL_TYPE_INFO(::darkskin::ThemeConstructor) + DECL_TYPE_INFO(::darkskin::ToolstripButtonTemplate) + DECL_TYPE_INFO(::darkskin::ToolstripButtonTemplateConstructor) + DECL_TYPE_INFO(::darkskin::ToolstripDropdownButtonTemplate) + DECL_TYPE_INFO(::darkskin::ToolstripDropdownButtonTemplateConstructor) + DECL_TYPE_INFO(::darkskin::ToolstripMenuTemplate) + DECL_TYPE_INFO(::darkskin::ToolstripMenuTemplateConstructor) + DECL_TYPE_INFO(::darkskin::ToolstripSplitArrowTemplate) + DECL_TYPE_INFO(::darkskin::ToolstripSplitArrowTemplateConstructor) + DECL_TYPE_INFO(::darkskin::ToolstripSplitButtonTemplate) + DECL_TYPE_INFO(::darkskin::ToolstripSplitButtonTemplateConstructor) + DECL_TYPE_INFO(::darkskin::ToolstripSplitterTemplate) + DECL_TYPE_INFO(::darkskin::ToolstripSplitterTemplateConstructor) + DECL_TYPE_INFO(::darkskin::ToolstripTemplate) + DECL_TYPE_INFO(::darkskin::ToolstripTemplateConstructor) + DECL_TYPE_INFO(::darkskin::TooltipTemplate) + DECL_TYPE_INFO(::darkskin::TooltipTemplateConstructor) + DECL_TYPE_INFO(::darkskin::TopScrollButtonTemplate) + DECL_TYPE_INFO(::darkskin::TopScrollButtonTemplateConstructor) + DECL_TYPE_INFO(::darkskin::TreeViewTemplate) + DECL_TYPE_INFO(::darkskin::TreeViewTemplateConstructor) + DECL_TYPE_INFO(::darkskin::VScrollHandleTemplate) + DECL_TYPE_INFO(::darkskin::VScrollHandleTemplateConstructor) + DECL_TYPE_INFO(::darkskin::VScrollTemplate) + DECL_TYPE_INFO(::darkskin::VScrollTemplateConstructor) + DECL_TYPE_INFO(::darkskin::VTrackerTemplate) + DECL_TYPE_INFO(::darkskin::VTrackerTemplateConstructor) + DECL_TYPE_INFO(::darkskin::WindowTemplate) + DECL_TYPE_INFO(::darkskin::WindowTemplateConstructor) +#endif + + extern bool LoadDarkSkinTypes(); + } + } +} + +#if defined( _MSC_VER) +#pragma warning(pop) +#elif defined(__GNUC__) +#pragma GCC diagnostic pop +#elif defined(__clang__) +#pragma clang diagnostic pop +#endif + +#endif + diff --git a/Import/Vlpp.cpp b/Import/Vlpp.cpp index 9664ee7b..ca71a446 100644 --- a/Import/Vlpp.cpp +++ b/Import/Vlpp.cpp @@ -5,7 +5,7 @@ DEVELOPER: Zihan Chen(vczh) #include "Vlpp.h" /*********************************************************************** -BASIC.CPP +.\BASIC.CPP ***********************************************************************/ #if defined VCZH_MSVC #include @@ -270,8 +270,9 @@ Interface } } + /*********************************************************************** -CONSOLE.CPP +.\CONSOLE.CPP ***********************************************************************/ #if defined VCZH_MSVC #elif defined VCZH_GCC @@ -389,8 +390,398 @@ Console } } + /*********************************************************************** -EXCEPTION.CPP +.\STRING.CPP +***********************************************************************/ +#if defined VCZH_MSVC +#elif defined VCZH_GCC +#include +#include +#define _strtoi64 strtoll +#define _strtoui64 strtoull +#define _wcstoi64 wcstoll +#define _wcstoui64 wcstoull +#endif + +namespace vl +{ +#if defined VCZH_GCC + void _itoa_s(vint32_t value, char* buffer, size_t size, vint radix) + { + sprintf(buffer, "%d", value); + } + + void _itow_s(vint32_t value, wchar_t* buffer, size_t size, vint radix) + { + swprintf(buffer, size - 1, L"%d", value); + } + + void _i64toa_s(vint64_t value, char* buffer, size_t size, vint radix) + { + sprintf(buffer, "%ld", value); + } + + void _i64tow_s(vint64_t value, wchar_t* buffer, size_t size, vint radix) + { + swprintf(buffer, size - 1, L"%ld", value); + } + + void _uitoa_s(vuint32_t value, char* buffer, size_t size, vint radix) + { + sprintf(buffer, "%u", value); + } + + void _uitow_s(vuint32_t value, wchar_t* buffer, size_t size, vint radix) + { + swprintf(buffer, size - 1, L"%u", value); + } + + void _ui64toa_s(vuint64_t value, char* buffer, size_t size, vint radix) + { + sprintf(buffer, "%lu", value); + } + + void _ui64tow_s(vuint64_t value, wchar_t* buffer, size_t size, vint radix) + { + swprintf(buffer, size - 1, L"%lu", value); + } + + void _gcvt_s(char* buffer, size_t size, double value, vint numberOfDigits) + { + sprintf(buffer, "%f", value); + char* point = strchr(buffer, '.'); + if(!point) return; + char* zero = buffer + strlen(buffer); + while(zero[-1] == '0') + { + *--zero = '\0'; + } + if(zero[-1] == '.') *--zero = '\0'; + } + + void _strlwr_s(char* buffer, size_t size) + { + while(*buffer) + { + *buffer=(char)tolower(*buffer); + buffer++; + } + } + + void _strupr_s(char* buffer, size_t size) + { + while(*buffer) + { + *buffer=(char)toupper(*buffer); + buffer++; + } + } + + void _wcslwr_s(wchar_t* buffer, size_t size) + { + while(*buffer) + { + *buffer=(char)towlower(*buffer); + buffer++; + } + } + + void _wcsupr_s(wchar_t* buffer, size_t size) + { + while(*buffer) + { + *buffer=(char)towupper(*buffer); + buffer++; + } + } +#endif + + vint atoi_test(const AString& string, bool& success) + { + char* endptr = 0; + vint result = strtol(string.Buffer(), &endptr, 10); + success = endptr == string.Buffer() + string.Length() && itoa(result) == string; + return result; + } + + vint wtoi_test(const WString& string, bool& success) + { + wchar_t* endptr = 0; + vint result = wcstol(string.Buffer(), &endptr, 10); + success = endptr == string.Buffer() + string.Length() && itow(result) == string; + return result; + } + + vint64_t atoi64_test(const AString& string, bool& success) + { + char* endptr = 0; + vint64_t result = _strtoi64(string.Buffer(), &endptr, 10); + success = endptr == string.Buffer() + string.Length() && i64toa(result) == string; + return result; + } + + vint64_t wtoi64_test(const WString& string, bool& success) + { + wchar_t* endptr = 0; + vint64_t result = _wcstoi64(string.Buffer(), &endptr, 10); + success = endptr == string.Buffer() + string.Length() && i64tow(result) == string; + return result; + } + + vuint atou_test(const AString& string, bool& success) + { + char* endptr = 0; + vuint result = strtoul(string.Buffer(), &endptr, 10); + success = endptr == string.Buffer() + string.Length() && utoa(result) == string; + return result; + } + + vuint wtou_test(const WString& string, bool& success) + { + wchar_t* endptr = 0; + vuint result = wcstoul(string.Buffer(), &endptr, 10); + success = endptr == string.Buffer() + string.Length() && utow(result) == string; + return result; + } + + vuint64_t atou64_test(const AString& string, bool& success) + { + char* endptr = 0; + vuint64_t result = _strtoui64(string.Buffer(), &endptr, 10); + success = endptr == string.Buffer() + string.Length() && u64toa(result) == string; + return result; + } + + vuint64_t wtou64_test(const WString& string, bool& success) + { + wchar_t* endptr = 0; + vuint64_t result = _wcstoui64(string.Buffer(), &endptr, 10); + success = endptr == string.Buffer() + string.Length() && u64tow(result) == string; + return result; + } + + double atof_test(const AString& string, bool& success) + { + char* endptr = 0; + double result = strtod(string.Buffer(), &endptr); + success = endptr == string.Buffer() + string.Length(); + return result; + } + + double wtof_test(const WString& string, bool& success) + { + wchar_t* endptr = 0; + double result = wcstod(string.Buffer(), &endptr); + success = endptr == string.Buffer() + string.Length(); + return result; + } + + vint atoi(const AString& string) + { + bool success = false; + return atoi_test(string, success); + } + + vint wtoi(const WString& string) + { + bool success = false; + return wtoi_test(string, success); + } + + vint64_t atoi64(const AString& string) + { + bool success = false; + return atoi64_test(string, success); + } + + vint64_t wtoi64(const WString& string) + { + bool success = false; + return wtoi64_test(string, success); + } + + vuint atou(const AString& string) + { + bool success = false; + return atou_test(string, success); + } + + vuint wtou(const WString& string) + { + bool success = false; + return wtou_test(string, success); + } + + vuint64_t atou64(const AString& string) + { + bool success = false; + return atou64_test(string, success); + } + + vuint64_t wtou64(const WString& string) + { + bool success = false; + return wtou64_test(string, success); + } + + double atof(const AString& string) + { + bool success = false; + return atof_test(string, success); + } + + double wtof(const WString& string) + { + bool success = false; + return wtof_test(string, success); + } + + AString itoa(vint number) + { + char buffer[100]; + ITOA_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10); + return buffer; + } + + WString itow(vint number) + { + wchar_t buffer[100]; + ITOW_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10); + return buffer; + } + + AString i64toa(vint64_t number) + { + char buffer[100]; + I64TOA_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10); + return buffer; + } + + WString i64tow(vint64_t number) + { + wchar_t buffer[100]; + I64TOW_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10); + return buffer; + } + + AString utoa(vuint number) + { + char buffer[100]; + UITOA_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10); + return buffer; + } + + WString utow(vuint number) + { + wchar_t buffer[100]; + UITOW_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10); + return buffer; + } + + AString u64toa(vuint64_t number) + { + char buffer[100]; + UI64TOA_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10); + return buffer; + } + + WString u64tow(vuint64_t number) + { + wchar_t buffer[100]; + UI64TOW_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10); + return buffer; + } + + AString ftoa(double number) + { + char buffer[320]; + _gcvt_s(buffer, 320, number, 30); + vint len = (vint)strlen(buffer); + if (buffer[len - 1] == '.') + { + buffer[len - 1] = '\0'; + } + return buffer; + } + + WString ftow(double number) + { + return atow(ftoa(number)); + } + + vint _wtoa(const wchar_t* w, char* a, vint chars) + { +#if defined VCZH_MSVC + return WideCharToMultiByte(CP_THREAD_ACP, 0, w, -1, a, (int)(a ? chars : 0), 0, 0); +#elif defined VCZH_GCC + return wcstombs(a, w, chars-1)+1; +#endif + } + + AString wtoa(const WString& string) + { + vint len = _wtoa(string.Buffer(), 0, 0); + char* buffer = new char[len]; + memset(buffer, 0, len*sizeof(*buffer)); + _wtoa(string.Buffer(), buffer, (int)len); + AString s = buffer; + delete[] buffer; + return s; + } + + vint _atow(const char* a, wchar_t* w, vint chars) + { +#if defined VCZH_MSVC + return MultiByteToWideChar(CP_THREAD_ACP, 0, a, -1, w, (int)(w ? chars : 0)); +#elif defined VCZH_GCC + return mbstowcs(w, a, chars-1)+1; +#endif + } + + WString atow(const AString& string) + { + vint len = _atow(string.Buffer(), 0, 0); + wchar_t* buffer = new wchar_t[len]; + memset(buffer, 0, len*sizeof(*buffer)); + _atow(string.Buffer(), buffer, (int)len); + WString s = buffer; + delete[] buffer; + return s; + } + + AString alower(const AString& string) + { + AString result = string.Buffer(); + _strlwr_s((char*)result.Buffer(), result.Length() + 1); + return result; + } + + WString wlower(const WString& string) + { + WString result = string.Buffer(); + _wcslwr_s((wchar_t*)result.Buffer(), result.Length() + 1); + return result; + } + + AString aupper(const AString& string) + { + AString result = string.Buffer(); + _strupr_s((char*)result.Buffer(), result.Length() + 1); + return result; + } + + WString wupper(const WString& string) + { + WString result = string.Buffer(); + _wcsupr_s((wchar_t*)result.Buffer(), result.Length() + 1); + return result; + } +} + + +/*********************************************************************** +.\EXCEPTION.CPP ***********************************************************************/ namespace vl @@ -453,7 +844,662 @@ ParsingException } /*********************************************************************** -FILESYSTEM.CPP +.\LOCALE.CPP +***********************************************************************/ +#if defined VCZH_MSVC +#elif defined VCZH_GCC +#endif + +namespace vl +{ + using namespace collections; + +#if defined VCZH_MSVC + + extern SYSTEMTIME DateTimeToSystemTime(const DateTime& dateTime); + + BOOL CALLBACK Locale_EnumLocalesProcEx( + _In_ LPWSTR lpLocaleString, + _In_ DWORD dwFlags, + _In_ LPARAM lParam + ) + { + ((List*)lParam)->Add(Locale(lpLocaleString)); + return TRUE; + } + + BOOL CALLBACK Locale_EnumDateFormatsProcExEx( + _In_ LPWSTR lpDateFormatString, + _In_ CALID CalendarID, + _In_ LPARAM lParam + ) + { + ((List*)lParam)->Add(lpDateFormatString); + return TRUE; + } + + BOOL CALLBACK EnumTimeFormatsProcEx( + _In_ LPWSTR lpTimeFormatString, + _In_ LPARAM lParam + ) + { + ((List*)lParam)->Add(lpTimeFormatString); + return TRUE; + } + + WString Transform(const WString& localeName, const WString& input, DWORD flag) + { + int length=LCMapStringEx(localeName.Buffer(), flag, input.Buffer(), (int)input.Length()+1, NULL, 0, NULL, NULL, NULL); + Array buffer(length); + LCMapStringEx(localeName.Buffer(), flag, input.Buffer(), (int)input.Length()+1, &buffer[0], (int)buffer.Count(), NULL, NULL, NULL); + return &buffer[0]; + } + + DWORD TranslateNormalization(Locale::Normalization normalization) + { + DWORD result=0; + if(normalization&Locale::IgnoreCase) result|=NORM_IGNORECASE; + if(normalization&Locale::IgnoreCaseLinguistic) result|=NORM_IGNORECASE | NORM_LINGUISTIC_CASING; + if(normalization&Locale::IgnoreKanaType) result|=NORM_IGNOREKANATYPE; + if(normalization&Locale::IgnoreNonSpace) result|=NORM_IGNORENONSPACE; + if(normalization&Locale::IgnoreSymbol) result|=NORM_IGNORESYMBOLS; + if(normalization&Locale::IgnoreWidth) result|=NORM_IGNOREWIDTH; + if(normalization&Locale::DigitsAsNumbers) result|=SORT_DIGITSASNUMBERS; + if(normalization&Locale::StringSoft) result|=SORT_STRINGSORT; + return result; + } + +#endif + +/*********************************************************************** +Locale +***********************************************************************/ + + Locale::Locale(const WString& _localeName) + :localeName(_localeName) + { + } + + Locale::~Locale() + { + } + + Locale Locale::Invariant() + { +#if defined VCZH_MSVC + return Locale(LOCALE_NAME_INVARIANT); +#elif defined VCZH_GCC + return Locale(L""); +#endif + } + + Locale Locale::SystemDefault() + { +#if defined VCZH_MSVC + wchar_t buffer[LOCALE_NAME_MAX_LENGTH+1]={0}; + GetSystemDefaultLocaleName(buffer, LOCALE_NAME_MAX_LENGTH); + return Locale(buffer); +#elif defined VCZH_GCC + return Locale(L"en-US"); +#endif + } + + Locale Locale::UserDefault() + { +#if defined VCZH_MSVC + wchar_t buffer[LOCALE_NAME_MAX_LENGTH+1]={0}; + GetUserDefaultLocaleName(buffer, LOCALE_NAME_MAX_LENGTH); + return Locale(buffer); +#elif defined VCZH_GCC + return Locale(L"en-US"); +#endif + } + + void Locale::Enumerate(collections::List& locales) + { +#if defined VCZH_MSVC + EnumSystemLocalesEx(&Locale_EnumLocalesProcEx, LOCALE_ALL, (LPARAM)&locales, NULL); +#elif defined VCZH_GCC + locales.Add(Locale(L"en-US")); +#endif + } + + const WString& Locale::GetName()const + { + return localeName; + } + + void Locale::GetShortDateFormats(collections::List& formats)const + { +#if defined VCZH_MSVC + EnumDateFormatsExEx(&Locale_EnumDateFormatsProcExEx, localeName.Buffer(), DATE_SHORTDATE, (LPARAM)&formats); +#elif defined VCZH_GCC + formats.Add(L"MM/dd/yyyy"); + formats.Add(L"yyyy-MM-dd"); +#endif + } + + void Locale::GetLongDateFormats(collections::List& formats)const + { +#if defined VCZH_MSVC + EnumDateFormatsExEx(&Locale_EnumDateFormatsProcExEx, localeName.Buffer(), DATE_LONGDATE, (LPARAM)&formats); +#elif defined VCZH_GCC + formats.Add(L"dddd, dd MMMM yyyy"); +#endif + } + + void Locale::GetYearMonthDateFormats(collections::List& formats)const + { +#if defined VCZH_MSVC + EnumDateFormatsExEx(&Locale_EnumDateFormatsProcExEx, localeName.Buffer(), DATE_YEARMONTH, (LPARAM)&formats); +#elif defined VCZH_GCC + formats.Add(L"yyyy MMMM"); +#endif + } + + void Locale::GetLongTimeFormats(collections::List& formats)const + { +#if defined VCZH_MSVC + EnumTimeFormatsEx(&EnumTimeFormatsProcEx, localeName.Buffer(), 0, (LPARAM)&formats); +#elif defined VCZH_GCC + formats.Add(L"HH:mm:ss"); +#endif + } + + void Locale::GetShortTimeFormats(collections::List& formats)const + { +#if defined VCZH_MSVC + EnumTimeFormatsEx(&EnumTimeFormatsProcEx, localeName.Buffer(), TIME_NOSECONDS, (LPARAM)&formats); +#elif defined VCZH_GCC + formats.Add(L"HH:mm"); + formats.Add(L"hh:mm tt"); +#endif + } + + WString Locale::FormatDate(const WString& format, DateTime date)const + { +#if defined VCZH_MSVC + SYSTEMTIME st=DateTimeToSystemTime(date); + int length=GetDateFormatEx(localeName.Buffer(), 0, &st, format.Buffer(), NULL, 0, NULL); + if(length==0) return L""; + Array buffer(length); + GetDateFormatEx(localeName.Buffer(), 0, &st, format.Buffer(), &buffer[0], (int)buffer.Count(), NULL); + return &buffer[0]; +#elif defined VCZH_GCC + /* + auto df = L"yyyy,MM,MMM,MMMM,dd,ddd,dddd"; + auto ds = L"2000,01,Jan,January,02,Sun,Sunday"; + auto tf = L"hh,HH,mm,ss,tt"; + auto ts = L"01,13,02,03,PM"; + */ + WString result; + const wchar_t* reading = format.Buffer(); + + while (*reading) + { + if (wcsncmp(reading, L"yyyy", 4) == 0) + { + WString fragment = itow(date.year); + while (fragment.Length() < 4) fragment = L"0" + fragment; + result += fragment; + reading += 4; + } + else if (wcsncmp(reading, L"MMMM", 4) == 0) + { + result += GetLongMonthName(date.month); + reading += 4; + } + else if (wcsncmp(reading, L"MMM", 3) == 0) + { + result += GetShortMonthName(date.month); + reading += 3; + } + else if (wcsncmp(reading, L"MM", 2) == 0) + { + WString fragment = itow(date.month); + while (fragment.Length() < 2) fragment = L"0" + fragment; + result += fragment; + reading += 2; + } + else if (wcsncmp(reading, L"dddd", 4) == 0) + { + result += GetLongDayOfWeekName(date.dayOfWeek); + reading += 4; + } + else if (wcsncmp(reading, L"ddd", 3) == 0) + { + result += GetShortDayOfWeekName(date.dayOfWeek); + reading += 3; + } + else if (wcsncmp(reading, L"dd", 2) == 0) + { + WString fragment = itow(date.day); + while (fragment.Length() < 2) fragment = L"0" + fragment; + result += fragment; + reading += 2; + } + else if (wcsncmp(reading, L"hh", 2) == 0) + { + WString fragment = itow(date.hour > 12 ? date.hour - 12 : date.hour); + while (fragment.Length() < 2) fragment = L"0" + fragment; + result += fragment; + reading += 2; + } + else if (wcsncmp(reading, L"HH", 2) == 0) + { + WString fragment = itow(date.hour); + while (fragment.Length() < 2) fragment = L"0" + fragment; + result += fragment; + reading += 2; + } + else if (wcsncmp(reading, L"mm", 2) == 0) + { + WString fragment = itow(date.minute); + while (fragment.Length() < 2) fragment = L"0" + fragment; + result += fragment; + reading += 2; + } + else if (wcsncmp(reading, L"ss", 2) == 0) + { + WString fragment = itow(date.second); + while (fragment.Length() < 2) fragment = L"0" + fragment; + result += fragment; + reading += 2; + } + else if (wcsncmp(reading, L"tt", 2) == 0) + { + result += date.hour > 12 ? L"PM" : L"AM"; + reading += 2; + } + else + { + result += *reading; + reading++; + } + } + return result; +#endif + } + + WString Locale::FormatTime(const WString& format, DateTime time)const + { +#if defined VCZH_MSVC + SYSTEMTIME st=DateTimeToSystemTime(time); + int length=GetTimeFormatEx(localeName.Buffer(), 0, &st, format.Buffer(), NULL, 0); + if(length==0) return L""; + Array buffer(length); + GetTimeFormatEx(localeName.Buffer(), 0, &st, format.Buffer(),&buffer[0], (int)buffer.Count()); + return &buffer[0]; +#elif defined VCZH_GCC + return FormatDate(format, time); +#endif + } + +#ifdef VCZH_MSVC + WString Locale::FormatNumber(const WString& number)const + { + int length=GetNumberFormatEx(localeName.Buffer(), 0, number.Buffer(), NULL, NULL, 0); + if(length==0) return L""; + Array buffer(length); + GetNumberFormatEx(localeName.Buffer(), 0, number.Buffer(), NULL, &buffer[0], (int)buffer.Count()); + return &buffer[0]; + } + + WString Locale::FormatCurrency(const WString& currency)const + { + int length=GetCurrencyFormatEx(localeName.Buffer(), 0, currency.Buffer(), NULL, NULL, 0); + if(length==0) return L""; + Array buffer(length); + GetCurrencyFormatEx(localeName.Buffer(), 0, currency.Buffer(), NULL, &buffer[0], (int)buffer.Count()); + return &buffer[0]; + } +#endif + + WString Locale::GetShortDayOfWeekName(vint dayOfWeek)const + { +#if defined VCZH_MSVC + return FormatDate(L"ddd", DateTime::FromDateTime(2000, 1, 2+dayOfWeek)); +#elif defined VCZH_GCC + switch(dayOfWeek) + { + case 0: return L"Sun"; + case 1: return L"Mon"; + case 2: return L"Tue"; + case 3: return L"Wed"; + case 4: return L"Thu"; + case 5: return L"Fri"; + case 6: return L"Sat"; + } + return L""; +#endif + } + + WString Locale::GetLongDayOfWeekName(vint dayOfWeek)const + { +#if defined VCZH_MSVC + return FormatDate(L"dddd", DateTime::FromDateTime(2000, 1, 2+dayOfWeek)); +#elif defined VCZH_GCC + switch(dayOfWeek) + { + case 0: return L"Sunday"; + case 1: return L"Monday"; + case 2: return L"Tuesday"; + case 3: return L"Wednesday"; + case 4: return L"Thursday"; + case 5: return L"Friday"; + case 6: return L"Saturday"; + } + return L""; +#endif + } + + WString Locale::GetShortMonthName(vint month)const + { +#if defined VCZH_MSVC + return FormatDate(L"MMM", DateTime::FromDateTime(2000, month, 1)); +#elif defined VCZH_GCC + switch(month) + { + case 1: return L"Jan"; + case 2: return L"Feb"; + case 3: return L"Mar"; + case 4: return L"Apr"; + case 5: return L"May"; + case 6: return L"Jun"; + case 7: return L"Jul"; + case 8: return L"Aug"; + case 9: return L"Sep"; + case 10: return L"Oct"; + case 11: return L"Nov"; + case 12: return L"Dec"; + } + return L""; +#endif + } + + WString Locale::GetLongMonthName(vint month)const + { +#if defined VCZH_MSVC + return FormatDate(L"MMMM", DateTime::FromDateTime(2000, month, 1)); +#elif defined VCZH_GCC + switch(month) + { + case 1: return L"January"; + case 2: return L"February"; + case 3: return L"March"; + case 4: return L"April"; + case 5: return L"May"; + case 6: return L"June"; + case 7: return L"July"; + case 8: return L"August"; + case 9: return L"September"; + case 10: return L"October"; + case 11: return L"November"; + case 12: return L"December"; + } + return L""; +#endif + } + +#ifdef VCZH_MSVC + WString Locale::ToFullWidth(const WString& str)const + { + return Transform(localeName, str, LCMAP_FULLWIDTH); + } + + WString Locale::ToHalfWidth(const WString& str)const + { + return Transform(localeName, str, LCMAP_HALFWIDTH); + } + + WString Locale::ToHiragana(const WString& str)const + { + return Transform(localeName, str, LCMAP_HIRAGANA); + } + + WString Locale::ToKatagana(const WString& str)const + { + return Transform(localeName, str, LCMAP_KATAKANA); + } +#endif + + WString Locale::ToLower(const WString& str)const + { +#if defined VCZH_MSVC + return Transform(localeName, str, LCMAP_LOWERCASE); +#elif defined VCZH_GCC + return wlower(str); +#endif + } + + WString Locale::ToUpper(const WString& str)const + { +#if defined VCZH_MSVC + return Transform(localeName, str, LCMAP_UPPERCASE); +#elif defined VCZH_GCC + return wupper(str); +#endif + } + + WString Locale::ToLinguisticLower(const WString& str)const + { +#if defined VCZH_MSVC + return Transform(localeName, str, LCMAP_LOWERCASE | LCMAP_LINGUISTIC_CASING); +#elif defined VCZH_GCC + return wlower(str); +#endif + } + + WString Locale::ToLinguisticUpper(const WString& str)const + { +#if defined VCZH_MSVC + return Transform(localeName, str, LCMAP_UPPERCASE | LCMAP_LINGUISTIC_CASING); +#elif defined VCZH_GCC + return wupper(str); +#endif + } + +#ifdef VCZH_MSVC + WString Locale::ToSimplifiedChinese(const WString& str)const + { + return Transform(localeName, str, LCMAP_SIMPLIFIED_CHINESE); + } + + WString Locale::ToTraditionalChinese(const WString& str)const + { + return Transform(localeName, str, LCMAP_TRADITIONAL_CHINESE); + } + + WString Locale::ToTileCase(const WString& str)const + { + return Transform(localeName, str, LCMAP_TITLECASE); + } +#endif + + vint Locale::Compare(const WString& s1, const WString& s2, Normalization normalization)const + { +#if defined VCZH_MSVC + switch(CompareStringEx(localeName.Buffer(), TranslateNormalization(normalization), s1.Buffer(), (int)s1.Length(), s2.Buffer(), (int)s2.Length(), NULL, NULL, NULL)) + { + case CSTR_LESS_THAN: return -1; + case CSTR_GREATER_THAN: return 1; + default: return 0; + } +#elif defined VCZH_GCC + switch(normalization) + { + case Normalization::None: + return wcscmp(s1.Buffer(), s2.Buffer()); + case Normalization::IgnoreCase: + return wcscasecmp(s1.Buffer(), s2.Buffer()); + } +#endif + } + + vint Locale::CompareOrdinal(const WString& s1, const WString& s2)const + { +#if defined VCZH_MSVC + switch(CompareStringOrdinal(s1.Buffer(), (int)s1.Length(), s2.Buffer(), (int)s2.Length(), FALSE)) + { + case CSTR_LESS_THAN: return -1; + case CSTR_GREATER_THAN: return 1; + default: return 0; + } +#elif defined VCZH_GCC + return wcscmp(s1.Buffer(), s2.Buffer()); +#endif + } + + vint Locale::CompareOrdinalIgnoreCase(const WString& s1, const WString& s2)const + { +#if defined VCZH_MSVC + switch(CompareStringOrdinal(s1.Buffer(), (int)s1.Length(), s2.Buffer(), (int)s2.Length(), TRUE)) + { + case CSTR_LESS_THAN: return -1; + case CSTR_GREATER_THAN: return 1; + default: return 0; + } +#elif defined VCZH_GCC + return wcscasecmp(s1.Buffer(), s2.Buffer()); +#endif + } + + collections::Pair Locale::FindFirst(const WString& text, const WString& find, Normalization normalization)const + { +#if defined VCZH_MSVC + int length=0; + int result=FindNLSStringEx(localeName.Buffer(), FIND_FROMSTART | TranslateNormalization(normalization), text.Buffer(), (int)text.Length(), find.Buffer(), (int)find.Length(), &length, NULL, NULL, NULL); + return result==-1?Pair(-1, 0):Pair(result, length); +#elif defined VCZH_GCC + if(text.Length() < find.Length() || find.Length() == 0) + { + return Pair(-1, 0); + } + const wchar_t* result = 0; + switch(normalization) + { + case Normalization::None: + { + const wchar_t* reading = text.Buffer(); + while(*reading) + { + if (wcsncmp(reading, find.Buffer(), find.Length())==0) + { + result = reading; + break; + } + reading++; + } + } + break; + case Normalization::IgnoreCase: + { + const wchar_t* reading = text.Buffer(); + while(*reading) + { + if (wcsncasecmp(reading, find.Buffer(), find.Length())==0) + { + result = reading; + break; + } + reading++; + } + } + break; + } + return result == nullptr ? Pair(-1, 0) : Pair(result - text.Buffer(), find.Length()); +#endif + } + + collections::Pair Locale::FindLast(const WString& text, const WString& find, Normalization normalization)const + { +#if defined VCZH_MSVC + int length=0; + int result=FindNLSStringEx(localeName.Buffer(), FIND_FROMEND | TranslateNormalization(normalization), text.Buffer(), (int)text.Length(), find.Buffer(), (int)find.Length(), &length, NULL, NULL, NULL); + return result==-1?Pair(-1, 0):Pair(result, length); +#elif defined VCZH_GCC + if(text.Length() < find.Length() || find.Length() == 0) + { + return Pair(-1, 0); + } + const wchar_t* result = 0; + switch(normalization) + { + case Normalization::None: + { + const wchar_t* reading = text.Buffer(); + while(*reading) + { + if (wcsncmp(reading, find.Buffer(), find.Length())==0) + { + result = reading; + } + reading++; + } + } + break; + case Normalization::IgnoreCase: + { + const wchar_t* reading = text.Buffer(); + while(*reading) + { + if (wcsncasecmp(reading, find.Buffer(), find.Length())==0) + { + result = reading; + } + reading++; + } + } + break; + } + return result == nullptr ? Pair(-1, 0) : Pair(result - text.Buffer(), find.Length()); +#endif + } + + bool Locale::StartsWith(const WString& text, const WString& find, Normalization normalization)const + { +#if defined VCZH_MSVC + int result=FindNLSStringEx(localeName.Buffer(), FIND_STARTSWITH | TranslateNormalization(normalization), text.Buffer(), (int)text.Length(), find.Buffer(), (int)find.Length(), NULL, NULL, NULL, NULL); + return result!=-1; +#elif defined VCZH_GCC + if(text.Length() < find.Length() || find.Length() == 0) + { + return false; + } + switch(normalization) + { + case Normalization::None: + return wcsncmp(text.Buffer(), find.Buffer(), find.Length()) == 0; + case Normalization::IgnoreCase: + return wcsncasecmp(text.Buffer(), find.Buffer(), find.Length()) == 0; + } +#endif + } + + bool Locale::EndsWith(const WString& text, const WString& find, Normalization normalization)const + { +#if defined VCZH_MSVC + int result=FindNLSStringEx(localeName.Buffer(), FIND_ENDSWITH | TranslateNormalization(normalization), text.Buffer(), (int)text.Length(), find.Buffer(), (int)find.Length(), NULL, NULL, NULL, NULL); + return result!=-1; +#elif defined VCZH_GCC + if(text.Length() < find.Length() || find.Length() == 0) + { + return false; + } + switch(normalization) + { + case Normalization::None: + return wcsncmp(text.Buffer() + text.Length() - find.Length(), find.Buffer(), find.Length()) == 0; + case Normalization::IgnoreCase: + return wcsncasecmp(text.Buffer() + text.Length() - find.Length(), find.Buffer(), find.Length()) == 0; + } +#endif + } +} + + +/*********************************************************************** +.\FILESYSTEM.CPP ***********************************************************************/ #if defined VCZH_MSVC #include @@ -1273,8 +2319,2245 @@ Folder } } + /*********************************************************************** -GLOBALSTORAGE.CPP +.\STREAM\ACCESSOR.CPP +***********************************************************************/ + +namespace vl +{ + namespace stream + { + using namespace collections; + +/*********************************************************************** +TextReader +***********************************************************************/ + + WString TextReader::ReadString(vint length) + { + wchar_t* buffer=new wchar_t[length+1]; + vint i=0; + for(;i0 && result[result.Length()-1]==L'\r') + { + return result.Left(result.Length()-1); + } + else + { + return result; + } + } + + WString TextReader::ReadToEnd() + { + WString result; + auto buffer = new wchar_t[65537]; + buffer[0]=L'\0'; + vint i=0; + while(true) + { + wchar_t c=ReadChar(); + if(c==L'\0') + { + buffer[i]=L'\0'; + result+=buffer; + buffer[0]=L'\0'; + i=0; + break; + } + else + { + if(i==65536) + { + buffer[i]=L'\0'; + result+=buffer; + buffer[0]=L'\0'; + i=0; + } + buffer[i++]=c; + } + } + result+=buffer; + delete[] buffer; + return result; + } + +/*********************************************************************** +TextWriter +***********************************************************************/ + + void TextWriter::WriteString(const wchar_t* string, vint charCount) + { + while(*string) + { + WriteChar(*string++); + } + } + + void TextWriter::WriteString(const wchar_t* string) + { + WriteString(string, (vint)wcslen(string)); + } + + void TextWriter::WriteString(const WString& string) + { + if(string.Length()) + { + WriteString(string.Buffer(), string.Length()); + } + } + + void TextWriter::WriteLine(const wchar_t* string, vint charCount) + { + WriteString(string, charCount); + WriteString(L"\r\n", 2); + } + + void TextWriter::WriteLine(const wchar_t* string) + { + WriteString(string); + WriteString(L"\r\n", 2); + } + + void TextWriter::WriteLine(const WString& string) + { + WriteString(string); + WriteString(L"\r\n", 2); + } + + namespace monospace_tabling + { + void WriteBorderLine(TextWriter& writer, Array& columnWidths, vint columns) + { + writer.WriteChar(L'+'); + for(vint i=0;i& columnWidths, vint rowHeight, vint columns, Array& tableByRow, vint startRow) + { + vint cellStart=startRow*columns; + for(vint r=0;r=length;i--) + { + writer.WriteChar(L' '); + } + writer.WriteChar(L'|'); + } + writer.WriteLine(L""); + } + } + } + using namespace monospace_tabling; + + void TextWriter::WriteMonospacedEnglishTable(collections::Array& tableByRow, vint rows, vint columns) + { + Array rowHeights(rows); + Array columnWidths(columns); + for(vint i=0;iremain) length=remain; + WString result=string.Sub(current, length); + current+=length; + return result; + } + } + + WString StringReader::ReadLine() + { + PrepareIfLastCallIsReadLine(); + if(IsEnd()) + { + return L""; + } + else + { + vint lineEnd=current; + while(lineEndRead(&buffer, sizeof(buffer))==0) + { + stream=0; + return 0; + } + else + { + return buffer; + } + } + else + { + return L'\0'; + } + } + +/*********************************************************************** +StreamWriter +***********************************************************************/ + + StreamWriter::StreamWriter(IStream& _stream) + :stream(&_stream) + { + } + + void StreamWriter::WriteChar(wchar_t c) + { + stream->Write(&c, sizeof(c)); + } + + void StreamWriter::WriteString(const wchar_t* string, vint charCount) + { + stream->Write((void*)string, charCount*sizeof(*string)); + } + +/*********************************************************************** +EncoderStream +***********************************************************************/ + + EncoderStream::EncoderStream(IStream& _stream, IEncoder& _encoder) + :stream(&_stream) + ,encoder(&_encoder) + ,position(0) + { + encoder->Setup(stream); + } + + EncoderStream::~EncoderStream() + { + Close(); + } + + bool EncoderStream::CanRead()const + { + return false; + } + + bool EncoderStream::CanWrite()const + { + return IsAvailable(); + } + + bool EncoderStream::CanSeek()const + { + return false; + } + + bool EncoderStream::CanPeek()const + { + return false; + } + + bool EncoderStream::IsLimited()const + { + return stream!=0 && stream->IsLimited(); + } + + bool EncoderStream::IsAvailable()const + { + return stream!=0 && stream->IsAvailable(); + } + + void EncoderStream::Close() + { + encoder->Close(); + stream=0; + } + + pos_t EncoderStream::Position()const + { + return IsAvailable()?position:-1; + } + + pos_t EncoderStream::Size()const + { + return -1; + } + + void EncoderStream::Seek(pos_t _size) + { + CHECK_FAIL(L"EncoderStream::Seek(pos_t)#Operation not supported."); + } + + void EncoderStream::SeekFromBegin(pos_t _size) + { + CHECK_FAIL(L"EncoderStream::SeekFromBegin(pos_t)#Operation not supported."); + } + + void EncoderStream::SeekFromEnd(pos_t _size) + { + CHECK_FAIL(L"EncoderStream::SeekFromEnd(pos_t)#Operation not supported."); + } + + vint EncoderStream::Read(void* _buffer, vint _size) + { + CHECK_FAIL(L"EncoderStream::Read(void*, vint)#Operation not supported."); + } + + vint EncoderStream::Write(void* _buffer, vint _size) + { + vint result=encoder->Write(_buffer, _size); + if(result>=0) + { + position+=result; + } + return result; + } + + vint EncoderStream::Peek(void* _buffer, vint _size) + { + CHECK_FAIL(L"EncoderStream::Peek(void*, vint)#Operation not supported."); + } + +/*********************************************************************** +DecoderStream +***********************************************************************/ + + DecoderStream::DecoderStream(IStream& _stream, IDecoder& _decoder) + :stream(&_stream) + ,decoder(&_decoder) + ,position(0) + { + decoder->Setup(stream); + } + + DecoderStream::~DecoderStream() + { + Close(); + } + + bool DecoderStream::CanRead()const + { + return IsAvailable(); + } + + bool DecoderStream::CanWrite()const + { + return false; + } + + bool DecoderStream::CanSeek()const + { + return false; + } + + bool DecoderStream::CanPeek()const + { + return false; + } + + bool DecoderStream::IsLimited()const + { + return stream!=0 && stream->IsLimited(); + } + + bool DecoderStream::IsAvailable()const + { + return stream!=0 && stream->IsAvailable(); + } + + void DecoderStream::Close() + { + decoder->Close(); + stream=0; + } + + pos_t DecoderStream::Position()const + { + return IsAvailable()?position:-1; + } + + pos_t DecoderStream::Size()const + { + return -1; + } + + void DecoderStream::Seek(pos_t _size) + { + CHECK_FAIL(L"DecoderStream::Seek(pos_t)#Operation not supported."); + } + + void DecoderStream::SeekFromBegin(pos_t _size) + { + CHECK_FAIL(L"DecoderStream::SeekFromBegin(pos_t)#Operation not supported."); + } + + void DecoderStream::SeekFromEnd(pos_t _size) + { + CHECK_FAIL(L"DecoderStream::SeekFromEnd(pos_t)#Operation not supported."); + } + + vint DecoderStream::Read(void* _buffer, vint _size) + { + vint result=decoder->Read(_buffer, _size); + if(result>=0) + { + position+=result; + } + return result; + } + + vint DecoderStream::Write(void* _buffer, vint _size) + { + CHECK_FAIL(L"DecoderStream::Write(void*, vint)#Operation not supported."); + } + + vint DecoderStream::Peek(void* _buffer, vint _size) + { + CHECK_FAIL(L"DecoderStream::Peek(void*, vint)#Operation not supported."); + } + } +} + + +/*********************************************************************** +.\STREAM\CHARFORMAT.CPP +***********************************************************************/ +#if defined VCZH_MSVC +#include +#elif defined VCZH_GCC +#endif + +namespace vl +{ + namespace stream + { + +/*********************************************************************** +CharEncoder +***********************************************************************/ + + CharEncoder::CharEncoder() + :stream(0) + ,cacheSize(0) + { + } + + void CharEncoder::Setup(IStream* _stream) + { + stream=_stream; + } + + void CharEncoder::Close() + { + } + + vint CharEncoder::Write(void* _buffer, vint _size) + { + const vint all=cacheSize+_size; + const vint chars=all/sizeof(wchar_t); + const vint bytes=chars*sizeof(wchar_t); + wchar_t* unicode=0; + bool needToFree=false; + vint result=0; + + if(chars) + { + if(cacheSize>0) + { + unicode=new wchar_t[chars]; + memcpy(unicode, cacheBuffer, cacheSize); + memcpy(((vuint8_t*)unicode)+cacheSize, _buffer, bytes-cacheSize); + needToFree=true; + } + else + { + unicode=(wchar_t*)_buffer; + } + result=WriteString(unicode, chars)*sizeof(wchar_t)-cacheSize; + cacheSize=0; + } + + if(needToFree) + { + delete[] unicode; + } + if(all-bytes>0) + { + cacheSize=all-bytes; + memcpy(cacheBuffer, (vuint8_t*)_buffer+_size-cacheSize, cacheSize); + result+=cacheSize; + } + return result; + } + +/*********************************************************************** +CharDecoder +***********************************************************************/ + + CharDecoder::CharDecoder() + :stream(0) + ,cacheSize(0) + { + } + + void CharDecoder::Setup(IStream* _stream) + { + stream=_stream; + } + + void CharDecoder::Close() + { + } + + vint CharDecoder::Read(void* _buffer, vint _size) + { + vuint8_t* unicode=(vuint8_t*)_buffer; + vint result=0; + { + vint index=0; + while(cacheSize>0 && _size>0) + { + *unicode++=cacheBuffer[index]++; + cacheSize--; + _size--; + result++; + } + } + + const vint chars=_size/sizeof(wchar_t); + vint bytes=ReadString((wchar_t*)unicode, chars)*sizeof(wchar_t); + result+=bytes; + _size-=bytes; + unicode+=bytes; + + if(_size>0) + { + wchar_t c; + if(ReadString(&c, 1)==1) + { + cacheSize=sizeof(wchar_t)-_size; + memcpy(unicode, &c, _size); + memcpy(cacheBuffer, (vuint8_t*)&c+_size, cacheSize); + result+=_size; + } + } + return result; + } + +/*********************************************************************** +Mbcs +***********************************************************************/ + + vint MbcsEncoder::WriteString(wchar_t* _buffer, vint chars) + { +#if defined VCZH_MSVC + vint length=WideCharToMultiByte(CP_THREAD_ACP, 0, _buffer, (int)chars, NULL, NULL, NULL, NULL); + char* mbcs=new char[length]; + WideCharToMultiByte(CP_THREAD_ACP, 0, _buffer, (int)chars, mbcs, (int)length, NULL, NULL); + vint result=stream->Write(mbcs, length); + delete[] mbcs; +#elif defined VCZH_GCC + WString w(_buffer, chars); + AString a=wtoa(w); + vint length=a.Length(); + vint result=stream->Write((void*)a.Buffer(), length); +#endif + if(result==length) + { + return chars; + } + else + { + Close(); + return 0; + } + } + + vint MbcsDecoder::ReadString(wchar_t* _buffer, vint chars) + { + char* source=new char[chars*2]; + char* reading=source; + vint readed=0; + while(readedRead(reading, 1)!=1) + { + break; + } +#if defined VCZH_MSVC + if(IsDBCSLeadByte(*reading)) +#elif defined VCZH_GCC + if((vint8_t)*reading<0) +#endif + { + if(stream->Read(reading+1, 1)!=1) + { + break; + } + reading+=2; + } + else + { + reading++; + } + readed++; + } +#if defined VCZH_MSVC + MultiByteToWideChar(CP_THREAD_ACP, 0, source, (int)(reading-source), _buffer, (int)chars); +#elif defined VCZH_GCC + AString a(source, (vint)(reading-source)); + WString w=atow(a); + memcpy(_buffer, w.Buffer(), readed*sizeof(wchar_t)); +#endif + delete[] source; + return readed; + } + +/*********************************************************************** +Utf-16 +***********************************************************************/ + + vint Utf16Encoder::WriteString(wchar_t* _buffer, vint chars) + { +#if defined VCZH_MSVC + return stream->Write(_buffer, chars*sizeof(wchar_t))/sizeof(wchar_t); +#elif defined VCZH_GCC + vint writed = 0; + vuint16_t utf16 = 0; + vuint8_t* utf16buf = (vuint8_t*)&utf16; + while (writed < chars) + { + wchar_t w = *_buffer++; + if (w < 0x10000) + { + utf16 = (vuint16_t)w; + if (stream->Write(&utf16buf[0], 1) != 1) break; + if (stream->Write(&utf16buf[1], 1) != 1) break; + } + else if (w < 0x110000) + { + wchar_t inc = w - 0x10000; + + utf16 = (vuint16_t)(inc / 0x400) + 0xD800; + if (stream->Write(&utf16buf[0], 1) != 1) break; + if (stream->Write(&utf16buf[1], 1) != 1) break; + + utf16 = (vuint16_t)(inc % 0x400) + 0xDC00; + if (stream->Write(&utf16buf[0], 1) != 1) break; + if (stream->Write(&utf16buf[1], 1) != 1) break; + } + else + { + break; + } + writed++; + } + if(writed!=chars) + { + Close(); + } + return writed; +#endif + } + + vint Utf16Decoder::ReadString(wchar_t* _buffer, vint chars) + { +#if defined VCZH_MSVC + return stream->Read(_buffer, chars*sizeof(wchar_t))/sizeof(wchar_t); +#elif defined VCZH_GCC + wchar_t* writing = _buffer; + while (writing - _buffer < chars) + { + vuint16_t utf16_1 = 0; + vuint16_t utf16_2 = 0; + + if (stream->Read(&utf16_1, 2) != 2) break; + if (utf16_1 < 0xD800 || utf16_1 > 0xDFFF) + { + *writing++ = (wchar_t)utf16_1; + } + else if (utf16_1 < 0xDC00) + { + if (stream->Read(&utf16_2, 2) != 2) break; + if (0xDC00 <= utf16_2 && utf16_2 <= 0xDFFF) + { + *writing++ = (wchar_t)(utf16_1 - 0xD800) * 0x400 + (wchar_t)(utf16_2 - 0xDC00) + 0x10000; + } + else + { + break; + } + } + else + { + break; + } + } + return writing - _buffer; +#endif + } + +/*********************************************************************** +Utf-16-be +***********************************************************************/ + + vint Utf16BEEncoder::WriteString(wchar_t* _buffer, vint chars) + { +#if defined VCZH_MSVC + vint writed=0; + while(writedWrite(((unsigned char*)_buffer)+1, 1)!=1) + { + break; + } + if(stream->Write(_buffer, 1)!=1) + { + break; + } + _buffer++; + writed++; + } + if(writed!=chars) + { + Close(); + } + return writed; +#elif defined VCZH_GCC + vint writed = 0; + vuint16_t utf16 = 0; + vuint8_t* utf16buf = (vuint8_t*)&utf16; + while (writed < chars) + { + wchar_t w = *_buffer++; + if (w < 0x10000) + { + utf16 = (vuint16_t)w; + if (stream->Write(&utf16buf[1], 1) != 1) break; + if (stream->Write(&utf16buf[0], 1) != 1) break; + } + else if (w < 0x110000) + { + wchar_t inc = w - 0x10000; + + utf16 = (vuint16_t)(inc / 0x400) + 0xD800; + if (stream->Write(&utf16buf[1], 1) != 1) break; + if (stream->Write(&utf16buf[0], 1) != 1) break; + + utf16 = (vuint16_t)(inc % 0x400) + 0xDC00; + if (stream->Write(&utf16buf[1], 1) != 1) break; + if (stream->Write(&utf16buf[0], 1) != 1) break; + } + else + { + break; + } + writed++; + } + if(writed!=chars) + { + Close(); + } + return writed; +#endif + } + + vint Utf16BEDecoder::ReadString(wchar_t* _buffer, vint chars) + { +#if defined VCZH_MSVC + chars=stream->Read(_buffer, chars*sizeof(wchar_t))/sizeof(wchar_t); + unsigned char* unicode=(unsigned char*)_buffer; + for(vint i=0;iRead(&utf16_1, 2) != 2) break; + + utf16buf = (vuint8_t*)&utf16_1; + utf16buf_temp = utf16buf[0]; + utf16buf[0] = utf16buf[1]; + utf16buf[1] = utf16buf_temp; + + if (utf16_1 < 0xD800 || utf16_1 > 0xDFFF) + { + *writing++ = (wchar_t)utf16_1; + } + else if (utf16_1 < 0xDC00) + { + if (stream->Read(&utf16_2, 2) != 2) break; + + utf16buf = (vuint8_t*)&utf16_2; + utf16buf_temp = utf16buf[0]; + utf16buf[0] = utf16buf[1]; + utf16buf[1] = utf16buf_temp; + + if (0xDC00 <= utf16_2 && utf16_2 <= 0xDFFF) + { + *writing++ = (wchar_t)(utf16_1 - 0xD800) * 0x400 + (wchar_t)(utf16_2 - 0xDC00) + 0x10000; + } + else + { + break; + } + } + else + { + break; + } + } + return writing - _buffer; +#endif + } + +/*********************************************************************** +Utf8 +***********************************************************************/ + + vint Utf8Encoder::WriteString(wchar_t* _buffer, vint chars) + { +#if defined VCZH_MSVC + vint length=WideCharToMultiByte(CP_UTF8, 0, _buffer, (int)chars, NULL, NULL, NULL, NULL); + char* mbcs=new char[length]; + WideCharToMultiByte(CP_UTF8, 0, _buffer, (int)chars, mbcs, (int)length, NULL, NULL); + vint result=stream->Write(mbcs, length); + delete[] mbcs; + if(result==length) + { + return chars; + } + else + { + Close(); + return 0; + } +#elif defined VCZH_GCC + vint writed = 0; + while (writed < chars) + { + wchar_t w = *_buffer++; + vuint8_t utf8[4]; + if (w < 0x80) + { + utf8[0] = (vuint8_t)w; + if (stream->Write(utf8, 1) != 1) break; + } + else if (w < 0x800) + { + utf8[0] = 0xC0 + ((w & 0x7C0) >> 6); + utf8[1] = 0x80 + (w & 0x3F); + if (stream->Write(utf8, 2) != 2) break; + } + else if (w < 0x10000) + { + utf8[0] = 0xE0 + ((w & 0xF000) >> 12); + utf8[1] = 0x80 + ((w & 0xFC0) >> 6); + utf8[2] = 0x80 + (w & 0x3F); + if (stream->Write(utf8, 3) != 3) break; + } + else if (w < 0x110000) // only accept UTF-16 range + { + utf8[0] = 0xF0 + ((w & 0x1C0000) >> 18); + utf8[1] = 0x80 + ((w & 0x3F000) >> 12); + utf8[2] = 0x80 + ((w & 0xFC0) >> 6); + utf8[3] = 0x80 + (w & 0x3F); + if (stream->Write(utf8, 4) != 4) break; + } + else + { + break; + } + writed++; + } + if(writed!=chars) + { + Close(); + } + return writed; +#endif + } + + Utf8Decoder::Utf8Decoder() +#if defined VCZH_MSVC + :cache(0) + ,cacheAvailable(false) +#endif + { + } + + vint Utf8Decoder::ReadString(wchar_t* _buffer, vint chars) + { + vuint8_t source[4]; +#if defined VCZH_MSVC + wchar_t target[2]; +#endif + wchar_t* writing=_buffer; + vint readed=0; + vint sourceCount=0; + + while(readedRead(source, 1)!=1) + { + break; + } + if((*source & 0xF0) == 0xF0) + { + if(stream->Read(source+1, 3)!=3) + { + break; + } + sourceCount=4; + } + else if((*source & 0xE0) == 0xE0) + { + if(stream->Read(source+1, 2)!=2) + { + break; + } + sourceCount=3; + } + else if((*source & 0xC0) == 0xC0) + { + if(stream->Read(source+1, 1)!=1) + { + break; + } + sourceCount=2; + } + else + { + sourceCount=1; + } +#if defined VCZH_MSVC + int targetCount=MultiByteToWideChar(CP_UTF8, 0, (char*)source, (int)sourceCount, target, 2); + if(targetCount==1) + { + *writing++=target[0]; + } + else if(targetCount==2) + { + *writing++=target[0]; + cache=target[1]; + cacheAvailable=true; + } + else + { + break; + } + } +#elif defined VCZH_GCC + if (sourceCount == 1) + { + *writing++ = (wchar_t)source[0]; + } + else if (sourceCount == 2) + { + *writing++ = (((wchar_t)source[0] & 0x1F) << 6) + ((wchar_t)source[1] & 0x3F); + } + else if (sourceCount == 3) + { + *writing++ = (((wchar_t)source[0] & 0xF) << 12) + (((wchar_t)source[1] & 0x3F) << 6) + ((wchar_t)source[2] & 0x3F); + } + else if (sourceCount == 4) + { + *writing++ = (((wchar_t)source[0] & 0x7) << 18) + (((wchar_t)source[1] & 0x3F) << 12) + (((wchar_t)source[2] & 0x3F) << 6) + ((wchar_t)source[3] & 0x3F); + } + else + { + break; + } +#endif + readed++; + } + return readed; + } + +/*********************************************************************** +BomEncoder +***********************************************************************/ + + BomEncoder::BomEncoder(Encoding _encoding) + :encoding(_encoding) + ,encoder(0) + { + switch(encoding) + { + case Mbcs: + encoder=new MbcsEncoder; + break; + case Utf8: + encoder=new Utf8Encoder; + break; + case Utf16: + encoder=new Utf16Encoder; + break; + case Utf16BE: + encoder=new Utf16BEEncoder; + break; + } + } + + BomEncoder::~BomEncoder() + { + Close(); + } + + void BomEncoder::Setup(IStream* _stream) + { + switch(encoding) + { + case Mbcs: + break; + case Utf8: + _stream->Write((void*)"\xEF\xBB\xBF", 3); + break; + case Utf16: + _stream->Write((void*)"\xFF\xFE", 2); + break; + case Utf16BE: + _stream->Write((void*)"\xFE\xFF", 2); + break; + } + encoder->Setup(_stream); + } + + void BomEncoder::Close() + { + if(encoder) + { + encoder->Close(); + delete encoder; + encoder=0; + } + } + + vint BomEncoder::Write(void* _buffer, vint _size) + { + return encoder->Write(_buffer, _size); + } + +/*********************************************************************** +BomDecoder +***********************************************************************/ + + BomDecoder::BomStream::BomStream(IStream* _stream, char* _bom, vint _bomLength) + :stream(_stream) + ,bomPosition(0) + ,bomLength(_bomLength) + { + memcpy(bom, _bom, bomLength); + } + + bool BomDecoder::BomStream::CanRead()const + { + return IsAvailable(); + } + + bool BomDecoder::BomStream::CanWrite()const + { + return false; + } + + bool BomDecoder::BomStream::CanSeek()const + { + return false; + } + + bool BomDecoder::BomStream::CanPeek()const + { + return false; + } + + bool BomDecoder::BomStream::IsLimited()const + { + return stream!=0 && stream->IsLimited(); + } + + bool BomDecoder::BomStream::IsAvailable()const + { + return stream!=0 && stream->IsAvailable(); + } + + void BomDecoder::BomStream::Close() + { + stream=0; + } + + pos_t BomDecoder::BomStream::Position()const + { + return IsAvailable()?bomPosition+stream->Position():-1; + } + + pos_t BomDecoder::BomStream::Size()const + { + return -1; + } + + void BomDecoder::BomStream::Seek(pos_t _size) + { + CHECK_FAIL(L"BomDecoder::BomStream::Seek(pos_t)#Operation not supported."); + } + + void BomDecoder::BomStream::SeekFromBegin(pos_t _size) + { + CHECK_FAIL(L"BomDecoder::BomStream::SeekFromBegin(pos_t)#Operation not supported."); + } + + void BomDecoder::BomStream::SeekFromEnd(pos_t _size) + { + CHECK_FAIL(L"BomDecoder::BomStream::SeekFromEnd(pos_t)#Operation not supported."); + } + + vint BomDecoder::BomStream::Read(void* _buffer, vint _size) + { + vint result=0; + unsigned char* buffer=(unsigned char*)_buffer; + if(bomPositionRead(buffer, _size); + } + return result; + } + + vint BomDecoder::BomStream::Write(void* _buffer, vint _size) + { + CHECK_FAIL(L"BomDecoder::BomStream::Write(void*, vint)#Operation not supported."); + } + + vint BomDecoder::BomStream::Peek(void* _buffer, vint _size) + { + CHECK_FAIL(L"BomDecoder::BomStream::Peek(void*, vint)#Operation not supported."); + } + + BomDecoder::BomDecoder() + :decoder(0) + { + } + + BomDecoder::~BomDecoder() + { + Close(); + } + + void BomDecoder::Setup(IStream* _stream) + { + char bom[3]={0}; + vint length=_stream->Read(bom, sizeof(bom)); + if(strncmp(bom, "\xEF\xBB\xBF", 3)==0) + { + decoder=new Utf8Decoder; + stream=new BomStream(_stream, bom+3, 0); + } + else if(strncmp(bom, "\xFF\xFE", 2)==0) + { + decoder=new Utf16Decoder; + stream=new BomStream(_stream, bom+2, 1); + } + else if(strncmp(bom, "\xFE\xFF", 2)==0) + { + decoder=new Utf16BEDecoder; + stream=new BomStream(_stream, bom+2, 1); + } + else + { + decoder=new MbcsDecoder; + stream=new BomStream(_stream, bom, 3); + } + decoder->Setup(stream); + } + + void BomDecoder::Close() + { + if(decoder) + { + decoder->Close(); + delete decoder; + decoder=0; + stream->Close(); + delete stream; + stream=0; + } + } + + vint BomDecoder::Read(void* _buffer, vint _size) + { + return decoder->Read(_buffer, _size); + } + +/*********************************************************************** +CharEncoder +***********************************************************************/ + + bool CanBeMbcs(unsigned char* buffer, vint size) + { + for(vint i=0;i + bool GetEncodingResult(int(&tests)[Count], bool(&results)[Count], int test) + { + for (vint i = 0; i < Count; i++) + { + if (tests[i] & test) + { + if (results[i]) return true; + } + } + return false; + } +#endif + + void TestEncoding(unsigned char* buffer, vint size, BomEncoder::Encoding& encoding, bool& containsBom) + { + if (size >= 3 && strncmp((char*)buffer, "\xEF\xBB\xBF", 3) == 0) + { + encoding = BomEncoder::Utf8; + containsBom = true; + } + else if (size >= 2 && strncmp((char*)buffer, "\xFF\xFE", 2) == 0) + { + encoding = BomEncoder::Utf16; + containsBom = true; + } + else if (size >= 2 && strncmp((char*)buffer, "\xFE\xFF", 2) == 0) + { + encoding = BomEncoder::Utf16BE; + containsBom = true; + } + else + { + encoding = BomEncoder::Mbcs; + containsBom = false; + + bool utf16HitSurrogatePairs = false; + bool utf16BEHitSurrogatePairs = false; + bool roughMbcs = CanBeMbcs(buffer, size); + bool roughUtf8 = CanBeUtf8(buffer, size); + bool roughUtf16 = CanBeUtf16(buffer, size, utf16HitSurrogatePairs); + bool roughUtf16BE = CanBeUtf16BE(buffer, size, utf16BEHitSurrogatePairs); + + vint roughCount = (roughMbcs ? 1 : 0) + (roughUtf8 ? 1 : 0) + (roughUtf16 ? 1 : 0) + (roughUtf16BE ? 1 : 0); + if (roughCount == 1) + { + if (roughUtf8) encoding = BomEncoder::Utf8; + else if (roughUtf16) encoding = BomEncoder::Utf16; + else if (roughUtf16BE) encoding = BomEncoder::Utf16BE; + } + else if (roughCount > 1) + { +#if defined VCZH_MSVC + int tests[] = + { + IS_TEXT_UNICODE_REVERSE_ASCII16, + IS_TEXT_UNICODE_REVERSE_STATISTICS, + IS_TEXT_UNICODE_REVERSE_CONTROLS, + + IS_TEXT_UNICODE_ASCII16, + IS_TEXT_UNICODE_STATISTICS, + IS_TEXT_UNICODE_CONTROLS, + + IS_TEXT_UNICODE_ILLEGAL_CHARS, + IS_TEXT_UNICODE_ODD_LENGTH, + IS_TEXT_UNICODE_NULL_BYTES, + }; + + const vint TestCount = sizeof(tests) / sizeof(*tests); + bool results[TestCount]; + for (vint i = 0; i < TestCount; i++) + { + int test = tests[i]; + results[i] = IsTextUnicode(buffer, (int)size, &test) != 0; + } + + if (size % 2 == 0 + && !GetEncodingResult(tests, results, IS_TEXT_UNICODE_REVERSE_ASCII16) + && !GetEncodingResult(tests, results, IS_TEXT_UNICODE_REVERSE_STATISTICS) + && !GetEncodingResult(tests, results, IS_TEXT_UNICODE_REVERSE_CONTROLS) + ) + { + for (vint i = 0; i < size; i += 2) + { + unsigned char c = buffer[i]; + buffer[i] = buffer[i + 1]; + buffer[i + 1] = c; + } + // 3 = (count of reverse group) = (count of unicode group) + for (vint i = 0; i < 3; i++) + { + int test = tests[i + 3]; + results[i] = IsTextUnicode(buffer, (int)size, &test) != 0; + } + for (vint i = 0; i < size; i += 2) + { + unsigned char c = buffer[i]; + buffer[i] = buffer[i + 1]; + buffer[i + 1] = c; + } + } + + if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_NOT_UNICODE_MASK)) + { + if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_NOT_ASCII_MASK)) + { + encoding = BomEncoder::Utf8; + } + else if (roughUtf8 || !roughMbcs) + { + encoding = BomEncoder::Utf8; + } + } + else if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_ASCII16)) + { + encoding = BomEncoder::Utf16; + } + else if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_REVERSE_ASCII16)) + { + encoding = BomEncoder::Utf16BE; + } + else if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_CONTROLS)) + { + encoding = BomEncoder::Utf16; + } + else if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_REVERSE_CONTROLS)) + { + encoding = BomEncoder::Utf16BE; + } + else + { + if (!roughUtf8) + { + if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_STATISTICS)) + { + encoding = BomEncoder::Utf16; + } + else if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_STATISTICS)) + { + encoding = BomEncoder::Utf16BE; + } + } + else if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_NOT_UNICODE_MASK)) + { + encoding = BomEncoder::Utf8; + } + else if (roughUtf8 || !roughMbcs) + { + encoding = BomEncoder::Utf8; + } + } +#elif defined VCZH_GCC + if (roughUtf16 && roughUtf16BE && !roughUtf8) + { + if (utf16BEHitSurrogatePairs && !utf16HitSurrogatePairs) + { + encoding = BomEncoder::Utf16BE; + } + else + { + encoding = BomEncoder::Utf16; + } + } + else + { + encoding = BomEncoder::Utf8; + } +#endif + } + } + } + } +} + + +/*********************************************************************** +.\STREAM\FILESTREAM.CPP +***********************************************************************/ +#if defined VCZH_GCC +#endif + +namespace vl +{ + namespace stream + { + +#if defined VCZH_GCC + void _fseeki64(FILE* file, pos_t offset, int origin) + { + fseek(file, (long)offset, origin); + } +#endif + +/*********************************************************************** +FileStream +***********************************************************************/ + + FileStream::FileStream(const WString& fileName, AccessRight _accessRight) + :accessRight(_accessRight) + { + const wchar_t* mode=L"rb"; + switch(accessRight) + { + case ReadOnly: + mode=L"rb"; + break; + case WriteOnly: + mode=L"wb"; + break; + case ReadWrite: + mode=L"w+b"; + break; + } + +#if defined VCZH_MSVC + if(_wfopen_s(&file, fileName.Buffer(), mode)!=0) + { + file=0; + } +#elif defined VCZH_GCC + AString fileNameA = wtoa(fileName); + AString modeA = wtoa(mode); + file = fopen(fileNameA.Buffer(), modeA.Buffer()); +#endif + } + + FileStream::~FileStream() + { + Close(); + } + + bool FileStream::CanRead()const + { + return file!=0 && (accessRight==ReadOnly || accessRight==ReadWrite); + } + + bool FileStream::CanWrite()const + { + return file!=0 && (accessRight==WriteOnly || accessRight==ReadWrite); + } + + bool FileStream::CanSeek()const + { + return file!=0; + } + + bool FileStream::CanPeek()const + { + return file!=0 && (accessRight==ReadOnly || accessRight==ReadWrite); + } + + bool FileStream::IsLimited()const + { + return file!=0 && accessRight==ReadOnly; + } + + bool FileStream::IsAvailable()const + { + return file!=0; + } + + void FileStream::Close() + { + if(file!=0) + { + fclose(file); + file=0; + } + } + + pos_t FileStream::Position()const + { + if(file!=0) + { +#if defined VCZH_MSVC + fpos_t position=0; + if(fgetpos(file, &position)==0) + { + return position; + } +#elif defined VCZH_GCC + return (pos_t)ftell(file); +#endif + } + return -1; + } + + pos_t FileStream::Size()const + { + if(file!=0) + { +#if defined VCZH_MSVC + fpos_t position=0; + if(fgetpos(file, &position)==0) + { + if(fseek(file, 0, SEEK_END)==0) + { + pos_t size=Position(); + if(fsetpos(file, &position)==0) + { + return size; + } + } + } +#elif defined VCZH_GCC + long position = ftell(file); + fseek(file, 0, SEEK_END); + long size=ftell(file); + fseek(file, position, SEEK_SET); + return (pos_t)size; +#endif + } + return -1; + } + + void FileStream::Seek(pos_t _size) + { + if(Position()+_size>Size()) + { + _fseeki64(file, 0, SEEK_END); + } + else if(Position()+_size<0) + { + _fseeki64(file, 0, SEEK_SET); + } + else + { + _fseeki64(file, _size, SEEK_CUR); + } + } + + void FileStream::SeekFromBegin(pos_t _size) + { + if(_size>Size()) + { + _fseeki64(file, 0, SEEK_END); + } + else if(_size<0) + { + _fseeki64(file, 0, SEEK_SET); + } + else + { + _fseeki64(file, _size, SEEK_SET); + } + } + + void FileStream::SeekFromEnd(pos_t _size) + { + if(_size<0) + { + _fseeki64(file, 0, SEEK_END); + } + else if(_size>Size()) + { + _fseeki64(file, 0, SEEK_SET); + } + else + { + _fseeki64(file, -_size, SEEK_END); + } + } + + vint FileStream::Read(void* _buffer, vint _size) + { + CHECK_ERROR(file!=0, L"FileStream::Read(pos_t)#Stream is closed, cannot perform this operation."); + CHECK_ERROR(_size>=0, L"FileStream::Read(void*, vint)#Argument size cannot be negative."); + return fread(_buffer, 1, _size, file); + } + + vint FileStream::Write(void* _buffer, vint _size) + { + CHECK_ERROR(file!=0, L"FileStream::Write(pos_t)#Stream is closed, cannot perform this operation."); + CHECK_ERROR(_size>=0, L"FileStream::Write(void*, vint)#Argument size cannot be negative."); + return fwrite(_buffer, 1, _size, file); + } + + vint FileStream::Peek(void* _buffer, vint _size) + { + CHECK_ERROR(file!=0, L"FileStream::Peek(pos_t)#Stream is closed, cannot perform this operation."); + CHECK_ERROR(_size>=0, L"FileStream::Peek(void*, vint)#Argument size cannot be negative."); +#if defined VCZH_MSVC + fpos_t position=0; + if(fgetpos(file, &position)==0) + { + size_t count=fread(_buffer, 1, _size, file); + if(fsetpos(file, &position)==0) + { + return count; + } + } + return -1; +#elif defined VCZH_GCC + long position=ftell(file); + size_t count=fread(_buffer, 1, _size, file); + fseek(file, position, SEEK_SET); + return count; +#endif + } + } +} + + +/*********************************************************************** +.\STREAM\MEMORYSTREAM.CPP +***********************************************************************/ + +namespace vl +{ + namespace stream + { +/*********************************************************************** +MemoryStream +***********************************************************************/ + + void MemoryStream::PrepareSpace(vint totalSpace) + { + if(totalSpace>capacity) + { + totalSpace=(totalSpace/block+1)*block; + char* newBuffer=new char[totalSpace]; + if(buffer) + { + memcpy(newBuffer, buffer, size); + delete[] buffer; + } + buffer=newBuffer; + capacity=totalSpace; + } + } + + MemoryStream::MemoryStream(vint _block) + :block(_block) + ,buffer(0) + ,size(0) + ,position(0) + ,capacity(0) + { + if(block<=0) + { + block=65536; + } + } + + MemoryStream::~MemoryStream() + { + Close(); + } + + bool MemoryStream::CanRead()const + { + return block!=0; + } + + bool MemoryStream::CanWrite()const + { + return block!=0; + } + + bool MemoryStream::CanSeek()const + { + return block!=0; + } + + bool MemoryStream::CanPeek()const + { + return block!=0; + } + + bool MemoryStream::IsLimited()const + { + return false; + } + + bool MemoryStream::IsAvailable()const + { + return block!=0; + } + + void MemoryStream::Close() + { + if(buffer) + { + delete[] buffer; + } + block=0; + buffer=0; + size=-1; + position=-1; + capacity=0; + } + + pos_t MemoryStream::Position()const + { + return position; + } + + pos_t MemoryStream::Size()const + { + return size; + } + + void MemoryStream::Seek(pos_t _size) + { + SeekFromBegin(position+_size); + } + + void MemoryStream::SeekFromBegin(pos_t _size) + { + CHECK_ERROR(block!=0, L"MemoryStream::SeekFromBegin(pos_t)#Stream is closed, cannot perform this operation."); + vint expected=(vint)_size; + if(expected<0) + { + position=0; + } + else if(expected>=size) + { + position=size; + } + else + { + position=expected; + } + } + + void MemoryStream::SeekFromEnd(pos_t _size) + { + SeekFromBegin(size-_size); + } + + vint MemoryStream::Read(void* _buffer, vint _size) + { + CHECK_ERROR(block!=0, L"MemoryStream::Read(pos_t)#Stream is closed, cannot perform this operation."); + CHECK_ERROR(_size>=0, L"MemoryStream::Read(void*, vint)#Argument size cannot be negative."); + vint max=size-position; + if(_size>max) + { + _size=max; + } + memmove(_buffer, buffer+position, _size); + position+=_size; + return _size; + } + + vint MemoryStream::Write(void* _buffer, vint _size) + { + CHECK_ERROR(block!=0, L"MemoryStream::Write(pos_t)#Stream is closed, cannot perform this operation."); + CHECK_ERROR(_size>=0, L"MemoryStream::Write(void*, vint)#Argument size cannot be negative."); + PrepareSpace(size+_size); + memmove(buffer+position, _buffer, _size); + position+=_size; + if(size=0, L"MemoryStream::Peek(void*, vint)#Argument size cannot be negative."); + vint max=size-position; + if(_size>max) + { + _size=max; + } + memmove(_buffer, buffer+position, _size); + return _size; + } + + void* MemoryStream::GetInternalBuffer() + { + return buffer; + } + } +} + +/*********************************************************************** +.\STREAM\MEMORYWRAPPERSTREAM.CPP +***********************************************************************/ + +namespace vl +{ + namespace stream + { +/*********************************************************************** +MemoryWrapperStream +***********************************************************************/ + + MemoryWrapperStream::MemoryWrapperStream(void* _buffer, vint _size) + :buffer((char*)_buffer) + ,size(_size) + ,position(0) + { + if(size<=0) + { + buffer=0; + size=0; + } + } + + MemoryWrapperStream::~MemoryWrapperStream() + { + } + + bool MemoryWrapperStream::CanRead()const + { + return buffer!=0; + } + + bool MemoryWrapperStream::CanWrite()const + { + return buffer!=0; + } + + bool MemoryWrapperStream::CanSeek()const + { + return buffer!=0; + } + + bool MemoryWrapperStream::CanPeek()const + { + return buffer!=0; + } + + bool MemoryWrapperStream::IsLimited()const + { + return buffer!=0; + } + + bool MemoryWrapperStream::IsAvailable()const + { + return buffer!=0; + } + + void MemoryWrapperStream::Close() + { + buffer=0; + size=-1; + position=-1; + } + + pos_t MemoryWrapperStream::Position()const + { + return position; + } + + pos_t MemoryWrapperStream::Size()const + { + return size; + } + + void MemoryWrapperStream::Seek(pos_t _size) + { + SeekFromBegin(position+_size); + } + + void MemoryWrapperStream::SeekFromBegin(pos_t _size) + { + CHECK_ERROR(buffer!=0, L"MemoryWrapperStream::SeekFromBegin(pos_t)#Stream is closed, cannot perform this operation."); + vint expected=(vint)_size; + if(expected<0) + { + position=0; + } + else if(expected>=size) + { + position=size; + } + else + { + position=expected; + } + } + + void MemoryWrapperStream::SeekFromEnd(pos_t _size) + { + SeekFromBegin(size-_size); + } + + vint MemoryWrapperStream::Read(void* _buffer, vint _size) + { + CHECK_ERROR(buffer!=0, L"MemoryWrapperStream::Read(pos_t)#Stream is closed, cannot perform this operation."); + CHECK_ERROR(_size>=0, L"MemoryWrapperStream::Read(void*, vint)#Argument size cannot be negative."); + vint max=size-position; + if(_size>max) + { + _size=max; + } + memmove(_buffer, buffer+position, _size); + position+=_size; + return _size; + } + + vint MemoryWrapperStream::Write(void* _buffer, vint _size) + { + CHECK_ERROR(buffer!=0, L"MemoryWrapperStream::Write(pos_t)#Stream is closed, cannot perform this operation."); + CHECK_ERROR(_size>=0, L"MemoryWrapperStream::Write(void*, vint)#Argument size cannot be negative."); + vint max=size-position; + if(_size>max) + { + _size=max; + } + memmove(buffer+position, _buffer, _size); + position+=_size; + return _size; + } + + vint MemoryWrapperStream::Peek(void* _buffer, vint _size) + { + CHECK_ERROR(buffer!=0, L"MemoryWrapperStream::Peek(pos_t)#Stream is closed, cannot perform this operation."); + CHECK_ERROR(_size>=0, L"MemoryWrapperStream::Peek(void*, vint)#Argument size cannot be negative."); + vint max=size-position; + if(_size>max) + { + _size=max; + } + memmove(_buffer, buffer+position, _size); + return _size; + } + } +} + +/*********************************************************************** +.\GLOBALSTORAGE.CPP ***********************************************************************/ namespace vl @@ -1352,8 +4635,9 @@ GlobalStorage } } + /*********************************************************************** -HTTPUTILITY.CPP +.\HTTPUTILITY.CPP ***********************************************************************/ #ifdef VCZH_MSVC @@ -1695,2957 +4979,8549 @@ Utilities } #endif + /*********************************************************************** -LOCALE.CPP +.\STREAM\COMPRESSIONSTREAM.CPP +***********************************************************************/ + +namespace vl +{ + namespace stream + { + using namespace lzw; + +/*********************************************************************** +LzwBase +***********************************************************************/ + + void LzwBase::UpdateIndexBits() + { + if (nextIndex >=2 && (nextIndex & (nextIndex - 1)) == 0) + { + indexBits++; + } + } + + lzw::Code* LzwBase::CreateCode(lzw::Code* prefix, vuint8_t byte) + { + if (nextIndex < MaxDictionarySize) + { + Code* code = codeAllocator.Create(); + code->byte = byte; + code->code = nextIndex; + code->parent = prefix; + code->size = prefix->size + 1; + prefix->children.Set(byte, code, mapAllocator); + nextIndex++; + + return code; + } + else + { + return 0; + } + } + + LzwBase::LzwBase() + :codeAllocator(65536) + , mapAllocator(1048576) + { + root = codeAllocator.Create(); + + for (vint i = 0; i < 256; i++) + { + UpdateIndexBits(); + CreateCode(root, (vuint8_t)i); + } + } + + LzwBase::LzwBase(bool (&existingBytes)[256]) + { + root = codeAllocator.Create(); + for (vint i = 0; i < 256; i++) + { + if (existingBytes[i]) + { + UpdateIndexBits(); + CreateCode(root, (vuint8_t)i); + } + } + + if (indexBits < 8) + { + eofIndex = nextIndex++; + } + } + + LzwBase::~LzwBase() + { + } + +/*********************************************************************** +LzwEncoder +***********************************************************************/ + + void LzwEncoder::Flush() + { + vint written = 0; + vint bufferUsedSize = bufferUsedBits / 8; + if (bufferUsedBits % 8 != 0) + { + bufferUsedSize++; + } + while (written < bufferUsedSize) + { + vint size = stream->Write(buffer + written, bufferUsedSize - written); + CHECK_ERROR(size != 0, L"LzwEncoder::Flush()#Failed to flush the lzw buffer."); + written += size; + } + bufferUsedBits = 0; + } + + vuint8_t highMarks[9] = { 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF }; + vuint8_t lowMarks[9] = { 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF }; + + void LzwEncoder::WriteNumber(vint number, vint bitSize) + { + vint bitStart = 0; + vint bitStep = 8 - bufferUsedBits % 8; + if (bitStep > bitSize) + { + bitStep = bitSize; + } + while (bitStart < bitSize) + { + if(bufferUsedBits == BufferSize * 8) + { + Flush(); + } + + vint writeStart = bufferUsedBits % 8; + vint byteIndex = bufferUsedBits / 8; + vuint8_t byte = buffer[byteIndex]; + byte &= highMarks[writeStart]; + + vuint8_t content = (vuint8_t)((number >> bitStart)&lowMarks[bitStep]) << (8 - writeStart - bitStep); + byte |= content; + + buffer[byteIndex] = byte; + bufferUsedBits += bitStep; + + bitStart += bitStep; + vint remain = bitSize - bitStart; + bitStep = remain < 8 ? remain : 8; + } + } + + LzwEncoder::LzwEncoder() + { + prefix = root; + } + + LzwEncoder::LzwEncoder(bool (&existingBytes)[256]) + :LzwBase(existingBytes) + { + prefix = root; + } + + LzwEncoder::~LzwEncoder() + { + } + + void LzwEncoder::Setup(IStream* _stream) + { + stream = _stream; + } + + void LzwEncoder::Close() + { + if (prefix != root) + { + WriteNumber(prefix->code, indexBits); + prefix = root; + } + + vint remain = 8 - bufferUsedBits % 8; + if (remain != 8 && remain >= indexBits) + { + CHECK_ERROR(eofIndex != -1, L"LzwEncoder::Close()#Internal error."); + WriteNumber(eofIndex, indexBits); + } + Flush(); + } + + vint LzwEncoder::Write(void* _buffer, vint _size) + { + vuint8_t* bytes = (vuint8_t*)_buffer; + for (vint i = 0; i < _size; i++) + { + vuint8_t byte = bytes[i]; + Code* next = prefix->children.Get(byte); + if (next) + { + prefix = next; + } + else + { + WriteNumber(prefix->code, indexBits); + + if (nextIndex < MaxDictionarySize) + { + UpdateIndexBits(); + CreateCode(prefix, byte); + } + prefix = root->children.Get(byte); + } + } + return _size; + } + +/*********************************************************************** +LzwDecoder +***********************************************************************/ + + bool LzwDecoder::ReadNumber(vint& number, vint bitSize) + { + number = 0; + if (inputBufferSize == -1) + { + return false; + } + + vint remainBits = inputBufferSize * 8 - inputBufferUsedBits; + vint writtenBits = 0; + vint bitStep = 8 - inputBufferUsedBits % 8; + if (bitStep > bitSize) + { + bitStep = bitSize; + } + while (writtenBits < bitSize) + { + if (remainBits == 0) + { + inputBufferSize = stream->Read(inputBuffer, BufferSize); + if (inputBufferSize == 0) + { + inputBufferSize = -1; + return false; + } + remainBits = inputBufferSize * 8; + inputBufferUsedBits = 0; + } + + vuint8_t byte = inputBuffer[inputBufferUsedBits / 8]; + byte >>= (8 - inputBufferUsedBits % 8 - bitStep); + byte &= lowMarks[bitStep]; + number |= byte << writtenBits; + + inputBufferUsedBits += bitStep; + remainBits -= bitStep; + writtenBits += bitStep; + vint remain = bitSize - writtenBits; + bitStep = remain < 8 ? remain : 8; + } + + return true; + } + + void LzwDecoder::PrepareOutputBuffer(vint size) + { + if (outputBuffer.Count() < size) + { + outputBuffer.Resize(size); + } + outputBufferSize = size; + } + + void LzwDecoder::ExpandCodeToOutputBuffer(lzw::Code* code) + { + vuint8_t* outputByte = &outputBuffer[0] + code->size; + Code* current = code; + while (current != root) + { + *(--outputByte) = current->byte; + current = current->parent; + } + outputBufferUsedBytes = 0; + } + + LzwDecoder::LzwDecoder() + { + for (vint i = 0; i < 256; i++) + { + dictionary.Add(root->children.Get((vuint8_t)i)); + } + } + + LzwDecoder::LzwDecoder(bool (&existingBytes)[256]) + :LzwBase(existingBytes) + { + for (vint i = 0; i < 256; i++) + { + if (existingBytes[i]) + { + dictionary.Add(root->children.Get((vuint8_t)i)); + } + } + if (eofIndex != -1) + { + dictionary.Add(0); + } + } + + LzwDecoder::~LzwDecoder() + { + } + + void LzwDecoder::Setup(IStream* _stream) + { + stream = _stream; + } + + void LzwDecoder::Close() + { + } + + vint LzwDecoder::Read(void* _buffer, vint _size) + { + vint written = 0; + vuint8_t* bytes = (vuint8_t*)_buffer; + while (written < _size) + { + vint expect = _size - written; + vint remain = outputBufferSize - outputBufferUsedBytes; + if (remain == 0) + { + vint index = 0; + if (!ReadNumber(index, indexBits) || index == eofIndex) + { + break; + } + + Code* prefix = 0; + if (index == dictionary.Count()) + { + prefix = lastCode; + PrepareOutputBuffer(prefix->size + 1); + ExpandCodeToOutputBuffer(prefix); + outputBuffer[outputBufferSize - 1] = outputBuffer[0]; + } + else + { + prefix = dictionary[index]; + PrepareOutputBuffer(prefix->size); + ExpandCodeToOutputBuffer(prefix); + } + + if (nextIndex < MaxDictionarySize) + { + if (lastCode) + { + dictionary.Add(CreateCode(lastCode, outputBuffer[0])); + } + UpdateIndexBits(); + } + lastCode = dictionary[index]; + } + else + { + if (remain > expect) + { + remain = expect; + } + memcpy(bytes + written, &outputBuffer[outputBufferUsedBytes], remain); + + outputBufferUsedBytes += remain; + written += remain; + } + } + return written; + } + } +} + +/*********************************************************************** +.\PARSING\PARSINGDEFINITIONS.CPP ***********************************************************************/ -#if defined VCZH_MSVC -#elif defined VCZH_GCC -#include -#include -#endif namespace vl { using namespace collections; -#if defined VCZH_MSVC - - extern SYSTEMTIME DateTimeToSystemTime(const DateTime& dateTime); - - BOOL CALLBACK Locale_EnumLocalesProcEx( - _In_ LPWSTR lpLocaleString, - _In_ DWORD dwFlags, - _In_ LPARAM lParam - ) + namespace parsing { - ((List*)lParam)->Add(Locale(lpLocaleString)); - return TRUE; - } - - BOOL CALLBACK Locale_EnumDateFormatsProcExEx( - _In_ LPWSTR lpDateFormatString, - _In_ CALID CalendarID, - _In_ LPARAM lParam - ) - { - ((List*)lParam)->Add(lpDateFormatString); - return TRUE; - } - - BOOL CALLBACK EnumTimeFormatsProcEx( - _In_ LPWSTR lpTimeFormatString, - _In_ LPARAM lParam - ) - { - ((List*)lParam)->Add(lpTimeFormatString); - return TRUE; - } - - WString Transform(const WString& localeName, const WString& input, DWORD flag) - { - int length=LCMapStringEx(localeName.Buffer(), flag, input.Buffer(), (int)input.Length()+1, NULL, 0, NULL, NULL, NULL); - Array buffer(length); - LCMapStringEx(localeName.Buffer(), flag, input.Buffer(), (int)input.Length()+1, &buffer[0], (int)buffer.Count(), NULL, NULL, NULL); - return &buffer[0]; - } - - DWORD TranslateNormalization(Locale::Normalization normalization) - { - DWORD result=0; - if(normalization&Locale::IgnoreCase) result|=NORM_IGNORECASE; - if(normalization&Locale::IgnoreCaseLinguistic) result|=NORM_IGNORECASE | NORM_LINGUISTIC_CASING; - if(normalization&Locale::IgnoreKanaType) result|=NORM_IGNOREKANATYPE; - if(normalization&Locale::IgnoreNonSpace) result|=NORM_IGNORENONSPACE; - if(normalization&Locale::IgnoreSymbol) result|=NORM_IGNORESYMBOLS; - if(normalization&Locale::IgnoreWidth) result|=NORM_IGNOREWIDTH; - if(normalization&Locale::DigitsAsNumbers) result|=SORT_DIGITSASNUMBERS; - if(normalization&Locale::StringSoft) result|=SORT_STRINGSORT; - return result; - } - -#endif + namespace definitions + { /*********************************************************************** -Locale +ParsingDefinitionType(Visitor) ***********************************************************************/ - Locale::Locale(const WString& _localeName) - :localeName(_localeName) - { - } - - Locale::~Locale() - { - } - - Locale Locale::Invariant() - { -#if defined VCZH_MSVC - return Locale(LOCALE_NAME_INVARIANT); -#elif defined VCZH_GCC - return Locale(L""); -#endif - } - - Locale Locale::SystemDefault() - { -#if defined VCZH_MSVC - wchar_t buffer[LOCALE_NAME_MAX_LENGTH+1]={0}; - GetSystemDefaultLocaleName(buffer, LOCALE_NAME_MAX_LENGTH); - return Locale(buffer); -#elif defined VCZH_GCC - return Locale(L"en-US"); -#endif - } - - Locale Locale::UserDefault() - { -#if defined VCZH_MSVC - wchar_t buffer[LOCALE_NAME_MAX_LENGTH+1]={0}; - GetUserDefaultLocaleName(buffer, LOCALE_NAME_MAX_LENGTH); - return Locale(buffer); -#elif defined VCZH_GCC - return Locale(L"en-US"); -#endif - } - - void Locale::Enumerate(collections::List& locales) - { -#if defined VCZH_MSVC - EnumSystemLocalesEx(&Locale_EnumLocalesProcEx, LOCALE_ALL, (LPARAM)&locales, NULL); -#elif defined VCZH_GCC - locales.Add(Locale(L"en-US")); -#endif - } - - const WString& Locale::GetName()const - { - return localeName; - } - - void Locale::GetShortDateFormats(collections::List& formats)const - { -#if defined VCZH_MSVC - EnumDateFormatsExEx(&Locale_EnumDateFormatsProcExEx, localeName.Buffer(), DATE_SHORTDATE, (LPARAM)&formats); -#elif defined VCZH_GCC - formats.Add(L"MM/dd/yyyy"); - formats.Add(L"yyyy-MM-dd"); -#endif - } - - void Locale::GetLongDateFormats(collections::List& formats)const - { -#if defined VCZH_MSVC - EnumDateFormatsExEx(&Locale_EnumDateFormatsProcExEx, localeName.Buffer(), DATE_LONGDATE, (LPARAM)&formats); -#elif defined VCZH_GCC - formats.Add(L"dddd, dd MMMM yyyy"); -#endif - } - - void Locale::GetYearMonthDateFormats(collections::List& formats)const - { -#if defined VCZH_MSVC - EnumDateFormatsExEx(&Locale_EnumDateFormatsProcExEx, localeName.Buffer(), DATE_YEARMONTH, (LPARAM)&formats); -#elif defined VCZH_GCC - formats.Add(L"yyyy MMMM"); -#endif - } - - void Locale::GetLongTimeFormats(collections::List& formats)const - { -#if defined VCZH_MSVC - EnumTimeFormatsEx(&EnumTimeFormatsProcEx, localeName.Buffer(), 0, (LPARAM)&formats); -#elif defined VCZH_GCC - formats.Add(L"HH:mm:ss"); -#endif - } - - void Locale::GetShortTimeFormats(collections::List& formats)const - { -#if defined VCZH_MSVC - EnumTimeFormatsEx(&EnumTimeFormatsProcEx, localeName.Buffer(), TIME_NOSECONDS, (LPARAM)&formats); -#elif defined VCZH_GCC - formats.Add(L"HH:mm"); - formats.Add(L"hh:mm tt"); -#endif - } - - WString Locale::FormatDate(const WString& format, DateTime date)const - { -#if defined VCZH_MSVC - SYSTEMTIME st=DateTimeToSystemTime(date); - int length=GetDateFormatEx(localeName.Buffer(), 0, &st, format.Buffer(), NULL, 0, NULL); - if(length==0) return L""; - Array buffer(length); - GetDateFormatEx(localeName.Buffer(), 0, &st, format.Buffer(), &buffer[0], (int)buffer.Count(), NULL); - return &buffer[0]; -#elif defined VCZH_GCC - /* - auto df = L"yyyy,MM,MMM,MMMM,dd,ddd,dddd"; - auto ds = L"2000,01,Jan,January,02,Sun,Sunday"; - auto tf = L"hh,HH,mm,ss,tt"; - auto ts = L"01,13,02,03,PM"; - */ - WString result; - const wchar_t* reading = format.Buffer(); - - while (*reading) - { - if (wcsncmp(reading, L"yyyy", 4) == 0) + void ParsingDefinitionPrimitiveType::Accept(IVisitor* visitor) { - WString fragment = itow(date.year); - while (fragment.Length() < 4) fragment = L"0" + fragment; - result += fragment; - reading += 4; + visitor->Visit(this); } - else if (wcsncmp(reading, L"MMMM", 4) == 0) + + void ParsingDefinitionTokenType::Accept(IVisitor* visitor) { - result += GetLongMonthName(date.month); - reading += 4; + visitor->Visit(this); } - else if (wcsncmp(reading, L"MMM", 3) == 0) + + void ParsingDefinitionSubType::Accept(IVisitor* visitor) { - result += GetShortMonthName(date.month); - reading += 3; + visitor->Visit(this); } - else if (wcsncmp(reading, L"MM", 2) == 0) + + void ParsingDefinitionArrayType::Accept(IVisitor* visitor) { - WString fragment = itow(date.month); - while (fragment.Length() < 2) fragment = L"0" + fragment; - result += fragment; - reading += 2; + visitor->Visit(this); } - else if (wcsncmp(reading, L"dddd", 4) == 0) + +/*********************************************************************** +ParsingDefinitionTypeDefinition(Visitor) +***********************************************************************/ + + void ParsingDefinitionClassMemberDefinition::Accept(IVisitor* visitor) { - result += GetLongDayOfWeekName(date.dayOfWeek); - reading += 4; + visitor->Visit(this); } - else if (wcsncmp(reading, L"ddd", 3) == 0) + + void ParsingDefinitionClassDefinition::Accept(IVisitor* visitor) { - result += GetShortDayOfWeekName(date.dayOfWeek); - reading += 3; + visitor->Visit(this); } - else if (wcsncmp(reading, L"dd", 2) == 0) + + void ParsingDefinitionEnumMemberDefinition::Accept(IVisitor* visitor) { - WString fragment = itow(date.day); - while (fragment.Length() < 2) fragment = L"0" + fragment; - result += fragment; - reading += 2; + visitor->Visit(this); } - else if (wcsncmp(reading, L"hh", 2) == 0) + + void ParsingDefinitionEnumDefinition::Accept(IVisitor* visitor) { - WString fragment = itow(date.hour > 12 ? date.hour - 12 : date.hour); - while (fragment.Length() < 2) fragment = L"0" + fragment; - result += fragment; - reading += 2; + visitor->Visit(this); } - else if (wcsncmp(reading, L"HH", 2) == 0) + +/*********************************************************************** +ParsingDefinitionGrammar(Visitor) +***********************************************************************/ + + void ParsingDefinitionPrimitiveGrammar::Accept(IVisitor* visitor) { - WString fragment = itow(date.hour); - while (fragment.Length() < 2) fragment = L"0" + fragment; - result += fragment; - reading += 2; + visitor->Visit(this); } - else if (wcsncmp(reading, L"mm", 2) == 0) + + void ParsingDefinitionTextGrammar::Accept(IVisitor* visitor) { - WString fragment = itow(date.minute); - while (fragment.Length() < 2) fragment = L"0" + fragment; - result += fragment; - reading += 2; + visitor->Visit(this); } - else if (wcsncmp(reading, L"ss", 2) == 0) + + void ParsingDefinitionSequenceGrammar::Accept(IVisitor* visitor) { - WString fragment = itow(date.second); - while (fragment.Length() < 2) fragment = L"0" + fragment; - result += fragment; - reading += 2; + visitor->Visit(this); } - else if (wcsncmp(reading, L"tt", 2) == 0) + + void ParsingDefinitionAlternativeGrammar::Accept(IVisitor* visitor) { - result += date.hour > 12 ? L"PM" : L"AM"; - reading += 2; + visitor->Visit(this); } - else + + void ParsingDefinitionLoopGrammar::Accept(IVisitor* visitor) { - result += *reading; - reading++; + visitor->Visit(this); + } + + void ParsingDefinitionOptionalGrammar::Accept(IVisitor* visitor) + { + visitor->Visit(this); + } + + void ParsingDefinitionCreateGrammar::Accept(IVisitor* visitor) + { + visitor->Visit(this); + } + + void ParsingDefinitionAssignGrammar::Accept(IVisitor* visitor) + { + visitor->Visit(this); + } + + void ParsingDefinitionUseGrammar::Accept(IVisitor* visitor) + { + visitor->Visit(this); + } + + void ParsingDefinitionSetterGrammar::Accept(IVisitor* visitor) + { + visitor->Visit(this); + } + +/*********************************************************************** +ParsingDefinitionTypeWriter +***********************************************************************/ + + ParsingDefinitionAttributeWriter::ParsingDefinitionAttributeWriter(const WString& name) + { + attribute=new ParsingDefinitionAttribute; + attribute->name=name; + } + + ParsingDefinitionAttributeWriter::ParsingDefinitionAttributeWriter(const ParsingDefinitionAttributeWriter& attributeWriter) + { + attribute=attributeWriter.attribute; + } + + ParsingDefinitionAttributeWriter& ParsingDefinitionAttributeWriter::Argument(const WString& argument) + { + attribute->arguments.Add(argument); + return *this; + } + + Ptr ParsingDefinitionAttributeWriter::Attribute()const + { + return attribute; + } + + ParsingDefinitionAttributeWriter Attribute(const WString& name) + { + return ParsingDefinitionAttributeWriter(name); + } + +/*********************************************************************** +ParsingDefinitionTypeWriter +***********************************************************************/ + + ParsingDefinitionTypeWriter::ParsingDefinitionTypeWriter(Ptr internalType) + { + type=internalType; + } + + ParsingDefinitionTypeWriter::ParsingDefinitionTypeWriter(const ParsingDefinitionTypeWriter& typeWriter) + { + type=typeWriter.type; + } + + ParsingDefinitionTypeWriter::ParsingDefinitionTypeWriter(const WString& name) + { + Ptr primitiveType=new ParsingDefinitionPrimitiveType; + primitiveType->name=name; + type=primitiveType; + } + + ParsingDefinitionTypeWriter ParsingDefinitionTypeWriter::Sub(const WString& subTypeName)const + { + Ptr subType=new ParsingDefinitionSubType; + subType->parentType=type; + subType->subTypeName=subTypeName; + return ParsingDefinitionTypeWriter(subType); + } + + ParsingDefinitionTypeWriter ParsingDefinitionTypeWriter::Array()const + { + Ptr arrayType=new ParsingDefinitionArrayType; + arrayType->elementType=type; + return ParsingDefinitionTypeWriter(arrayType); + } + + Ptr ParsingDefinitionTypeWriter::Type()const + { + return type; + } + + ParsingDefinitionTypeWriter Type(const WString& name) + { + return ParsingDefinitionTypeWriter(name); + } + + ParsingDefinitionTypeWriter TokenType() + { + Ptr type=new ParsingDefinitionTokenType; + return ParsingDefinitionTypeWriter(type); + } + +/*********************************************************************** +ParsingDefinitionClassDefinitionWriter +***********************************************************************/ + + ParsingDefinitionClassDefinitionWriter::ParsingDefinitionClassDefinitionWriter(const WString& name) + { + definition=new ParsingDefinitionClassDefinition; + definition->name=name; + currentDefinition=definition; + } + + ParsingDefinitionClassDefinitionWriter::ParsingDefinitionClassDefinitionWriter(const WString& name, const ParsingDefinitionTypeWriter& parentType) + { + definition=new ParsingDefinitionClassDefinition; + definition->name=name; + definition->parentType=parentType.Type(); + currentDefinition=definition; + } + + ParsingDefinitionClassDefinitionWriter& ParsingDefinitionClassDefinitionWriter::AmbiguousType(const ParsingDefinitionTypeWriter& ambiguousType) + { + definition->ambiguousType=ambiguousType.Type(); + return *this; + } + + ParsingDefinitionClassDefinitionWriter& ParsingDefinitionClassDefinitionWriter::Member(const WString& name, const ParsingDefinitionTypeWriter& type, const WString& unescapingFunction) + { + Ptr member=new ParsingDefinitionClassMemberDefinition; + member->name=name; + member->type=type.Type(); + member->unescapingFunction=unescapingFunction; + definition->members.Add(member); + currentDefinition=member; + return *this; + } + + ParsingDefinitionClassDefinitionWriter& ParsingDefinitionClassDefinitionWriter::SubType(const ParsingDefinitionTypeDefinitionWriter& type) + { + definition->subTypes.Add(type.Definition()); + return *this; + } + + ParsingDefinitionClassDefinitionWriter& ParsingDefinitionClassDefinitionWriter::Attribute(const ParsingDefinitionAttributeWriter& attribute) + { + currentDefinition->attributes.Add(attribute.Attribute()); + return *this; + } + + Ptr ParsingDefinitionClassDefinitionWriter::Definition()const + { + return definition; + } + + ParsingDefinitionClassDefinitionWriter Class(const WString& name) + { + return ParsingDefinitionClassDefinitionWriter(name); + } + + ParsingDefinitionClassDefinitionWriter Class(const WString& name, const ParsingDefinitionTypeWriter& parentType) + { + return ParsingDefinitionClassDefinitionWriter(name, parentType); + } + +/*********************************************************************** +ParsingDefinitionEnumDefinitionWriter +***********************************************************************/ + + ParsingDefinitionEnumDefinitionWriter::ParsingDefinitionEnumDefinitionWriter(const WString& name) + { + definition=new ParsingDefinitionEnumDefinition; + definition->name=name; + currentDefinition=definition; + } + + ParsingDefinitionEnumDefinitionWriter& ParsingDefinitionEnumDefinitionWriter::Member(const WString& name) + { + Ptr member=new ParsingDefinitionEnumMemberDefinition; + member->name=name; + definition->members.Add(member); + currentDefinition=member; + return *this; + } + + ParsingDefinitionEnumDefinitionWriter& ParsingDefinitionEnumDefinitionWriter::Attribute(const ParsingDefinitionAttributeWriter& attribute) + { + currentDefinition->attributes.Add(attribute.Attribute()); + return *this; + } + + Ptr ParsingDefinitionEnumDefinitionWriter::Definition()const + { + return definition; + } + + ParsingDefinitionEnumDefinitionWriter Enum(const WString& name) + { + return ParsingDefinitionEnumDefinitionWriter(name); + } + +/*********************************************************************** +ParsingDefinitionGrammarWriter +***********************************************************************/ + + ParsingDefinitionGrammarWriter::ParsingDefinitionGrammarWriter(Ptr internalGrammar) + { + grammar=internalGrammar; + } + + ParsingDefinitionGrammarWriter::ParsingDefinitionGrammarWriter(const ParsingDefinitionGrammarWriter& grammarWriter) + { + grammar=grammarWriter.grammar; + } + + ParsingDefinitionGrammarWriter ParsingDefinitionGrammarWriter::operator+(const ParsingDefinitionGrammarWriter& next)const + { + Ptr sequence=new ParsingDefinitionSequenceGrammar; + sequence->first=grammar; + sequence->second=next.Grammar(); + return ParsingDefinitionGrammarWriter(sequence); + } + + ParsingDefinitionGrammarWriter ParsingDefinitionGrammarWriter::operator|(const ParsingDefinitionGrammarWriter& next)const + { + Ptr alternative=new ParsingDefinitionAlternativeGrammar; + alternative->first=grammar; + alternative->second=next.Grammar(); + return ParsingDefinitionGrammarWriter(alternative); + } + + ParsingDefinitionGrammarWriter ParsingDefinitionGrammarWriter::operator*()const + { + Ptr loop=new ParsingDefinitionLoopGrammar; + loop->grammar=grammar; + return ParsingDefinitionGrammarWriter(loop); + } + + ParsingDefinitionGrammarWriter ParsingDefinitionGrammarWriter::As(const ParsingDefinitionTypeWriter& type)const + { + Ptr create=new ParsingDefinitionCreateGrammar; + create->grammar=grammar; + create->type=type.Type(); + return ParsingDefinitionGrammarWriter(create); + } + + ParsingDefinitionGrammarWriter ParsingDefinitionGrammarWriter::operator[](const WString& memberName)const + { + Ptr assign=new ParsingDefinitionAssignGrammar; + assign->grammar=grammar; + assign->memberName=memberName; + return ParsingDefinitionGrammarWriter(assign); + } + + ParsingDefinitionGrammarWriter ParsingDefinitionGrammarWriter::operator!()const + { + Ptr use=new ParsingDefinitionUseGrammar; + use->grammar=grammar; + return ParsingDefinitionGrammarWriter(use); + } + + ParsingDefinitionGrammarWriter ParsingDefinitionGrammarWriter::Set(const WString& memberName, const WString& value)const + { + Ptr setter=new ParsingDefinitionSetterGrammar; + setter->grammar=grammar; + setter->memberName=memberName; + setter->value=value; + return ParsingDefinitionGrammarWriter(setter); + } + + Ptr ParsingDefinitionGrammarWriter::Grammar()const + { + return grammar; + } + + ParsingDefinitionGrammarWriter Rule(const WString& name) + { + Ptr grammar=new ParsingDefinitionPrimitiveGrammar; + grammar->name=name; + return ParsingDefinitionGrammarWriter(grammar); + } + + ParsingDefinitionGrammarWriter Text(const WString& text) + { + Ptr grammar=new ParsingDefinitionTextGrammar; + grammar->text=text; + return ParsingDefinitionGrammarWriter(grammar); + } + + ParsingDefinitionGrammarWriter Opt(const ParsingDefinitionGrammarWriter& writer) + { + Ptr grammar=new ParsingDefinitionOptionalGrammar; + grammar->grammar=writer.Grammar(); + return ParsingDefinitionGrammarWriter(grammar); + } + +/*********************************************************************** +ParsingDefinitionTokenDefinitionWriter +***********************************************************************/ + + ParsingDefinitionTokenDefinitionWriter::ParsingDefinitionTokenDefinitionWriter(ParsingDefinitionWriter& _owner, Ptr _token) + :owner(_owner) + ,token(_token) + { + } + + ParsingDefinitionTokenDefinitionWriter& ParsingDefinitionTokenDefinitionWriter::Attribute(const ParsingDefinitionAttributeWriter& attribute) + { + token->attributes.Add(attribute.Attribute()); + return *this; + } + + ParsingDefinitionWriter& ParsingDefinitionTokenDefinitionWriter::EndToken() + { + return owner; + } + +/*********************************************************************** +ParsingDefinitionRuleDefinitionWriter +***********************************************************************/ + + ParsingDefinitionRuleDefinitionWriter::ParsingDefinitionRuleDefinitionWriter(ParsingDefinitionWriter& _owner, Ptr _rule) + :owner(_owner) + ,rule(_rule) + { + } + + ParsingDefinitionRuleDefinitionWriter& ParsingDefinitionRuleDefinitionWriter::Imply(const ParsingDefinitionGrammarWriter& grammar) + { + rule->grammars.Add(grammar.Grammar()); + return *this; + } + + ParsingDefinitionRuleDefinitionWriter& ParsingDefinitionRuleDefinitionWriter::Attribute(const ParsingDefinitionAttributeWriter& attribute) + { + rule->attributes.Add(attribute.Attribute()); + return *this; + } + + ParsingDefinitionWriter& ParsingDefinitionRuleDefinitionWriter::EndRule() + { + return owner; + } + +/*********************************************************************** +ParsingDefinitionWriter +***********************************************************************/ + + ParsingDefinitionWriter::ParsingDefinitionWriter() + { + definition=new ParsingDefinition; + } + + ParsingDefinitionWriter& ParsingDefinitionWriter::Type(const ParsingDefinitionTypeDefinitionWriter& type) + { + definition->types.Add(type.Definition()); + return *this; + } + + ParsingDefinitionWriter& ParsingDefinitionWriter::Token(const WString& name, const WString& regex) + { + return TokenAtt(name, regex).EndToken(); + } + + ParsingDefinitionTokenDefinitionWriter ParsingDefinitionWriter::TokenAtt(const WString& name, const WString& regex) + { + Ptr token=new ParsingDefinitionTokenDefinition; + token->name=name; + token->regex=regex; + token->discard=false; + definition->tokens.Add(token); + return ParsingDefinitionTokenDefinitionWriter(*this, token); + } + + ParsingDefinitionWriter& ParsingDefinitionWriter::Discard(const WString& name, const WString& regex) + { + Ptr token=new ParsingDefinitionTokenDefinition; + token->name=name; + token->regex=regex; + token->discard=true; + definition->tokens.Add(token); + return *this; + } + + ParsingDefinitionRuleDefinitionWriter ParsingDefinitionWriter::Rule(const WString& name, const ParsingDefinitionTypeWriter& type) + { + Ptr rule=new ParsingDefinitionRuleDefinition; + rule->name=name; + rule->type=type.Type(); + definition->rules.Add(rule); + return ParsingDefinitionRuleDefinitionWriter(*this, rule); + } + + Ptr ParsingDefinitionWriter::Definition()const + { + return definition; } } - return result; -#endif } +} - WString Locale::FormatTime(const WString& format, DateTime time)const - { -#if defined VCZH_MSVC - SYSTEMTIME st=DateTimeToSystemTime(time); - int length=GetTimeFormatEx(localeName.Buffer(), 0, &st, format.Buffer(), NULL, 0); - if(length==0) return L""; - Array buffer(length); - GetTimeFormatEx(localeName.Buffer(), 0, &st, format.Buffer(),&buffer[0], (int)buffer.Count()); - return &buffer[0]; -#elif defined VCZH_GCC - return FormatDate(format, time); -#endif - } -#ifdef VCZH_MSVC - WString Locale::FormatNumber(const WString& number)const - { - int length=GetNumberFormatEx(localeName.Buffer(), 0, number.Buffer(), NULL, NULL, 0); - if(length==0) return L""; - Array buffer(length); - GetNumberFormatEx(localeName.Buffer(), 0, number.Buffer(), NULL, &buffer[0], (int)buffer.Count()); - return &buffer[0]; - } +/*********************************************************************** +.\PARSING\PARSINGDEFINITIONS_CREATEPARSERDEFINITION.CPP +***********************************************************************/ - WString Locale::FormatCurrency(const WString& currency)const +namespace vl +{ + namespace parsing { - int length=GetCurrencyFormatEx(localeName.Buffer(), 0, currency.Buffer(), NULL, NULL, 0); - if(length==0) return L""; - Array buffer(length); - GetCurrencyFormatEx(localeName.Buffer(), 0, currency.Buffer(), NULL, &buffer[0], (int)buffer.Count()); - return &buffer[0]; - } -#endif - - WString Locale::GetShortDayOfWeekName(vint dayOfWeek)const - { -#if defined VCZH_MSVC - return FormatDate(L"ddd", DateTime::FromDateTime(2000, 1, 2+dayOfWeek)); -#elif defined VCZH_GCC - switch(dayOfWeek) + namespace definitions { - case 0: return L"Sun"; - case 1: return L"Mon"; - case 2: return L"Tue"; - case 3: return L"Wed"; - case 4: return L"Thu"; - case 5: return L"Fri"; - case 6: return L"Sat"; - } - return L""; -#endif - } + using namespace collections; - WString Locale::GetLongDayOfWeekName(vint dayOfWeek)const - { -#if defined VCZH_MSVC - return FormatDate(L"dddd", DateTime::FromDateTime(2000, 1, 2+dayOfWeek)); -#elif defined VCZH_GCC - switch(dayOfWeek) - { - case 0: return L"Sunday"; - case 1: return L"Monday"; - case 2: return L"Tuesday"; - case 3: return L"Wednesday"; - case 4: return L"Thursday"; - case 5: return L"Friday"; - case 6: return L"Saturday"; - } - return L""; -#endif - } +/*********************************************************************** +自举 +***********************************************************************/ - WString Locale::GetShortMonthName(vint month)const - { -#if defined VCZH_MSVC - return FormatDate(L"MMM", DateTime::FromDateTime(2000, month, 1)); -#elif defined VCZH_GCC - switch(month) - { - case 1: return L"Jan"; - case 2: return L"Feb"; - case 3: return L"Mar"; - case 4: return L"Apr"; - case 5: return L"May"; - case 6: return L"Jun"; - case 7: return L"Jul"; - case 8: return L"Aug"; - case 9: return L"Sep"; - case 10: return L"Oct"; - case 11: return L"Nov"; - case 12: return L"Dec"; - } - return L""; -#endif - } + Ptr CreateParserDefinition() + { + ParsingDefinitionWriter definitionWriter; - WString Locale::GetLongMonthName(vint month)const - { -#if defined VCZH_MSVC - return FormatDate(L"MMMM", DateTime::FromDateTime(2000, month, 1)); -#elif defined VCZH_GCC - switch(month) - { - case 1: return L"January"; - case 2: return L"February"; - case 3: return L"March"; - case 4: return L"April"; - case 5: return L"May"; - case 6: return L"June"; - case 7: return L"July"; - case 8: return L"August"; - case 9: return L"September"; - case 10: return L"October"; - case 11: return L"November"; - case 12: return L"December"; - } - return L""; -#endif - } + definitionWriter + .Type( + Class(L"AttributeDef") + .Member(L"name", TokenType()) + .Attribute(Attribute(L"Semantic").Argument(L"Attribute")) + .Member(L"arguments", TokenType().Array()) + ) + .Type( + Class(L"DefBase") + .Member(L"attributes", Type(L"AttributeDef").Array()) + ) + //------------------------------------- + .Type( + Class(L"TypeObj") + ) -#ifdef VCZH_MSVC - WString Locale::ToFullWidth(const WString& str)const - { - return Transform(localeName, str, LCMAP_FULLWIDTH); - } + .Type( + Class(L"PrimitiveTypeObj", Type(L"TypeObj")) + .Member(L"name", TokenType()) + .Attribute(Attribute(L"Semantic").Argument(L"Type")) + ) - WString Locale::ToHalfWidth(const WString& str)const - { - return Transform(localeName, str, LCMAP_HALFWIDTH); - } + .Type( + Class(L"TokenTypeObj", Type(L"TypeObj")) + ) - WString Locale::ToHiragana(const WString& str)const - { - return Transform(localeName, str, LCMAP_HIRAGANA); - } + .Type( + Class(L"SubTypeObj", Type(L"TypeObj")) + .Member(L"parentType", Type(L"TypeObj")) + .Member(L"name", TokenType()) + .Attribute(Attribute(L"Semantic").Argument(L"Type")) + ) - WString Locale::ToKatagana(const WString& str)const - { - return Transform(localeName, str, LCMAP_KATAKANA); - } -#endif + .Type( + Class(L"ArrayTypeObj", Type(L"TypeObj")) + .Member(L"elementType", Type(L"TypeObj")) + ) + //------------------------------------- + .Type( + Class(L"TypeDef", Type(L"DefBase")) + .Member(L"name", TokenType()) + .Attribute(Attribute(L"Color").Argument(L"Type")) + ) - WString Locale::ToLower(const WString& str)const - { -#if defined VCZH_MSVC - return Transform(localeName, str, LCMAP_LOWERCASE); -#elif defined VCZH_GCC - return wlower(str); -#endif - } + .Type( + Class(L"ClassMemberDef", Type(L"DefBase")) + .Member(L"type", Type(L"TypeObj")) + .Member(L"name", TokenType()) + .Member(L"unescapingFunction", TokenType()) + ) - WString Locale::ToUpper(const WString& str)const - { -#if defined VCZH_MSVC - return Transform(localeName, str, LCMAP_UPPERCASE); -#elif defined VCZH_GCC - return wupper(str); -#endif - } + .Type( + Class(L"ClassTypeDef", Type(L"TypeDef")) + .Member(L"ambiguousType", Type(L"TypeObj")) + .Member(L"parentType", Type(L"TypeObj")) + .Member(L"members", Type(L"ClassMemberDef").Array()) + .Member(L"subTypes", Type(L"TypeDef").Array()) + ) - WString Locale::ToLinguisticLower(const WString& str)const - { -#if defined VCZH_MSVC - return Transform(localeName, str, LCMAP_LOWERCASE | LCMAP_LINGUISTIC_CASING); -#elif defined VCZH_GCC - return wlower(str); -#endif - } + .Type( + Class(L"EnumMemberDef", Type(L"DefBase")) + .Member(L"name", TokenType()) + ) - WString Locale::ToLinguisticUpper(const WString& str)const - { -#if defined VCZH_MSVC - return Transform(localeName, str, LCMAP_UPPERCASE | LCMAP_LINGUISTIC_CASING); -#elif defined VCZH_GCC - return wupper(str); -#endif - } + .Type( + Class(L"EnumTypeDef", Type(L"TypeDef")) + .Member(L"members", Type(L"EnumMemberDef").Array()) + ) + //------------------------------------- + .Type( + Class(L"GrammarDef") + ) -#ifdef VCZH_MSVC - WString Locale::ToSimplifiedChinese(const WString& str)const - { - return Transform(localeName, str, LCMAP_SIMPLIFIED_CHINESE); - } + .Type( + Class(L"PrimitiveGrammarDef", Type(L"GrammarDef")) + .Member(L"name", TokenType()) + .Attribute(Attribute(L"Semantic").Argument(L"Token").Argument(L"Rule")) + ) - WString Locale::ToTraditionalChinese(const WString& str)const - { - return Transform(localeName, str, LCMAP_TRADITIONAL_CHINESE); - } + .Type( + Class(L"TextGrammarDef", Type(L"GrammarDef")) + .Member(L"text", TokenType()) + .Attribute(Attribute(L"Semantic").Argument(L"Literal")) + ) - WString Locale::ToTileCase(const WString& str)const - { - return Transform(localeName, str, LCMAP_TITLECASE); - } -#endif + .Type( + Class(L"SequenceGrammarDef", Type(L"GrammarDef")) + .Member(L"first", Type(L"GrammarDef")) + .Member(L"second", Type(L"GrammarDef")) + ) - vint Locale::Compare(const WString& s1, const WString& s2, Normalization normalization)const - { -#if defined VCZH_MSVC - switch(CompareStringEx(localeName.Buffer(), TranslateNormalization(normalization), s1.Buffer(), (int)s1.Length(), s2.Buffer(), (int)s2.Length(), NULL, NULL, NULL)) - { - case CSTR_LESS_THAN: return -1; - case CSTR_GREATER_THAN: return 1; - default: return 0; - } -#elif defined VCZH_GCC - switch(normalization) - { - case Normalization::None: - return wcscmp(s1.Buffer(), s2.Buffer()); - case Normalization::IgnoreCase: - return wcscasecmp(s1.Buffer(), s2.Buffer()); - } -#endif - } + .Type( + Class(L"AlternativeGrammarDef", Type(L"GrammarDef")) + .Member(L"first", Type(L"GrammarDef")) + .Member(L"second", Type(L"GrammarDef")) + ) - vint Locale::CompareOrdinal(const WString& s1, const WString& s2)const - { -#if defined VCZH_MSVC - switch(CompareStringOrdinal(s1.Buffer(), (int)s1.Length(), s2.Buffer(), (int)s2.Length(), FALSE)) - { - case CSTR_LESS_THAN: return -1; - case CSTR_GREATER_THAN: return 1; - default: return 0; - } -#elif defined VCZH_GCC - return wcscmp(s1.Buffer(), s2.Buffer()); -#endif - } + .Type( + Class(L"LoopGrammarDef", Type(L"GrammarDef")) + .Member(L"grammar", Type(L"GrammarDef")) + ) - vint Locale::CompareOrdinalIgnoreCase(const WString& s1, const WString& s2)const - { -#if defined VCZH_MSVC - switch(CompareStringOrdinal(s1.Buffer(), (int)s1.Length(), s2.Buffer(), (int)s2.Length(), TRUE)) - { - case CSTR_LESS_THAN: return -1; - case CSTR_GREATER_THAN: return 1; - default: return 0; - } -#elif defined VCZH_GCC - return wcscasecmp(s1.Buffer(), s2.Buffer()); -#endif - } + .Type( + Class(L"OptionalGrammarDef", Type(L"GrammarDef")) + .Member(L"grammar", Type(L"GrammarDef")) + ) - collections::Pair Locale::FindFirst(const WString& text, const WString& find, Normalization normalization)const - { -#if defined VCZH_MSVC - int length=0; - int result=FindNLSStringEx(localeName.Buffer(), FIND_FROMSTART | TranslateNormalization(normalization), text.Buffer(), (int)text.Length(), find.Buffer(), (int)find.Length(), &length, NULL, NULL, NULL); - return result==-1?Pair(-1, 0):Pair(result, length); -#elif defined VCZH_GCC - if(text.Length() < find.Length() || find.Length() == 0) - { - return Pair(-1, 0); - } - const wchar_t* result = 0; - switch(normalization) - { - case Normalization::None: + .Type( + Class(L"CreateGrammarDef", Type(L"GrammarDef")) + .Member(L"grammar", Type(L"GrammarDef")) + .Member(L"type", Type(L"TypeObj")) + ) + + .Type( + Class(L"AssignGrammarDef", Type(L"GrammarDef")) + .Member(L"grammar", Type(L"GrammarDef")) + .Member(L"memberName", TokenType()) + .Attribute(Attribute(L"Semantic").Argument(L"Field")) + ) + + .Type( + Class(L"UseGrammarDef", Type(L"GrammarDef")) + .Member(L"grammar", Type(L"GrammarDef")) + ) + + .Type( + Class(L"SetterGrammarDef", Type(L"GrammarDef")) + .Member(L"grammar", Type(L"GrammarDef")) + .Member(L"memberName", TokenType()) + .Attribute(Attribute(L"Semantic").Argument(L"Field")) + .Member(L"value", TokenType()) + .Attribute(Attribute(L"Semantic").Argument(L"EnumValue")) + ) + //------------------------------------- + .Type( + Class(L"TokenDef", Type(L"DefBase")) + .SubType( + Enum(L"DiscardOption") + .Member(L"DiscardToken") + .Member(L"KeepToken") + ) + .Member(L"name", TokenType()) + .Attribute(Attribute(L"Color").Argument(L"Token")) + .Member(L"regex", TokenType()) + .Member(L"discard", Type(L"DiscardOption")) + ) + + .Type( + Class(L"RuleDef", Type(L"DefBase")) + .Member(L"name", TokenType()) + .Attribute(Attribute(L"Color").Argument(L"Rule")) + .Member(L"type", Type(L"TypeObj")) + .Member(L"grammars", Type(L"GrammarDef").Array()) + ) + + .Type( + Class(L"ParserDef") + .Member(L"definitions", Type(L"DefBase").Array()) + ) + //------------------------------------- + .TokenAtt(L"CLASS", L"class") + .Attribute(Attribute(L"Color").Argument(L"Keyword")) + .Attribute(Attribute(L"Candidate")) + .EndToken() + .TokenAtt(L"AMBIGUOUS", L"ambiguous") + .Attribute(Attribute(L"Color").Argument(L"Keyword")) + .Attribute(Attribute(L"Candidate")) + .EndToken() + .TokenAtt(L"ENUM", L"enum") + .Attribute(Attribute(L"Color").Argument(L"Keyword")) + .Attribute(Attribute(L"Candidate")) + .EndToken() + .TokenAtt(L"TOKEN", L"token") + .Attribute(Attribute(L"Color").Argument(L"Keyword")) + .Attribute(Attribute(L"Candidate")) + .EndToken() + .TokenAtt(L"DISCARDTOKEN", L"discardtoken") + .Attribute(Attribute(L"Color").Argument(L"Keyword")) + .Attribute(Attribute(L"Candidate")) + .EndToken() + .TokenAtt(L"RULE", L"rule") + .Attribute(Attribute(L"Color").Argument(L"Keyword")) + .Attribute(Attribute(L"Candidate")) + .EndToken() + .TokenAtt(L"AS", L"as") + .Attribute(Attribute(L"Color").Argument(L"Keyword")) + .Attribute(Attribute(L"Candidate")) + .EndToken() + .TokenAtt(L"WITH", L"with") + .Attribute(Attribute(L"Color").Argument(L"Keyword")) + .Attribute(Attribute(L"Candidate")) + .EndToken() + + .Token(L"OPEN", L"/{") + .Token(L"CLOSE", L"/}") + .Token(L"SEMICOLON", L";") + .Token(L"COLON", L":") + .Token(L"COMMA", L",") + .Token(L"DOT", L".") + .Token(L"ASSIGN", L"/=") + .Token(L"USING", L"/!") + .Token(L"OR", L"/|") + .Token(L"OPTOPEN", L"/[") + .Token(L"OPTCLOSE", L"/]") + .Token(L"PREOPEN", L"/(") + .Token(L"PRECLOSE", L"/)") + .TokenAtt(L"ATT", L"@") + .Attribute(Attribute(L"Color").Argument(L"Attribute")) + .EndToken() + + .TokenAtt(L"NAME", L"[a-zA-Z_]/w*") + .Attribute(Attribute(L"Color").Argument(L"Default")) + .Attribute(Attribute(L"ContextColor")) + .Attribute(Attribute(L"AutoComplete")) + .EndToken() + .TokenAtt(L"STRING", L"\"([^\"]|\"\")*\"") + .Attribute(Attribute(L"Color").Argument(L"String")) + .Attribute(Attribute(L"AutoComplete")) + .EndToken() + .Discard(L"SPACE", L"/s+") + .Discard(L"COMMENT", L"////[^\\r\\n]*") + //------------------------------------- + .Rule(L"Attribute", Type(L"AttributeDef")) + .Imply( + (Text(L"@") + Rule(L"NAME")[L"name"] + Text(L"(") + Opt(Rule(L"STRING")[L"arguments"] + *(Text(L",") + Rule(L"STRING")[L"arguments"])) + Text(L")")) + .As(Type(L"AttributeDef")) + ) + .EndRule() + //------------------------------------- + .Rule(L"Type", Type(L"TypeObj")) + .Imply( + (Rule(L"NAME")[L"name"]) + .As(Type(L"PrimitiveTypeObj")) + ) + .Imply( + Text(L"token") + .As(Type(L"TokenTypeObj")) + ) + .Imply( + (Rule(L"Type")[L"parentType"] + Text(L".") + Rule(L"NAME")[L"name"]) + .As(Type(L"SubTypeObj")) + ) + .Imply( + (Rule(L"Type")[L"elementType"] + Text(L"[") + Text(L"]")) + .As(Type(L"ArrayTypeObj")) + ) + .EndRule() + //------------------------------------- + .Rule(L"EnumMember", Type(L"EnumMemberDef")) + .Imply( + ( + Rule(L"NAME")[L"name"] + + Opt(Rule(L"Attribute")[L"attributes"] + *(Text(L",") + Rule(L"Attribute")[L"attributes"])) + + Text(L",") + ) + .As(Type(L"EnumMemberDef")) + ) + .EndRule() + .Rule(L"Enum", Type(L"EnumTypeDef")) + .Imply( + ( + Text(L"enum") + Rule(L"NAME")[L"name"] + + Opt(Rule(L"Attribute")[L"attributes"] + *(Text(L",") + Rule(L"Attribute")[L"attributes"])) + + Text(L"{") + + *(Rule(L"EnumMember")[L"members"]) + + Text(L"}") + ) + .As(Type(L"EnumTypeDef")) + ) + .EndRule() + .Rule(L"ClassMember", Type(L"ClassMemberDef")) + .Imply( + ( + Rule(L"Type")[L"type"] + Rule(L"NAME")[L"name"] + + Opt(Text(L"(") + Rule(L"NAME")[L"unescapingFunction"] + Text(L")")) + + Opt(Rule(L"Attribute")[L"attributes"] + *(Text(L",") + Rule(L"Attribute")[L"attributes"])) + + Text(L";") + ) + .As(Type(L"ClassMemberDef")) + ) + .EndRule() + .Rule(L"Class", Type(L"ClassTypeDef")) + .Imply( + ( + Text(L"class") + Rule(L"NAME")[L"name"] + + Opt(Text(L"ambiguous") + Text(L"(") + Rule(L"Type")[L"ambiguousType"] + Text(L")")) + + Opt(Text(L":") + Rule(L"Type")[L"parentType"]) + + Opt(Rule(L"Attribute")[L"attributes"] + *(Text(L",") + Rule(L"Attribute")[L"attributes"])) + + Text(L"{") + + *(Rule(L"ClassMember")[L"members"] | Rule(L"TypeDecl")[L"subTypes"]) + + Text(L"}") + ) + .As(Type(L"ClassTypeDef")) + ) + .EndRule() + .Rule(L"TypeDecl", Type(L"TypeDef")) + .Imply(!Rule(L"Enum") | !Rule(L"Class")) + .EndRule() + //------------------------------------ + .Rule(L"PrimitiveGrammar", Type(L"GrammarDef")) + .Imply( + (Rule(L"NAME")[L"name"]) + .As(Type(L"PrimitiveGrammarDef")) + ) + .Imply( + (Rule(L"STRING")[L"text"]) + .As(Type(L"TextGrammarDef")) + ) + .Imply( + (Rule(L"PrimitiveGrammar")[L"grammar"] + Text(L":") + Rule(L"NAME")[L"memberName"]) + .As(Type(L"AssignGrammarDef")) + ) + .Imply( + (Text(L"!") + Rule(L"PrimitiveGrammar")[L"grammar"]) + .As(Type(L"UseGrammarDef")) + ) + .Imply( + (Text(L"[") + Rule(L"Grammar")[L"grammar"] + Text(L"]")) + .As(Type(L"OptionalGrammarDef")) + ) + .Imply( + (Text(L"{") + Rule(L"Grammar")[L"grammar"] + Text(L"}")) + .As(Type(L"LoopGrammarDef")) + ) + .Imply( + (Text(L"(") + !Rule(L"Grammar") + Text(L")")) + ) + .EndRule() + + .Rule(L"SequenceGrammar", Type(L"GrammarDef")) + .Imply( + !Rule(L"PrimitiveGrammar") + ) + .Imply( + (Rule(L"SequenceGrammar")[L"first"] + Rule(L"PrimitiveGrammar")[L"second"]) + .As(Type(L"SequenceGrammarDef")) + ) + .EndRule() + + .Rule(L"AlternativeGrammar", Type(L"GrammarDef")) + .Imply( + !Rule(L"SequenceGrammar") + ) + .Imply( + (Rule(L"AlternativeGrammar")[L"first"] + Text(L"|") + Rule(L"SequenceGrammar")[L"second"]) + .As(Type(L"AlternativeGrammarDef")) + ) + .EndRule() + + .Rule(L"Grammar", Type(L"GrammarDef")) + .Imply( + !Rule(L"AlternativeGrammar") + ) + .Imply( + (Rule(L"Grammar")[L"grammar"] + Text(L"as") + Rule(L"Type")[L"type"]) + .As(Type(L"CreateGrammarDef")) + ) + .Imply( + (Rule(L"Grammar")[L"grammar"] + Text(L"with") + Text(L"{") + Rule(L"NAME")[L"memberName"] + Text(L"=") + Rule(L"STRING")[L"value"] + Text(L"}")) + .As(Type(L"SetterGrammarDef")) + ) + .EndRule() + //------------------------------------ + .Rule(L"TokenDecl", Type(L"TokenDef")) + .Imply( + ( + Text(L"token") + Rule(L"NAME")[L"name"] + + Text(L"=") + Rule(L"STRING")[L"regex"] + + Opt(Rule(L"Attribute")[L"attributes"] + *(Text(L",") + Rule(L"Attribute")[L"attributes"])) + + Text(L";") + ) + .As(Type(L"TokenDef")) + .Set(L"discard", L"KeepToken") + ) + .Imply( + (Text(L"discardtoken") + Rule(L"NAME")[L"name"] + Text(L"=") + Rule(L"STRING")[L"regex"] + Text(L";")) + .As(Type(L"TokenDef")) + .Set(L"discard", L"DiscardToken") + ) + .EndRule() + + .Rule(L"RuleDecl", Type(L"RuleDef")) + .Imply( + ( + Text(L"rule") + Rule(L"Type")[L"type"] + Rule(L"NAME")[L"name"] + + Opt(Rule(L"Attribute")[L"attributes"] + *(Text(L",") + Rule(L"Attribute")[L"attributes"])) + + *(Text(L"=") + Rule(L"Grammar")[L"grammars"]) + + Text(L";") + ) + .As(Type(L"RuleDef")) + ) + .EndRule() + //------------------------------------ + .Rule(L"ParserDecl", Type(L"ParserDef")) + .Imply( + ( + *( + Rule(L"TypeDecl")[L"definitions"] | + Rule(L"TokenDecl")[L"definitions"] | + Rule(L"RuleDecl")[L"definitions"] + ) + +( + Rule(L"TypeDecl")[L"definitions"] | + Rule(L"TokenDecl")[L"definitions"] | + Rule(L"RuleDecl")[L"definitions"] + ) + ) + .As(Type(L"ParserDef")) + ) + .EndRule() + ; + + return definitionWriter.Definition(); + } + + WString DeserializeString(const WString& value) + { + if(value.Length()>=2 && value[0]==L'"' && value[value.Length()-1]==L'"') { - const wchar_t* reading = text.Buffer(); + Array chars(value.Length()); + memset(&chars[0], 0, chars.Count()*sizeof(wchar_t)); + const wchar_t* reading=value.Buffer()+1; + wchar_t* writing=&chars[0]; while(*reading) { - if (wcsncmp(reading, find.Buffer(), find.Length())==0) + if(*reading!=L'"') + { + *writing++=*reading++; + } + else if(reading[1]!=L'"') { - result = reading; break; } - reading++; + else + { + *writing++=L'"'; + reading+=2; + } + } + return &chars[0]; + } + return L""; + } + + WString DeserializeString(Ptr token) + { + const WString& value=token->GetValue(); + return DeserializeString(value); + } + + void SetName(WString& target, Ptr node) + { + Ptr token=node.Cast(); + if(token) + { + target=token->GetValue(); + } + } + + void SetText(WString& target, Ptr node) + { + Ptr token=node.Cast(); + if(token) + { + target=DeserializeString(token); + } + } + + extern Ptr Deserialize(Ptr node); + + template + void SetArray(List>& target, Ptr node) + { + Ptr source=node.Cast(); + if(source) + { + for(vint i=0;iCount();i++) + { + target.Add(Deserialize(source->GetItem(i).Cast()).Cast()); } } - break; - case Normalization::IgnoreCase: + } + + void SetArray(List& target, Ptr node) + { + Ptr source=node.Cast(); + if(source) { - const wchar_t* reading = text.Buffer(); - while(*reading) + for(vint i=0;iCount();i++) { - if (wcsncasecmp(reading, find.Buffer(), find.Length())==0) + WString name; + SetName(name, source->GetItem(i)); + target.Add(name); + } + } + } + + template + void SetMember(Ptr& target, Ptr node) + { + Ptr source=node.Cast(); + if(source) + { + target=Deserialize(source).Cast(); + } + } + + Ptr Deserialize(Ptr node) + { + if(!node) + { + return 0; + } + else if(node->GetType()==L"AttributeDef") + { + Ptr target=new ParsingDefinitionAttribute; + SetName(target->name, node->GetMember(L"name")); + SetArray(target->arguments, node->GetMember(L"arguments")); + for(vint i=0;iarguments.Count();i++) + { + target->arguments[i]=DeserializeString(target->arguments[i]); + } + return target; + } + else if(node->GetType()==L"PrimitiveTypeObj") + { + Ptr target=new ParsingDefinitionPrimitiveType; + SetName(target->name, node->GetMember(L"name")); + return target; + } + else if(node->GetType()==L"TokenTypeObj") + { + Ptr target=new ParsingDefinitionTokenType; + return target; + } + else if(node->GetType()==L"SubTypeObj") + { + Ptr target=new ParsingDefinitionSubType; + SetMember(target->parentType, node->GetMember(L"parentType")); + SetName(target->subTypeName, node->GetMember(L"name")); + return target; + } + else if(node->GetType()==L"ArrayTypeObj") + { + Ptr target=new ParsingDefinitionArrayType; + SetMember(target->elementType, node->GetMember(L"elementType")); + return target; + } + else if(node->GetType()==L"ClassMemberDef") + { + Ptr target=new ParsingDefinitionClassMemberDefinition; + SetArray(target->attributes, node->GetMember(L"attributes")); + SetMember(target->type, node->GetMember(L"type")); + SetName(target->name, node->GetMember(L"name")); + SetName(target->unescapingFunction, node->GetMember(L"unescapingFunction")); + return target; + } + else if(node->GetType()==L"ClassTypeDef") + { + Ptr target=new ParsingDefinitionClassDefinition; + SetArray(target->attributes, node->GetMember(L"attributes")); + SetMember(target->ambiguousType, node->GetMember(L"ambiguousType")); + SetMember(target->parentType, node->GetMember(L"parentType")); + SetName(target->name, node->GetMember(L"name")); + SetArray(target->members, node->GetMember(L"members")); + SetArray(target->subTypes, node->GetMember(L"subTypes")); + return target; + } + else if(node->GetType()==L"EnumMemberDef") + { + Ptr target=new ParsingDefinitionEnumMemberDefinition; + SetArray(target->attributes, node->GetMember(L"attributes")); + SetName(target->name, node->GetMember(L"name")); + return target; + } + else if(node->GetType()==L"EnumTypeDef") + { + Ptr target=new ParsingDefinitionEnumDefinition; + SetArray(target->attributes, node->GetMember(L"attributes")); + SetName(target->name, node->GetMember(L"name")); + SetArray(target->members, node->GetMember(L"members")); + return target; + } + else if(node->GetType()==L"PrimitiveGrammarDef") + { + Ptr target=new ParsingDefinitionPrimitiveGrammar; + SetName(target->name, node->GetMember(L"name")); + return target; + } + else if(node->GetType()==L"TextGrammarDef") + { + Ptr target=new ParsingDefinitionTextGrammar; + SetText(target->text, node->GetMember(L"text")); + return target; + } + else if(node->GetType()==L"SequenceGrammarDef") + { + Ptr target=new ParsingDefinitionSequenceGrammar; + SetMember(target->first, node->GetMember(L"first")); + SetMember(target->second, node->GetMember(L"second")); + return target; + } + else if(node->GetType()==L"AlternativeGrammarDef") + { + Ptr target=new ParsingDefinitionAlternativeGrammar; + SetMember(target->first, node->GetMember(L"first")); + SetMember(target->second, node->GetMember(L"second")); + return target; + } + else if(node->GetType()==L"LoopGrammarDef") + { + Ptr target=new ParsingDefinitionLoopGrammar; + SetMember(target->grammar, node->GetMember(L"grammar")); + return target; + } + else if(node->GetType()==L"OptionalGrammarDef") + { + Ptr target=new ParsingDefinitionOptionalGrammar; + SetMember(target->grammar, node->GetMember(L"grammar")); + return target; + } + else if(node->GetType()==L"CreateGrammarDef") + { + Ptr target=new ParsingDefinitionCreateGrammar; + SetMember(target->grammar, node->GetMember(L"grammar")); + SetMember(target->type, node->GetMember(L"type")); + return target; + } + else if(node->GetType()==L"AssignGrammarDef") + { + Ptr target=new ParsingDefinitionAssignGrammar; + SetMember(target->grammar, node->GetMember(L"grammar")); + SetName(target->memberName, node->GetMember(L"memberName")); + return target; + } + else if(node->GetType()==L"UseGrammarDef") + { + Ptr target=new ParsingDefinitionUseGrammar; + SetMember(target->grammar, node->GetMember(L"grammar")); + return target; + } + else if(node->GetType()==L"SetterGrammarDef") + { + Ptr target=new ParsingDefinitionSetterGrammar; + SetMember(target->grammar, node->GetMember(L"grammar")); + SetName(target->memberName, node->GetMember(L"memberName")); + SetText(target->value, node->GetMember(L"value")); + return target; + } + else if(node->GetType()==L"TokenDef") + { + Ptr target=new ParsingDefinitionTokenDefinition; + SetArray(target->attributes, node->GetMember(L"attributes")); + SetName(target->name, node->GetMember(L"name")); + SetText(target->regex, node->GetMember(L"regex")); + + Ptr token=node->GetMember(L"discard").Cast(); + target->discard=(token && token->GetValue()==L"DiscardToken"); + return target; + } + else if(node->GetType()==L"RuleDef") + { + Ptr target=new ParsingDefinitionRuleDefinition; + SetArray(target->attributes, node->GetMember(L"attributes")); + SetName(target->name, node->GetMember(L"name")); + SetMember(target->type, node->GetMember(L"type")); + SetArray(target->grammars, node->GetMember(L"grammars")); + return target; + } + else if(node->GetType()==L"ParserDef") + { + Ptr target=new ParsingDefinition; + Ptr defs=node->GetMember(L"definitions").Cast(); + if(defs) + { + vint count=defs->Count(); + for(vint i=0;i def=defs->GetItem(i).Cast(); + Ptr defObject=Deserialize(def); + if(Ptr defType=defObject.Cast()) + { + target->types.Add(defType); + } + else if(Ptr defToken=defObject.Cast()) + { + target->tokens.Add(defToken); + } + else if(Ptr defRule=defObject.Cast()) + { + target->rules.Add(defRule); + } + } + } + return target; + } + else + { + return 0; + } + } + + Ptr DeserializeDefinition(Ptr node) + { + return Deserialize(node.Cast()).Cast(); + } + } + } +} + + +/*********************************************************************** +.\PARSING\PARSINGSTATE.CPP +***********************************************************************/ + +namespace vl +{ + namespace parsing + { + namespace tabling + { + using namespace collections; + using namespace regex; + +/*********************************************************************** +ParsingTokenWalker::LookAheadEnumerator +***********************************************************************/ + + ParsingTokenWalker::LookAheadEnumerator::LookAheadEnumerator(const ParsingTokenWalker* _walker, vint _currentToken) + :walker(_walker) + ,firstToken(_currentToken) + ,currentToken(_currentToken) + ,currentValue(-1) + ,index(-1) + { + } + + ParsingTokenWalker::LookAheadEnumerator::LookAheadEnumerator(const LookAheadEnumerator& _enumerator) + :walker(_enumerator.walker) + ,firstToken(_enumerator.firstToken) + ,currentToken(_enumerator.currentToken) + ,currentValue(_enumerator.currentValue) + ,index(_enumerator.index) + { + } + + IEnumerator* ParsingTokenWalker::LookAheadEnumerator::Clone()const + { + return new LookAheadEnumerator(*this); + } + + const vint& ParsingTokenWalker::LookAheadEnumerator::Current()const + { + return currentValue; + } + + vint ParsingTokenWalker::LookAheadEnumerator::Index()const + { + return index; + } + + bool ParsingTokenWalker::LookAheadEnumerator::Next() + { + vint newToken=walker->GetNextIndex(currentToken); + if(newToken==-3) return false; + currentToken=newToken; + index++; + currentValue=walker->GetTableTokenIndex(currentToken); + return true; + } + + void ParsingTokenWalker::LookAheadEnumerator::Reset() + { + currentToken=firstToken; + currentValue=-1; + index=-1; + } + +/*********************************************************************** +ParsingTokenWalker::TokenLookAhead +***********************************************************************/ + + ParsingTokenWalker::TokenLookAhead::TokenLookAhead(const ParsingTokenWalker* _walker) + :walker(_walker) + { + } + + collections::IEnumerator* ParsingTokenWalker::TokenLookAhead::CreateEnumerator()const + { + return new LookAheadEnumerator(walker, walker->currentToken); + } + +/*********************************************************************** +ParsingTokenWalker::ReduceLookAhead +***********************************************************************/ + + ParsingTokenWalker::ReduceLookAhead::ReduceLookAhead(const ParsingTokenWalker* _walker) + :walker(_walker) + { + } + + collections::IEnumerator* ParsingTokenWalker::ReduceLookAhead::CreateEnumerator()const + { + return new LookAheadEnumerator(walker, walker->currentToken - 1); + } + +/*********************************************************************** +ParsingTokenWalker +***********************************************************************/ + + vint ParsingTokenWalker::GetNextIndex(vint index)const + { + if(index==-2) + { + return -1; + } + else if(-1<=index && indexIsInputToken(tokens[index].token)) { - result = reading; break; } - reading++; - } - } - break; - } - return result == nullptr ? Pair(-1, 0) : Pair(result - text.Buffer(), find.Length()); -#endif - } - - collections::Pair Locale::FindLast(const WString& text, const WString& find, Normalization normalization)const - { -#if defined VCZH_MSVC - int length=0; - int result=FindNLSStringEx(localeName.Buffer(), FIND_FROMEND | TranslateNormalization(normalization), text.Buffer(), (int)text.Length(), find.Buffer(), (int)find.Length(), &length, NULL, NULL, NULL); - return result==-1?Pair(-1, 0):Pair(result, length); -#elif defined VCZH_GCC - if(text.Length() < find.Length() || find.Length() == 0) - { - return Pair(-1, 0); - } - const wchar_t* result = 0; - switch(normalization) - { - case Normalization::None: - { - const wchar_t* reading = text.Buffer(); - while(*reading) - { - if (wcsncmp(reading, find.Buffer(), find.Length())==0) + else { - result = reading; + index++; } - reading++; } + return index; } - break; - case Normalization::IgnoreCase: + else { - const wchar_t* reading = text.Buffer(); - while(*reading) + return -3; + } + } + + vint ParsingTokenWalker::GetTableTokenIndex(vint index)const + { + if(index==-1) + { + return ParsingTable::TokenBegin; + } + else if(index==tokens.Count()) + { + return ParsingTable::TokenFinish; + } + else if(0<=index && indexGetTableTokenIndex(tokens[index].token); + } + else + { + return -1; + } + } + + ParsingTokenWalker::ParsingTokenWalker(collections::List& _tokens, Ptr _table) + :tokens(_tokens) + ,table(_table) + ,currentToken(-2) + , tokenLookAhead(this) + , reduceLookAhead(this) + { + } + + ParsingTokenWalker::~ParsingTokenWalker() + { + } + + const collections::IEnumerable& ParsingTokenWalker::GetTokenLookahead()const + { + return tokenLookAhead; + } + + const collections::IEnumerable& ParsingTokenWalker::GetReduceLookahead()const + { + return reduceLookAhead; + } + + void ParsingTokenWalker::Reset() + { + currentToken=-2; + } + + bool ParsingTokenWalker::Move() + { + currentToken=GetNextIndex(currentToken); + return currentToken!=-3; + } + + vint ParsingTokenWalker::GetTableTokenIndex()const + { + return GetTableTokenIndex(currentToken); + } + + regex::RegexToken* ParsingTokenWalker::GetRegexToken()const + { + vint index=GetTokenIndexInStream(); + return index==-1?0:&tokens[index]; + } + + vint ParsingTokenWalker::GetTokenIndexInStream()const + { + if(0<=currentToken && currentToken _table, vint codeIndex) + :input(_input.Buffer()) + ,table(_table) + ,parsingRuleStartState(-1) + { + CopyFrom(tokens, table->GetLexer().Parse(input, codeIndex)); + walker=new ParsingTokenWalker(tokens, table); + } + + ParsingState::~ParsingState() + { + } + + const WString& ParsingState::GetInput() + { + return input; + } + + Ptr ParsingState::GetTable() + { + return table; + } + + const collections::List& ParsingState::GetTokens() + { + return tokens; + } + + regex::RegexToken* ParsingState::GetToken(vint index) + { + if(index<=0) + { + index=0; + } + else if(index>tokens.Count()) + { + index=tokens.Count(); + } + + return index==tokens.Count()?0:&tokens[index]; + } + + vint ParsingState::Reset(const WString& rule) + { + const ParsingTable::RuleInfo& info=table->GetRuleInfo(rule); + auto infoExists = &info; + if(infoExists) + { + walker->Reset(); + walker->Move(); + stateGroup=new StateGroup(info); + parsingRule=rule; + parsingRuleStartState=info.rootStartState; + return stateGroup->currentState; + } + return -1; + } + + WString ParsingState::GetParsingRule() + { + return parsingRule; + } + + vint ParsingState::GetParsingRuleStartState() + { + return parsingRuleStartState; + } + + vint ParsingState::GetCurrentToken() + { + return walker->GetTableTokenIndex()==ParsingTable::TokenFinish + ?tokens.Count() + :walker->GetTokenIndexInStream(); + } + + vint ParsingState::GetCurrentTableTokenIndex() + { + return walker->GetTableTokenIndex(); + } + + const collections::List& ParsingState::GetStateStack() + { + return stateGroup->stateStack; + } + + vint ParsingState::GetCurrentState() + { + return stateGroup->currentState; + } + + void ParsingState::SkipCurrentToken() + { + walker->Move(); + } + + bool ParsingState::TestTransitionItemInFuture(vint tableTokenIndex, Future* future, ParsingTable::TransitionItem* item, const collections::IEnumerable* lookAheadTokens) + { + bool passLookAheadTest=true; + if(item->lookAheads.Count()>0 && lookAheadTokens) + { + passLookAheadTest=false; + FOREACH(Ptr, info, item->lookAheads) { - if (wcsncasecmp(reading, find.Buffer(), find.Length())==0) + vint index=0; + FOREACH(vint, token, *lookAheadTokens) { - result = reading; + if(info->tokens[index]!=token) + { + break; + } + index++; + if(index>=info->tokens.Count()) + { + break; + } + } + if(index==info->tokens.Count()) + { + passLookAheadTest=true; + break; } - reading++; } } - break; - } - return result == nullptr ? Pair(-1, 0) : Pair(result - text.Buffer(), find.Length()); -#endif - } - - bool Locale::StartsWith(const WString& text, const WString& find, Normalization normalization)const - { -#if defined VCZH_MSVC - int result=FindNLSStringEx(localeName.Buffer(), FIND_STARTSWITH | TranslateNormalization(normalization), text.Buffer(), (int)text.Length(), find.Buffer(), (int)find.Length(), NULL, NULL, NULL, NULL); - return result!=-1; -#elif defined VCZH_GCC - if(text.Length() < find.Length() || find.Length() == 0) - { - return false; - } - switch(normalization) - { - case Normalization::None: - return wcsncmp(text.Buffer(), find.Buffer(), find.Length()) == 0; - case Normalization::IgnoreCase: - return wcsncasecmp(text.Buffer(), find.Buffer(), find.Length()) == 0; - } -#endif - } - - bool Locale::EndsWith(const WString& text, const WString& find, Normalization normalization)const - { -#if defined VCZH_MSVC - int result=FindNLSStringEx(localeName.Buffer(), FIND_ENDSWITH | TranslateNormalization(normalization), text.Buffer(), (int)text.Length(), find.Buffer(), (int)find.Length(), NULL, NULL, NULL, NULL); - return result!=-1; -#elif defined VCZH_GCC - if(text.Length() < find.Length() || find.Length() == 0) - { - return false; - } - switch(normalization) - { - case Normalization::None: - return wcsncmp(text.Buffer() + text.Length() - find.Length(), find.Buffer(), find.Length()) == 0; - case Normalization::IgnoreCase: - return wcsncasecmp(text.Buffer() + text.Length() - find.Length(), find.Buffer(), find.Length()) == 0; - } -#endif - } -} - -/*********************************************************************** -STRING.CPP -***********************************************************************/ -#if defined VCZH_MSVC -#elif defined VCZH_GCC -#define _strtoi64 strtoll -#define _strtoui64 strtoull -#define _wcstoi64 wcstoll -#define _wcstoui64 wcstoull -#endif - -namespace vl -{ -#if defined VCZH_GCC - void _itoa_s(vint32_t value, char* buffer, size_t size, vint radix) - { - sprintf(buffer, "%d", value); - } - - void _itow_s(vint32_t value, wchar_t* buffer, size_t size, vint radix) - { - swprintf(buffer, size - 1, L"%d", value); - } - - void _i64toa_s(vint64_t value, char* buffer, size_t size, vint radix) - { - sprintf(buffer, "%ld", value); - } - - void _i64tow_s(vint64_t value, wchar_t* buffer, size_t size, vint radix) - { - swprintf(buffer, size - 1, L"%ld", value); - } - - void _uitoa_s(vuint32_t value, char* buffer, size_t size, vint radix) - { - sprintf(buffer, "%u", value); - } - - void _uitow_s(vuint32_t value, wchar_t* buffer, size_t size, vint radix) - { - swprintf(buffer, size - 1, L"%u", value); - } - - void _ui64toa_s(vuint64_t value, char* buffer, size_t size, vint radix) - { - sprintf(buffer, "%lu", value); - } - - void _ui64tow_s(vuint64_t value, wchar_t* buffer, size_t size, vint radix) - { - swprintf(buffer, size - 1, L"%lu", value); - } - - void _gcvt_s(char* buffer, size_t size, double value, vint numberOfDigits) - { - sprintf(buffer, "%f", value); - char* point = strchr(buffer, '.'); - if(!point) return; - char* zero = buffer + strlen(buffer); - while(zero[-1] == '0') - { - *--zero = '\0'; - } - if(zero[-1] == '.') *--zero = '\0'; - } - - void _strlwr_s(char* buffer, size_t size) - { - while(*buffer) - { - *buffer=(char)tolower(*buffer); - buffer++; - } - } - - void _strupr_s(char* buffer, size_t size) - { - while(*buffer) - { - *buffer=(char)toupper(*buffer); - buffer++; - } - } - - void _wcslwr_s(wchar_t* buffer, size_t size) - { - while(*buffer) - { - *buffer=(char)towlower(*buffer); - buffer++; - } - } - - void _wcsupr_s(wchar_t* buffer, size_t size) - { - while(*buffer) - { - *buffer=(char)towupper(*buffer); - buffer++; - } - } -#endif - - vint atoi_test(const AString& string, bool& success) - { - char* endptr = 0; - vint result = strtol(string.Buffer(), &endptr, 10); - success = endptr == string.Buffer() + string.Length() && itoa(result) == string; - return result; - } - - vint wtoi_test(const WString& string, bool& success) - { - wchar_t* endptr = 0; - vint result = wcstol(string.Buffer(), &endptr, 10); - success = endptr == string.Buffer() + string.Length() && itow(result) == string; - return result; - } - - vint64_t atoi64_test(const AString& string, bool& success) - { - char* endptr = 0; - vint64_t result = _strtoi64(string.Buffer(), &endptr, 10); - success = endptr == string.Buffer() + string.Length() && i64toa(result) == string; - return result; - } - - vint64_t wtoi64_test(const WString& string, bool& success) - { - wchar_t* endptr = 0; - vint64_t result = _wcstoi64(string.Buffer(), &endptr, 10); - success = endptr == string.Buffer() + string.Length() && i64tow(result) == string; - return result; - } - - vuint atou_test(const AString& string, bool& success) - { - char* endptr = 0; - vuint result = strtoul(string.Buffer(), &endptr, 10); - success = endptr == string.Buffer() + string.Length() && utoa(result) == string; - return result; - } - - vuint wtou_test(const WString& string, bool& success) - { - wchar_t* endptr = 0; - vuint result = wcstoul(string.Buffer(), &endptr, 10); - success = endptr == string.Buffer() + string.Length() && utow(result) == string; - return result; - } - - vuint64_t atou64_test(const AString& string, bool& success) - { - char* endptr = 0; - vuint64_t result = _strtoui64(string.Buffer(), &endptr, 10); - success = endptr == string.Buffer() + string.Length() && u64toa(result) == string; - return result; - } - - vuint64_t wtou64_test(const WString& string, bool& success) - { - wchar_t* endptr = 0; - vuint64_t result = _wcstoui64(string.Buffer(), &endptr, 10); - success = endptr == string.Buffer() + string.Length() && u64tow(result) == string; - return result; - } - - double atof_test(const AString& string, bool& success) - { - char* endptr = 0; - double result = strtod(string.Buffer(), &endptr); - success = endptr == string.Buffer() + string.Length(); - return result; - } - - double wtof_test(const WString& string, bool& success) - { - wchar_t* endptr = 0; - double result = wcstod(string.Buffer(), &endptr); - success = endptr == string.Buffer() + string.Length(); - return result; - } - - vint atoi(const AString& string) - { - bool success = false; - return atoi_test(string, success); - } - - vint wtoi(const WString& string) - { - bool success = false; - return wtoi_test(string, success); - } - - vint64_t atoi64(const AString& string) - { - bool success = false; - return atoi64_test(string, success); - } - - vint64_t wtoi64(const WString& string) - { - bool success = false; - return wtoi64_test(string, success); - } - - vuint atou(const AString& string) - { - bool success = false; - return atou_test(string, success); - } - - vuint wtou(const WString& string) - { - bool success = false; - return wtou_test(string, success); - } - - vuint64_t atou64(const AString& string) - { - bool success = false; - return atou64_test(string, success); - } - - vuint64_t wtou64(const WString& string) - { - bool success = false; - return wtou64_test(string, success); - } - - double atof(const AString& string) - { - bool success = false; - return atof_test(string, success); - } - - double wtof(const WString& string) - { - bool success = false; - return wtof_test(string, success); - } - - AString itoa(vint number) - { - char buffer[100]; - ITOA_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10); - return buffer; - } - - WString itow(vint number) - { - wchar_t buffer[100]; - ITOW_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10); - return buffer; - } - - AString i64toa(vint64_t number) - { - char buffer[100]; - I64TOA_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10); - return buffer; - } - - WString i64tow(vint64_t number) - { - wchar_t buffer[100]; - I64TOW_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10); - return buffer; - } - - AString utoa(vuint number) - { - char buffer[100]; - UITOA_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10); - return buffer; - } - - WString utow(vuint number) - { - wchar_t buffer[100]; - UITOW_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10); - return buffer; - } - - AString u64toa(vuint64_t number) - { - char buffer[100]; - UI64TOA_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10); - return buffer; - } - - WString u64tow(vuint64_t number) - { - wchar_t buffer[100]; - UI64TOW_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10); - return buffer; - } - - AString ftoa(double number) - { - char buffer[320]; - _gcvt_s(buffer, 320, number, 30); - vint len = (vint)strlen(buffer); - if (buffer[len - 1] == '.') - { - buffer[len - 1] = '\0'; - } - return buffer; - } - - WString ftow(double number) - { - return atow(ftoa(number)); - } - - vint _wtoa(const wchar_t* w, char* a, vint chars) - { -#if defined VCZH_MSVC - return WideCharToMultiByte(CP_THREAD_ACP, 0, w, -1, a, (int)(a ? chars : 0), 0, 0); -#elif defined VCZH_GCC - return wcstombs(a, w, chars-1)+1; -#endif - } - - AString wtoa(const WString& string) - { - vint len = _wtoa(string.Buffer(), 0, 0); - char* buffer = new char[len]; - memset(buffer, 0, len*sizeof(*buffer)); - _wtoa(string.Buffer(), buffer, (int)len); - AString s = buffer; - delete[] buffer; - return s; - } - - vint _atow(const char* a, wchar_t* w, vint chars) - { -#if defined VCZH_MSVC - return MultiByteToWideChar(CP_THREAD_ACP, 0, a, -1, w, (int)(w ? chars : 0)); -#elif defined VCZH_GCC - return mbstowcs(w, a, chars-1)+1; -#endif - } - - WString atow(const AString& string) - { - vint len = _atow(string.Buffer(), 0, 0); - wchar_t* buffer = new wchar_t[len]; - memset(buffer, 0, len*sizeof(*buffer)); - _atow(string.Buffer(), buffer, (int)len); - WString s = buffer; - delete[] buffer; - return s; - } - - AString alower(const AString& string) - { - AString result = string.Buffer(); - _strlwr_s((char*)result.Buffer(), result.Length() + 1); - return result; - } - - WString wlower(const WString& string) - { - WString result = string.Buffer(); - _wcslwr_s((wchar_t*)result.Buffer(), result.Length() + 1); - return result; - } - - AString aupper(const AString& string) - { - AString result = string.Buffer(); - _strupr_s((char*)result.Buffer(), result.Length() + 1); - return result; - } - - WString wupper(const WString& string) - { - WString result = string.Buffer(); - _wcsupr_s((wchar_t*)result.Buffer(), result.Length() + 1); - return result; - } -} - -/*********************************************************************** -THREADING.CPP -***********************************************************************/ -#ifdef VCZH_MSVC - -namespace vl -{ - using namespace threading_internal; - using namespace collections; - -/*********************************************************************** -WaitableObject -***********************************************************************/ - - namespace threading_internal - { - struct WaitableData - { - HANDLE handle; - - WaitableData(HANDLE _handle) - :handle(_handle) - { - } - }; - } - - WaitableObject::WaitableObject() - :waitableData(0) - { - } - - void WaitableObject::SetData(threading_internal::WaitableData* data) - { - waitableData=data; - } - - bool WaitableObject::IsCreated() - { - return waitableData!=0; - } - - bool WaitableObject::Wait() - { - return WaitForTime(INFINITE); - } - - bool WaitableObject::WaitForTime(vint ms) - { - if(IsCreated()) - { - if(WaitForSingleObject(waitableData->handle, (DWORD)ms)==WAIT_OBJECT_0) - { - return true; - } - } - return false; - } - - bool WaitableObject::WaitAll(WaitableObject** objects, vint count) - { - Array handles(count); - for(vint i=0;iwaitableData->handle; - } - DWORD result=WaitForMultipleObjects((DWORD)count, &handles[0], TRUE, INFINITE); - return result==WAIT_OBJECT_0 || result==WAIT_ABANDONED_0; - - } - - bool WaitableObject::WaitAllForTime(WaitableObject** objects, vint count, vint ms) - { - Array handles(count); - for(vint i=0;iwaitableData->handle; - } - DWORD result=WaitForMultipleObjects((DWORD)count, &handles[0], TRUE, (DWORD)ms); - return result==WAIT_OBJECT_0 || result==WAIT_ABANDONED_0; - } - - vint WaitableObject::WaitAny(WaitableObject** objects, vint count, bool* abandoned) - { - Array handles(count); - for(vint i=0;iwaitableData->handle; - } - DWORD result=WaitForMultipleObjects((DWORD)count, &handles[0], FALSE, INFINITE); - if(WAIT_OBJECT_0 <= result && result handles(count); - for(vint i=0;iwaitableData->handle; - } - DWORD result=WaitForMultipleObjects((DWORD)count, &handles[0], FALSE, (DWORD)ms); - if(WAIT_OBJECT_0 <= result && resultdeleteAfterStopped; - ThreadLocalStorage::FixStorages(); - try + if(!passLookAheadTest) { - procedure(this, argument); - threadState=Thread::Stopped; - ThreadLocalStorage::ClearStorages(); + return false; } - catch (...) + + vint availableStackDepth=stateGroup->stateStack.Count()-future->reduceStateCount; + vint totalStackDepth=stateGroup->stateStack.Count()-future->reduceStateCount+future->shiftStates.Count(); + if(item->stackPattern.Count()<=totalStackDepth) { - ThreadLocalStorage::ClearStorages(); - throw; + if(tableTokenIndex!=ParsingTable::TokenFinish || item->stackPattern.Count()==totalStackDepth) + { + bool match=true; + for(vint j=0;jstackPattern.Count();j++) + { + vint state= + jshiftStates.Count() + ?future->shiftStates[future->shiftStates.Count()-1-j] + :stateGroup->stateStack[availableStackDepth-1-(j-future->shiftStates.Count())] + ; + if(item->stackPattern[j]!=state) + { + match=false; + } + } + if(match) + { + return true; + } + } } - if(deleteAfterStopped) - { - delete this; - } - } - public: - ProceduredThread(Thread::ThreadProcedure _procedure, void* _argument, bool _deleteAfterStopped) - :procedure(_procedure) - ,argument(_argument) - ,deleteAfterStopped(_deleteAfterStopped) - { - } - }; - - class LambdaThread : public Thread - { - private: - Func procedure; - bool deleteAfterStopped; - - protected: - void Run() - { - bool deleteAfterStopped = this->deleteAfterStopped; - ThreadLocalStorage::FixStorages(); - try - { - procedure(); - threadState=Thread::Stopped; - ThreadLocalStorage::ClearStorages(); - } - catch (...) - { - ThreadLocalStorage::ClearStorages(); - throw; - } - if(deleteAfterStopped) - { - delete this; - } - } - public: - LambdaThread(const Func& _procedure, bool _deleteAfterStopped) - :procedure(_procedure) - ,deleteAfterStopped(_deleteAfterStopped) - { - } - }; - } - - void InternalThreadProc(Thread* thread) - { - thread->Run(); - } - - DWORD WINAPI InternalThreadProcWrapper(LPVOID lpParameter) - { - InternalThreadProc((Thread*)lpParameter); - return 0; - } - - Thread::Thread() - { - internalData=new ThreadData; - internalData->handle=CreateThread(NULL, 0, InternalThreadProcWrapper, this, CREATE_SUSPENDED, &internalData->id); - threadState=Thread::NotStarted; - SetData(internalData); - } - - Thread::~Thread() - { - if (internalData) - { - Stop(); - CloseHandle(internalData->handle); - delete internalData; - } - } - - Thread* Thread::CreateAndStart(ThreadProcedure procedure, void* argument, bool deleteAfterStopped) - { - if(procedure) - { - Thread* thread=new ProceduredThread(procedure, argument, deleteAfterStopped); - if(thread->Start()) - { - return thread; - } - else - { - delete thread; - } - } - return 0; - } - - Thread* Thread::CreateAndStart(const Func& procedure, bool deleteAfterStopped) - { - Thread* thread=new LambdaThread(procedure, deleteAfterStopped); - if(thread->Start()) - { - return thread; - } - else - { - delete thread; - } - return 0; - } - - void Thread::Sleep(vint ms) - { - ::Sleep((DWORD)ms); - } - - - vint Thread::GetCPUCount() - { - SYSTEM_INFO info; - GetSystemInfo(&info); - return info.dwNumberOfProcessors; - } - - vint Thread::GetCurrentThreadId() - { - return (vint)::GetCurrentThreadId(); - } - - bool Thread::Start() - { - if(threadState==Thread::NotStarted && internalData->handle!=NULL) - { - if(ResumeThread(internalData->handle)!=-1) - { - threadState=Thread::Running; - return true; - } - } - return false; - } - - bool Thread::Stop() - { - if(internalData->handle!=NULL) - { - if (SuspendThread(internalData->handle) != -1) - { - threadState=Thread::Stopped; - return true; - } - } - return false; - } - - Thread::ThreadState Thread::GetState() - { - return threadState; - } - - void Thread::SetCPU(vint index) - { - SetThreadAffinityMask(internalData->handle, ((vint)1 << index)); - } - -/*********************************************************************** -Mutex -***********************************************************************/ - - namespace threading_internal - { - struct MutexData : public WaitableData - { - MutexData(HANDLE _handle) - :WaitableData(_handle) - { - } - }; - } - - Mutex::Mutex() - :internalData(0) - { - } - - Mutex::~Mutex() - { - if(internalData) - { - CloseHandle(internalData->handle); - delete internalData; - } - } - - bool Mutex::Create(bool owned, const WString& name) - { - if(IsCreated())return false; - BOOL aOwned=owned?TRUE:FALSE; - LPCTSTR aName=name==L""?NULL:name.Buffer(); - HANDLE handle=CreateMutex(NULL, aOwned, aName); - if(handle) - { - internalData=new MutexData(handle); - SetData(internalData); - } - return IsCreated(); - } - - bool Mutex::Open(bool inheritable, const WString& name) - { - if(IsCreated())return false; - BOOL aInteritable=inheritable?TRUE:FALSE; - HANDLE handle=OpenMutex(SYNCHRONIZE, aInteritable, name.Buffer()); - if(handle) - { - internalData=new MutexData(handle); - SetData(internalData); - } - return IsCreated(); - } - - bool Mutex::Release() - { - if(IsCreated()) - { - return ReleaseMutex(internalData->handle)!=0; - } - return false; - } - -/*********************************************************************** -Semaphore -***********************************************************************/ - - namespace threading_internal - { - struct SemaphoreData : public WaitableData - { - SemaphoreData(HANDLE _handle) - :WaitableData(_handle) - { - } - }; - } - - Semaphore::Semaphore() - :internalData(0) - { - } - - Semaphore::~Semaphore() - { - if(internalData) - { - CloseHandle(internalData->handle); - delete internalData; - } - } - - bool Semaphore::Create(vint initialCount, vint maxCount, const WString& name) - { - if(IsCreated())return false; - LONG aInitial=(LONG)initialCount; - LONG aMax=(LONG)maxCount; - LPCTSTR aName=name==L""?NULL:name.Buffer(); - HANDLE handle=CreateSemaphore(NULL, aInitial, aMax, aName); - if(handle) - { - internalData=new SemaphoreData(handle); - SetData(internalData); - } - return IsCreated(); - } - - bool Semaphore::Open(bool inheritable, const WString& name) - { - if(IsCreated())return false; - BOOL aInteritable=inheritable?TRUE:FALSE; - HANDLE handle=OpenSemaphore(SYNCHRONIZE, aInteritable, name.Buffer()); - if(handle) - { - internalData=new SemaphoreData(handle); - SetData(internalData); - } - return IsCreated(); - } - - bool Semaphore::Release() - { - if(IsCreated()) - { - return Release(1)!=-1; - } - return false; - } - - vint Semaphore::Release(vint count) - { - if(IsCreated()) - { - LONG previous=-1; - if(ReleaseSemaphore(internalData->handle, (LONG)count, &previous)!=0) - { - return (vint)previous; - } - } - return -1; - } - -/*********************************************************************** -EventObject -***********************************************************************/ - - namespace threading_internal - { - struct EventData : public WaitableData - { - EventData(HANDLE _handle) - :WaitableData(_handle) - { - } - }; - } - - EventObject::EventObject() - :internalData(0) - { - } - - EventObject::~EventObject() - { - if(internalData) - { - CloseHandle(internalData->handle); - delete internalData; - } - } - - bool EventObject::CreateAutoUnsignal(bool signaled, const WString& name) - { - if(IsCreated())return false; - BOOL aSignaled=signaled?TRUE:FALSE; - LPCTSTR aName=name==L""?NULL:name.Buffer(); - HANDLE handle=CreateEvent(NULL, FALSE, aSignaled, aName); - if(handle) - { - internalData=new EventData(handle); - SetData(internalData); - } - return IsCreated(); - } - - bool EventObject::CreateManualUnsignal(bool signaled, const WString& name) - { - if(IsCreated())return false; - BOOL aSignaled=signaled?TRUE:FALSE; - LPCTSTR aName=name==L""?NULL:name.Buffer(); - HANDLE handle=CreateEvent(NULL, TRUE, aSignaled, aName); - if(handle) - { - internalData=new EventData(handle); - SetData(internalData); - } - return IsCreated(); - } - - bool EventObject::Open(bool inheritable, const WString& name) - { - if(IsCreated())return false; - BOOL aInteritable=inheritable?TRUE:FALSE; - HANDLE handle=OpenEvent(SYNCHRONIZE, aInteritable, name.Buffer()); - if(handle) - { - internalData=new EventData(handle); - SetData(internalData); - } - return IsCreated(); - } - - bool EventObject::Signal() - { - if(IsCreated()) - { - return SetEvent(internalData->handle)!=0; - } - return false; - } - - bool EventObject::Unsignal() - { - if(IsCreated()) - { - return ResetEvent(internalData->handle)!=0; - } - return false; - } - -/*********************************************************************** -ThreadPoolLite -***********************************************************************/ - - struct ThreadPoolQueueProcArgument - { - void(*proc)(void*); - void* argument; - }; - - DWORD WINAPI ThreadPoolQueueProc(void* argument) - { - Ptr proc=(ThreadPoolQueueProcArgument*)argument; - ThreadLocalStorage::FixStorages(); - try - { - proc->proc(proc->argument); - ThreadLocalStorage::ClearStorages(); - } - catch (...) - { - ThreadLocalStorage::ClearStorages(); - } - return 0; - } - - DWORD WINAPI ThreadPoolQueueFunc(void* argument) - { - Ptr> proc=(Func*)argument; - ThreadLocalStorage::FixStorages(); - try - { - (*proc.Obj())(); - ThreadLocalStorage::ClearStorages(); - } - catch (...) - { - ThreadLocalStorage::ClearStorages(); - } - return 0; - } - - ThreadPoolLite::ThreadPoolLite() - { - } - - ThreadPoolLite::~ThreadPoolLite() - { - } - - bool ThreadPoolLite::Queue(void(*proc)(void*), void* argument) - { - ThreadPoolQueueProcArgument* p=new ThreadPoolQueueProcArgument; - p->proc=proc; - p->argument=argument; - if(QueueUserWorkItem(&ThreadPoolQueueProc, p, WT_EXECUTEDEFAULT)) - { - return true; - } - else - { - delete p; return false; } - } - bool ThreadPoolLite::Queue(const Func& proc) - { - Func* p=new Func(proc); - if(QueueUserWorkItem(&ThreadPoolQueueFunc, p, WT_EXECUTEDEFAULT)) + ParsingTable::TransitionItem* ParsingState::MatchTokenInFuture(vint tableTokenIndex, Future* future, const collections::IEnumerable* lookAheadTokens) { + ParsingTable::TransitionBag* bag=table->GetTransitionBag(future->currentState, tableTokenIndex).Obj(); + if(bag) + { + for(vint i=0;itransitionItems.Count();i++) + { + ParsingTable::TransitionItem* item=bag->transitionItems[i].Obj(); + if(TestTransitionItemInFuture(tableTokenIndex, future, item, lookAheadTokens)) + { + return item; + } + } + } + return 0; + } + + ParsingTable::TransitionItem* ParsingState::MatchToken(vint tableTokenIndex, const collections::IEnumerable* lookAheadTokens) + { + Future future; + future.currentState=stateGroup->currentState; + return MatchTokenInFuture(tableTokenIndex, &future, lookAheadTokens); + } + + void ParsingState::RunTransitionInFuture(ParsingTable::TransitionItem* transition, Future* previous, Future* now) + { + if(previous) + { + now->reduceStateCount=previous->reduceStateCount; + CopyFrom(now->shiftStates, previous->shiftStates); + } + else + { + now->reduceStateCount=0; + now->shiftStates.Clear(); + } + now->currentState=transition->targetState; + now->selectedToken=transition->token; + now->selectedItem=transition; + now->previous=previous; + now->next=0; + + for(vint j=0;jinstructions.Count();j++) + { + ParsingTable::Instruction& ins=transition->instructions[j]; + switch(ins.instructionType) + { + case ParsingTable::Instruction::Shift: + { + now->shiftStates.Add(ins.stateParameter); + } + break; + case ParsingTable::Instruction::Reduce: + { + if(now->shiftStates.Count()==0) + { + now->reduceStateCount++; + } + else + { + now->shiftStates.RemoveAt(now->shiftStates.Count()-1); + } + } + break; + default:; + } + } + } + + ParsingState::TransitionResult ParsingState::RunTransition(ParsingTable::TransitionItem* transition, regex::RegexToken* regexToken, vint instructionBegin, vint instructionCount, bool lastPart) + { + if(regexToken) + { + if(!stateGroup->shiftToken) + { + stateGroup->shiftToken=regexToken; + stateGroup->reduceToken=regexToken; + } + } + if(transition->token>=ParsingTable::UserTokenStart) + { + if(stateGroup->tokenSequenceIndex==0) + { + stateGroup->shiftTokenStack.Add(stateGroup->shiftToken); + } + stateGroup->tokenSequenceIndex++; + } + + TransitionResult result; + result.tableTokenIndex=transition->token; + result.token=regexToken; + result.tokenIndexInStream=regexToken?walker->GetTokenIndexInStream():-1; + result.tableStateSource=stateGroup->currentState; + result.tableStateTarget=transition->targetState; + result.transition=transition; + result.instructionBegin=instructionBegin; + result.instructionCount=instructionCount; + + for(vint j=instructionBegin;jinstructions[j]; + switch(ins.instructionType) + { + case ParsingTable::Instruction::Shift: + { + stateGroup->stateStack.Add(ins.stateParameter); + + stateGroup->shiftTokenStack.Add(stateGroup->shiftToken); + stateGroup->shiftToken=regexToken; + stateGroup->reduceToken=regexToken; + } + break; + case ParsingTable::Instruction::Reduce: + { + stateGroup->stateStack.RemoveAt(stateGroup->stateStack.Count()-1); + + result.AddShiftReduceRange(stateGroup->shiftToken, stateGroup->reduceToken); + stateGroup->shiftToken=stateGroup->shiftTokenStack[stateGroup->shiftTokenStack.Count()-1]; + stateGroup->shiftTokenStack.RemoveAt(stateGroup->shiftTokenStack.Count()-1); + } + break; + case ParsingTable::Instruction::LeftRecursiveReduce: + { + result.AddShiftReduceRange(stateGroup->shiftToken, stateGroup->reduceToken); + if(regexToken) + { + stateGroup->reduceToken=regexToken; + } + } + break; + default:; + } + } + + if(regexToken) + { + stateGroup->reduceToken=regexToken; + } + + if(transition->token==ParsingTable::TokenFinish && lastPart) + { + stateGroup->shiftToken=stateGroup->shiftTokenStack[stateGroup->shiftTokenStack.Count()-1]; + stateGroup->shiftTokenStack.RemoveAt(stateGroup->shiftTokenStack.Count()-1); + result.AddShiftReduceRange(stateGroup->shiftToken, stateGroup->reduceToken); + } + + stateGroup->currentState=transition->targetState; + return result; + } + + ParsingState::TransitionResult ParsingState::RunTransition(ParsingTable::TransitionItem* transition, regex::RegexToken* regexToken) + { + return RunTransition(transition, regexToken, 0, transition->instructions.Count(), true); + } + + bool ParsingState::ReadTokenInFuture(vint tableTokenIndex, Future* previous, Future* now, const collections::IEnumerable* lookAheadTokens) + { + ParsingTable::TransitionItem* selectedItem=0; + if(previous) + { + selectedItem=MatchTokenInFuture(tableTokenIndex, previous, lookAheadTokens); + } + else + { + selectedItem=MatchToken(tableTokenIndex, lookAheadTokens); + } + + if(!selectedItem) + { + return false; + } + RunTransitionInFuture(selectedItem, previous, now); return true; } - else + + ParsingState::TransitionResult ParsingState::ReadToken(vint tableTokenIndex, regex::RegexToken* regexToken, const collections::IEnumerable* lookAheadTokens) { - delete p; + ParsingTable::TransitionItem* item=MatchToken(tableTokenIndex, lookAheadTokens); + if(item) + { + return RunTransition(item, regexToken); + } + return TransitionResult(); + } + + ParsingState::TransitionResult ParsingState::ReadToken() + { + if(walker->GetTableTokenIndex()==-1) + { + return TransitionResult(); + } + vint token=walker->GetTableTokenIndex(); + RegexToken* regexToken=walker->GetRegexToken(); + + bool tryReduce=false; + TransitionResult result=ReadToken(token, regexToken, &walker->GetTokenLookahead()); + if(!result) + { + result=ReadToken(ParsingTable::LeftRecursiveReduce, 0, &walker->GetReduceLookahead()); + tryReduce=true; + } + if(!result) + { + result=ReadToken(ParsingTable::NormalReduce, 0, &walker->GetReduceLookahead()); + tryReduce=true; + } + + if(result && !tryReduce) + { + walker->Move(); + } + return result; + } + + bool ParsingState::TestExplore(vint tableTokenIndex, Future* previous) + { + Future fakePrevious; + fakePrevious.currentState=stateGroup->currentState; + Future* realPrevious=previous?previous:&fakePrevious; + + ParsingTable::TransitionBag* bag=table->GetTransitionBag(realPrevious->currentState, tableTokenIndex).Obj(); + if(bag) + { + for(vint i=0;itransitionItems.Count();i++) + { + ParsingTable::TransitionItem* item=bag->transitionItems[i].Obj(); + if(TestTransitionItemInFuture(tableTokenIndex, realPrevious, item, 0)) + { + return true; + } + } + } return false; } - } + + bool ParsingState::Explore(vint tableTokenIndex, Future* previous, collections::List& possibilities) + { + Future fakePrevious; + fakePrevious.currentState=stateGroup->currentState; + Future* realPrevious=previous?previous:&fakePrevious; + + ParsingTable::TransitionBag* bag=table->GetTransitionBag(realPrevious->currentState, tableTokenIndex).Obj(); + bool successful = false; + if(bag) + { + for(vint i=0;itransitionItems.Count();i++) + { + ParsingTable::TransitionItem* item=bag->transitionItems[i].Obj(); + if(TestTransitionItemInFuture(tableTokenIndex, realPrevious, item, 0)) + { + Future* now=new Future; + RunTransitionInFuture(item, previous, now); + possibilities.Add(now); + successful = true; + } + } + } + return successful; + } + + bool ParsingState::ExploreStep(collections::List& previousFutures, vint start, vint count, collections::List& possibilities) + { + if(walker->GetTableTokenIndex()==-1) + { + return false; + } + vint token = walker->GetTableTokenIndex(); + RegexToken* regexToken = walker->GetRegexToken(); + vint oldPossibilitiesCount = possibilities.Count(); + for (vint i = 0; iselectedRegexToken = regexToken; + } + return true; + } + + bool ParsingState::ExploreNormalReduce(collections::List& previousFutures, vint start, vint count, collections::List& possibilities) + { + if(walker->GetTableTokenIndex()==-1) + { + return false; + } + vint oldPossibilitiesCount = possibilities.Count(); + for(vint i=0;i oldPossibilitiesCount; + } + + bool ParsingState::ExploreLeftRecursiveReduce(collections::List& previousFutures, vint start, vint count, collections::List& possibilities) + { + if(walker->GetTableTokenIndex()==-1) + { + return false; + } + vint oldPossibilitiesCount = possibilities.Count(); + for(vint i=0;i oldPossibilitiesCount; + } + + ParsingState::Future* ParsingState::ExploreCreateRootFuture() + { + Future* future=new Future; + future->currentState=stateGroup->currentState; + return future; + } + + Ptr ParsingState::TakeSnapshot() + { + return new StateGroup(*stateGroup.Obj()); + } + + void ParsingState::RestoreSnapshot(Ptr group) + { + stateGroup=new StateGroup(*group.Obj()); + } /*********************************************************************** -CriticalSection +ParsingTreeBuilder ***********************************************************************/ - namespace threading_internal - { - struct CriticalSectionData - { - CRITICAL_SECTION criticalSection; - }; - } + ParsingTreeBuilder::ParsingTreeBuilder() + :processingAmbiguityBranch(false) + ,ambiguityBranchSharedNodeCount(0) + { + } - CriticalSection::Scope::Scope(CriticalSection& _criticalSection) - :criticalSection(&_criticalSection) - { - criticalSection->Enter(); - } + ParsingTreeBuilder::~ParsingTreeBuilder() + { + } - CriticalSection::Scope::~Scope() - { - criticalSection->Leave(); - } - - CriticalSection::CriticalSection() - { - internalData=new CriticalSectionData; - InitializeCriticalSection(&internalData->criticalSection); - } + void ParsingTreeBuilder::Reset() + { + createdObject=0; + operationTarget=new ParsingTreeObject(); + nodeStack.Clear(); - CriticalSection::~CriticalSection() - { - DeleteCriticalSection(&internalData->criticalSection); - delete internalData; - } + processingAmbiguityBranch=false; + ambiguityBranchCreatedObject=0; + ambiguityBranchOperationTarget=0; + ambiguityBranchSharedNodeCount=0; + ambiguityBranchNodeStack.Clear(); + ambiguityNodes.Clear(); + } - bool CriticalSection::TryEnter() - { - return TryEnterCriticalSection(&internalData->criticalSection)!=0; - } + bool ParsingTreeBuilder::Run(const ParsingState::TransitionResult& result) + { + if(!operationTarget) + { + return false; + } - void CriticalSection::Enter() - { - EnterCriticalSection(&internalData->criticalSection); - } + switch(result.transitionType) + { + case ParsingState::TransitionResult::AmbiguityBegin: + { + if(processingAmbiguityBranch) return false; + processingAmbiguityBranch=true; + if(createdObject) + { + ambiguityBranchCreatedObject=createdObject->Clone(); + } + else + { + ambiguityBranchCreatedObject=0; + } + ambiguityBranchOperationTarget=operationTarget->Clone().Cast(); + ambiguityBranchNodeStack.Clear(); + ambiguityBranchSharedNodeCount=nodeStack.Count()-result.ambiguityAffectedStackNodeCount+1; + for(vint i=ambiguityBranchSharedNodeCount;iClone().Cast()); + } + ambiguityNodes.Clear(); + } + break; + case ParsingState::TransitionResult::AmbiguityBranch: + { + if(!processingAmbiguityBranch) return false; + if(nodeStack.Count()!=ambiguityBranchSharedNodeCount) return false; + ambiguityNodes.Add(operationTarget); + if(ambiguityBranchCreatedObject) + { + createdObject=ambiguityBranchCreatedObject->Clone(); + } + else + { + createdObject=0; + } + operationTarget=ambiguityBranchOperationTarget->Clone().Cast(); + for(vint i=0;iClone().Cast()); + } + } + break; + case ParsingState::TransitionResult::AmbiguityEnd: + { + if(!processingAmbiguityBranch) return false; + if(nodeStack.Count()!=ambiguityBranchSharedNodeCount) return false; + ambiguityNodes.Add(operationTarget); - void CriticalSection::Leave() - { - LeaveCriticalSection(&internalData->criticalSection); - } + processingAmbiguityBranch=false; + createdObject=0; + ambiguityBranchCreatedObject=0; + ambiguityBranchOperationTarget=0; + ambiguityBranchSharedNodeCount=0; + ambiguityBranchNodeStack.Clear(); + + { + Ptr ambiguousNode=new ParsingTreeObject(result.ambiguityNodeType, operationTarget->GetCodeRange()); + Ptr items=new ParsingTreeArray(L"", operationTarget->GetCodeRange()); + FOREACH(Ptr, node, ambiguityNodes) + { + items->AddItem(node); + } + ambiguousNode->SetMember(L"items", items); + operationTarget=ambiguousNode; + } + ambiguityNodes.Clear(); + } + break; + case ParsingState::TransitionResult::ExecuteInstructions: + { + vint shiftReduceRangeIndex=0; + for(vint j=result.instructionBegin;jinstructions[j]; + switch(ins.instructionType) + { + case ParsingTable::Instruction::Create: + { + if(operationTarget->GetType()!=L"") + { + return false; + } + operationTarget->SetType(ins.nameParameter); + operationTarget->GetCreatorRules().Add(ins.creatorRule); + } + break; + case ParsingTable::Instruction::Using: + { + if(operationTarget->GetType()!=L"" || !createdObject) + { + return false; + } + Ptr obj=createdObject.Cast(); + if(!obj) + { + return false; + } + for(vint i=0;iGetMembers().Count();i++) + { + WString name=operationTarget->GetMembers().Keys().Get(i); + Ptr value=operationTarget->GetMembers().Values().Get(i); + obj->SetMember(name, value); + } + operationTarget=obj; + operationTarget->GetCreatorRules().Add(ins.creatorRule); + createdObject=0; + } + break; + case ParsingTable::Instruction::Assign: + { + if(!createdObject) + { + Ptr value; + if(result.token==0) + { + value=new ParsingTreeToken(L"", result.tokenIndexInStream); + } + else + { + value=new ParsingTreeToken(WString(result.token->reading, result.token->length), result.tokenIndexInStream); + value->SetCodeRange(ParsingTextRange(result.token, result.token)); + } + operationTarget->SetMember(ins.nameParameter, value); + } + else + { + operationTarget->SetMember(ins.nameParameter, createdObject); + createdObject=0; + } + } + break; + case ParsingTable::Instruction::Item: + { + Ptr arr=operationTarget->GetMember(ins.nameParameter).Cast();; + if(!arr) + { + arr=new ParsingTreeArray(); + operationTarget->SetMember(ins.nameParameter, arr); + } + ParsingTextRange arrRange=arr->GetCodeRange(); + ParsingTextRange itemRange; + if(!createdObject) + { + Ptr value; + if(result.token==0) + { + value=new ParsingTreeToken(L"", result.tokenIndexInStream); + } + else + { + value=new ParsingTreeToken(WString(result.token->reading, result.token->length), result.tokenIndexInStream); + value->SetCodeRange(ParsingTextRange(result.token, result.token)); + itemRange=value->GetCodeRange(); + } + arr->AddItem(value); + } + else + { + arr->AddItem(createdObject); + itemRange=createdObject->GetCodeRange(); + createdObject=0; + } + + if(arrRange.start.index==ParsingTextPos::UnknownValue || itemRange.startarrRange.end) + { + arrRange.end=itemRange.end; + } + arr->SetCodeRange(arrRange); + } + break; + case ParsingTable::Instruction::Setter: + { + Ptr value=new ParsingTreeToken(ins.value, -1); + operationTarget->SetMember(ins.nameParameter, value); + } + break; + case ParsingTable::Instruction::Shift: + { + nodeStack.Add(operationTarget); + operationTarget=new ParsingTreeObject(); + createdObject=0; + } + break; + case ParsingTable::Instruction::Reduce: + { + if(nodeStack.Count()==0) + { + return false; + } + createdObject=operationTarget; + operationTarget=nodeStack[nodeStack.Count()-1]; + nodeStack.RemoveAt(nodeStack.Count()-1); + + if(result.shiftReduceRanges) + { + ParsingState::ShiftReduceRange tokenRange=result.shiftReduceRanges->Get(shiftReduceRangeIndex++); + if(tokenRange.shiftToken && tokenRange.reduceToken) + { + ParsingTextRange codeRange(tokenRange.shiftToken, tokenRange.reduceToken); + createdObject->SetCodeRange(codeRange); + } + } + } + break; + case ParsingTable::Instruction::LeftRecursiveReduce: + { + createdObject=operationTarget; + operationTarget=new ParsingTreeObject(); + + if(result.shiftReduceRanges) + { + ParsingState::ShiftReduceRange tokenRange=result.shiftReduceRanges->Get(shiftReduceRangeIndex++); + if(tokenRange.shiftToken && tokenRange.reduceToken) + { + ParsingTextRange codeRange(tokenRange.shiftToken, tokenRange.reduceToken); + createdObject->SetCodeRange(codeRange); + } + } + } + break; + default: + return false; + } + } + + if(result.tableTokenIndex==ParsingTable::TokenFinish && !processingAmbiguityBranch) + { + if(result.shiftReduceRanges) + { + ParsingState::ShiftReduceRange tokenRange=result.shiftReduceRanges->Get(shiftReduceRangeIndex++); + if(tokenRange.shiftToken && tokenRange.reduceToken) + { + ParsingTextRange codeRange(tokenRange.shiftToken, tokenRange.reduceToken); + operationTarget->SetCodeRange(codeRange); + } + } + } + } + break; + default: + return false; + } + + return true; + } + + bool ParsingTreeBuilder::GetProcessingAmbiguityBranch() + { + return processingAmbiguityBranch; + } + + Ptr ParsingTreeBuilder::GetNode()const + { + if(nodeStack.Count()==0) + { + return operationTarget; + } + else + { + return 0; + } + } /*********************************************************************** -ReaderWriterLock +ParsingTransitionCollector ***********************************************************************/ - namespace threading_internal - { - struct ReaderWriterLockData - { - SRWLOCK lock; - }; - } + ParsingTransitionCollector::ParsingTransitionCollector() + :ambiguityBegin(-1) + { + } - ReaderWriterLock::ReaderScope::ReaderScope(ReaderWriterLock& _lock) - :lock(&_lock) - { - lock->EnterReader(); - } + ParsingTransitionCollector::~ParsingTransitionCollector() + { + } - ReaderWriterLock::ReaderScope::~ReaderScope() - { - lock->LeaveReader(); - } + void ParsingTransitionCollector::Reset() + { + ambiguityBegin=-1; + transitions.Clear(); + ambiguityBeginToEnds.Clear(); + ambiguityBeginToBranches.Clear(); + ambiguityBranchToBegins.Clear(); + } - ReaderWriterLock::WriterScope::WriterScope(ReaderWriterLock& _lock) - :lock(&_lock) - { - lock->EnterWriter(); - } + bool ParsingTransitionCollector::Run(const ParsingState::TransitionResult& result) + { + vint index=transitions.Count(); + switch(result.transitionType) + { + case ParsingState::TransitionResult::AmbiguityBegin: + if(ambiguityBegin!=-1) return false; + ambiguityBegin=index; + break; + case ParsingState::TransitionResult::AmbiguityBranch: + { + if(ambiguityBegin==-1) return false; + ambiguityBeginToBranches.Add(ambiguityBegin, index); + ambiguityBranchToBegins.Add(index, ambiguityBegin); + } + break; + case ParsingState::TransitionResult::AmbiguityEnd: + { + if(ambiguityBegin==-1) return false; + ambiguityBeginToEnds.Add(ambiguityBegin, index); + ambiguityBegin=-1; + } + break; + case ParsingState::TransitionResult::ExecuteInstructions: + break; + default: + return false; + } - ReaderWriterLock::WriterScope::~WriterScope() - { - lock->LeaveWriter(); - } + transitions.Add(result); + return true; + } - ReaderWriterLock::ReaderWriterLock() - :internalData(new threading_internal::ReaderWriterLockData) - { - InitializeSRWLock(&internalData->lock); - } + bool ParsingTransitionCollector::GetProcessingAmbiguityBranch() + { + return ambiguityBegin!=-1; + } - ReaderWriterLock::~ReaderWriterLock() - { - delete internalData; - } + const ParsingTransitionCollector::TransitionResultList& ParsingTransitionCollector::GetTransitions()const + { + return transitions; + } - bool ReaderWriterLock::TryEnterReader() - { - return TryAcquireSRWLockShared(&internalData->lock)!=0; - } + vint ParsingTransitionCollector::GetAmbiguityEndFromBegin(vint transitionIndex)const + { + vint index=ambiguityBeginToEnds.Keys().IndexOf(transitionIndex); + return index==-1?-1:ambiguityBeginToEnds.Values()[index]; + } - void ReaderWriterLock::EnterReader() - { - AcquireSRWLockShared(&internalData->lock); - } + const collections::List& ParsingTransitionCollector::GetAmbiguityBranchesFromBegin(vint transitionIndex)const + { + vint index=ambiguityBeginToBranches.Keys().IndexOf(transitionIndex); + return index==-1?*(collections::List*)0:ambiguityBeginToBranches.GetByIndex(index); + } - void ReaderWriterLock::LeaveReader() - { - ReleaseSRWLockShared(&internalData->lock); - } - - bool ReaderWriterLock::TryEnterWriter() - { - return TryAcquireSRWLockExclusive(&internalData->lock)!=0; - } - - void ReaderWriterLock::EnterWriter() - { - AcquireSRWLockExclusive(&internalData->lock); - } - - void ReaderWriterLock::LeaveWriter() - { - ReleaseSRWLockExclusive(&internalData->lock); - } - -/*********************************************************************** -ConditionVariable -***********************************************************************/ - - namespace threading_internal - { - struct ConditionVariableData - { - CONDITION_VARIABLE variable; - }; - } - - ConditionVariable::ConditionVariable() - :internalData(new threading_internal::ConditionVariableData) - { - InitializeConditionVariable(&internalData->variable); - } - - ConditionVariable::~ConditionVariable() - { - delete internalData; - } - - bool ConditionVariable::SleepWith(CriticalSection& cs) - { - return SleepConditionVariableCS(&internalData->variable, &cs.internalData->criticalSection, INFINITE)!=0; - } - - bool ConditionVariable::SleepWithForTime(CriticalSection& cs, vint ms) - { - return SleepConditionVariableCS(&internalData->variable, &cs.internalData->criticalSection, (DWORD)ms)!=0; - } - - bool ConditionVariable::SleepWithReader(ReaderWriterLock& lock) - { - return SleepConditionVariableSRW(&internalData->variable, &lock.internalData->lock, INFINITE, CONDITION_VARIABLE_LOCKMODE_SHARED)!=0; - } - - bool ConditionVariable::SleepWithReaderForTime(ReaderWriterLock& lock, vint ms) - { - return SleepConditionVariableSRW(&internalData->variable, &lock.internalData->lock, (DWORD)ms, CONDITION_VARIABLE_LOCKMODE_SHARED)!=0; - } - - bool ConditionVariable::SleepWithWriter(ReaderWriterLock& lock) - { - return SleepConditionVariableSRW(&internalData->variable, &lock.internalData->lock, INFINITE, 0)!=0; - } - - bool ConditionVariable::SleepWithWriterForTime(ReaderWriterLock& lock, vint ms) - { - return SleepConditionVariableSRW(&internalData->variable, &lock.internalData->lock, (DWORD)ms, 0)!=0; - } - - void ConditionVariable::WakeOnePending() - { - WakeConditionVariable(&internalData->variable); - } - - void ConditionVariable::WakeAllPendings() - { - WakeAllConditionVariable(&internalData->variable); - } - -/*********************************************************************** -SpinLock -***********************************************************************/ - - SpinLock::Scope::Scope(SpinLock& _spinLock) - :spinLock(&_spinLock) - { - spinLock->Enter(); - } - - SpinLock::Scope::~Scope() - { - spinLock->Leave(); - } - - SpinLock::SpinLock() - :token(0) - { - } - - SpinLock::~SpinLock() - { - } - - bool SpinLock::TryEnter() - { - return _InterlockedExchange(&token, 1)==0; - } - - void SpinLock::Enter() - { - while(_InterlockedCompareExchange(&token, 1, 0)!=0) - { - while(token!=0) _mm_pause(); + vint ParsingTransitionCollector::GetAmbiguityBeginFromBranch(vint transitionIndex)const + { + vint index=ambiguityBranchToBegins.Keys().IndexOf(transitionIndex); + return index==-1?-1:ambiguityBranchToBegins.Values()[index]; + } } } - - void SpinLock::Leave() - { - _InterlockedExchange(&token, 0); - } - -/*********************************************************************** -ThreadLocalStorage -***********************************************************************/ - -#define KEY ((DWORD&)key) - - ThreadLocalStorage::ThreadLocalStorage(Destructor _destructor) - :destructor(_destructor) - { - static_assert(sizeof(key) >= sizeof(DWORD), "ThreadLocalStorage's key storage is not large enouth."); - PushStorage(this); - KEY = TlsAlloc(); - CHECK_ERROR(KEY != TLS_OUT_OF_INDEXES, L"vl::ThreadLocalStorage::ThreadLocalStorage()#Failed to alloc new thread local storage index."); - } - - ThreadLocalStorage::~ThreadLocalStorage() - { - TlsFree(KEY); - } - - void* ThreadLocalStorage::Get() - { - CHECK_ERROR(!disposed, L"vl::ThreadLocalStorage::Get()#Cannot access a disposed ThreadLocalStorage."); - return TlsGetValue(KEY); - } - - void ThreadLocalStorage::Set(void* data) - { - CHECK_ERROR(!disposed, L"vl::ThreadLocalStorage::Set()#Cannot access a disposed ThreadLocalStorage."); - TlsSetValue(KEY, data); - } - -#undef KEY } -#endif + /*********************************************************************** -ThreadLocalStorage Common Implementations +.\PARSING\PARSINGTABLE.CPP ***********************************************************************/ namespace vl { - void ThreadLocalStorage::Clear() + namespace stream { - CHECK_ERROR(!disposed, L"vl::ThreadLocalStorage::Clear()#Cannot access a disposed ThreadLocalStorage."); - if(destructor) + namespace internal { - if (auto data = Get()) - { - destructor(data); - } - } - Set(nullptr); - } - - void ThreadLocalStorage::Dispose() - { - CHECK_ERROR(!disposed, L"vl::ThreadLocalStorage::Dispose()#Cannot access a disposed ThreadLocalStorage."); - Clear(); - disposed = true; - } - - struct TlsStorageLink - { - ThreadLocalStorage* storage = nullptr; - TlsStorageLink* next = nullptr; - }; - - volatile bool tlsFixed = false; - TlsStorageLink* tlsHead = nullptr; - TlsStorageLink** tlsTail = &tlsHead; - - void ThreadLocalStorage::PushStorage(ThreadLocalStorage* storage) - { - CHECK_ERROR(!tlsFixed, L"vl::ThreadLocalStorage::PushStorage(ThreadLocalStorage*)#Cannot create new ThreadLocalStorage instance after calling ThreadLocalStorage::FixStorages()."); - auto link = new TlsStorageLink; - link->storage = storage; - *tlsTail = link; - tlsTail = &link->next; - } - - void ThreadLocalStorage::FixStorages() - { - tlsFixed = true; - } - - void ThreadLocalStorage::ClearStorages() - { - FixStorages(); - auto current = tlsHead; - while (current) - { - current->storage->Clear(); - current = current->next; - } - } - - void ThreadLocalStorage::DisposeStorages() - { - FixStorages(); - auto current = tlsHead; - tlsHead = nullptr; - tlsTail = nullptr; - while (current) - { - current->storage->Dispose(); - - auto temp = current; - current = current->next; - delete temp; - } - } -} + using namespace vl::parsing::tabling; /*********************************************************************** -THREADINGLINUX.CPP +ParsingTable (Serialization) ***********************************************************************/ + + BEGIN_SERIALIZATION(ParsingTable::AttributeInfo) + SERIALIZE(name) + SERIALIZE(arguments) + END_SERIALIZATION + + BEGIN_SERIALIZATION(ParsingTable::AttributeInfoList) + SERIALIZE(attributes) + END_SERIALIZATION + + BEGIN_SERIALIZATION(ParsingTable::TreeTypeInfo) + SERIALIZE(type) + SERIALIZE(attributeIndex) + END_SERIALIZATION + + BEGIN_SERIALIZATION(ParsingTable::TreeFieldInfo) + SERIALIZE(type) + SERIALIZE(field) + SERIALIZE(attributeIndex) + END_SERIALIZATION + + BEGIN_SERIALIZATION(ParsingTable::TokenInfo) + SERIALIZE(name) + SERIALIZE(regex) + SERIALIZE(regexTokenIndex) + SERIALIZE(attributeIndex) + END_SERIALIZATION + + BEGIN_SERIALIZATION(ParsingTable::StateInfo) + SERIALIZE(ruleName) + SERIALIZE(stateName) + SERIALIZE(stateExpression) + END_SERIALIZATION + + BEGIN_SERIALIZATION(ParsingTable::RuleInfo) + SERIALIZE(name) + SERIALIZE(type) + SERIALIZE(ambiguousType) + SERIALIZE(rootStartState) + SERIALIZE(attributeIndex) + END_SERIALIZATION + + BEGIN_SERIALIZATION(ParsingTable::Instruction) + SERIALIZE(instructionType) + SERIALIZE(stateParameter) + SERIALIZE(nameParameter) + SERIALIZE(value) + SERIALIZE(creatorRule) + END_SERIALIZATION + + SERIALIZE_ENUM(ParsingTable::Instruction::InstructionType) + + BEGIN_SERIALIZATION(ParsingTable::LookAheadInfo) + SERIALIZE(tokens) + SERIALIZE(state) + END_SERIALIZATION + + BEGIN_SERIALIZATION(ParsingTable::TransitionItem) + SERIALIZE(token) + SERIALIZE(targetState) + SERIALIZE(lookAheads) + SERIALIZE(stackPattern) + SERIALIZE(instructions) + END_SERIALIZATION + + BEGIN_SERIALIZATION(ParsingTable::TransitionBag) + SERIALIZE(transitionItems) + END_SERIALIZATION + } + } + + namespace parsing + { + namespace tabling + { + using namespace collections; + using namespace regex; + #ifdef VCZH_GCC -#include -#include -#include -#include -#if defined(__APPLE__) || defined(__APPLE_CC__) -#include + const vint ParsingTable::TokenBegin; + const vint ParsingTable::TokenFinish; + const vint ParsingTable::NormalReduce; + const vint ParsingTable::LeftRecursiveReduce; + const vint ParsingTable::UserTokenStart; #endif +/*********************************************************************** +ParsingTable::AttributeInfoList +***********************************************************************/ + + Ptr ParsingTable::AttributeInfoList::FindFirst(const WString& name) + { + for(vint i=0;iname==name) + { + return attributes[i]; + } + } + return 0; + } + +/*********************************************************************** +ParsingTable::LookAheadInfo +***********************************************************************/ + + ParsingTable::LookAheadInfo::PrefixResult ParsingTable::LookAheadInfo::TestPrefix(Ptr a, Ptr b) + { + if(a->tokens.Count()>b->tokens.Count()) + { + return ParsingTable::LookAheadInfo::NotPrefix; + } + for(vint i=0;itokens.Count();i++) + { + if(a->tokens[i]!=b->tokens[i]) + { + return ParsingTable::LookAheadInfo::NotPrefix; + } + } + return a->tokens.Count()tokens.Count()?ParsingTable::LookAheadInfo::Prefix:ParsingTable::LookAheadInfo::Equal; + } + + void ParsingTable::LookAheadInfo::WalkInternal(Ptr table, Ptr previous, vint state, collections::SortedList& walkedStates, collections::List>& newInfos) + { + if (walkedStates.Contains(state)) return; + walkedStates.Add(state); + + for (vint i = 0; i < table->GetTokenCount(); i++) + { + if(Ptr bag=table->GetTransitionBag(state, i)) + { + FOREACH(Ptr, item, bag->transitionItems) + { + if (i == ParsingTable::NormalReduce || i == ParsingTable::LeftRecursiveReduce) + { + WalkInternal(table, previous, item->targetState, walkedStates, newInfos); + } + else + { + Ptr info=new LookAheadInfo; + info->state=item->targetState; + if(previous) + { + CopyFrom(info->tokens, previous->tokens); + } + info->tokens.Add(i); + newInfos.Add(info); + } + } + } + } + + walkedStates.Remove(state); + } + + void ParsingTable::LookAheadInfo::Walk(Ptr table, Ptr previous, vint state, collections::List>& newInfos) + { + SortedList walkedStates; + WalkInternal(table, previous, state, walkedStates, newInfos); + } + +/*********************************************************************** +ParsingTable::TransitionItem +***********************************************************************/ + + enum TransitionLevel + { + ReduceTransition, + LeftRecursiveReduceTransition, + NormalTransition, + }; + + TransitionLevel GetTransitionLevel(Ptr t) + { + bool hasReduce=false; + bool hasLrReduce=false; + FOREACH(ParsingTable::Instruction, ins, t->instructions) + { + switch(ins.instructionType) + { + case ParsingTable::Instruction::Reduce: + hasReduce=true; + break; + case ParsingTable::Instruction::LeftRecursiveReduce: + hasLrReduce=true; + break; + default:; + } + } + + return + hasLrReduce?LeftRecursiveReduceTransition: + hasReduce?ReduceTransition: + NormalTransition; + } + + ParsingTable::TransitionItem::OrderResult ParsingTable::TransitionItem::CheckOrder(Ptr t1, Ptr t2, bool forceGivingOrder) + { + if(t1->token!=t2->token) return UnknownOrder; + if(forceGivingOrder) + { + TransitionLevel level1=GetTransitionLevel(t1); + TransitionLevel level2=GetTransitionLevel(t2); + if(level1>level2) return CorrectOrder; + if(level1stackPattern.Count(); + vint ic2=t2->stackPattern.Count(); + vint ic=ic1stackPattern[i]; + vint s2=t2->stackPattern[i]; + + if(s1>s2) + { + return CorrectOrder; + } + else if(s1token==TokenFinish) + { + if(ic1>ic2) + { + return CorrectOrder; + } + else if(ic1t2?CorrectOrder:SameOrder; + } + else + { + return UnknownOrder; + } + } + + vint ParsingTable::TransitionItem::Compare(Ptr t1, Ptr t2) + { + OrderResult order=CheckOrder(t1, t2, true); + switch(order) + { + case CorrectOrder: return -1; + case WrongOrder: return 1; + default: return 0; + } + } + + template + void ParsingTable::IO(TIO& io) + { + io + << ambiguity + << attributeInfos + << treeTypeInfos + << treeFieldInfos + << tokenCount + << stateCount + << tokenInfos + << discardTokenInfos + << stateInfos + << ruleInfos + << transitionBags + ; + } + + ParsingTable::ParsingTable(stream::IStream& input) + { + stream::internal::ContextFreeReader reader(input); + IO(reader); + } + + void ParsingTable::Serialize(stream::IStream& output) + { + stream::internal::ContextFreeWriter writer(output); + IO(writer); + } + +/*********************************************************************** +ParsingTable +***********************************************************************/ + + ParsingTable::ParsingTable(vint _attributeInfoCount, vint _treeTypeInfoCount, vint _treeFieldInfoCount, vint _tokenCount, vint discardTokenCount, vint _stateCount, vint _ruleCount) + :ambiguity(false) + ,tokenCount(_tokenCount+UserTokenStart) + ,stateCount(_stateCount) + ,attributeInfos(_attributeInfoCount) + ,treeTypeInfos(_treeTypeInfoCount) + ,treeFieldInfos(_treeFieldInfoCount) + ,tokenInfos(_tokenCount+UserTokenStart) + ,discardTokenInfos(discardTokenCount) + ,stateInfos(_stateCount) + ,ruleInfos(_ruleCount) + ,transitionBags((_tokenCount+UserTokenStart)*_stateCount) + { + } + + ParsingTable::~ParsingTable() + { + } + + bool ParsingTable::GetAmbiguity() + { + return ambiguity; + } + + void ParsingTable::SetAmbiguity(bool value) + { + ambiguity=value; + } + + vint ParsingTable::GetAttributeInfoCount() + { + return attributeInfos.Count(); + } + + Ptr ParsingTable::GetAttributeInfo(vint index) + { + return attributeInfos[index]; + } + + void ParsingTable::SetAttributeInfo(vint index, Ptr info) + { + attributeInfos[index]=info; + } + + vint ParsingTable::GetTreeTypeInfoCount() + { + return treeTypeInfos.Count(); + } + + const ParsingTable::TreeTypeInfo& ParsingTable::GetTreeTypeInfo(vint index) + { + return treeTypeInfos[index]; + } + + const ParsingTable::TreeTypeInfo& ParsingTable::GetTreeTypeInfo(const WString& type) + { + vint index=treeTypeInfoMap.Keys().IndexOf(type); + if(index==-1) return *(const TreeTypeInfo*)0; + return treeTypeInfos[treeTypeInfoMap.Values().Get(index)]; + } + + void ParsingTable::SetTreeTypeInfo(vint index, const TreeTypeInfo& info) + { + treeTypeInfos[index]=info; + } + + vint ParsingTable::GetTreeFieldInfoCount() + { + return treeFieldInfos.Count(); + } + + const ParsingTable::TreeFieldInfo& ParsingTable::GetTreeFieldInfo(vint index) + { + return treeFieldInfos[index]; + } + + const ParsingTable::TreeFieldInfo& ParsingTable::GetTreeFieldInfo(const WString& type, const WString& field) + { + Pair key(type, field); + vint index=treeFieldInfoMap.Keys().IndexOf(key); + if(index==-1) return *(const TreeFieldInfo*)0; + return treeFieldInfos[treeFieldInfoMap.Values().Get(index)]; + } + + void ParsingTable::SetTreeFieldInfo(vint index, const TreeFieldInfo& info) + { + treeFieldInfos[index]=info; + } + + vint ParsingTable::GetTokenCount() + { + return tokenCount; + } + + const ParsingTable::TokenInfo& ParsingTable::GetTokenInfo(vint token) + { + return tokenInfos[token]; + } + + void ParsingTable::SetTokenInfo(vint token, const TokenInfo& info) + { + tokenInfos[token]=info; + } + + vint ParsingTable::GetDiscardTokenCount() + { + return discardTokenInfos.Count(); + } + + const ParsingTable::TokenInfo& ParsingTable::GetDiscardTokenInfo(vint token) + { + return discardTokenInfos[token]; + } + + void ParsingTable::SetDiscardTokenInfo(vint token, const TokenInfo& info) + { + discardTokenInfos[token]=info; + } + + vint ParsingTable::GetStateCount() + { + return stateCount; + } + + const ParsingTable::StateInfo& ParsingTable::GetStateInfo(vint state) + { + return stateInfos[state]; + } + + void ParsingTable::SetStateInfo(vint state, const StateInfo& info) + { + stateInfos[state]=info; + } + + vint ParsingTable::GetRuleCount() + { + return ruleInfos.Count(); + } + + const ParsingTable::RuleInfo& ParsingTable::GetRuleInfo(const WString& ruleName) + { + vint index=ruleMap.Keys().IndexOf(ruleName); + if(index==-1) return *(const RuleInfo*)0; + return ruleInfos[ruleMap.Values().Get(index)]; + } + + const ParsingTable::RuleInfo& ParsingTable::GetRuleInfo(vint rule) + { + return ruleInfos[rule]; + } + + void ParsingTable::SetRuleInfo(vint rule, const RuleInfo& info) + { + ruleInfos[rule]=info; + } + + const regex::RegexLexer& ParsingTable::GetLexer() + { + return *lexer.Obj(); + } + + Ptr ParsingTable::GetTransitionBag(vint state, vint token) + { + return transitionBags[state*tokenCount+token]; + } + + void ParsingTable::SetTransitionBag(vint state, vint token, Ptr bag) + { + transitionBags[state*tokenCount+token]=bag; + } + + void ParsingTable::Initialize() + { + List tokens; + FOREACH(TokenInfo, info, From(tokenInfos).Skip(UserTokenStart)) + { + tokens.Add(info.regex); + } + FOREACH(TokenInfo, info, discardTokenInfos) + { + tokens.Add(info.regex); + } + + vint regexTokenIndex=0; + for(vint i=UserTokenStart;i key(info.type, info.field); + treeFieldInfoMap.Add(key, index); + } + } + + bool ParsingTable::IsInputToken(vint regexTokenIndex) + { + return regexTokenIndex>=0 && regexTokenIndex=tokenCount-UserTokenStart?regexTokenIndex-(tokenCount-UserTokenStart):-1; + } + } + } +} + + +/*********************************************************************** +.\PARSING\PARSINGTREE.CPP +***********************************************************************/ namespace vl { - using namespace threading_internal; using namespace collections; + namespace parsing + { + vint CompareTextRange(Ptr r1, Ptr r2) + { + return ParsingTextPos::Compare(r1->GetCodeRange().start, r2->GetCodeRange().start); + } /*********************************************************************** -Thread +ParsingTreeNode::TraversalVisitor ***********************************************************************/ - namespace threading_internal - { - struct ThreadData + ParsingTreeNode::TraversalVisitor::TraversalVisitor(TraverseDirection _direction) + :direction(_direction) { - pthread_t id; - EventObject ev; - }; + } - class ProceduredThread : public Thread + void ParsingTreeNode::TraversalVisitor::BeforeVisit(ParsingTreeToken* node) { - private: - Thread::ThreadProcedure procedure; - void* argument; - bool deleteAfterStopped; + } - protected: - void Run() + void ParsingTreeNode::TraversalVisitor::AfterVisit(ParsingTreeToken* node) + { + } + + void ParsingTreeNode::TraversalVisitor::BeforeVisit(ParsingTreeObject* node) + { + } + + void ParsingTreeNode::TraversalVisitor::AfterVisit(ParsingTreeObject* node) + { + } + + void ParsingTreeNode::TraversalVisitor::BeforeVisit(ParsingTreeArray* node) + { + } + + void ParsingTreeNode::TraversalVisitor::AfterVisit(ParsingTreeArray* node) + { + } + + void ParsingTreeNode::TraversalVisitor::Visit(ParsingTreeToken* node) + { + BeforeVisit(node); + AfterVisit(node); + } + + void ParsingTreeNode::TraversalVisitor::Visit(ParsingTreeObject* node) + { + BeforeVisit(node); + switch(direction) { - bool deleteAfterStopped = this->deleteAfterStopped; - ThreadLocalStorage::FixStorages(); - try + case TraverseDirection::ByTextPosition: { - procedure(this, argument); - threadState=Thread::Stopped; - internalData->ev.Signal(); - ThreadLocalStorage::ClearStorages(); + FOREACH(Ptr, node, node->GetSubNodes()) + { + node->Accept(this); + } } - catch (...) + break; + case TraverseDirection::ByStorePosition: { - ThreadLocalStorage::ClearStorages(); - throw; + FOREACH(Ptr, node, node->GetMembers().Values()) + { + node->Accept(this); + } } - if(deleteAfterStopped) + break; + } + AfterVisit(node); + } + + void ParsingTreeNode::TraversalVisitor::Visit(ParsingTreeArray* node) + { + BeforeVisit(node); + switch(direction) + { + case TraverseDirection::ByTextPosition: { - delete this; + FOREACH(Ptr, node, node->GetSubNodes()) + { + node->Accept(this); + } } - } - public: - ProceduredThread(Thread::ThreadProcedure _procedure, void* _argument, bool _deleteAfterStopped) - :procedure(_procedure) - ,argument(_argument) - ,deleteAfterStopped(_deleteAfterStopped) - { - } - }; - - class LambdaThread : public Thread - { - private: - Func procedure; - bool deleteAfterStopped; - - protected: - void Run() - { - bool deleteAfterStopped = this->deleteAfterStopped; - ThreadLocalStorage::FixStorages(); - try + break; + case TraverseDirection::ByStorePosition: { - procedure(); - threadState=Thread::Stopped; - internalData->ev.Signal(); - ThreadLocalStorage::ClearStorages(); - } - catch (...) - { - ThreadLocalStorage::ClearStorages(); - throw; - } - if(deleteAfterStopped) - { - delete this; + FOREACH(Ptr, node, node->GetItems()) + { + node->Accept(this); + } } + break; } - public: - LambdaThread(const Func& _procedure, bool _deleteAfterStopped) - :procedure(_procedure) - ,deleteAfterStopped(_deleteAfterStopped) - { - } - }; - } - - void InternalThreadProc(Thread* thread) - { - thread->Run(); - } - - void* InternalThreadProcWrapper(void* lpParameter) - { - InternalThreadProc((Thread*)lpParameter); - return 0; - } - - Thread::Thread() - { - internalData=new ThreadData; - internalData->ev.CreateManualUnsignal(false); - threadState=Thread::NotStarted; - } - - Thread::~Thread() - { - if (internalData) - { - Stop(); - if (threadState!=Thread::NotStarted) - { - pthread_detach(internalData->id); - } - delete internalData; + AfterVisit(node); } - } - - Thread* Thread::CreateAndStart(ThreadProcedure procedure, void* argument, bool deleteAfterStopped) - { - if(procedure) - { - Thread* thread=new ProceduredThread(procedure, argument, deleteAfterStopped); - if(thread->Start()) - { - return thread; - } - else - { - delete thread; - } - } - return 0; - } - - Thread* Thread::CreateAndStart(const Func& procedure, bool deleteAfterStopped) - { - Thread* thread=new LambdaThread(procedure, deleteAfterStopped); - if(thread->Start()) - { - return thread; - } - else - { - delete thread; - } - return 0; - } - - void Thread::Sleep(vint ms) - { - if (ms >= 1000) - { - sleep(ms / 1000); - } - if (ms % 1000) - { - usleep((ms % 1000) * 1000); - } - } - - vint Thread::GetCPUCount() - { - return (vint)sysconf(_SC_NPROCESSORS_ONLN); - } - - vint Thread::GetCurrentThreadId() - { - return (vint)::pthread_self(); - } - - bool Thread::Start() - { - if(threadState==Thread::NotStarted) - { - if(pthread_create(&internalData->id, nullptr, &InternalThreadProcWrapper, this)==0) - { - threadState=Thread::Running; - return true; - } - } - return false; - } - - bool Thread::Wait() - { - return internalData->ev.Wait(); - } - - bool Thread::Stop() - { - if (threadState==Thread::Running) - { - if(pthread_cancel(internalData->id)==0) - { - threadState=Thread::Stopped; - internalData->ev.Signal(); - return true; - } - } - return false; - } - - Thread::ThreadState Thread::GetState() - { - return threadState; - } /*********************************************************************** -Mutex +ParsingTreeNode ***********************************************************************/ - namespace threading_internal - { - struct MutexData + bool ParsingTreeNode::BeforeAddChild(Ptr node) { - Semaphore sem; - }; - }; + return node->parent==0; + } - Mutex::Mutex() - { - internalData = new MutexData; - } + void ParsingTreeNode::AfterAddChild(Ptr node) + { + node->parent=this; + ClearQueryCache(); + } - Mutex::~Mutex() - { - delete internalData; - } + bool ParsingTreeNode::BeforeRemoveChild(Ptr node) + { + return node->parent!=0; + } - bool Mutex::Create(bool owned, const WString& name) - { - return internalData->sem.Create(owned ? 0 : 1, 1, name); - } + void ParsingTreeNode::AfterRemoveChild(Ptr node) + { + node->parent=0; + ClearQueryCache(); + } - bool Mutex::Open(bool inheritable, const WString& name) - { - return internalData->sem.Open(inheritable, name); - } + ParsingTreeNode::ParsingTreeNode(const ParsingTextRange& _codeRange) + :codeRange(_codeRange) + ,parent(0) + { + } - bool Mutex::Release() - { - return internalData->sem.Release(); - } + ParsingTreeNode::~ParsingTreeNode() + { + } - bool Mutex::Wait() - { - return internalData->sem.Wait(); - } + ParsingTextRange ParsingTreeNode::GetCodeRange() + { + return codeRange; + } + + void ParsingTreeNode::SetCodeRange(const ParsingTextRange& range) + { + codeRange=range; + } + + void ParsingTreeNode::InitializeQueryCache() + { + const NodeList& subNodes=GetSubNodesInternal(); + ClearQueryCache(); + auto subNodesExists = &subNodes; + if(subNodesExists) + { + FOREACH(Ptr, node, subNodes) + { + node->InitializeQueryCache(); + } + + //if (codeRange.start.IsInvalid() || codeRange.start.IsInvalid()) + { + FOREACH(Ptr, subNode, subNodes) + { + const auto& subRange = subNode->codeRange; + const auto& min = !subRange.start.IsInvalid() ? subRange.start : subRange.end; + const auto& max = !subRange.end.IsInvalid() ? subRange.end : subRange.start; + + if (codeRange.start.IsInvalid() || (!min.IsInvalid() && codeRange.start > min)) + { + codeRange.start = min; + } + if (codeRange.end.IsInvalid() || (!max.IsInvalid() && codeRange.end < max)) + { + codeRange.end = max; + } + } + } + + CopyFrom( + cachedOrderedSubNodes, + From(subNodes) + .Where([=](Ptr node) + { + const auto& range = node->GetCodeRange(); + return !range.start.IsInvalid() && !range.end.IsInvalid(); + }) + .OrderBy(&CompareTextRange) + ); + } + } + + void ParsingTreeNode::ClearQueryCache() + { + cachedOrderedSubNodes.Clear(); + } + + ParsingTreeNode* ParsingTreeNode::GetParent() + { + return parent; + } + + const ParsingTreeNode::NodeList& ParsingTreeNode::GetSubNodes() + { + return cachedOrderedSubNodes; + } + + ParsingTreeNode* ParsingTreeNode::FindSubNode(const ParsingTextPos& position) + { + return FindSubNode(ParsingTextRange(position, position)); + } + + ParsingTreeNode* ParsingTreeNode::FindSubNode(const ParsingTextRange& range) + { + if (codeRange.start <= range.start && range.end <= codeRange.end) + { + vint start = 0; + vint end = cachedOrderedSubNodes.Count() - 1; + while (start <= end) + { + vint selected = (start + end) / 2; + ParsingTreeNode* selectedNode = cachedOrderedSubNodes[selected].Obj(); + const ParsingTextRange& selectedRange = selectedNode->codeRange; + if (range.endselectedRange.end) + { + start = selected + 1; + } + else if (selectedRange.start <= range.start && range.end <= selectedRange.end) + { + return selectedNode; + } + else + { + return this; + } + } + } + return this; + } + + ParsingTreeNode* ParsingTreeNode::FindDeepestNode(const ParsingTextPos& position) + { + return FindDeepestNode(ParsingTextRange(position, position)); + } + + ParsingTreeNode* ParsingTreeNode::FindDeepestNode(const ParsingTextRange& range) + { + ParsingTreeNode* result=0; + ParsingTreeNode* node=this; + do + { + result=node; + node=node->FindSubNode(range); + }while(result!=node); + return result; + } /*********************************************************************** -Semaphore +ParsingTreeToken ***********************************************************************/ - namespace threading_internal - { - struct SemaphoreData + const ParsingTreeToken::NodeList& ParsingTreeToken::GetSubNodesInternal() { - sem_t semUnnamed; - sem_t* semNamed = nullptr; - }; - } - - Semaphore::Semaphore() - :internalData(0) - { - } - - Semaphore::~Semaphore() - { - if (internalData) - { - if (internalData->semNamed) - { - sem_close(internalData->semNamed); - } - else - { - sem_destroy(&internalData->semUnnamed); - } - delete internalData; + return *(NodeList*)0; } - } - bool Semaphore::Create(vint initialCount, vint maxCount, const WString& name) - { - if (internalData) return false; - if (initialCount > maxCount) return false; - - internalData = new SemaphoreData; -#if defined(__APPLE__) - - AString auuid; - if(name.Length() == 0) + ParsingTreeToken::ParsingTreeToken(const WString& _value, vint _tokenIndex, const ParsingTextRange& _codeRange) + :ParsingTreeNode(_codeRange) + ,value(_value) + ,tokenIndex(_tokenIndex) { - CFUUIDRef cfuuid = CFUUIDCreate(kCFAllocatorDefault); - CFStringRef cfstr = CFUUIDCreateString(kCFAllocatorDefault, cfuuid); - auuid = CFStringGetCStringPtr(cfstr, kCFStringEncodingASCII); - - CFRelease(cfstr); - CFRelease(cfuuid); } - auuid = auuid.Insert(0, "/"); - // OSX SEM_NAME_LENGTH = 31 - if(auuid.Length() >= 30) - auuid = auuid.Sub(0, 30); - - if ((internalData->semNamed = sem_open(auuid.Buffer(), O_CREAT, O_RDWR, initialCount)) == SEM_FAILED) + + ParsingTreeToken::~ParsingTreeToken() { - delete internalData; - internalData = 0; + } + + void ParsingTreeToken::Accept(IVisitor* visitor) + { + visitor->Visit(this); + } + + Ptr ParsingTreeToken::Clone() + { + Ptr clone=new ParsingTreeToken(value, tokenIndex, codeRange); + return clone; + } + + vint ParsingTreeToken::GetTokenIndex() + { + return tokenIndex; + } + + void ParsingTreeToken::SetTokenIndex(vint _tokenIndex) + { + tokenIndex=_tokenIndex; + } + + const WString& ParsingTreeToken::GetValue() + { + return value; + } + + void ParsingTreeToken::SetValue(const WString& _value) + { + value=_value; + } + +/*********************************************************************** +ParsingTreeObject +***********************************************************************/ + + const ParsingTreeObject::NodeList& ParsingTreeObject::GetSubNodesInternal() + { + return members.Values(); + } + + ParsingTreeObject::ParsingTreeObject(const WString& _type, const ParsingTextRange& _codeRange) + :ParsingTreeNode(_codeRange) + ,type(_type) + { + } + + ParsingTreeObject::~ParsingTreeObject() + { + } + + void ParsingTreeObject::Accept(IVisitor* visitor) + { + visitor->Visit(this); + } + + Ptr ParsingTreeObject::Clone() + { + Ptr clone=new ParsingTreeObject(type, codeRange); + CopyFrom(clone->rules, rules); + for(vint i=0;i node=members.Values().Get(i)->Clone(); + clone->SetMember(name, node); + } + return clone; + } + + const WString& ParsingTreeObject::GetType() + { + return type; + } + + void ParsingTreeObject::SetType(const WString& _type) + { + type=_type; + } + + ParsingTreeObject::NodeMap& ParsingTreeObject::GetMembers() + { + return members; + } + + Ptr ParsingTreeObject::GetMember(const WString& name) + { + vint index=members.Keys().IndexOf(name); + if(index==-1) return 0; + return members.Values().Get(index); + } + + bool ParsingTreeObject::SetMember(const WString& name, Ptr node) + { + vint index=members.Keys().IndexOf(name); + if(index!=-1) + { + Ptr previous=members.Values().Get(index); + if(previous==node) return true; + if(!BeforeRemoveChild(previous) || !BeforeAddChild(node)) return false; + members.Remove(name); + AfterRemoveChild(previous); + } + members.Add(name, node); + AfterAddChild(node); + return true; + } + + bool ParsingTreeObject::RemoveMember(const WString& name) + { + vint index=members.Keys().IndexOf(name); + if(index!=-1) + { + Ptr previous=members.Values().Get(index); + if(BeforeRemoveChild(previous)) + { + members.Remove(name); + AfterRemoveChild(previous); + return true; + } + } return false; } - -#else - if (name == L"") + + const ParsingTreeObject::NameList& ParsingTreeObject::GetMemberNames() { - if(sem_init(&internalData->semUnnamed, 0, (int)initialCount) == -1) + return members.Keys(); + } + + ParsingTreeObject::RuleList& ParsingTreeObject::GetCreatorRules() + { + return rules; + } + +/*********************************************************************** +ParsingTreeArray +***********************************************************************/ + + const ParsingTreeArray::NodeList& ParsingTreeArray::GetSubNodesInternal() + { + return items; + } + + ParsingTreeArray::ParsingTreeArray(const WString& _elementType, const ParsingTextRange& _codeRange) + :ParsingTreeNode(_codeRange) + ,elementType(_elementType) + { + } + + ParsingTreeArray::~ParsingTreeArray() + { + } + + void ParsingTreeArray::Accept(IVisitor* visitor) + { + visitor->Visit(this); + } + + Ptr ParsingTreeArray::Clone() + { + Ptr clone=new ParsingTreeArray(elementType, codeRange); + for(vint i=0;i node=items.Get(i)->Clone(); + clone->AddItem(node); + } + return clone; + } + + const WString& ParsingTreeArray::GetElementType() + { + return elementType; + } + + void ParsingTreeArray::SetElementType(const WString& _elementType) + { + elementType=_elementType; + } + + ParsingTreeArray::NodeArray& ParsingTreeArray::GetItems() + { + return items; + } + + Ptr ParsingTreeArray::GetItem(vint index) + { + if(0<=index && index node) + { + if(0<=index && indexsemNamed = sem_open(astr.Buffer(), O_CREAT, 0777, initialCount)) == SEM_FAILED) + + bool ParsingTreeArray::AddItem(Ptr node) + { + return InsertItem(items.Count(), node); + } + + bool ParsingTreeArray::InsertItem(vint index, Ptr node) + { + if(0<=index && index<=items.Count()) { - delete internalData; - internalData = 0; - return false; + if(BeforeAddChild(node)) + { + items.Insert(index, node); + AfterAddChild(node); + return true; + } } + return false; + } + + bool ParsingTreeArray::RemoveItem(vint index) + { + if(0<=index && index previous=items[index]; + if(BeforeRemoveChild(previous)) + { + items.RemoveAt(index); + AfterRemoveChild(previous); + return true; + } + } + return false; + } + + bool ParsingTreeArray::RemoveItem(ParsingTreeNode* node) + { + return RemoveItem(items.IndexOf(node)); + } + + vint ParsingTreeArray::IndexOfItem(ParsingTreeNode* node) + { + return items.IndexOf(node); + } + + bool ParsingTreeArray::ContainsItem(ParsingTreeNode* node) + { + return items.Contains(node); + } + + vint ParsingTreeArray::Count() + { + return items.Count(); + } + + bool ParsingTreeArray::Clear() + { + FOREACH(Ptr, node, items) + { + if(!BeforeRemoveChild(node)) return false; + } + FOREACH(Ptr, node, items) + { + AfterRemoveChild(node); + } + items.Clear(); + return true; + } + +/*********************************************************************** +ParsingError +***********************************************************************/ + + ParsingError::ParsingError() + :token(0) + ,parsingTree(0) + { + } + + ParsingError::ParsingError(const WString& _errorMessage) + :token(0) + ,parsingTree(0) + ,errorMessage(_errorMessage) + { + } + + ParsingError::ParsingError(const regex::RegexToken* _token, const WString& _errorMessage) + :token(_token) + ,parsingTree(0) + ,errorMessage(_errorMessage) + { + if(token) + { + codeRange.start.row=_token->rowStart; + codeRange.start.column=_token->columnStart; + codeRange.start.index=_token->start; + codeRange.end.row=_token->rowEnd; + codeRange.end.column=_token->columnEnd; + codeRange.end.index=_token->start+_token->length-1; + codeRange.codeIndex = _token->codeIndex; + } + } + + ParsingError::ParsingError(ParsingTreeCustomBase* _parsingTree, const WString& _errorMessage) + :codeRange(_parsingTree->codeRange) + ,token(0) + ,parsingTree(_parsingTree) + ,errorMessage(_errorMessage) + { + } + + ParsingError::~ParsingError() + { + } + +/*********************************************************************** +ParsingEmptyPrintNodeRecorder +***********************************************************************/ + + ParsingEmptyPrintNodeRecorder::ParsingEmptyPrintNodeRecorder() + { + } + + ParsingEmptyPrintNodeRecorder::~ParsingEmptyPrintNodeRecorder() + { + } + + void ParsingEmptyPrintNodeRecorder::Record(ParsingTreeCustomBase* node, const ParsingTextRange& range) + { + } + +/*********************************************************************** +ParsingMultiplePrintNodeRecorder +***********************************************************************/ + + ParsingMultiplePrintNodeRecorder::ParsingMultiplePrintNodeRecorder() + { + } + + ParsingMultiplePrintNodeRecorder::~ParsingMultiplePrintNodeRecorder() + { + } + + void ParsingMultiplePrintNodeRecorder::AddRecorder(Ptr recorder) + { + recorders.Add(recorder); + } + + void ParsingMultiplePrintNodeRecorder::Record(ParsingTreeCustomBase* node, const ParsingTextRange& range) + { + FOREACH(Ptr, recorder, recorders) + { + recorder->Record(node, range); + } + } + +/*********************************************************************** +ParsingOriginalLocationRecorder +***********************************************************************/ + + ParsingOriginalLocationRecorder::ParsingOriginalLocationRecorder(Ptr _recorder) + :recorder(_recorder) + { + } + + ParsingOriginalLocationRecorder::~ParsingOriginalLocationRecorder() + { + } + + void ParsingOriginalLocationRecorder::Record(ParsingTreeCustomBase* node, const ParsingTextRange& range) + { + auto codeRange = node->codeRange; + codeRange.codeIndex = range.codeIndex; + recorder->Record(node, codeRange); + } + +/*********************************************************************** +ParsingGeneratedLocationRecorder +***********************************************************************/ + + ParsingGeneratedLocationRecorder::ParsingGeneratedLocationRecorder(RangeMap& _rangeMap) + :rangeMap(_rangeMap) + { + } + + ParsingGeneratedLocationRecorder::~ParsingGeneratedLocationRecorder() + { + } + + void ParsingGeneratedLocationRecorder::Record(ParsingTreeCustomBase* node, const ParsingTextRange& range) + { + rangeMap.Add(node, range); + } + +/*********************************************************************** +ParsingUpdateLocationRecorder +***********************************************************************/ + + ParsingUpdateLocationRecorder::ParsingUpdateLocationRecorder() + { + } + + ParsingUpdateLocationRecorder::~ParsingUpdateLocationRecorder() + { + } + + void ParsingUpdateLocationRecorder::Record(ParsingTreeCustomBase* node, const ParsingTextRange& range) + { + node->codeRange = range; + } + +/*********************************************************************** +ParsingWriter +***********************************************************************/ + + void ParsingWriter::HandleChar(wchar_t c) + { + lastPos = currentPos; + switch (c) + { + case L'\n': + currentPos.index++; + currentPos.row++; + currentPos.column = 0; + break; + default: + currentPos.index++; + currentPos.column++; + } + } + + ParsingWriter::ParsingWriter(stream::TextWriter& _writer, Ptr _recorder, vint _codeIndex) + :writer(_writer) + , recorder(_recorder) + , codeIndex(_codeIndex) + , lastPos(-1, 0, -1) + , currentPos(0, 0, 0) + { + } + + ParsingWriter::~ParsingWriter() + { + } + + void ParsingWriter::WriteChar(wchar_t c) + { + writer.WriteChar(c); + if (!recorder) return; + HandleChar(c); + } + + void ParsingWriter::WriteString(const wchar_t* string, vint charCount) + { + writer.WriteString(string, charCount); + if (!recorder) return; + for (vint i = 0; i < charCount; i++) + { + HandleChar(string[i]); + } + } + + void ParsingWriter::BeforePrint(ParsingTreeCustomBase* node) + { + if (!recorder) return; + nodePositions.Add(NodePosPair(node, currentPos)); + } + + void ParsingWriter::AfterPrint(ParsingTreeCustomBase* node) + { + if (!recorder) return; + + auto pair = nodePositions[nodePositions.Count() - 1]; + nodePositions.RemoveAt(nodePositions.Count() - 1); + CHECK_ERROR(pair.key == node, L"vl::parsing::ParsingWriter::AfterPrint(ParsingTreeNode*)#BeforePrint and AfterPrint should be call in pairs."); + + ParsingTextRange range(pair.value, lastPos, codeIndex); + recorder->Record(node, range); + } + } +} + + +/*********************************************************************** +.\REFLECTION\GUITYPEDESCRIPTOR.CPP +***********************************************************************/ + +namespace vl +{ + using namespace collections; + + namespace reflection + { + +/*********************************************************************** +DescriptableObject +***********************************************************************/ + +#ifndef VCZH_DEBUG_NO_REFLECTION + + bool DescriptableObject::IsAggregated() + { + return aggregationInfo != nullptr; + } + + vint DescriptableObject::GetAggregationSize() + { + CHECK_ERROR(IsAggregated(), L"vl::reflection::DescriptableObject::GetAggregationSize()#This function should not be called on non-aggregated objects."); + return aggregationSize; + } + + DescriptableObject* DescriptableObject::GetAggregationRoot() + { + CHECK_ERROR(IsAggregated(), L"vl::reflection::DescriptableObject::GetAggregationRoot()#This function should not be called on non-aggregated objects."); + return aggregationInfo[aggregationSize]; + } + + void DescriptableObject::SetAggregationRoot(DescriptableObject* value) + { + CHECK_ERROR(value != nullptr, L"vl::reflection::DescriptableObject::SetAggregationRoot(Descriptable*)#The root object should not null."); + CHECK_ERROR(value->IsAggregated() && value->GetAggregationRoot() == nullptr, L"vl::reflection::DescriptableObject::SetAggregationRoot(Descriptable*)#The root object should not have an aggregation root."); + if (!IsAggregated()) + { + InitializeAggregation(0); + } + aggregationInfo[aggregationSize] = value; + aggregationInfo[aggregationSize + 1] = value; + for (vint i = 0; i < aggregationSize; i++) + { + if (aggregationInfo[i]) + { + aggregationInfo[i]->SetAggregationRoot(value); + } + } + } + + DescriptableObject* DescriptableObject::GetAggregationParent(vint index) + { + CHECK_ERROR(IsAggregated(), L"vl::reflection::DescriptableObject::GetAggregationParent(vint)#This function should not be called on non-aggregated objects."); + CHECK_ERROR(0 <= index && index < aggregationSize, L"vl::reflection::DescriptableObject::GetAggregationParent(vint)#Index out of range."); + return aggregationInfo[index]; + } + + void DescriptableObject::SetAggregationParent(vint index, DescriptableObject* value) + { + CHECK_ERROR(IsAggregated(), L"vl::reflection::DescriptableObject::SetAggregationParent(vint, DescriptableObject*)#This function should not be called on non-aggregated objects."); + CHECK_ERROR(0 <= index && index < aggregationSize, L"vl::reflection::DescriptableObject::SetAggregationParent(vint, DescriptableObject*)#Index out of range."); + CHECK_ERROR(aggregationInfo[index] == nullptr, L"vl::reflection::DescriptableObject::SetAggregationParent(vint, DescriptableObject*)#This index has been used."); + CHECK_ERROR(value != nullptr, L"vl::reflection::DescriptableObject::SetAggregationParent(vint, DescriptableObject*)#Parent should not be null."); + CHECK_ERROR(!value->IsAggregated() || value->GetAggregationRoot() == nullptr, L"vl::reflection::DescriptableObject::SetAggregationParent(vint, DescriptableObject*)#Parent already has a aggregation root."); + CHECK_ERROR(value->referenceCounter == 0, L"vl::reflection::DescriptableObject::SetAggregationParent(vint, DescriptableObject*)#Parent should not be contained in any smart pointer."); + value->SetAggregationRoot(this); + aggregationInfo[index] = value; + } + + void DescriptableObject::SetAggregationParent(vint index, Ptr& value) + { + CHECK_ERROR(IsAggregated(), L"vl::reflection::DescriptableObject::SetAggregationParent(vint, Ptr&)#This function should not be called on non-aggregated objects."); + CHECK_ERROR(0 <= index && index < aggregationSize, L"vl::reflection::DescriptableObject::SetAggregationParent(vint, Ptr&)#Index out of range."); + CHECK_ERROR(aggregationInfo[index] == nullptr, L"vl::reflection::DescriptableObject::SetAggregationParent(vint, Ptr&)#This index has been used."); + CHECK_ERROR(value, L"vl::reflection::DescriptableObject::SetAggregationParent(vint, Ptr&)#Parent should not be null"); + CHECK_ERROR(!value->IsAggregated() || value->GetAggregationRoot() == nullptr, L"vl::reflection::DescriptableObject::SetAggregationParent(vint, Ptr&)#Parent already has a aggregation root."); + CHECK_ERROR(value->referenceCounter == 1, L"vl::reflection::DescriptableObject::SetAggregationParent(vint, Ptr&)#Parent should not be contained in any other smart pointer."); + value->SetAggregationRoot(this); + + auto parent = value.Detach(); + aggregationInfo[index] = parent; + } + + void DescriptableObject::InitializeAggregation(vint size) + { + CHECK_ERROR(!IsAggregated(), L"vl::reflection::DescriptableObject::InitializeAggregation(vint)#This function should not be called on aggregated objects."); + CHECK_ERROR(size >= 0, L"vl::reflection::DescriptableObject::InitializeAggregation(vint)#Size shout not be negative."); + aggregationSize = size; + aggregationInfo = new DescriptableObject*[size + 2]; + memset(aggregationInfo, 0, sizeof(*aggregationInfo) * (size + 2)); } #endif - Release(initialCount); - return true; - } - - bool Semaphore::Open(bool inheritable, const WString& name) - { - if (internalData) return false; - if (inheritable) return false; - - internalData = new SemaphoreData; - if (!(internalData->semNamed = sem_open(wtoa(name).Buffer(), 0))) + void DescriptableObject::FinalizeAggregation() { - delete internalData; - internalData = 0; - return false; +#ifndef VCZH_DEBUG_NO_REFLECTION + if (IsAggregated()) + { + if (auto root = GetAggregationRoot()) + { + if (aggregationInfo[aggregationSize + 1] == nullptr) + { + return; + } + else + { + aggregationInfo[aggregationSize + 1] = nullptr; + } + + if (!root->destructing) + { + destructing = true; + delete root; + } + } + } +#endif } - return true; - } - - bool Semaphore::Release() - { - return Release(1); - } - - vint Semaphore::Release(vint count) - { - for (vint i = 0; i < count; i++) + DescriptableObject::DescriptableObject() + :referenceCounter(0) + , sharedPtrDestructorProc(0) +#ifndef VCZH_DEBUG_NO_REFLECTION + , objectSize(0) + , typeDescriptor(0) + , destructing(false) + , aggregationInfo(nullptr) + , aggregationSize(-1) +#endif { - if (internalData->semNamed) + } + + DescriptableObject::~DescriptableObject() + { +#ifndef VCZH_DEBUG_NO_REFLECTION + destructing = true; + if (IsAggregated()) { - sem_post(internalData->semNamed); + if (auto root = GetAggregationRoot()) + { + if (aggregationInfo[aggregationSize + 1] != nullptr) + { +#pragma warning (push) +#pragma warning (disable: 4297) + // Your class should call FinalizeAggregation in the destructor if it inherits from AggregatableDescription. + CHECK_ERROR(!IsAggregated(), L"vl::reflection::DescriptableObject::~DescriptableObject0()#FinalizeAggregation function should be called."); +#pragma warning (pop) + } + } + for (vint i = 0; i < aggregationSize; i++) + { + if (auto parent = GetAggregationParent(i)) + { + if (!parent->destructing) + { + delete parent; + } + } + } + delete[] aggregationInfo; + } +#endif + } + +#ifndef VCZH_DEBUG_NO_REFLECTION + + description::ITypeDescriptor* DescriptableObject::GetTypeDescriptor() + { + return typeDescriptor?*typeDescriptor:0; + } + +#endif + + Ptr DescriptableObject::GetInternalProperty(const WString& name) + { + if(!internalProperties) return 0; + vint index=internalProperties->Keys().IndexOf(name); + if(index==-1) return 0; + return internalProperties->Values().Get(index); + } + + void DescriptableObject::SetInternalProperty(const WString& name, Ptr value) + { + if(internalProperties) + { + vint index=internalProperties->Keys().IndexOf(name); + if(index==-1) + { + if(value) + { + internalProperties->Add(name, value); + } + } + else + { + if(value) + { + internalProperties->Set(name, value); + } + else + { + internalProperties->Remove(name); + if(internalProperties->Count()==0) + { + internalProperties=0; + } + } + } } else { - sem_post(&internalData->semUnnamed); + if(value) + { + internalProperties=new InternalPropertyMap; + internalProperties->Add(name, value); + } } } - return true; - } - bool Semaphore::Wait() - { - if (internalData->semNamed) + bool DescriptableObject::Dispose(bool forceDisposing) { - return sem_wait(internalData->semNamed) == 0; - } - else - { - return sem_wait(&internalData->semUnnamed) == 0; - } - } - -/*********************************************************************** -EventObject -***********************************************************************/ - - namespace threading_internal - { - struct EventData - { - bool autoReset; - volatile bool signaled; - CriticalSection mutex; - ConditionVariable cond; - volatile vint counter = 0; - }; - } - - EventObject::EventObject() - { - internalData = nullptr; - } - - EventObject::~EventObject() - { - if (internalData) - { - delete internalData; - } - } - - bool EventObject::CreateAutoUnsignal(bool signaled, const WString& name) - { - if (name!=L"") return false; - if (internalData) return false; - - internalData = new EventData; - internalData->autoReset = true; - internalData->signaled = signaled; - return true; - } - - bool EventObject::CreateManualUnsignal(bool signaled, const WString& name) - { - if (name!=L"") return false; - if (internalData) return false; - - internalData = new EventData; - internalData->autoReset = false; - internalData->signaled = signaled; - return true; - } - - bool EventObject::Signal() - { - if (!internalData) return false; - - internalData->mutex.Enter(); - internalData->signaled = true; - if (internalData->counter) - { - if (internalData->autoReset) +#ifndef VCZH_DEBUG_NO_REFLECTION + if (IsAggregated()) { - internalData->cond.WakeOnePending(); - internalData->signaled = false; + if (auto root = GetAggregationRoot()) + { + return root->Dispose(forceDisposing); + } + } +#endif + + if (referenceCounter > 0 && forceDisposing) + { + throw description::ValueNotDisposableException(); + } + + if (sharedPtrDestructorProc) + { + return sharedPtrDestructorProc(this, forceDisposing); } else { - internalData->cond.WakeAllPendings(); + delete this; + return true; } } - internalData->mutex.Leave(); - return true; - } - bool EventObject::Unsignal() - { - if (!internalData) return false; +#ifndef VCZH_DEBUG_NO_REFLECTION - internalData->mutex.Enter(); - internalData->signaled = false; - internalData->mutex.Leave(); - return true; - } - - bool EventObject::Wait() - { - if (!internalData) return false; - - internalData->mutex.Enter(); - if (internalData->signaled) + DescriptableObject* DescriptableObject::SafeGetAggregationRoot() { - if (internalData->autoReset) + if (IsAggregated()) { - internalData->signaled = false; + if (auto root = GetAggregationRoot()) + { + return root; + } } + return this; } - else - { - internalData->counter++; - internalData->cond.SleepWith(internalData->mutex); - internalData->counter--; - } - internalData->mutex.Leave(); - return true; - } + +#endif /*********************************************************************** -ThreadPoolLite +description::Value ***********************************************************************/ - namespace threading_internal - { - struct ThreadPoolTask + namespace description { - Func task; - Ptr next; - }; - - struct ThreadPoolData - { - Semaphore semaphore; - EventObject taskFinishEvent; - Ptr taskBegin; - Ptr* taskEnd = nullptr; - volatile bool stopping = false; - List taskThreads; - }; - - SpinLock threadPoolLock; - ThreadPoolData* threadPoolData = nullptr; - - void ThreadPoolProc(Thread* thread, void* argument) - { - while (true) + Value::Value(DescriptableObject* value) + :valueType(value ? RawPtr :Null) + ,rawPtr(nullptr) +#ifndef VCZH_DEBUG_NO_REFLECTION + ,typeDescriptor(0) +#endif { - Ptr task; - - threadPoolData->semaphore.Wait(); - SPIN_LOCK(threadPoolLock) +#ifndef VCZH_DEBUG_NO_REFLECTION + if (value) { - if (threadPoolData->taskBegin) - { - task = threadPoolData->taskBegin; - threadPoolData->taskBegin = task->next; - } + rawPtr = value->SafeGetAggregationRoot(); + } +#else + rawPtr = value; +#endif + } - if (!threadPoolData->taskBegin) + Value::Value(Ptr value) + :valueType(value ? SharedPtr : Null) + ,rawPtr(nullptr) +#ifndef VCZH_DEBUG_NO_REFLECTION + ,typeDescriptor(0) +#endif + { +#ifndef VCZH_DEBUG_NO_REFLECTION + if (value) + { + rawPtr = value->SafeGetAggregationRoot(); + sharedPtr = rawPtr; + } +#else + rawPtr = value.Obj(); + sharedPtr = value; +#endif + } + + Value::Value(Ptr value, ITypeDescriptor* associatedTypeDescriptor) + :valueType(value ? BoxedValue : Null) + , rawPtr(nullptr) + , boxedValue(value) +#ifndef VCZH_DEBUG_NO_REFLECTION + , typeDescriptor(associatedTypeDescriptor) +#endif + { + } + + vint Value::Compare(const Value& a, const Value& b)const + { + switch (a.GetValueType()) + { + case Value::RawPtr: + case Value::SharedPtr: + switch (b.GetValueType()) { - threadPoolData->taskEnd = &threadPoolData->taskBegin; - threadPoolData->taskFinishEvent.Signal(); + case Value::RawPtr: + case Value::SharedPtr: + { + auto pa = a.GetRawPtr(); + auto pb = b.GetRawPtr(); + if (pa < pb) return -1; + if (pa > pb) return 1; + return 0; + } + case Value::BoxedValue: + return -1; + default: + return 1; + } + case Value::BoxedValue: + switch (b.GetValueType()) + { + case Value::RawPtr: + case Value::SharedPtr: + return 1; + case Value::BoxedValue: + { +#ifndef VCZH_DEBUG_NO_REFLECTION + auto aSt = a.GetTypeDescriptor()->GetSerializableType(); + auto bSt = b.GetTypeDescriptor()->GetSerializableType(); + if (aSt) + { + if (bSt) + { + auto aSt = a.GetTypeDescriptor()->GetSerializableType(); + auto bSt = b.GetTypeDescriptor()->GetSerializableType(); + + WString aText; + WString bText; + aSt->Serialize(a, aText); + bSt->Serialize(b, bText); + if (aText < bText) return -1; + if (aText > bText) return 1; + return 0; + } + else + { + return 1; + } + } + else + { + if (bSt) + { + return -1; + } + else + { + if (a.GetTypeDescriptor() != b.GetTypeDescriptor()) + { + auto aText = a.GetTypeDescriptor()->GetTypeName(); + auto bText = b.GetTypeDescriptor()->GetTypeName(); + if (aText < bText) return -1; + if (aText > bText) return 1; + return 0; + } + + switch (a.GetTypeDescriptor()->GetTypeDescriptorFlags()) + { + case TypeDescriptorFlags::Struct: + { + auto td = a.GetTypeDescriptor(); + vint count = td->GetPropertyCount(); + for (vint i = 0; i < count; i++) + { + auto prop = td->GetProperty(i); + auto ap = prop->GetValue(a); + auto bp = prop->GetValue(b); + vint result = Compare(ap, bp); + if (result != 0) + { + return result; + } + } + } + return 0; + case TypeDescriptorFlags::FlagEnum: + case TypeDescriptorFlags::NormalEnum: + { + auto ai = a.GetTypeDescriptor()->GetEnumType()->FromEnum(a); + auto bi = a.GetTypeDescriptor()->GetEnumType()->FromEnum(b); + if (ai < bi) return -1; + if (ai > bi) return 1; + return 0; + } + default: + return 0; + } + } + } +#else + auto pa = a.GetBoxedValue(); + auto pb = b.GetBoxedValue(); + switch (pa->ComparePrimitive(pb)) + { + case IBoxedValue::Smaller: return -1; + case IBoxedValue::Greater: return 1; + case IBoxedValue::Equal: return 0; + default:; + } + if (pa.Obj() < pb.Obj()) return -1; + if (pa.Obj() > pb.Obj()) return 1; + return 0; +#endif + } + default: + return 1; + } + default: + switch (b.GetValueType()) + { + case Value::RawPtr: + case Value::SharedPtr: + case Value::BoxedValue: + return -1; + default: + return 0; + } + } + } + + Value::Value() + :valueType(Null) + ,rawPtr(0) +#ifndef VCZH_DEBUG_NO_REFLECTION + ,typeDescriptor(0) +#endif + { + } + + Value::Value(const Value& value) + :valueType(value.valueType) + ,rawPtr(value.rawPtr) + ,sharedPtr(value.sharedPtr) + ,boxedValue(value.boxedValue ? value.boxedValue->Copy() : nullptr) +#ifndef VCZH_DEBUG_NO_REFLECTION + ,typeDescriptor(value.typeDescriptor) +#endif + { + } + + Value& Value::operator=(const Value& value) + { + valueType = value.valueType; + rawPtr = value.rawPtr; + sharedPtr = value.sharedPtr; + boxedValue = value.boxedValue ? value.boxedValue->Copy() : nullptr; +#ifndef VCZH_DEBUG_NO_REFLECTION + typeDescriptor = value.typeDescriptor; +#endif + return *this; + } + + Value::ValueType Value::GetValueType()const + { + return valueType; + } + + DescriptableObject* Value::GetRawPtr()const + { + return rawPtr; + } + + Ptr Value::GetSharedPtr()const + { + return sharedPtr; + } + + Ptr Value::GetBoxedValue()const + { + return boxedValue; + } + + bool Value::IsNull()const + { + return valueType == Null; + } + +#ifndef VCZH_DEBUG_NO_REFLECTION + + ITypeDescriptor* Value::GetTypeDescriptor()const + { + switch(valueType) + { + case RawPtr: + case SharedPtr: + return rawPtr?rawPtr->GetTypeDescriptor():0; + case BoxedValue: + return typeDescriptor; + default:; + } + return 0; + } + + WString Value::GetTypeFriendlyName()const + { + switch(valueType) + { + case RawPtr: + return GetTypeDescriptor()->GetTypeName()+L"*"; + case SharedPtr: + return L"Ptr<"+GetTypeDescriptor()->GetTypeName()+L">"; + case BoxedValue: + return GetTypeDescriptor()->GetTypeName(); + default: + return L"null"; + } + } + + bool Value::CanConvertTo(ITypeDescriptor* targetType, ValueType targetValueType)const + { + if(targetType==GetGlobalTypeManager()->GetRootType()) + { + return true; + } + switch(valueType) + { + case Null: + return targetValueType != BoxedValue; + case RawPtr: + case SharedPtr: + if (targetValueType != RawPtr && targetValueType != SharedPtr) return false; + break; + case BoxedValue: + return targetValueType == BoxedValue; + } + return GetTypeDescriptor()->CanConvertTo(targetType); + } + + bool Value::CanConvertTo(ITypeInfo* targetType)const + { + if(valueType==Null && targetType->GetDecorator()==ITypeInfo::Nullable) + { + return true; + } + ValueType targetValueType=ValueType::Null; + { + ITypeInfo* currentType=targetType; + while(currentType) + { + switch(targetType->GetDecorator()) + { + case ITypeInfo::RawPtr: + targetValueType=RawPtr; + currentType=0; + break; + case ITypeInfo::SharedPtr: + targetValueType=SharedPtr; + currentType=0; + break; + case ITypeInfo::TypeDescriptor: + case ITypeInfo::Nullable: + targetValueType=BoxedValue; + currentType=0; + break; + default: + currentType=currentType->GetElementType(); + } + } + } + return CanConvertTo(targetType->GetTypeDescriptor(), targetValueType); + } + +#endif + + Value Value::From(DescriptableObject* value) + { + return Value(value); + } + + Value Value::From(Ptr value) + { + return Value(value); + } + + Value Value::From(Ptr value, ITypeDescriptor* type) + { + return Value(value, type); + } + +#ifndef VCZH_DEBUG_NO_REFLECTION + + IMethodInfo* Value::SelectMethod(IMethodGroupInfo* methodGroup, collections::Array& arguments) + { + if(methodGroup->GetMethodCount()==1) + { + return methodGroup->GetMethod(0); + } + + List methods; + for(vint i=0;iGetMethodCount();i++) + { + IMethodInfo* method=methodGroup->GetMethod(i); + if(method->GetParameterCount()==arguments.Count()) + { + methods.Add(method); } } - if (task) + if(methods.Count()==0) { - ThreadLocalStorage::FixStorages(); - try + throw ArgumentCountMismtatchException(methodGroup); + } + else if(methods.Count()==1) + { + return methods[0]; + } + else + { + for(vint i=0;itask(); - ThreadLocalStorage::ClearStorages(); + IMethodInfo* method=methods[i]; + try + { + method->CheckArguments(arguments); + return method; + } + catch(const TypeDescriptorException&) + { + } } - catch (...) + return methods[0]; + } + } + + Value Value::Create(ITypeDescriptor* type) + { + Array arguments; + return Create(type, arguments); + } + + Value Value::Create(ITypeDescriptor* type, collections::Array& arguments) + { + IMethodGroupInfo* methodGroup=type->GetConstructorGroup(); + if(!methodGroup) throw ConstructorNotExistsException(type); + + IMethodInfo* method=SelectMethod(methodGroup, arguments); + return method->Invoke(Value(), arguments); + } + + Value Value::Create(const WString& typeName) + { + Array arguments; + return Create(typeName, arguments); + } + + Value Value::Create(const WString& typeName, collections::Array& arguments) + { + ITypeDescriptor* type = vl::reflection::description::GetTypeDescriptor(typeName); + if(!type) throw TypeNotExistsException(typeName); + return Create(type, arguments); + } + + Value Value::InvokeStatic(const WString& typeName, const WString& name) + { + Array arguments; + return InvokeStatic(typeName, name, arguments); + } + + Value Value::InvokeStatic(const WString& typeName, const WString& name, collections::Array& arguments) + { + ITypeDescriptor* type=vl::reflection::description::GetTypeDescriptor(typeName); + if(!type) throw TypeNotExistsException(typeName); + + IMethodGroupInfo* methodGroup=type->GetMethodGroupByName(name, true); + if(!methodGroup) throw MemberNotExistsException(name, type); + + IMethodInfo* method=SelectMethod(methodGroup, arguments); + return method->Invoke(Value(), arguments); + } + + Value Value::GetProperty(const WString& name)const + { + ITypeDescriptor* type=GetTypeDescriptor(); + if(!type) throw ArgumentNullException(L"thisObject", name); + + IPropertyInfo* prop=type->GetPropertyByName(name, true); + if(!prop) throw MemberNotExistsException(name, type); + + return prop->GetValue(*this); + } + + void Value::SetProperty(const WString& name, const Value& newValue) + { + ITypeDescriptor* type=GetTypeDescriptor(); + if(!type) throw ArgumentNullException(L"thisObject", name); + + IPropertyInfo* prop=type->GetPropertyByName(name, true); + if(!prop) throw MemberNotExistsException(name, type); + + prop->SetValue(*this, newValue); + } + + Value Value::Invoke(const WString& name)const + { + Array arguments; + return Invoke(name, arguments); + } + + Value Value::Invoke(const WString& name, collections::Array& arguments)const + { + ITypeDescriptor* type=GetTypeDescriptor(); + if(!type) throw ArgumentNullException(L"thisObject", name); + + IMethodGroupInfo* methodGroup=type->GetMethodGroupByName(name, true); + if(!methodGroup) throw MemberNotExistsException(name, type); + + IMethodInfo* method=SelectMethod(methodGroup, arguments); + return method->Invoke(*this, arguments); + } + + Ptr Value::AttachEvent(const WString& name, const Value& function)const + { + ITypeDescriptor* type=GetTypeDescriptor(); + if(!type) throw ArgumentNullException(L"thisObject", name); + + IEventInfo* eventInfo=type->GetEventByName(name, true); + if(!eventInfo) throw MemberNotExistsException(name, type); + + Ptr proxy=UnboxValue>(function, Description::GetAssociatedTypeDescriptor(), L"function"); + return eventInfo->Attach(*this, proxy); + } + + bool Value::DetachEvent(const WString& name, Ptr handler)const + { + ITypeDescriptor* type = GetTypeDescriptor(); + if (!type) throw ArgumentNullException(L"thisObject", name); + + IEventInfo* eventInfo = type->GetEventByName(name, true); + if (!eventInfo) throw MemberNotExistsException(name, type); + + return eventInfo->Detach(*this, handler); + } + +#endif + + bool Value::DeleteRawPtr() + { + if(valueType!=RawPtr) return false; + if(!rawPtr) return false; + rawPtr->Dispose(true); + *this=Value(); + return true; + } + +#ifndef VCZH_DEBUG_NO_REFLECTION + +/*********************************************************************** +description::TypeManager +***********************************************************************/ + + class TypeManager : public Object, public ITypeManager + { + protected: + Dictionary> typeDescriptors; + List> typeLoaders; + ITypeDescriptor* rootType; + bool loaded; + + public: + TypeManager() + :rootType(0) + ,loaded(false) + { + } + + ~TypeManager() + { + Unload(); + } + + vint GetTypeDescriptorCount()override + { + return typeDescriptors.Values().Count(); + } + + ITypeDescriptor* GetTypeDescriptor(vint index)override + { + return typeDescriptors.Values().Get(index).Obj(); + } + + ITypeDescriptor* GetTypeDescriptor(const WString& name)override + { + vint index=typeDescriptors.Keys().IndexOf(name); + return index==-1?0:typeDescriptors.Values().Get(index).Obj(); + } + + bool SetTypeDescriptor(const WString& name, Ptr typeDescriptor)override + { + if(typeDescriptor && name!=typeDescriptor->GetTypeName()) { - ThreadLocalStorage::ClearStorages(); + return false; + } + if(!typeDescriptors.Keys().Contains(name)) + { + if(typeDescriptor) + { + typeDescriptors.Add(name, typeDescriptor); + return true; + } + } + else + { + if(!typeDescriptor) + { + typeDescriptors.Remove(name); + return true; + } + } + return false; + } + + bool AddTypeLoader(Ptr typeLoader)override + { + vint index=typeLoaders.IndexOf(typeLoader.Obj()); + if(index==-1) + { + typeLoaders.Add(typeLoader); + if(loaded) + { + typeLoader->Load(this); + } + return true; + } + else + { + return false; } } - else if (threadPoolData->stopping) + + bool RemoveTypeLoader(Ptr typeLoader)override + { + vint index=typeLoaders.IndexOf(typeLoader.Obj()); + if(index!=-1) + { + if(loaded) + { + typeLoader->Unload(this); + } + typeLoaders.RemoveAt(index); + return true; + } + else + { + return false; + } + } + + bool Load()override + { + if(!loaded) + { + loaded=true; + for(vint i=0;iLoad(this); + } + return true; + } + else + { + return false; + } + } + + bool Unload()override + { + if(loaded) + { + loaded=false; + rootType=0; + for(vint i=0;iUnload(this); + } + typeDescriptors.Clear(); + return true; + } + else + { + return false; + } + } + + bool Reload()override + { + Unload(); + Load(); + return true; + } + + bool IsLoaded()override + { + return loaded; + } + + ITypeDescriptor* GetRootType()override + { + if (!rootType) + { + rootType=description::GetTypeDescriptor(); + } + return rootType; + } + }; + +/*********************************************************************** +description::TypeManager helper functions +***********************************************************************/ + + ITypeManager* globalTypeManager=0; + bool initializedGlobalTypeManager=false; + + ITypeManager* GetGlobalTypeManager() + { + if(!initializedGlobalTypeManager) + { + initializedGlobalTypeManager=true; + globalTypeManager=new TypeManager; + } + return globalTypeManager; + } + + bool DestroyGlobalTypeManager() + { + if(initializedGlobalTypeManager && globalTypeManager) + { + delete globalTypeManager; + globalTypeManager=0; + return true; + } + else + { + return false; + } + } + + bool ResetGlobalTypeManager() + { + if(!DestroyGlobalTypeManager()) return false; + initializedGlobalTypeManager=false; + return true; + } + + ITypeDescriptor* GetTypeDescriptor(const WString& name) + { + if(globalTypeManager) + { + if(!globalTypeManager->IsLoaded()) + { + globalTypeManager->Load(); + } + return globalTypeManager->GetTypeDescriptor(name); + } + return 0; + } + +/*********************************************************************** +Cpp Helper Functions +***********************************************************************/ + + WString CppGetFullName(ITypeDescriptor* type) + { + if (auto cpp = type->GetCpp()) + { + if (cpp->GetFullName() == L"void" || cpp->GetFullName() == L"vl::reflection::description::VoidValue") + { + return L"void"; + } + else if (cpp->GetFullName() == L"float") + { + return L"float"; + } + else if (cpp->GetFullName() == L"double") + { + return L"double"; + } + else if (cpp->GetFullName() == L"bool") + { + return L"bool"; + } + else if (cpp->GetFullName() == L"wchar_t") + { + return L"wchar_t"; + } + else + { + return L"::" + cpp->GetFullName(); + } + } + else + { + return L"::vl::" + type->GetTypeName(); + } + } + + WString CppGetReferenceTemplate(IPropertyInfo* prop) + { + if (auto cpp = prop->GetCpp()) + { + return cpp->GetReferenceTemplate(); + } + else if ((prop->GetOwnerTypeDescriptor()->GetTypeDescriptorFlags() & TypeDescriptorFlags::ReferenceType) != TypeDescriptorFlags::Undefined) + { + return WString(L"$This->$Name", false); + } + else + { + return WString(L"$This.$Name", false); + } + } + + WString CppGetClosureTemplate(IMethodInfo* method) + { + if (auto cpp = method->GetCpp()) + { + return cpp->GetClosureTemplate(); + } + + if (method->IsStatic()) + { + return WString(L"::vl::Func<$Func>(&$Type::$Name)", false); + } + else + { + return WString(L"::vl::Func<$Func>($This, &$Type::$Name)", false); + } + } + + WString CppGetInvokeTemplate(IMethodInfo* method) + { + if (auto cpp = method->GetCpp()) + { + return cpp->GetInvokeTemplate(); + } + + if (method->GetOwnerMethodGroup() == method->GetOwnerTypeDescriptor()->GetConstructorGroup()) + { + return WString(L"new $Type($Arguments)", false); + } + else if (method->IsStatic()) + { + return WString(L"$Type::$Name($Arguments)", false); + } + else + { + return WString(L"$This->$Name($Arguments)", false); + } + } + + WString CppGetAttachTemplate(IEventInfo* ev) + { + auto cpp = ev->GetCpp(); + return cpp == nullptr ? WString(L"::vl::__vwsn::EventAttach($This->$Name, $Handler)", false) : cpp->GetAttachTemplate(); + } + + WString CppGetDetachTemplate(IEventInfo* ev) + { + auto cpp = ev->GetCpp(); + return cpp == nullptr ? WString(L"::vl::__vwsn::EventDetach($This->$Name, $Handler)", false) : cpp->GetDetachTemplate(); + } + + WString CppGetInvokeTemplate(IEventInfo* ev) + { + auto cpp = ev->GetCpp(); + return cpp == nullptr ? WString(L"::vl::__vwsn::EventInvoke($This->$Name)($Arguments)", false) : cpp->GetInvokeTemplate(); + } + + bool CppExists(ITypeDescriptor* type) + { + auto cpp = type->GetCpp(); + return cpp == nullptr || cpp->GetFullName() != L"*"; + } + + bool CppExists(IPropertyInfo* prop) + { + if (auto cpp = prop->GetCpp()) + { + return cpp->GetReferenceTemplate() != L"*"; + } + else if (auto method = prop->GetGetter()) + { + return CppExists(method); + } + else + { + return true; + } + } + + bool CppExists(IMethodInfo* method) + { + auto cpp = method->GetCpp(); + return cpp == nullptr || cpp->GetInvokeTemplate() != L"*"; + } + + bool CppExists(IEventInfo* ev) + { + auto cpp = ev->GetCpp(); + return cpp == nullptr || cpp->GetInvokeTemplate() != L"*"; + } + +#endif + } + } +} + + +/*********************************************************************** +.\REFLECTION\GUITYPEDESCRIPTORBUILDER.CPP +***********************************************************************/ + +namespace vl +{ + using namespace collections; + + namespace reflection + { + namespace description + { + +#ifndef VCZH_DEBUG_NO_REFLECTION + +/*********************************************************************** +TypeDescriptorImplBase +***********************************************************************/ + + const WString& TypeDescriptorImplBase::GetFullName() + { + return cppFullTypeName; + } + + const TypeInfoContent* TypeDescriptorImplBase::GetTypeInfoContentInternal() + { + return typeInfoContent; + } + + TypeDescriptorImplBase::TypeDescriptorImplBase(TypeDescriptorFlags _typeDescriptorFlags, const TypeInfoContent* _typeInfoContent) + :typeDescriptorFlags(_typeDescriptorFlags) + , typeInfoContent(_typeInfoContent) + , typeName(_typeInfoContent->typeName, false) + { + switch (typeInfoContent->cppName) + { + case TypeInfoContent::VlppType: + break; + case TypeInfoContent::CppType: + cppFullTypeName = WString(typeInfoContent->typeName, false); + break; + case TypeInfoContent::Renamed: + cppFullTypeName = WString(typeInfoContent->cppFullTypeName, false); + break; + } + } + + TypeDescriptorImplBase::~TypeDescriptorImplBase() + { + } + + ITypeDescriptor::ICpp* TypeDescriptorImplBase::GetCpp() + { + return typeInfoContent->cppName == TypeInfoContent::VlppType ? nullptr : this; + } + + TypeDescriptorFlags TypeDescriptorImplBase::GetTypeDescriptorFlags() + { + return typeDescriptorFlags; + } + + const WString& TypeDescriptorImplBase::GetTypeName() + { + return typeName; + } + +/*********************************************************************** +ValueTypeDescriptorBase +***********************************************************************/ + + void ValueTypeDescriptorBase::LoadInternal() + { + } + + void ValueTypeDescriptorBase::Load() + { + if (!loaded) + { + loaded = true; + LoadInternal(); + } + } + + ValueTypeDescriptorBase::ValueTypeDescriptorBase(TypeDescriptorFlags _typeDescriptorFlags, const TypeInfoContent* _typeInfoContent) + :TypeDescriptorImplBase(_typeDescriptorFlags, _typeInfoContent) + , loaded(false) + { + } + + ValueTypeDescriptorBase::~ValueTypeDescriptorBase() + { + } + + bool ValueTypeDescriptorBase::IsAggregatable() + { + return false; + } + + IValueType* ValueTypeDescriptorBase::GetValueType() + { + Load(); + return valueType.Obj(); + } + + IEnumType* ValueTypeDescriptorBase::GetEnumType() + { + Load(); + return enumType.Obj(); + } + + ISerializableType* ValueTypeDescriptorBase::GetSerializableType() + { + Load(); + return serializableType.Obj(); + } + + vint ValueTypeDescriptorBase::GetBaseTypeDescriptorCount() + { + return 0; + } + + ITypeDescriptor* ValueTypeDescriptorBase::GetBaseTypeDescriptor(vint index) + { + return 0; + } + + bool ValueTypeDescriptorBase::CanConvertTo(ITypeDescriptor* targetType) + { + return this == targetType; + } + + vint ValueTypeDescriptorBase::GetPropertyCount() + { + return 0; + } + + IPropertyInfo* ValueTypeDescriptorBase::GetProperty(vint index) + { + return 0; + } + + bool ValueTypeDescriptorBase::IsPropertyExists(const WString& name, bool inheritable) + { + return false; + } + + IPropertyInfo* ValueTypeDescriptorBase::GetPropertyByName(const WString& name, bool inheritable) + { + return 0; + } + + vint ValueTypeDescriptorBase::GetEventCount() + { + return 0; + } + + IEventInfo* ValueTypeDescriptorBase::GetEvent(vint index) + { + return 0; + } + + bool ValueTypeDescriptorBase::IsEventExists(const WString& name, bool inheritable) + { + return false; + } + + IEventInfo* ValueTypeDescriptorBase::GetEventByName(const WString& name, bool inheritable) + { + return 0; + } + + vint ValueTypeDescriptorBase::GetMethodGroupCount() + { + return 0; + } + + IMethodGroupInfo* ValueTypeDescriptorBase::GetMethodGroup(vint index) + { + return 0; + } + + bool ValueTypeDescriptorBase::IsMethodGroupExists(const WString& name, bool inheritable) + { + return false; + } + + IMethodGroupInfo* ValueTypeDescriptorBase::GetMethodGroupByName(const WString& name, bool inheritable) + { + return 0; + } + + IMethodGroupInfo* ValueTypeDescriptorBase::GetConstructorGroup() + { + return 0; + } + +/*********************************************************************** +TypeDescriptorTypeInfo +***********************************************************************/ + + TypeDescriptorTypeInfo::TypeDescriptorTypeInfo(ITypeDescriptor* _typeDescriptor, TypeInfoHint _hint) + :typeDescriptor(_typeDescriptor) + , hint(_hint) + { + } + + TypeDescriptorTypeInfo::~TypeDescriptorTypeInfo() + { + } + + ITypeInfo::Decorator TypeDescriptorTypeInfo::GetDecorator() + { + return ITypeInfo::TypeDescriptor; + } + + TypeInfoHint TypeDescriptorTypeInfo::GetHint() + { + return hint; + } + + ITypeInfo* TypeDescriptorTypeInfo::GetElementType() + { + return nullptr; + } + + ITypeDescriptor* TypeDescriptorTypeInfo::GetTypeDescriptor() + { + return typeDescriptor; + } + + vint TypeDescriptorTypeInfo::GetGenericArgumentCount() + { + return 0; + } + + ITypeInfo* TypeDescriptorTypeInfo::GetGenericArgument(vint index) + { + return nullptr; + } + + WString TypeDescriptorTypeInfo::GetTypeFriendlyName() + { + return typeDescriptor->GetTypeName(); + } + +/*********************************************************************** +DecoratedTypeInfo +***********************************************************************/ + + DecoratedTypeInfo::DecoratedTypeInfo(Ptr _elementType) + :elementType(_elementType) + { + } + + DecoratedTypeInfo::~DecoratedTypeInfo() + { + } + + TypeInfoHint DecoratedTypeInfo::GetHint() + { + return elementType->GetHint(); + } + + ITypeInfo* DecoratedTypeInfo::GetElementType() + { + return elementType.Obj(); + } + + ITypeDescriptor* DecoratedTypeInfo::GetTypeDescriptor() + { + return elementType->GetTypeDescriptor(); + } + + vint DecoratedTypeInfo::GetGenericArgumentCount() + { + return 0; + } + + ITypeInfo* DecoratedTypeInfo::GetGenericArgument(vint index) + { + return nullptr; + } + +/*********************************************************************** +RawPtrTypeInfo +***********************************************************************/ + + RawPtrTypeInfo::RawPtrTypeInfo(Ptr _elementType) + :DecoratedTypeInfo(_elementType) + { + } + + RawPtrTypeInfo::~RawPtrTypeInfo() + { + } + + ITypeInfo::Decorator RawPtrTypeInfo::GetDecorator() + { + return ITypeInfo::RawPtr; + } + + WString RawPtrTypeInfo::GetTypeFriendlyName() + { + return elementType->GetTypeFriendlyName() + L"*"; + } + +/*********************************************************************** +SharedPtrTypeInfo +***********************************************************************/ + + SharedPtrTypeInfo::SharedPtrTypeInfo(Ptr _elementType) + :DecoratedTypeInfo(_elementType) + { + } + + SharedPtrTypeInfo::~SharedPtrTypeInfo() + { + } + + ITypeInfo::Decorator SharedPtrTypeInfo::GetDecorator() + { + return ITypeInfo::SharedPtr; + } + + WString SharedPtrTypeInfo::GetTypeFriendlyName() + { + return elementType->GetTypeFriendlyName() + L"^"; + } + +/*********************************************************************** +NullableTypeInfo +***********************************************************************/ + + NullableTypeInfo::NullableTypeInfo(Ptr _elementType) + :DecoratedTypeInfo(_elementType) + { + } + + NullableTypeInfo::~NullableTypeInfo() + { + } + + ITypeInfo::Decorator NullableTypeInfo::GetDecorator() + { + return ITypeInfo::Nullable; + } + + WString NullableTypeInfo::GetTypeFriendlyName() + { + return elementType->GetTypeFriendlyName() + L"?"; + } + +/*********************************************************************** +GenericTypeInfo +***********************************************************************/ + + GenericTypeInfo::GenericTypeInfo(Ptr _elementType) + :DecoratedTypeInfo(_elementType) + { + } + + GenericTypeInfo::~GenericTypeInfo() + { + } + + ITypeInfo::Decorator GenericTypeInfo::GetDecorator() + { + return ITypeInfo::Generic; + } + + vint GenericTypeInfo::GetGenericArgumentCount() + { + return genericArguments.Count(); + } + + ITypeInfo* GenericTypeInfo::GetGenericArgument(vint index) + { + return genericArguments[index].Obj(); + } + + WString GenericTypeInfo::GetTypeFriendlyName() + { + WString result = elementType->GetTypeFriendlyName() + L"<"; + FOREACH_INDEXER(Ptr, type, i, genericArguments) + { + WString result = elementType->GetTypeFriendlyName() + L"<"; + FOREACH_INDEXER(Ptr, type, i, genericArguments) + { + if (i>0) result += L", "; + result += type->GetTypeFriendlyName(); + } + result += L">"; + return result; + if (i>0) result += L", "; + result += type->GetTypeFriendlyName(); + } + result += L">"; + return result; + } + + void GenericTypeInfo::AddGenericArgument(Ptr value) + { + genericArguments.Add(value); + } + +/*********************************************************************** +ParameterInfoImpl +***********************************************************************/ + + ParameterInfoImpl::ParameterInfoImpl(IMethodInfo* _ownerMethod, const WString& _name, Ptr _type) + :ownerMethod(_ownerMethod) + ,name(_name) + ,type(_type) + { + } + + ParameterInfoImpl::~ParameterInfoImpl() + { + } + + ITypeDescriptor* ParameterInfoImpl::GetOwnerTypeDescriptor() + { + return ownerMethod->GetOwnerTypeDescriptor(); + } + + const WString& ParameterInfoImpl::GetName() + { + return name; + } + + ITypeInfo* ParameterInfoImpl::GetType() + { + return type.Obj(); + } + + IMethodInfo* ParameterInfoImpl::GetOwnerMethod() + { + return ownerMethod; + } + +/*********************************************************************** +MethodInfoImpl +***********************************************************************/ + + MethodInfoImpl::MethodInfoImpl(IMethodGroupInfo* _ownerMethodGroup, Ptr _return, bool _isStatic) + :ownerMethodGroup(_ownerMethodGroup) + ,ownerProperty(0) + ,returnInfo(_return) + ,isStatic(_isStatic) + { + } + + MethodInfoImpl::~MethodInfoImpl() + { + } + + ITypeDescriptor* MethodInfoImpl::GetOwnerTypeDescriptor() + { + return ownerMethodGroup->GetOwnerTypeDescriptor(); + } + + IPropertyInfo* MethodInfoImpl::GetOwnerProperty() + { + return ownerProperty; + } + + const WString& MethodInfoImpl::GetName() + { + return ownerMethodGroup->GetName(); + } + + IMethodGroupInfo* MethodInfoImpl::GetOwnerMethodGroup() + { + return ownerMethodGroup; + } + + vint MethodInfoImpl::GetParameterCount() + { + return parameters.Count(); + } + + IParameterInfo* MethodInfoImpl::GetParameter(vint index) + { + if(0<=index && index& arguments) + { + if(arguments.Count()!=parameters.Count()) + { + throw ArgumentCountMismtatchException(ownerMethodGroup); + } + for(vint i=0;iGetType())) + { + throw ArgumentTypeMismtatchException(parameters[i]->GetName(), parameters[i]->GetType(), arguments[i]); + } + } + } + + Value MethodInfoImpl::Invoke(const Value& thisObject, collections::Array& arguments) + { + if(thisObject.IsNull()) + { + if(!isStatic) + { + throw ArgumentNullException(L"thisObject", this); + } + } + else if(!thisObject.CanConvertTo(ownerMethodGroup->GetOwnerTypeDescriptor(), Value::RawPtr)) + { + throw ArgumentTypeMismtatchException(L"thisObject", ownerMethodGroup->GetOwnerTypeDescriptor(), Value::RawPtr, thisObject); + } + CheckArguments(arguments); + return InvokeInternal(thisObject, arguments); + } + + Value MethodInfoImpl::CreateFunctionProxy(const Value& thisObject) + { + if(thisObject.IsNull()) + { + if(!isStatic) + { + throw ArgumentNullException(L"thisObject", this); + } + } + else if(!thisObject.CanConvertTo(ownerMethodGroup->GetOwnerTypeDescriptor(), Value::RawPtr)) + { + throw ArgumentTypeMismtatchException(L"thisObject", ownerMethodGroup->GetOwnerTypeDescriptor(), Value::RawPtr, thisObject); + } + return CreateFunctionProxyInternal(thisObject); + } + + bool MethodInfoImpl::AddParameter(Ptr parameter) + { + for(vint i=0;iGetName()==parameter->GetName()) + { + return false; + } + } + parameters.Add(parameter); + return true; + } + + bool MethodInfoImpl::SetOwnerMethodgroup(IMethodGroupInfo* _ownerMethodGroup) + { + if(ownerMethodGroup) return false; + ownerMethodGroup=_ownerMethodGroup; + return true; + } + +/*********************************************************************** +MethodGroupInfoImpl +***********************************************************************/ + + MethodGroupInfoImpl::MethodGroupInfoImpl(ITypeDescriptor* _ownerTypeDescriptor, const WString& _name) + :ownerTypeDescriptor(_ownerTypeDescriptor) + ,name(_name) + { + } + + MethodGroupInfoImpl::~MethodGroupInfoImpl() + { + } + + ITypeDescriptor* MethodGroupInfoImpl::GetOwnerTypeDescriptor() + { + return ownerTypeDescriptor; + } + + const WString& MethodGroupInfoImpl::GetName() + { + return name; + } + + vint MethodGroupInfoImpl::GetMethodCount() + { + return methods.Count(); + } + + IMethodInfo* MethodGroupInfoImpl::GetMethod(vint index) + { + if(0<=index && index _method) + { + methods.Add(_method); + return true; + } + +/*********************************************************************** +EventInfoImpl +***********************************************************************/ + + EventInfoImpl::EventInfoImpl(ITypeDescriptor* _ownerTypeDescriptor, const WString& _name) + :ownerTypeDescriptor(_ownerTypeDescriptor) + ,name(_name) + { + } + + EventInfoImpl::~EventInfoImpl() + { + } + + ITypeDescriptor* EventInfoImpl::GetOwnerTypeDescriptor() + { + return ownerTypeDescriptor; + } + + ITypeInfo* EventInfoImpl::GetHandlerType() + { + if(!handlerType) + { + handlerType=GetHandlerTypeInternal(); + } + return handlerType.Obj(); + } + + vint EventInfoImpl::GetObservingPropertyCount() + { + return observingProperties.Count(); + } + + IPropertyInfo* EventInfoImpl::GetObservingProperty(vint index) + { + return observingProperties[index]; + } + + const WString& EventInfoImpl::GetName() + { + return name; + } + + Ptr EventInfoImpl::Attach(const Value& thisObject, Ptr handler) + { + if(thisObject.IsNull()) + { + throw ArgumentNullException(L"thisObject", this); + } + else if(!thisObject.CanConvertTo(ownerTypeDescriptor, Value::RawPtr)) + { + throw ArgumentTypeMismtatchException(L"thisObject", ownerTypeDescriptor, Value::RawPtr, thisObject); + } + + DescriptableObject* rawThisObject=thisObject.GetRawPtr(); + if(rawThisObject) + { + return AttachInternal(rawThisObject, handler); + } + else + { + return nullptr; + } + } + + bool EventInfoImpl::Detach(const Value& thisObject, Ptr handler) + { + if (thisObject.IsNull()) + { + throw ArgumentNullException(L"thisObject", this); + } + else if (!thisObject.CanConvertTo(ownerTypeDescriptor, Value::RawPtr)) + { + throw ArgumentTypeMismtatchException(L"thisObject", ownerTypeDescriptor, Value::RawPtr, thisObject); + } + + DescriptableObject* rawThisObject = thisObject.GetRawPtr(); + if (rawThisObject) + { + return DetachInternal(rawThisObject, handler); + } + else + { + return false; + } + } + + void EventInfoImpl::Invoke(const Value& thisObject, Ptr arguments) + { + if(thisObject.IsNull()) + { + throw ArgumentNullException(L"thisObject", this); + } + else if(!thisObject.CanConvertTo(ownerTypeDescriptor, Value::RawPtr)) + { + throw ArgumentTypeMismtatchException(L"thisObject", ownerTypeDescriptor, Value::RawPtr, thisObject); + } + + DescriptableObject* rawThisObject=thisObject.GetRawPtr(); + if(rawThisObject) + { + InvokeInternal(rawThisObject, arguments); + } + else { return; } } - } - bool ThreadPoolQueue(const Func& proc) - { - SPIN_LOCK(threadPoolLock) +/*********************************************************************** +PropertyInfoImpl +***********************************************************************/ + + PropertyInfoImpl::PropertyInfoImpl(ITypeDescriptor* _ownerTypeDescriptor, const WString& _name, MethodInfoImpl* _getter, MethodInfoImpl* _setter, EventInfoImpl* _valueChangedEvent) + :ownerTypeDescriptor(_ownerTypeDescriptor) + ,name(_name) + ,getter(_getter) + ,setter(_setter) + ,valueChangedEvent(_valueChangedEvent) { - if (!threadPoolData) + if(getter) getter->ownerProperty=this; + if(setter) setter->ownerProperty=this; + if(valueChangedEvent) { - threadPoolData = new ThreadPoolData; - threadPoolData->semaphore.Create(0, 65536); - threadPoolData->taskFinishEvent.CreateManualUnsignal(false); - threadPoolData->taskEnd = &threadPoolData->taskBegin; + valueChangedEvent->observingProperties.Add(this); + } + } - for (vint i = 0; i < Thread::GetCPUCount() * 4; i++) + PropertyInfoImpl::~PropertyInfoImpl() + { + } + + ITypeDescriptor* PropertyInfoImpl::GetOwnerTypeDescriptor() + { + return ownerTypeDescriptor; + } + + const WString& PropertyInfoImpl::GetName() + { + return name; + } + + IPropertyInfo::ICpp* PropertyInfoImpl::GetCpp() + { + return nullptr; + } + + bool PropertyInfoImpl::IsReadable() + { + return getter!=0; + } + + bool PropertyInfoImpl::IsWritable() + { + return setter!=0; + } + + ITypeInfo* PropertyInfoImpl::GetReturn() + { + return getter?getter->GetReturn():0; + } + + IMethodInfo* PropertyInfoImpl::GetGetter() + { + return getter; + } + + IMethodInfo* PropertyInfoImpl::GetSetter() + { + return setter; + } + + IEventInfo* PropertyInfoImpl::GetValueChangedEvent() + { + return valueChangedEvent; + } + + Value PropertyInfoImpl::GetValue(const Value& thisObject) + { + if(getter) + { + Array arguments; + return getter->Invoke(thisObject, arguments); + } + else + { + throw PropertyIsNotReadableException(this); + } + } + + void PropertyInfoImpl::SetValue(Value& thisObject, const Value& newValue) + { + if(setter) + { + Array arguments(1); + arguments[0]=newValue; + setter->Invoke(thisObject, arguments); + } + else + { + throw PropertyIsNotWritableException(this); + } + } + +/*********************************************************************** +PropertyInfoImpl_StaticCpp +***********************************************************************/ + + const WString& PropertyInfoImpl_StaticCpp::GetReferenceTemplate() + { + return referenceTemplate; + } + + PropertyInfoImpl_StaticCpp::PropertyInfoImpl_StaticCpp(ITypeDescriptor* _ownerTypeDescriptor, const WString& _name, MethodInfoImpl* _getter, MethodInfoImpl* _setter, EventInfoImpl* _valueChangedEvent, const WString& _referenceTemplate) + :PropertyInfoImpl(_ownerTypeDescriptor, _name, _getter, _setter, _valueChangedEvent) + , referenceTemplate(_referenceTemplate) + { + } + + PropertyInfoImpl_StaticCpp::~PropertyInfoImpl_StaticCpp() + { + } + + IPropertyInfo::ICpp* PropertyInfoImpl_StaticCpp::GetCpp() + { + return this; + } + +/*********************************************************************** +FieldInfoImpl +***********************************************************************/ + + FieldInfoImpl::FieldInfoImpl(ITypeDescriptor* _ownerTypeDescriptor, const WString& _name, Ptr _returnInfo) + :ownerTypeDescriptor(_ownerTypeDescriptor) + ,name(_name) + ,returnInfo(_returnInfo) + { + } + + FieldInfoImpl::~FieldInfoImpl() + { + } + + ITypeDescriptor* FieldInfoImpl::GetOwnerTypeDescriptor() + { + return ownerTypeDescriptor; + } + + const WString& FieldInfoImpl::GetName() + { + return name; + } + + bool FieldInfoImpl::IsReadable() + { + return true; + } + + bool FieldInfoImpl::IsWritable() + { + return true; + } + + ITypeInfo* FieldInfoImpl::GetReturn() + { + return returnInfo.Obj(); + } + + IMethodInfo* FieldInfoImpl::GetGetter() + { + return 0; + } + + IMethodInfo* FieldInfoImpl::GetSetter() + { + return 0; + } + + IEventInfo* FieldInfoImpl::GetValueChangedEvent() + { + return 0; + } + + Value FieldInfoImpl::GetValue(const Value& thisObject) + { + if(thisObject.IsNull()) + { + throw ArgumentNullException(L"thisObject", this); + } + else + { + auto td = thisObject.GetTypeDescriptor(); + auto valueType = td->GetValueType() ? Value::BoxedValue : Value::RawPtr; + if(!thisObject.CanConvertTo(ownerTypeDescriptor, valueType)) { - threadPoolData->taskThreads.Add(Thread::CreateAndStart(&ThreadPoolProc, nullptr, false)); + throw ArgumentTypeMismtatchException(L"thisObject", ownerTypeDescriptor, valueType, thisObject); } } + return GetValueInternal(thisObject); + } - if (threadPoolData) + void FieldInfoImpl::SetValue(Value& thisObject, const Value& newValue) + { + if(thisObject.IsNull()) { - if (threadPoolData->stopping) + throw ArgumentNullException(L"thisObject", this); + } + else + { + auto td = thisObject.GetTypeDescriptor(); + auto valueType = td->GetValueType() ? Value::BoxedValue : Value::RawPtr; + if(!thisObject.CanConvertTo(ownerTypeDescriptor, valueType)) { - return false; + throw ArgumentTypeMismtatchException(L"thisObject", ownerTypeDescriptor, valueType, thisObject); } - - auto task = MakePtr(); - task->task = proc; - *threadPoolData->taskEnd = task; - threadPoolData->taskEnd = &task->next; - threadPoolData->semaphore.Release(); - threadPoolData->taskFinishEvent.Unsignal(); } - } - return true; - } - - bool ThreadPoolStop(bool discardPendingTasks) - { - SPIN_LOCK(threadPoolLock) - { - if (!threadPoolData) return false; - if (threadPoolData->stopping) return false; - - threadPoolData->stopping = true; - if (discardPendingTasks) + if(!newValue.CanConvertTo(returnInfo.Obj())) { - threadPoolData->taskEnd = &threadPoolData->taskBegin; - threadPoolData->taskBegin = nullptr; + throw ArgumentTypeMismtatchException(L"newValue", returnInfo.Obj(), newValue); } - - threadPoolData->semaphore.Release(threadPoolData->taskThreads.Count()); + SetValueInternal(thisObject, newValue); } - threadPoolData->taskFinishEvent.Wait(); - for (vint i = 0; i < threadPoolData->taskThreads.Count(); i++) +/*********************************************************************** +TypeDescriptorImpl +***********************************************************************/ + + MethodGroupInfoImpl* TypeDescriptorImpl::PrepareMethodGroup(const WString& name) { - auto thread = threadPoolData->taskThreads[i]; - thread->Wait(); - delete thread; + vint index=methodGroups.Keys().IndexOf(name); + if(index==-1) + { + Ptr methodGroup=new MethodGroupInfoImpl(this, name); + methodGroups.Add(name, methodGroup); + return methodGroup.Obj(); + } + else + { + return methodGroups.Values().Get(index).Obj(); + } } - threadPoolData->taskThreads.Clear(); - SPIN_LOCK(threadPoolLock) + MethodGroupInfoImpl* TypeDescriptorImpl::PrepareConstructorGroup() { - delete threadPoolData; - threadPoolData = nullptr; + if(!constructorGroup) + { + constructorGroup=new MethodGroupInfoImpl(this, L""); + } + return constructorGroup.Obj(); } - return true; - } - } - ThreadPoolLite::ThreadPoolLite() - { - } + IPropertyInfo* TypeDescriptorImpl::AddProperty(Ptr value) + { + properties.Add(value->GetName(), value); + return value.Obj(); + } - ThreadPoolLite::~ThreadPoolLite() - { - } + IEventInfo* TypeDescriptorImpl::AddEvent(Ptr value) + { + events.Add(value->GetName(), value); + return value.Obj(); + } - bool ThreadPoolLite::Queue(void(*proc)(void*), void* argument) - { - return ThreadPoolQueue([proc, argument](){proc(argument);}); - } + IMethodInfo* TypeDescriptorImpl::AddMethod(const WString& name, Ptr value) + { + MethodGroupInfoImpl* methodGroup=PrepareMethodGroup(name); + value->SetOwnerMethodgroup(methodGroup); + methodGroup->AddMethod(value); + return value.Obj(); + } - bool ThreadPoolLite::Queue(const Func& proc) - { - return ThreadPoolQueue(proc); - } + IMethodInfo* TypeDescriptorImpl::AddConstructor(Ptr value) + { + MethodGroupInfoImpl* methodGroup=PrepareConstructorGroup(); + value->SetOwnerMethodgroup(methodGroup); + methodGroup->AddMethod(value); + return value.Obj(); + } - bool ThreadPoolLite::Stop(bool discardPendingTasks) - { - return ThreadPoolStop(discardPendingTasks); - } + void TypeDescriptorImpl::AddBaseType(ITypeDescriptor* value) + { + baseTypeDescriptors.Add(value); + } -/*********************************************************************** -CriticalSection -***********************************************************************/ + void TypeDescriptorImpl::Load() + { + if(!loaded) + { + loaded=true; + LoadInternal(); + } + } - namespace threading_internal - { - struct CriticalSectionData - { - pthread_mutex_t mutex; - }; - } + TypeDescriptorImpl::TypeDescriptorImpl(TypeDescriptorFlags _typeDescriptorFlags, const TypeInfoContent* _typeInfoContent) + :TypeDescriptorImplBase(_typeDescriptorFlags, _typeInfoContent) + ,loaded(false) + { + } - CriticalSection::CriticalSection() - { - internalData = new CriticalSectionData; - pthread_mutex_init(&internalData->mutex, nullptr); - } + TypeDescriptorImpl::~TypeDescriptorImpl() + { + } - CriticalSection::~CriticalSection() - { - pthread_mutex_destroy(&internalData->mutex); - delete internalData; - } + bool TypeDescriptorImpl::IsAggregatable() + { + return false; + } - bool CriticalSection::TryEnter() - { - return pthread_mutex_trylock(&internalData->mutex) == 0; - } + IValueType* TypeDescriptorImpl::GetValueType() + { + return nullptr; + } - void CriticalSection::Enter() - { - pthread_mutex_lock(&internalData->mutex); - } + IEnumType* TypeDescriptorImpl::GetEnumType() + { + return nullptr; + } - void CriticalSection::Leave() - { - pthread_mutex_unlock(&internalData->mutex); - } + ISerializableType* TypeDescriptorImpl::GetSerializableType() + { + return nullptr; + } - CriticalSection::Scope::Scope(CriticalSection& _criticalSection) - :criticalSection(&_criticalSection) - { - criticalSection->Enter(); - } + vint TypeDescriptorImpl::GetBaseTypeDescriptorCount() + { + Load(); + return baseTypeDescriptors.Count(); + } - CriticalSection::Scope::~Scope() - { - criticalSection->Leave(); - } + ITypeDescriptor* TypeDescriptorImpl::GetBaseTypeDescriptor(vint index) + { + Load(); + if(0<=index && indexCanConvertTo(targetType)) return true; + } + return false; + } - namespace threading_internal - { - struct ReaderWriterLockData - { - pthread_rwlock_t rwlock; - }; - } + vint TypeDescriptorImpl::GetPropertyCount() + { + Load(); + return properties.Count(); + } - ReaderWriterLock::ReaderWriterLock() - { - internalData = new ReaderWriterLockData; - pthread_rwlock_init(&internalData->rwlock, nullptr); - } + IPropertyInfo* TypeDescriptorImpl::GetProperty(vint index) + { + Load(); + if(0<=index && indexrwlock); - delete internalData; - } + bool TypeDescriptorImpl::IsPropertyExists(const WString& name, bool inheritable) + { + Load(); + if(properties.Keys().Contains(name)) + { + return true; + } + if(inheritable) + { + for(vint i=0;iIsPropertyExists(name, true)) + { + return true; + } + } + } + return false; + } - bool ReaderWriterLock::TryEnterReader() - { - return pthread_rwlock_tryrdlock(&internalData->rwlock) == 0; - } + IPropertyInfo* TypeDescriptorImpl::GetPropertyByName(const WString& name, bool inheritable) + { + Load(); + vint index=properties.Keys().IndexOf(name); + if(index!=-1) + { + return properties.Values().Get(index).Obj(); + } + if(inheritable) + { + for(vint i=0;iGetPropertyByName(name, true); + if(result) + { + return result; + } + } + } + return 0; + } - void ReaderWriterLock::EnterReader() - { - pthread_rwlock_rdlock(&internalData->rwlock); - } + vint TypeDescriptorImpl::GetEventCount() + { + Load(); + return events.Count(); + } - void ReaderWriterLock::LeaveReader() - { - pthread_rwlock_unlock(&internalData->rwlock); - } + IEventInfo* TypeDescriptorImpl::GetEvent(vint index) + { + Load(); + if(0<=index && indexrwlock) == 0; - } + bool TypeDescriptorImpl::IsEventExists(const WString& name, bool inheritable) + { + Load(); + if(events.Keys().Contains(name)) + { + return true; + } + if(inheritable) + { + for(vint i=0;iIsEventExists(name, true)) + { + return true; + } + } + } + return false; + } - void ReaderWriterLock::EnterWriter() - { - pthread_rwlock_wrlock(&internalData->rwlock); - } + IEventInfo* TypeDescriptorImpl::GetEventByName(const WString& name, bool inheritable) + { + Load(); + vint index=events.Keys().IndexOf(name); + if(index!=-1) + { + return events.Values().Get(index).Obj(); + } + if(inheritable) + { + for(vint i=0;iGetEventByName(name, true); + if(result) + { + return result; + } + } + } + return 0; + } - void ReaderWriterLock::LeaveWriter() - { - pthread_rwlock_unlock(&internalData->rwlock); - } + vint TypeDescriptorImpl::GetMethodGroupCount() + { + Load(); + return methodGroups.Count(); + } - ReaderWriterLock::ReaderScope::ReaderScope(ReaderWriterLock& _lock) - :lock(&_lock) - { - lock->EnterReader(); - } + IMethodGroupInfo* TypeDescriptorImpl::GetMethodGroup(vint index) + { + Load(); + if(0<=index && indexLeaveReader(); - } + bool TypeDescriptorImpl::IsMethodGroupExists(const WString& name, bool inheritable) + { + Load(); + if(methodGroups.Keys().Contains(name)) + { + return true; + } + if(inheritable) + { + for(vint i=0;iIsMethodGroupExists(name, true)) + { + return true; + } + } + } + return false; + } - ReaderWriterLock::WriterScope::WriterScope(ReaderWriterLock& _lock) - :lock(&_lock) - { - lock->EnterWriter(); - } + IMethodGroupInfo* TypeDescriptorImpl::GetMethodGroupByName(const WString& name, bool inheritable) + { + Load(); + vint index=methodGroups.Keys().IndexOf(name); + if(index!=-1) + { + return methodGroups.Values().Get(index).Obj(); + } + if(inheritable) + { + for(vint i=0;iGetMethodGroupByName(name, true); + if(result) + { + return result; + } + } + } + return 0; + } - ReaderWriterLock::WriterScope::~WriterScope() - { - lock->LeaveReader(); - } - -/*********************************************************************** -ConditionVariable -***********************************************************************/ - - namespace threading_internal - { - struct ConditionVariableData - { - pthread_cond_t cond; - }; - } - - ConditionVariable::ConditionVariable() - { - internalData = new ConditionVariableData; - pthread_cond_init(&internalData->cond, nullptr); - } - - ConditionVariable::~ConditionVariable() - { - pthread_cond_destroy(&internalData->cond); - delete internalData; - } - - bool ConditionVariable::SleepWith(CriticalSection& cs) - { - return pthread_cond_wait(&internalData->cond, &cs.internalData->mutex) == 0; - } - - void ConditionVariable::WakeOnePending() - { - pthread_cond_signal(&internalData->cond); - } - - void ConditionVariable::WakeAllPendings() - { - pthread_cond_broadcast(&internalData->cond); - } - -/*********************************************************************** -SpinLock -***********************************************************************/ - - SpinLock::Scope::Scope(SpinLock& _spinLock) - :spinLock(&_spinLock) - { - spinLock->Enter(); - } - - SpinLock::Scope::~Scope() - { - spinLock->Leave(); - } - - SpinLock::SpinLock() - :token(0) - { - } - - SpinLock::~SpinLock() - { - } - - bool SpinLock::TryEnter() - { - return __sync_lock_test_and_set(&token, 1)==0; - } - - void SpinLock::Enter() - { - while(__sync_val_compare_and_swap(&token, 0, 1)!=0) - { - while(token!=0) _mm_pause(); - } - } - - void SpinLock::Leave() - { - __sync_lock_test_and_set(&token, 0); - } - -/*********************************************************************** -ThreadLocalStorage -***********************************************************************/ - -#define KEY ((pthread_key_t&)key) - - ThreadLocalStorage::ThreadLocalStorage(Destructor _destructor) - :destructor(_destructor) - { - static_assert(sizeof(key) >= sizeof(pthread_key_t), "ThreadLocalStorage's key storage is not large enouth."); - PushStorage(this); - auto error = pthread_key_create(&KEY, destructor); - CHECK_ERROR(error != EAGAIN && error != ENOMEM, L"vl::ThreadLocalStorage::ThreadLocalStorage()#Failed to create a thread local storage index."); - } - - ThreadLocalStorage::~ThreadLocalStorage() - { - pthread_key_delete(KEY); - } - - void* ThreadLocalStorage::Get() - { - CHECK_ERROR(!disposed, L"vl::ThreadLocalStorage::Get()#Cannot access a disposed ThreadLocalStorage."); - return pthread_getspecific(KEY); - } - - void ThreadLocalStorage::Set(void* data) - { - CHECK_ERROR(!disposed, L"vl::ThreadLocalStorage::Set()#Cannot access a disposed ThreadLocalStorage."); - pthread_setspecific(KEY, data); - } - -#undef KEY -} + IMethodGroupInfo* TypeDescriptorImpl::GetConstructorGroup() + { + Load(); + return constructorGroup.Obj(); + } #endif /*********************************************************************** -PARSING\PARSING.CPP +Function Related +***********************************************************************/ + + namespace internal_helper + { + void UnboxSpecifiedParameter(Ptr arguments, vint index) + { + } + +#ifndef VCZH_DEBUG_NO_REFLECTION + void UnboxSpecifiedParameter(MethodInfoImpl* methodInfo, collections::Array& arguments, vint index) + { + } +#endif + + void AddValueToList(Ptr arguments) + { + } + } + } + } +} + +/*********************************************************************** +.\REFLECTION\GUITYPEDESCRIPTORREFLECTION.CPP +***********************************************************************/ +#include +#include + +namespace vl +{ + using namespace collections; + using namespace regex; + + namespace reflection + { + namespace description + { + +/*********************************************************************** +TypeName +***********************************************************************/ + +#ifndef VCZH_DEBUG_NO_REFLECTION + + IMPL_TYPE_INFO_RENAME(vl::reflection::description::Sys, system::Sys) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::Math, system::Math) + IMPL_TYPE_INFO_RENAME(void, system::Void) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::VoidValue, system::Void) + IMPL_TYPE_INFO_RENAME(vl::reflection::IDescriptable, system::Interface) + IMPL_TYPE_INFO_RENAME(vl::reflection::DescriptableObject, system::ReferenceType) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::Value, system::Object) + IMPL_TYPE_INFO_RENAME(vl::vuint8_t, system::UInt8) + IMPL_TYPE_INFO_RENAME(vl::vuint16_t, system::UInt16) + IMPL_TYPE_INFO_RENAME(vl::vuint32_t, system::UInt32) + IMPL_TYPE_INFO_RENAME(vl::vuint64_t, system::UInt64) + IMPL_TYPE_INFO_RENAME(vl::vint8_t, system::Int8) + IMPL_TYPE_INFO_RENAME(vl::vint16_t, system::Int16) + IMPL_TYPE_INFO_RENAME(vl::vint32_t, system::Int32) + IMPL_TYPE_INFO_RENAME(vl::vint64_t, system::Int64) + IMPL_TYPE_INFO_RENAME(float, system::Single) + IMPL_TYPE_INFO_RENAME(double, system::Double) + IMPL_TYPE_INFO_RENAME(bool, system::Boolean) + IMPL_TYPE_INFO_RENAME(wchar_t, system::Char) + IMPL_TYPE_INFO_RENAME(vl::WString, system::String) + IMPL_TYPE_INFO_RENAME(vl::DateTime, system::DateTime) + IMPL_TYPE_INFO_RENAME(vl::Locale, system::Locale) + + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueEnumerator, system::Enumerator) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueEnumerable, system::Enumerable) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueReadonlyList, system::ReadonlyList) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueList, system::List) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueObservableList, system::ObservableList) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueReadonlyDictionary, system::ReadonlyDictionary) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueDictionary, system::Dictionary) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueInterfaceProxy, system::InterfaceProxy) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueFunctionProxy, system::Function) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueSubscription, system::Subscription) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueCallStack, system::CallStack) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueException, system::Exception) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::CoroutineStatus, system::CoroutineStatus) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::CoroutineResult, system::CoroutineResult) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::ICoroutine, system::Coroutine) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::EnumerableCoroutine::IImpl, system::EnumerableCoroutine::IImpl) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::EnumerableCoroutine, system::EnumerableCoroutine) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::AsyncStatus, system::AsyncStatus) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IAsync, system::Async) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IPromise, system::Promise) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IFuture, system::Future) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IAsyncScheduler, system::AsyncScheduler) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::AsyncCoroutine::IImpl, system::AsyncCoroutine::IImpl) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::AsyncCoroutine, system::AsyncCoroutine) + + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IBoxedValue, system::reflection::BoxedValue) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IBoxedValue::CompareResult, system::reflection::ValueType::CompareResult) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueType, system::reflection::ValueType) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IEnumType, system::reflection::EnumType) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::ISerializableType, system::reflection::SerializableType) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::ITypeInfo, system::reflection::TypeInfo) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::ITypeInfo::Decorator, system::reflection::TypeInfo::Decorator) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IMemberInfo, system::reflection::MemberInfo) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IEventHandler, system::reflection::EventHandler) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IEventInfo, system::reflection::EventInfo) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IPropertyInfo, system::reflection::PropertyInfo) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IParameterInfo, system::reflection::ParameterInfo) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IMethodInfo, system::reflection::MethodInfo) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::IMethodGroupInfo, system::reflection::MethodGroupInfo) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::TypeDescriptorFlags, system::reflection::TypeDescriptorFlags) + IMPL_TYPE_INFO_RENAME(vl::reflection::description::ITypeDescriptor, system::reflection::TypeDescriptor) + +#endif + +/*********************************************************************** +TypedValueSerializerProvider +***********************************************************************/ + +#define DEFINE_COMPARE(TYPENAME)\ + IBoxedValue::CompareResult TypedValueSerializerProvider::Compare(const TYPENAME& a, const TYPENAME& b)\ + {\ + if (a < b) return IBoxedValue::Smaller;\ + if (a > b) return IBoxedValue::Greater;\ + return IBoxedValue::Equal;\ + }\ + + REFLECTION_PREDEFINED_PRIMITIVE_TYPES(DEFINE_COMPARE) + +#undef DEFINE_COMPARE + + vuint8_t TypedValueSerializerProvider::GetDefaultValue() + { + return 0; + } + + bool TypedValueSerializerProvider::Serialize(const vuint8_t& input, WString& output) + { + output = u64tow(input); + return true; + } + + bool TypedValueSerializerProvider::Deserialize(const WString& input, vuint8_t& output) + { + bool success = false; + vuint64_t result = wtou64_test(input, success); + if (!success) return false; + if (result>_UI8_MAX) return false; + output = (vuint8_t)result; + return true; + } + + //--------------------------------------- + + vuint16_t TypedValueSerializerProvider::GetDefaultValue() + { + return 0; + } + + bool TypedValueSerializerProvider::Serialize(const vuint16_t& input, WString& output) + { + output = u64tow(input); + return true; + } + + bool TypedValueSerializerProvider::Deserialize(const WString& input, vuint16_t& output) + { + bool success = false; + vuint64_t result = wtou64_test(input, success); + if (!success) return false; + if (result>_UI16_MAX) return false; + output = (vuint16_t)result; + return true; + } + + //--------------------------------------- + + vuint32_t TypedValueSerializerProvider::GetDefaultValue() + { + return 0; + } + + bool TypedValueSerializerProvider::Serialize(const vuint32_t& input, WString& output) + { + output = u64tow(input); + return true; + } + + bool TypedValueSerializerProvider::Deserialize(const WString& input, vuint32_t& output) + { + bool success = false; + vuint64_t result = wtou64_test(input, success); + if (!success) return false; + if (result>_UI32_MAX) return false; + output = (vuint32_t)result; + return true; + } + + //--------------------------------------- + + vuint64_t TypedValueSerializerProvider::GetDefaultValue() + { + return 0; + } + + bool TypedValueSerializerProvider::Serialize(const vuint64_t& input, WString& output) + { + output = u64tow(input); + return true; + } + + bool TypedValueSerializerProvider::Deserialize(const WString& input, vuint64_t& output) + { + bool success = false; + vuint64_t result = wtou64_test(input, success); + if (!success) return false; + output = result; + return true; + } + + //--------------------------------------- + + vint8_t TypedValueSerializerProvider::GetDefaultValue() + { + return 0; + } + + bool TypedValueSerializerProvider::Serialize(const vint8_t& input, WString& output) + { + output = i64tow(input); + return true; + } + + bool TypedValueSerializerProvider::Deserialize(const WString& input, vint8_t& output) + { + bool success = false; + vint64_t result = wtoi64_test(input, success); + if (!success) return false; + if (result<_I8_MIN || result>_I8_MAX) return false; + output = (vint8_t)result; + return true; + } + + //--------------------------------------- + + vint16_t TypedValueSerializerProvider::GetDefaultValue() + { + return 0; + } + + bool TypedValueSerializerProvider::Serialize(const vint16_t& input, WString& output) + { + output = i64tow(input); + return true; + } + + bool TypedValueSerializerProvider::Deserialize(const WString& input, vint16_t& output) + { + bool success = false; + vint64_t result = wtoi64_test(input, success); + if (!success) return false; + if (result<_I16_MIN || result>_I16_MAX) return false; + output = (vint16_t)result; + return true; + } + + //--------------------------------------- + + vint32_t TypedValueSerializerProvider::GetDefaultValue() + { + return 0; + } + + bool TypedValueSerializerProvider::Serialize(const vint32_t& input, WString& output) + { + output = i64tow(input); + return true; + } + + bool TypedValueSerializerProvider::Deserialize(const WString& input, vint32_t& output) + { + bool success = false; + vint64_t result = wtoi64_test(input, success); + if (!success) return false; + if (result<_I32_MIN || result>_I32_MAX) return false; + output = (vint32_t)result; + return true; + } + + //--------------------------------------- + + vint64_t TypedValueSerializerProvider::GetDefaultValue() + { + return 0; + } + + bool TypedValueSerializerProvider::Serialize(const vint64_t& input, WString& output) + { + output = i64tow(input); + return true; + } + + bool TypedValueSerializerProvider::Deserialize(const WString& input, vint64_t& output) + { + bool success = false; + vint64_t result = wtoi64_test(input, success); + if (!success) return false; + output = result; + return true; + } + + //--------------------------------------- + + float TypedValueSerializerProvider::GetDefaultValue() + { + return 0; + } + + bool TypedValueSerializerProvider::Serialize(const float& input, WString& output) + { + output = ftow(input); + return true; + } + + bool TypedValueSerializerProvider::Deserialize(const WString& input, float& output) + { + bool success = false; + double result = wtof_test(input, success); + if (!success) return false; + if (result<-FLT_MAX || result>FLT_MAX) return false; + output = (float)result; + return true; + } + + //--------------------------------------- + + double TypedValueSerializerProvider::GetDefaultValue() + { + return 0; + } + + bool TypedValueSerializerProvider::Serialize(const double& input, WString& output) + { + output = ftow(input); + return true; + } + + bool TypedValueSerializerProvider::Deserialize(const WString& input, double& output) + { + bool success = false; + double result = wtof_test(input, success); + if (!success) return false; + output = result; + return true; + } + + //--------------------------------------- + + wchar_t TypedValueSerializerProvider::GetDefaultValue() + { + return 0; + } + + bool TypedValueSerializerProvider::Serialize(const wchar_t& input, WString& output) + { + output = input ? WString(input) : L""; + return true; + } + + bool TypedValueSerializerProvider::Deserialize(const WString& input, wchar_t& output) + { + if (input.Length()>1) return false; + output = input.Length() == 0 ? 0 : input[0]; + return true; + } + + //--------------------------------------- + + WString TypedValueSerializerProvider::GetDefaultValue() + { + return L""; + } + + bool TypedValueSerializerProvider::Serialize(const WString& input, WString& output) + { + output = input; + return true; + } + + bool TypedValueSerializerProvider::Deserialize(const WString& input, WString& output) + { + output = input; + return true; + } + + //--------------------------------------- + + bool TypedValueSerializerProvider::GetDefaultValue() + { + return false; + } + + bool TypedValueSerializerProvider::Serialize(const bool& input, WString& output) + { + output = input ? L"true" : L"false"; + return true; + } + + bool TypedValueSerializerProvider::Deserialize(const WString& input, bool& output) + { + output = input == L"true"; + return input == L"true" || input == L"false"; + } + + //--------------------------------------- + + Locale TypedValueSerializerProvider::GetDefaultValue() + { + return Locale(); + } + + bool TypedValueSerializerProvider::Serialize(const Locale& input, WString& output) + { + output = input.GetName(); + return true; + } + + bool TypedValueSerializerProvider::Deserialize(const WString& input, Locale& output) + { + output = Locale(input); + return true; + } + +/*********************************************************************** +DateTimeValueSerializer +***********************************************************************/ + + BEGIN_GLOBAL_STORAGE_CLASS(DateTimeSerializerStorage) + Regex* regexDateTime = nullptr; + + INITIALIZE_GLOBAL_STORAGE_CLASS + regexDateTime = new Regex(L"(/d/d/d/d)-(/d/d)-(/d/d) (/d/d):(/d/d):(/d/d).(/d/d/d)"); + + FINALIZE_GLOBAL_STORAGE_CLASS + delete regexDateTime; + regexDateTime = nullptr; + + END_GLOBAL_STORAGE_CLASS(DateTimeSerializerStorage) + + DateTime TypedValueSerializerProvider::GetDefaultValue() + { + return DateTime(); + } + + WString FormatDigits(vint number, vint length) + { + WString result = itow(number); + while (result.Length() < length) + { + result = L"0" + result; + } + return result; + } + + bool TypedValueSerializerProvider::Serialize(const DateTime& input, WString& output) + { + output = + FormatDigits(input.year, 4) + L"-" + FormatDigits(input.month, 2) + L"-" + FormatDigits(input.day, 2) + L" " + + FormatDigits(input.hour, 2) + L":" + FormatDigits(input.minute, 2) + L":" + FormatDigits(input.second, 2) + L"." + + FormatDigits(input.milliseconds, 3); + return true; + } + + bool TypedValueSerializerProvider::Deserialize(const WString& input, DateTime& output) + { + Ptr match = GetDateTimeSerializerStorage().regexDateTime->Match(input); + if (!match) return false; + if (!match->Success()) return false; + if (match->Result().Start() != 0) return false; + if (match->Result().Length() != input.Length()) return false; + + vint year = wtoi(match->Groups()[L"Y"].Get(0).Value()); + vint month = wtoi(match->Groups()[L"M"].Get(0).Value()); + vint day = wtoi(match->Groups()[L"D"].Get(0).Value()); + vint hour = wtoi(match->Groups()[L"h"].Get(0).Value()); + vint minute = wtoi(match->Groups()[L"m"].Get(0).Value()); + vint second = wtoi(match->Groups()[L"s"].Get(0).Value()); + vint milliseconds = wtoi(match->Groups()[L"ms"].Get(0).Value()); + + output = DateTime::FromDateTime(year, month, day, hour, minute, second, milliseconds); + return true; + } + + IBoxedValue::CompareResult TypedValueSerializerProvider::Compare(const DateTime& a, const DateTime& b) + { + auto ta = a.filetime; + auto tb = b.filetime; + if (ta < tb) return IBoxedValue::Smaller; + if (ta > tb) return IBoxedValue::Greater; + return IBoxedValue::Equal; + } + +/*********************************************************************** +Helper Functions +***********************************************************************/ + +#ifndef VCZH_DEBUG_NO_REFLECTION + + vint ITypeDescriptor_GetTypeDescriptorCount() + { + return GetGlobalTypeManager()->GetTypeDescriptorCount(); + } + + ITypeDescriptor* ITypeDescriptor_GetTypeDescriptor(vint index) + { + return GetGlobalTypeManager()->GetTypeDescriptor(index); + } + + ITypeDescriptor* ITypeDescriptor_GetTypeDescriptor(const WString& name) + { + return GetGlobalTypeManager()->GetTypeDescriptor(name); + } + + ITypeDescriptor* ITypeDescriptor_GetTypeDescriptor(const Value& value) + { + return value.GetTypeDescriptor(); + } + +#else + + vint ITypeDescriptor_GetTypeDescriptorCount() + { + return 0; + } + + ITypeDescriptor* ITypeDescriptor_GetTypeDescriptor(vint index) + { + return nullptr; + } + + ITypeDescriptor* ITypeDescriptor_GetTypeDescriptor(const WString& name) + { + return nullptr; + } + + ITypeDescriptor* ITypeDescriptor_GetTypeDescriptor(const Value& value) + { + return nullptr; + } + +#endif + +/*********************************************************************** +LoadPredefinedTypes +***********************************************************************/ + +#ifndef VCZH_DEBUG_NO_REFLECTION + +#define _ , + + template<> + struct CustomTypeDescriptorSelector + { + public: + class CustomTypeDescriptorImpl : public TypeDescriptorImpl + { + public: + CustomTypeDescriptorImpl() + :TypeDescriptorImpl(TypeDescriptorFlags::Class, &TypeInfo::content) + { + Description::SetAssociatedTypeDescroptor(this); + } + ~CustomTypeDescriptorImpl() + { + Description::SetAssociatedTypeDescroptor(0); + } + protected: + void LoadInternal()override + { + } + }; + }; + +#define PT(TYPE) PT_##TYPE +#define PT_vint Int +#define PT_vint8_t Int8 +#define PT_vint16_t Int16 +#define PT_vint32_t Int32 +#define PT_vint64_t Int64 +#define PT_vuint8_t UInt8 +#define PT_vuint16_t UInt16 +#define PT_vuint32_t UInt32 +#define PT_vuint64_t UInt64 +#define PT_float Single +#define PT_double Double +#define PT_bool Bool +#define PT_wchar_t Char +#define PT_WString String +#define PT_Locale Locale +#define PT_DateTime DateTime +#define PT_CONCAT_(A, B) A##B +#define PT_CONCAT(A, B) PT_CONCAT_(A, B) + + BEGIN_CLASS_MEMBER(Sys) + CLASS_MEMBER_STATIC_METHOD(Len, { L"value" }) + CLASS_MEMBER_STATIC_METHOD(Left, { L"value" _ L"length" }) + CLASS_MEMBER_STATIC_METHOD(Right, { L"value" _ L"length" }) + CLASS_MEMBER_STATIC_METHOD(Mid, { L"value" _ L"start" _ L"length" }) + CLASS_MEMBER_STATIC_METHOD(Find, { L"value" _ L"substr" }) + CLASS_MEMBER_STATIC_METHOD(ReverseEnumerable, { L"value" }) +#pragma push_macro("CompareString") +#if defined CompareString +#undef CompareString +#endif +#define DEFINE_COMPARE(TYPE) CLASS_MEMBER_STATIC_EXTERNALMETHOD(PT_CONCAT(Compare, PT(TYPE)), PROTECT_PARAMETERS({L"a" _ L"b"}), vint(*)(TYPE, TYPE), vl::reflection::description::Sys::Compare) + REFLECTION_PREDEFINED_PRIMITIVE_TYPES(DEFINE_COMPARE) + DEFINE_COMPARE(DateTime) + DEFINE_COMPARE(vint) +#undef DEFINE_COMPARE +#pragma pop_macro("CompareString") + END_CLASS_MEMBER(Sys) + + BEGIN_CLASS_MEMBER(Math) + CLASS_MEMBER_STATIC_EXTERNALMETHOD(AbsInt8, { L"value" }, vint8_t(*)(vint8_t), vl::reflection::description::Math::Abs) + CLASS_MEMBER_STATIC_EXTERNALMETHOD(AbsInt16, { L"value" }, vint16_t(*)(vint16_t), vl::reflection::description::Math::Abs) + CLASS_MEMBER_STATIC_EXTERNALMETHOD(AbsInt32, { L"value" }, vint32_t(*)(vint32_t), vl::reflection::description::Math::Abs) + CLASS_MEMBER_STATIC_EXTERNALMETHOD(AbsInt64, { L"value" }, vint64_t(*)(vint64_t), vl::reflection::description::Math::Abs) + CLASS_MEMBER_STATIC_EXTERNALMETHOD(AbsSingle, { L"value" }, float(*)(float), vl::reflection::description::Math::Abs) + CLASS_MEMBER_STATIC_EXTERNALMETHOD(AbsDouble, { L"value" }, double(*)(double), vl::reflection::description::Math::Abs) + +#define DEFINE_MINMAX(TYPE)\ + CLASS_MEMBER_STATIC_EXTERNALMETHOD(PT_CONCAT(Min, PT(TYPE)), PROTECT_PARAMETERS({L"a" _ L"b"}), TYPE(*)(TYPE, TYPE), vl::reflection::description::Math::Min)\ + CLASS_MEMBER_STATIC_EXTERNALMETHOD(PT_CONCAT(Max, PT(TYPE)), PROTECT_PARAMETERS({L"a" _ L"b"}), TYPE(*)(TYPE, TYPE), vl::reflection::description::Math::Max)\ + + REFLECTION_PREDEFINED_PRIMITIVE_TYPES(DEFINE_MINMAX) + DEFINE_MINMAX(DateTime) + DEFINE_MINMAX(vint) +#undef DEFINE_MINMAX + + CLASS_MEMBER_STATIC_METHOD(Sin, { L"value" }) + CLASS_MEMBER_STATIC_METHOD(Cos, { L"value" }) + CLASS_MEMBER_STATIC_METHOD(Tan, { L"value" }) + CLASS_MEMBER_STATIC_METHOD(ASin, { L"value" }) + CLASS_MEMBER_STATIC_METHOD(ACos, { L"value" }) + CLASS_MEMBER_STATIC_METHOD(ATan, { L"value" }) + CLASS_MEMBER_STATIC_METHOD(ATan2, { L"x" _ L"y" }) + + CLASS_MEMBER_STATIC_METHOD(Exp, { L"value" }) + CLASS_MEMBER_STATIC_METHOD(LogN, { L"value" }) + CLASS_MEMBER_STATIC_METHOD(Log10, { L"value" }) + CLASS_MEMBER_STATIC_METHOD(Log, { L"value" _ L"base" }) + CLASS_MEMBER_STATIC_METHOD(Pow, { L"value" _ L"power" }) + CLASS_MEMBER_STATIC_METHOD(Ceil, { L"value" }) + CLASS_MEMBER_STATIC_METHOD(Floor, { L"value" }) + CLASS_MEMBER_STATIC_METHOD(Round, { L"value" }) + CLASS_MEMBER_STATIC_METHOD(Trunc, { L"value" }) + END_CLASS_MEMBER(Math) + +#undef PT +#undef PT_vint8_t +#undef PT_vint16_t +#undef PT_vint32_t +#undef PT_vint64_t +#undef PT_vuint8_t +#undef PT_vuint16_t +#undef PT_vuint32_t +#undef PT_vuint64_t +#undef PT_float +#undef PT_double +#undef PT_bool +#undef PT_wchar_t +#undef PT_WString +#undef PT_DateTime +#undef PT_CONCAT_ +#undef PT_CONCAT + + BEGIN_STRUCT_MEMBER_FLAG(VoidValue, TypeDescriptorFlags::Primitive) + END_STRUCT_MEMBER(VoidValue) + + BEGIN_INTERFACE_MEMBER_NOPROXY_FLAG(IDescriptable, TypeDescriptorFlags::IDescriptable) + END_INTERFACE_MEMBER(IDescriptable) + + BEGIN_STRUCT_MEMBER(DateTime) + valueType = new SerializableValueType(); + serializableType = new SerializableType(); + STRUCT_MEMBER(year) + STRUCT_MEMBER(month) + STRUCT_MEMBER(dayOfWeek) + STRUCT_MEMBER(day) + STRUCT_MEMBER(hour) + STRUCT_MEMBER(minute) + STRUCT_MEMBER(second) + STRUCT_MEMBER(milliseconds) + END_STRUCT_MEMBER(DateTime) + + BEGIN_INTERFACE_MEMBER(IValueEnumerator) + CLASS_MEMBER_PROPERTY_READONLY_FAST(Current) + CLASS_MEMBER_PROPERTY_READONLY_FAST(Index) + CLASS_MEMBER_METHOD(Next, NO_PARAMETER) + END_INTERFACE_MEMBER(IValueEnumerator) + + BEGIN_INTERFACE_MEMBER(IValueEnumerable) + CLASS_MEMBER_METHOD(CreateEnumerator, NO_PARAMETER) + END_INTERFACE_MEMBER(IValueEnumerable) + + BEGIN_INTERFACE_MEMBER(IValueReadonlyList) + CLASS_MEMBER_BASE(IValueEnumerable) + CLASS_MEMBER_PROPERTY_READONLY_FAST(Count) + CLASS_MEMBER_METHOD(Get, { L"index" }) + CLASS_MEMBER_METHOD(Contains, { L"value" }) + CLASS_MEMBER_METHOD(IndexOf, { L"value" }) + END_INTERFACE_MEMBER(IValueReadonlyList) + + BEGIN_INTERFACE_MEMBER(IValueList) + CLASS_MEMBER_BASE(IValueReadonlyList) + CLASS_MEMBER_EXTERNALCTOR(Ptr(), NO_PARAMETER, vl::reflection::description::IValueList::Create) + CLASS_MEMBER_EXTERNALCTOR(Ptr(Ptr), { L"values" }, vl::reflection::description::IValueList::Create) + + CLASS_MEMBER_METHOD(Set, { L"index" _ L"value" }) + CLASS_MEMBER_METHOD(Add, { L"value" }) + CLASS_MEMBER_METHOD(Insert, { L"index" _ L"value" }) + CLASS_MEMBER_METHOD(Remove, { L"value" }) + CLASS_MEMBER_METHOD(RemoveAt, { L"index" }) + CLASS_MEMBER_METHOD(Clear, NO_PARAMETER) + END_INTERFACE_MEMBER(IValueList) + + BEGIN_INTERFACE_MEMBER(IValueObservableList) + CLASS_MEMBER_BASE(IValueList) + CLASS_MEMBER_EXTERNALCTOR(Ptr(), NO_PARAMETER, vl::reflection::description::IValueObservableList::Create) + CLASS_MEMBER_EXTERNALCTOR(Ptr(Ptr), { L"values" }, vl::reflection::description::IValueObservableList::Create) + + CLASS_MEMBER_EVENT(ItemChanged) + END_INTERFACE_MEMBER(IValueObservableList) + + BEGIN_INTERFACE_MEMBER(IValueReadonlyDictionary) + CLASS_MEMBER_PROPERTY_READONLY_FAST(Keys) + CLASS_MEMBER_PROPERTY_READONLY_FAST(Values) + CLASS_MEMBER_PROPERTY_READONLY_FAST(Count) + CLASS_MEMBER_METHOD(Get, { L"key" }) + END_INTERFACE_MEMBER(IValueReadonlyDictionary) + + BEGIN_INTERFACE_MEMBER(IValueDictionary) + CLASS_MEMBER_BASE(IValueReadonlyDictionary) + CLASS_MEMBER_EXTERNALCTOR(Ptr(), NO_PARAMETER, vl::reflection::description::IValueDictionary::Create) + CLASS_MEMBER_EXTERNALCTOR(Ptr(Ptr), { L"values" }, vl::reflection::description::IValueDictionary::Create) + CLASS_MEMBER_METHOD(Set, { L"key" _ L"value" }) + CLASS_MEMBER_METHOD(Remove, { L"key" }) + CLASS_MEMBER_METHOD(Clear, NO_PARAMETER) + END_INTERFACE_MEMBER(IValueDictionary) + + BEGIN_INTERFACE_MEMBER_NOPROXY(IValueInterfaceProxy) + CLASS_MEMBER_METHOD(Invoke, { L"methodInfo" _ L"arguments" }) + END_INTERFACE_MEMBER(IValueInterfaceProxy) + + BEGIN_INTERFACE_MEMBER_NOPROXY(IValueFunctionProxy) + CLASS_MEMBER_METHOD(Invoke, { L"arguments" }) + END_INTERFACE_MEMBER(IValueFunctionProxy) + + BEGIN_INTERFACE_MEMBER(IValueSubscription) + CLASS_MEMBER_EVENT(ValueChanged) + CLASS_MEMBER_METHOD(Open, NO_PARAMETER) + CLASS_MEMBER_METHOD(Update, NO_PARAMETER) + CLASS_MEMBER_METHOD(Close, NO_PARAMETER) + END_CLASS_MEMBER(IValueSubscription) + + BEGIN_INTERFACE_MEMBER_NOPROXY(IValueCallStack) + CLASS_MEMBER_PROPERTY_READONLY_FAST(LocalVariables) + CLASS_MEMBER_PROPERTY_READONLY_FAST(LocalArguments) + CLASS_MEMBER_PROPERTY_READONLY_FAST(CapturedVariables) + CLASS_MEMBER_PROPERTY_READONLY_FAST(GlobalVariables) + CLASS_MEMBER_PROPERTY_READONLY_FAST(FunctionName) + CLASS_MEMBER_PROPERTY_READONLY_FAST(SourceCodeBeforeCodegen) + CLASS_MEMBER_PROPERTY_READONLY_FAST(SourceCodeAfterCodegen) + CLASS_MEMBER_PROPERTY_READONLY_FAST(RowBeforeCodegen) + CLASS_MEMBER_PROPERTY_READONLY_FAST(RowAfterCodegen) + END_INTERFACE_MEMBER(IValueCallStack) + + BEGIN_INTERFACE_MEMBER_NOPROXY(IValueException) +#pragma push_macro("GetMessage") +#if defined GetMessage +#undef GetMessage +#endif + CLASS_MEMBER_PROPERTY_READONLY_FAST(Message) +#pragma pop_macro("GetMessage") + CLASS_MEMBER_PROPERTY_READONLY_FAST(Fatal) + CLASS_MEMBER_PROPERTY_READONLY_FAST(CallStack) + END_INTERFACE_MEMBER(IValueException) + + BEGIN_ENUM_ITEM(CoroutineStatus) + ENUM_CLASS_ITEM(Waiting) + ENUM_CLASS_ITEM(Executing) + ENUM_CLASS_ITEM(Stopped) + END_ENUM_ITEM(CoroutineStatus) + + BEGIN_INTERFACE_MEMBER(ICoroutine) + CLASS_MEMBER_METHOD(Resume, { L"raiseException" _ L"output" }) + CLASS_MEMBER_PROPERTY_READONLY_FAST(Failure) + CLASS_MEMBER_PROPERTY_READONLY_FAST(Status) + END_INTERFACE_MEMBER(ICoroutine) + + BEGIN_CLASS_MEMBER(CoroutineResult) + CLASS_MEMBER_CONSTRUCTOR(Ptr(), NO_PARAMETER) + CLASS_MEMBER_PROPERTY_FAST(Result) + CLASS_MEMBER_PROPERTY_FAST(Failure) + END_CLASS_MEMBER(CoroutineResult) + + BEGIN_INTERFACE_MEMBER_NOPROXY(EnumerableCoroutine::IImpl) + CLASS_MEMBER_BASE(IValueEnumerator) + END_INTERFACE_MEMBER(EnumerableCoroutine::IImpl) + + BEGIN_CLASS_MEMBER(EnumerableCoroutine) + CLASS_MEMBER_STATIC_METHOD(YieldAndPause, { L"impl" _ L"value" }) + CLASS_MEMBER_STATIC_METHOD(JoinAndPause, { L"impl" _ L"value" }) + CLASS_MEMBER_STATIC_METHOD(ReturnAndExit, { L"impl" }) + CLASS_MEMBER_STATIC_METHOD(Create, { L"creator" }) + END_CLASS_MEMBER(EnumerableCoroutine) + + BEGIN_ENUM_ITEM(AsyncStatus) + ENUM_CLASS_ITEM(Ready) + ENUM_CLASS_ITEM(Executing) + ENUM_CLASS_ITEM(Stopped) + END_ENUM_ITEM(AsyncStatus) + + BEGIN_INTERFACE_MEMBER(IAsync) + CLASS_MEMBER_PROPERTY_READONLY_FAST(Status) + CLASS_MEMBER_METHOD(Execute, { L"callback" }) + CLASS_MEMBER_STATIC_METHOD(Delay, { L"milliseconds" }) + END_INTERFACE_MEMBER(IAsync) + + BEGIN_INTERFACE_MEMBER_NOPROXY(IPromise) + CLASS_MEMBER_METHOD(SendResult, { L"result" }) + CLASS_MEMBER_METHOD(SendFailure, { L"failure" }) + END_INTERFACE_MEMBER(IPromise) + + BEGIN_INTERFACE_MEMBER_NOPROXY(IFuture) + CLASS_MEMBER_BASE(IAsync) + CLASS_MEMBER_BASE(IPromise) + CLASS_MEMBER_PROPERTY_READONLY_FAST(Promise) + CLASS_MEMBER_STATIC_METHOD(Create, NO_PARAMETER) + END_INTERFACE_MEMBER(IFuture) + + BEGIN_INTERFACE_MEMBER_NOPROXY(IAsyncScheduler) + CLASS_MEMBER_METHOD(Execute, { L"callback" }) + CLASS_MEMBER_METHOD(ExecuteInBackground, { L"callback" }) + CLASS_MEMBER_METHOD(DelayExecute, { L"callback" _ L"milliseconds" }) + CLASS_MEMBER_STATIC_METHOD(GetSchedulerForCurrentThread, NO_PARAMETER) + END_INTERFACE_MEMBER(IAsyncScheduler) + + BEGIN_INTERFACE_MEMBER_NOPROXY(AsyncCoroutine::IImpl) + CLASS_MEMBER_BASE(IAsync) + END_INTERFACE_MEMBER(AsyncCoroutine::IImpl) + + BEGIN_CLASS_MEMBER(AsyncCoroutine) + CLASS_MEMBER_STATIC_METHOD(AwaitAndRead, { L"impl" _ L"value" }) + CLASS_MEMBER_STATIC_METHOD(ReturnAndExit, { L"impl" _ L"value"}) + CLASS_MEMBER_STATIC_METHOD(Create, { L"creator" }) + CLASS_MEMBER_STATIC_METHOD(CreateAndRun, { L"creator" }) + END_CLASS_MEMBER(AsyncCoroutine) + + BEGIN_INTERFACE_MEMBER_NOPROXY(IBoxedValue) + CLASS_MEMBER_METHOD(Copy, NO_PARAMETER) + END_INTERFACE_MEMBER(IBoxedValue) + + BEGIN_ENUM_ITEM(IBoxedValue::CompareResult) + ENUM_ITEM_NAMESPACE(IBoxedValue) + + ENUM_NAMESPACE_ITEM(Smaller) + ENUM_NAMESPACE_ITEM(Greater) + ENUM_NAMESPACE_ITEM(Equal) + ENUM_NAMESPACE_ITEM(NotComparable) + END_ENUM_ITEM(ITypeInfo::Decorator) + + BEGIN_INTERFACE_MEMBER_NOPROXY(IValueType) + CLASS_MEMBER_METHOD(CreateDefault, NO_PARAMETER) + CLASS_MEMBER_METHOD(Compare, { L"a" _ L"b" }) + END_INTERFACE_MEMBER(IValueType) + + BEGIN_INTERFACE_MEMBER_NOPROXY(IEnumType) + CLASS_MEMBER_METHOD(IsFlagEnum, NO_PARAMETER) + CLASS_MEMBER_METHOD(GetItemCount, NO_PARAMETER) + CLASS_MEMBER_METHOD(GetItemName, { L"index" }) + CLASS_MEMBER_METHOD(GetItemValue, { L"index" }) + CLASS_MEMBER_METHOD(IndexOfItem, { L"name" }) + CLASS_MEMBER_METHOD(ToEnum, { L"value" }) + CLASS_MEMBER_METHOD(FromEnum, { L"value" }) + END_INTERFACE_MEMBER(IEnumType) + + BEGIN_INTERFACE_MEMBER_NOPROXY(ISerializableType) + CLASS_MEMBER_METHOD(Serialize, { L"input" _ L"output" }) + CLASS_MEMBER_METHOD(Deserialize, { L"input" _ L"output" }) + END_INTERFACE_MEMBER(ISerializableType) + + BEGIN_INTERFACE_MEMBER_NOPROXY(ITypeInfo) + CLASS_MEMBER_PROPERTY_READONLY_FAST(Decorator) + CLASS_MEMBER_PROPERTY_READONLY_FAST(ElementType) + CLASS_MEMBER_PROPERTY_READONLY_FAST(TypeDescriptor) + CLASS_MEMBER_PROPERTY_READONLY_FAST(GenericArgumentCount) + CLASS_MEMBER_PROPERTY_READONLY_FAST(TypeFriendlyName) + + CLASS_MEMBER_METHOD(GetGenericArgument, { L"index" }) + END_INTERFACE_MEMBER(ITypeInfo) + + BEGIN_ENUM_ITEM(ITypeInfo::Decorator) + ENUM_ITEM_NAMESPACE(ITypeInfo) + + ENUM_NAMESPACE_ITEM(RawPtr) + ENUM_NAMESPACE_ITEM(SharedPtr) + ENUM_NAMESPACE_ITEM(Nullable) + ENUM_NAMESPACE_ITEM(TypeDescriptor) + ENUM_NAMESPACE_ITEM(Generic) + END_ENUM_ITEM(ITypeInfo::Decorator) + + BEGIN_INTERFACE_MEMBER_NOPROXY(IMemberInfo) + CLASS_MEMBER_PROPERTY_READONLY_FAST(OwnerTypeDescriptor) + CLASS_MEMBER_PROPERTY_READONLY_FAST(Name) + END_INTERFACE_MEMBER(IMemberInfo) + + BEGIN_INTERFACE_MEMBER_NOPROXY(IEventHandler) + CLASS_MEMBER_METHOD(IsAttached, NO_PARAMETER) + END_INTERFACE_MEMBER(IEventHandler) + + BEGIN_INTERFACE_MEMBER_NOPROXY(IEventInfo) + CLASS_MEMBER_BASE(IMemberInfo) + + CLASS_MEMBER_PROPERTY_READONLY_FAST(HandlerType) + CLASS_MEMBER_PROPERTY_READONLY_FAST(ObservingPropertyCount) + + CLASS_MEMBER_METHOD(GetObservingProperty, { L"index" }) + CLASS_MEMBER_METHOD(Attach, { L"thisObject" _ L"handler" }) + CLASS_MEMBER_METHOD(Invoke, { L"thisObject" _ L"arguments" }) + END_INTERFACE_MEMBER(IEventInfo) + + BEGIN_INTERFACE_MEMBER_NOPROXY(IPropertyInfo) + CLASS_MEMBER_BASE(IMemberInfo) + + CLASS_MEMBER_PROPERTY_READONLY_FAST(Return) + CLASS_MEMBER_PROPERTY_READONLY_FAST(Getter) + CLASS_MEMBER_PROPERTY_READONLY_FAST(Setter) + CLASS_MEMBER_PROPERTY_READONLY_FAST(ValueChangedEvent) + + CLASS_MEMBER_METHOD(IsReadable, NO_PARAMETER) + CLASS_MEMBER_METHOD(IsWritable, NO_PARAMETER) + CLASS_MEMBER_METHOD(GetValue, { L"thisObject" }) + CLASS_MEMBER_METHOD(SetValue, { L"thisObject" _ L"newValue" }) + END_INTERFACE_MEMBER(IPropertyInfo) + + BEGIN_INTERFACE_MEMBER_NOPROXY(IParameterInfo) + CLASS_MEMBER_BASE(IMemberInfo) + + CLASS_MEMBER_PROPERTY_READONLY_FAST(Type) + CLASS_MEMBER_PROPERTY_READONLY_FAST(OwnerMethod) + END_CLASS_MEMBER(IParameterInfo) + + BEGIN_INTERFACE_MEMBER_NOPROXY(IMethodInfo) + CLASS_MEMBER_BASE(IMemberInfo) + + CLASS_MEMBER_PROPERTY_READONLY_FAST(OwnerMethodGroup) + CLASS_MEMBER_PROPERTY_READONLY_FAST(OwnerProperty) + CLASS_MEMBER_PROPERTY_READONLY_FAST(ParameterCount) + CLASS_MEMBER_PROPERTY_READONLY_FAST(Return) + + CLASS_MEMBER_METHOD(GetParameter, { L"index" }) + CLASS_MEMBER_METHOD(IsStatic, NO_PARAMETER) + CLASS_MEMBER_METHOD(CheckArguments, { L"arguments" }) + CLASS_MEMBER_METHOD(Invoke, { L"thisObject" _ L"arguments" }) + CLASS_MEMBER_BASE(IMemberInfo) + END_INTERFACE_MEMBER(IMethodInfo) + + BEGIN_INTERFACE_MEMBER_NOPROXY(IMethodGroupInfo) + CLASS_MEMBER_BASE(IMemberInfo) + + CLASS_MEMBER_PROPERTY_READONLY_FAST(MethodCount) + + CLASS_MEMBER_METHOD(GetMethod, { L"index" }) + END_INTERFACE_MEMBER(IMethodGroupInfo) + + BEGIN_ENUM_ITEM_MERGABLE(TypeDescriptorFlags) + ENUM_CLASS_ITEM(Object) + ENUM_CLASS_ITEM(IDescriptable) + ENUM_CLASS_ITEM(Class) + ENUM_CLASS_ITEM(Interface) + ENUM_CLASS_ITEM(Primitive) + ENUM_CLASS_ITEM(Struct) + ENUM_CLASS_ITEM(FlagEnum) + ENUM_CLASS_ITEM(NormalEnum) + END_ENUM_ITEM(TypeDescriptorFlags) + + BEGIN_INTERFACE_MEMBER_NOPROXY(ITypeDescriptor) + CLASS_MEMBER_PROPERTY_READONLY_FAST(TypeDescriptorFlags) + CLASS_MEMBER_PROPERTY_READONLY_FAST(TypeName) + CLASS_MEMBER_PROPERTY_READONLY_FAST(ValueType) + CLASS_MEMBER_PROPERTY_READONLY_FAST(EnumType) + CLASS_MEMBER_PROPERTY_READONLY_FAST(SerializableType) + CLASS_MEMBER_PROPERTY_READONLY_FAST(BaseTypeDescriptorCount) + CLASS_MEMBER_PROPERTY_READONLY_FAST(PropertyCount) + CLASS_MEMBER_PROPERTY_READONLY_FAST(EventCount) + CLASS_MEMBER_PROPERTY_READONLY_FAST(MethodGroupCount) + CLASS_MEMBER_PROPERTY_READONLY_FAST(ConstructorGroup) + + CLASS_MEMBER_METHOD(GetBaseTypeDescriptor, { L"index" }) + CLASS_MEMBER_METHOD(CanConvertTo, { L"targetType" }) + CLASS_MEMBER_METHOD(GetProperty, { L"index" }) + CLASS_MEMBER_METHOD(IsPropertyExists, { L"name" _ L"inheritable" }) + CLASS_MEMBER_METHOD(GetPropertyByName, { L"name" _ L"inheritable" }) + CLASS_MEMBER_METHOD(GetEvent, { L"index" }) + CLASS_MEMBER_METHOD(IsEventExists, { L"name" _ L"inheritable" }) + CLASS_MEMBER_METHOD(GetEventByName, { L"name" _ L"inheritable" }) + CLASS_MEMBER_METHOD(GetMethodGroup, { L"index" }) + CLASS_MEMBER_METHOD(IsMethodGroupExists, { L"name" _ L"inheritable" }) + CLASS_MEMBER_METHOD(GetMethodGroupByName, { L"name" _ L"inheritable" }) + + CLASS_MEMBER_STATIC_EXTERNALMETHOD(GetTypeDescriptorCount, NO_PARAMETER, vint(*)(), vl::reflection::description::ITypeDescriptor_GetTypeDescriptorCount) + CLASS_MEMBER_STATIC_EXTERNALMETHOD(GetTypeDescriptor, { L"index" }, ITypeDescriptor*(*)(vint), vl::reflection::description::ITypeDescriptor_GetTypeDescriptor) + CLASS_MEMBER_STATIC_EXTERNALMETHOD(GetTypeDescriptor, { L"name" }, ITypeDescriptor*(*)(const WString&), vl::reflection::description::ITypeDescriptor_GetTypeDescriptor) + CLASS_MEMBER_STATIC_EXTERNALMETHOD(GetTypeDescriptor, { L"value" }, ITypeDescriptor*(*)(const Value&), vl::reflection::description::ITypeDescriptor_GetTypeDescriptor) + END_INTERFACE_MEMBER(ITypeDescriptor) +#undef _ + + class PredefinedTypeLoader : public Object, public ITypeLoader + { + public: + void Load(ITypeManager* manager)override + { + manager->SetTypeDescriptor(TypeInfo::content.typeName, new TypedValueTypeDescriptorBase); +#define ADD_PRIMITIVE_TYPE(TYPE) manager->SetTypeDescriptor(TypeInfo::content.typeName, new PrimitiveTypeDescriptor()); + REFLECTION_PREDEFINED_PRIMITIVE_TYPES(ADD_PRIMITIVE_TYPE) +#undef ADD_PRIMITIVE_TYPE + REFLECTION_PREDEFINED_COMPLEX_TYPES(ADD_TYPE_INFO, VoidValue) + } + + void Unload(ITypeManager* manager)override + { + } + }; + +#endif + + bool LoadPredefinedTypes() + { +#ifndef VCZH_DEBUG_NO_REFLECTION + ITypeManager* manager = GetGlobalTypeManager(); + if (manager) + { + Ptr loader = new PredefinedTypeLoader; + return manager->AddTypeLoader(loader); + } +#endif + return false; + } + } + } +} + + +/*********************************************************************** +.\REFLECTION\GUITYPEDESCRIPTOR_LOG.CPP +***********************************************************************/ + +namespace vl +{ + namespace reflection + { + namespace description + { + using namespace collections; + +#ifndef VCZH_DEBUG_NO_REFLECTION + +/*********************************************************************** +LogTypeManager (enum) +***********************************************************************/ + + void LogTypeManager_Enum(stream::TextWriter& writer, ITypeDescriptor* type) + { + writer.WriteLine((type->GetTypeDescriptorFlags() == TypeDescriptorFlags::FlagEnum ? L"flags " : L"enum ") + type->GetTypeName()); + writer.WriteLine(L"{"); + + auto enumType = type->GetEnumType(); + for (vint j = 0; j < enumType->GetItemCount(); j++) + { + writer.WriteLine(L" " + enumType->GetItemName(j) + L" = " + u64tow(enumType->GetItemValue(j)) + L","); + } + + writer.WriteLine(L"}"); + } + +/*********************************************************************** +LogTypeManager (struct) +***********************************************************************/ + + void LogTypeManager_Struct(stream::TextWriter& writer, ITypeDescriptor* type) + { + writer.WriteLine(L"struct " + type->GetTypeName()); + writer.WriteLine(L"{"); + for (vint j = 0; jGetPropertyCount(); j++) + { + IPropertyInfo* info = type->GetProperty(j); + writer.WriteLine(L" " + info->GetReturn()->GetTypeFriendlyName() + L" " + info->GetName() + L";"); + } + writer.WriteLine(L"}"); + } + +/*********************************************************************** +LogTypeManager (data) +***********************************************************************/ + + void LogTypeManager_Data(stream::TextWriter& writer, ITypeDescriptor* type) + { + writer.WriteLine(L"primitive " + type->GetTypeName() + L";"); + } + +/*********************************************************************** +LogTypeManager (class) +***********************************************************************/ + + void LogTypeManager_PrintEvents(stream::TextWriter& writer, ITypeDescriptor* type) + { + bool printed = false; + for (vint j = 0; jGetEventCount(); j++) + { + printed = true; + IEventInfo* info = type->GetEvent(j); + writer.WriteString(L" event " + info->GetHandlerType()->GetTypeFriendlyName() + L" " + info->GetName() + L"{"); + if (info->GetObservingPropertyCount()>0) + { + writer.WriteString(L" observing "); + vint count = +info->GetObservingPropertyCount(); + for (vint i = 0; i0) writer.WriteString(L", "); + writer.WriteString(info->GetObservingProperty(i)->GetName()); + } + writer.WriteString(L";"); + } + writer.WriteLine(L"};"); + } + if (printed) + { + writer.WriteLine(L""); + } + } + + void LogTypeManager_PrintProperties(stream::TextWriter& writer, ITypeDescriptor* type, List& propertyAccessors) + { + bool printed = false; + for (vint j = 0; jGetPropertyCount(); j++) + { + printed = true; + IPropertyInfo* info = type->GetProperty(j); + writer.WriteString(L" property " + info->GetReturn()->GetTypeFriendlyName() + L" " + info->GetName() + L"{"); + if (info->GetGetter()) + { + propertyAccessors.Add(info->GetGetter()); + writer.WriteString(L" getter " + info->GetGetter()->GetName() + L";"); + } + if (info->GetSetter()) + { + propertyAccessors.Add(info->GetSetter()); + writer.WriteString(L" setter " + info->GetSetter()->GetName() + L";"); + } + if (info->GetValueChangedEvent()) + { + writer.WriteString(L" raising " + info->GetValueChangedEvent()->GetName() + L";"); + } + writer.WriteLine(L"}"); + } + if (printed) + { + writer.WriteLine(L""); + } + } + + void LogTypeManager_PrintMethods(stream::TextWriter& writer, ITypeDescriptor* type, const List& propertyAccessors, bool isPropertyAccessor) + { + bool printed = false; + for (vint j = 0; jGetMethodGroupCount(); j++) + { + IMethodGroupInfo* group = type->GetMethodGroup(j); + for (vint k = 0; kGetMethodCount(); k++) + { + IMethodInfo* info = group->GetMethod(k); + if (propertyAccessors.Contains(info) == isPropertyAccessor) + { + printed = true; + writer.WriteString(WString(L" ") + (info->IsStatic() ? L"static " : L"") + (isPropertyAccessor ? L"accessor " : L"function ") + info->GetReturn()->GetTypeFriendlyName()); + writer.WriteString(L" " + info->GetName() + L"("); + for (vint l = 0; lGetParameterCount(); l++) + { + if (l>0) writer.WriteString(L", "); + IParameterInfo* parameter = info->GetParameter(l); + writer.WriteString(parameter->GetType()->GetTypeFriendlyName() + L" " + parameter->GetName()); + } + writer.WriteLine(L");"); + } + } + } + if (printed) + { + writer.WriteLine(L""); + } + } + + void LogTypeManager_PrintConstructors(stream::TextWriter& writer, ITypeDescriptor* type) + { + if (IMethodGroupInfo* group = type->GetConstructorGroup()) + { + for (vint k = 0; kGetMethodCount(); k++) + { + IMethodInfo* info = group->GetMethod(k); + writer.WriteString(L" constructor " + info->GetReturn()->GetTypeFriendlyName()); + writer.WriteString(L" " + info->GetName() + L"("); + for (vint l = 0; lGetParameterCount(); l++) + { + if (l>0) writer.WriteString(L", "); + IParameterInfo* parameter = info->GetParameter(l); + writer.WriteString(parameter->GetType()->GetTypeFriendlyName() + L" " + parameter->GetName()); + } + writer.WriteLine(L");"); + } + } + } + + void LogTypeManager_Class(stream::TextWriter& writer, ITypeDescriptor* type) + { + bool acceptProxy = false; + bool isInterface = (type->GetTypeDescriptorFlags() & TypeDescriptorFlags::InterfaceType) != TypeDescriptorFlags::Undefined; + writer.WriteString((isInterface ? L"interface " : L"class ") + type->GetTypeName()); + for (vint j = 0; jGetBaseTypeDescriptorCount(); j++) + { + writer.WriteString(j == 0 ? L" : " : L", "); + writer.WriteString(type->GetBaseTypeDescriptor(j)->GetTypeName()); + } + writer.WriteLine(L""); + writer.WriteLine(L"{"); + + List propertyAccessors; + LogTypeManager_PrintEvents(writer, type); + LogTypeManager_PrintProperties(writer, type, propertyAccessors); + LogTypeManager_PrintMethods(writer, type, propertyAccessors, false); + LogTypeManager_PrintMethods(writer, type, propertyAccessors, true); + LogTypeManager_PrintConstructors(writer, type); + + writer.WriteLine(L"}"); + } + +/*********************************************************************** +LogTypeManager +***********************************************************************/ + + bool IsInterfaceType(ITypeDescriptor* typeDescriptor, bool& acceptProxy) + { + bool containsConstructor = false; + if (IMethodGroupInfo* group = typeDescriptor->GetConstructorGroup()) + { + containsConstructor = group->GetMethodCount() > 0; + if (group->GetMethodCount() == 1) + { + if (IMethodInfo* info = group->GetMethod(0)) + { + if (info->GetParameterCount() == 1 && info->GetParameter(0)->GetType()->GetTypeDescriptor()->GetTypeName() == TypeInfo::content.typeName) + { + acceptProxy = true; + return true; + } + } + } + } + + if (!containsConstructor) + { + if (typeDescriptor->GetTypeName() == TypeInfo::content.typeName) + { + return true; + } + else + { + for (vint i = 0; i < typeDescriptor->GetBaseTypeDescriptorCount(); i++) + { + bool _acceptProxy = false; + if (!IsInterfaceType(typeDescriptor->GetBaseTypeDescriptor(i), _acceptProxy)) + { + return false; + } + } + const wchar_t* name = typeDescriptor->GetTypeName().Buffer(); + while (const wchar_t* next = ::wcschr(name, L':')) + { + name = next + 1; + } + return name[0] == L'I' && (L'A' <= name[1] && name[1] <= L'Z'); + } + } + return false; + } + + void LogTypeManager(stream::TextWriter& writer) + { + for (vint i = 0; i < GetGlobalTypeManager()->GetTypeDescriptorCount(); i++) + { + ITypeDescriptor* type = GetGlobalTypeManager()->GetTypeDescriptor(i); + + switch (type->GetTypeDescriptorFlags()) + { + case TypeDescriptorFlags::Object: + case TypeDescriptorFlags::IDescriptable: + case TypeDescriptorFlags::Class: + case TypeDescriptorFlags::Interface: + LogTypeManager_Class(writer, type); + break; + case TypeDescriptorFlags::FlagEnum: + case TypeDescriptorFlags::NormalEnum: + LogTypeManager_Enum(writer, type); + break; + case TypeDescriptorFlags::Primitive: + LogTypeManager_Data(writer, type); + break; + case TypeDescriptorFlags::Struct: + LogTypeManager_Struct(writer, type); + break; + default:; + } + writer.WriteLine(L""); + } + } + +#endif + } + } +} + + +/*********************************************************************** +.\PARSING\JSON\PARSINGJSON.CPP +***********************************************************************/ + +namespace vl +{ + namespace parsing + { + namespace json + { + using namespace stream; + using namespace collections; + +/*********************************************************************** +Unescaping Function Foward Declarations +***********************************************************************/ + + void JsonUnescapingString(vl::parsing::ParsingToken& value, const vl::collections::List& tokens) + { + MemoryStream stream; + { + StreamWriter writer(stream); + JsonUnescapeString(value.value.Sub(1, value.value.Length()-2), writer); + } + stream.SeekFromBegin(0); + { + StreamReader reader(stream); + value.value=reader.ReadToEnd(); + } + } + +/*********************************************************************** +JsonPrintVisitor +***********************************************************************/ + + class JsonPrintVisitor : public Object, public JsonNode::IVisitor + { + public: + TextWriter& writer; + + JsonPrintVisitor(TextWriter& _writer) + :writer(_writer) + { + } + + void Visit(JsonLiteral* node) + { + switch(node->value) + { + case JsonLiteral::JsonValue::True: + writer.WriteString(L"true"); + break; + case JsonLiteral::JsonValue::False: + writer.WriteString(L"false"); + break; + case JsonLiteral::JsonValue::Null: + writer.WriteString(L"null"); + break; + } + } + + void Visit(JsonString* node) + { + writer.WriteChar(L'\"'); + JsonEscapeString(node->content.value, writer); + writer.WriteChar(L'\"'); + } + + void Visit(JsonNumber* node) + { + writer.WriteString(node->content.value); + } + + void Visit(JsonArray* node) + { + writer.WriteChar(L'['); + FOREACH_INDEXER(Ptr, item, i, node->items) + { + if(i>0) writer.WriteChar(L','); + item->Accept(this); + } + writer.WriteChar(L']'); + } + + void Visit(JsonObjectField* node) + { + writer.WriteChar(L'\"'); + JsonEscapeString(node->name.value, writer); + writer.WriteString(L"\":"); + node->value->Accept(this); + } + + void Visit(JsonObject* node) + { + writer.WriteChar(L'{'); + FOREACH_INDEXER(Ptr, field, i, node->fields) + { + if(i>0) writer.WriteChar(L','); + field->Accept(this); + } + writer.WriteChar(L'}'); + } + }; + +/*********************************************************************** +API +***********************************************************************/ + + void JsonEscapeString(const WString& text, stream::TextWriter& writer) + { + const wchar_t* reading=text.Buffer(); + while(wchar_t c=*reading++) + { + switch(c) + { + case L'\"': writer.WriteString(L"\\\""); break; + case L'\\': writer.WriteString(L"\\\\"); break; + case L'/': writer.WriteString(L"\\/"); break; + case L'\b': writer.WriteString(L"\\b"); break; + case L'\f': writer.WriteString(L"\\f"); break; + case L'\n': writer.WriteString(L"\\n"); break; + case L'\r': writer.WriteString(L"\\r"); break; + case L'\t': writer.WriteString(L"\\t"); break; + default: writer.WriteChar(c); + } + } + } + + vuint16_t GetHex(wchar_t c) + { + if(L'0'<=c && c<=L'9') + { + return c-L'0'; + } + else if(L'A'<=c && c<=L'F') + { + return c-L'A'; + } + else if(L'a'<=c && c<=L'f') + { + return c-L'a'; + } + else + { + return 0; + } + } + + void JsonUnescapeString(const WString& text, stream::TextWriter& writer) + { + const wchar_t* reading=text.Buffer(); + while(wchar_t c=*reading++) + { + if(c==L'\\' && *reading) + { + switch(c=*reading++) + { + case L'b': writer.WriteChar(L'\b'); break; + case L'f': writer.WriteChar(L'\f'); break; + case L'n': writer.WriteChar(L'\n'); break; + case L'r': writer.WriteChar(L'\r'); break; + case L't': writer.WriteChar(L'\t'); break; + case L'u': + { + wchar_t h1, h2, h3, h4; + if((h1=reading[0]) && (h2=reading[1]) && (h3=reading[2]) && (h4=reading[3])) + { + reading+=4; + wchar_t h=(wchar_t)(vuint16_t)( + (GetHex(h1)<<12) + + (GetHex(h2)<<8) + + (GetHex(h3)<<4) + + (GetHex(h4)<<0) + ); + writer.WriteChar(h); + } + } + break; + default: writer.WriteChar(c); + } + } + else + { + writer.WriteChar(c); + } + } + } + + void JsonPrint(Ptr node, stream::TextWriter& writer) + { + JsonPrintVisitor visitor(writer); + node->Accept(&visitor); + } + + WString JsonToString(Ptr node) + { + MemoryStream stream; + { + StreamWriter writer(stream); + JsonPrint(node, writer); + } + stream.SeekFromBegin(0); + { + StreamReader reader(stream); + return reader.ReadToEnd(); + } + } + } + } +} + + +/*********************************************************************** +.\PARSING\JSON\PARSINGJSON_AST.CPP +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Parser::ParsingJson.parser.txt + +This file is generated by: Vczh Parser Generator +***********************************************************************/ + + +namespace vl +{ + namespace parsing + { + namespace json + { +/*********************************************************************** +Visitor Pattern Implementation +***********************************************************************/ + + void JsonLiteral::Accept(JsonNode::IVisitor* visitor) + { + visitor->Visit(this); + } + + void JsonString::Accept(JsonNode::IVisitor* visitor) + { + visitor->Visit(this); + } + + void JsonNumber::Accept(JsonNode::IVisitor* visitor) + { + visitor->Visit(this); + } + + void JsonArray::Accept(JsonNode::IVisitor* visitor) + { + visitor->Visit(this); + } + + void JsonObjectField::Accept(JsonNode::IVisitor* visitor) + { + visitor->Visit(this); + } + + void JsonObject::Accept(JsonNode::IVisitor* visitor) + { + visitor->Visit(this); + } + + } + } +} +namespace vl +{ + namespace reflection + { + namespace description + { +#ifndef VCZH_DEBUG_NO_REFLECTION + using namespace vl::parsing::json; + +#define PARSING_TOKEN_FIELD(NAME)\ + CLASS_MEMBER_EXTERNALMETHOD_TEMPLATE(get_##NAME, NO_PARAMETER, vl::WString(ClassType::*)(), [](ClassType* node) { return node->NAME.value; }, L"*", L"*")\ + CLASS_MEMBER_EXTERNALMETHOD_TEMPLATE(set_##NAME, { L"value" }, void(ClassType::*)(const vl::WString&), [](ClassType* node, const vl::WString& value) { node->NAME.value = value; }, L"*", L"*")\ + CLASS_MEMBER_PROPERTY_REFERENCETEMPLATE(NAME, get_##NAME, set_##NAME, L"$This->$Name.value")\ + + IMPL_TYPE_INFO_RENAME(vl::parsing::json::JsonNode, system::JsonNode) + IMPL_TYPE_INFO_RENAME(vl::parsing::json::JsonLiteral, system::JsonLiteral) + IMPL_TYPE_INFO_RENAME(vl::parsing::json::JsonLiteral::JsonValue, system::JsonLiteral::JsonValue) + IMPL_TYPE_INFO_RENAME(vl::parsing::json::JsonString, system::JsonString) + IMPL_TYPE_INFO_RENAME(vl::parsing::json::JsonNumber, system::JsonNumber) + IMPL_TYPE_INFO_RENAME(vl::parsing::json::JsonArray, system::JsonArray) + IMPL_TYPE_INFO_RENAME(vl::parsing::json::JsonObjectField, system::JsonObjectField) + IMPL_TYPE_INFO_RENAME(vl::parsing::json::JsonObject, system::JsonObject) + IMPL_TYPE_INFO_RENAME(vl::parsing::json::JsonNode::IVisitor, system::JsonNode::IVisitor) + + BEGIN_CLASS_MEMBER(JsonNode) + CLASS_MEMBER_METHOD_OVERLOAD(Accept, {L"visitor"}, void(JsonNode::*)(JsonNode::IVisitor* visitor)) + END_CLASS_MEMBER(JsonNode) + + BEGIN_CLASS_MEMBER(JsonLiteral) + CLASS_MEMBER_BASE(JsonNode) + + CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) + + CLASS_MEMBER_FIELD(value) + END_CLASS_MEMBER(JsonLiteral) + + BEGIN_ENUM_ITEM(JsonLiteral::JsonValue) + ENUM_ITEM_NAMESPACE(JsonLiteral::JsonValue) + ENUM_NAMESPACE_ITEM(True) + ENUM_NAMESPACE_ITEM(False) + ENUM_NAMESPACE_ITEM(Null) + END_ENUM_ITEM(JsonLiteral::JsonValue) + + BEGIN_CLASS_MEMBER(JsonString) + CLASS_MEMBER_BASE(JsonNode) + + CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) + + PARSING_TOKEN_FIELD(content) + END_CLASS_MEMBER(JsonString) + + BEGIN_CLASS_MEMBER(JsonNumber) + CLASS_MEMBER_BASE(JsonNode) + + CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) + + PARSING_TOKEN_FIELD(content) + END_CLASS_MEMBER(JsonNumber) + + BEGIN_CLASS_MEMBER(JsonArray) + CLASS_MEMBER_BASE(JsonNode) + + CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) + + CLASS_MEMBER_FIELD(items) + END_CLASS_MEMBER(JsonArray) + + BEGIN_CLASS_MEMBER(JsonObjectField) + CLASS_MEMBER_BASE(JsonNode) + + CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) + + PARSING_TOKEN_FIELD(name) + CLASS_MEMBER_FIELD(value) + END_CLASS_MEMBER(JsonObjectField) + + BEGIN_CLASS_MEMBER(JsonObject) + CLASS_MEMBER_BASE(JsonNode) + + CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) + + CLASS_MEMBER_FIELD(fields) + END_CLASS_MEMBER(JsonObject) + + BEGIN_INTERFACE_MEMBER(JsonNode::IVisitor) + CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(JsonNode::IVisitor::*)(JsonLiteral* node)) + CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(JsonNode::IVisitor::*)(JsonString* node)) + CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(JsonNode::IVisitor::*)(JsonNumber* node)) + CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(JsonNode::IVisitor::*)(JsonArray* node)) + CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(JsonNode::IVisitor::*)(JsonObjectField* node)) + CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(JsonNode::IVisitor::*)(JsonObject* node)) + END_INTERFACE_MEMBER(JsonNode) + +#undef PARSING_TOKEN_FIELD + + class JsonTypeLoader : public vl::Object, public ITypeLoader + { + public: + void Load(ITypeManager* manager) + { + ADD_TYPE_INFO(vl::parsing::json::JsonNode) + ADD_TYPE_INFO(vl::parsing::json::JsonLiteral) + ADD_TYPE_INFO(vl::parsing::json::JsonLiteral::JsonValue) + ADD_TYPE_INFO(vl::parsing::json::JsonString) + ADD_TYPE_INFO(vl::parsing::json::JsonNumber) + ADD_TYPE_INFO(vl::parsing::json::JsonArray) + ADD_TYPE_INFO(vl::parsing::json::JsonObjectField) + ADD_TYPE_INFO(vl::parsing::json::JsonObject) + ADD_TYPE_INFO(vl::parsing::json::JsonNode::IVisitor) + } + + void Unload(ITypeManager* manager) + { + } + }; +#endif + + bool JsonLoadTypes() + { +#ifndef VCZH_DEBUG_NO_REFLECTION + ITypeManager* manager=GetGlobalTypeManager(); + if(manager) + { + Ptr loader=new JsonTypeLoader; + return manager->AddTypeLoader(loader); + } +#endif + return false; + } + } + } +} + + +/*********************************************************************** +.\PARSING\JSON\PARSINGJSON_PARSER.CPP +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Parser::ParsingJson.parser.txt + +This file is generated by: Vczh Parser Generator +***********************************************************************/ + + +namespace vl +{ + namespace parsing + { + namespace json + { +/*********************************************************************** +ParserText +***********************************************************************/ + +const wchar_t parserTextBuffer[] = +L"\r\n" L"" +L"\r\n" L"//////////////////////////////////////////////////////////////////" +L"\r\n" L"// AST" +L"\r\n" L"//////////////////////////////////////////////////////////////////" +L"\r\n" L"" +L"\r\n" L"class Node" +L"\r\n" L"{" +L"\r\n" L"}" +L"\r\n" L"" +L"\r\n" L"class Literal:Node" +L"\r\n" L"{" +L"\r\n" L"\tenum Value" +L"\r\n" L"\t{" +L"\r\n" L"\t\tTrue," +L"\r\n" L"\t\tFalse," +L"\r\n" L"\t\tNull," +L"\r\n" L"\t}" +L"\r\n" L"" +L"\r\n" L"\tValue value;" +L"\r\n" L"}" +L"\r\n" L"" +L"\r\n" L"class String:Node" +L"\r\n" L"{" +L"\r\n" L"\ttoken content(JsonUnescapingString)\t\t\t\t@Color(\"String\");" +L"\r\n" L"}" +L"\r\n" L"" +L"\r\n" L"class Number:Node" +L"\r\n" L"{" +L"\r\n" L"\ttoken content;" +L"\r\n" L"}" +L"\r\n" L"" +L"\r\n" L"class Array:Node" +L"\r\n" L"{" +L"\r\n" L"\tNode[] items;" +L"\r\n" L"}" +L"\r\n" L"" +L"\r\n" L"class ObjectField:Node" +L"\r\n" L"{" +L"\r\n" L"\ttoken name(JsonUnescapingString)\t\t\t\t@Color(\"AttName\");" +L"\r\n" L"\tNode value;" +L"\r\n" L"}" +L"\r\n" L"" +L"\r\n" L"class Object:Node" +L"\r\n" L"{" +L"\r\n" L"\tObjectField[] fields;" +L"\r\n" L"}" +L"\r\n" L"" +L"\r\n" L"//////////////////////////////////////////////////////////////////" +L"\r\n" L"// Lexer" +L"\r\n" L"//////////////////////////////////////////////////////////////////" +L"\r\n" L"" +L"\r\n" L"token TRUEVALUE = \"true\"\t\t\t\t\t\t\t@Color(\"Keyword\");" +L"\r\n" L"token FALSEVALUE = \"false\"\t\t\t\t\t\t\t@Color(\"Keyword\");" +L"\r\n" L"token NULLVALUE = \"null\"\t\t\t\t\t\t\t@Color(\"Keyword\");" +L"\r\n" L"token OBJOPEN = \"\\{\"\t\t\t\t\t\t\t\t@Color(\"Boundary\");" +L"\r\n" L"token OBJCLOSE = \"\\}\"\t\t\t\t\t\t\t\t@Color(\"Boundary\");" +L"\r\n" L"token ARROPEN = \"\\[\"\t\t\t\t\t\t\t\t@Color(\"Boundary\");" +L"\r\n" L"token ARRCLOSE = \"\\]\"\t\t\t\t\t\t\t\t@Color(\"Boundary\");" +L"\r\n" L"token COMMA = \",\";" +L"\r\n" L"token COLON = \":\";" +L"\r\n" L"token NUMBER = \"[\\-]?\\d+(.\\d+)?([eE][+\\-]?\\d+)?\"\t@Color(\"Number\");" +L"\r\n" L"token STRING = \"\"\"([^\\\\\"\"]|\\\\[^u]|\\\\u\\d{4})*\"\"\"\t\t@ContextColor();" +L"\r\n" L"" +L"\r\n" L"discardtoken SPACE = \"\\s+\";" +L"\r\n" L"" +L"\r\n" L"//////////////////////////////////////////////////////////////////" +L"\r\n" L"// Rules" +L"\r\n" L"//////////////////////////////////////////////////////////////////" +L"\r\n" L"" +L"\r\n" L"rule Node JLiteral" +L"\r\n" L"\t= STRING:content as String" +L"\r\n" L"\t= NUMBER:content as Number" +L"\r\n" L"\t= \"true\" as Literal with {value = \"True\"}" +L"\r\n" L"\t= \"false\" as Literal with {value = \"False\"}" +L"\r\n" L"\t= \"null\" as Literal with {value = \"Null\"}" +L"\r\n" L"\t;" +L"\r\n" L"" +L"\r\n" L"rule ObjectField JField" +L"\r\n" L"\t= STRING:name \":\" JValue:value as ObjectField" +L"\r\n" L"\t;" +L"\r\n" L"" +L"\r\n" L"rule Object JObject" +L"\r\n" L"\t= \"{\" [JField:fields {\",\" JField:fields} ] \"}\" as Object" +L"\r\n" L"\t;" +L"\r\n" L"" +L"\r\n" L"rule Array JArray" +L"\r\n" L"\t= \"[\" [JValue:items {\",\" JValue:items} ] \"]\" as Array" +L"\r\n" L"\t;" +L"\r\n" L"" +L"\r\n" L"rule Node JValue" +L"\r\n" L"\t= !JLiteral" +L"\r\n" L"\t= !JObject" +L"\r\n" L"\t= !JArray" +L"\r\n" L"\t;" +L"\r\n" L"" +L"\r\n" L"rule Node JRoot" +L"\r\n" L"\t= !JObject" +L"\r\n" L"\t= !JArray" +L"\r\n" L"\t;" +; + + vl::WString JsonGetParserTextBuffer() + { + return parserTextBuffer; + } + +/*********************************************************************** +SerializedTable +***********************************************************************/ + +const vint parserBufferLength = 3779; // 17748 bytes before compressing +const vint parserBufferBlock = 1024; +const vint parserBufferRemain = 707; +const vint parserBufferRows = 4; +const char* parserBuffer[] = { +"\x00\x0B\x00\x02\x83\x80\x07\x7D\x00\x82\x03\xFF\x45\x08\x82\x83\x86\x81\x21\x6F\x6C\x2F\x32\x37\x84\x86\x02\x86\x00\x17\x82\x93\x24\x3A\x39\x34\x37\x67\x06\x98\x8A\x88\x8E\x84\x00\x88\x12\x94\x98\x87\x0B\x93\x81\x20\x3A\x74\x4E\x21\x2D\x35\x32\x90\x86\x92\x0C\xA6\xA8\x93\x85\x88\x84\x96\x86\x3F\x80\x0B\x25\x39\x3F\x3B\x88\x32\x36\x88\xB8\x88\x8A\x99\x88\x9F\x96\x40\x83\x83\xA5\xA7\xA1\xA4\x83\xA5\x04\xCD\xA9\x9D\x94\x81\xA1\xAE\xA9\x44\xC6\xB2\x28\xAC\xA9\x86\x93\xAC\x03\xBB\xAA\x8C\x88\x00\x8D\xB6\x81\x42\x6F\x35\x2E\x34\x31\x32\x39\x3C\x56\xE6\xA5\x89\xBE\xA3\xB4\x85\xB7\x7F\x83\xB1\xB3\xB5\xBF\xB9\xBC\x81\x58\x83\x9A\xAF\xAC\xB6\xB6\xC0\xB9\x74\xF6\xB8\xA5\xB8\xC7\xB2\xC4\xBE\x5B\x8E\xCD\xD0\xB0\xCD\xC3\xC9\x91\x96\x8D\x98\xCC\xC8\x82\x8D\xD3\x81\x4E\x75\x2D\x22\x35\x32\x3B\xC3\x82\x0C\x18\xB1\xCF\x8F\x36\x34\x3B\x32\x78\x74\x2A\xB8\x80\x06\xAF\xCB\x9C\x2E\xF2\x32\x21\x38\xBF\x7E\xE3\xE3\xFF\x3E\xC2\x81\xAC\x21\x37\xDB\xE1\x6C\x48\xC8\xE4\x08\x8C\xEA\x80\x27\x6F\x64\x35\x92\xE6\xE6\xD0\x82\xD3\xA9\xAB\xED\xDC\xED\xE8\x8E\xD3\x27\x62\x6A\x25\x23\x34\x3C\xF3\x7F\x80\x0C\xF0\xC0\x08\xFA\xF4\xF6\x23\x34\x65\x6C\x08\xA4\xFE\xEB\x82\xD2\x8E\x1E\x60\x4E\x7A\x72\x00\x21\x65\x81\x70\xC3\x79\x16\x82\x49\xCE\x65\x1D\x1B\x1C\x03\x90\x50\x01\x73\xCF\x61\x1C\x1B\x82\x03\x76\x16\x85\x1D\xDB\x5C\x7D\x7E\x40\xE0\x6A\x6C\x6A\x1C\x04\x81\x53\x19\x6D\xB7\x76\x6E\x7B\x87\x19\x43\x44\x7F\x7A\x74\x2C\x86\x6A\x19\xF8\x7A\x70\x84\x79\xF2\x44\x42\x7F\x8B\xF6\x75\x84\x1A\x75\x08\x40\x9E\x1B\x4C\x65\x14\x60\x40\x46\x3B\xA9\x70\x8F\x7D\xF9\x64\x18\x86\x40\x1A\xAC\x1C\x87\x8A\xE6\x43\x40\x83\x47\x67\x25\x83\x43\x89\xB6\x65\x16\x6C\x6F\x0F\x18\x44\x08\x46\x61\xBC\x66\x9A\x52\xEE\x64\x77\x9B\x4D\x69\x9C\x7B\x98\x9A\x6D\x88\x7F\x9B\x55\x71\x88\x79\x00\x46\x77\x82\x44\x16\x14\x55\x05\x16\x15\x10\x4C\x3D\x90\x90\x41\x40\x9D\x4C\x84\x6F\x02\x18\x4A\x02\xA2\x03\x46\x10\xA3\x14\x7E\x80\xAD\x9F\x93\x00\x26\x16\x87\x1C\x45\x98\x43\x00\x9E\x9C\x97\x75\x14\x13\x4C\x3F\x91\xA1\x11\x83\x83\x42\x91\x1D\x6C\x2C\x19\xA0\x43\xA5\x8B\x72\x87\x13\x42\x0A\x1F\x10\x14\x45\x0E\x1B\xA8\x42\xB7\x9C\x1B\x1F\xA6\xC0\x5B\x61\x62\x40\xB0\x8A\x13\x10\x13\x4F\x10\xA7\xAC\x41\xB9\xBD\x1D\xA9\x8B\x51\x4D\xB0\x01\x10\x52\x12\x13\xAD\xAD\xC7\x83\x49\xAF\x16\x06\x84\x80\x60\x41\x80\x50\xB2\x17\xB0\xC5\x85\x15\xB6\x40\xB9\x9D\x1C\x8B\xB6\xBF\x4C\x59\x5B\x13\x4D\x0D\x11\x12\x91\x3D\x6C\x04\x82\x7B\x94\x83\x1F\x10\xB1\x4E\x30\xB3\x42\x0E\xE8\x88\x6C\x7D\x95\x9E\x8D\x12\x11\x11\x52\x1F\x08\x46\xC1\x02\x5B\x1C\x15\x0B\x5D\x3F\x0C\x14\x19\x2B\x28\x0E\x0B\xC3\x2B\x29\x0F\x0C\x0A\x5B\x25\x15\x11\x17\x5B\x2B\x0B\xC1\xC3\x14\xD6\xC9\x9C\x42\x23\xDF\x70\xC0\x00\x53\x3B\x99\x12\x13\x47\x1B\x08\x46\xCB\x02\x62\x08\xC6\x17\x5C\x1C\x12\x09\x17\x7C\x35\xCB\x16\x17\x75\x38\xC5\xCD\x1D\x0F\xFB\x14\x0D\x1F\x29\x2A\x02\x0B\xA2\x0C\x48\xD8\x42\x91\x94\x93\x10\x15\x10\x43\x05\x1C\xAC\x42\x53\xDC\x13\x1F\x0A\x39\x89\x44\x7B\x98\x16\x67\xCA\x10\x93\xFA\x50\x08\x46\xD8\x02\x5F\xDE\x8E\x0B\x52\x2F\x1F\x18\x1D\x1C\x76\x54\x1D\xD6\x02\x72\x70\x10\x08\x24\x3C\x06\xD9\x93\x3E\x32\x83\x43\xDD\xFA\x73\x68\x42\xDF\x7C\xE4\x1E\x09\xDB\x72\x34\x1A\xD0\x41\x4A\xF3\xD6\xDC\xD8\x64\x39\xDE\xD4\xE3\xFD\x80\x00\x61\xE0\x2E\x31\x0A\x0C\x46\x97\xC2\x4B\xE2\x8F\x3E\x3A\x00\x09\xCA\x52\x2B\xC7\x10\x08\x9E\xC3\x94\x4F\xDC\x22\x3A\x02\x08\x08\x4A\x16\x1B\x85\x19\xA4\xE0\x01\x94\x87\x20\x21\x13\x1C\x08\x3C\xB4\x1C\xE2\xDE\x65\xD0\xEA\x64\x00\x94\xF2\x09\xE4\x42\xC3\xDB\xE8\xDE\xE7\xA0\xE2\xE1\xEE\xE9\xB0\xE9\xE2\x0B\xDC\xAD\xEF\xE1\xEF\xEC\xB0\xF6\xE8\xEE\x92\x3D\x8D\x91\xE7\xE4\x14\xAD\x66\x87\xE1\x03\x4A\xDA\x11\xF7\xD0\x55\xEA\x3C\x46\xE7\xDA\xE3\xF9\x83\xD0\x5D\xE0\x0A\x08\x6E\x28\xAC\x1B\xEA\xD6\xE4\xF6\x87\xDC\x77\x0E\x78\x18\x08\x7B\x32\xE2\xF5\x0F\xEF\x69\x35\xAA\x2B\x7D\x0F\x06\x0A\x06\x6E\xF6\x6C\x0E\xFB\x22\x06\x52\x36\x18\x54\x7E\xB7\x69\x80\xFE\x7A\x7C\x7E\xFF\x52\x48\x76\x00\x82\x06\x11\x17\x55\x0C\x02\x86\x80\x81\xEC\x76\x42\xFB\x4E\x05\x0A\x81\x44\x61\x76\x5C\x49\x44\x1D\x35\x77\x77\xF0\x23\x40\x08\x1F\x8B\x7D\x85\x0A\x88\x78\x95\x6C\x60\x85\x28\x5E\x4B\x0A\xD6\x77\x4A\x90\x30\x87\x80\x32\x9E\x78\x0D\xEF\x76\x51", +"\x0E\xAC\x80\x04\x12\x80\x05\xFE\x74\x0B\x7F\xFE\x54\x78\x04\x19\x94\x0A\x1C\x1C\x44\x80\x2D\x65\x69\x77\x25\x63\x23\xC8\x32\x58\x7A\x3A\x15\x71\x09\x18\x20\x8E\xFA\x39\x7B\x81\x3D\x0F\x78\x04\x5B\x0C\x74\xE3\x31\x74\x47\x26\x77\x75\x7F\x22\x0C\x07\xEA\x01\x7C\x8C\x1F\x77\x75\x0F\x20\x1D\x0B\xFB\x7D\x00\x83\xEB\x75\x39\x46\x5E\x61\x0A\x70\x44\x3B\x7B\xBD\x42\x91\x41\x95\x65\x08\x46\x0A\x9A\x7D\x43\x84\x3B\x81\x5B\x07\x8D\x1A\xD1\x77\x83\xD8\x4D\x47\x41\x15\x91\x8F\x1C\xAE\x75\x92\xCF\x57\x97\x8E\x79\x8F\x7D\x17\x7D\x8E\x91\x3C\x05\x95\x6C\x09\x84\x6C\x42\x2A\x91\x89\xF2\x69\x6B\x6D\x45\x14\x2D\x03\x18\x23\x96\x81\x35\x6D\x95\x22\x80\x04\x10\x3C\x70\x78\x4E\x9C\x47\x94\xBD\x8F\x75\xE5\x3D\x08\x22\x62\xAA\x7E\x97\x65\x0E\x7D\x08\x4A\x05\x95\x1F\xB6\x68\x99\xCA\x98\x94\x1B\x4E\x94\x92\x0E\x51\x99\x77\x40\x16\x88\xF0\x58\x8D\x53\x6D\x9D\x8E\x05\x32\x02\x8C\x42\x62\x96\x6E\x32\x9E\x72\x04\x66\x88\x8E\x1A\xBE\x45\x8E\x37\x99\x92\x8E\xEB\x8D\x49\x3B\xB6\x40\x04\x3C\xBA\x8A\x04\x7C\x87\x88\x36\xBC\x9C\x99\x41\xA6\x97\x77\xFD\x88\x93\x0C\x0C\x98\x20\x82\xB6\x6D\x94\x90\x8B\x77\x24\xC8\x96\x93\xDB\x18\x90\x8E\xF0\x95\x98\xEC\x1E\x9E\xA0\x50\xB7\x9B\x94\x47\x8D\x98\x3F\xBE\x7E\x56\xCA\x73\x03\x78\x04\x25\x79\xE0\x6E\x79\x79\x1B\xA5\x74\x48\xEF\x6A\x74\xEB\x0C\xAE\x73\x27\x96\x79\x77\x8C\x7B\x95\x20\xFE\x90\x99\x80\x84\x38\x9C\x8C\x18\x21\x4E\x8D\x9E\x9F\x84\xAA\x9A\xA2\x0D\xAE\x43\x1C\x73\x60\xA3\x4D\x92\x7C\xA2\x42\xB5\x9D\x28\xB7\x64\x94\x7F\xB1\x80\xA1\xE7\x91\x93\x4F\xAC\xA0\x05\x4F\xBA\x95\xA8\x2B\xA7\xA9\x55\x95\xAA\xA9\x8B\x8D\xA9\x41\xFC\x88\x9A\x03\x18\x23\xAD\xB2\x48\x98\x6D\x6A\x74\x0D\x2C\xE4\x00\x6F\x23\x76\x97\x99\xAF\x7E\x06\x2E\xDA\x9C\x8B\x3F\xA5\x48\x21\x77\xB5\xAC\x8C\x68\xA0\x96\xBA\x3E\x6C\x20\x7E\x77\x94\x19\xBA\x94\x52\x25\x2F\x94\x0E\x74\xA7\xB1\xE5\x25\x08\x22\xC6\xAA\x7F\xB0\xD7\x9D\x88\x35\x90\xBE\x73\x65\x9A\xA3\xA6\x09\x45\xAC\x42\x1A\xB6\xA7\x3C\x3C\xAA\xAD\x74\x2D\xAE\x7C\x37\x98\xA0\x5D\x9B\xA6\x47\x9A\xA4\x20\x67\x8C\x7F\xB3\xB5\xA2\xB3\x20\xB7\x8C\x72\x5C\xD9\x92\x42\xBD\xAC\x39\x8B\x02\x3B\x89\xEE\x2E\x05\x06\x4A\x18\x26\xB7\x63\x9D\x89\x19\x8A\xA1\x9E\xFD\x33\x9C\x0C\xB7\x60\x08\x56\xF4\x8E\x73\x36\xB4\x9E\x9E\x7B\x9D\x8D\xEE\x31\x86\x9D\xF7\x69\x9B\x92\x6B\x8D\xBA\x1D\xC4\xAF\x7D\x88\x99\xB8\x04\xCE\xA8\xB9\x57\xD1\xBA\x9F\x2E\xBC\x9D\x94\x35\xA5\x96\x0B\x34\x04\xA0\x82\x06\xA5\xB3\x3E\xAB\xA2\x56\xD6\xA5\xA8\xE8\x54\xAE\xAA\xD0\xAC\xA9\x46\xFE\x95\xB1\xC3\xB5\x90\x21\xFF\xA6\xB1\x5A\xAD\xB4\x2E\xF0\x42\x22\x69\xB7\x90\xB3\x5C\xB5\xBC\x9A\x86\x3A\xB7\x9B\x33\x02\x9C\x41\x64\x96\xB6\x3A\x03\xBF\xA7\xDF\xA1\xBF\x1B\xDD\xB7\x8C\xE6\xA0\xBE\x8E\xE3\xB8\x9E\x74\xDD\x84\xAF\xDC\x51\x00\x23\x27\xD7\x8B\x37\x87\xB4\x70\x3A\x3F\xAB\x20\x7E\x73\x6E\x60\xC2\xB5\xC5\x2E\xBF\xBC\x20\x01\xDB\xB5\x8B\xAF\xB2\x20\xC5\x55\xC6\x07\x35\xA9\x82\x04\x18\x23\xC8\x54\xA1\x84\x0D\x9F\xAD\xC7\x8D\x83\x2F\xBE\x19\xE0\x83\x86\x40\xC0\xA1\x02\xA9\xB3\x20\xCE\x89\x83\x70\x74\x0E\x6F\x8B\x82\x21\xC6\x10\x0F\xCA\x88\x8E\x7D\x69\xD9\x25\x9A\x94\x82\x2C\x92\xBD\x2C\xD9\xC9\xE1\x3C\xC0\x00\x27\xF0\xBF\xBC\xFE\x9B\xC8\x00\x00\x7A\xBD\x16\xC6\xC0\x00\x89\x7E\xCB\x9B\xDE\x68\x99\x32\xC3\x24\x95\x67\xA9\xCE\xDB\x6C\xCE\xCC\x68\xA1\xAF\x75\x72\xC0\x73\x59\xF6\xCC\x51\x1E\xFA\xC8\x9A\xFD\xA9\xAF\x5D\x84\x29\xAE\xC5\x82\xD5\x70\x77\xD9\xCD\x82\xE9\xAE\x07\x48\xEB\x6C\xCD\x02\xCB\x6C\x96\xEE\x68\xB6\x00\x23\x66\xC7\x90\xA7\xB6\xF6\x00\xAC\xB4\x1A\x20\xA3\x5F\x03\x26\x7A\x7E\x24\xA6\x87\xD1\x67\xA4\x26\x29\xA6\xA9\x27\x96\x84\x77\x97\x9D\x89\xA6\x35\xDF\x8D\xA9\x8F\xCF\x8F\xF5\x92\xC3\x20\x14\xD5\xB8\x3A\xC4\xBE\xC2\x0D\xEF\x9B\x8E\x19\xC0\xC5\x7E\xF9\x9E\xD7\x3F\x80\x09\xC8\x47\xD9\xD3\xDE\x57\xC2\x07\xF4\x48\x26\xDB\x5F\xCD\x7F\x39\x8D\x8F\x81\x23\x89\x82\x89\x14\x8E\x8B\xFF\x6F\x7B\x82\x07\x86\x8D\x0F\xD4\x89\x83\x02\xF1\x73\x80\x73\xC7\xC8\xDD\x4C\x95\x83\x13\x99\x82\x81\xF9\x75\x99\xDE\x47\xC3\x85\x09\x83\x62\x0A\x1C\x9D\x4E\x36\x47\x8E\x85\x6B\x00\xE0\xCB\x1A\xA1\x76\xA4\x20\x09\x86\x0E\xC7\x8D\x87\x33\x0C\xE0\xCC\xE7\x85\x89\x1F\xE7\xDB\x89\x26\xBC\xD0\x83\xEF\x72\x88\x15\xFF\xD0\xCF\x04\x69\xBE\x9F\xBC\xAD\xBF\x40\x6F\xB0\xAB\xF7", +"\x52\xAA\xBE\xBB\xD4\xBC\x87\xD9\xA1\xE6\xAE\xB9\xB8\xA3\xD6\x77\xB2\x98\xA7\x3D\x76\x1F\x6C\xC8\xA6\x3E\x53\x4E\xD6\x5C\x31\xD8\x18\x7C\x91\x77\xBC\x36\x03\x48\x64\x38\xDB\x19\x8B\x58\x48\xD8\x3A\x38\x6F\x18\x0B\xE8\x0F\x58\xB4\x38\x94\x45\x94\x6F\x1A\x05\xEA\xE9\x07\xD7\x82\x4F\xE8\x35\x76\x65\x0C\x36\x0E\x1D\xE8\x39\x9E\xD4\x0D\xD8\xD7\x33\xEC\xDE\x1E\x07\xEC\xC7\x3C\x03\xB8\x2F\x3F\x1E\xDE\x06\x4A\xE8\x78\xF9\xEF\x48\x46\x4F\x1E\x2A\xE4\x5A\xEF\x0C\x3A\x5E\xD0\xEB\xE0\x00\xE6\x7C\x32\xD5\xFA\x2F\x4C\xDD\xF2\xC3\x6A\xC0\xF9\xEC\xEE\x84\xEE\xF0\x00\x4B\x56\x41\xC6\xCE\xF0\xF1\x4E\x58\x21\x07\x12\xFE\x3E\x3E\xEF\x73\x59\xBC\x34\x50\xF5\x04\xF2\xE5\x32\x0D\xEA\x88\x79\xFA\x99\x02\xBC\x37\xF4\xE8\x34\xEE\x40\xA0\xF8\xEC\xE5\x9A\x5C\xF2\x10\x4F\x76\x47\x06\x5B\xF1\xED\xDF\xEC\x43\xD8\xFD\x52\x5D\x50\x4F\x74\xA5\x6D\xD8\x53\xD6\xD6\x41\xF5\x12\x4B\xF7\xEF\x5C\x5B\xDB\x23\xF4\xEC\x45\xBE\xF3\x4F\xEC\x8C\x26\xF2\xC0\xD8\xF1\xF7\xB5\xEC\x58\xCF\xC1\x90\xEC\xBC\xE2\xF7\xF3\xD5\x28\x36\xFC\x46\xFC\x0C\xE4\xCE\x5A\xF9\xBE\x4C\xFA\x91\xB3\x84\xEE\x02\x46\x41\xEF\xE3\x47\x40\xF5\xD9\xF7\xFA\xCD\xF4\xFE\xF3\x17\x85\x20\xDF\xA5\xDC\x44\xF8\xFB\x2B\xFE\xBB\x77\x7B\x4D\x28\x7D\x01\x8B\x73\x12\x59\x10\x7C\x7B\x64\x02\x11\x7D\x6F\x23\x7D\x54\x37\x7F\x06\x8C\x38\x04\x8C\x79\xBC\x79\x29\x42\x7A\x4D\x12\x7F\x25\xCB\x73\x10\xDC\x37\x64\x79\x7C\x4B\x0A\x72\x07\xAC\x72\x65\xCE\x7C\x77\x7E\x73\x79\xD9\x7E\x80\x04\x15\x7D\x7A\x75\x7F\x0C\x1A\x7B\x14\x88\x7F\x1C\x27\x77\x12\x2F\x15\x02\x19\x81\x74\x03\x82\x1D\x58\x7E\x73\x2C\x4B\x15\x7A\x83\xBF\x20\x3C\xAB\x74\x77\x46\x24\x20\xD9\x7A\x7F\x23\x11\x7F\x91\x36\x77\xF6\x7C\x10\xF1\x7C\x22\x30\x82\x79\xE4\x7C\x82\x47\x85\x81\x92\x74\x77\x91\x35\x6A\x47\x8A\x14\x26\x88\x11\xF1\x7E\x7F\xBF\x78\x16\xB5\x75\x74\xEC\x14\x83\xAC\x21\x7E\x02\x16\x78\x27\x36\x32\x3D\x7D\x24\x57\x1C\x77\x91\x7E\x78\x2A\x8D\x79\x05\x8B\x7D\x9D\x53\x81\x92\x75\x81\x0C\x89\x2E\x62\x80\x00\xA3\x78\x86\x00\x05\x7A\xE4\x76\x7E\x3E\x13\x10\x3C\x8A\x7E\x41\x82\x4D\xAF\x70\x88\x92\x73\x87\xB6\x75\x87\x6C\x80\x3C\xA5\x48\x87\x97\x72\x83\x65\x0B\x87\xA2\x1F\x7B\xD4\x33\x7C\x1C\x43\x88\x78\x7A\x7A\x1E\x8B\x81\x02\x1D\x81\xEC\x7C\x77\xD0\x79\x82\xFF\x7B\x7D\x79\x87\x75\x0A\x2D\x84\x31\x86\x80\xC8\x48\x89\xF2\x70\x7C\x7E\x80\x7E\x67\x87\x1D\xE3\x74\x82\x33\x44\x88\x36\x83\x21\xA1\x89\x7E\x1C\x8D\x7C\xA5\x83\x12\xEE\x79\x7D\xF1\x76\x20\xFD\x78\x77\x25\x78\x75\xAE\x8B\x8A\xB0\x8F\x3A\x48\x87\x13\xFC\x76\x8C\xA9\x81\x89\xCE\x86\x87\x93\x8D\x8C\x95\x8F\x8C\x17\x44\x77\xDA\x6B\x85\x7B\x73\x12\x0A\x88\x82\xB5\x7E\x88\xDA\x77\x8D\x91\x87\x87\xDA\x86\x7D\x96\x86\x86\x85\x8E\x2C\x38\x80\x84\x88\x82\x4D\x1F\x87\x32\x21\x82\x8F\xC1\x8B\x7E\x42\x44\x77\x27\x82\x8B\xBC\x16\x8E\xC9\x82\x74\xCB\x8D\x8A\x2F\x80\x81\x76\x88\x4C\xEE\x8D\x8B\xBD\x81\x8F\xA2\x82\x39\xC2\x88\x7A\xCA\x87\x32\x3F\x8D\x90\xA4\x80\x91\x42\x74\x84\xB4\x40\x8E\x4A\x1C\x82\xFF\x01\x7F\x72\x6C\x84\x0C\x13\x01\x5E\x8B\x86\x03\x12\x92\x90\x84\x87\xDC\x7C\x21\x5F\x85\x8D\xE9\x2F\x49\x87\x7C\x8A\x1D\x92\x1B\x78\x76\x24\x2C\x2F\x84\x24\x9C\x8E\xDC\x8A\x92\xDE\x79\x8A\x2E\x97\x93\xDA\x7D\x59\x31\x91\x1F\x33\x94\x7B\x4E\x8E\x93\x54\x81\x91\x39\x96\x81\x73\x2F\x7D\xF9\x7E\x93\xA6\x11\x38\x73\x28\x91\x0C\x17\x82\x79\x79\x90\x6B\x27\x74\x5D\x4C\x1B\x64\x8D\x1E\xF1\x71\x94\x78\x53\x94\x0C\x18\x30\x0F\x87\x92\x8F\x83\x1F\x59\x95\x83\x03\x11\x14\x15\x6C\x22\x62\x92\x79\x5B\x97\x94\xB5\x79\x76\x5E\x98\x88\x6F\x26\x24\x51\x83\x10\x70\x9D\x83\x27\x38\x74\x68\x9E\x2A\x2A\x6F\x47\x50\x89\x7D\x6F\x9A\x91\xD6\x88\x92\x07\x8A\x78\x7C\x76\x24\x7E\x60\x78\x56\x97\x26\x59\x7E\x4F\x2F\x96\x80\xA5\x43\x97\x09\x11\x7F\x93\x6B\x26\x46\x2D\x96\x78\x99\x7D\x8F\x99\x20\x91\x98\x8D\xFE\x4C\x96\x06\x99\x8E\xA5\x49\x97\x92\x72\x97\x4A\x80\x96\x08\x17\x97\x02\x16\x9A\x6B\x2D\x99\xC4\x1F\x99\xA4\x91\x9A\xEB\x8D\x82\xAC\x8E\x9A\x38\x97\x90\xD0\x88\x98\xE1\x8C\x10\x29\x6C\x79\x8D\x96\x26\x3F\x7F\x6B\x41\x7E\x94\x7B\x3C\x38\x94\x98\x18\xF1\x75\x64\x73\x26\x24\x15\x04\x94\x9C\x73\x9C\x7F\x4C\x38\xB2\x96\x98\xBB\x38\x11\xCF\x94\x96\x3F\x9C\x38\x2B\x9B\x73\x91\x8A\x61\x5A\x9C\x60\x5D\x49\x9C\x00\x0C\x9C\x75\x9C\x92\xAD\x99\x7D", +"\xD2\x9B\x24\xC5\x9E\x9D\xD6\x9E\x23\x2C\x2F\x7E\x48\x96\x87\xDC\x93\x9F\xDF\x96\x47\xE1\x9E\x2C\x15\x65\x7B\xDE\x8D\x68\x84\x91\x8D\x4A\x1D\x56\x26\x9F\x9F\x04\xAF\x86\xBD\x98\x10\x14\x05\xA0\x0A\xAE\x78\x58\x8D\x4D\x04\xA4\x77\x6D\x59\x9D\x0B\xA8\x80\x23\x11\x87\x80\x76\x8E\x03\xA8\x8E\x86\x99\x8D\x05\x9A\x9D\x4F\x91\x8B\x3B\x9A\x89\xB6\x81\x24\x03\x12\x88\xBA\x86\x91\x73\x20\x8A\xBB\x84\x91\x0F\x9E\x7A\x7C\x70\x7B\xA8\x81\x86\x25\x93\x9A\x1B\xAC\x5F\xB5\x95\x8F\x49\x92\x8B\x4C\x9C\x21\x9C\x8E\x6E\x9E\x87\x81\xC9\x7F\x8B\x41\x83\x8F\x09\x4F\x7C\x8C\x82\x87\xE8\x90\x00\x19\xAB\x8D\xA0\x99\x20\x94\x89\x9B\xE9\x80\xA2\x42\x7B\xA3\x97\x80\x88\xFD\x6F\xA3\x29\xA1\xA4\x2B\xA0\x8C\xA3\x8D\xA2\x16\x2D\x7E\x49\xA0\x86\xB4\x84\x10\x4B\xA0\xA5\x35\xAE\xA4\x37\xA6\x9F\x86\x98\x4C\x00\xA7\x15\xD3\x85\x7B\xC7\x88\x11\x65\xA6\x9B\x92\x96\xA3\x1D\xAF\x8A\xBA\x9D\x94\x6D\xA9\x10\xE3\x8E\x8F\x47\xA9\x89\x08\x13\xA7\x38\xAD\xA4\xCC\x87\xA7\x1A\xA5\x96\x12\x51\x9C\x18\x89\x43\x1A\x8C\xA5\x0E\x9A\x8F\xD0\x13\xA8\x91\x87\x8F\x2C\xA0\xA9\x5F\xAD\x85\xB7\x8C\x79\x18\xA4\xA3\x88\xAC\xA1\xAB\x9C\xA9\x3F\x98\x90\x9F\x82\x21\x0C\x9E\xA8\x15\x91\xA9\x6A\xA5\x96\x13\x96\xAA\x5E\xA5\x7E\x84\x9C\x8F\x23\x90\xA7\x49\xA2\xA1\x6E\x92\x9E\x7F\x41\x9C\x84\x7A\x86\xEE\x98\xA8\xC8\x9C\x77\xBC\x17\x01\x13\xA0\x78\x60\xA2\xA3\x0B\xA4\x77\xBC\x19\x01\xC1\xA7\x91\x70\x8F\xA7\x7A\x71\x7F\x3A\xA9\x8A\x7F\x89\xA9\x26\xAB\x83\x42\xAF\x26\x2A\xA8\xA2\x74\x99\x8F\x42\x85\x82\xA0\x1C\xAC\x62\xA4\x28\x21\xA4\x8B\x9B\x89\x8A\xC4\x76\x7A\x27\xA8\xAA\x40\xA7\x7E\xD5\xAA\xAD\x44\xAC\xAD\x37\x17\x8A\xB2\xA9\xA9\x6F\x24\xA5\x84\x77\xA5\xE7\xA7\x7C\xA3\xAA\xAE\x5B\xA3\xA4\xDA\xA4\x8F\x5C\x82\x8E\xDE\xA8\x77\xF1\x7A\xA8\xA4\xAC\xA8\x39\x85\xA9\xDB\xAB\xAF\x6F\x20\x82\x22\x2D\x1A\xF8\x8D\xA5\x96\xA1\x1D\x98\xA4\xA2\xF1\xAB\x34\xF9\xAF\x8E\x00\x05\xAA\xFC\xA0\xB1\x09\xB8\xAD\x57\x92\x91\x1D\x18\x25\x0F\xBF\xA8\x1D\xBE\xA2\x23\x1C\x1B\x30\x39\xAC\x8F\x7B\x7F\x3E\x9F\x9F\xC6\xA9\xA6\x2A\xB4\xA1\x37\x16\xA1\x7A\x7C\x82\x4F\xA4\xA7\x79\xAD\x7B\xE1\xAD\x87\xD1\xA4\xB1\x81\x83\x45\xE6\xA4\xAD\x0A\xBB\x26\xD7\xA8\xAE\x1B\xB4\xB2\x8A\x8F\xA2\x01\xB2\x74\x36\xB0\xB3\x7A\x99\xA3\x3B\xB9\x2E\xE3\xAF\x7B\xE5\xA8\xA5\xD6\xAA\xA5\x1E\xBC\xB1\xED\xA3\x8C\xEF\xAB\xB4\x73\x2D\xB4\x86\xAC\xA4\x51\xA3\xA2\xF3\xA0\xAD\x64\xB6\x2A\xE2\x79\x2A\x56\xB4\xB4\x58\xB6\xB4\xD9\xAC\xB1\x49\xB4\x8C\x61\xAA\x9A\x7D\x84\x10\xAC\x98\xB3\x63\xB9\x7F\x74\x7F\xA6\xC0\x99\xA4\x77\xB2\xA9\x6B\xAB\x9B\x7B\xA8\x18\x7D\xA9\x7D\x60\xBF\xA9\x1E\xAB\x37\xA2\xA9\xAE\x18\xBA\xB1\x6F\xB8\xB4\x87\x8F\xB1\x3B\x74\xA9\xAC\xA1\xB1\xB0\xA2\xAF\x8E\x77\xB8\x76\xB0\xAA\x1F\xAF\x3A\x04\xB0\x8F\x06\xB3\xB2\xA7\xA8\xAF\x02\x90\xB2\x01\x27\x06\xA2\xBD\xAA\x2F\xB1\x96\x31\xBA\xAC\x72\xB4\xAC\x7A\x7C\x34\x07\x3C\x99\xA9\x81\x6A\x39\x8B\xB7\x2D\xB4\xB7\x7C\x83\x10\x9A\x90\x78\x69\x7D\xBA\xE0\x80", +}; + + void JsonGetParserBuffer(vl::stream::MemoryStream& stream) + { + vl::stream::MemoryStream compressedStream; + for (vint i = 0; i < parserBufferRows; i++) + { + vint size = i == parserBufferRows - 1 ? parserBufferRemain : parserBufferBlock; + compressedStream.Write((void*)parserBuffer[i], size); + } + compressedStream.SeekFromBegin(0); + vl::stream::LzwDecoder decoder; + vl::stream::DecoderStream decoderStream(compressedStream, decoder); + vl::collections::Array buffer(65536); + while (true) + { + vl::vint size = decoderStream.Read(&buffer[0], 65536); + if (size == 0) break; + stream.Write(&buffer[0], size); + } + stream.SeekFromBegin(0); + } +/*********************************************************************** +Unescaping Function Foward Declarations +***********************************************************************/ + + extern void JsonUnescapingString(vl::parsing::ParsingToken& value, const vl::collections::List& tokens); + +/*********************************************************************** +Parsing Tree Conversion Driver Implementation +***********************************************************************/ + + class JsonTreeConverter : public vl::parsing::ParsingTreeConverter + { + public: + using vl::parsing::ParsingTreeConverter::SetMember; + + bool SetMember(JsonLiteral::JsonValue& member, vl::Ptr node, const TokenList& tokens) + { + vl::Ptr token=node.Cast(); + if(token) + { + if(token->GetValue()==L"True") { member=JsonLiteral::JsonValue::True; return true; } + else if(token->GetValue()==L"False") { member=JsonLiteral::JsonValue::False; return true; } + else if(token->GetValue()==L"Null") { member=JsonLiteral::JsonValue::Null; return true; } + else { member=JsonLiteral::JsonValue::True; return false; } + } + member=JsonLiteral::JsonValue::True; + return false; + } + + void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) + { + } + + void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) + { + SetMember(tree->value, obj->GetMember(L"value"), tokens); + } + + void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) + { + if(SetMember(tree->content, obj->GetMember(L"content"), tokens)) + { + JsonUnescapingString(tree->content, tokens); + } + } + + void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) + { + SetMember(tree->content, obj->GetMember(L"content"), tokens); + } + + void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) + { + SetMember(tree->items, obj->GetMember(L"items"), tokens); + } + + void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) + { + if(SetMember(tree->name, obj->GetMember(L"name"), tokens)) + { + JsonUnescapingString(tree->name, tokens); + } + SetMember(tree->value, obj->GetMember(L"value"), tokens); + } + + void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) + { + SetMember(tree->fields, obj->GetMember(L"fields"), tokens); + } + + vl::Ptr ConvertClass(vl::Ptr obj, const TokenList& tokens)override + { + if(obj->GetType()==L"Literal") + { + vl::Ptr tree = new JsonLiteral; + vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); + Fill(tree, obj, tokens); + Fill(tree.Cast(), obj, tokens); + return tree; + } + else if(obj->GetType()==L"String") + { + vl::Ptr tree = new JsonString; + vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); + Fill(tree, obj, tokens); + Fill(tree.Cast(), obj, tokens); + return tree; + } + else if(obj->GetType()==L"Number") + { + vl::Ptr tree = new JsonNumber; + vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); + Fill(tree, obj, tokens); + Fill(tree.Cast(), obj, tokens); + return tree; + } + else if(obj->GetType()==L"Array") + { + vl::Ptr tree = new JsonArray; + vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); + Fill(tree, obj, tokens); + Fill(tree.Cast(), obj, tokens); + return tree; + } + else if(obj->GetType()==L"ObjectField") + { + vl::Ptr tree = new JsonObjectField; + vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); + Fill(tree, obj, tokens); + Fill(tree.Cast(), obj, tokens); + return tree; + } + else if(obj->GetType()==L"Object") + { + vl::Ptr tree = new JsonObject; + vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); + Fill(tree, obj, tokens); + Fill(tree.Cast(), obj, tokens); + return tree; + } + else + return 0; + } + }; + + vl::Ptr JsonConvertParsingTreeNode(vl::Ptr node, const vl::collections::List& tokens) + { + JsonTreeConverter converter; + vl::Ptr tree; + converter.SetMember(tree, node, tokens); + return tree; + } + +/*********************************************************************** +Parsing Tree Conversion Implementation +***********************************************************************/ + + vl::Ptr JsonLiteral::Convert(vl::Ptr node, const vl::collections::List& tokens) + { + return JsonConvertParsingTreeNode(node, tokens).Cast(); + } + + vl::Ptr JsonString::Convert(vl::Ptr node, const vl::collections::List& tokens) + { + return JsonConvertParsingTreeNode(node, tokens).Cast(); + } + + vl::Ptr JsonNumber::Convert(vl::Ptr node, const vl::collections::List& tokens) + { + return JsonConvertParsingTreeNode(node, tokens).Cast(); + } + + vl::Ptr JsonArray::Convert(vl::Ptr node, const vl::collections::List& tokens) + { + return JsonConvertParsingTreeNode(node, tokens).Cast(); + } + + vl::Ptr JsonObjectField::Convert(vl::Ptr node, const vl::collections::List& tokens) + { + return JsonConvertParsingTreeNode(node, tokens).Cast(); + } + + vl::Ptr JsonObject::Convert(vl::Ptr node, const vl::collections::List& tokens) + { + return JsonConvertParsingTreeNode(node, tokens).Cast(); + } + +/*********************************************************************** +Parser Function +***********************************************************************/ + + vl::Ptr JsonParseAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex) + { + vl::parsing::tabling::ParsingState state(input, table, codeIndex); + state.Reset(L"JRoot"); + vl::Ptr parser=vl::parsing::tabling::CreateStrictParser(table); + vl::Ptr node=parser->Parse(state, errors); + return node; + } + + vl::Ptr JsonParseAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::vint codeIndex) + { + vl::collections::List> errors; + return JsonParseAsParsingTreeNode(input, table, errors, codeIndex); + } + + vl::Ptr JsonParse(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex) + { + vl::parsing::tabling::ParsingState state(input, table, codeIndex); + state.Reset(L"JRoot"); + vl::Ptr parser=vl::parsing::tabling::CreateStrictParser(table); + vl::Ptr node=parser->Parse(state, errors); + if(node && errors.Count()==0) + { + return JsonConvertParsingTreeNode(node, state.GetTokens()).Cast(); + } + return 0; + } + + vl::Ptr JsonParse(const vl::WString& input, vl::Ptr table, vl::vint codeIndex) + { + vl::collections::List> errors; + return JsonParse(input, table, errors, codeIndex); + } + +/*********************************************************************** +Table Generation +***********************************************************************/ + + vl::Ptr JsonLoadTable() + { + vl::stream::MemoryStream stream; + JsonGetParserBuffer(stream); + vl::Ptr table=new vl::parsing::tabling::ParsingTable(stream); + table->Initialize(); + return table; + } + + } + } +} + + +/*********************************************************************** +.\PARSING\PARSING.CPP ***********************************************************************/ namespace vl @@ -5720,7 +14596,2090 @@ Type Loader } /*********************************************************************** -PARSING\PARSINGANALYZER.CPP +.\PARSING\PARSINGAUTOMATON.CPP +***********************************************************************/ + +namespace vl +{ + namespace parsing + { + using namespace collections; + using namespace definitions; + + namespace analyzing + { + +/*********************************************************************** +Action +***********************************************************************/ + + Action::Action() + :actionType(Create) + ,actionSource(0) + ,actionTarget(0) + ,creatorRule(0) + ,shiftReduceSource(0) + ,shiftReduceTarget(0) + { + } + + Action::~Action() + { + } + +/*********************************************************************** +Transition +***********************************************************************/ + + Transition::Transition() + :source(0) + ,target(0) + ,transitionType(Epsilon) + ,stackOperationType(None) + ,transitionSymbol(0) + { + } + + Transition::~Transition() + { + } + + bool Transition::IsEquivalent(Transition* t1, Transition* t2, bool careSourceAndTarget) + { + if(careSourceAndTarget) + { + if(t1->source!=t2->source || t1->target!=t2->target) + { + return false; + } + } + if( t1->actions.Count()!=t2->actions.Count() || + t1->transitionType!=t2->transitionType || + t1->transitionSymbol!=t2->transitionSymbol) + { + return false; + } + for(vint j=0;jactions.Count();j++) + { + Ptr a1=t1->actions[j]; + Ptr a2=t2->actions[j]; + if( a1->actionType!=a2->actionType || + a1->actionSource!=a2->actionSource || + a1->actionTarget!=a2->actionTarget || + a1->shiftReduceSource!=a2->shiftReduceSource ) + { + return false; + } + } + return true; + } + +/*********************************************************************** +State +***********************************************************************/ + + State::State() + :ownerRule(0) + ,ownerRuleSymbol(0) + ,grammarNode(0) + ,stateNode(0) + ,statePosition(BeforeNode) + ,endState(false) + { + } + + State::~State() + { + } + +/*********************************************************************** +RuleInfo +***********************************************************************/ + + RuleInfo::RuleInfo() + :rootRuleStartState(0) + ,rootRuleEndState(0) + ,startState(0) + ,stateNameCount(0) + { + } + + RuleInfo::~RuleInfo() + { + } + +/*********************************************************************** +Automaton +***********************************************************************/ + + Automaton::Automaton(ParsingSymbolManager* _symbolManager) + :symbolManager(_symbolManager) + { + } + + Automaton::~Automaton() + { + } + + State* Automaton::RuleStartState(definitions::ParsingDefinitionRuleDefinition* ownerRule) + { + State* state=new State; + states.Add(state); + + state->ownerRule=ownerRule; + state->ownerRuleSymbol=symbolManager->GetGlobal()->GetSubSymbolByName(ownerRule->name); + state->stateName=ownerRule->name+L".Start"; + state->stateExpression=L"@ <"+ownerRule->name+L">"; + return state; + } + + State* Automaton::RootRuleStartState(definitions::ParsingDefinitionRuleDefinition* ownerRule) + { + State* state=new State; + states.Add(state); + + state->ownerRule=ownerRule; + state->ownerRuleSymbol=symbolManager->GetGlobal()->GetSubSymbolByName(ownerRule->name); + state->stateName=ownerRule->name+L".RootStart"; + state->stateExpression=L"@ $<"+ownerRule->name+L">"; + return state; + } + + State* Automaton::RootRuleEndState(definitions::ParsingDefinitionRuleDefinition* ownerRule) + { + State* state=new State; + states.Add(state); + + state->ownerRule=ownerRule; + state->ownerRuleSymbol=symbolManager->GetGlobal()->GetSubSymbolByName(ownerRule->name); + state->stateName=ownerRule->name+L".RootEnd"; + state->stateExpression=L"$<"+ownerRule->name+L"> @"; + return state; + } + + State* Automaton::StartState(definitions::ParsingDefinitionRuleDefinition* ownerRule, definitions::ParsingDefinitionGrammar* grammarNode, definitions::ParsingDefinitionGrammar* stateNode) + { + State* state=new State; + states.Add(state); + + state->ownerRule=ownerRule; + state->ownerRuleSymbol=symbolManager->GetGlobal()->GetSubSymbolByName(ownerRule->name); + state->grammarNode=grammarNode; + state->stateNode=stateNode; + state->statePosition=State::BeforeNode; + state->stateName=ownerRule->name+L"."+itow(++ruleInfos[ownerRule]->stateNameCount); + stateNode=FindAppropriateGrammarState(grammarNode, stateNode, true); + state->stateExpression=L"<"+ownerRule->name+L">: "+GrammarStateToString(grammarNode, stateNode, true); + return state; + } + + State* Automaton::EndState(definitions::ParsingDefinitionRuleDefinition* ownerRule, definitions::ParsingDefinitionGrammar* grammarNode, definitions::ParsingDefinitionGrammar* stateNode) + { + State* state=new State; + states.Add(state); + + state->ownerRule=ownerRule; + state->ownerRuleSymbol=symbolManager->GetGlobal()->GetSubSymbolByName(ownerRule->name); + state->grammarNode=grammarNode; + state->stateNode=stateNode; + state->statePosition=State::AfterNode; + state->stateName=ownerRule->name+L"."+itow(++ruleInfos[ownerRule]->stateNameCount); + stateNode=FindAppropriateGrammarState(grammarNode, stateNode, false); + state->stateExpression=L"<"+ownerRule->name+L">: "+GrammarStateToString(grammarNode, stateNode, false); + return state; + } + + State* Automaton::CopyState(State* oldState) + { + State* resultState=0; + if(oldState->statePosition==State::BeforeNode) + { + resultState=StartState(oldState->ownerRule, oldState->grammarNode, oldState->stateNode); + } + else + { + resultState=EndState(oldState->ownerRule, oldState->grammarNode, oldState->stateNode); + } + resultState->endState=oldState->endState; + return resultState; + } + + Transition* Automaton::CreateTransition(State* start, State* end) + { + Transition* transition=new Transition; + transitions.Add(transition); + + start->transitions.Add(transition); + end->inputs.Add(transition); + + transition->source=start; + transition->target=end; + return transition; + } + + Transition* Automaton::TokenBegin(State* start, State* end) + { + Transition* transition=CreateTransition(start, end); + transition->transitionType=Transition::TokenBegin; + return transition; + } + + Transition* Automaton::TokenFinish(State* start, State* end) + { + Transition* transition=CreateTransition(start, end); + transition->transitionType=Transition::TokenFinish; + return transition; + } + + Transition* Automaton::NormalReduce(State* start, State* end) + { + Transition* transition=CreateTransition(start, end); + transition->transitionType=Transition::NormalReduce; + return transition; + } + + Transition* Automaton::LeftRecursiveReduce(State* start, State* end) + { + Transition* transition=CreateTransition(start, end); + transition->transitionType=Transition::LeftRecursiveReduce; + return transition; + } + + Transition* Automaton::Epsilon(State* start, State* end) + { + Transition* transition=CreateTransition(start, end); + transition->transitionType=Transition::Epsilon; + return transition; + } + + Transition* Automaton::Symbol(State* start, State* end, ParsingSymbol* transitionSymbol) + { + Transition* transition=CreateTransition(start, end); + transition->transitionType=Transition::Symbol; + transition->transitionSymbol=transitionSymbol; + return transition; + } + + Transition* Automaton::CopyTransition(State* start, State* end, Transition* oldTransition) + { + Transition* transition=CreateTransition(start, end); + transition->transitionType=oldTransition->transitionType; + transition->stackOperationType=oldTransition->stackOperationType; + transition->transitionSymbol=oldTransition->transitionSymbol; + return transition; + } + + void Automaton::DeleteTransition(Transition* transition) + { + transition->source->transitions.Remove(transition); + transition->target->inputs.Remove(transition); + transitions.Remove(transition); + } + + void Automaton::DeleteState(State* state) + { + while(state->inputs.Count()) + { + DeleteTransition(state->inputs[0]); + } + while(state->transitions.Count()) + { + DeleteTransition(state->transitions[0]); + } + states.Remove(state); + } + } + } +} + +/*********************************************************************** +.\PARSING\PARSINGAUTOMATON_CLOSURE.CPP +***********************************************************************/ + +namespace vl +{ + namespace parsing + { + using namespace collections; + using namespace definitions; + + namespace analyzing + { + +/*********************************************************************** +CreateNondeterministicPDAFromEpsilonPDA::closure_searching +***********************************************************************/ + + // closure function for searching reachable states + ClosureItem::SearchResult EpsilonClosure(Transition* transition) + { + return + transition->transitionType!=Transition::Epsilon?ClosureItem::Hit: + //transition->target->endState?ClosureItem::Blocked: + ClosureItem::Continue; + } + + // closure searching function + void SearchClosureInternal(ClosureItem::SearchResult(*closurePredicate)(Transition*), List& transitionPath, Transition* transition, State* state, List& closure) + { + FOREACH(Transition*, singleTransitionPath, transitionPath) + { + if(singleTransitionPath->source==state && closurePredicate(singleTransitionPath)!=ClosureItem::Blocked) + { + Ptr> path=new List; + CopyFrom(*path.Obj(), transitionPath); + closure.Add(ClosureItem(state, path, true)); + return; + } + } + + ClosureItem::SearchResult result=transition?closurePredicate(transition):ClosureItem::Continue; + switch(result) + { + case ClosureItem::Continue: + { + FOREACH(Transition*, newTransition, state->transitions) + { + if(!transitionPath.Contains(newTransition)) + { + transitionPath.Add(newTransition); + SearchClosureInternal(closurePredicate, transitionPath, newTransition, newTransition->target, closure); + transitionPath.RemoveAt(transitionPath.Count()-1); + } + } + } + break; + case ClosureItem::Hit: + { + Ptr> path=new List; + CopyFrom(*path.Obj(), transitionPath); + closure.Add(ClosureItem(state, path, false)); + } + break; + default:; + } + } + + void SearchClosure(ClosureItem::SearchResult(*closurePredicate)(Transition*), State* startState, List& closure) + { + List transitionPath; + SearchClosureInternal(closurePredicate, transitionPath, 0, startState, closure); + } + + // map old state to new state and track all states that are not visited yet + State* GetMappedState(Ptr newAutomaton, State* oldState, List& scanningStates, Dictionary& oldNewStateMap) + { + State* newState=0; + vint mapIndex=oldNewStateMap.Keys().IndexOf(oldState); + if(mapIndex==-1) + { + newState=newAutomaton->CopyState(oldState); + oldNewStateMap.Add(oldState, newState); + } + else + { + newState=oldNewStateMap.Values().Get(mapIndex); + } + if(!scanningStates.Contains(oldState)) + { + scanningStates.Add(oldState); + } + return newState; + } + +/*********************************************************************** +RemoveEpsilonTransitions +***********************************************************************/ + + void RemoveEpsilonTransitions(collections::Dictionary& oldNewStateMap, collections::List& scanningStates, Ptr automaton) + { + vint currentStateIndex=0; + + while(currentStateIndex closure; + SearchClosure(&EpsilonClosure, currentOldState, closure); + FOREACH(ClosureItem, closureItem, closure) + { + Transition* oldTransition=closureItem.transitions->Get(closureItem.transitions->Count()-1); + if(!closureItem.cycle || oldTransition->transitionType!=Transition::Epsilon) + { + // if the oldTransition begins from an end state + if(oldTransition->source->endState && closureItem.transitions->Count()>1) + { + // keep a epsilon transition that without the last "TokenFinish" + State* newEndState=GetMappedState(automaton, oldTransition->source, scanningStates, oldNewStateMap); + Transition* transition=automaton->Epsilon(currentNewState, newEndState); + FOREACH(Transition*, pathTransition, *closureItem.transitions.Obj()) + { + if(pathTransition==oldTransition) break; + CopyFrom(transition->actions, pathTransition->actions, true); + } + } + else + { + // build compacted non-epsilon transition to the target state of the path + State* newEndState=GetMappedState(automaton, oldTransition->target, scanningStates, oldNewStateMap); + Transition* transition=automaton->CopyTransition(currentNewState, newEndState, oldTransition); + FOREACH(Transition*, pathTransition, *closureItem.transitions.Obj()) + { + CopyFrom(transition->actions, pathTransition->actions, true); + } + } + } + } + } + } + } + } +} + +/*********************************************************************** +.\PARSING\PARSINGAUTOMATON_EPDA.CPP +***********************************************************************/ + +namespace vl +{ + namespace parsing + { + using namespace collections; + using namespace definitions; + + namespace analyzing + { + +/*********************************************************************** +CreateEpsilonPDAVisitor +***********************************************************************/ + + class CreateEpsilonPDAVisitor : public Object, public ParsingDefinitionGrammar::IVisitor + { + public: + Ptr automaton; + ParsingDefinitionRuleDefinition* rule; + ParsingDefinitionGrammar* ruleGrammar; + State* startState; + State* endState; + Transition* result; + + CreateEpsilonPDAVisitor(Ptr _automaton, ParsingDefinitionRuleDefinition* _rule, ParsingDefinitionGrammar* _ruleGrammar, State* _startState, State* _endState) + :automaton(_automaton) + ,rule(_rule) + ,ruleGrammar(_ruleGrammar) + ,startState(_startState) + ,endState(_endState) + ,result(0) + { + } + + static Transition* Create(ParsingDefinitionGrammar* grammar, Ptr automaton, ParsingDefinitionRuleDefinition* rule, ParsingDefinitionGrammar* ruleGrammar, State* startState, State* endState) + { + CreateEpsilonPDAVisitor visitor(automaton, rule, ruleGrammar, startState, endState); + grammar->Accept(&visitor); + return visitor.result; + } + + Transition* Create(ParsingDefinitionGrammar* grammar, State* startState, State* endState) + { + return Create(grammar, automaton, rule, ruleGrammar, startState, endState); + } + + void Visit(ParsingDefinitionPrimitiveGrammar* node)override + { + result=automaton->Symbol(startState, endState, automaton->symbolManager->CacheGetSymbol(node)); + } + + void Visit(ParsingDefinitionTextGrammar* node)override + { + result=automaton->Symbol(startState, endState, automaton->symbolManager->CacheGetSymbol(node)); + } + + void Visit(ParsingDefinitionSequenceGrammar* node)override + { + State* middleState=automaton->EndState(startState->ownerRule, ruleGrammar, node->first.Obj()); + Create(node->first.Obj(), startState, middleState); + Create(node->second.Obj(), middleState, endState); + } + + void Visit(ParsingDefinitionAlternativeGrammar* node)override + { + Create(node->first.Obj(), startState, endState); + Create(node->second.Obj(), startState, endState); + } + + void Visit(ParsingDefinitionLoopGrammar* node)override + { + State* loopStart=automaton->StartState(startState->ownerRule, ruleGrammar, node->grammar.Obj()); + automaton->Epsilon(startState, loopStart); + automaton->Epsilon(loopStart, endState); + Create(node->grammar.Obj(), loopStart, loopStart); + } + + void Visit(ParsingDefinitionOptionalGrammar* node)override + { + Create(node->grammar.Obj(), startState, endState); + automaton->Epsilon(startState, endState); + } + + void Visit(ParsingDefinitionCreateGrammar* node)override + { + State* middleState=automaton->EndState(startState->ownerRule, ruleGrammar, node->grammar.Obj()); + Create(node->grammar.Obj(), startState, middleState); + Transition* transition=automaton->Epsilon(middleState, endState); + + Ptr action=new Action; + action->actionType=Action::Create; + action->actionSource=automaton->symbolManager->CacheGetType(node->type.Obj(), 0); + action->creatorRule=rule; + transition->actions.Add(action); + } + + void Visit(ParsingDefinitionAssignGrammar* node)override + { + Transition* transition=Create(node->grammar.Obj(), startState, endState); + + Ptr action=new Action; + action->actionType=Action::Assign; + action->actionSource=automaton->symbolManager->CacheGetSymbol(node); + action->creatorRule=rule; + transition->actions.Add(action); + } + + void Visit(ParsingDefinitionUseGrammar* node)override + { + Transition* transition=Create(node->grammar.Obj(), startState, endState); + + Ptr action=new Action; + action->actionType=Action::Using; + action->creatorRule=rule; + transition->actions.Add(action); + } + + void Visit(ParsingDefinitionSetterGrammar* node)override + { + State* middleState=automaton->EndState(startState->ownerRule, ruleGrammar, node->grammar.Obj()); + Create(node->grammar.Obj(), startState, middleState); + Transition* transition=automaton->Epsilon(middleState, endState); + + Ptr action=new Action; + action->actionType=Action::Setter; + action->actionSource=automaton->symbolManager->CacheGetSymbol(node); + action->actionTarget=action->actionSource->GetDescriptorSymbol()->GetSubSymbolByName(node->value); + action->creatorRule=rule; + transition->actions.Add(action); + } + }; + +/*********************************************************************** +CreateRuleEpsilonPDA +***********************************************************************/ + + void CreateRuleEpsilonPDA(Ptr automaton, Ptr rule, ParsingSymbolManager* manager) + { + Ptr ruleInfo=new RuleInfo; + automaton->ruleInfos.Add(rule.Obj(), ruleInfo); + + ruleInfo->rootRuleStartState=automaton->RootRuleStartState(rule.Obj()); + ruleInfo->rootRuleEndState=automaton->RootRuleEndState(rule.Obj()); + ruleInfo->startState=automaton->RuleStartState(rule.Obj()); + automaton->TokenBegin(ruleInfo->rootRuleStartState, ruleInfo->startState); + + FOREACH(Ptr, grammar, rule->grammars) + { + State* grammarStartState=automaton->StartState(rule.Obj(), grammar.Obj(), grammar.Obj()); + State* grammarEndState=automaton->EndState(rule.Obj(), grammar.Obj(), grammar.Obj()); + grammarEndState->stateName+=L".End"; + grammarEndState->endState=true; + automaton->Epsilon(ruleInfo->startState, grammarStartState); + automaton->TokenFinish(grammarEndState, ruleInfo->rootRuleEndState); + ruleInfo->endStates.Add(grammarEndState); + CreateEpsilonPDAVisitor::Create(grammar.Obj(), automaton, rule.Obj(), grammar.Obj(), grammarStartState, grammarEndState); + } + } + +/*********************************************************************** +CreateEpsilonPDA +***********************************************************************/ + + Ptr CreateEpsilonPDA(Ptr definition, ParsingSymbolManager* manager) + { + Ptr automaton=new Automaton(manager); + FOREACH(Ptr, rule, definition->rules) + { + CreateRuleEpsilonPDA(automaton, rule, manager); + } + return automaton; + } + } + } +} + +/*********************************************************************** +.\PARSING\PARSINGAUTOMATON_GENERATETABLE.CPP +***********************************************************************/ + +namespace vl +{ + namespace parsing + { + using namespace collections; + using namespace definitions; + using namespace tabling; + + namespace analyzing + { + +/*********************************************************************** +GetTypeNameForCreateInstruction +***********************************************************************/ + + WString GetTypeNameForCreateInstruction(ParsingSymbol* type) + { + ParsingSymbol* parent=type->GetParentSymbol(); + if(parent->GetType()==ParsingSymbol::ClassType) + { + return GetTypeNameForCreateInstruction(parent)+L"."+type->GetName(); + } + else + { + return type->GetName(); + } + } + +/*********************************************************************** +CreateLookAhead +***********************************************************************/ + + void CopyStableLookAheads(List>& la, List>& sla, const List>& la2) + { + CopyFrom(sla, From(la) + .Where([&](Ptr lai) + { + return From(la2).All([&](Ptr lai2) + { + return ParsingTable::LookAheadInfo::TestPrefix(lai, lai2)==ParsingTable::LookAheadInfo::NotPrefix; + }); + }), + true); + } + + void RemoveStableLookAheads(List>& la, const List>& sla) + { + for(vint i=la.Count()-1;i>=0;i--) + { + if(sla.Contains(la[i].Obj())) + { + la.RemoveAt(i); + } + } + } + + bool WalkLookAheads(Ptr table, List>& la, vint maxTokenCount) + { + vint count=la.Count(); + for(vint i=0;i lai=la[i]; + if(lai->tokens.Count()==maxTokenCount) + { + return false; + } + ParsingTable::LookAheadInfo::Walk(table, lai, lai->state, la); + } + return true; + } + + void CompactLookAheads(Ptr t, List>& sla) + { + CopyFrom(sla, t->lookAheads, true); + CopyFrom(t->lookAheads, From(sla) + .Where([&](Ptr lai) + { + return From(sla).All([&](Ptr lai2) + { + if(lai==lai2) return true; + ParsingTable::LookAheadInfo::PrefixResult result=ParsingTable::LookAheadInfo::TestPrefix(lai, lai2); + switch(result) + { + case ParsingTable::LookAheadInfo::Prefix: + return false; + case ParsingTable::LookAheadInfo::Equal: + return lai table, Ptr t1, Ptr t2, vint maxTokenCount) + { + List> la1, la2, sla1, sla2; + + // calculate 1-token look aheads + ParsingTable::LookAheadInfo::Walk(table, 0, t1->targetState, la1); + ParsingTable::LookAheadInfo::Walk(table, 0, t2->targetState, la2); + + do + { + // pick up all stable look aheads and remove them from the look ahead list + // stable look ahead means, when the look ahead is satisfied, then the transition is picked up with full confidence + // non-stable look ahead means, when the look ahead is satisifed, it only increase confidence, needs further tokens for decision + CopyStableLookAheads(la1, sla1, la2); + CopyStableLookAheads(la2, sla2, la1); + RemoveStableLookAheads(la1, sla1); + RemoveStableLookAheads(la2, sla2); + + // check if there are non-stable look aheads in two transitions points to the same state + // in such situation means that the two transition cannot always be determined using look aheads + FOREACH(Ptr, lai1, la1) + { + FOREACH(Ptr, lai2, la2) + { + if (lai1->state == lai2->state) + { + if (ParsingTable::LookAheadInfo::TestPrefix(lai1, lai2) != ParsingTable::LookAheadInfo::NotPrefix) + { + return false; + } + if (ParsingTable::LookAheadInfo::TestPrefix(lai2, lai1) != ParsingTable::LookAheadInfo::NotPrefix) + { + return false; + } + } + } + } + + // use the non-stable look aheads to walk a token further + if(!WalkLookAheads(table, la1, maxTokenCount) || !WalkLookAheads(table, la2, maxTokenCount)) + { + return false; + } + } + while(la1.Count()>0 || la2.Count()>0); + + CompactLookAheads(t1, sla1); + CompactLookAheads(t2, sla2); + return true; + } + +/*********************************************************************** +CollectAttribute +***********************************************************************/ + + void CollectType(ParsingSymbol* symbol, List& types) + { + if(symbol->GetType()==ParsingSymbol::ClassType) + { + types.Add(symbol); + } + vint count=symbol->GetSubSymbolCount(); + for(vint i=0;iGetSubSymbol(i), types); + } + } + + void CollectAttributeInfo(Ptr att, List>& atts) + { + FOREACH(Ptr, datt, atts) + { + Ptr tatt=new ParsingTable::AttributeInfo(datt->name); + CopyFrom(tatt->arguments, datt->arguments); + att->attributes.Add(tatt); + } + } + + Ptr CreateAttributeInfo(List>& atts) + { + Ptr att=new ParsingTable::AttributeInfoList; + CollectAttributeInfo(att, atts); + return att; + } + +/*********************************************************************** +GenerateTable +***********************************************************************/ + + vint LookAheadConflictPriority(vint tableTokenIndex) + { + switch (tableTokenIndex) + { + case ParsingTable::NormalReduce: + return 0; + case ParsingTable::LeftRecursiveReduce: + return 1; + default: + return 2; + } + } + + void GenerateLookAhead(Ptr table, List& stateIds, vint state, vint token, Ptr t1, Ptr t2, bool enableAmbiguity, collections::List>& errors) + { + if(ParsingTable::TransitionItem::CheckOrder(t1, t2, false)==ParsingTable::TransitionItem::UnknownOrder) + { + if(enableAmbiguity || !CreateLookAhead(table, t1, t2, 16)) + { + if (LookAheadConflictPriority(t1->token) != LookAheadConflictPriority(t2->token)) + { + return; + } + WString stateName=itow(state)+L"["+table->GetStateInfo(state).stateName+L"]"; + WString tokenName= + token==ParsingTable::TokenBegin?WString(L"$TokenBegin"): + token==ParsingTable::TokenFinish?WString(L"$TokenFinish"): + token==ParsingTable::NormalReduce?WString(L"$NormalReduce"): + token==ParsingTable::LeftRecursiveReduce?WString(L"$LeftRecursiveReduce"): + table->GetTokenInfo(token).name; + switch (t1->token) + { + case ParsingTable::NormalReduce: + errors.Add(new ParsingError(stateIds[state]->ownerRule, L"Conflict happened with normal reduce in transition of \""+tokenName+L"\" of state \""+stateName+L"\".")); + break; + case ParsingTable::LeftRecursiveReduce: + errors.Add(new ParsingError(stateIds[state]->ownerRule, L"Conflict happened with left recursive reduce in transition of \""+tokenName+L"\" of state \""+stateName+L"\".")); + break; + default: + errors.Add(new ParsingError(stateIds[state]->ownerRule, L"Conflict happened in transition of \""+tokenName+L"\" of state \""+stateName+L"\".")); + break; + } + } + } + } + + Ptr GenerateTableFromPDA(Ptr definition, ParsingSymbolManager* manager, Ptr jointPDA, bool enableAmbiguity, collections::List>& errors) + { + List> atts; + + /*********************************************************************** + find all class types + ***********************************************************************/ + List types; + Dictionary typeAtts; + Dictionary, vint> treeFieldAtts; + Dictionary>> childTypes; + + // find all class types + CollectType(manager->GetGlobal(), types); + FOREACH(ParsingSymbol*, type, types) + { + Ptr typeAtt=new ParsingTable::AttributeInfoList; + ParsingSymbol* parent=type; + while(parent) + { + ParsingDefinitionClassDefinition* classDef=manager->CacheGetClassDefinition(parent); + CollectAttributeInfo(typeAtt, classDef->attributes); + + Ptr> children; + vint index=childTypes.Keys().IndexOf(parent); + if(index==-1) + { + children=new List; + childTypes.Add(parent, children); + } + else + { + children=childTypes.Values().Get(index); + } + + children->Add(type); + parent=parent->GetDescriptorSymbol(); + } + + if(typeAtt->attributes.Count()>0) + { + typeAtts.Add(GetTypeFullName(type), atts.Count()); + atts.Add(typeAtt); + } + else + { + typeAtts.Add(GetTypeFullName(type), -1); + } + } + + // find all class fields + for(vint i=0;i& children=*childTypes.Values().Get(i).Obj(); + + ParsingDefinitionClassDefinition* classDef=manager->CacheGetClassDefinition(type); + List fieldAtts; + FOREACH_INDEXER(Ptr, field, index, classDef->members) + { + if(field->attributes.Count()>0) + { + fieldAtts.Add(atts.Count()); + atts.Add(CreateAttributeInfo(field->attributes)); + } + else + { + fieldAtts.Add(-1); + } + } + + FOREACH(ParsingSymbol*, child, children) + { + WString type=GetTypeFullName(child); + FOREACH_INDEXER(Ptr, field, index, classDef->members) + { + treeFieldAtts.Add(Pair(type, field->name), fieldAtts[index]); + } + } + } + + /*********************************************************************** + find all tokens + ***********************************************************************/ + vint tokenCount=0; + vint discardTokenCount=0; + Dictionary tokenIds; + List discardTokens; + + Dictionary tokenAtts; + Dictionary ruleAtts; + + FOREACH(Ptr, token, definition->tokens) + { + if(token->attributes.Count()>0) + { + tokenAtts.Add(token->name, atts.Count()); + atts.Add(CreateAttributeInfo(token->attributes)); + } + else + { + tokenAtts.Add(token->name, -1); + } + + if(token->discard) + { + discardTokens.Add(token->name); + discardTokenCount++; + } + else + { + ParsingSymbol* tokenSymbol=jointPDA->symbolManager->GetGlobal()->GetSubSymbolByName(token->name); + tokenIds.Add(tokenSymbol, tokenIds.Count()+ParsingTable::UserTokenStart); + tokenCount++; + } + } + + /*********************************************************************** + find all rules + ***********************************************************************/ + FOREACH(Ptr, rule, definition->rules) + { + if(rule->attributes.Count()>0) + { + ruleAtts.Add(rule->name, atts.Count()); + atts.Add(CreateAttributeInfo(rule->attributes)); + } + else + { + ruleAtts.Add(rule->name, -1); + } + } + + /*********************************************************************** + find all available states + ***********************************************************************/ + List stateIds; + vint availableStateCount=0; + { + vint currentState=0; + List scanningStates; + FOREACH(Ptr, ruleInfo, jointPDA->ruleInfos.Values()) + { + if(!scanningStates.Contains(ruleInfo->rootRuleStartState)) + { + scanningStates.Add(ruleInfo->rootRuleStartState); + } + + while(currentStatetransitions) + { + if(!scanningStates.Contains(transition->target)) + { + scanningStates.Add(transition->target); + } + } + } + } + availableStateCount=scanningStates.Count(); + } + + // there will be some states that is used in shift and reduce but it is not a reachable state + // so the state table will record all state + FOREACH(Ptr, state, jointPDA->states) + { + if(!stateIds.Contains(state.Obj())) + { + stateIds.Add(state.Obj()); + } + } + vint stateCount=stateIds.Count(); + + Ptr table=new ParsingTable(atts.Count(), typeAtts.Count(), treeFieldAtts.Count(), tokenCount, discardTokenCount, stateCount, definition->rules.Count()); + + /*********************************************************************** + fill attribute infos + ***********************************************************************/ + FOREACH_INDEXER(Ptr, att, index, atts) + { + table->SetAttributeInfo(index, att); + } + + /*********************************************************************** + fill tree type infos + ***********************************************************************/ + typedef Pair TreeTypeAttsPair; + FOREACH_INDEXER(TreeTypeAttsPair, type, index, typeAtts) + { + table->SetTreeTypeInfo(index, ParsingTable::TreeTypeInfo(type.key, type.value)); + } + + /*********************************************************************** + fill tree field infos + ***********************************************************************/ + typedef Pair, vint> TreeFieldAttsPair; + FOREACH_INDEXER(TreeFieldAttsPair, field, index, treeFieldAtts) + { + table->SetTreeFieldInfo(index, ParsingTable::TreeFieldInfo(field.key.key, field.key.value, field.value)); + } + + /*********************************************************************** + fill token infos + ***********************************************************************/ + FOREACH(ParsingSymbol*, symbol, tokenIds.Keys()) + { + ParsingTable::TokenInfo info; + info.name=symbol->GetName(); + info.regex=symbol->GetDescriptorString(); + info.attributeIndex=tokenAtts[info.name]; + + vint id=tokenIds[symbol]; + table->SetTokenInfo(id, info); + } + + FOREACH_INDEXER(WString, name, i, discardTokens) + { + ParsingSymbol* symbol=jointPDA->symbolManager->GetGlobal()->GetSubSymbolByName(name); + + ParsingTable::TokenInfo info; + info.name=symbol->GetName(); + info.regex=symbol->GetDescriptorString(); + info.attributeIndex=tokenAtts[info.name]; + table->SetDiscardTokenInfo(i, info); + } + + /*********************************************************************** + fill rule infos + ***********************************************************************/ + FOREACH_INDEXER(ParsingDefinitionRuleDefinition*, rule, i, jointPDA->ruleInfos.Keys()) + { + Ptr pdaRuleInfo=jointPDA->ruleInfos[rule]; + ParsingTable::RuleInfo info; + info.name=rule->name; + info.type=TypeToString(rule->type.Obj()); + info.rootStartState=stateIds.IndexOf(pdaRuleInfo->rootRuleStartState); + info.attributeIndex=ruleAtts[info.name]; + + if(Ptr classType=rule->type.Cast()) + { + ParsingSymbol* ruleSymbol=manager->GetGlobal()->GetSubSymbolByName(rule->name); + ParsingSymbol* ruleType=ruleSymbol->GetDescriptorSymbol(); + ParsingDefinitionClassDefinition* ruleTypeDef=manager->CacheGetClassDefinition(ruleType); + if(ruleTypeDef && ruleTypeDef->ambiguousType) + { + ParsingSymbol* ambiguousType=manager->CacheGetType(ruleTypeDef->ambiguousType.Obj(), ruleType->GetParentSymbol()); + info.ambiguousType=GetTypeFullName(ambiguousType); + } + } + table->SetRuleInfo(i, info); + } + + /*********************************************************************** + fill state infos + ***********************************************************************/ + FOREACH_INDEXER(State*, state, i, stateIds) + { + ParsingTable::StateInfo info; + info.ruleName=state->ownerRule->name; + info.stateName=state->stateName; + info.stateExpression=state->stateExpression; + table->SetStateInfo(i, info); + } + + /*********************************************************************** + fill transition table + ***********************************************************************/ + FOREACH_INDEXER(State*, state, stateIndex, stateIds) + { + // if this state is not necessary, stop building the table + if(stateIndex>=availableStateCount) break; + + FOREACH(Transition*, transition, state->transitions) + { + vint tokenIndex=-1; + switch(transition->transitionType) + { + case Transition::TokenBegin: + tokenIndex=ParsingTable::TokenBegin; + break; + case Transition::TokenFinish: + tokenIndex=ParsingTable::TokenFinish; + break; + case Transition::NormalReduce: + tokenIndex=ParsingTable::NormalReduce; + break; + case Transition::LeftRecursiveReduce: + tokenIndex=ParsingTable::LeftRecursiveReduce; + break; + case Transition::Symbol: + tokenIndex=tokenIds[transition->transitionSymbol]; + break; + default:; + } + + Ptr bag=table->GetTransitionBag(stateIndex, tokenIndex); + if(!bag) + { + bag=new ParsingTable::TransitionBag; + table->SetTransitionBag(stateIndex, tokenIndex, bag); + } + + Ptr item=new ParsingTable::TransitionItem; + item->token=tokenIndex; + item->targetState=stateIds.IndexOf(transition->target); + bag->transitionItems.Add(item); + + FOREACH(Ptr, action, transition->actions) + { + ParsingTable::Instruction ins; + switch(action->actionType) + { + case Action::Create: + { + ins.instructionType=ParsingTable::Instruction::Create; + ins.nameParameter=GetTypeNameForCreateInstruction(action->actionSource); + } + break; + case Action::Using: + { + ins.instructionType=ParsingTable::Instruction::Using; + } + break; + case Action::Assign: + { + if(action->actionSource->GetDescriptorSymbol()->GetType()==ParsingSymbol::ArrayType) + { + ins.instructionType=ParsingTable::Instruction::Item; + } + else + { + ins.instructionType=ParsingTable::Instruction::Assign; + } + ins.nameParameter=action->actionSource->GetName(); + } + break; + case Action::Setter: + { + ins.instructionType=ParsingTable::Instruction::Setter; + ins.nameParameter=action->actionSource->GetName(); + ins.value=action->actionTarget->GetName(); + } + break; + case Action::Shift: + { + ins.instructionType=ParsingTable::Instruction::Shift; + ins.stateParameter=stateIds.IndexOf(action->shiftReduceSource); + } + break; + case Action::Reduce: + { + ins.instructionType=ParsingTable::Instruction::Reduce; + ins.stateParameter=stateIds.IndexOf(action->shiftReduceSource); + item->stackPattern.Add(ins.stateParameter); + } + break; + case Action::LeftRecursiveReduce: + { + ins.instructionType=ParsingTable::Instruction::LeftRecursiveReduce; + ins.stateParameter=stateIds.IndexOf(action->shiftReduceSource); + } + break; + } + ins.creatorRule=action->creatorRule->name; + item->instructions.Add(ins); + } + } + } + + /*********************************************************************** + check conflict and build look ahead table + ***********************************************************************/ + for (vint i = 0; i < table->GetStateCount(); i++) + { + for (vint j = 0; j < table->GetTokenCount(); j++) + { + Ptr bag=table->GetTransitionBag(i, j); + if(bag) + { + CopyFrom(bag->transitionItems, From(bag->transitionItems).OrderBy(ParsingTable::TransitionItem::Compare)); + + // build look ahead inside a transition + for (vint k1 = 0; k1 < bag->transitionItems.Count() - 1; k1++) + { + for (vint k2 = k1 + 1; k2 < bag->transitionItems.Count(); k2++) + { + Ptr t1=bag->transitionItems[k1]; + Ptr t2=bag->transitionItems[k2]; + GenerateLookAhead(table, stateIds, i, j, t1, t2, enableAmbiguity, errors); + } + } + + // build look ahead between this transition and reduce transitions + for (vint t = ParsingTable::NormalReduce; t <= ParsingTable::LeftRecursiveReduce && t < j; t++) + { + if (Ptr reduceBag = table->GetTransitionBag(i, t)) + { + for (vint k1 = 0; k1 < reduceBag->transitionItems.Count(); k1++) + { + for (vint k2 = 0; k2 < bag->transitionItems.Count(); k2++) + { + Ptr t1=reduceBag->transitionItems[k1]; + Ptr t2=bag->transitionItems[k2]; + GenerateLookAhead(table, stateIds, i, j, t1, t2, enableAmbiguity, errors); + } + } + } + } + } + } + } + + /*********************************************************************** + initialize table + ***********************************************************************/ + if(errors.Count()>0) + { + table->SetAmbiguity(true); + } + table->Initialize(); + return table; + } + + Ptr GenerateTable(Ptr definition, bool enableAmbiguity, collections::List>& errors) + { + errors.Clear(); + ParsingSymbolManager symbolManager; + ValidateDefinition(definition, &symbolManager, errors); + if(errors.Count()==0) + { + Ptr epsilonPDA=CreateEpsilonPDA(definition, &symbolManager); + Ptr nondeterministicPDA=CreateNondeterministicPDAFromEpsilonPDA(epsilonPDA); + Ptr jointPDA=CreateJointPDAFromNondeterministicPDA(nondeterministicPDA); + CompactJointPDA(jointPDA); + MarkLeftRecursiveInJointPDA(jointPDA, errors); + if(errors.Count()==0) + { + Ptr table=GenerateTableFromPDA(definition, &symbolManager, jointPDA, enableAmbiguity, errors); + if(enableAmbiguity || errors.Count()==0) + { + return table; + } + } + } + return 0; + } + } + } +} + +/*********************************************************************** +.\PARSING\PARSINGAUTOMATON_JPDA.CPP +***********************************************************************/ + +namespace vl +{ + namespace parsing + { + using namespace collections; + using namespace definitions; + + namespace analyzing + { +/*********************************************************************** +CreateJointPDAFromNondeterministicPDA +***********************************************************************/ + + Ptr CreateJointPDAFromNondeterministicPDA(Ptr nondeterministicPDA) + { + Ptr automaton=new Automaton(nondeterministicPDA->symbolManager); + + // build rule info data + Dictionary ruleMap; + Dictionary oldNewStateMap; + FOREACH(ParsingDefinitionRuleDefinition*, rule, nondeterministicPDA->ruleInfos.Keys()) + { + // build new rule info + Ptr ruleInfo=nondeterministicPDA->ruleInfos[rule]; + Ptr newRuleInfo=new RuleInfo; + automaton->ruleInfos.Add(rule, newRuleInfo); + ruleMap.Add(rule->name, rule); + + newRuleInfo->rootRuleStartState=automaton->RootRuleStartState(rule); + newRuleInfo->rootRuleEndState=automaton->RootRuleEndState(rule); + newRuleInfo->startState=automaton->RuleStartState(rule); + + oldNewStateMap.Add(ruleInfo->rootRuleStartState, newRuleInfo->rootRuleStartState); + oldNewStateMap.Add(ruleInfo->rootRuleEndState, newRuleInfo->rootRuleEndState); + oldNewStateMap.Add(ruleInfo->startState, newRuleInfo->startState); + + newRuleInfo->rootRuleStartState->stateExpression=ruleInfo->rootRuleStartState->stateExpression; + newRuleInfo->rootRuleEndState->stateExpression=ruleInfo->rootRuleEndState->stateExpression; + newRuleInfo->startState->stateExpression=ruleInfo->startState->stateExpression; + } + + FOREACH(Ptr, oldState, nondeterministicPDA->states) + { + if((oldState->inputs.Count()>0 || oldState->transitions.Count()>0) && !oldNewStateMap.Keys().Contains(oldState.Obj())) + { + State* newState=automaton->CopyState(oldState.Obj()); + oldNewStateMap.Add(oldState.Obj(), newState); + newState->stateExpression=oldState->stateExpression; + } + } + + // create transitions + FOREACH(ParsingDefinitionRuleDefinition*, rule, nondeterministicPDA->ruleInfos.Keys()) + { + Ptr ruleInfo=nondeterministicPDA->ruleInfos[rule]; + Ptr newRuleInfo=automaton->ruleInfos[rule]; + + // complete new rule info + FOREACH(State*, endState, ruleInfo->endStates) + { + newRuleInfo->endStates.Add(oldNewStateMap[endState]); + } + + // create joint transitions according to old automaton + List scanningStates; + vint currentStateIndex=0; + scanningStates.Add(ruleInfo->rootRuleStartState); + + while(currentStateIndextransitions) + { + State* oldSource=oldTransition->source; + State* oldTarget=oldTransition->target; + State* newSource=oldNewStateMap[oldSource]; + State* newTarget=oldNewStateMap[oldTarget]; + + if(!scanningStates.Contains(oldSource)) scanningStates.Add(oldSource); + if(!scanningStates.Contains(oldTarget)) scanningStates.Add(oldTarget); + + if(oldTransition->transitionType==Transition::Symbol && oldTransition->transitionSymbol->GetType()==ParsingSymbol::RuleDef) + { + // if this is a rule transition, create + // source -> ruleStart + // ruleEnd[] -> target + ParsingDefinitionRuleDefinition* rule=ruleMap[oldTransition->transitionSymbol->GetName()]; + Ptr oldRuleInfo=nondeterministicPDA->ruleInfos[rule]; + + { + Transition* shiftTransition=automaton->Epsilon(newSource, oldNewStateMap[oldRuleInfo->startState]); + Ptr action=new Action; + action->actionType=Action::Shift; + action->shiftReduceSource=newSource; + action->shiftReduceTarget=newTarget; + action->creatorRule=shiftTransition->source->ownerRule; + shiftTransition->actions.Add(action); + } + + FOREACH(State*, oldEndState, oldRuleInfo->endStates) + { + Transition* reduceTransition=automaton->NormalReduce(oldNewStateMap[oldEndState], newTarget); + Ptr action=new Action; + action->actionType=Action::Reduce; + action->shiftReduceSource=newSource; + action->shiftReduceTarget=newTarget; + action->creatorRule=reduceTransition->source->ownerRule; + reduceTransition->actions.Add(action); + CopyFrom(reduceTransition->actions, oldTransition->actions, true); + } + } + else + { + // if not, just copy + Transition* newTransition=automaton->CopyTransition(newSource, newTarget, oldTransition); + CopyFrom(newTransition->actions, oldTransition->actions); + } + } + } + } + return automaton; + } + +/*********************************************************************** +CompactJointPDA +***********************************************************************/ + + // closure function for searching shift-reduce-compact transition + ClosureItem::SearchResult ShiftReduceCompactClosure(Transition* transition) + { + return + transition->stackOperationType!=Transition::None?ClosureItem::Blocked: + transition->transitionType!=Transition::Epsilon?ClosureItem::Hit: + ClosureItem::Continue; + } + + void CompactJointPDA(Ptr jointPDA) + { + FOREACH(Ptr, state, jointPDA->states) + { + State* currentState=state.Obj(); + + // search for epsilon closure + List closure; + SearchClosure(&ShiftReduceCompactClosure, currentState, closure); + + FOREACH(ClosureItem, closureItem, closure) + { + Transition* lastTransition=closureItem.transitions->Get(closureItem.transitions->Count()-1); + Transition::StackOperationType stackOperationType=Transition::None; + Transition::TransitionType transitionType=lastTransition->transitionType; + + if(closureItem.cycle && lastTransition->transitionType==Transition::Epsilon) + { + bool containsShift=false; + bool containsReduce=false; + FOREACH(Transition*, pathTransition, *closureItem.transitions.Obj()) + { + FOREACH(Ptr, action, pathTransition->actions) + { + if(action->actionType==Action::Shift) containsShift=true; + if(action->actionType==Action::Reduce) containsReduce=true; + } + } + if(containsShift && !containsReduce) + { + // a left recursive compacted shift transition is found + // if the left recursive state is not the current state + // that means this transition path fall into other left recursive state + // e.g. + // Term = Factor | Term (here is a left recursion) * Factor + // Exp = Term (this rule symbol transition will fall into Term's left recursive state) ... + // if such a case happened, this transition path will be simply discarded + if(closureItem.state==currentState) + { + stackOperationType=Transition::LeftRecursive; + } + } + else if(!containsShift && containsReduce) + { + // a right recursive compacted reduce transition is found + // if this state will receive $TokenFinish, then the stack pattern number can be infinite + // e.g. for right recursive expression "a b c" == "(a (b c))" + // when trying to do a transition by $TokenFinish + // "a b" should reduce once + // "a b c" should reduce twice + // because that a reduce is not considered a virtual token, so this is not going to be happened + } + } + else if(closureItem.transitions->Count()>1) + { + // in joint PDA, only shift and reduce transitions are epsilon transition + // if there are more than one transition in a path, then there should be shift or reduce transitions in the path + stackOperationType=Transition::ShiftReduceCompacted; + } + + if(stackOperationType!=Transition::None) + { + // build shift-reduce-compacted transition to the target state of the path + Transition* transition=jointPDA->CopyTransition(currentState, lastTransition->target, lastTransition); + transition->transitionType=transitionType; + transition->stackOperationType=stackOperationType; + + // there will be , or + // but there will not be something like + // so we can append stackPattern safely + FOREACH(Transition*, pathTransition, *closureItem.transitions.Obj()) + { + CopyFrom(transition->actions, pathTransition->actions, true); + } + } + } + } + + // delete unnecessary transactions + for(vint i=jointPDA->transitions.Count()-1;i>=0;i--) + { + Transition* transition=jointPDA->transitions[i].Obj(); + if(transition->stackOperationType==Transition::None && transition->transitionType==Transition::Epsilon) + { + jointPDA->DeleteTransition(transition); + } + } + } + +/*********************************************************************** +MarkLeftRecursiveInJointPDA +***********************************************************************/ + + void MarkLeftRecursiveInJointPDA(Ptr jointPDA, collections::List>& errors) + { + vint errorCount=errors.Count(); + // record all left recursive shifts and delete all left recursive epsilon transition + SortedList> leftRecursiveShifts; + FOREACH(Ptr, state, jointPDA->states) + { + for(vint i=state->transitions.Count()-1;i>=0;i--) + { + Transition* transition=state->transitions[i]; + if(transition->stackOperationType==Transition::LeftRecursive) + { + Ptr shiftAction; + FOREACH(Ptr, action, transition->actions) + { + if(action->actionType==Action::Shift) + { + if(shiftAction) + { + errors.Add(new ParsingError(state->ownerRule, L"Indirect left recursive transition in rule \""+state->ownerRule->name+L"\" is not allowed.")); + goto FOUND_INDIRECT_LEFT_RECURSIVE_TRANSITION; + } + else + { + shiftAction=action; + } + } + } + if(shiftAction) + { + leftRecursiveShifts.Add(Pair(shiftAction->shiftReduceSource, shiftAction->shiftReduceTarget)); + } + FOUND_INDIRECT_LEFT_RECURSIVE_TRANSITION: + jointPDA->DeleteTransition(transition); + } + } + } + if(errorCount!=errors.Count()) + { + return; + } + + // change all reduce actions whose (shiftReduceSource, shiftReduceTarget) is recorded in leftRecursiveShifts to left-recursive-reduce + // when a reduce is converted to a left-recursive-reduce, the corresponding state in stackPattern should be removed + // so this will keep count(Reduce) == count(stackPattern) + FOREACH(Ptr, state, jointPDA->states) + { + FOREACH(Transition*, transition, state->transitions) + { + for(vint i=transition->actions.Count()-1;i>=0;i--) + { + Ptr action=transition->actions[i]; + if(action->actionType==Action::Reduce) + { + Pair shift(action->shiftReduceSource, action->shiftReduceTarget); + if(leftRecursiveShifts.Contains(shift)) + { + // check if this is a normal reduce transition, and change it to a left recursive reduce transition. + if (transition->transitionType == Transition::NormalReduce) + { + transition->transitionType = Transition::LeftRecursiveReduce; + // need to create a new action because in the previous phrases, these action object are shared and treated as read only + Ptr newAction=new Action; + newAction->actionType=Action::LeftRecursiveReduce; + newAction->actionSource=action->actionSource; + newAction->actionTarget=action->actionTarget; + newAction->creatorRule=action->creatorRule; + newAction->shiftReduceSource=action->shiftReduceSource; + newAction->shiftReduceTarget=action->shiftReduceTarget; + newAction->creatorRule=shift.key->ownerRule; + transition->actions[i]=newAction; + } + else + { + errors.Add(new ParsingError(state->ownerRule, L"Left recursive reduce action in non-normal-reduce found in rule \""+state->ownerRule->name+L"\" is not allowed.")); + } + } + } + } + } + } + + // delete complicated transitions + FOREACH(Ptr, state, jointPDA->states) + { + while(true) + { + bool deleted=false; + FOREACH(Transition*, t1, state->transitions) + FOREACH(Transition*, t2, state->transitions) + if(t1!=t2) + { + if(Transition::IsEquivalent(t1, t2, true)) + { + jointPDA->DeleteTransition(t2); + deleted=true; + goto TRANSITION_DELETED; + } + } + TRANSITION_DELETED: + if(!deleted) break; + } + } + } + } + } +} + +/*********************************************************************** +.\PARSING\PARSINGAUTOMATON_MERGESTATES.CPP +***********************************************************************/ + +namespace vl +{ + namespace parsing + { + using namespace collections; + using namespace definitions; + + namespace analyzing + { + +/*********************************************************************** +DeleteUnnecessaryStates +***********************************************************************/ + + void DeleteUnnecessaryStates(Ptr automaton, Ptr ruleInfo, List& newStates) + { + // delete all states that are not reachable to the end state + while(true) + { + // find a non-end state without out transitions + vint deleteCount=0; + for(vint i=newStates.Count()-1;i>=0;i--) + { + State* newState=newStates[i]; + if(newState->transitions.Count()==0) + { + if(newState!=ruleInfo->rootRuleEndState && !newState->endState) + { + automaton->DeleteState(newState); + newStates.RemoveAt(i); + } + } + } + if(deleteCount==0) + { + break; + } + } + } + +/*********************************************************************** +IsMergableCandidate +***********************************************************************/ + + bool IsMergableCandidate(State* state, Ptr ruleInfo) + { + if(state==ruleInfo->rootRuleStartState || state==ruleInfo->rootRuleEndState || state==ruleInfo->startState) + { + return false; + } + return true; + } + +/*********************************************************************** +RearrangeState +***********************************************************************/ + + vint CompareTransitionForRearranging(Transition* t1, Transition* t2) + { + if(t1->transitionTypetransitionType) return -1; + if(t1->transitionType>t2->transitionType) return 1; + if(t1->transitionSymboltransitionSymbol) return -1; + if(t1->transitionSymbol>t2->transitionSymbol) return 1; + return 0; + } + + vint CompareActionForRearranging(Ptr a1, Ptr a2) + { + if(a1->actionTypeactionType) return -1; + if(a1->actionType>a2->actionType) return 1; + if(a1->actionSourceactionSource) return -1; + if(a1->actionSource>a2->actionSource) return 1; + if(a1->actionTargetactionTarget) return -1; + if(a1->actionTarget>a2->actionTarget) return 1; + return 0; + } + + void RearrangeState(State* state, SortedList& stateContentSorted) + { + if(!stateContentSorted.Contains(state)) + { + FOREACH(Transition*, transition, state->transitions) + { + CopyFrom(transition->actions, From(transition->actions).OrderBy(&CompareActionForRearranging)); + } + CopyFrom(state->transitions, From(state->transitions).OrderBy(&CompareTransitionForRearranging)); + stateContentSorted.Add(state); + } + } + +/*********************************************************************** +MoveActionsForMergingState +***********************************************************************/ + + void MoveActionsForMergingState(Transition* transition) + { + // collect all movable actions + List> movableActions; + for(vint i=transition->actions.Count()-1;i>=0;i--) + { + switch(transition->actions[i]->actionType) + { + // Using and Assign actions are not movable + case Action::Using: + case Action::Assign: + break; + default: + movableActions.Add(transition->actions[i]); + transition->actions.RemoveAt(i); + } + } + + // copy all movable actions + FOREACH(Transition*, t, transition->source->inputs) + { + CopyFrom(t->actions, movableActions, true); + } + } + +/*********************************************************************** +IsMergableBecause(Transitions|Input) +***********************************************************************/ + + bool IsMergableBecauseTransitions(State* state1, State* state2) + { + if(state1->transitions.Count()!=state2->transitions.Count()) return false; + if(state1->transitions.Count()==1 && state2->transitions.Count()==1) + { + Transition* t1=state1->transitions[0]; + Transition* t2=state2->transitions[0]; + if(CompareTransitionForRearranging(t1, t2)==0 && !Transition::IsEquivalent(t1, t2, false) && t1->target==t2->target) + { + MoveActionsForMergingState(t1); + MoveActionsForMergingState(t2); + } + } + for(vint i=0;itransitions.Count();i++) + { + Transition* t1=state1->transitions[i]; + Transition* t2=state2->transitions[i]; + if(!Transition::IsEquivalent(t1, t2, false) || t1->target!=t2->target) + { + return false; + } + } + return true; + } + + bool IsMergableBecauseInputs(State* state1, State* state2) + { + if(state1->inputs.Count()!=state2->inputs.Count()) return false; + for(vint i=0;iinputs.Count();i++) + { + Transition* t1=state1->inputs[i]; + Transition* t2=state2->inputs[i]; + if(!Transition::IsEquivalent(t1, t2, false) || t1->source!=t2->source) + { + return false; + } + } + return true; + } + +/*********************************************************************** +MergeState2ToState1Because(Transitions|Input) +***********************************************************************/ + + void MergeState2ToState1BecauseTransitions(Ptr automaton, State* state1, State* state2) + { + // modify state1's expression + state1->stateExpression+=L"\r\n"+state2->stateExpression; + + // retarget state2's input to state1 + for(vint i=state2->inputs.Count()-1;i>=0;i--) + { + Transition* t2=state2->inputs[i]; + bool add=true; + FOREACH(Transition*, t1, state1->inputs) + { + if(Transition::IsEquivalent(t1, t2, false) && t1->source==t2->source) + { + add=false; + break; + } + } + if(add) + { + state1->inputs.Add(t2); + t2->target=state1; + state2->inputs.RemoveAt(i); + } + } + + automaton->DeleteState(state2); + } + + void MergeState2ToState1BecauseInputs(Ptr automaton, State* state1, State* state2) + { + // modify state1's expression + state1->stateExpression+=L"\r\n"+state2->stateExpression; + + // retarget state2's input to state1 + for(vint i=state2->transitions.Count()-1;i>=0;i--) + { + Transition* t2=state2->transitions[i]; + bool add=true; + FOREACH(Transition*, t1, state1->transitions) + { + if(Transition::IsEquivalent(t1, t2, false) && t1->target==t2->target) + { + add=false; + break; + } + } + if(add) + { + state1->transitions.Add(t2); + t2->source=state1; + state2->transitions.RemoveAt(i); + } + } + + automaton->DeleteState(state2); + } + +/*********************************************************************** +MergeStates +***********************************************************************/ + + void MergeStates(Ptr automaton, Ptr ruleInfo, List& newStates) + { + SortedList stateContentSorted; + while(true) + { + for(vint i=0;i CreateNondeterministicPDAFromEpsilonPDA(Ptr epsilonPDA) + { + Ptr automaton=new Automaton(epsilonPDA->symbolManager); + FOREACH(ParsingDefinitionRuleDefinition*, rule, epsilonPDA->ruleInfos.Keys()) + { + // build new rule info + Ptr ruleInfo=epsilonPDA->ruleInfos[rule]; + Ptr newRuleInfo=new RuleInfo; + automaton->ruleInfos.Add(rule, newRuleInfo); + + newRuleInfo->rootRuleStartState=automaton->RootRuleStartState(rule); + newRuleInfo->rootRuleEndState=automaton->RootRuleEndState(rule); + newRuleInfo->startState=automaton->RuleStartState(rule); + + // build state mapping and state visiting tracking + Dictionary oldNewStateMap; + List scanningStates; + vint currentStateIndex=0; + oldNewStateMap.Add(ruleInfo->rootRuleStartState, newRuleInfo->rootRuleStartState); + oldNewStateMap.Add(ruleInfo->rootRuleEndState, newRuleInfo->rootRuleEndState); + oldNewStateMap.Add(ruleInfo->startState, newRuleInfo->startState); + // begin with a root rule state state + scanningStates.Add(ruleInfo->rootRuleStartState); + // remove epsilon transitions + RemoveEpsilonTransitions(oldNewStateMap, scanningStates, automaton); + + List newStates; + CopyFrom(newStates, oldNewStateMap.Values()); + DeleteUnnecessaryStates(automaton, newRuleInfo, newStates); + MergeStates(automaton, newRuleInfo, newStates); + + // there should be at east one and only one transition that is TokenBegin from rootRuleStartState + // update the startState because the startState may be deleted + newRuleInfo->startState=newRuleInfo->rootRuleStartState->transitions[0]->target; + + // record end states + FOREACH(State*, state, newStates) + { + if(state->endState) + { + newRuleInfo->endStates.Add(state); + } + } + } + return automaton; + } + } + } +} + +/*********************************************************************** +.\REGEX\REGEXDATA.CPP +***********************************************************************/ + +namespace vl +{ + namespace regex_internal + { + +/*********************************************************************** +CharRange +***********************************************************************/ + + CharRange::CharRange() + :begin(L'\0') + ,end(L'\0') + { + } + + CharRange::CharRange(wchar_t _begin, wchar_t _end) + :begin(_begin) + ,end(_end) + { + } + + bool CharRange::operator<(CharRange item)const + { + return end(CharRange item)const + { + return item.end=(CharRange item)const + { + return *this>item || *this==item; + } + + bool CharRange::operator==(CharRange item)const + { + return begin==item.begin && end==item.end; + } + + bool CharRange::operator!=(CharRange item)const + { + return begin!=item.begin || item.end!=end; + } + + bool CharRange::operator<(wchar_t item)const + { + return end(wchar_t item)const + { + return item=(wchar_t item)const + { + return item<=end; + } + + bool CharRange::operator==(wchar_t item)const + { + return begin<=item && item<=end; + } + + bool CharRange::operator!=(wchar_t item)const + { + return itemsource!=t2->source || t1->target!=t2->target) - { - return false; - } - } - if( t1->actions.Count()!=t2->actions.Count() || - t1->transitionType!=t2->transitionType || - t1->transitionSymbol!=t2->transitionSymbol) - { - return false; - } - for(vint j=0;jactions.Count();j++) - { - Ptr a1=t1->actions[j]; - Ptr a2=t2->actions[j]; - if( a1->actionType!=a2->actionType || - a1->actionSource!=a2->actionSource || - a1->actionTarget!=a2->actionTarget || - a1->shiftReduceSource!=a2->shiftReduceSource ) - { - return false; - } - } - return true; - } - -/*********************************************************************** -State -***********************************************************************/ - - State::State() - :ownerRule(0) - ,ownerRuleSymbol(0) - ,grammarNode(0) - ,stateNode(0) - ,statePosition(BeforeNode) - ,endState(false) - { - } - - State::~State() - { - } - -/*********************************************************************** -RuleInfo -***********************************************************************/ - - RuleInfo::RuleInfo() - :rootRuleStartState(0) - ,rootRuleEndState(0) - ,startState(0) - ,stateNameCount(0) - { - } - - RuleInfo::~RuleInfo() - { - } - -/*********************************************************************** -Automaton -***********************************************************************/ - - Automaton::Automaton(ParsingSymbolManager* _symbolManager) - :symbolManager(_symbolManager) - { - } - - Automaton::~Automaton() - { - } - - State* Automaton::RuleStartState(definitions::ParsingDefinitionRuleDefinition* ownerRule) - { - State* state=new State; - states.Add(state); - - state->ownerRule=ownerRule; - state->ownerRuleSymbol=symbolManager->GetGlobal()->GetSubSymbolByName(ownerRule->name); - state->stateName=ownerRule->name+L".Start"; - state->stateExpression=L"@ <"+ownerRule->name+L">"; - return state; - } - - State* Automaton::RootRuleStartState(definitions::ParsingDefinitionRuleDefinition* ownerRule) - { - State* state=new State; - states.Add(state); - - state->ownerRule=ownerRule; - state->ownerRuleSymbol=symbolManager->GetGlobal()->GetSubSymbolByName(ownerRule->name); - state->stateName=ownerRule->name+L".RootStart"; - state->stateExpression=L"@ $<"+ownerRule->name+L">"; - return state; - } - - State* Automaton::RootRuleEndState(definitions::ParsingDefinitionRuleDefinition* ownerRule) - { - State* state=new State; - states.Add(state); - - state->ownerRule=ownerRule; - state->ownerRuleSymbol=symbolManager->GetGlobal()->GetSubSymbolByName(ownerRule->name); - state->stateName=ownerRule->name+L".RootEnd"; - state->stateExpression=L"$<"+ownerRule->name+L"> @"; - return state; - } - - State* Automaton::StartState(definitions::ParsingDefinitionRuleDefinition* ownerRule, definitions::ParsingDefinitionGrammar* grammarNode, definitions::ParsingDefinitionGrammar* stateNode) - { - State* state=new State; - states.Add(state); - - state->ownerRule=ownerRule; - state->ownerRuleSymbol=symbolManager->GetGlobal()->GetSubSymbolByName(ownerRule->name); - state->grammarNode=grammarNode; - state->stateNode=stateNode; - state->statePosition=State::BeforeNode; - state->stateName=ownerRule->name+L"."+itow(++ruleInfos[ownerRule]->stateNameCount); - stateNode=FindAppropriateGrammarState(grammarNode, stateNode, true); - state->stateExpression=L"<"+ownerRule->name+L">: "+GrammarStateToString(grammarNode, stateNode, true); - return state; - } - - State* Automaton::EndState(definitions::ParsingDefinitionRuleDefinition* ownerRule, definitions::ParsingDefinitionGrammar* grammarNode, definitions::ParsingDefinitionGrammar* stateNode) - { - State* state=new State; - states.Add(state); - - state->ownerRule=ownerRule; - state->ownerRuleSymbol=symbolManager->GetGlobal()->GetSubSymbolByName(ownerRule->name); - state->grammarNode=grammarNode; - state->stateNode=stateNode; - state->statePosition=State::AfterNode; - state->stateName=ownerRule->name+L"."+itow(++ruleInfos[ownerRule]->stateNameCount); - stateNode=FindAppropriateGrammarState(grammarNode, stateNode, false); - state->stateExpression=L"<"+ownerRule->name+L">: "+GrammarStateToString(grammarNode, stateNode, false); - return state; - } - - State* Automaton::CopyState(State* oldState) - { - State* resultState=0; - if(oldState->statePosition==State::BeforeNode) - { - resultState=StartState(oldState->ownerRule, oldState->grammarNode, oldState->stateNode); - } - else - { - resultState=EndState(oldState->ownerRule, oldState->grammarNode, oldState->stateNode); - } - resultState->endState=oldState->endState; - return resultState; - } - - Transition* Automaton::CreateTransition(State* start, State* end) - { - Transition* transition=new Transition; - transitions.Add(transition); - - start->transitions.Add(transition); - end->inputs.Add(transition); - - transition->source=start; - transition->target=end; - return transition; - } - - Transition* Automaton::TokenBegin(State* start, State* end) - { - Transition* transition=CreateTransition(start, end); - transition->transitionType=Transition::TokenBegin; - return transition; - } - - Transition* Automaton::TokenFinish(State* start, State* end) - { - Transition* transition=CreateTransition(start, end); - transition->transitionType=Transition::TokenFinish; - return transition; - } - - Transition* Automaton::NormalReduce(State* start, State* end) - { - Transition* transition=CreateTransition(start, end); - transition->transitionType=Transition::NormalReduce; - return transition; - } - - Transition* Automaton::LeftRecursiveReduce(State* start, State* end) - { - Transition* transition=CreateTransition(start, end); - transition->transitionType=Transition::LeftRecursiveReduce; - return transition; - } - - Transition* Automaton::Epsilon(State* start, State* end) - { - Transition* transition=CreateTransition(start, end); - transition->transitionType=Transition::Epsilon; - return transition; - } - - Transition* Automaton::Symbol(State* start, State* end, ParsingSymbol* transitionSymbol) - { - Transition* transition=CreateTransition(start, end); - transition->transitionType=Transition::Symbol; - transition->transitionSymbol=transitionSymbol; - return transition; - } - - Transition* Automaton::CopyTransition(State* start, State* end, Transition* oldTransition) - { - Transition* transition=CreateTransition(start, end); - transition->transitionType=oldTransition->transitionType; - transition->stackOperationType=oldTransition->stackOperationType; - transition->transitionSymbol=oldTransition->transitionSymbol; - return transition; - } - - void Automaton::DeleteTransition(Transition* transition) - { - transition->source->transitions.Remove(transition); - transition->target->inputs.Remove(transition); - transitions.Remove(transition); - } - - void Automaton::DeleteState(State* state) - { - while(state->inputs.Count()) - { - DeleteTransition(state->inputs[0]); - } - while(state->transitions.Count()) - { - DeleteTransition(state->transitions[0]); - } - states.Remove(state); - } - } - } -} - -/*********************************************************************** -PARSING\PARSINGAUTOMATON_CLOSURE.CPP -***********************************************************************/ - -namespace vl -{ - namespace parsing - { - using namespace collections; - using namespace definitions; - - namespace analyzing - { - -/*********************************************************************** -CreateNondeterministicPDAFromEpsilonPDA::closure_searching -***********************************************************************/ - - // closure function for searching reachable states - ClosureItem::SearchResult EpsilonClosure(Transition* transition) - { - return - transition->transitionType!=Transition::Epsilon?ClosureItem::Hit: - //transition->target->endState?ClosureItem::Blocked: - ClosureItem::Continue; - } - - // closure searching function - void SearchClosureInternal(ClosureItem::SearchResult(*closurePredicate)(Transition*), List& transitionPath, Transition* transition, State* state, List& closure) - { - FOREACH(Transition*, singleTransitionPath, transitionPath) - { - if(singleTransitionPath->source==state && closurePredicate(singleTransitionPath)!=ClosureItem::Blocked) - { - Ptr> path=new List; - CopyFrom(*path.Obj(), transitionPath); - closure.Add(ClosureItem(state, path, true)); - return; - } - } - - ClosureItem::SearchResult result=transition?closurePredicate(transition):ClosureItem::Continue; - switch(result) - { - case ClosureItem::Continue: - { - FOREACH(Transition*, newTransition, state->transitions) - { - if(!transitionPath.Contains(newTransition)) - { - transitionPath.Add(newTransition); - SearchClosureInternal(closurePredicate, transitionPath, newTransition, newTransition->target, closure); - transitionPath.RemoveAt(transitionPath.Count()-1); - } - } - } - break; - case ClosureItem::Hit: - { - Ptr> path=new List; - CopyFrom(*path.Obj(), transitionPath); - closure.Add(ClosureItem(state, path, false)); - } - break; - default:; - } - } - - void SearchClosure(ClosureItem::SearchResult(*closurePredicate)(Transition*), State* startState, List& closure) - { - List transitionPath; - SearchClosureInternal(closurePredicate, transitionPath, 0, startState, closure); - } - - // map old state to new state and track all states that are not visited yet - State* GetMappedState(Ptr newAutomaton, State* oldState, List& scanningStates, Dictionary& oldNewStateMap) - { - State* newState=0; - vint mapIndex=oldNewStateMap.Keys().IndexOf(oldState); - if(mapIndex==-1) - { - newState=newAutomaton->CopyState(oldState); - oldNewStateMap.Add(oldState, newState); - } - else - { - newState=oldNewStateMap.Values().Get(mapIndex); - } - if(!scanningStates.Contains(oldState)) - { - scanningStates.Add(oldState); - } - return newState; - } - -/*********************************************************************** -RemoveEpsilonTransitions -***********************************************************************/ - - void RemoveEpsilonTransitions(collections::Dictionary& oldNewStateMap, collections::List& scanningStates, Ptr automaton) - { - vint currentStateIndex=0; - - while(currentStateIndex closure; - SearchClosure(&EpsilonClosure, currentOldState, closure); - FOREACH(ClosureItem, closureItem, closure) - { - Transition* oldTransition=closureItem.transitions->Get(closureItem.transitions->Count()-1); - if(!closureItem.cycle || oldTransition->transitionType!=Transition::Epsilon) - { - // if the oldTransition begins from an end state - if(oldTransition->source->endState && closureItem.transitions->Count()>1) - { - // keep a epsilon transition that without the last "TokenFinish" - State* newEndState=GetMappedState(automaton, oldTransition->source, scanningStates, oldNewStateMap); - Transition* transition=automaton->Epsilon(currentNewState, newEndState); - FOREACH(Transition*, pathTransition, *closureItem.transitions.Obj()) - { - if(pathTransition==oldTransition) break; - CopyFrom(transition->actions, pathTransition->actions, true); - } - } - else - { - // build compacted non-epsilon transition to the target state of the path - State* newEndState=GetMappedState(automaton, oldTransition->target, scanningStates, oldNewStateMap); - Transition* transition=automaton->CopyTransition(currentNewState, newEndState, oldTransition); - FOREACH(Transition*, pathTransition, *closureItem.transitions.Obj()) - { - CopyFrom(transition->actions, pathTransition->actions, true); - } - } - } - } - } - } - } - } -} - -/*********************************************************************** -PARSING\PARSINGAUTOMATON_EPDA.CPP -***********************************************************************/ - -namespace vl -{ - namespace parsing - { - using namespace collections; - using namespace definitions; - - namespace analyzing - { - -/*********************************************************************** -CreateEpsilonPDAVisitor -***********************************************************************/ - - class CreateEpsilonPDAVisitor : public Object, public ParsingDefinitionGrammar::IVisitor - { - public: - Ptr automaton; - ParsingDefinitionRuleDefinition* rule; - ParsingDefinitionGrammar* ruleGrammar; - State* startState; - State* endState; - Transition* result; - - CreateEpsilonPDAVisitor(Ptr _automaton, ParsingDefinitionRuleDefinition* _rule, ParsingDefinitionGrammar* _ruleGrammar, State* _startState, State* _endState) - :automaton(_automaton) - ,rule(_rule) - ,ruleGrammar(_ruleGrammar) - ,startState(_startState) - ,endState(_endState) - ,result(0) - { - } - - static Transition* Create(ParsingDefinitionGrammar* grammar, Ptr automaton, ParsingDefinitionRuleDefinition* rule, ParsingDefinitionGrammar* ruleGrammar, State* startState, State* endState) - { - CreateEpsilonPDAVisitor visitor(automaton, rule, ruleGrammar, startState, endState); - grammar->Accept(&visitor); - return visitor.result; - } - - Transition* Create(ParsingDefinitionGrammar* grammar, State* startState, State* endState) - { - return Create(grammar, automaton, rule, ruleGrammar, startState, endState); - } - - void Visit(ParsingDefinitionPrimitiveGrammar* node)override - { - result=automaton->Symbol(startState, endState, automaton->symbolManager->CacheGetSymbol(node)); - } - - void Visit(ParsingDefinitionTextGrammar* node)override - { - result=automaton->Symbol(startState, endState, automaton->symbolManager->CacheGetSymbol(node)); - } - - void Visit(ParsingDefinitionSequenceGrammar* node)override - { - State* middleState=automaton->EndState(startState->ownerRule, ruleGrammar, node->first.Obj()); - Create(node->first.Obj(), startState, middleState); - Create(node->second.Obj(), middleState, endState); - } - - void Visit(ParsingDefinitionAlternativeGrammar* node)override - { - Create(node->first.Obj(), startState, endState); - Create(node->second.Obj(), startState, endState); - } - - void Visit(ParsingDefinitionLoopGrammar* node)override - { - State* loopStart=automaton->StartState(startState->ownerRule, ruleGrammar, node->grammar.Obj()); - automaton->Epsilon(startState, loopStart); - automaton->Epsilon(loopStart, endState); - Create(node->grammar.Obj(), loopStart, loopStart); - } - - void Visit(ParsingDefinitionOptionalGrammar* node)override - { - Create(node->grammar.Obj(), startState, endState); - automaton->Epsilon(startState, endState); - } - - void Visit(ParsingDefinitionCreateGrammar* node)override - { - State* middleState=automaton->EndState(startState->ownerRule, ruleGrammar, node->grammar.Obj()); - Create(node->grammar.Obj(), startState, middleState); - Transition* transition=automaton->Epsilon(middleState, endState); - - Ptr action=new Action; - action->actionType=Action::Create; - action->actionSource=automaton->symbolManager->CacheGetType(node->type.Obj(), 0); - action->creatorRule=rule; - transition->actions.Add(action); - } - - void Visit(ParsingDefinitionAssignGrammar* node)override - { - Transition* transition=Create(node->grammar.Obj(), startState, endState); - - Ptr action=new Action; - action->actionType=Action::Assign; - action->actionSource=automaton->symbolManager->CacheGetSymbol(node); - action->creatorRule=rule; - transition->actions.Add(action); - } - - void Visit(ParsingDefinitionUseGrammar* node)override - { - Transition* transition=Create(node->grammar.Obj(), startState, endState); - - Ptr action=new Action; - action->actionType=Action::Using; - action->creatorRule=rule; - transition->actions.Add(action); - } - - void Visit(ParsingDefinitionSetterGrammar* node)override - { - State* middleState=automaton->EndState(startState->ownerRule, ruleGrammar, node->grammar.Obj()); - Create(node->grammar.Obj(), startState, middleState); - Transition* transition=automaton->Epsilon(middleState, endState); - - Ptr action=new Action; - action->actionType=Action::Setter; - action->actionSource=automaton->symbolManager->CacheGetSymbol(node); - action->actionTarget=action->actionSource->GetDescriptorSymbol()->GetSubSymbolByName(node->value); - action->creatorRule=rule; - transition->actions.Add(action); - } - }; - -/*********************************************************************** -CreateRuleEpsilonPDA -***********************************************************************/ - - void CreateRuleEpsilonPDA(Ptr automaton, Ptr rule, ParsingSymbolManager* manager) - { - Ptr ruleInfo=new RuleInfo; - automaton->ruleInfos.Add(rule.Obj(), ruleInfo); - - ruleInfo->rootRuleStartState=automaton->RootRuleStartState(rule.Obj()); - ruleInfo->rootRuleEndState=automaton->RootRuleEndState(rule.Obj()); - ruleInfo->startState=automaton->RuleStartState(rule.Obj()); - automaton->TokenBegin(ruleInfo->rootRuleStartState, ruleInfo->startState); - - FOREACH(Ptr, grammar, rule->grammars) - { - State* grammarStartState=automaton->StartState(rule.Obj(), grammar.Obj(), grammar.Obj()); - State* grammarEndState=automaton->EndState(rule.Obj(), grammar.Obj(), grammar.Obj()); - grammarEndState->stateName+=L".End"; - grammarEndState->endState=true; - automaton->Epsilon(ruleInfo->startState, grammarStartState); - automaton->TokenFinish(grammarEndState, ruleInfo->rootRuleEndState); - ruleInfo->endStates.Add(grammarEndState); - CreateEpsilonPDAVisitor::Create(grammar.Obj(), automaton, rule.Obj(), grammar.Obj(), grammarStartState, grammarEndState); - } - } - -/*********************************************************************** -CreateEpsilonPDA -***********************************************************************/ - - Ptr CreateEpsilonPDA(Ptr definition, ParsingSymbolManager* manager) - { - Ptr automaton=new Automaton(manager); - FOREACH(Ptr, rule, definition->rules) - { - CreateRuleEpsilonPDA(automaton, rule, manager); - } - return automaton; - } - } - } -} - -/*********************************************************************** -PARSING\PARSINGAUTOMATON_GENERATETABLE.CPP -***********************************************************************/ - -namespace vl -{ - namespace parsing - { - using namespace collections; - using namespace definitions; - using namespace tabling; - - namespace analyzing - { - -/*********************************************************************** -GetTypeNameForCreateInstruction -***********************************************************************/ - - WString GetTypeNameForCreateInstruction(ParsingSymbol* type) - { - ParsingSymbol* parent=type->GetParentSymbol(); - if(parent->GetType()==ParsingSymbol::ClassType) - { - return GetTypeNameForCreateInstruction(parent)+L"."+type->GetName(); - } - else - { - return type->GetName(); - } - } - -/*********************************************************************** -CreateLookAhead -***********************************************************************/ - - void CopyStableLookAheads(List>& la, List>& sla, const List>& la2) - { - CopyFrom(sla, From(la) - .Where([&](Ptr lai) - { - return From(la2).All([&](Ptr lai2) - { - return ParsingTable::LookAheadInfo::TestPrefix(lai, lai2)==ParsingTable::LookAheadInfo::NotPrefix; - }); - }), - true); - } - - void RemoveStableLookAheads(List>& la, const List>& sla) - { - for(vint i=la.Count()-1;i>=0;i--) - { - if(sla.Contains(la[i].Obj())) - { - la.RemoveAt(i); - } - } - } - - bool WalkLookAheads(Ptr table, List>& la, vint maxTokenCount) - { - vint count=la.Count(); - for(vint i=0;i lai=la[i]; - if(lai->tokens.Count()==maxTokenCount) - { - return false; - } - ParsingTable::LookAheadInfo::Walk(table, lai, lai->state, la); - } - return true; - } - - void CompactLookAheads(Ptr t, List>& sla) - { - CopyFrom(sla, t->lookAheads, true); - CopyFrom(t->lookAheads, From(sla) - .Where([&](Ptr lai) - { - return From(sla).All([&](Ptr lai2) - { - if(lai==lai2) return true; - ParsingTable::LookAheadInfo::PrefixResult result=ParsingTable::LookAheadInfo::TestPrefix(lai, lai2); - switch(result) - { - case ParsingTable::LookAheadInfo::Prefix: - return false; - case ParsingTable::LookAheadInfo::Equal: - return lai table, Ptr t1, Ptr t2, vint maxTokenCount) - { - List> la1, la2, sla1, sla2; - - // calculate 1-token look aheads - ParsingTable::LookAheadInfo::Walk(table, 0, t1->targetState, la1); - ParsingTable::LookAheadInfo::Walk(table, 0, t2->targetState, la2); - - do - { - // pick up all stable look aheads and remove them from the look ahead list - // stable look ahead means, when the look ahead is satisfied, then the transition is picked up with full confidence - // non-stable look ahead means, when the look ahead is satisifed, it only increase confidence, needs further tokens for decision - CopyStableLookAheads(la1, sla1, la2); - CopyStableLookAheads(la2, sla2, la1); - RemoveStableLookAheads(la1, sla1); - RemoveStableLookAheads(la2, sla2); - - // check if there are non-stable look aheads in two transitions points to the same state - // in such situation means that the two transition cannot always be determined using look aheads - FOREACH(Ptr, lai1, la1) - { - FOREACH(Ptr, lai2, la2) - { - if (lai1->state == lai2->state) - { - if (ParsingTable::LookAheadInfo::TestPrefix(lai1, lai2) != ParsingTable::LookAheadInfo::NotPrefix) - { - return false; - } - if (ParsingTable::LookAheadInfo::TestPrefix(lai2, lai1) != ParsingTable::LookAheadInfo::NotPrefix) - { - return false; - } - } - } - } - - // use the non-stable look aheads to walk a token further - if(!WalkLookAheads(table, la1, maxTokenCount) || !WalkLookAheads(table, la2, maxTokenCount)) - { - return false; - } - } - while(la1.Count()>0 || la2.Count()>0); - - CompactLookAheads(t1, sla1); - CompactLookAheads(t2, sla2); - return true; - } - -/*********************************************************************** -CollectAttribute -***********************************************************************/ - - void CollectType(ParsingSymbol* symbol, List& types) - { - if(symbol->GetType()==ParsingSymbol::ClassType) - { - types.Add(symbol); - } - vint count=symbol->GetSubSymbolCount(); - for(vint i=0;iGetSubSymbol(i), types); - } - } - - void CollectAttributeInfo(Ptr att, List>& atts) - { - FOREACH(Ptr, datt, atts) - { - Ptr tatt=new ParsingTable::AttributeInfo(datt->name); - CopyFrom(tatt->arguments, datt->arguments); - att->attributes.Add(tatt); - } - } - - Ptr CreateAttributeInfo(List>& atts) - { - Ptr att=new ParsingTable::AttributeInfoList; - CollectAttributeInfo(att, atts); - return att; - } - -/*********************************************************************** -GenerateTable -***********************************************************************/ - - vint LookAheadConflictPriority(vint tableTokenIndex) - { - switch (tableTokenIndex) - { - case ParsingTable::NormalReduce: - return 0; - case ParsingTable::LeftRecursiveReduce: - return 1; - default: - return 2; - } - } - - void GenerateLookAhead(Ptr table, List& stateIds, vint state, vint token, Ptr t1, Ptr t2, bool enableAmbiguity, collections::List>& errors) - { - if(ParsingTable::TransitionItem::CheckOrder(t1, t2, false)==ParsingTable::TransitionItem::UnknownOrder) - { - if(enableAmbiguity || !CreateLookAhead(table, t1, t2, 16)) - { - if (LookAheadConflictPriority(t1->token) != LookAheadConflictPriority(t2->token)) - { - return; - } - WString stateName=itow(state)+L"["+table->GetStateInfo(state).stateName+L"]"; - WString tokenName= - token==ParsingTable::TokenBegin?WString(L"$TokenBegin"): - token==ParsingTable::TokenFinish?WString(L"$TokenFinish"): - token==ParsingTable::NormalReduce?WString(L"$NormalReduce"): - token==ParsingTable::LeftRecursiveReduce?WString(L"$LeftRecursiveReduce"): - table->GetTokenInfo(token).name; - switch (t1->token) - { - case ParsingTable::NormalReduce: - errors.Add(new ParsingError(stateIds[state]->ownerRule, L"Conflict happened with normal reduce in transition of \""+tokenName+L"\" of state \""+stateName+L"\".")); - break; - case ParsingTable::LeftRecursiveReduce: - errors.Add(new ParsingError(stateIds[state]->ownerRule, L"Conflict happened with left recursive reduce in transition of \""+tokenName+L"\" of state \""+stateName+L"\".")); - break; - default: - errors.Add(new ParsingError(stateIds[state]->ownerRule, L"Conflict happened in transition of \""+tokenName+L"\" of state \""+stateName+L"\".")); - break; - } - } - } - } - - Ptr GenerateTableFromPDA(Ptr definition, ParsingSymbolManager* manager, Ptr jointPDA, bool enableAmbiguity, collections::List>& errors) - { - List> atts; - - /*********************************************************************** - find all class types - ***********************************************************************/ - List types; - Dictionary typeAtts; - Dictionary, vint> treeFieldAtts; - Dictionary>> childTypes; - - // find all class types - CollectType(manager->GetGlobal(), types); - FOREACH(ParsingSymbol*, type, types) - { - Ptr typeAtt=new ParsingTable::AttributeInfoList; - ParsingSymbol* parent=type; - while(parent) - { - ParsingDefinitionClassDefinition* classDef=manager->CacheGetClassDefinition(parent); - CollectAttributeInfo(typeAtt, classDef->attributes); - - Ptr> children; - vint index=childTypes.Keys().IndexOf(parent); - if(index==-1) - { - children=new List; - childTypes.Add(parent, children); - } - else - { - children=childTypes.Values().Get(index); - } - - children->Add(type); - parent=parent->GetDescriptorSymbol(); - } - - if(typeAtt->attributes.Count()>0) - { - typeAtts.Add(GetTypeFullName(type), atts.Count()); - atts.Add(typeAtt); - } - else - { - typeAtts.Add(GetTypeFullName(type), -1); - } - } - - // find all class fields - for(vint i=0;i& children=*childTypes.Values().Get(i).Obj(); - - ParsingDefinitionClassDefinition* classDef=manager->CacheGetClassDefinition(type); - List fieldAtts; - FOREACH_INDEXER(Ptr, field, index, classDef->members) - { - if(field->attributes.Count()>0) - { - fieldAtts.Add(atts.Count()); - atts.Add(CreateAttributeInfo(field->attributes)); - } - else - { - fieldAtts.Add(-1); - } - } - - FOREACH(ParsingSymbol*, child, children) - { - WString type=GetTypeFullName(child); - FOREACH_INDEXER(Ptr, field, index, classDef->members) - { - treeFieldAtts.Add(Pair(type, field->name), fieldAtts[index]); - } - } - } - - /*********************************************************************** - find all tokens - ***********************************************************************/ - vint tokenCount=0; - vint discardTokenCount=0; - Dictionary tokenIds; - List discardTokens; - - Dictionary tokenAtts; - Dictionary ruleAtts; - - FOREACH(Ptr, token, definition->tokens) - { - if(token->attributes.Count()>0) - { - tokenAtts.Add(token->name, atts.Count()); - atts.Add(CreateAttributeInfo(token->attributes)); - } - else - { - tokenAtts.Add(token->name, -1); - } - - if(token->discard) - { - discardTokens.Add(token->name); - discardTokenCount++; - } - else - { - ParsingSymbol* tokenSymbol=jointPDA->symbolManager->GetGlobal()->GetSubSymbolByName(token->name); - tokenIds.Add(tokenSymbol, tokenIds.Count()+ParsingTable::UserTokenStart); - tokenCount++; - } - } - - /*********************************************************************** - find all rules - ***********************************************************************/ - FOREACH(Ptr, rule, definition->rules) - { - if(rule->attributes.Count()>0) - { - ruleAtts.Add(rule->name, atts.Count()); - atts.Add(CreateAttributeInfo(rule->attributes)); - } - else - { - ruleAtts.Add(rule->name, -1); - } - } - - /*********************************************************************** - find all available states - ***********************************************************************/ - List stateIds; - vint availableStateCount=0; - { - vint currentState=0; - List scanningStates; - FOREACH(Ptr, ruleInfo, jointPDA->ruleInfos.Values()) - { - if(!scanningStates.Contains(ruleInfo->rootRuleStartState)) - { - scanningStates.Add(ruleInfo->rootRuleStartState); - } - - while(currentStatetransitions) - { - if(!scanningStates.Contains(transition->target)) - { - scanningStates.Add(transition->target); - } - } - } - } - availableStateCount=scanningStates.Count(); - } - - // there will be some states that is used in shift and reduce but it is not a reachable state - // so the state table will record all state - FOREACH(Ptr, state, jointPDA->states) - { - if(!stateIds.Contains(state.Obj())) - { - stateIds.Add(state.Obj()); - } - } - vint stateCount=stateIds.Count(); - - Ptr table=new ParsingTable(atts.Count(), typeAtts.Count(), treeFieldAtts.Count(), tokenCount, discardTokenCount, stateCount, definition->rules.Count()); - - /*********************************************************************** - fill attribute infos - ***********************************************************************/ - FOREACH_INDEXER(Ptr, att, index, atts) - { - table->SetAttributeInfo(index, att); - } - - /*********************************************************************** - fill tree type infos - ***********************************************************************/ - typedef Pair TreeTypeAttsPair; - FOREACH_INDEXER(TreeTypeAttsPair, type, index, typeAtts) - { - table->SetTreeTypeInfo(index, ParsingTable::TreeTypeInfo(type.key, type.value)); - } - - /*********************************************************************** - fill tree field infos - ***********************************************************************/ - typedef Pair, vint> TreeFieldAttsPair; - FOREACH_INDEXER(TreeFieldAttsPair, field, index, treeFieldAtts) - { - table->SetTreeFieldInfo(index, ParsingTable::TreeFieldInfo(field.key.key, field.key.value, field.value)); - } - - /*********************************************************************** - fill token infos - ***********************************************************************/ - FOREACH(ParsingSymbol*, symbol, tokenIds.Keys()) - { - ParsingTable::TokenInfo info; - info.name=symbol->GetName(); - info.regex=symbol->GetDescriptorString(); - info.attributeIndex=tokenAtts[info.name]; - - vint id=tokenIds[symbol]; - table->SetTokenInfo(id, info); - } - - FOREACH_INDEXER(WString, name, i, discardTokens) - { - ParsingSymbol* symbol=jointPDA->symbolManager->GetGlobal()->GetSubSymbolByName(name); - - ParsingTable::TokenInfo info; - info.name=symbol->GetName(); - info.regex=symbol->GetDescriptorString(); - info.attributeIndex=tokenAtts[info.name]; - table->SetDiscardTokenInfo(i, info); - } - - /*********************************************************************** - fill rule infos - ***********************************************************************/ - FOREACH_INDEXER(ParsingDefinitionRuleDefinition*, rule, i, jointPDA->ruleInfos.Keys()) - { - Ptr pdaRuleInfo=jointPDA->ruleInfos[rule]; - ParsingTable::RuleInfo info; - info.name=rule->name; - info.type=TypeToString(rule->type.Obj()); - info.rootStartState=stateIds.IndexOf(pdaRuleInfo->rootRuleStartState); - info.attributeIndex=ruleAtts[info.name]; - - if(Ptr classType=rule->type.Cast()) - { - ParsingSymbol* ruleSymbol=manager->GetGlobal()->GetSubSymbolByName(rule->name); - ParsingSymbol* ruleType=ruleSymbol->GetDescriptorSymbol(); - ParsingDefinitionClassDefinition* ruleTypeDef=manager->CacheGetClassDefinition(ruleType); - if(ruleTypeDef && ruleTypeDef->ambiguousType) - { - ParsingSymbol* ambiguousType=manager->CacheGetType(ruleTypeDef->ambiguousType.Obj(), ruleType->GetParentSymbol()); - info.ambiguousType=GetTypeFullName(ambiguousType); - } - } - table->SetRuleInfo(i, info); - } - - /*********************************************************************** - fill state infos - ***********************************************************************/ - FOREACH_INDEXER(State*, state, i, stateIds) - { - ParsingTable::StateInfo info; - info.ruleName=state->ownerRule->name; - info.stateName=state->stateName; - info.stateExpression=state->stateExpression; - table->SetStateInfo(i, info); - } - - /*********************************************************************** - fill transition table - ***********************************************************************/ - FOREACH_INDEXER(State*, state, stateIndex, stateIds) - { - // if this state is not necessary, stop building the table - if(stateIndex>=availableStateCount) break; - - FOREACH(Transition*, transition, state->transitions) - { - vint tokenIndex=-1; - switch(transition->transitionType) - { - case Transition::TokenBegin: - tokenIndex=ParsingTable::TokenBegin; - break; - case Transition::TokenFinish: - tokenIndex=ParsingTable::TokenFinish; - break; - case Transition::NormalReduce: - tokenIndex=ParsingTable::NormalReduce; - break; - case Transition::LeftRecursiveReduce: - tokenIndex=ParsingTable::LeftRecursiveReduce; - break; - case Transition::Symbol: - tokenIndex=tokenIds[transition->transitionSymbol]; - break; - default:; - } - - Ptr bag=table->GetTransitionBag(stateIndex, tokenIndex); - if(!bag) - { - bag=new ParsingTable::TransitionBag; - table->SetTransitionBag(stateIndex, tokenIndex, bag); - } - - Ptr item=new ParsingTable::TransitionItem; - item->token=tokenIndex; - item->targetState=stateIds.IndexOf(transition->target); - bag->transitionItems.Add(item); - - FOREACH(Ptr, action, transition->actions) - { - ParsingTable::Instruction ins; - switch(action->actionType) - { - case Action::Create: - { - ins.instructionType=ParsingTable::Instruction::Create; - ins.nameParameter=GetTypeNameForCreateInstruction(action->actionSource); - } - break; - case Action::Using: - { - ins.instructionType=ParsingTable::Instruction::Using; - } - break; - case Action::Assign: - { - if(action->actionSource->GetDescriptorSymbol()->GetType()==ParsingSymbol::ArrayType) - { - ins.instructionType=ParsingTable::Instruction::Item; - } - else - { - ins.instructionType=ParsingTable::Instruction::Assign; - } - ins.nameParameter=action->actionSource->GetName(); - } - break; - case Action::Setter: - { - ins.instructionType=ParsingTable::Instruction::Setter; - ins.nameParameter=action->actionSource->GetName(); - ins.value=action->actionTarget->GetName(); - } - break; - case Action::Shift: - { - ins.instructionType=ParsingTable::Instruction::Shift; - ins.stateParameter=stateIds.IndexOf(action->shiftReduceSource); - } - break; - case Action::Reduce: - { - ins.instructionType=ParsingTable::Instruction::Reduce; - ins.stateParameter=stateIds.IndexOf(action->shiftReduceSource); - item->stackPattern.Add(ins.stateParameter); - } - break; - case Action::LeftRecursiveReduce: - { - ins.instructionType=ParsingTable::Instruction::LeftRecursiveReduce; - ins.stateParameter=stateIds.IndexOf(action->shiftReduceSource); - } - break; - } - ins.creatorRule=action->creatorRule->name; - item->instructions.Add(ins); - } - } - } - - /*********************************************************************** - check conflict and build look ahead table - ***********************************************************************/ - for (vint i = 0; i < table->GetStateCount(); i++) - { - for (vint j = 0; j < table->GetTokenCount(); j++) - { - Ptr bag=table->GetTransitionBag(i, j); - if(bag) - { - CopyFrom(bag->transitionItems, From(bag->transitionItems).OrderBy(ParsingTable::TransitionItem::Compare)); - - // build look ahead inside a transition - for (vint k1 = 0; k1 < bag->transitionItems.Count() - 1; k1++) - { - for (vint k2 = k1 + 1; k2 < bag->transitionItems.Count(); k2++) - { - Ptr t1=bag->transitionItems[k1]; - Ptr t2=bag->transitionItems[k2]; - GenerateLookAhead(table, stateIds, i, j, t1, t2, enableAmbiguity, errors); - } - } - - // build look ahead between this transition and reduce transitions - for (vint t = ParsingTable::NormalReduce; t <= ParsingTable::LeftRecursiveReduce && t < j; t++) - { - if (Ptr reduceBag = table->GetTransitionBag(i, t)) - { - for (vint k1 = 0; k1 < reduceBag->transitionItems.Count(); k1++) - { - for (vint k2 = 0; k2 < bag->transitionItems.Count(); k2++) - { - Ptr t1=reduceBag->transitionItems[k1]; - Ptr t2=bag->transitionItems[k2]; - GenerateLookAhead(table, stateIds, i, j, t1, t2, enableAmbiguity, errors); - } - } - } - } - } - } - } - - /*********************************************************************** - initialize table - ***********************************************************************/ - if(errors.Count()>0) - { - table->SetAmbiguity(true); - } - table->Initialize(); - return table; - } - - Ptr GenerateTable(Ptr definition, bool enableAmbiguity, collections::List>& errors) - { - errors.Clear(); - ParsingSymbolManager symbolManager; - ValidateDefinition(definition, &symbolManager, errors); - if(errors.Count()==0) - { - Ptr epsilonPDA=CreateEpsilonPDA(definition, &symbolManager); - Ptr nondeterministicPDA=CreateNondeterministicPDAFromEpsilonPDA(epsilonPDA); - Ptr jointPDA=CreateJointPDAFromNondeterministicPDA(nondeterministicPDA); - CompactJointPDA(jointPDA); - MarkLeftRecursiveInJointPDA(jointPDA, errors); - if(errors.Count()==0) - { - Ptr table=GenerateTableFromPDA(definition, &symbolManager, jointPDA, enableAmbiguity, errors); - if(enableAmbiguity || errors.Count()==0) - { - return table; - } - } - } - return 0; - } - } - } -} - -/*********************************************************************** -PARSING\PARSINGAUTOMATON_JPDA.CPP -***********************************************************************/ - -namespace vl -{ - namespace parsing - { - using namespace collections; - using namespace definitions; - - namespace analyzing - { -/*********************************************************************** -CreateJointPDAFromNondeterministicPDA -***********************************************************************/ - - Ptr CreateJointPDAFromNondeterministicPDA(Ptr nondeterministicPDA) - { - Ptr automaton=new Automaton(nondeterministicPDA->symbolManager); - - // build rule info data - Dictionary ruleMap; - Dictionary oldNewStateMap; - FOREACH(ParsingDefinitionRuleDefinition*, rule, nondeterministicPDA->ruleInfos.Keys()) - { - // build new rule info - Ptr ruleInfo=nondeterministicPDA->ruleInfos[rule]; - Ptr newRuleInfo=new RuleInfo; - automaton->ruleInfos.Add(rule, newRuleInfo); - ruleMap.Add(rule->name, rule); - - newRuleInfo->rootRuleStartState=automaton->RootRuleStartState(rule); - newRuleInfo->rootRuleEndState=automaton->RootRuleEndState(rule); - newRuleInfo->startState=automaton->RuleStartState(rule); - - oldNewStateMap.Add(ruleInfo->rootRuleStartState, newRuleInfo->rootRuleStartState); - oldNewStateMap.Add(ruleInfo->rootRuleEndState, newRuleInfo->rootRuleEndState); - oldNewStateMap.Add(ruleInfo->startState, newRuleInfo->startState); - - newRuleInfo->rootRuleStartState->stateExpression=ruleInfo->rootRuleStartState->stateExpression; - newRuleInfo->rootRuleEndState->stateExpression=ruleInfo->rootRuleEndState->stateExpression; - newRuleInfo->startState->stateExpression=ruleInfo->startState->stateExpression; - } - - FOREACH(Ptr, oldState, nondeterministicPDA->states) - { - if((oldState->inputs.Count()>0 || oldState->transitions.Count()>0) && !oldNewStateMap.Keys().Contains(oldState.Obj())) - { - State* newState=automaton->CopyState(oldState.Obj()); - oldNewStateMap.Add(oldState.Obj(), newState); - newState->stateExpression=oldState->stateExpression; - } - } - - // create transitions - FOREACH(ParsingDefinitionRuleDefinition*, rule, nondeterministicPDA->ruleInfos.Keys()) - { - Ptr ruleInfo=nondeterministicPDA->ruleInfos[rule]; - Ptr newRuleInfo=automaton->ruleInfos[rule]; - - // complete new rule info - FOREACH(State*, endState, ruleInfo->endStates) - { - newRuleInfo->endStates.Add(oldNewStateMap[endState]); - } - - // create joint transitions according to old automaton - List scanningStates; - vint currentStateIndex=0; - scanningStates.Add(ruleInfo->rootRuleStartState); - - while(currentStateIndextransitions) - { - State* oldSource=oldTransition->source; - State* oldTarget=oldTransition->target; - State* newSource=oldNewStateMap[oldSource]; - State* newTarget=oldNewStateMap[oldTarget]; - - if(!scanningStates.Contains(oldSource)) scanningStates.Add(oldSource); - if(!scanningStates.Contains(oldTarget)) scanningStates.Add(oldTarget); - - if(oldTransition->transitionType==Transition::Symbol && oldTransition->transitionSymbol->GetType()==ParsingSymbol::RuleDef) - { - // if this is a rule transition, create - // source -> ruleStart - // ruleEnd[] -> target - ParsingDefinitionRuleDefinition* rule=ruleMap[oldTransition->transitionSymbol->GetName()]; - Ptr oldRuleInfo=nondeterministicPDA->ruleInfos[rule]; - - { - Transition* shiftTransition=automaton->Epsilon(newSource, oldNewStateMap[oldRuleInfo->startState]); - Ptr action=new Action; - action->actionType=Action::Shift; - action->shiftReduceSource=newSource; - action->shiftReduceTarget=newTarget; - action->creatorRule=shiftTransition->source->ownerRule; - shiftTransition->actions.Add(action); - } - - FOREACH(State*, oldEndState, oldRuleInfo->endStates) - { - Transition* reduceTransition=automaton->NormalReduce(oldNewStateMap[oldEndState], newTarget); - Ptr action=new Action; - action->actionType=Action::Reduce; - action->shiftReduceSource=newSource; - action->shiftReduceTarget=newTarget; - action->creatorRule=reduceTransition->source->ownerRule; - reduceTransition->actions.Add(action); - CopyFrom(reduceTransition->actions, oldTransition->actions, true); - } - } - else - { - // if not, just copy - Transition* newTransition=automaton->CopyTransition(newSource, newTarget, oldTransition); - CopyFrom(newTransition->actions, oldTransition->actions); - } - } - } - } - return automaton; - } - -/*********************************************************************** -CompactJointPDA -***********************************************************************/ - - // closure function for searching shift-reduce-compact transition - ClosureItem::SearchResult ShiftReduceCompactClosure(Transition* transition) - { - return - transition->stackOperationType!=Transition::None?ClosureItem::Blocked: - transition->transitionType!=Transition::Epsilon?ClosureItem::Hit: - ClosureItem::Continue; - } - - void CompactJointPDA(Ptr jointPDA) - { - FOREACH(Ptr, state, jointPDA->states) - { - State* currentState=state.Obj(); - - // search for epsilon closure - List closure; - SearchClosure(&ShiftReduceCompactClosure, currentState, closure); - - FOREACH(ClosureItem, closureItem, closure) - { - Transition* lastTransition=closureItem.transitions->Get(closureItem.transitions->Count()-1); - Transition::StackOperationType stackOperationType=Transition::None; - Transition::TransitionType transitionType=lastTransition->transitionType; - - if(closureItem.cycle && lastTransition->transitionType==Transition::Epsilon) - { - bool containsShift=false; - bool containsReduce=false; - FOREACH(Transition*, pathTransition, *closureItem.transitions.Obj()) - { - FOREACH(Ptr, action, pathTransition->actions) - { - if(action->actionType==Action::Shift) containsShift=true; - if(action->actionType==Action::Reduce) containsReduce=true; - } - } - if(containsShift && !containsReduce) - { - // a left recursive compacted shift transition is found - // if the left recursive state is not the current state - // that means this transition path fall into other left recursive state - // e.g. - // Term = Factor | Term (here is a left recursion) * Factor - // Exp = Term (this rule symbol transition will fall into Term's left recursive state) ... - // if such a case happened, this transition path will be simply discarded - if(closureItem.state==currentState) - { - stackOperationType=Transition::LeftRecursive; - } - } - else if(!containsShift && containsReduce) - { - // a right recursive compacted reduce transition is found - // if this state will receive $TokenFinish, then the stack pattern number can be infinite - // e.g. for right recursive expression "a b c" == "(a (b c))" - // when trying to do a transition by $TokenFinish - // "a b" should reduce once - // "a b c" should reduce twice - // because that a reduce is not considered a virtual token, so this is not going to be happened - } - } - else if(closureItem.transitions->Count()>1) - { - // in joint PDA, only shift and reduce transitions are epsilon transition - // if there are more than one transition in a path, then there should be shift or reduce transitions in the path - stackOperationType=Transition::ShiftReduceCompacted; - } - - if(stackOperationType!=Transition::None) - { - // build shift-reduce-compacted transition to the target state of the path - Transition* transition=jointPDA->CopyTransition(currentState, lastTransition->target, lastTransition); - transition->transitionType=transitionType; - transition->stackOperationType=stackOperationType; - - // there will be , or - // but there will not be something like - // so we can append stackPattern safely - FOREACH(Transition*, pathTransition, *closureItem.transitions.Obj()) - { - CopyFrom(transition->actions, pathTransition->actions, true); - } - } - } - } - - // delete unnecessary transactions - for(vint i=jointPDA->transitions.Count()-1;i>=0;i--) - { - Transition* transition=jointPDA->transitions[i].Obj(); - if(transition->stackOperationType==Transition::None && transition->transitionType==Transition::Epsilon) - { - jointPDA->DeleteTransition(transition); - } - } - } - -/*********************************************************************** -MarkLeftRecursiveInJointPDA -***********************************************************************/ - - void MarkLeftRecursiveInJointPDA(Ptr jointPDA, collections::List>& errors) - { - vint errorCount=errors.Count(); - // record all left recursive shifts and delete all left recursive epsilon transition - SortedList> leftRecursiveShifts; - FOREACH(Ptr, state, jointPDA->states) - { - for(vint i=state->transitions.Count()-1;i>=0;i--) - { - Transition* transition=state->transitions[i]; - if(transition->stackOperationType==Transition::LeftRecursive) - { - Ptr shiftAction; - FOREACH(Ptr, action, transition->actions) - { - if(action->actionType==Action::Shift) - { - if(shiftAction) - { - errors.Add(new ParsingError(state->ownerRule, L"Indirect left recursive transition in rule \""+state->ownerRule->name+L"\" is not allowed.")); - goto FOUND_INDIRECT_LEFT_RECURSIVE_TRANSITION; - } - else - { - shiftAction=action; - } - } - } - if(shiftAction) - { - leftRecursiveShifts.Add(Pair(shiftAction->shiftReduceSource, shiftAction->shiftReduceTarget)); - } - FOUND_INDIRECT_LEFT_RECURSIVE_TRANSITION: - jointPDA->DeleteTransition(transition); - } - } - } - if(errorCount!=errors.Count()) - { - return; - } - - // change all reduce actions whose (shiftReduceSource, shiftReduceTarget) is recorded in leftRecursiveShifts to left-recursive-reduce - // when a reduce is converted to a left-recursive-reduce, the corresponding state in stackPattern should be removed - // so this will keep count(Reduce) == count(stackPattern) - FOREACH(Ptr, state, jointPDA->states) - { - FOREACH(Transition*, transition, state->transitions) - { - for(vint i=transition->actions.Count()-1;i>=0;i--) - { - Ptr action=transition->actions[i]; - if(action->actionType==Action::Reduce) - { - Pair shift(action->shiftReduceSource, action->shiftReduceTarget); - if(leftRecursiveShifts.Contains(shift)) - { - // check if this is a normal reduce transition, and change it to a left recursive reduce transition. - if (transition->transitionType == Transition::NormalReduce) - { - transition->transitionType = Transition::LeftRecursiveReduce; - // need to create a new action because in the previous phrases, these action object are shared and treated as read only - Ptr newAction=new Action; - newAction->actionType=Action::LeftRecursiveReduce; - newAction->actionSource=action->actionSource; - newAction->actionTarget=action->actionTarget; - newAction->creatorRule=action->creatorRule; - newAction->shiftReduceSource=action->shiftReduceSource; - newAction->shiftReduceTarget=action->shiftReduceTarget; - newAction->creatorRule=shift.key->ownerRule; - transition->actions[i]=newAction; - } - else - { - errors.Add(new ParsingError(state->ownerRule, L"Left recursive reduce action in non-normal-reduce found in rule \""+state->ownerRule->name+L"\" is not allowed.")); - } - } - } - } - } - } - - // delete complicated transitions - FOREACH(Ptr, state, jointPDA->states) - { - while(true) - { - bool deleted=false; - FOREACH(Transition*, t1, state->transitions) - FOREACH(Transition*, t2, state->transitions) - if(t1!=t2) - { - if(Transition::IsEquivalent(t1, t2, true)) - { - jointPDA->DeleteTransition(t2); - deleted=true; - goto TRANSITION_DELETED; - } - } - TRANSITION_DELETED: - if(!deleted) break; - } - } - } - } - } -} - -/*********************************************************************** -PARSING\PARSINGAUTOMATON_MERGESTATES.CPP -***********************************************************************/ - -namespace vl -{ - namespace parsing - { - using namespace collections; - using namespace definitions; - - namespace analyzing - { - -/*********************************************************************** -DeleteUnnecessaryStates -***********************************************************************/ - - void DeleteUnnecessaryStates(Ptr automaton, Ptr ruleInfo, List& newStates) - { - // delete all states that are not reachable to the end state - while(true) - { - // find a non-end state without out transitions - vint deleteCount=0; - for(vint i=newStates.Count()-1;i>=0;i--) - { - State* newState=newStates[i]; - if(newState->transitions.Count()==0) - { - if(newState!=ruleInfo->rootRuleEndState && !newState->endState) - { - automaton->DeleteState(newState); - newStates.RemoveAt(i); - } - } - } - if(deleteCount==0) - { - break; - } - } - } - -/*********************************************************************** -IsMergableCandidate -***********************************************************************/ - - bool IsMergableCandidate(State* state, Ptr ruleInfo) - { - if(state==ruleInfo->rootRuleStartState || state==ruleInfo->rootRuleEndState || state==ruleInfo->startState) - { - return false; - } - return true; - } - -/*********************************************************************** -RearrangeState -***********************************************************************/ - - vint CompareTransitionForRearranging(Transition* t1, Transition* t2) - { - if(t1->transitionTypetransitionType) return -1; - if(t1->transitionType>t2->transitionType) return 1; - if(t1->transitionSymboltransitionSymbol) return -1; - if(t1->transitionSymbol>t2->transitionSymbol) return 1; - return 0; - } - - vint CompareActionForRearranging(Ptr a1, Ptr a2) - { - if(a1->actionTypeactionType) return -1; - if(a1->actionType>a2->actionType) return 1; - if(a1->actionSourceactionSource) return -1; - if(a1->actionSource>a2->actionSource) return 1; - if(a1->actionTargetactionTarget) return -1; - if(a1->actionTarget>a2->actionTarget) return 1; - return 0; - } - - void RearrangeState(State* state, SortedList& stateContentSorted) - { - if(!stateContentSorted.Contains(state)) - { - FOREACH(Transition*, transition, state->transitions) - { - CopyFrom(transition->actions, From(transition->actions).OrderBy(&CompareActionForRearranging)); - } - CopyFrom(state->transitions, From(state->transitions).OrderBy(&CompareTransitionForRearranging)); - stateContentSorted.Add(state); - } - } - -/*********************************************************************** -MoveActionsForMergingState -***********************************************************************/ - - void MoveActionsForMergingState(Transition* transition) - { - // collect all movable actions - List> movableActions; - for(vint i=transition->actions.Count()-1;i>=0;i--) - { - switch(transition->actions[i]->actionType) - { - // Using and Assign actions are not movable - case Action::Using: - case Action::Assign: - break; - default: - movableActions.Add(transition->actions[i]); - transition->actions.RemoveAt(i); - } - } - - // copy all movable actions - FOREACH(Transition*, t, transition->source->inputs) - { - CopyFrom(t->actions, movableActions, true); - } - } - -/*********************************************************************** -IsMergableBecause(Transitions|Input) -***********************************************************************/ - - bool IsMergableBecauseTransitions(State* state1, State* state2) - { - if(state1->transitions.Count()!=state2->transitions.Count()) return false; - if(state1->transitions.Count()==1 && state2->transitions.Count()==1) - { - Transition* t1=state1->transitions[0]; - Transition* t2=state2->transitions[0]; - if(CompareTransitionForRearranging(t1, t2)==0 && !Transition::IsEquivalent(t1, t2, false) && t1->target==t2->target) - { - MoveActionsForMergingState(t1); - MoveActionsForMergingState(t2); - } - } - for(vint i=0;itransitions.Count();i++) - { - Transition* t1=state1->transitions[i]; - Transition* t2=state2->transitions[i]; - if(!Transition::IsEquivalent(t1, t2, false) || t1->target!=t2->target) - { - return false; - } - } - return true; - } - - bool IsMergableBecauseInputs(State* state1, State* state2) - { - if(state1->inputs.Count()!=state2->inputs.Count()) return false; - for(vint i=0;iinputs.Count();i++) - { - Transition* t1=state1->inputs[i]; - Transition* t2=state2->inputs[i]; - if(!Transition::IsEquivalent(t1, t2, false) || t1->source!=t2->source) - { - return false; - } - } - return true; - } - -/*********************************************************************** -MergeState2ToState1Because(Transitions|Input) -***********************************************************************/ - - void MergeState2ToState1BecauseTransitions(Ptr automaton, State* state1, State* state2) - { - // modify state1's expression - state1->stateExpression+=L"\r\n"+state2->stateExpression; - - // retarget state2's input to state1 - for(vint i=state2->inputs.Count()-1;i>=0;i--) - { - Transition* t2=state2->inputs[i]; - bool add=true; - FOREACH(Transition*, t1, state1->inputs) - { - if(Transition::IsEquivalent(t1, t2, false) && t1->source==t2->source) - { - add=false; - break; - } - } - if(add) - { - state1->inputs.Add(t2); - t2->target=state1; - state2->inputs.RemoveAt(i); - } - } - - automaton->DeleteState(state2); - } - - void MergeState2ToState1BecauseInputs(Ptr automaton, State* state1, State* state2) - { - // modify state1's expression - state1->stateExpression+=L"\r\n"+state2->stateExpression; - - // retarget state2's input to state1 - for(vint i=state2->transitions.Count()-1;i>=0;i--) - { - Transition* t2=state2->transitions[i]; - bool add=true; - FOREACH(Transition*, t1, state1->transitions) - { - if(Transition::IsEquivalent(t1, t2, false) && t1->target==t2->target) - { - add=false; - break; - } - } - if(add) - { - state1->transitions.Add(t2); - t2->source=state1; - state2->transitions.RemoveAt(i); - } - } - - automaton->DeleteState(state2); - } - -/*********************************************************************** -MergeStates -***********************************************************************/ - - void MergeStates(Ptr automaton, Ptr ruleInfo, List& newStates) - { - SortedList stateContentSorted; - while(true) - { - for(vint i=0;i CreateNondeterministicPDAFromEpsilonPDA(Ptr epsilonPDA) - { - Ptr automaton=new Automaton(epsilonPDA->symbolManager); - FOREACH(ParsingDefinitionRuleDefinition*, rule, epsilonPDA->ruleInfos.Keys()) - { - // build new rule info - Ptr ruleInfo=epsilonPDA->ruleInfos[rule]; - Ptr newRuleInfo=new RuleInfo; - automaton->ruleInfos.Add(rule, newRuleInfo); - - newRuleInfo->rootRuleStartState=automaton->RootRuleStartState(rule); - newRuleInfo->rootRuleEndState=automaton->RootRuleEndState(rule); - newRuleInfo->startState=automaton->RuleStartState(rule); - - // build state mapping and state visiting tracking - Dictionary oldNewStateMap; - List scanningStates; - vint currentStateIndex=0; - oldNewStateMap.Add(ruleInfo->rootRuleStartState, newRuleInfo->rootRuleStartState); - oldNewStateMap.Add(ruleInfo->rootRuleEndState, newRuleInfo->rootRuleEndState); - oldNewStateMap.Add(ruleInfo->startState, newRuleInfo->startState); - // begin with a root rule state state - scanningStates.Add(ruleInfo->rootRuleStartState); - // remove epsilon transitions - RemoveEpsilonTransitions(oldNewStateMap, scanningStates, automaton); - - List newStates; - CopyFrom(newStates, oldNewStateMap.Values()); - DeleteUnnecessaryStates(automaton, newRuleInfo, newStates); - MergeStates(automaton, newRuleInfo, newStates); - - // there should be at east one and only one transition that is TokenBegin from rootRuleStartState - // update the startState because the startState may be deleted - newRuleInfo->startState=newRuleInfo->rootRuleStartState->transitions[0]->target; - - // record end states - FOREACH(State*, state, newStates) - { - if(state->endState) - { - newRuleInfo->endStates.Add(state); - } - } - } - return automaton; - } - } - } -} - -/*********************************************************************** -PARSING\PARSINGDEFINITIONS.CPP -***********************************************************************/ - -namespace vl -{ - using namespace collections; - - namespace parsing - { - namespace definitions - { - -/*********************************************************************** -ParsingDefinitionType(Visitor) -***********************************************************************/ - - void ParsingDefinitionPrimitiveType::Accept(IVisitor* visitor) - { - visitor->Visit(this); - } - - void ParsingDefinitionTokenType::Accept(IVisitor* visitor) - { - visitor->Visit(this); - } - - void ParsingDefinitionSubType::Accept(IVisitor* visitor) - { - visitor->Visit(this); - } - - void ParsingDefinitionArrayType::Accept(IVisitor* visitor) - { - visitor->Visit(this); - } - -/*********************************************************************** -ParsingDefinitionTypeDefinition(Visitor) -***********************************************************************/ - - void ParsingDefinitionClassMemberDefinition::Accept(IVisitor* visitor) - { - visitor->Visit(this); - } - - void ParsingDefinitionClassDefinition::Accept(IVisitor* visitor) - { - visitor->Visit(this); - } - - void ParsingDefinitionEnumMemberDefinition::Accept(IVisitor* visitor) - { - visitor->Visit(this); - } - - void ParsingDefinitionEnumDefinition::Accept(IVisitor* visitor) - { - visitor->Visit(this); - } - -/*********************************************************************** -ParsingDefinitionGrammar(Visitor) -***********************************************************************/ - - void ParsingDefinitionPrimitiveGrammar::Accept(IVisitor* visitor) - { - visitor->Visit(this); - } - - void ParsingDefinitionTextGrammar::Accept(IVisitor* visitor) - { - visitor->Visit(this); - } - - void ParsingDefinitionSequenceGrammar::Accept(IVisitor* visitor) - { - visitor->Visit(this); - } - - void ParsingDefinitionAlternativeGrammar::Accept(IVisitor* visitor) - { - visitor->Visit(this); - } - - void ParsingDefinitionLoopGrammar::Accept(IVisitor* visitor) - { - visitor->Visit(this); - } - - void ParsingDefinitionOptionalGrammar::Accept(IVisitor* visitor) - { - visitor->Visit(this); - } - - void ParsingDefinitionCreateGrammar::Accept(IVisitor* visitor) - { - visitor->Visit(this); - } - - void ParsingDefinitionAssignGrammar::Accept(IVisitor* visitor) - { - visitor->Visit(this); - } - - void ParsingDefinitionUseGrammar::Accept(IVisitor* visitor) - { - visitor->Visit(this); - } - - void ParsingDefinitionSetterGrammar::Accept(IVisitor* visitor) - { - visitor->Visit(this); - } - -/*********************************************************************** -ParsingDefinitionTypeWriter -***********************************************************************/ - - ParsingDefinitionAttributeWriter::ParsingDefinitionAttributeWriter(const WString& name) - { - attribute=new ParsingDefinitionAttribute; - attribute->name=name; - } - - ParsingDefinitionAttributeWriter::ParsingDefinitionAttributeWriter(const ParsingDefinitionAttributeWriter& attributeWriter) - { - attribute=attributeWriter.attribute; - } - - ParsingDefinitionAttributeWriter& ParsingDefinitionAttributeWriter::Argument(const WString& argument) - { - attribute->arguments.Add(argument); - return *this; - } - - Ptr ParsingDefinitionAttributeWriter::Attribute()const - { - return attribute; - } - - ParsingDefinitionAttributeWriter Attribute(const WString& name) - { - return ParsingDefinitionAttributeWriter(name); - } - -/*********************************************************************** -ParsingDefinitionTypeWriter -***********************************************************************/ - - ParsingDefinitionTypeWriter::ParsingDefinitionTypeWriter(Ptr internalType) - { - type=internalType; - } - - ParsingDefinitionTypeWriter::ParsingDefinitionTypeWriter(const ParsingDefinitionTypeWriter& typeWriter) - { - type=typeWriter.type; - } - - ParsingDefinitionTypeWriter::ParsingDefinitionTypeWriter(const WString& name) - { - Ptr primitiveType=new ParsingDefinitionPrimitiveType; - primitiveType->name=name; - type=primitiveType; - } - - ParsingDefinitionTypeWriter ParsingDefinitionTypeWriter::Sub(const WString& subTypeName)const - { - Ptr subType=new ParsingDefinitionSubType; - subType->parentType=type; - subType->subTypeName=subTypeName; - return ParsingDefinitionTypeWriter(subType); - } - - ParsingDefinitionTypeWriter ParsingDefinitionTypeWriter::Array()const - { - Ptr arrayType=new ParsingDefinitionArrayType; - arrayType->elementType=type; - return ParsingDefinitionTypeWriter(arrayType); - } - - Ptr ParsingDefinitionTypeWriter::Type()const - { - return type; - } - - ParsingDefinitionTypeWriter Type(const WString& name) - { - return ParsingDefinitionTypeWriter(name); - } - - ParsingDefinitionTypeWriter TokenType() - { - Ptr type=new ParsingDefinitionTokenType; - return ParsingDefinitionTypeWriter(type); - } - -/*********************************************************************** -ParsingDefinitionClassDefinitionWriter -***********************************************************************/ - - ParsingDefinitionClassDefinitionWriter::ParsingDefinitionClassDefinitionWriter(const WString& name) - { - definition=new ParsingDefinitionClassDefinition; - definition->name=name; - currentDefinition=definition; - } - - ParsingDefinitionClassDefinitionWriter::ParsingDefinitionClassDefinitionWriter(const WString& name, const ParsingDefinitionTypeWriter& parentType) - { - definition=new ParsingDefinitionClassDefinition; - definition->name=name; - definition->parentType=parentType.Type(); - currentDefinition=definition; - } - - ParsingDefinitionClassDefinitionWriter& ParsingDefinitionClassDefinitionWriter::AmbiguousType(const ParsingDefinitionTypeWriter& ambiguousType) - { - definition->ambiguousType=ambiguousType.Type(); - return *this; - } - - ParsingDefinitionClassDefinitionWriter& ParsingDefinitionClassDefinitionWriter::Member(const WString& name, const ParsingDefinitionTypeWriter& type, const WString& unescapingFunction) - { - Ptr member=new ParsingDefinitionClassMemberDefinition; - member->name=name; - member->type=type.Type(); - member->unescapingFunction=unescapingFunction; - definition->members.Add(member); - currentDefinition=member; - return *this; - } - - ParsingDefinitionClassDefinitionWriter& ParsingDefinitionClassDefinitionWriter::SubType(const ParsingDefinitionTypeDefinitionWriter& type) - { - definition->subTypes.Add(type.Definition()); - return *this; - } - - ParsingDefinitionClassDefinitionWriter& ParsingDefinitionClassDefinitionWriter::Attribute(const ParsingDefinitionAttributeWriter& attribute) - { - currentDefinition->attributes.Add(attribute.Attribute()); - return *this; - } - - Ptr ParsingDefinitionClassDefinitionWriter::Definition()const - { - return definition; - } - - ParsingDefinitionClassDefinitionWriter Class(const WString& name) - { - return ParsingDefinitionClassDefinitionWriter(name); - } - - ParsingDefinitionClassDefinitionWriter Class(const WString& name, const ParsingDefinitionTypeWriter& parentType) - { - return ParsingDefinitionClassDefinitionWriter(name, parentType); - } - -/*********************************************************************** -ParsingDefinitionEnumDefinitionWriter -***********************************************************************/ - - ParsingDefinitionEnumDefinitionWriter::ParsingDefinitionEnumDefinitionWriter(const WString& name) - { - definition=new ParsingDefinitionEnumDefinition; - definition->name=name; - currentDefinition=definition; - } - - ParsingDefinitionEnumDefinitionWriter& ParsingDefinitionEnumDefinitionWriter::Member(const WString& name) - { - Ptr member=new ParsingDefinitionEnumMemberDefinition; - member->name=name; - definition->members.Add(member); - currentDefinition=member; - return *this; - } - - ParsingDefinitionEnumDefinitionWriter& ParsingDefinitionEnumDefinitionWriter::Attribute(const ParsingDefinitionAttributeWriter& attribute) - { - currentDefinition->attributes.Add(attribute.Attribute()); - return *this; - } - - Ptr ParsingDefinitionEnumDefinitionWriter::Definition()const - { - return definition; - } - - ParsingDefinitionEnumDefinitionWriter Enum(const WString& name) - { - return ParsingDefinitionEnumDefinitionWriter(name); - } - -/*********************************************************************** -ParsingDefinitionGrammarWriter -***********************************************************************/ - - ParsingDefinitionGrammarWriter::ParsingDefinitionGrammarWriter(Ptr internalGrammar) - { - grammar=internalGrammar; - } - - ParsingDefinitionGrammarWriter::ParsingDefinitionGrammarWriter(const ParsingDefinitionGrammarWriter& grammarWriter) - { - grammar=grammarWriter.grammar; - } - - ParsingDefinitionGrammarWriter ParsingDefinitionGrammarWriter::operator+(const ParsingDefinitionGrammarWriter& next)const - { - Ptr sequence=new ParsingDefinitionSequenceGrammar; - sequence->first=grammar; - sequence->second=next.Grammar(); - return ParsingDefinitionGrammarWriter(sequence); - } - - ParsingDefinitionGrammarWriter ParsingDefinitionGrammarWriter::operator|(const ParsingDefinitionGrammarWriter& next)const - { - Ptr alternative=new ParsingDefinitionAlternativeGrammar; - alternative->first=grammar; - alternative->second=next.Grammar(); - return ParsingDefinitionGrammarWriter(alternative); - } - - ParsingDefinitionGrammarWriter ParsingDefinitionGrammarWriter::operator*()const - { - Ptr loop=new ParsingDefinitionLoopGrammar; - loop->grammar=grammar; - return ParsingDefinitionGrammarWriter(loop); - } - - ParsingDefinitionGrammarWriter ParsingDefinitionGrammarWriter::As(const ParsingDefinitionTypeWriter& type)const - { - Ptr create=new ParsingDefinitionCreateGrammar; - create->grammar=grammar; - create->type=type.Type(); - return ParsingDefinitionGrammarWriter(create); - } - - ParsingDefinitionGrammarWriter ParsingDefinitionGrammarWriter::operator[](const WString& memberName)const - { - Ptr assign=new ParsingDefinitionAssignGrammar; - assign->grammar=grammar; - assign->memberName=memberName; - return ParsingDefinitionGrammarWriter(assign); - } - - ParsingDefinitionGrammarWriter ParsingDefinitionGrammarWriter::operator!()const - { - Ptr use=new ParsingDefinitionUseGrammar; - use->grammar=grammar; - return ParsingDefinitionGrammarWriter(use); - } - - ParsingDefinitionGrammarWriter ParsingDefinitionGrammarWriter::Set(const WString& memberName, const WString& value)const - { - Ptr setter=new ParsingDefinitionSetterGrammar; - setter->grammar=grammar; - setter->memberName=memberName; - setter->value=value; - return ParsingDefinitionGrammarWriter(setter); - } - - Ptr ParsingDefinitionGrammarWriter::Grammar()const - { - return grammar; - } - - ParsingDefinitionGrammarWriter Rule(const WString& name) - { - Ptr grammar=new ParsingDefinitionPrimitiveGrammar; - grammar->name=name; - return ParsingDefinitionGrammarWriter(grammar); - } - - ParsingDefinitionGrammarWriter Text(const WString& text) - { - Ptr grammar=new ParsingDefinitionTextGrammar; - grammar->text=text; - return ParsingDefinitionGrammarWriter(grammar); - } - - ParsingDefinitionGrammarWriter Opt(const ParsingDefinitionGrammarWriter& writer) - { - Ptr grammar=new ParsingDefinitionOptionalGrammar; - grammar->grammar=writer.Grammar(); - return ParsingDefinitionGrammarWriter(grammar); - } - -/*********************************************************************** -ParsingDefinitionTokenDefinitionWriter -***********************************************************************/ - - ParsingDefinitionTokenDefinitionWriter::ParsingDefinitionTokenDefinitionWriter(ParsingDefinitionWriter& _owner, Ptr _token) - :owner(_owner) - ,token(_token) - { - } - - ParsingDefinitionTokenDefinitionWriter& ParsingDefinitionTokenDefinitionWriter::Attribute(const ParsingDefinitionAttributeWriter& attribute) - { - token->attributes.Add(attribute.Attribute()); - return *this; - } - - ParsingDefinitionWriter& ParsingDefinitionTokenDefinitionWriter::EndToken() - { - return owner; - } - -/*********************************************************************** -ParsingDefinitionRuleDefinitionWriter -***********************************************************************/ - - ParsingDefinitionRuleDefinitionWriter::ParsingDefinitionRuleDefinitionWriter(ParsingDefinitionWriter& _owner, Ptr _rule) - :owner(_owner) - ,rule(_rule) - { - } - - ParsingDefinitionRuleDefinitionWriter& ParsingDefinitionRuleDefinitionWriter::Imply(const ParsingDefinitionGrammarWriter& grammar) - { - rule->grammars.Add(grammar.Grammar()); - return *this; - } - - ParsingDefinitionRuleDefinitionWriter& ParsingDefinitionRuleDefinitionWriter::Attribute(const ParsingDefinitionAttributeWriter& attribute) - { - rule->attributes.Add(attribute.Attribute()); - return *this; - } - - ParsingDefinitionWriter& ParsingDefinitionRuleDefinitionWriter::EndRule() - { - return owner; - } - -/*********************************************************************** -ParsingDefinitionWriter -***********************************************************************/ - - ParsingDefinitionWriter::ParsingDefinitionWriter() - { - definition=new ParsingDefinition; - } - - ParsingDefinitionWriter& ParsingDefinitionWriter::Type(const ParsingDefinitionTypeDefinitionWriter& type) - { - definition->types.Add(type.Definition()); - return *this; - } - - ParsingDefinitionWriter& ParsingDefinitionWriter::Token(const WString& name, const WString& regex) - { - return TokenAtt(name, regex).EndToken(); - } - - ParsingDefinitionTokenDefinitionWriter ParsingDefinitionWriter::TokenAtt(const WString& name, const WString& regex) - { - Ptr token=new ParsingDefinitionTokenDefinition; - token->name=name; - token->regex=regex; - token->discard=false; - definition->tokens.Add(token); - return ParsingDefinitionTokenDefinitionWriter(*this, token); - } - - ParsingDefinitionWriter& ParsingDefinitionWriter::Discard(const WString& name, const WString& regex) - { - Ptr token=new ParsingDefinitionTokenDefinition; - token->name=name; - token->regex=regex; - token->discard=true; - definition->tokens.Add(token); - return *this; - } - - ParsingDefinitionRuleDefinitionWriter ParsingDefinitionWriter::Rule(const WString& name, const ParsingDefinitionTypeWriter& type) - { - Ptr rule=new ParsingDefinitionRuleDefinition; - rule->name=name; - rule->type=type.Type(); - definition->rules.Add(rule); - return ParsingDefinitionRuleDefinitionWriter(*this, rule); - } - - Ptr ParsingDefinitionWriter::Definition()const - { - return definition; - } - } - } -} - -/*********************************************************************** -PARSING\PARSINGDEFINITIONS_CREATEPARSERDEFINITION.CPP -***********************************************************************/ - -namespace vl -{ - namespace parsing - { - namespace definitions - { - using namespace collections; - -/*********************************************************************** -自举 -***********************************************************************/ - - Ptr CreateParserDefinition() - { - ParsingDefinitionWriter definitionWriter; - - definitionWriter - .Type( - Class(L"AttributeDef") - .Member(L"name", TokenType()) - .Attribute(Attribute(L"Semantic").Argument(L"Attribute")) - .Member(L"arguments", TokenType().Array()) - ) - .Type( - Class(L"DefBase") - .Member(L"attributes", Type(L"AttributeDef").Array()) - ) - //------------------------------------- - .Type( - Class(L"TypeObj") - ) - - .Type( - Class(L"PrimitiveTypeObj", Type(L"TypeObj")) - .Member(L"name", TokenType()) - .Attribute(Attribute(L"Semantic").Argument(L"Type")) - ) - - .Type( - Class(L"TokenTypeObj", Type(L"TypeObj")) - ) - - .Type( - Class(L"SubTypeObj", Type(L"TypeObj")) - .Member(L"parentType", Type(L"TypeObj")) - .Member(L"name", TokenType()) - .Attribute(Attribute(L"Semantic").Argument(L"Type")) - ) - - .Type( - Class(L"ArrayTypeObj", Type(L"TypeObj")) - .Member(L"elementType", Type(L"TypeObj")) - ) - //------------------------------------- - .Type( - Class(L"TypeDef", Type(L"DefBase")) - .Member(L"name", TokenType()) - .Attribute(Attribute(L"Color").Argument(L"Type")) - ) - - .Type( - Class(L"ClassMemberDef", Type(L"DefBase")) - .Member(L"type", Type(L"TypeObj")) - .Member(L"name", TokenType()) - .Member(L"unescapingFunction", TokenType()) - ) - - .Type( - Class(L"ClassTypeDef", Type(L"TypeDef")) - .Member(L"ambiguousType", Type(L"TypeObj")) - .Member(L"parentType", Type(L"TypeObj")) - .Member(L"members", Type(L"ClassMemberDef").Array()) - .Member(L"subTypes", Type(L"TypeDef").Array()) - ) - - .Type( - Class(L"EnumMemberDef", Type(L"DefBase")) - .Member(L"name", TokenType()) - ) - - .Type( - Class(L"EnumTypeDef", Type(L"TypeDef")) - .Member(L"members", Type(L"EnumMemberDef").Array()) - ) - //------------------------------------- - .Type( - Class(L"GrammarDef") - ) - - .Type( - Class(L"PrimitiveGrammarDef", Type(L"GrammarDef")) - .Member(L"name", TokenType()) - .Attribute(Attribute(L"Semantic").Argument(L"Token").Argument(L"Rule")) - ) - - .Type( - Class(L"TextGrammarDef", Type(L"GrammarDef")) - .Member(L"text", TokenType()) - .Attribute(Attribute(L"Semantic").Argument(L"Literal")) - ) - - .Type( - Class(L"SequenceGrammarDef", Type(L"GrammarDef")) - .Member(L"first", Type(L"GrammarDef")) - .Member(L"second", Type(L"GrammarDef")) - ) - - .Type( - Class(L"AlternativeGrammarDef", Type(L"GrammarDef")) - .Member(L"first", Type(L"GrammarDef")) - .Member(L"second", Type(L"GrammarDef")) - ) - - .Type( - Class(L"LoopGrammarDef", Type(L"GrammarDef")) - .Member(L"grammar", Type(L"GrammarDef")) - ) - - .Type( - Class(L"OptionalGrammarDef", Type(L"GrammarDef")) - .Member(L"grammar", Type(L"GrammarDef")) - ) - - .Type( - Class(L"CreateGrammarDef", Type(L"GrammarDef")) - .Member(L"grammar", Type(L"GrammarDef")) - .Member(L"type", Type(L"TypeObj")) - ) - - .Type( - Class(L"AssignGrammarDef", Type(L"GrammarDef")) - .Member(L"grammar", Type(L"GrammarDef")) - .Member(L"memberName", TokenType()) - .Attribute(Attribute(L"Semantic").Argument(L"Field")) - ) - - .Type( - Class(L"UseGrammarDef", Type(L"GrammarDef")) - .Member(L"grammar", Type(L"GrammarDef")) - ) - - .Type( - Class(L"SetterGrammarDef", Type(L"GrammarDef")) - .Member(L"grammar", Type(L"GrammarDef")) - .Member(L"memberName", TokenType()) - .Attribute(Attribute(L"Semantic").Argument(L"Field")) - .Member(L"value", TokenType()) - .Attribute(Attribute(L"Semantic").Argument(L"EnumValue")) - ) - //------------------------------------- - .Type( - Class(L"TokenDef", Type(L"DefBase")) - .SubType( - Enum(L"DiscardOption") - .Member(L"DiscardToken") - .Member(L"KeepToken") - ) - .Member(L"name", TokenType()) - .Attribute(Attribute(L"Color").Argument(L"Token")) - .Member(L"regex", TokenType()) - .Member(L"discard", Type(L"DiscardOption")) - ) - - .Type( - Class(L"RuleDef", Type(L"DefBase")) - .Member(L"name", TokenType()) - .Attribute(Attribute(L"Color").Argument(L"Rule")) - .Member(L"type", Type(L"TypeObj")) - .Member(L"grammars", Type(L"GrammarDef").Array()) - ) - - .Type( - Class(L"ParserDef") - .Member(L"definitions", Type(L"DefBase").Array()) - ) - //------------------------------------- - .TokenAtt(L"CLASS", L"class") - .Attribute(Attribute(L"Color").Argument(L"Keyword")) - .Attribute(Attribute(L"Candidate")) - .EndToken() - .TokenAtt(L"AMBIGUOUS", L"ambiguous") - .Attribute(Attribute(L"Color").Argument(L"Keyword")) - .Attribute(Attribute(L"Candidate")) - .EndToken() - .TokenAtt(L"ENUM", L"enum") - .Attribute(Attribute(L"Color").Argument(L"Keyword")) - .Attribute(Attribute(L"Candidate")) - .EndToken() - .TokenAtt(L"TOKEN", L"token") - .Attribute(Attribute(L"Color").Argument(L"Keyword")) - .Attribute(Attribute(L"Candidate")) - .EndToken() - .TokenAtt(L"DISCARDTOKEN", L"discardtoken") - .Attribute(Attribute(L"Color").Argument(L"Keyword")) - .Attribute(Attribute(L"Candidate")) - .EndToken() - .TokenAtt(L"RULE", L"rule") - .Attribute(Attribute(L"Color").Argument(L"Keyword")) - .Attribute(Attribute(L"Candidate")) - .EndToken() - .TokenAtt(L"AS", L"as") - .Attribute(Attribute(L"Color").Argument(L"Keyword")) - .Attribute(Attribute(L"Candidate")) - .EndToken() - .TokenAtt(L"WITH", L"with") - .Attribute(Attribute(L"Color").Argument(L"Keyword")) - .Attribute(Attribute(L"Candidate")) - .EndToken() - - .Token(L"OPEN", L"/{") - .Token(L"CLOSE", L"/}") - .Token(L"SEMICOLON", L";") - .Token(L"COLON", L":") - .Token(L"COMMA", L",") - .Token(L"DOT", L".") - .Token(L"ASSIGN", L"/=") - .Token(L"USING", L"/!") - .Token(L"OR", L"/|") - .Token(L"OPTOPEN", L"/[") - .Token(L"OPTCLOSE", L"/]") - .Token(L"PREOPEN", L"/(") - .Token(L"PRECLOSE", L"/)") - .TokenAtt(L"ATT", L"@") - .Attribute(Attribute(L"Color").Argument(L"Attribute")) - .EndToken() - - .TokenAtt(L"NAME", L"[a-zA-Z_]/w*") - .Attribute(Attribute(L"Color").Argument(L"Default")) - .Attribute(Attribute(L"ContextColor")) - .Attribute(Attribute(L"AutoComplete")) - .EndToken() - .TokenAtt(L"STRING", L"\"([^\"]|\"\")*\"") - .Attribute(Attribute(L"Color").Argument(L"String")) - .Attribute(Attribute(L"AutoComplete")) - .EndToken() - .Discard(L"SPACE", L"/s+") - .Discard(L"COMMENT", L"////[^\\r\\n]*") - //------------------------------------- - .Rule(L"Attribute", Type(L"AttributeDef")) - .Imply( - (Text(L"@") + Rule(L"NAME")[L"name"] + Text(L"(") + Opt(Rule(L"STRING")[L"arguments"] + *(Text(L",") + Rule(L"STRING")[L"arguments"])) + Text(L")")) - .As(Type(L"AttributeDef")) - ) - .EndRule() - //------------------------------------- - .Rule(L"Type", Type(L"TypeObj")) - .Imply( - (Rule(L"NAME")[L"name"]) - .As(Type(L"PrimitiveTypeObj")) - ) - .Imply( - Text(L"token") - .As(Type(L"TokenTypeObj")) - ) - .Imply( - (Rule(L"Type")[L"parentType"] + Text(L".") + Rule(L"NAME")[L"name"]) - .As(Type(L"SubTypeObj")) - ) - .Imply( - (Rule(L"Type")[L"elementType"] + Text(L"[") + Text(L"]")) - .As(Type(L"ArrayTypeObj")) - ) - .EndRule() - //------------------------------------- - .Rule(L"EnumMember", Type(L"EnumMemberDef")) - .Imply( - ( - Rule(L"NAME")[L"name"] - + Opt(Rule(L"Attribute")[L"attributes"] + *(Text(L",") + Rule(L"Attribute")[L"attributes"])) - + Text(L",") - ) - .As(Type(L"EnumMemberDef")) - ) - .EndRule() - .Rule(L"Enum", Type(L"EnumTypeDef")) - .Imply( - ( - Text(L"enum") + Rule(L"NAME")[L"name"] - + Opt(Rule(L"Attribute")[L"attributes"] + *(Text(L",") + Rule(L"Attribute")[L"attributes"])) - + Text(L"{") - + *(Rule(L"EnumMember")[L"members"]) - + Text(L"}") - ) - .As(Type(L"EnumTypeDef")) - ) - .EndRule() - .Rule(L"ClassMember", Type(L"ClassMemberDef")) - .Imply( - ( - Rule(L"Type")[L"type"] + Rule(L"NAME")[L"name"] - + Opt(Text(L"(") + Rule(L"NAME")[L"unescapingFunction"] + Text(L")")) - + Opt(Rule(L"Attribute")[L"attributes"] + *(Text(L",") + Rule(L"Attribute")[L"attributes"])) - + Text(L";") - ) - .As(Type(L"ClassMemberDef")) - ) - .EndRule() - .Rule(L"Class", Type(L"ClassTypeDef")) - .Imply( - ( - Text(L"class") + Rule(L"NAME")[L"name"] - + Opt(Text(L"ambiguous") + Text(L"(") + Rule(L"Type")[L"ambiguousType"] + Text(L")")) - + Opt(Text(L":") + Rule(L"Type")[L"parentType"]) - + Opt(Rule(L"Attribute")[L"attributes"] + *(Text(L",") + Rule(L"Attribute")[L"attributes"])) - + Text(L"{") - + *(Rule(L"ClassMember")[L"members"] | Rule(L"TypeDecl")[L"subTypes"]) - + Text(L"}") - ) - .As(Type(L"ClassTypeDef")) - ) - .EndRule() - .Rule(L"TypeDecl", Type(L"TypeDef")) - .Imply(!Rule(L"Enum") | !Rule(L"Class")) - .EndRule() - //------------------------------------ - .Rule(L"PrimitiveGrammar", Type(L"GrammarDef")) - .Imply( - (Rule(L"NAME")[L"name"]) - .As(Type(L"PrimitiveGrammarDef")) - ) - .Imply( - (Rule(L"STRING")[L"text"]) - .As(Type(L"TextGrammarDef")) - ) - .Imply( - (Rule(L"PrimitiveGrammar")[L"grammar"] + Text(L":") + Rule(L"NAME")[L"memberName"]) - .As(Type(L"AssignGrammarDef")) - ) - .Imply( - (Text(L"!") + Rule(L"PrimitiveGrammar")[L"grammar"]) - .As(Type(L"UseGrammarDef")) - ) - .Imply( - (Text(L"[") + Rule(L"Grammar")[L"grammar"] + Text(L"]")) - .As(Type(L"OptionalGrammarDef")) - ) - .Imply( - (Text(L"{") + Rule(L"Grammar")[L"grammar"] + Text(L"}")) - .As(Type(L"LoopGrammarDef")) - ) - .Imply( - (Text(L"(") + !Rule(L"Grammar") + Text(L")")) - ) - .EndRule() - - .Rule(L"SequenceGrammar", Type(L"GrammarDef")) - .Imply( - !Rule(L"PrimitiveGrammar") - ) - .Imply( - (Rule(L"SequenceGrammar")[L"first"] + Rule(L"PrimitiveGrammar")[L"second"]) - .As(Type(L"SequenceGrammarDef")) - ) - .EndRule() - - .Rule(L"AlternativeGrammar", Type(L"GrammarDef")) - .Imply( - !Rule(L"SequenceGrammar") - ) - .Imply( - (Rule(L"AlternativeGrammar")[L"first"] + Text(L"|") + Rule(L"SequenceGrammar")[L"second"]) - .As(Type(L"AlternativeGrammarDef")) - ) - .EndRule() - - .Rule(L"Grammar", Type(L"GrammarDef")) - .Imply( - !Rule(L"AlternativeGrammar") - ) - .Imply( - (Rule(L"Grammar")[L"grammar"] + Text(L"as") + Rule(L"Type")[L"type"]) - .As(Type(L"CreateGrammarDef")) - ) - .Imply( - (Rule(L"Grammar")[L"grammar"] + Text(L"with") + Text(L"{") + Rule(L"NAME")[L"memberName"] + Text(L"=") + Rule(L"STRING")[L"value"] + Text(L"}")) - .As(Type(L"SetterGrammarDef")) - ) - .EndRule() - //------------------------------------ - .Rule(L"TokenDecl", Type(L"TokenDef")) - .Imply( - ( - Text(L"token") + Rule(L"NAME")[L"name"] - + Text(L"=") + Rule(L"STRING")[L"regex"] - + Opt(Rule(L"Attribute")[L"attributes"] + *(Text(L",") + Rule(L"Attribute")[L"attributes"])) - + Text(L";") - ) - .As(Type(L"TokenDef")) - .Set(L"discard", L"KeepToken") - ) - .Imply( - (Text(L"discardtoken") + Rule(L"NAME")[L"name"] + Text(L"=") + Rule(L"STRING")[L"regex"] + Text(L";")) - .As(Type(L"TokenDef")) - .Set(L"discard", L"DiscardToken") - ) - .EndRule() - - .Rule(L"RuleDecl", Type(L"RuleDef")) - .Imply( - ( - Text(L"rule") + Rule(L"Type")[L"type"] + Rule(L"NAME")[L"name"] - + Opt(Rule(L"Attribute")[L"attributes"] + *(Text(L",") + Rule(L"Attribute")[L"attributes"])) - + *(Text(L"=") + Rule(L"Grammar")[L"grammars"]) - + Text(L";") - ) - .As(Type(L"RuleDef")) - ) - .EndRule() - //------------------------------------ - .Rule(L"ParserDecl", Type(L"ParserDef")) - .Imply( - ( - *( - Rule(L"TypeDecl")[L"definitions"] | - Rule(L"TokenDecl")[L"definitions"] | - Rule(L"RuleDecl")[L"definitions"] - ) - +( - Rule(L"TypeDecl")[L"definitions"] | - Rule(L"TokenDecl")[L"definitions"] | - Rule(L"RuleDecl")[L"definitions"] - ) - ) - .As(Type(L"ParserDef")) - ) - .EndRule() - ; - - return definitionWriter.Definition(); - } - - WString DeserializeString(const WString& value) - { - if(value.Length()>=2 && value[0]==L'"' && value[value.Length()-1]==L'"') - { - Array chars(value.Length()); - memset(&chars[0], 0, chars.Count()*sizeof(wchar_t)); - const wchar_t* reading=value.Buffer()+1; - wchar_t* writing=&chars[0]; - while(*reading) - { - if(*reading!=L'"') - { - *writing++=*reading++; - } - else if(reading[1]!=L'"') - { - break; - } - else - { - *writing++=L'"'; - reading+=2; - } - } - return &chars[0]; - } - return L""; - } - - WString DeserializeString(Ptr token) - { - const WString& value=token->GetValue(); - return DeserializeString(value); - } - - void SetName(WString& target, Ptr node) - { - Ptr token=node.Cast(); - if(token) - { - target=token->GetValue(); - } - } - - void SetText(WString& target, Ptr node) - { - Ptr token=node.Cast(); - if(token) - { - target=DeserializeString(token); - } - } - - extern Ptr Deserialize(Ptr node); - - template - void SetArray(List>& target, Ptr node) - { - Ptr source=node.Cast(); - if(source) - { - for(vint i=0;iCount();i++) - { - target.Add(Deserialize(source->GetItem(i).Cast()).Cast()); - } - } - } - - void SetArray(List& target, Ptr node) - { - Ptr source=node.Cast(); - if(source) - { - for(vint i=0;iCount();i++) - { - WString name; - SetName(name, source->GetItem(i)); - target.Add(name); - } - } - } - - template - void SetMember(Ptr& target, Ptr node) - { - Ptr source=node.Cast(); - if(source) - { - target=Deserialize(source).Cast(); - } - } - - Ptr Deserialize(Ptr node) - { - if(!node) - { - return 0; - } - else if(node->GetType()==L"AttributeDef") - { - Ptr target=new ParsingDefinitionAttribute; - SetName(target->name, node->GetMember(L"name")); - SetArray(target->arguments, node->GetMember(L"arguments")); - for(vint i=0;iarguments.Count();i++) - { - target->arguments[i]=DeserializeString(target->arguments[i]); - } - return target; - } - else if(node->GetType()==L"PrimitiveTypeObj") - { - Ptr target=new ParsingDefinitionPrimitiveType; - SetName(target->name, node->GetMember(L"name")); - return target; - } - else if(node->GetType()==L"TokenTypeObj") - { - Ptr target=new ParsingDefinitionTokenType; - return target; - } - else if(node->GetType()==L"SubTypeObj") - { - Ptr target=new ParsingDefinitionSubType; - SetMember(target->parentType, node->GetMember(L"parentType")); - SetName(target->subTypeName, node->GetMember(L"name")); - return target; - } - else if(node->GetType()==L"ArrayTypeObj") - { - Ptr target=new ParsingDefinitionArrayType; - SetMember(target->elementType, node->GetMember(L"elementType")); - return target; - } - else if(node->GetType()==L"ClassMemberDef") - { - Ptr target=new ParsingDefinitionClassMemberDefinition; - SetArray(target->attributes, node->GetMember(L"attributes")); - SetMember(target->type, node->GetMember(L"type")); - SetName(target->name, node->GetMember(L"name")); - SetName(target->unescapingFunction, node->GetMember(L"unescapingFunction")); - return target; - } - else if(node->GetType()==L"ClassTypeDef") - { - Ptr target=new ParsingDefinitionClassDefinition; - SetArray(target->attributes, node->GetMember(L"attributes")); - SetMember(target->ambiguousType, node->GetMember(L"ambiguousType")); - SetMember(target->parentType, node->GetMember(L"parentType")); - SetName(target->name, node->GetMember(L"name")); - SetArray(target->members, node->GetMember(L"members")); - SetArray(target->subTypes, node->GetMember(L"subTypes")); - return target; - } - else if(node->GetType()==L"EnumMemberDef") - { - Ptr target=new ParsingDefinitionEnumMemberDefinition; - SetArray(target->attributes, node->GetMember(L"attributes")); - SetName(target->name, node->GetMember(L"name")); - return target; - } - else if(node->GetType()==L"EnumTypeDef") - { - Ptr target=new ParsingDefinitionEnumDefinition; - SetArray(target->attributes, node->GetMember(L"attributes")); - SetName(target->name, node->GetMember(L"name")); - SetArray(target->members, node->GetMember(L"members")); - return target; - } - else if(node->GetType()==L"PrimitiveGrammarDef") - { - Ptr target=new ParsingDefinitionPrimitiveGrammar; - SetName(target->name, node->GetMember(L"name")); - return target; - } - else if(node->GetType()==L"TextGrammarDef") - { - Ptr target=new ParsingDefinitionTextGrammar; - SetText(target->text, node->GetMember(L"text")); - return target; - } - else if(node->GetType()==L"SequenceGrammarDef") - { - Ptr target=new ParsingDefinitionSequenceGrammar; - SetMember(target->first, node->GetMember(L"first")); - SetMember(target->second, node->GetMember(L"second")); - return target; - } - else if(node->GetType()==L"AlternativeGrammarDef") - { - Ptr target=new ParsingDefinitionAlternativeGrammar; - SetMember(target->first, node->GetMember(L"first")); - SetMember(target->second, node->GetMember(L"second")); - return target; - } - else if(node->GetType()==L"LoopGrammarDef") - { - Ptr target=new ParsingDefinitionLoopGrammar; - SetMember(target->grammar, node->GetMember(L"grammar")); - return target; - } - else if(node->GetType()==L"OptionalGrammarDef") - { - Ptr target=new ParsingDefinitionOptionalGrammar; - SetMember(target->grammar, node->GetMember(L"grammar")); - return target; - } - else if(node->GetType()==L"CreateGrammarDef") - { - Ptr target=new ParsingDefinitionCreateGrammar; - SetMember(target->grammar, node->GetMember(L"grammar")); - SetMember(target->type, node->GetMember(L"type")); - return target; - } - else if(node->GetType()==L"AssignGrammarDef") - { - Ptr target=new ParsingDefinitionAssignGrammar; - SetMember(target->grammar, node->GetMember(L"grammar")); - SetName(target->memberName, node->GetMember(L"memberName")); - return target; - } - else if(node->GetType()==L"UseGrammarDef") - { - Ptr target=new ParsingDefinitionUseGrammar; - SetMember(target->grammar, node->GetMember(L"grammar")); - return target; - } - else if(node->GetType()==L"SetterGrammarDef") - { - Ptr target=new ParsingDefinitionSetterGrammar; - SetMember(target->grammar, node->GetMember(L"grammar")); - SetName(target->memberName, node->GetMember(L"memberName")); - SetText(target->value, node->GetMember(L"value")); - return target; - } - else if(node->GetType()==L"TokenDef") - { - Ptr target=new ParsingDefinitionTokenDefinition; - SetArray(target->attributes, node->GetMember(L"attributes")); - SetName(target->name, node->GetMember(L"name")); - SetText(target->regex, node->GetMember(L"regex")); - - Ptr token=node->GetMember(L"discard").Cast(); - target->discard=(token && token->GetValue()==L"DiscardToken"); - return target; - } - else if(node->GetType()==L"RuleDef") - { - Ptr target=new ParsingDefinitionRuleDefinition; - SetArray(target->attributes, node->GetMember(L"attributes")); - SetName(target->name, node->GetMember(L"name")); - SetMember(target->type, node->GetMember(L"type")); - SetArray(target->grammars, node->GetMember(L"grammars")); - return target; - } - else if(node->GetType()==L"ParserDef") - { - Ptr target=new ParsingDefinition; - Ptr defs=node->GetMember(L"definitions").Cast(); - if(defs) - { - vint count=defs->Count(); - for(vint i=0;i def=defs->GetItem(i).Cast(); - Ptr defObject=Deserialize(def); - if(Ptr defType=defObject.Cast()) - { - target->types.Add(defType); - } - else if(Ptr defToken=defObject.Cast()) - { - target->tokens.Add(defToken); - } - else if(Ptr defRule=defObject.Cast()) - { - target->rules.Add(defRule); - } - } - } - return target; - } - else - { - return 0; - } - } - - Ptr DeserializeDefinition(Ptr node) - { - return Deserialize(node.Cast()).Cast(); - } - } - } -} - -/*********************************************************************** -PARSING\PARSINGLOGGING.CPP +.\PARSING\PARSINGLOGGING.CPP ***********************************************************************/ namespace vl @@ -11384,9668 +19121,7 @@ Logger (ParsingTreeNode) } /*********************************************************************** -PARSING\PARSINGSTATE.CPP -***********************************************************************/ - -namespace vl -{ - namespace parsing - { - namespace tabling - { - using namespace collections; - using namespace regex; - -/*********************************************************************** -ParsingTokenWalker::LookAheadEnumerator -***********************************************************************/ - - ParsingTokenWalker::LookAheadEnumerator::LookAheadEnumerator(const ParsingTokenWalker* _walker, vint _currentToken) - :walker(_walker) - ,firstToken(_currentToken) - ,currentToken(_currentToken) - ,currentValue(-1) - ,index(-1) - { - } - - ParsingTokenWalker::LookAheadEnumerator::LookAheadEnumerator(const LookAheadEnumerator& _enumerator) - :walker(_enumerator.walker) - ,firstToken(_enumerator.firstToken) - ,currentToken(_enumerator.currentToken) - ,currentValue(_enumerator.currentValue) - ,index(_enumerator.index) - { - } - - IEnumerator* ParsingTokenWalker::LookAheadEnumerator::Clone()const - { - return new LookAheadEnumerator(*this); - } - - const vint& ParsingTokenWalker::LookAheadEnumerator::Current()const - { - return currentValue; - } - - vint ParsingTokenWalker::LookAheadEnumerator::Index()const - { - return index; - } - - bool ParsingTokenWalker::LookAheadEnumerator::Next() - { - vint newToken=walker->GetNextIndex(currentToken); - if(newToken==-3) return false; - currentToken=newToken; - index++; - currentValue=walker->GetTableTokenIndex(currentToken); - return true; - } - - void ParsingTokenWalker::LookAheadEnumerator::Reset() - { - currentToken=firstToken; - currentValue=-1; - index=-1; - } - -/*********************************************************************** -ParsingTokenWalker::TokenLookAhead -***********************************************************************/ - - ParsingTokenWalker::TokenLookAhead::TokenLookAhead(const ParsingTokenWalker* _walker) - :walker(_walker) - { - } - - collections::IEnumerator* ParsingTokenWalker::TokenLookAhead::CreateEnumerator()const - { - return new LookAheadEnumerator(walker, walker->currentToken); - } - -/*********************************************************************** -ParsingTokenWalker::ReduceLookAhead -***********************************************************************/ - - ParsingTokenWalker::ReduceLookAhead::ReduceLookAhead(const ParsingTokenWalker* _walker) - :walker(_walker) - { - } - - collections::IEnumerator* ParsingTokenWalker::ReduceLookAhead::CreateEnumerator()const - { - return new LookAheadEnumerator(walker, walker->currentToken - 1); - } - -/*********************************************************************** -ParsingTokenWalker -***********************************************************************/ - - vint ParsingTokenWalker::GetNextIndex(vint index)const - { - if(index==-2) - { - return -1; - } - else if(-1<=index && indexIsInputToken(tokens[index].token)) - { - break; - } - else - { - index++; - } - } - return index; - } - else - { - return -3; - } - } - - vint ParsingTokenWalker::GetTableTokenIndex(vint index)const - { - if(index==-1) - { - return ParsingTable::TokenBegin; - } - else if(index==tokens.Count()) - { - return ParsingTable::TokenFinish; - } - else if(0<=index && indexGetTableTokenIndex(tokens[index].token); - } - else - { - return -1; - } - } - - ParsingTokenWalker::ParsingTokenWalker(collections::List& _tokens, Ptr _table) - :tokens(_tokens) - ,table(_table) - ,currentToken(-2) - , tokenLookAhead(this) - , reduceLookAhead(this) - { - } - - ParsingTokenWalker::~ParsingTokenWalker() - { - } - - const collections::IEnumerable& ParsingTokenWalker::GetTokenLookahead()const - { - return tokenLookAhead; - } - - const collections::IEnumerable& ParsingTokenWalker::GetReduceLookahead()const - { - return reduceLookAhead; - } - - void ParsingTokenWalker::Reset() - { - currentToken=-2; - } - - bool ParsingTokenWalker::Move() - { - currentToken=GetNextIndex(currentToken); - return currentToken!=-3; - } - - vint ParsingTokenWalker::GetTableTokenIndex()const - { - return GetTableTokenIndex(currentToken); - } - - regex::RegexToken* ParsingTokenWalker::GetRegexToken()const - { - vint index=GetTokenIndexInStream(); - return index==-1?0:&tokens[index]; - } - - vint ParsingTokenWalker::GetTokenIndexInStream()const - { - if(0<=currentToken && currentToken _table, vint codeIndex) - :input(_input.Buffer()) - ,table(_table) - ,parsingRuleStartState(-1) - { - CopyFrom(tokens, table->GetLexer().Parse(input, codeIndex)); - walker=new ParsingTokenWalker(tokens, table); - } - - ParsingState::~ParsingState() - { - } - - const WString& ParsingState::GetInput() - { - return input; - } - - Ptr ParsingState::GetTable() - { - return table; - } - - const collections::List& ParsingState::GetTokens() - { - return tokens; - } - - regex::RegexToken* ParsingState::GetToken(vint index) - { - if(index<=0) - { - index=0; - } - else if(index>tokens.Count()) - { - index=tokens.Count(); - } - - return index==tokens.Count()?0:&tokens[index]; - } - - vint ParsingState::Reset(const WString& rule) - { - const ParsingTable::RuleInfo& info=table->GetRuleInfo(rule); - auto infoExists = &info; - if(infoExists) - { - walker->Reset(); - walker->Move(); - stateGroup=new StateGroup(info); - parsingRule=rule; - parsingRuleStartState=info.rootStartState; - return stateGroup->currentState; - } - return -1; - } - - WString ParsingState::GetParsingRule() - { - return parsingRule; - } - - vint ParsingState::GetParsingRuleStartState() - { - return parsingRuleStartState; - } - - vint ParsingState::GetCurrentToken() - { - return walker->GetTableTokenIndex()==ParsingTable::TokenFinish - ?tokens.Count() - :walker->GetTokenIndexInStream(); - } - - vint ParsingState::GetCurrentTableTokenIndex() - { - return walker->GetTableTokenIndex(); - } - - const collections::List& ParsingState::GetStateStack() - { - return stateGroup->stateStack; - } - - vint ParsingState::GetCurrentState() - { - return stateGroup->currentState; - } - - void ParsingState::SkipCurrentToken() - { - walker->Move(); - } - - bool ParsingState::TestTransitionItemInFuture(vint tableTokenIndex, Future* future, ParsingTable::TransitionItem* item, const collections::IEnumerable* lookAheadTokens) - { - bool passLookAheadTest=true; - if(item->lookAheads.Count()>0 && lookAheadTokens) - { - passLookAheadTest=false; - FOREACH(Ptr, info, item->lookAheads) - { - vint index=0; - FOREACH(vint, token, *lookAheadTokens) - { - if(info->tokens[index]!=token) - { - break; - } - index++; - if(index>=info->tokens.Count()) - { - break; - } - } - if(index==info->tokens.Count()) - { - passLookAheadTest=true; - break; - } - } - } - if(!passLookAheadTest) - { - return false; - } - - vint availableStackDepth=stateGroup->stateStack.Count()-future->reduceStateCount; - vint totalStackDepth=stateGroup->stateStack.Count()-future->reduceStateCount+future->shiftStates.Count(); - if(item->stackPattern.Count()<=totalStackDepth) - { - if(tableTokenIndex!=ParsingTable::TokenFinish || item->stackPattern.Count()==totalStackDepth) - { - bool match=true; - for(vint j=0;jstackPattern.Count();j++) - { - vint state= - jshiftStates.Count() - ?future->shiftStates[future->shiftStates.Count()-1-j] - :stateGroup->stateStack[availableStackDepth-1-(j-future->shiftStates.Count())] - ; - if(item->stackPattern[j]!=state) - { - match=false; - } - } - if(match) - { - return true; - } - } - } - return false; - } - - ParsingTable::TransitionItem* ParsingState::MatchTokenInFuture(vint tableTokenIndex, Future* future, const collections::IEnumerable* lookAheadTokens) - { - ParsingTable::TransitionBag* bag=table->GetTransitionBag(future->currentState, tableTokenIndex).Obj(); - if(bag) - { - for(vint i=0;itransitionItems.Count();i++) - { - ParsingTable::TransitionItem* item=bag->transitionItems[i].Obj(); - if(TestTransitionItemInFuture(tableTokenIndex, future, item, lookAheadTokens)) - { - return item; - } - } - } - return 0; - } - - ParsingTable::TransitionItem* ParsingState::MatchToken(vint tableTokenIndex, const collections::IEnumerable* lookAheadTokens) - { - Future future; - future.currentState=stateGroup->currentState; - return MatchTokenInFuture(tableTokenIndex, &future, lookAheadTokens); - } - - void ParsingState::RunTransitionInFuture(ParsingTable::TransitionItem* transition, Future* previous, Future* now) - { - if(previous) - { - now->reduceStateCount=previous->reduceStateCount; - CopyFrom(now->shiftStates, previous->shiftStates); - } - else - { - now->reduceStateCount=0; - now->shiftStates.Clear(); - } - now->currentState=transition->targetState; - now->selectedToken=transition->token; - now->selectedItem=transition; - now->previous=previous; - now->next=0; - - for(vint j=0;jinstructions.Count();j++) - { - ParsingTable::Instruction& ins=transition->instructions[j]; - switch(ins.instructionType) - { - case ParsingTable::Instruction::Shift: - { - now->shiftStates.Add(ins.stateParameter); - } - break; - case ParsingTable::Instruction::Reduce: - { - if(now->shiftStates.Count()==0) - { - now->reduceStateCount++; - } - else - { - now->shiftStates.RemoveAt(now->shiftStates.Count()-1); - } - } - break; - default:; - } - } - } - - ParsingState::TransitionResult ParsingState::RunTransition(ParsingTable::TransitionItem* transition, regex::RegexToken* regexToken, vint instructionBegin, vint instructionCount, bool lastPart) - { - if(regexToken) - { - if(!stateGroup->shiftToken) - { - stateGroup->shiftToken=regexToken; - stateGroup->reduceToken=regexToken; - } - } - if(transition->token>=ParsingTable::UserTokenStart) - { - if(stateGroup->tokenSequenceIndex==0) - { - stateGroup->shiftTokenStack.Add(stateGroup->shiftToken); - } - stateGroup->tokenSequenceIndex++; - } - - TransitionResult result; - result.tableTokenIndex=transition->token; - result.token=regexToken; - result.tokenIndexInStream=regexToken?walker->GetTokenIndexInStream():-1; - result.tableStateSource=stateGroup->currentState; - result.tableStateTarget=transition->targetState; - result.transition=transition; - result.instructionBegin=instructionBegin; - result.instructionCount=instructionCount; - - for(vint j=instructionBegin;jinstructions[j]; - switch(ins.instructionType) - { - case ParsingTable::Instruction::Shift: - { - stateGroup->stateStack.Add(ins.stateParameter); - - stateGroup->shiftTokenStack.Add(stateGroup->shiftToken); - stateGroup->shiftToken=regexToken; - stateGroup->reduceToken=regexToken; - } - break; - case ParsingTable::Instruction::Reduce: - { - stateGroup->stateStack.RemoveAt(stateGroup->stateStack.Count()-1); - - result.AddShiftReduceRange(stateGroup->shiftToken, stateGroup->reduceToken); - stateGroup->shiftToken=stateGroup->shiftTokenStack[stateGroup->shiftTokenStack.Count()-1]; - stateGroup->shiftTokenStack.RemoveAt(stateGroup->shiftTokenStack.Count()-1); - } - break; - case ParsingTable::Instruction::LeftRecursiveReduce: - { - result.AddShiftReduceRange(stateGroup->shiftToken, stateGroup->reduceToken); - if(regexToken) - { - stateGroup->reduceToken=regexToken; - } - } - break; - default:; - } - } - - if(regexToken) - { - stateGroup->reduceToken=regexToken; - } - - if(transition->token==ParsingTable::TokenFinish && lastPart) - { - stateGroup->shiftToken=stateGroup->shiftTokenStack[stateGroup->shiftTokenStack.Count()-1]; - stateGroup->shiftTokenStack.RemoveAt(stateGroup->shiftTokenStack.Count()-1); - result.AddShiftReduceRange(stateGroup->shiftToken, stateGroup->reduceToken); - } - - stateGroup->currentState=transition->targetState; - return result; - } - - ParsingState::TransitionResult ParsingState::RunTransition(ParsingTable::TransitionItem* transition, regex::RegexToken* regexToken) - { - return RunTransition(transition, regexToken, 0, transition->instructions.Count(), true); - } - - bool ParsingState::ReadTokenInFuture(vint tableTokenIndex, Future* previous, Future* now, const collections::IEnumerable* lookAheadTokens) - { - ParsingTable::TransitionItem* selectedItem=0; - if(previous) - { - selectedItem=MatchTokenInFuture(tableTokenIndex, previous, lookAheadTokens); - } - else - { - selectedItem=MatchToken(tableTokenIndex, lookAheadTokens); - } - - if(!selectedItem) - { - return false; - } - RunTransitionInFuture(selectedItem, previous, now); - return true; - } - - ParsingState::TransitionResult ParsingState::ReadToken(vint tableTokenIndex, regex::RegexToken* regexToken, const collections::IEnumerable* lookAheadTokens) - { - ParsingTable::TransitionItem* item=MatchToken(tableTokenIndex, lookAheadTokens); - if(item) - { - return RunTransition(item, regexToken); - } - return TransitionResult(); - } - - ParsingState::TransitionResult ParsingState::ReadToken() - { - if(walker->GetTableTokenIndex()==-1) - { - return TransitionResult(); - } - vint token=walker->GetTableTokenIndex(); - RegexToken* regexToken=walker->GetRegexToken(); - - bool tryReduce=false; - TransitionResult result=ReadToken(token, regexToken, &walker->GetTokenLookahead()); - if(!result) - { - result=ReadToken(ParsingTable::LeftRecursiveReduce, 0, &walker->GetReduceLookahead()); - tryReduce=true; - } - if(!result) - { - result=ReadToken(ParsingTable::NormalReduce, 0, &walker->GetReduceLookahead()); - tryReduce=true; - } - - if(result && !tryReduce) - { - walker->Move(); - } - return result; - } - - bool ParsingState::TestExplore(vint tableTokenIndex, Future* previous) - { - Future fakePrevious; - fakePrevious.currentState=stateGroup->currentState; - Future* realPrevious=previous?previous:&fakePrevious; - - ParsingTable::TransitionBag* bag=table->GetTransitionBag(realPrevious->currentState, tableTokenIndex).Obj(); - if(bag) - { - for(vint i=0;itransitionItems.Count();i++) - { - ParsingTable::TransitionItem* item=bag->transitionItems[i].Obj(); - if(TestTransitionItemInFuture(tableTokenIndex, realPrevious, item, 0)) - { - return true; - } - } - } - return false; - } - - bool ParsingState::Explore(vint tableTokenIndex, Future* previous, collections::List& possibilities) - { - Future fakePrevious; - fakePrevious.currentState=stateGroup->currentState; - Future* realPrevious=previous?previous:&fakePrevious; - - ParsingTable::TransitionBag* bag=table->GetTransitionBag(realPrevious->currentState, tableTokenIndex).Obj(); - bool successful = false; - if(bag) - { - for(vint i=0;itransitionItems.Count();i++) - { - ParsingTable::TransitionItem* item=bag->transitionItems[i].Obj(); - if(TestTransitionItemInFuture(tableTokenIndex, realPrevious, item, 0)) - { - Future* now=new Future; - RunTransitionInFuture(item, previous, now); - possibilities.Add(now); - successful = true; - } - } - } - return successful; - } - - bool ParsingState::ExploreStep(collections::List& previousFutures, vint start, vint count, collections::List& possibilities) - { - if(walker->GetTableTokenIndex()==-1) - { - return false; - } - vint token = walker->GetTableTokenIndex(); - RegexToken* regexToken = walker->GetRegexToken(); - vint oldPossibilitiesCount = possibilities.Count(); - for (vint i = 0; iselectedRegexToken = regexToken; - } - return true; - } - - bool ParsingState::ExploreNormalReduce(collections::List& previousFutures, vint start, vint count, collections::List& possibilities) - { - if(walker->GetTableTokenIndex()==-1) - { - return false; - } - vint oldPossibilitiesCount = possibilities.Count(); - for(vint i=0;i oldPossibilitiesCount; - } - - bool ParsingState::ExploreLeftRecursiveReduce(collections::List& previousFutures, vint start, vint count, collections::List& possibilities) - { - if(walker->GetTableTokenIndex()==-1) - { - return false; - } - vint oldPossibilitiesCount = possibilities.Count(); - for(vint i=0;i oldPossibilitiesCount; - } - - ParsingState::Future* ParsingState::ExploreCreateRootFuture() - { - Future* future=new Future; - future->currentState=stateGroup->currentState; - return future; - } - - Ptr ParsingState::TakeSnapshot() - { - return new StateGroup(*stateGroup.Obj()); - } - - void ParsingState::RestoreSnapshot(Ptr group) - { - stateGroup=new StateGroup(*group.Obj()); - } - -/*********************************************************************** -ParsingTreeBuilder -***********************************************************************/ - - ParsingTreeBuilder::ParsingTreeBuilder() - :processingAmbiguityBranch(false) - ,ambiguityBranchSharedNodeCount(0) - { - } - - ParsingTreeBuilder::~ParsingTreeBuilder() - { - } - - void ParsingTreeBuilder::Reset() - { - createdObject=0; - operationTarget=new ParsingTreeObject(); - nodeStack.Clear(); - - processingAmbiguityBranch=false; - ambiguityBranchCreatedObject=0; - ambiguityBranchOperationTarget=0; - ambiguityBranchSharedNodeCount=0; - ambiguityBranchNodeStack.Clear(); - ambiguityNodes.Clear(); - } - - bool ParsingTreeBuilder::Run(const ParsingState::TransitionResult& result) - { - if(!operationTarget) - { - return false; - } - - switch(result.transitionType) - { - case ParsingState::TransitionResult::AmbiguityBegin: - { - if(processingAmbiguityBranch) return false; - processingAmbiguityBranch=true; - if(createdObject) - { - ambiguityBranchCreatedObject=createdObject->Clone(); - } - else - { - ambiguityBranchCreatedObject=0; - } - ambiguityBranchOperationTarget=operationTarget->Clone().Cast(); - ambiguityBranchNodeStack.Clear(); - ambiguityBranchSharedNodeCount=nodeStack.Count()-result.ambiguityAffectedStackNodeCount+1; - for(vint i=ambiguityBranchSharedNodeCount;iClone().Cast()); - } - ambiguityNodes.Clear(); - } - break; - case ParsingState::TransitionResult::AmbiguityBranch: - { - if(!processingAmbiguityBranch) return false; - if(nodeStack.Count()!=ambiguityBranchSharedNodeCount) return false; - ambiguityNodes.Add(operationTarget); - if(ambiguityBranchCreatedObject) - { - createdObject=ambiguityBranchCreatedObject->Clone(); - } - else - { - createdObject=0; - } - operationTarget=ambiguityBranchOperationTarget->Clone().Cast(); - for(vint i=0;iClone().Cast()); - } - } - break; - case ParsingState::TransitionResult::AmbiguityEnd: - { - if(!processingAmbiguityBranch) return false; - if(nodeStack.Count()!=ambiguityBranchSharedNodeCount) return false; - ambiguityNodes.Add(operationTarget); - - processingAmbiguityBranch=false; - createdObject=0; - ambiguityBranchCreatedObject=0; - ambiguityBranchOperationTarget=0; - ambiguityBranchSharedNodeCount=0; - ambiguityBranchNodeStack.Clear(); - - { - Ptr ambiguousNode=new ParsingTreeObject(result.ambiguityNodeType, operationTarget->GetCodeRange()); - Ptr items=new ParsingTreeArray(L"", operationTarget->GetCodeRange()); - FOREACH(Ptr, node, ambiguityNodes) - { - items->AddItem(node); - } - ambiguousNode->SetMember(L"items", items); - operationTarget=ambiguousNode; - } - ambiguityNodes.Clear(); - } - break; - case ParsingState::TransitionResult::ExecuteInstructions: - { - vint shiftReduceRangeIndex=0; - for(vint j=result.instructionBegin;jinstructions[j]; - switch(ins.instructionType) - { - case ParsingTable::Instruction::Create: - { - if(operationTarget->GetType()!=L"") - { - return false; - } - operationTarget->SetType(ins.nameParameter); - operationTarget->GetCreatorRules().Add(ins.creatorRule); - } - break; - case ParsingTable::Instruction::Using: - { - if(operationTarget->GetType()!=L"" || !createdObject) - { - return false; - } - Ptr obj=createdObject.Cast(); - if(!obj) - { - return false; - } - for(vint i=0;iGetMembers().Count();i++) - { - WString name=operationTarget->GetMembers().Keys().Get(i); - Ptr value=operationTarget->GetMembers().Values().Get(i); - obj->SetMember(name, value); - } - operationTarget=obj; - operationTarget->GetCreatorRules().Add(ins.creatorRule); - createdObject=0; - } - break; - case ParsingTable::Instruction::Assign: - { - if(!createdObject) - { - Ptr value; - if(result.token==0) - { - value=new ParsingTreeToken(L"", result.tokenIndexInStream); - } - else - { - value=new ParsingTreeToken(WString(result.token->reading, result.token->length), result.tokenIndexInStream); - value->SetCodeRange(ParsingTextRange(result.token, result.token)); - } - operationTarget->SetMember(ins.nameParameter, value); - } - else - { - operationTarget->SetMember(ins.nameParameter, createdObject); - createdObject=0; - } - } - break; - case ParsingTable::Instruction::Item: - { - Ptr arr=operationTarget->GetMember(ins.nameParameter).Cast();; - if(!arr) - { - arr=new ParsingTreeArray(); - operationTarget->SetMember(ins.nameParameter, arr); - } - ParsingTextRange arrRange=arr->GetCodeRange(); - ParsingTextRange itemRange; - if(!createdObject) - { - Ptr value; - if(result.token==0) - { - value=new ParsingTreeToken(L"", result.tokenIndexInStream); - } - else - { - value=new ParsingTreeToken(WString(result.token->reading, result.token->length), result.tokenIndexInStream); - value->SetCodeRange(ParsingTextRange(result.token, result.token)); - itemRange=value->GetCodeRange(); - } - arr->AddItem(value); - } - else - { - arr->AddItem(createdObject); - itemRange=createdObject->GetCodeRange(); - createdObject=0; - } - - if(arrRange.start.index==ParsingTextPos::UnknownValue || itemRange.startarrRange.end) - { - arrRange.end=itemRange.end; - } - arr->SetCodeRange(arrRange); - } - break; - case ParsingTable::Instruction::Setter: - { - Ptr value=new ParsingTreeToken(ins.value, -1); - operationTarget->SetMember(ins.nameParameter, value); - } - break; - case ParsingTable::Instruction::Shift: - { - nodeStack.Add(operationTarget); - operationTarget=new ParsingTreeObject(); - createdObject=0; - } - break; - case ParsingTable::Instruction::Reduce: - { - if(nodeStack.Count()==0) - { - return false; - } - createdObject=operationTarget; - operationTarget=nodeStack[nodeStack.Count()-1]; - nodeStack.RemoveAt(nodeStack.Count()-1); - - if(result.shiftReduceRanges) - { - ParsingState::ShiftReduceRange tokenRange=result.shiftReduceRanges->Get(shiftReduceRangeIndex++); - if(tokenRange.shiftToken && tokenRange.reduceToken) - { - ParsingTextRange codeRange(tokenRange.shiftToken, tokenRange.reduceToken); - createdObject->SetCodeRange(codeRange); - } - } - } - break; - case ParsingTable::Instruction::LeftRecursiveReduce: - { - createdObject=operationTarget; - operationTarget=new ParsingTreeObject(); - - if(result.shiftReduceRanges) - { - ParsingState::ShiftReduceRange tokenRange=result.shiftReduceRanges->Get(shiftReduceRangeIndex++); - if(tokenRange.shiftToken && tokenRange.reduceToken) - { - ParsingTextRange codeRange(tokenRange.shiftToken, tokenRange.reduceToken); - createdObject->SetCodeRange(codeRange); - } - } - } - break; - default: - return false; - } - } - - if(result.tableTokenIndex==ParsingTable::TokenFinish && !processingAmbiguityBranch) - { - if(result.shiftReduceRanges) - { - ParsingState::ShiftReduceRange tokenRange=result.shiftReduceRanges->Get(shiftReduceRangeIndex++); - if(tokenRange.shiftToken && tokenRange.reduceToken) - { - ParsingTextRange codeRange(tokenRange.shiftToken, tokenRange.reduceToken); - operationTarget->SetCodeRange(codeRange); - } - } - } - } - break; - default: - return false; - } - - return true; - } - - bool ParsingTreeBuilder::GetProcessingAmbiguityBranch() - { - return processingAmbiguityBranch; - } - - Ptr ParsingTreeBuilder::GetNode()const - { - if(nodeStack.Count()==0) - { - return operationTarget; - } - else - { - return 0; - } - } - -/*********************************************************************** -ParsingTransitionCollector -***********************************************************************/ - - ParsingTransitionCollector::ParsingTransitionCollector() - :ambiguityBegin(-1) - { - } - - ParsingTransitionCollector::~ParsingTransitionCollector() - { - } - - void ParsingTransitionCollector::Reset() - { - ambiguityBegin=-1; - transitions.Clear(); - ambiguityBeginToEnds.Clear(); - ambiguityBeginToBranches.Clear(); - ambiguityBranchToBegins.Clear(); - } - - bool ParsingTransitionCollector::Run(const ParsingState::TransitionResult& result) - { - vint index=transitions.Count(); - switch(result.transitionType) - { - case ParsingState::TransitionResult::AmbiguityBegin: - if(ambiguityBegin!=-1) return false; - ambiguityBegin=index; - break; - case ParsingState::TransitionResult::AmbiguityBranch: - { - if(ambiguityBegin==-1) return false; - ambiguityBeginToBranches.Add(ambiguityBegin, index); - ambiguityBranchToBegins.Add(index, ambiguityBegin); - } - break; - case ParsingState::TransitionResult::AmbiguityEnd: - { - if(ambiguityBegin==-1) return false; - ambiguityBeginToEnds.Add(ambiguityBegin, index); - ambiguityBegin=-1; - } - break; - case ParsingState::TransitionResult::ExecuteInstructions: - break; - default: - return false; - } - - transitions.Add(result); - return true; - } - - bool ParsingTransitionCollector::GetProcessingAmbiguityBranch() - { - return ambiguityBegin!=-1; - } - - const ParsingTransitionCollector::TransitionResultList& ParsingTransitionCollector::GetTransitions()const - { - return transitions; - } - - vint ParsingTransitionCollector::GetAmbiguityEndFromBegin(vint transitionIndex)const - { - vint index=ambiguityBeginToEnds.Keys().IndexOf(transitionIndex); - return index==-1?-1:ambiguityBeginToEnds.Values()[index]; - } - - const collections::List& ParsingTransitionCollector::GetAmbiguityBranchesFromBegin(vint transitionIndex)const - { - vint index=ambiguityBeginToBranches.Keys().IndexOf(transitionIndex); - return index==-1?*(collections::List*)0:ambiguityBeginToBranches.GetByIndex(index); - } - - vint ParsingTransitionCollector::GetAmbiguityBeginFromBranch(vint transitionIndex)const - { - vint index=ambiguityBranchToBegins.Keys().IndexOf(transitionIndex); - return index==-1?-1:ambiguityBranchToBegins.Values()[index]; - } - } - } -} - -/*********************************************************************** -PARSING\PARSINGTABLE.CPP -***********************************************************************/ - -namespace vl -{ - namespace stream - { - namespace internal - { - using namespace vl::parsing::tabling; - -/*********************************************************************** -ParsingTable (Serialization) -***********************************************************************/ - - BEGIN_SERIALIZATION(ParsingTable::AttributeInfo) - SERIALIZE(name) - SERIALIZE(arguments) - END_SERIALIZATION - - BEGIN_SERIALIZATION(ParsingTable::AttributeInfoList) - SERIALIZE(attributes) - END_SERIALIZATION - - BEGIN_SERIALIZATION(ParsingTable::TreeTypeInfo) - SERIALIZE(type) - SERIALIZE(attributeIndex) - END_SERIALIZATION - - BEGIN_SERIALIZATION(ParsingTable::TreeFieldInfo) - SERIALIZE(type) - SERIALIZE(field) - SERIALIZE(attributeIndex) - END_SERIALIZATION - - BEGIN_SERIALIZATION(ParsingTable::TokenInfo) - SERIALIZE(name) - SERIALIZE(regex) - SERIALIZE(regexTokenIndex) - SERIALIZE(attributeIndex) - END_SERIALIZATION - - BEGIN_SERIALIZATION(ParsingTable::StateInfo) - SERIALIZE(ruleName) - SERIALIZE(stateName) - SERIALIZE(stateExpression) - END_SERIALIZATION - - BEGIN_SERIALIZATION(ParsingTable::RuleInfo) - SERIALIZE(name) - SERIALIZE(type) - SERIALIZE(ambiguousType) - SERIALIZE(rootStartState) - SERIALIZE(attributeIndex) - END_SERIALIZATION - - BEGIN_SERIALIZATION(ParsingTable::Instruction) - SERIALIZE(instructionType) - SERIALIZE(stateParameter) - SERIALIZE(nameParameter) - SERIALIZE(value) - SERIALIZE(creatorRule) - END_SERIALIZATION - - SERIALIZE_ENUM(ParsingTable::Instruction::InstructionType) - - BEGIN_SERIALIZATION(ParsingTable::LookAheadInfo) - SERIALIZE(tokens) - SERIALIZE(state) - END_SERIALIZATION - - BEGIN_SERIALIZATION(ParsingTable::TransitionItem) - SERIALIZE(token) - SERIALIZE(targetState) - SERIALIZE(lookAheads) - SERIALIZE(stackPattern) - SERIALIZE(instructions) - END_SERIALIZATION - - BEGIN_SERIALIZATION(ParsingTable::TransitionBag) - SERIALIZE(transitionItems) - END_SERIALIZATION - } - } - - namespace parsing - { - namespace tabling - { - using namespace collections; - using namespace regex; - -#ifdef VCZH_GCC - const vint ParsingTable::TokenBegin; - const vint ParsingTable::TokenFinish; - const vint ParsingTable::NormalReduce; - const vint ParsingTable::LeftRecursiveReduce; - const vint ParsingTable::UserTokenStart; -#endif - -/*********************************************************************** -ParsingTable::AttributeInfoList -***********************************************************************/ - - Ptr ParsingTable::AttributeInfoList::FindFirst(const WString& name) - { - for(vint i=0;iname==name) - { - return attributes[i]; - } - } - return 0; - } - -/*********************************************************************** -ParsingTable::LookAheadInfo -***********************************************************************/ - - ParsingTable::LookAheadInfo::PrefixResult ParsingTable::LookAheadInfo::TestPrefix(Ptr a, Ptr b) - { - if(a->tokens.Count()>b->tokens.Count()) - { - return ParsingTable::LookAheadInfo::NotPrefix; - } - for(vint i=0;itokens.Count();i++) - { - if(a->tokens[i]!=b->tokens[i]) - { - return ParsingTable::LookAheadInfo::NotPrefix; - } - } - return a->tokens.Count()tokens.Count()?ParsingTable::LookAheadInfo::Prefix:ParsingTable::LookAheadInfo::Equal; - } - - void ParsingTable::LookAheadInfo::WalkInternal(Ptr table, Ptr previous, vint state, collections::SortedList& walkedStates, collections::List>& newInfos) - { - if (walkedStates.Contains(state)) return; - walkedStates.Add(state); - - for (vint i = 0; i < table->GetTokenCount(); i++) - { - if(Ptr bag=table->GetTransitionBag(state, i)) - { - FOREACH(Ptr, item, bag->transitionItems) - { - if (i == ParsingTable::NormalReduce || i == ParsingTable::LeftRecursiveReduce) - { - WalkInternal(table, previous, item->targetState, walkedStates, newInfos); - } - else - { - Ptr info=new LookAheadInfo; - info->state=item->targetState; - if(previous) - { - CopyFrom(info->tokens, previous->tokens); - } - info->tokens.Add(i); - newInfos.Add(info); - } - } - } - } - - walkedStates.Remove(state); - } - - void ParsingTable::LookAheadInfo::Walk(Ptr table, Ptr previous, vint state, collections::List>& newInfos) - { - SortedList walkedStates; - WalkInternal(table, previous, state, walkedStates, newInfos); - } - -/*********************************************************************** -ParsingTable::TransitionItem -***********************************************************************/ - - enum TransitionLevel - { - ReduceTransition, - LeftRecursiveReduceTransition, - NormalTransition, - }; - - TransitionLevel GetTransitionLevel(Ptr t) - { - bool hasReduce=false; - bool hasLrReduce=false; - FOREACH(ParsingTable::Instruction, ins, t->instructions) - { - switch(ins.instructionType) - { - case ParsingTable::Instruction::Reduce: - hasReduce=true; - break; - case ParsingTable::Instruction::LeftRecursiveReduce: - hasLrReduce=true; - break; - default:; - } - } - - return - hasLrReduce?LeftRecursiveReduceTransition: - hasReduce?ReduceTransition: - NormalTransition; - } - - ParsingTable::TransitionItem::OrderResult ParsingTable::TransitionItem::CheckOrder(Ptr t1, Ptr t2, bool forceGivingOrder) - { - if(t1->token!=t2->token) return UnknownOrder; - if(forceGivingOrder) - { - TransitionLevel level1=GetTransitionLevel(t1); - TransitionLevel level2=GetTransitionLevel(t2); - if(level1>level2) return CorrectOrder; - if(level1stackPattern.Count(); - vint ic2=t2->stackPattern.Count(); - vint ic=ic1stackPattern[i]; - vint s2=t2->stackPattern[i]; - - if(s1>s2) - { - return CorrectOrder; - } - else if(s1token==TokenFinish) - { - if(ic1>ic2) - { - return CorrectOrder; - } - else if(ic1t2?CorrectOrder:SameOrder; - } - else - { - return UnknownOrder; - } - } - - vint ParsingTable::TransitionItem::Compare(Ptr t1, Ptr t2) - { - OrderResult order=CheckOrder(t1, t2, true); - switch(order) - { - case CorrectOrder: return -1; - case WrongOrder: return 1; - default: return 0; - } - } - - template - void ParsingTable::IO(TIO& io) - { - io - << ambiguity - << attributeInfos - << treeTypeInfos - << treeFieldInfos - << tokenCount - << stateCount - << tokenInfos - << discardTokenInfos - << stateInfos - << ruleInfos - << transitionBags - ; - } - - ParsingTable::ParsingTable(stream::IStream& input) - { - stream::internal::ContextFreeReader reader(input); - IO(reader); - } - - void ParsingTable::Serialize(stream::IStream& output) - { - stream::internal::ContextFreeWriter writer(output); - IO(writer); - } - -/*********************************************************************** -ParsingTable -***********************************************************************/ - - ParsingTable::ParsingTable(vint _attributeInfoCount, vint _treeTypeInfoCount, vint _treeFieldInfoCount, vint _tokenCount, vint discardTokenCount, vint _stateCount, vint _ruleCount) - :ambiguity(false) - ,tokenCount(_tokenCount+UserTokenStart) - ,stateCount(_stateCount) - ,attributeInfos(_attributeInfoCount) - ,treeTypeInfos(_treeTypeInfoCount) - ,treeFieldInfos(_treeFieldInfoCount) - ,tokenInfos(_tokenCount+UserTokenStart) - ,discardTokenInfos(discardTokenCount) - ,stateInfos(_stateCount) - ,ruleInfos(_ruleCount) - ,transitionBags((_tokenCount+UserTokenStart)*_stateCount) - { - } - - ParsingTable::~ParsingTable() - { - } - - bool ParsingTable::GetAmbiguity() - { - return ambiguity; - } - - void ParsingTable::SetAmbiguity(bool value) - { - ambiguity=value; - } - - vint ParsingTable::GetAttributeInfoCount() - { - return attributeInfos.Count(); - } - - Ptr ParsingTable::GetAttributeInfo(vint index) - { - return attributeInfos[index]; - } - - void ParsingTable::SetAttributeInfo(vint index, Ptr info) - { - attributeInfos[index]=info; - } - - vint ParsingTable::GetTreeTypeInfoCount() - { - return treeTypeInfos.Count(); - } - - const ParsingTable::TreeTypeInfo& ParsingTable::GetTreeTypeInfo(vint index) - { - return treeTypeInfos[index]; - } - - const ParsingTable::TreeTypeInfo& ParsingTable::GetTreeTypeInfo(const WString& type) - { - vint index=treeTypeInfoMap.Keys().IndexOf(type); - if(index==-1) return *(const TreeTypeInfo*)0; - return treeTypeInfos[treeTypeInfoMap.Values().Get(index)]; - } - - void ParsingTable::SetTreeTypeInfo(vint index, const TreeTypeInfo& info) - { - treeTypeInfos[index]=info; - } - - vint ParsingTable::GetTreeFieldInfoCount() - { - return treeFieldInfos.Count(); - } - - const ParsingTable::TreeFieldInfo& ParsingTable::GetTreeFieldInfo(vint index) - { - return treeFieldInfos[index]; - } - - const ParsingTable::TreeFieldInfo& ParsingTable::GetTreeFieldInfo(const WString& type, const WString& field) - { - Pair key(type, field); - vint index=treeFieldInfoMap.Keys().IndexOf(key); - if(index==-1) return *(const TreeFieldInfo*)0; - return treeFieldInfos[treeFieldInfoMap.Values().Get(index)]; - } - - void ParsingTable::SetTreeFieldInfo(vint index, const TreeFieldInfo& info) - { - treeFieldInfos[index]=info; - } - - vint ParsingTable::GetTokenCount() - { - return tokenCount; - } - - const ParsingTable::TokenInfo& ParsingTable::GetTokenInfo(vint token) - { - return tokenInfos[token]; - } - - void ParsingTable::SetTokenInfo(vint token, const TokenInfo& info) - { - tokenInfos[token]=info; - } - - vint ParsingTable::GetDiscardTokenCount() - { - return discardTokenInfos.Count(); - } - - const ParsingTable::TokenInfo& ParsingTable::GetDiscardTokenInfo(vint token) - { - return discardTokenInfos[token]; - } - - void ParsingTable::SetDiscardTokenInfo(vint token, const TokenInfo& info) - { - discardTokenInfos[token]=info; - } - - vint ParsingTable::GetStateCount() - { - return stateCount; - } - - const ParsingTable::StateInfo& ParsingTable::GetStateInfo(vint state) - { - return stateInfos[state]; - } - - void ParsingTable::SetStateInfo(vint state, const StateInfo& info) - { - stateInfos[state]=info; - } - - vint ParsingTable::GetRuleCount() - { - return ruleInfos.Count(); - } - - const ParsingTable::RuleInfo& ParsingTable::GetRuleInfo(const WString& ruleName) - { - vint index=ruleMap.Keys().IndexOf(ruleName); - if(index==-1) return *(const RuleInfo*)0; - return ruleInfos[ruleMap.Values().Get(index)]; - } - - const ParsingTable::RuleInfo& ParsingTable::GetRuleInfo(vint rule) - { - return ruleInfos[rule]; - } - - void ParsingTable::SetRuleInfo(vint rule, const RuleInfo& info) - { - ruleInfos[rule]=info; - } - - const regex::RegexLexer& ParsingTable::GetLexer() - { - return *lexer.Obj(); - } - - Ptr ParsingTable::GetTransitionBag(vint state, vint token) - { - return transitionBags[state*tokenCount+token]; - } - - void ParsingTable::SetTransitionBag(vint state, vint token, Ptr bag) - { - transitionBags[state*tokenCount+token]=bag; - } - - void ParsingTable::Initialize() - { - List tokens; - FOREACH(TokenInfo, info, From(tokenInfos).Skip(UserTokenStart)) - { - tokens.Add(info.regex); - } - FOREACH(TokenInfo, info, discardTokenInfos) - { - tokens.Add(info.regex); - } - - vint regexTokenIndex=0; - for(vint i=UserTokenStart;i key(info.type, info.field); - treeFieldInfoMap.Add(key, index); - } - } - - bool ParsingTable::IsInputToken(vint regexTokenIndex) - { - return regexTokenIndex>=0 && regexTokenIndex=tokenCount-UserTokenStart?regexTokenIndex-(tokenCount-UserTokenStart):-1; - } - } - } -} - -/*********************************************************************** -PARSING\PARSINGTREE.CPP -***********************************************************************/ - -namespace vl -{ - using namespace collections; - - namespace parsing - { - vint CompareTextRange(Ptr r1, Ptr r2) - { - return ParsingTextPos::Compare(r1->GetCodeRange().start, r2->GetCodeRange().start); - } - -/*********************************************************************** -ParsingTreeNode::TraversalVisitor -***********************************************************************/ - - ParsingTreeNode::TraversalVisitor::TraversalVisitor(TraverseDirection _direction) - :direction(_direction) - { - } - - void ParsingTreeNode::TraversalVisitor::BeforeVisit(ParsingTreeToken* node) - { - } - - void ParsingTreeNode::TraversalVisitor::AfterVisit(ParsingTreeToken* node) - { - } - - void ParsingTreeNode::TraversalVisitor::BeforeVisit(ParsingTreeObject* node) - { - } - - void ParsingTreeNode::TraversalVisitor::AfterVisit(ParsingTreeObject* node) - { - } - - void ParsingTreeNode::TraversalVisitor::BeforeVisit(ParsingTreeArray* node) - { - } - - void ParsingTreeNode::TraversalVisitor::AfterVisit(ParsingTreeArray* node) - { - } - - void ParsingTreeNode::TraversalVisitor::Visit(ParsingTreeToken* node) - { - BeforeVisit(node); - AfterVisit(node); - } - - void ParsingTreeNode::TraversalVisitor::Visit(ParsingTreeObject* node) - { - BeforeVisit(node); - switch(direction) - { - case TraverseDirection::ByTextPosition: - { - FOREACH(Ptr, node, node->GetSubNodes()) - { - node->Accept(this); - } - } - break; - case TraverseDirection::ByStorePosition: - { - FOREACH(Ptr, node, node->GetMembers().Values()) - { - node->Accept(this); - } - } - break; - } - AfterVisit(node); - } - - void ParsingTreeNode::TraversalVisitor::Visit(ParsingTreeArray* node) - { - BeforeVisit(node); - switch(direction) - { - case TraverseDirection::ByTextPosition: - { - FOREACH(Ptr, node, node->GetSubNodes()) - { - node->Accept(this); - } - } - break; - case TraverseDirection::ByStorePosition: - { - FOREACH(Ptr, node, node->GetItems()) - { - node->Accept(this); - } - } - break; - } - AfterVisit(node); - } - -/*********************************************************************** -ParsingTreeNode -***********************************************************************/ - - bool ParsingTreeNode::BeforeAddChild(Ptr node) - { - return node->parent==0; - } - - void ParsingTreeNode::AfterAddChild(Ptr node) - { - node->parent=this; - ClearQueryCache(); - } - - bool ParsingTreeNode::BeforeRemoveChild(Ptr node) - { - return node->parent!=0; - } - - void ParsingTreeNode::AfterRemoveChild(Ptr node) - { - node->parent=0; - ClearQueryCache(); - } - - ParsingTreeNode::ParsingTreeNode(const ParsingTextRange& _codeRange) - :codeRange(_codeRange) - ,parent(0) - { - } - - ParsingTreeNode::~ParsingTreeNode() - { - } - - ParsingTextRange ParsingTreeNode::GetCodeRange() - { - return codeRange; - } - - void ParsingTreeNode::SetCodeRange(const ParsingTextRange& range) - { - codeRange=range; - } - - void ParsingTreeNode::InitializeQueryCache() - { - const NodeList& subNodes=GetSubNodesInternal(); - ClearQueryCache(); - auto subNodesExists = &subNodes; - if(subNodesExists) - { - FOREACH(Ptr, node, subNodes) - { - node->InitializeQueryCache(); - } - - //if (codeRange.start.IsInvalid() || codeRange.start.IsInvalid()) - { - FOREACH(Ptr, subNode, subNodes) - { - const auto& subRange = subNode->codeRange; - const auto& min = !subRange.start.IsInvalid() ? subRange.start : subRange.end; - const auto& max = !subRange.end.IsInvalid() ? subRange.end : subRange.start; - - if (codeRange.start.IsInvalid() || (!min.IsInvalid() && codeRange.start > min)) - { - codeRange.start = min; - } - if (codeRange.end.IsInvalid() || (!max.IsInvalid() && codeRange.end < max)) - { - codeRange.end = max; - } - } - } - - CopyFrom( - cachedOrderedSubNodes, - From(subNodes) - .Where([=](Ptr node) - { - const auto& range = node->GetCodeRange(); - return !range.start.IsInvalid() && !range.end.IsInvalid(); - }) - .OrderBy(&CompareTextRange) - ); - } - } - - void ParsingTreeNode::ClearQueryCache() - { - cachedOrderedSubNodes.Clear(); - } - - ParsingTreeNode* ParsingTreeNode::GetParent() - { - return parent; - } - - const ParsingTreeNode::NodeList& ParsingTreeNode::GetSubNodes() - { - return cachedOrderedSubNodes; - } - - ParsingTreeNode* ParsingTreeNode::FindSubNode(const ParsingTextPos& position) - { - return FindSubNode(ParsingTextRange(position, position)); - } - - ParsingTreeNode* ParsingTreeNode::FindSubNode(const ParsingTextRange& range) - { - if (codeRange.start <= range.start && range.end <= codeRange.end) - { - vint start = 0; - vint end = cachedOrderedSubNodes.Count() - 1; - while (start <= end) - { - vint selected = (start + end) / 2; - ParsingTreeNode* selectedNode = cachedOrderedSubNodes[selected].Obj(); - const ParsingTextRange& selectedRange = selectedNode->codeRange; - if (range.endselectedRange.end) - { - start = selected + 1; - } - else if (selectedRange.start <= range.start && range.end <= selectedRange.end) - { - return selectedNode; - } - else - { - return this; - } - } - } - return this; - } - - ParsingTreeNode* ParsingTreeNode::FindDeepestNode(const ParsingTextPos& position) - { - return FindDeepestNode(ParsingTextRange(position, position)); - } - - ParsingTreeNode* ParsingTreeNode::FindDeepestNode(const ParsingTextRange& range) - { - ParsingTreeNode* result=0; - ParsingTreeNode* node=this; - do - { - result=node; - node=node->FindSubNode(range); - }while(result!=node); - return result; - } - -/*********************************************************************** -ParsingTreeToken -***********************************************************************/ - - const ParsingTreeToken::NodeList& ParsingTreeToken::GetSubNodesInternal() - { - return *(NodeList*)0; - } - - ParsingTreeToken::ParsingTreeToken(const WString& _value, vint _tokenIndex, const ParsingTextRange& _codeRange) - :ParsingTreeNode(_codeRange) - ,value(_value) - ,tokenIndex(_tokenIndex) - { - } - - ParsingTreeToken::~ParsingTreeToken() - { - } - - void ParsingTreeToken::Accept(IVisitor* visitor) - { - visitor->Visit(this); - } - - Ptr ParsingTreeToken::Clone() - { - Ptr clone=new ParsingTreeToken(value, tokenIndex, codeRange); - return clone; - } - - vint ParsingTreeToken::GetTokenIndex() - { - return tokenIndex; - } - - void ParsingTreeToken::SetTokenIndex(vint _tokenIndex) - { - tokenIndex=_tokenIndex; - } - - const WString& ParsingTreeToken::GetValue() - { - return value; - } - - void ParsingTreeToken::SetValue(const WString& _value) - { - value=_value; - } - -/*********************************************************************** -ParsingTreeObject -***********************************************************************/ - - const ParsingTreeObject::NodeList& ParsingTreeObject::GetSubNodesInternal() - { - return members.Values(); - } - - ParsingTreeObject::ParsingTreeObject(const WString& _type, const ParsingTextRange& _codeRange) - :ParsingTreeNode(_codeRange) - ,type(_type) - { - } - - ParsingTreeObject::~ParsingTreeObject() - { - } - - void ParsingTreeObject::Accept(IVisitor* visitor) - { - visitor->Visit(this); - } - - Ptr ParsingTreeObject::Clone() - { - Ptr clone=new ParsingTreeObject(type, codeRange); - CopyFrom(clone->rules, rules); - for(vint i=0;i node=members.Values().Get(i)->Clone(); - clone->SetMember(name, node); - } - return clone; - } - - const WString& ParsingTreeObject::GetType() - { - return type; - } - - void ParsingTreeObject::SetType(const WString& _type) - { - type=_type; - } - - ParsingTreeObject::NodeMap& ParsingTreeObject::GetMembers() - { - return members; - } - - Ptr ParsingTreeObject::GetMember(const WString& name) - { - vint index=members.Keys().IndexOf(name); - if(index==-1) return 0; - return members.Values().Get(index); - } - - bool ParsingTreeObject::SetMember(const WString& name, Ptr node) - { - vint index=members.Keys().IndexOf(name); - if(index!=-1) - { - Ptr previous=members.Values().Get(index); - if(previous==node) return true; - if(!BeforeRemoveChild(previous) || !BeforeAddChild(node)) return false; - members.Remove(name); - AfterRemoveChild(previous); - } - members.Add(name, node); - AfterAddChild(node); - return true; - } - - bool ParsingTreeObject::RemoveMember(const WString& name) - { - vint index=members.Keys().IndexOf(name); - if(index!=-1) - { - Ptr previous=members.Values().Get(index); - if(BeforeRemoveChild(previous)) - { - members.Remove(name); - AfterRemoveChild(previous); - return true; - } - } - return false; - } - - const ParsingTreeObject::NameList& ParsingTreeObject::GetMemberNames() - { - return members.Keys(); - } - - ParsingTreeObject::RuleList& ParsingTreeObject::GetCreatorRules() - { - return rules; - } - -/*********************************************************************** -ParsingTreeArray -***********************************************************************/ - - const ParsingTreeArray::NodeList& ParsingTreeArray::GetSubNodesInternal() - { - return items; - } - - ParsingTreeArray::ParsingTreeArray(const WString& _elementType, const ParsingTextRange& _codeRange) - :ParsingTreeNode(_codeRange) - ,elementType(_elementType) - { - } - - ParsingTreeArray::~ParsingTreeArray() - { - } - - void ParsingTreeArray::Accept(IVisitor* visitor) - { - visitor->Visit(this); - } - - Ptr ParsingTreeArray::Clone() - { - Ptr clone=new ParsingTreeArray(elementType, codeRange); - for(vint i=0;i node=items.Get(i)->Clone(); - clone->AddItem(node); - } - return clone; - } - - const WString& ParsingTreeArray::GetElementType() - { - return elementType; - } - - void ParsingTreeArray::SetElementType(const WString& _elementType) - { - elementType=_elementType; - } - - ParsingTreeArray::NodeArray& ParsingTreeArray::GetItems() - { - return items; - } - - Ptr ParsingTreeArray::GetItem(vint index) - { - if(0<=index && index node) - { - if(0<=index && index node) - { - return InsertItem(items.Count(), node); - } - - bool ParsingTreeArray::InsertItem(vint index, Ptr node) - { - if(0<=index && index<=items.Count()) - { - if(BeforeAddChild(node)) - { - items.Insert(index, node); - AfterAddChild(node); - return true; - } - } - return false; - } - - bool ParsingTreeArray::RemoveItem(vint index) - { - if(0<=index && index previous=items[index]; - if(BeforeRemoveChild(previous)) - { - items.RemoveAt(index); - AfterRemoveChild(previous); - return true; - } - } - return false; - } - - bool ParsingTreeArray::RemoveItem(ParsingTreeNode* node) - { - return RemoveItem(items.IndexOf(node)); - } - - vint ParsingTreeArray::IndexOfItem(ParsingTreeNode* node) - { - return items.IndexOf(node); - } - - bool ParsingTreeArray::ContainsItem(ParsingTreeNode* node) - { - return items.Contains(node); - } - - vint ParsingTreeArray::Count() - { - return items.Count(); - } - - bool ParsingTreeArray::Clear() - { - FOREACH(Ptr, node, items) - { - if(!BeforeRemoveChild(node)) return false; - } - FOREACH(Ptr, node, items) - { - AfterRemoveChild(node); - } - items.Clear(); - return true; - } - -/*********************************************************************** -ParsingError -***********************************************************************/ - - ParsingError::ParsingError() - :token(0) - ,parsingTree(0) - { - } - - ParsingError::ParsingError(const WString& _errorMessage) - :token(0) - ,parsingTree(0) - ,errorMessage(_errorMessage) - { - } - - ParsingError::ParsingError(const regex::RegexToken* _token, const WString& _errorMessage) - :token(_token) - ,parsingTree(0) - ,errorMessage(_errorMessage) - { - if(token) - { - codeRange.start.row=_token->rowStart; - codeRange.start.column=_token->columnStart; - codeRange.start.index=_token->start; - codeRange.end.row=_token->rowEnd; - codeRange.end.column=_token->columnEnd; - codeRange.end.index=_token->start+_token->length-1; - codeRange.codeIndex = _token->codeIndex; - } - } - - ParsingError::ParsingError(ParsingTreeCustomBase* _parsingTree, const WString& _errorMessage) - :codeRange(_parsingTree->codeRange) - ,token(0) - ,parsingTree(_parsingTree) - ,errorMessage(_errorMessage) - { - } - - ParsingError::~ParsingError() - { - } - -/*********************************************************************** -ParsingEmptyPrintNodeRecorder -***********************************************************************/ - - ParsingEmptyPrintNodeRecorder::ParsingEmptyPrintNodeRecorder() - { - } - - ParsingEmptyPrintNodeRecorder::~ParsingEmptyPrintNodeRecorder() - { - } - - void ParsingEmptyPrintNodeRecorder::Record(ParsingTreeCustomBase* node, const ParsingTextRange& range) - { - } - -/*********************************************************************** -ParsingMultiplePrintNodeRecorder -***********************************************************************/ - - ParsingMultiplePrintNodeRecorder::ParsingMultiplePrintNodeRecorder() - { - } - - ParsingMultiplePrintNodeRecorder::~ParsingMultiplePrintNodeRecorder() - { - } - - void ParsingMultiplePrintNodeRecorder::AddRecorder(Ptr recorder) - { - recorders.Add(recorder); - } - - void ParsingMultiplePrintNodeRecorder::Record(ParsingTreeCustomBase* node, const ParsingTextRange& range) - { - FOREACH(Ptr, recorder, recorders) - { - recorder->Record(node, range); - } - } - -/*********************************************************************** -ParsingOriginalLocationRecorder -***********************************************************************/ - - ParsingOriginalLocationRecorder::ParsingOriginalLocationRecorder(Ptr _recorder) - :recorder(_recorder) - { - } - - ParsingOriginalLocationRecorder::~ParsingOriginalLocationRecorder() - { - } - - void ParsingOriginalLocationRecorder::Record(ParsingTreeCustomBase* node, const ParsingTextRange& range) - { - auto codeRange = node->codeRange; - codeRange.codeIndex = range.codeIndex; - recorder->Record(node, codeRange); - } - -/*********************************************************************** -ParsingGeneratedLocationRecorder -***********************************************************************/ - - ParsingGeneratedLocationRecorder::ParsingGeneratedLocationRecorder(RangeMap& _rangeMap) - :rangeMap(_rangeMap) - { - } - - ParsingGeneratedLocationRecorder::~ParsingGeneratedLocationRecorder() - { - } - - void ParsingGeneratedLocationRecorder::Record(ParsingTreeCustomBase* node, const ParsingTextRange& range) - { - rangeMap.Add(node, range); - } - -/*********************************************************************** -ParsingUpdateLocationRecorder -***********************************************************************/ - - ParsingUpdateLocationRecorder::ParsingUpdateLocationRecorder() - { - } - - ParsingUpdateLocationRecorder::~ParsingUpdateLocationRecorder() - { - } - - void ParsingUpdateLocationRecorder::Record(ParsingTreeCustomBase* node, const ParsingTextRange& range) - { - node->codeRange = range; - } - -/*********************************************************************** -ParsingWriter -***********************************************************************/ - - void ParsingWriter::HandleChar(wchar_t c) - { - lastPos = currentPos; - switch (c) - { - case L'\n': - currentPos.index++; - currentPos.row++; - currentPos.column = 0; - break; - default: - currentPos.index++; - currentPos.column++; - } - } - - ParsingWriter::ParsingWriter(stream::TextWriter& _writer, Ptr _recorder, vint _codeIndex) - :writer(_writer) - , recorder(_recorder) - , codeIndex(_codeIndex) - , lastPos(-1, 0, -1) - , currentPos(0, 0, 0) - { - } - - ParsingWriter::~ParsingWriter() - { - } - - void ParsingWriter::WriteChar(wchar_t c) - { - writer.WriteChar(c); - if (!recorder) return; - HandleChar(c); - } - - void ParsingWriter::WriteString(const wchar_t* string, vint charCount) - { - writer.WriteString(string, charCount); - if (!recorder) return; - for (vint i = 0; i < charCount; i++) - { - HandleChar(string[i]); - } - } - - void ParsingWriter::BeforePrint(ParsingTreeCustomBase* node) - { - if (!recorder) return; - nodePositions.Add(NodePosPair(node, currentPos)); - } - - void ParsingWriter::AfterPrint(ParsingTreeCustomBase* node) - { - if (!recorder) return; - - auto pair = nodePositions[nodePositions.Count() - 1]; - nodePositions.RemoveAt(nodePositions.Count() - 1); - CHECK_ERROR(pair.key == node, L"vl::parsing::ParsingWriter::AfterPrint(ParsingTreeNode*)#BeforePrint and AfterPrint should be call in pairs."); - - ParsingTextRange range(pair.value, lastPos, codeIndex); - recorder->Record(node, range); - } - } -} - -/*********************************************************************** -PARSING\JSON\PARSINGJSON.CPP -***********************************************************************/ - -namespace vl -{ - namespace parsing - { - namespace json - { - using namespace stream; - using namespace collections; - -/*********************************************************************** -Unescaping Function Foward Declarations -***********************************************************************/ - - void JsonUnescapingString(vl::parsing::ParsingToken& value, const vl::collections::List& tokens) - { - MemoryStream stream; - { - StreamWriter writer(stream); - JsonUnescapeString(value.value.Sub(1, value.value.Length()-2), writer); - } - stream.SeekFromBegin(0); - { - StreamReader reader(stream); - value.value=reader.ReadToEnd(); - } - } - -/*********************************************************************** -JsonPrintVisitor -***********************************************************************/ - - class JsonPrintVisitor : public Object, public JsonNode::IVisitor - { - public: - TextWriter& writer; - - JsonPrintVisitor(TextWriter& _writer) - :writer(_writer) - { - } - - void Visit(JsonLiteral* node) - { - switch(node->value) - { - case JsonLiteral::JsonValue::True: - writer.WriteString(L"true"); - break; - case JsonLiteral::JsonValue::False: - writer.WriteString(L"false"); - break; - case JsonLiteral::JsonValue::Null: - writer.WriteString(L"null"); - break; - } - } - - void Visit(JsonString* node) - { - writer.WriteChar(L'\"'); - JsonEscapeString(node->content.value, writer); - writer.WriteChar(L'\"'); - } - - void Visit(JsonNumber* node) - { - writer.WriteString(node->content.value); - } - - void Visit(JsonArray* node) - { - writer.WriteChar(L'['); - FOREACH_INDEXER(Ptr, item, i, node->items) - { - if(i>0) writer.WriteChar(L','); - item->Accept(this); - } - writer.WriteChar(L']'); - } - - void Visit(JsonObjectField* node) - { - writer.WriteChar(L'\"'); - JsonEscapeString(node->name.value, writer); - writer.WriteString(L"\":"); - node->value->Accept(this); - } - - void Visit(JsonObject* node) - { - writer.WriteChar(L'{'); - FOREACH_INDEXER(Ptr, field, i, node->fields) - { - if(i>0) writer.WriteChar(L','); - field->Accept(this); - } - writer.WriteChar(L'}'); - } - }; - -/*********************************************************************** -API -***********************************************************************/ - - void JsonEscapeString(const WString& text, stream::TextWriter& writer) - { - const wchar_t* reading=text.Buffer(); - while(wchar_t c=*reading++) - { - switch(c) - { - case L'\"': writer.WriteString(L"\\\""); break; - case L'\\': writer.WriteString(L"\\\\"); break; - case L'/': writer.WriteString(L"\\/"); break; - case L'\b': writer.WriteString(L"\\b"); break; - case L'\f': writer.WriteString(L"\\f"); break; - case L'\n': writer.WriteString(L"\\n"); break; - case L'\r': writer.WriteString(L"\\r"); break; - case L'\t': writer.WriteString(L"\\t"); break; - default: writer.WriteChar(c); - } - } - } - - vuint16_t GetHex(wchar_t c) - { - if(L'0'<=c && c<=L'9') - { - return c-L'0'; - } - else if(L'A'<=c && c<=L'F') - { - return c-L'A'; - } - else if(L'a'<=c && c<=L'f') - { - return c-L'a'; - } - else - { - return 0; - } - } - - void JsonUnescapeString(const WString& text, stream::TextWriter& writer) - { - const wchar_t* reading=text.Buffer(); - while(wchar_t c=*reading++) - { - if(c==L'\\' && *reading) - { - switch(c=*reading++) - { - case L'b': writer.WriteChar(L'\b'); break; - case L'f': writer.WriteChar(L'\f'); break; - case L'n': writer.WriteChar(L'\n'); break; - case L'r': writer.WriteChar(L'\r'); break; - case L't': writer.WriteChar(L'\t'); break; - case L'u': - { - wchar_t h1, h2, h3, h4; - if((h1=reading[0]) && (h2=reading[1]) && (h3=reading[2]) && (h4=reading[3])) - { - reading+=4; - wchar_t h=(wchar_t)(vuint16_t)( - (GetHex(h1)<<12) + - (GetHex(h2)<<8) + - (GetHex(h3)<<4) + - (GetHex(h4)<<0) - ); - writer.WriteChar(h); - } - } - break; - default: writer.WriteChar(c); - } - } - else - { - writer.WriteChar(c); - } - } - } - - void JsonPrint(Ptr node, stream::TextWriter& writer) - { - JsonPrintVisitor visitor(writer); - node->Accept(&visitor); - } - - WString JsonToString(Ptr node) - { - MemoryStream stream; - { - StreamWriter writer(stream); - JsonPrint(node, writer); - } - stream.SeekFromBegin(0); - { - StreamReader reader(stream); - return reader.ReadToEnd(); - } - } - } - } -} - -/*********************************************************************** -PARSING\JSON\PARSINGJSON_AST.CPP -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Parser::ParsingJson.parser.txt - -This file is generated by: Vczh Parser Generator -***********************************************************************/ - - -namespace vl -{ - namespace parsing - { - namespace json - { -/*********************************************************************** -Visitor Pattern Implementation -***********************************************************************/ - - void JsonLiteral::Accept(JsonNode::IVisitor* visitor) - { - visitor->Visit(this); - } - - void JsonString::Accept(JsonNode::IVisitor* visitor) - { - visitor->Visit(this); - } - - void JsonNumber::Accept(JsonNode::IVisitor* visitor) - { - visitor->Visit(this); - } - - void JsonArray::Accept(JsonNode::IVisitor* visitor) - { - visitor->Visit(this); - } - - void JsonObjectField::Accept(JsonNode::IVisitor* visitor) - { - visitor->Visit(this); - } - - void JsonObject::Accept(JsonNode::IVisitor* visitor) - { - visitor->Visit(this); - } - - } - } -} -namespace vl -{ - namespace reflection - { - namespace description - { -#ifndef VCZH_DEBUG_NO_REFLECTION - using namespace vl::parsing::json; - -#define PARSING_TOKEN_FIELD(NAME)\ - CLASS_MEMBER_EXTERNALMETHOD_TEMPLATE(get_##NAME, NO_PARAMETER, vl::WString(ClassType::*)(), [](ClassType* node) { return node->NAME.value; }, L"*", L"*")\ - CLASS_MEMBER_EXTERNALMETHOD_TEMPLATE(set_##NAME, { L"value" }, void(ClassType::*)(const vl::WString&), [](ClassType* node, const vl::WString& value) { node->NAME.value = value; }, L"*", L"*")\ - CLASS_MEMBER_PROPERTY_REFERENCETEMPLATE(NAME, get_##NAME, set_##NAME, L"$This->$Name.value")\ - - IMPL_TYPE_INFO_RENAME(vl::parsing::json::JsonNode, system::JsonNode) - IMPL_TYPE_INFO_RENAME(vl::parsing::json::JsonLiteral, system::JsonLiteral) - IMPL_TYPE_INFO_RENAME(vl::parsing::json::JsonLiteral::JsonValue, system::JsonLiteral::JsonValue) - IMPL_TYPE_INFO_RENAME(vl::parsing::json::JsonString, system::JsonString) - IMPL_TYPE_INFO_RENAME(vl::parsing::json::JsonNumber, system::JsonNumber) - IMPL_TYPE_INFO_RENAME(vl::parsing::json::JsonArray, system::JsonArray) - IMPL_TYPE_INFO_RENAME(vl::parsing::json::JsonObjectField, system::JsonObjectField) - IMPL_TYPE_INFO_RENAME(vl::parsing::json::JsonObject, system::JsonObject) - IMPL_TYPE_INFO_RENAME(vl::parsing::json::JsonNode::IVisitor, system::JsonNode::IVisitor) - - BEGIN_CLASS_MEMBER(JsonNode) - CLASS_MEMBER_METHOD_OVERLOAD(Accept, {L"visitor"}, void(JsonNode::*)(JsonNode::IVisitor* visitor)) - END_CLASS_MEMBER(JsonNode) - - BEGIN_CLASS_MEMBER(JsonLiteral) - CLASS_MEMBER_BASE(JsonNode) - - CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) - - CLASS_MEMBER_FIELD(value) - END_CLASS_MEMBER(JsonLiteral) - - BEGIN_ENUM_ITEM(JsonLiteral::JsonValue) - ENUM_ITEM_NAMESPACE(JsonLiteral::JsonValue) - ENUM_NAMESPACE_ITEM(True) - ENUM_NAMESPACE_ITEM(False) - ENUM_NAMESPACE_ITEM(Null) - END_ENUM_ITEM(JsonLiteral::JsonValue) - - BEGIN_CLASS_MEMBER(JsonString) - CLASS_MEMBER_BASE(JsonNode) - - CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) - - PARSING_TOKEN_FIELD(content) - END_CLASS_MEMBER(JsonString) - - BEGIN_CLASS_MEMBER(JsonNumber) - CLASS_MEMBER_BASE(JsonNode) - - CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) - - PARSING_TOKEN_FIELD(content) - END_CLASS_MEMBER(JsonNumber) - - BEGIN_CLASS_MEMBER(JsonArray) - CLASS_MEMBER_BASE(JsonNode) - - CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) - - CLASS_MEMBER_FIELD(items) - END_CLASS_MEMBER(JsonArray) - - BEGIN_CLASS_MEMBER(JsonObjectField) - CLASS_MEMBER_BASE(JsonNode) - - CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) - - PARSING_TOKEN_FIELD(name) - CLASS_MEMBER_FIELD(value) - END_CLASS_MEMBER(JsonObjectField) - - BEGIN_CLASS_MEMBER(JsonObject) - CLASS_MEMBER_BASE(JsonNode) - - CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) - - CLASS_MEMBER_FIELD(fields) - END_CLASS_MEMBER(JsonObject) - - BEGIN_INTERFACE_MEMBER(JsonNode::IVisitor) - CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(JsonNode::IVisitor::*)(JsonLiteral* node)) - CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(JsonNode::IVisitor::*)(JsonString* node)) - CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(JsonNode::IVisitor::*)(JsonNumber* node)) - CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(JsonNode::IVisitor::*)(JsonArray* node)) - CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(JsonNode::IVisitor::*)(JsonObjectField* node)) - CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(JsonNode::IVisitor::*)(JsonObject* node)) - END_INTERFACE_MEMBER(JsonNode) - -#undef PARSING_TOKEN_FIELD - - class JsonTypeLoader : public vl::Object, public ITypeLoader - { - public: - void Load(ITypeManager* manager) - { - ADD_TYPE_INFO(vl::parsing::json::JsonNode) - ADD_TYPE_INFO(vl::parsing::json::JsonLiteral) - ADD_TYPE_INFO(vl::parsing::json::JsonLiteral::JsonValue) - ADD_TYPE_INFO(vl::parsing::json::JsonString) - ADD_TYPE_INFO(vl::parsing::json::JsonNumber) - ADD_TYPE_INFO(vl::parsing::json::JsonArray) - ADD_TYPE_INFO(vl::parsing::json::JsonObjectField) - ADD_TYPE_INFO(vl::parsing::json::JsonObject) - ADD_TYPE_INFO(vl::parsing::json::JsonNode::IVisitor) - } - - void Unload(ITypeManager* manager) - { - } - }; -#endif - - bool JsonLoadTypes() - { -#ifndef VCZH_DEBUG_NO_REFLECTION - ITypeManager* manager=GetGlobalTypeManager(); - if(manager) - { - Ptr loader=new JsonTypeLoader; - return manager->AddTypeLoader(loader); - } -#endif - return false; - } - } - } -} - -/*********************************************************************** -PARSING\JSON\PARSINGJSON_PARSER.CPP -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Parser::ParsingJson.parser.txt - -This file is generated by: Vczh Parser Generator -***********************************************************************/ - - -namespace vl -{ - namespace parsing - { - namespace json - { -/*********************************************************************** -ParserText -***********************************************************************/ - -const wchar_t parserTextBuffer[] = -L"\r\n" L"" -L"\r\n" L"//////////////////////////////////////////////////////////////////" -L"\r\n" L"// AST" -L"\r\n" L"//////////////////////////////////////////////////////////////////" -L"\r\n" L"" -L"\r\n" L"class Node" -L"\r\n" L"{" -L"\r\n" L"}" -L"\r\n" L"" -L"\r\n" L"class Literal:Node" -L"\r\n" L"{" -L"\r\n" L"\tenum Value" -L"\r\n" L"\t{" -L"\r\n" L"\t\tTrue," -L"\r\n" L"\t\tFalse," -L"\r\n" L"\t\tNull," -L"\r\n" L"\t}" -L"\r\n" L"" -L"\r\n" L"\tValue value;" -L"\r\n" L"}" -L"\r\n" L"" -L"\r\n" L"class String:Node" -L"\r\n" L"{" -L"\r\n" L"\ttoken content(JsonUnescapingString)\t\t\t\t@Color(\"String\");" -L"\r\n" L"}" -L"\r\n" L"" -L"\r\n" L"class Number:Node" -L"\r\n" L"{" -L"\r\n" L"\ttoken content;" -L"\r\n" L"}" -L"\r\n" L"" -L"\r\n" L"class Array:Node" -L"\r\n" L"{" -L"\r\n" L"\tNode[] items;" -L"\r\n" L"}" -L"\r\n" L"" -L"\r\n" L"class ObjectField:Node" -L"\r\n" L"{" -L"\r\n" L"\ttoken name(JsonUnescapingString)\t\t\t\t@Color(\"AttName\");" -L"\r\n" L"\tNode value;" -L"\r\n" L"}" -L"\r\n" L"" -L"\r\n" L"class Object:Node" -L"\r\n" L"{" -L"\r\n" L"\tObjectField[] fields;" -L"\r\n" L"}" -L"\r\n" L"" -L"\r\n" L"//////////////////////////////////////////////////////////////////" -L"\r\n" L"// Lexer" -L"\r\n" L"//////////////////////////////////////////////////////////////////" -L"\r\n" L"" -L"\r\n" L"token TRUEVALUE = \"true\"\t\t\t\t\t\t\t@Color(\"Keyword\");" -L"\r\n" L"token FALSEVALUE = \"false\"\t\t\t\t\t\t\t@Color(\"Keyword\");" -L"\r\n" L"token NULLVALUE = \"null\"\t\t\t\t\t\t\t@Color(\"Keyword\");" -L"\r\n" L"token OBJOPEN = \"\\{\"\t\t\t\t\t\t\t\t@Color(\"Boundary\");" -L"\r\n" L"token OBJCLOSE = \"\\}\"\t\t\t\t\t\t\t\t@Color(\"Boundary\");" -L"\r\n" L"token ARROPEN = \"\\[\"\t\t\t\t\t\t\t\t@Color(\"Boundary\");" -L"\r\n" L"token ARRCLOSE = \"\\]\"\t\t\t\t\t\t\t\t@Color(\"Boundary\");" -L"\r\n" L"token COMMA = \",\";" -L"\r\n" L"token COLON = \":\";" -L"\r\n" L"token NUMBER = \"[\\-]?\\d+(.\\d+)?([eE][+\\-]?\\d+)?\"\t@Color(\"Number\");" -L"\r\n" L"token STRING = \"\"\"([^\\\\\"\"]|\\\\[^u]|\\\\u\\d{4})*\"\"\"\t\t@ContextColor();" -L"\r\n" L"" -L"\r\n" L"discardtoken SPACE = \"\\s+\";" -L"\r\n" L"" -L"\r\n" L"//////////////////////////////////////////////////////////////////" -L"\r\n" L"// Rules" -L"\r\n" L"//////////////////////////////////////////////////////////////////" -L"\r\n" L"" -L"\r\n" L"rule Node JLiteral" -L"\r\n" L"\t= STRING:content as String" -L"\r\n" L"\t= NUMBER:content as Number" -L"\r\n" L"\t= \"true\" as Literal with {value = \"True\"}" -L"\r\n" L"\t= \"false\" as Literal with {value = \"False\"}" -L"\r\n" L"\t= \"null\" as Literal with {value = \"Null\"}" -L"\r\n" L"\t;" -L"\r\n" L"" -L"\r\n" L"rule ObjectField JField" -L"\r\n" L"\t= STRING:name \":\" JValue:value as ObjectField" -L"\r\n" L"\t;" -L"\r\n" L"" -L"\r\n" L"rule Object JObject" -L"\r\n" L"\t= \"{\" [JField:fields {\",\" JField:fields} ] \"}\" as Object" -L"\r\n" L"\t;" -L"\r\n" L"" -L"\r\n" L"rule Array JArray" -L"\r\n" L"\t= \"[\" [JValue:items {\",\" JValue:items} ] \"]\" as Array" -L"\r\n" L"\t;" -L"\r\n" L"" -L"\r\n" L"rule Node JValue" -L"\r\n" L"\t= !JLiteral" -L"\r\n" L"\t= !JObject" -L"\r\n" L"\t= !JArray" -L"\r\n" L"\t;" -L"\r\n" L"" -L"\r\n" L"rule Node JRoot" -L"\r\n" L"\t= !JObject" -L"\r\n" L"\t= !JArray" -L"\r\n" L"\t;" -; - - vl::WString JsonGetParserTextBuffer() - { - return parserTextBuffer; - } - -/*********************************************************************** -SerializedTable -***********************************************************************/ - -const vint parserBufferLength = 3779; // 17748 bytes before compressing -const vint parserBufferBlock = 1024; -const vint parserBufferRemain = 707; -const vint parserBufferRows = 4; -const char* parserBuffer[] = { -"\x00\x0B\x00\x02\x83\x80\x07\x7D\x00\x82\x03\xFF\x45\x08\x82\x83\x86\x81\x21\x6F\x6C\x2F\x32\x37\x84\x86\x02\x86\x00\x17\x82\x93\x24\x3A\x39\x34\x37\x67\x06\x98\x8A\x88\x8E\x84\x00\x88\x12\x94\x98\x87\x0B\x93\x81\x20\x3A\x74\x4E\x21\x2D\x35\x32\x90\x86\x92\x0C\xA6\xA8\x93\x85\x88\x84\x96\x86\x3F\x80\x0B\x25\x39\x3F\x3B\x88\x32\x36\x88\xB8\x88\x8A\x99\x88\x9F\x96\x40\x83\x83\xA5\xA7\xA1\xA4\x83\xA5\x04\xCD\xA9\x9D\x94\x81\xA1\xAE\xA9\x44\xC6\xB2\x28\xAC\xA9\x86\x93\xAC\x03\xBB\xAA\x8C\x88\x00\x8D\xB6\x81\x42\x6F\x35\x2E\x34\x31\x32\x39\x3C\x56\xE6\xA5\x89\xBE\xA3\xB4\x85\xB7\x7F\x83\xB1\xB3\xB5\xBF\xB9\xBC\x81\x58\x83\x9A\xAF\xAC\xB6\xB6\xC0\xB9\x74\xF6\xB8\xA5\xB8\xC7\xB2\xC4\xBE\x5B\x8E\xCD\xD0\xB0\xCD\xC3\xC9\x91\x96\x8D\x98\xCC\xC8\x82\x8D\xD3\x81\x4E\x75\x2D\x22\x35\x32\x3B\xC3\x82\x0C\x18\xB1\xCF\x8F\x36\x34\x3B\x32\x78\x74\x2A\xB8\x80\x06\xAF\xCB\x9C\x2E\xF2\x32\x21\x38\xBF\x7E\xE3\xE3\xFF\x3E\xC2\x81\xAC\x21\x37\xDB\xE1\x6C\x48\xC8\xE4\x08\x8C\xEA\x80\x27\x6F\x64\x35\x92\xE6\xE6\xD0\x82\xD3\xA9\xAB\xED\xDC\xED\xE8\x8E\xD3\x27\x62\x6A\x25\x23\x34\x3C\xF3\x7F\x80\x0C\xF0\xC0\x08\xFA\xF4\xF6\x23\x34\x65\x6C\x08\xA4\xFE\xEB\x82\xD2\x8E\x1E\x60\x4E\x7A\x72\x00\x21\x65\x81\x70\xC3\x79\x16\x82\x49\xCE\x65\x1D\x1B\x1C\x03\x90\x50\x01\x73\xCF\x61\x1C\x1B\x82\x03\x76\x16\x85\x1D\xDB\x5C\x7D\x7E\x40\xE0\x6A\x6C\x6A\x1C\x04\x81\x53\x19\x6D\xB7\x76\x6E\x7B\x87\x19\x43\x44\x7F\x7A\x74\x2C\x86\x6A\x19\xF8\x7A\x70\x84\x79\xF2\x44\x42\x7F\x8B\xF6\x75\x84\x1A\x75\x08\x40\x9E\x1B\x4C\x65\x14\x60\x40\x46\x3B\xA9\x70\x8F\x7D\xF9\x64\x18\x86\x40\x1A\xAC\x1C\x87\x8A\xE6\x43\x40\x83\x47\x67\x25\x83\x43\x89\xB6\x65\x16\x6C\x6F\x0F\x18\x44\x08\x46\x61\xBC\x66\x9A\x52\xEE\x64\x77\x9B\x4D\x69\x9C\x7B\x98\x9A\x6D\x88\x7F\x9B\x55\x71\x88\x79\x00\x46\x77\x82\x44\x16\x14\x55\x05\x16\x15\x10\x4C\x3D\x90\x90\x41\x40\x9D\x4C\x84\x6F\x02\x18\x4A\x02\xA2\x03\x46\x10\xA3\x14\x7E\x80\xAD\x9F\x93\x00\x26\x16\x87\x1C\x45\x98\x43\x00\x9E\x9C\x97\x75\x14\x13\x4C\x3F\x91\xA1\x11\x83\x83\x42\x91\x1D\x6C\x2C\x19\xA0\x43\xA5\x8B\x72\x87\x13\x42\x0A\x1F\x10\x14\x45\x0E\x1B\xA8\x42\xB7\x9C\x1B\x1F\xA6\xC0\x5B\x61\x62\x40\xB0\x8A\x13\x10\x13\x4F\x10\xA7\xAC\x41\xB9\xBD\x1D\xA9\x8B\x51\x4D\xB0\x01\x10\x52\x12\x13\xAD\xAD\xC7\x83\x49\xAF\x16\x06\x84\x80\x60\x41\x80\x50\xB2\x17\xB0\xC5\x85\x15\xB6\x40\xB9\x9D\x1C\x8B\xB6\xBF\x4C\x59\x5B\x13\x4D\x0D\x11\x12\x91\x3D\x6C\x04\x82\x7B\x94\x83\x1F\x10\xB1\x4E\x30\xB3\x42\x0E\xE8\x88\x6C\x7D\x95\x9E\x8D\x12\x11\x11\x52\x1F\x08\x46\xC1\x02\x5B\x1C\x15\x0B\x5D\x3F\x0C\x14\x19\x2B\x28\x0E\x0B\xC3\x2B\x29\x0F\x0C\x0A\x5B\x25\x15\x11\x17\x5B\x2B\x0B\xC1\xC3\x14\xD6\xC9\x9C\x42\x23\xDF\x70\xC0\x00\x53\x3B\x99\x12\x13\x47\x1B\x08\x46\xCB\x02\x62\x08\xC6\x17\x5C\x1C\x12\x09\x17\x7C\x35\xCB\x16\x17\x75\x38\xC5\xCD\x1D\x0F\xFB\x14\x0D\x1F\x29\x2A\x02\x0B\xA2\x0C\x48\xD8\x42\x91\x94\x93\x10\x15\x10\x43\x05\x1C\xAC\x42\x53\xDC\x13\x1F\x0A\x39\x89\x44\x7B\x98\x16\x67\xCA\x10\x93\xFA\x50\x08\x46\xD8\x02\x5F\xDE\x8E\x0B\x52\x2F\x1F\x18\x1D\x1C\x76\x54\x1D\xD6\x02\x72\x70\x10\x08\x24\x3C\x06\xD9\x93\x3E\x32\x83\x43\xDD\xFA\x73\x68\x42\xDF\x7C\xE4\x1E\x09\xDB\x72\x34\x1A\xD0\x41\x4A\xF3\xD6\xDC\xD8\x64\x39\xDE\xD4\xE3\xFD\x80\x00\x61\xE0\x2E\x31\x0A\x0C\x46\x97\xC2\x4B\xE2\x8F\x3E\x3A\x00\x09\xCA\x52\x2B\xC7\x10\x08\x9E\xC3\x94\x4F\xDC\x22\x3A\x02\x08\x08\x4A\x16\x1B\x85\x19\xA4\xE0\x01\x94\x87\x20\x21\x13\x1C\x08\x3C\xB4\x1C\xE2\xDE\x65\xD0\xEA\x64\x00\x94\xF2\x09\xE4\x42\xC3\xDB\xE8\xDE\xE7\xA0\xE2\xE1\xEE\xE9\xB0\xE9\xE2\x0B\xDC\xAD\xEF\xE1\xEF\xEC\xB0\xF6\xE8\xEE\x92\x3D\x8D\x91\xE7\xE4\x14\xAD\x66\x87\xE1\x03\x4A\xDA\x11\xF7\xD0\x55\xEA\x3C\x46\xE7\xDA\xE3\xF9\x83\xD0\x5D\xE0\x0A\x08\x6E\x28\xAC\x1B\xEA\xD6\xE4\xF6\x87\xDC\x77\x0E\x78\x18\x08\x7B\x32\xE2\xF5\x0F\xEF\x69\x35\xAA\x2B\x7D\x0F\x06\x0A\x06\x6E\xF6\x6C\x0E\xFB\x22\x06\x52\x36\x18\x54\x7E\xB7\x69\x80\xFE\x7A\x7C\x7E\xFF\x52\x48\x76\x00\x82\x06\x11\x17\x55\x0C\x02\x86\x80\x81\xEC\x76\x42\xFB\x4E\x05\x0A\x81\x44\x61\x76\x5C\x49\x44\x1D\x35\x77\x77\xF0\x23\x40\x08\x1F\x8B\x7D\x85\x0A\x88\x78\x95\x6C\x60\x85\x28\x5E\x4B\x0A\xD6\x77\x4A\x90\x30\x87\x80\x32\x9E\x78\x0D\xEF\x76\x51", -"\x0E\xAC\x80\x04\x12\x80\x05\xFE\x74\x0B\x7F\xFE\x54\x78\x04\x19\x94\x0A\x1C\x1C\x44\x80\x2D\x65\x69\x77\x25\x63\x23\xC8\x32\x58\x7A\x3A\x15\x71\x09\x18\x20\x8E\xFA\x39\x7B\x81\x3D\x0F\x78\x04\x5B\x0C\x74\xE3\x31\x74\x47\x26\x77\x75\x7F\x22\x0C\x07\xEA\x01\x7C\x8C\x1F\x77\x75\x0F\x20\x1D\x0B\xFB\x7D\x00\x83\xEB\x75\x39\x46\x5E\x61\x0A\x70\x44\x3B\x7B\xBD\x42\x91\x41\x95\x65\x08\x46\x0A\x9A\x7D\x43\x84\x3B\x81\x5B\x07\x8D\x1A\xD1\x77\x83\xD8\x4D\x47\x41\x15\x91\x8F\x1C\xAE\x75\x92\xCF\x57\x97\x8E\x79\x8F\x7D\x17\x7D\x8E\x91\x3C\x05\x95\x6C\x09\x84\x6C\x42\x2A\x91\x89\xF2\x69\x6B\x6D\x45\x14\x2D\x03\x18\x23\x96\x81\x35\x6D\x95\x22\x80\x04\x10\x3C\x70\x78\x4E\x9C\x47\x94\xBD\x8F\x75\xE5\x3D\x08\x22\x62\xAA\x7E\x97\x65\x0E\x7D\x08\x4A\x05\x95\x1F\xB6\x68\x99\xCA\x98\x94\x1B\x4E\x94\x92\x0E\x51\x99\x77\x40\x16\x88\xF0\x58\x8D\x53\x6D\x9D\x8E\x05\x32\x02\x8C\x42\x62\x96\x6E\x32\x9E\x72\x04\x66\x88\x8E\x1A\xBE\x45\x8E\x37\x99\x92\x8E\xEB\x8D\x49\x3B\xB6\x40\x04\x3C\xBA\x8A\x04\x7C\x87\x88\x36\xBC\x9C\x99\x41\xA6\x97\x77\xFD\x88\x93\x0C\x0C\x98\x20\x82\xB6\x6D\x94\x90\x8B\x77\x24\xC8\x96\x93\xDB\x18\x90\x8E\xF0\x95\x98\xEC\x1E\x9E\xA0\x50\xB7\x9B\x94\x47\x8D\x98\x3F\xBE\x7E\x56\xCA\x73\x03\x78\x04\x25\x79\xE0\x6E\x79\x79\x1B\xA5\x74\x48\xEF\x6A\x74\xEB\x0C\xAE\x73\x27\x96\x79\x77\x8C\x7B\x95\x20\xFE\x90\x99\x80\x84\x38\x9C\x8C\x18\x21\x4E\x8D\x9E\x9F\x84\xAA\x9A\xA2\x0D\xAE\x43\x1C\x73\x60\xA3\x4D\x92\x7C\xA2\x42\xB5\x9D\x28\xB7\x64\x94\x7F\xB1\x80\xA1\xE7\x91\x93\x4F\xAC\xA0\x05\x4F\xBA\x95\xA8\x2B\xA7\xA9\x55\x95\xAA\xA9\x8B\x8D\xA9\x41\xFC\x88\x9A\x03\x18\x23\xAD\xB2\x48\x98\x6D\x6A\x74\x0D\x2C\xE4\x00\x6F\x23\x76\x97\x99\xAF\x7E\x06\x2E\xDA\x9C\x8B\x3F\xA5\x48\x21\x77\xB5\xAC\x8C\x68\xA0\x96\xBA\x3E\x6C\x20\x7E\x77\x94\x19\xBA\x94\x52\x25\x2F\x94\x0E\x74\xA7\xB1\xE5\x25\x08\x22\xC6\xAA\x7F\xB0\xD7\x9D\x88\x35\x90\xBE\x73\x65\x9A\xA3\xA6\x09\x45\xAC\x42\x1A\xB6\xA7\x3C\x3C\xAA\xAD\x74\x2D\xAE\x7C\x37\x98\xA0\x5D\x9B\xA6\x47\x9A\xA4\x20\x67\x8C\x7F\xB3\xB5\xA2\xB3\x20\xB7\x8C\x72\x5C\xD9\x92\x42\xBD\xAC\x39\x8B\x02\x3B\x89\xEE\x2E\x05\x06\x4A\x18\x26\xB7\x63\x9D\x89\x19\x8A\xA1\x9E\xFD\x33\x9C\x0C\xB7\x60\x08\x56\xF4\x8E\x73\x36\xB4\x9E\x9E\x7B\x9D\x8D\xEE\x31\x86\x9D\xF7\x69\x9B\x92\x6B\x8D\xBA\x1D\xC4\xAF\x7D\x88\x99\xB8\x04\xCE\xA8\xB9\x57\xD1\xBA\x9F\x2E\xBC\x9D\x94\x35\xA5\x96\x0B\x34\x04\xA0\x82\x06\xA5\xB3\x3E\xAB\xA2\x56\xD6\xA5\xA8\xE8\x54\xAE\xAA\xD0\xAC\xA9\x46\xFE\x95\xB1\xC3\xB5\x90\x21\xFF\xA6\xB1\x5A\xAD\xB4\x2E\xF0\x42\x22\x69\xB7\x90\xB3\x5C\xB5\xBC\x9A\x86\x3A\xB7\x9B\x33\x02\x9C\x41\x64\x96\xB6\x3A\x03\xBF\xA7\xDF\xA1\xBF\x1B\xDD\xB7\x8C\xE6\xA0\xBE\x8E\xE3\xB8\x9E\x74\xDD\x84\xAF\xDC\x51\x00\x23\x27\xD7\x8B\x37\x87\xB4\x70\x3A\x3F\xAB\x20\x7E\x73\x6E\x60\xC2\xB5\xC5\x2E\xBF\xBC\x20\x01\xDB\xB5\x8B\xAF\xB2\x20\xC5\x55\xC6\x07\x35\xA9\x82\x04\x18\x23\xC8\x54\xA1\x84\x0D\x9F\xAD\xC7\x8D\x83\x2F\xBE\x19\xE0\x83\x86\x40\xC0\xA1\x02\xA9\xB3\x20\xCE\x89\x83\x70\x74\x0E\x6F\x8B\x82\x21\xC6\x10\x0F\xCA\x88\x8E\x7D\x69\xD9\x25\x9A\x94\x82\x2C\x92\xBD\x2C\xD9\xC9\xE1\x3C\xC0\x00\x27\xF0\xBF\xBC\xFE\x9B\xC8\x00\x00\x7A\xBD\x16\xC6\xC0\x00\x89\x7E\xCB\x9B\xDE\x68\x99\x32\xC3\x24\x95\x67\xA9\xCE\xDB\x6C\xCE\xCC\x68\xA1\xAF\x75\x72\xC0\x73\x59\xF6\xCC\x51\x1E\xFA\xC8\x9A\xFD\xA9\xAF\x5D\x84\x29\xAE\xC5\x82\xD5\x70\x77\xD9\xCD\x82\xE9\xAE\x07\x48\xEB\x6C\xCD\x02\xCB\x6C\x96\xEE\x68\xB6\x00\x23\x66\xC7\x90\xA7\xB6\xF6\x00\xAC\xB4\x1A\x20\xA3\x5F\x03\x26\x7A\x7E\x24\xA6\x87\xD1\x67\xA4\x26\x29\xA6\xA9\x27\x96\x84\x77\x97\x9D\x89\xA6\x35\xDF\x8D\xA9\x8F\xCF\x8F\xF5\x92\xC3\x20\x14\xD5\xB8\x3A\xC4\xBE\xC2\x0D\xEF\x9B\x8E\x19\xC0\xC5\x7E\xF9\x9E\xD7\x3F\x80\x09\xC8\x47\xD9\xD3\xDE\x57\xC2\x07\xF4\x48\x26\xDB\x5F\xCD\x7F\x39\x8D\x8F\x81\x23\x89\x82\x89\x14\x8E\x8B\xFF\x6F\x7B\x82\x07\x86\x8D\x0F\xD4\x89\x83\x02\xF1\x73\x80\x73\xC7\xC8\xDD\x4C\x95\x83\x13\x99\x82\x81\xF9\x75\x99\xDE\x47\xC3\x85\x09\x83\x62\x0A\x1C\x9D\x4E\x36\x47\x8E\x85\x6B\x00\xE0\xCB\x1A\xA1\x76\xA4\x20\x09\x86\x0E\xC7\x8D\x87\x33\x0C\xE0\xCC\xE7\x85\x89\x1F\xE7\xDB\x89\x26\xBC\xD0\x83\xEF\x72\x88\x15\xFF\xD0\xCF\x04\x69\xBE\x9F\xBC\xAD\xBF\x40\x6F\xB0\xAB\xF7", -"\x52\xAA\xBE\xBB\xD4\xBC\x87\xD9\xA1\xE6\xAE\xB9\xB8\xA3\xD6\x77\xB2\x98\xA7\x3D\x76\x1F\x6C\xC8\xA6\x3E\x53\x4E\xD6\x5C\x31\xD8\x18\x7C\x91\x77\xBC\x36\x03\x48\x64\x38\xDB\x19\x8B\x58\x48\xD8\x3A\x38\x6F\x18\x0B\xE8\x0F\x58\xB4\x38\x94\x45\x94\x6F\x1A\x05\xEA\xE9\x07\xD7\x82\x4F\xE8\x35\x76\x65\x0C\x36\x0E\x1D\xE8\x39\x9E\xD4\x0D\xD8\xD7\x33\xEC\xDE\x1E\x07\xEC\xC7\x3C\x03\xB8\x2F\x3F\x1E\xDE\x06\x4A\xE8\x78\xF9\xEF\x48\x46\x4F\x1E\x2A\xE4\x5A\xEF\x0C\x3A\x5E\xD0\xEB\xE0\x00\xE6\x7C\x32\xD5\xFA\x2F\x4C\xDD\xF2\xC3\x6A\xC0\xF9\xEC\xEE\x84\xEE\xF0\x00\x4B\x56\x41\xC6\xCE\xF0\xF1\x4E\x58\x21\x07\x12\xFE\x3E\x3E\xEF\x73\x59\xBC\x34\x50\xF5\x04\xF2\xE5\x32\x0D\xEA\x88\x79\xFA\x99\x02\xBC\x37\xF4\xE8\x34\xEE\x40\xA0\xF8\xEC\xE5\x9A\x5C\xF2\x10\x4F\x76\x47\x06\x5B\xF1\xED\xDF\xEC\x43\xD8\xFD\x52\x5D\x50\x4F\x74\xA5\x6D\xD8\x53\xD6\xD6\x41\xF5\x12\x4B\xF7\xEF\x5C\x5B\xDB\x23\xF4\xEC\x45\xBE\xF3\x4F\xEC\x8C\x26\xF2\xC0\xD8\xF1\xF7\xB5\xEC\x58\xCF\xC1\x90\xEC\xBC\xE2\xF7\xF3\xD5\x28\x36\xFC\x46\xFC\x0C\xE4\xCE\x5A\xF9\xBE\x4C\xFA\x91\xB3\x84\xEE\x02\x46\x41\xEF\xE3\x47\x40\xF5\xD9\xF7\xFA\xCD\xF4\xFE\xF3\x17\x85\x20\xDF\xA5\xDC\x44\xF8\xFB\x2B\xFE\xBB\x77\x7B\x4D\x28\x7D\x01\x8B\x73\x12\x59\x10\x7C\x7B\x64\x02\x11\x7D\x6F\x23\x7D\x54\x37\x7F\x06\x8C\x38\x04\x8C\x79\xBC\x79\x29\x42\x7A\x4D\x12\x7F\x25\xCB\x73\x10\xDC\x37\x64\x79\x7C\x4B\x0A\x72\x07\xAC\x72\x65\xCE\x7C\x77\x7E\x73\x79\xD9\x7E\x80\x04\x15\x7D\x7A\x75\x7F\x0C\x1A\x7B\x14\x88\x7F\x1C\x27\x77\x12\x2F\x15\x02\x19\x81\x74\x03\x82\x1D\x58\x7E\x73\x2C\x4B\x15\x7A\x83\xBF\x20\x3C\xAB\x74\x77\x46\x24\x20\xD9\x7A\x7F\x23\x11\x7F\x91\x36\x77\xF6\x7C\x10\xF1\x7C\x22\x30\x82\x79\xE4\x7C\x82\x47\x85\x81\x92\x74\x77\x91\x35\x6A\x47\x8A\x14\x26\x88\x11\xF1\x7E\x7F\xBF\x78\x16\xB5\x75\x74\xEC\x14\x83\xAC\x21\x7E\x02\x16\x78\x27\x36\x32\x3D\x7D\x24\x57\x1C\x77\x91\x7E\x78\x2A\x8D\x79\x05\x8B\x7D\x9D\x53\x81\x92\x75\x81\x0C\x89\x2E\x62\x80\x00\xA3\x78\x86\x00\x05\x7A\xE4\x76\x7E\x3E\x13\x10\x3C\x8A\x7E\x41\x82\x4D\xAF\x70\x88\x92\x73\x87\xB6\x75\x87\x6C\x80\x3C\xA5\x48\x87\x97\x72\x83\x65\x0B\x87\xA2\x1F\x7B\xD4\x33\x7C\x1C\x43\x88\x78\x7A\x7A\x1E\x8B\x81\x02\x1D\x81\xEC\x7C\x77\xD0\x79\x82\xFF\x7B\x7D\x79\x87\x75\x0A\x2D\x84\x31\x86\x80\xC8\x48\x89\xF2\x70\x7C\x7E\x80\x7E\x67\x87\x1D\xE3\x74\x82\x33\x44\x88\x36\x83\x21\xA1\x89\x7E\x1C\x8D\x7C\xA5\x83\x12\xEE\x79\x7D\xF1\x76\x20\xFD\x78\x77\x25\x78\x75\xAE\x8B\x8A\xB0\x8F\x3A\x48\x87\x13\xFC\x76\x8C\xA9\x81\x89\xCE\x86\x87\x93\x8D\x8C\x95\x8F\x8C\x17\x44\x77\xDA\x6B\x85\x7B\x73\x12\x0A\x88\x82\xB5\x7E\x88\xDA\x77\x8D\x91\x87\x87\xDA\x86\x7D\x96\x86\x86\x85\x8E\x2C\x38\x80\x84\x88\x82\x4D\x1F\x87\x32\x21\x82\x8F\xC1\x8B\x7E\x42\x44\x77\x27\x82\x8B\xBC\x16\x8E\xC9\x82\x74\xCB\x8D\x8A\x2F\x80\x81\x76\x88\x4C\xEE\x8D\x8B\xBD\x81\x8F\xA2\x82\x39\xC2\x88\x7A\xCA\x87\x32\x3F\x8D\x90\xA4\x80\x91\x42\x74\x84\xB4\x40\x8E\x4A\x1C\x82\xFF\x01\x7F\x72\x6C\x84\x0C\x13\x01\x5E\x8B\x86\x03\x12\x92\x90\x84\x87\xDC\x7C\x21\x5F\x85\x8D\xE9\x2F\x49\x87\x7C\x8A\x1D\x92\x1B\x78\x76\x24\x2C\x2F\x84\x24\x9C\x8E\xDC\x8A\x92\xDE\x79\x8A\x2E\x97\x93\xDA\x7D\x59\x31\x91\x1F\x33\x94\x7B\x4E\x8E\x93\x54\x81\x91\x39\x96\x81\x73\x2F\x7D\xF9\x7E\x93\xA6\x11\x38\x73\x28\x91\x0C\x17\x82\x79\x79\x90\x6B\x27\x74\x5D\x4C\x1B\x64\x8D\x1E\xF1\x71\x94\x78\x53\x94\x0C\x18\x30\x0F\x87\x92\x8F\x83\x1F\x59\x95\x83\x03\x11\x14\x15\x6C\x22\x62\x92\x79\x5B\x97\x94\xB5\x79\x76\x5E\x98\x88\x6F\x26\x24\x51\x83\x10\x70\x9D\x83\x27\x38\x74\x68\x9E\x2A\x2A\x6F\x47\x50\x89\x7D\x6F\x9A\x91\xD6\x88\x92\x07\x8A\x78\x7C\x76\x24\x7E\x60\x78\x56\x97\x26\x59\x7E\x4F\x2F\x96\x80\xA5\x43\x97\x09\x11\x7F\x93\x6B\x26\x46\x2D\x96\x78\x99\x7D\x8F\x99\x20\x91\x98\x8D\xFE\x4C\x96\x06\x99\x8E\xA5\x49\x97\x92\x72\x97\x4A\x80\x96\x08\x17\x97\x02\x16\x9A\x6B\x2D\x99\xC4\x1F\x99\xA4\x91\x9A\xEB\x8D\x82\xAC\x8E\x9A\x38\x97\x90\xD0\x88\x98\xE1\x8C\x10\x29\x6C\x79\x8D\x96\x26\x3F\x7F\x6B\x41\x7E\x94\x7B\x3C\x38\x94\x98\x18\xF1\x75\x64\x73\x26\x24\x15\x04\x94\x9C\x73\x9C\x7F\x4C\x38\xB2\x96\x98\xBB\x38\x11\xCF\x94\x96\x3F\x9C\x38\x2B\x9B\x73\x91\x8A\x61\x5A\x9C\x60\x5D\x49\x9C\x00\x0C\x9C\x75\x9C\x92\xAD\x99\x7D", -"\xD2\x9B\x24\xC5\x9E\x9D\xD6\x9E\x23\x2C\x2F\x7E\x48\x96\x87\xDC\x93\x9F\xDF\x96\x47\xE1\x9E\x2C\x15\x65\x7B\xDE\x8D\x68\x84\x91\x8D\x4A\x1D\x56\x26\x9F\x9F\x04\xAF\x86\xBD\x98\x10\x14\x05\xA0\x0A\xAE\x78\x58\x8D\x4D\x04\xA4\x77\x6D\x59\x9D\x0B\xA8\x80\x23\x11\x87\x80\x76\x8E\x03\xA8\x8E\x86\x99\x8D\x05\x9A\x9D\x4F\x91\x8B\x3B\x9A\x89\xB6\x81\x24\x03\x12\x88\xBA\x86\x91\x73\x20\x8A\xBB\x84\x91\x0F\x9E\x7A\x7C\x70\x7B\xA8\x81\x86\x25\x93\x9A\x1B\xAC\x5F\xB5\x95\x8F\x49\x92\x8B\x4C\x9C\x21\x9C\x8E\x6E\x9E\x87\x81\xC9\x7F\x8B\x41\x83\x8F\x09\x4F\x7C\x8C\x82\x87\xE8\x90\x00\x19\xAB\x8D\xA0\x99\x20\x94\x89\x9B\xE9\x80\xA2\x42\x7B\xA3\x97\x80\x88\xFD\x6F\xA3\x29\xA1\xA4\x2B\xA0\x8C\xA3\x8D\xA2\x16\x2D\x7E\x49\xA0\x86\xB4\x84\x10\x4B\xA0\xA5\x35\xAE\xA4\x37\xA6\x9F\x86\x98\x4C\x00\xA7\x15\xD3\x85\x7B\xC7\x88\x11\x65\xA6\x9B\x92\x96\xA3\x1D\xAF\x8A\xBA\x9D\x94\x6D\xA9\x10\xE3\x8E\x8F\x47\xA9\x89\x08\x13\xA7\x38\xAD\xA4\xCC\x87\xA7\x1A\xA5\x96\x12\x51\x9C\x18\x89\x43\x1A\x8C\xA5\x0E\x9A\x8F\xD0\x13\xA8\x91\x87\x8F\x2C\xA0\xA9\x5F\xAD\x85\xB7\x8C\x79\x18\xA4\xA3\x88\xAC\xA1\xAB\x9C\xA9\x3F\x98\x90\x9F\x82\x21\x0C\x9E\xA8\x15\x91\xA9\x6A\xA5\x96\x13\x96\xAA\x5E\xA5\x7E\x84\x9C\x8F\x23\x90\xA7\x49\xA2\xA1\x6E\x92\x9E\x7F\x41\x9C\x84\x7A\x86\xEE\x98\xA8\xC8\x9C\x77\xBC\x17\x01\x13\xA0\x78\x60\xA2\xA3\x0B\xA4\x77\xBC\x19\x01\xC1\xA7\x91\x70\x8F\xA7\x7A\x71\x7F\x3A\xA9\x8A\x7F\x89\xA9\x26\xAB\x83\x42\xAF\x26\x2A\xA8\xA2\x74\x99\x8F\x42\x85\x82\xA0\x1C\xAC\x62\xA4\x28\x21\xA4\x8B\x9B\x89\x8A\xC4\x76\x7A\x27\xA8\xAA\x40\xA7\x7E\xD5\xAA\xAD\x44\xAC\xAD\x37\x17\x8A\xB2\xA9\xA9\x6F\x24\xA5\x84\x77\xA5\xE7\xA7\x7C\xA3\xAA\xAE\x5B\xA3\xA4\xDA\xA4\x8F\x5C\x82\x8E\xDE\xA8\x77\xF1\x7A\xA8\xA4\xAC\xA8\x39\x85\xA9\xDB\xAB\xAF\x6F\x20\x82\x22\x2D\x1A\xF8\x8D\xA5\x96\xA1\x1D\x98\xA4\xA2\xF1\xAB\x34\xF9\xAF\x8E\x00\x05\xAA\xFC\xA0\xB1\x09\xB8\xAD\x57\x92\x91\x1D\x18\x25\x0F\xBF\xA8\x1D\xBE\xA2\x23\x1C\x1B\x30\x39\xAC\x8F\x7B\x7F\x3E\x9F\x9F\xC6\xA9\xA6\x2A\xB4\xA1\x37\x16\xA1\x7A\x7C\x82\x4F\xA4\xA7\x79\xAD\x7B\xE1\xAD\x87\xD1\xA4\xB1\x81\x83\x45\xE6\xA4\xAD\x0A\xBB\x26\xD7\xA8\xAE\x1B\xB4\xB2\x8A\x8F\xA2\x01\xB2\x74\x36\xB0\xB3\x7A\x99\xA3\x3B\xB9\x2E\xE3\xAF\x7B\xE5\xA8\xA5\xD6\xAA\xA5\x1E\xBC\xB1\xED\xA3\x8C\xEF\xAB\xB4\x73\x2D\xB4\x86\xAC\xA4\x51\xA3\xA2\xF3\xA0\xAD\x64\xB6\x2A\xE2\x79\x2A\x56\xB4\xB4\x58\xB6\xB4\xD9\xAC\xB1\x49\xB4\x8C\x61\xAA\x9A\x7D\x84\x10\xAC\x98\xB3\x63\xB9\x7F\x74\x7F\xA6\xC0\x99\xA4\x77\xB2\xA9\x6B\xAB\x9B\x7B\xA8\x18\x7D\xA9\x7D\x60\xBF\xA9\x1E\xAB\x37\xA2\xA9\xAE\x18\xBA\xB1\x6F\xB8\xB4\x87\x8F\xB1\x3B\x74\xA9\xAC\xA1\xB1\xB0\xA2\xAF\x8E\x77\xB8\x76\xB0\xAA\x1F\xAF\x3A\x04\xB0\x8F\x06\xB3\xB2\xA7\xA8\xAF\x02\x90\xB2\x01\x27\x06\xA2\xBD\xAA\x2F\xB1\x96\x31\xBA\xAC\x72\xB4\xAC\x7A\x7C\x34\x07\x3C\x99\xA9\x81\x6A\x39\x8B\xB7\x2D\xB4\xB7\x7C\x83\x10\x9A\x90\x78\x69\x7D\xBA\xE0\x80", -}; - - void JsonGetParserBuffer(vl::stream::MemoryStream& stream) - { - vl::stream::MemoryStream compressedStream; - for (vint i = 0; i < parserBufferRows; i++) - { - vint size = i == parserBufferRows - 1 ? parserBufferRemain : parserBufferBlock; - compressedStream.Write((void*)parserBuffer[i], size); - } - compressedStream.SeekFromBegin(0); - vl::stream::LzwDecoder decoder; - vl::stream::DecoderStream decoderStream(compressedStream, decoder); - vl::collections::Array buffer(65536); - while (true) - { - vl::vint size = decoderStream.Read(&buffer[0], 65536); - if (size == 0) break; - stream.Write(&buffer[0], size); - } - stream.SeekFromBegin(0); - } -/*********************************************************************** -Unescaping Function Foward Declarations -***********************************************************************/ - - extern void JsonUnescapingString(vl::parsing::ParsingToken& value, const vl::collections::List& tokens); - -/*********************************************************************** -Parsing Tree Conversion Driver Implementation -***********************************************************************/ - - class JsonTreeConverter : public vl::parsing::ParsingTreeConverter - { - public: - using vl::parsing::ParsingTreeConverter::SetMember; - - bool SetMember(JsonLiteral::JsonValue& member, vl::Ptr node, const TokenList& tokens) - { - vl::Ptr token=node.Cast(); - if(token) - { - if(token->GetValue()==L"True") { member=JsonLiteral::JsonValue::True; return true; } - else if(token->GetValue()==L"False") { member=JsonLiteral::JsonValue::False; return true; } - else if(token->GetValue()==L"Null") { member=JsonLiteral::JsonValue::Null; return true; } - else { member=JsonLiteral::JsonValue::True; return false; } - } - member=JsonLiteral::JsonValue::True; - return false; - } - - void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) - { - } - - void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) - { - SetMember(tree->value, obj->GetMember(L"value"), tokens); - } - - void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) - { - if(SetMember(tree->content, obj->GetMember(L"content"), tokens)) - { - JsonUnescapingString(tree->content, tokens); - } - } - - void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) - { - SetMember(tree->content, obj->GetMember(L"content"), tokens); - } - - void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) - { - SetMember(tree->items, obj->GetMember(L"items"), tokens); - } - - void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) - { - if(SetMember(tree->name, obj->GetMember(L"name"), tokens)) - { - JsonUnescapingString(tree->name, tokens); - } - SetMember(tree->value, obj->GetMember(L"value"), tokens); - } - - void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) - { - SetMember(tree->fields, obj->GetMember(L"fields"), tokens); - } - - vl::Ptr ConvertClass(vl::Ptr obj, const TokenList& tokens)override - { - if(obj->GetType()==L"Literal") - { - vl::Ptr tree = new JsonLiteral; - vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); - Fill(tree, obj, tokens); - Fill(tree.Cast(), obj, tokens); - return tree; - } - else if(obj->GetType()==L"String") - { - vl::Ptr tree = new JsonString; - vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); - Fill(tree, obj, tokens); - Fill(tree.Cast(), obj, tokens); - return tree; - } - else if(obj->GetType()==L"Number") - { - vl::Ptr tree = new JsonNumber; - vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); - Fill(tree, obj, tokens); - Fill(tree.Cast(), obj, tokens); - return tree; - } - else if(obj->GetType()==L"Array") - { - vl::Ptr tree = new JsonArray; - vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); - Fill(tree, obj, tokens); - Fill(tree.Cast(), obj, tokens); - return tree; - } - else if(obj->GetType()==L"ObjectField") - { - vl::Ptr tree = new JsonObjectField; - vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); - Fill(tree, obj, tokens); - Fill(tree.Cast(), obj, tokens); - return tree; - } - else if(obj->GetType()==L"Object") - { - vl::Ptr tree = new JsonObject; - vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); - Fill(tree, obj, tokens); - Fill(tree.Cast(), obj, tokens); - return tree; - } - else - return 0; - } - }; - - vl::Ptr JsonConvertParsingTreeNode(vl::Ptr node, const vl::collections::List& tokens) - { - JsonTreeConverter converter; - vl::Ptr tree; - converter.SetMember(tree, node, tokens); - return tree; - } - -/*********************************************************************** -Parsing Tree Conversion Implementation -***********************************************************************/ - - vl::Ptr JsonLiteral::Convert(vl::Ptr node, const vl::collections::List& tokens) - { - return JsonConvertParsingTreeNode(node, tokens).Cast(); - } - - vl::Ptr JsonString::Convert(vl::Ptr node, const vl::collections::List& tokens) - { - return JsonConvertParsingTreeNode(node, tokens).Cast(); - } - - vl::Ptr JsonNumber::Convert(vl::Ptr node, const vl::collections::List& tokens) - { - return JsonConvertParsingTreeNode(node, tokens).Cast(); - } - - vl::Ptr JsonArray::Convert(vl::Ptr node, const vl::collections::List& tokens) - { - return JsonConvertParsingTreeNode(node, tokens).Cast(); - } - - vl::Ptr JsonObjectField::Convert(vl::Ptr node, const vl::collections::List& tokens) - { - return JsonConvertParsingTreeNode(node, tokens).Cast(); - } - - vl::Ptr JsonObject::Convert(vl::Ptr node, const vl::collections::List& tokens) - { - return JsonConvertParsingTreeNode(node, tokens).Cast(); - } - -/*********************************************************************** -Parser Function -***********************************************************************/ - - vl::Ptr JsonParseAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex) - { - vl::parsing::tabling::ParsingState state(input, table, codeIndex); - state.Reset(L"JRoot"); - vl::Ptr parser=vl::parsing::tabling::CreateStrictParser(table); - vl::Ptr node=parser->Parse(state, errors); - return node; - } - - vl::Ptr JsonParseAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::vint codeIndex) - { - vl::collections::List> errors; - return JsonParseAsParsingTreeNode(input, table, errors, codeIndex); - } - - vl::Ptr JsonParse(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex) - { - vl::parsing::tabling::ParsingState state(input, table, codeIndex); - state.Reset(L"JRoot"); - vl::Ptr parser=vl::parsing::tabling::CreateStrictParser(table); - vl::Ptr node=parser->Parse(state, errors); - if(node && errors.Count()==0) - { - return JsonConvertParsingTreeNode(node, state.GetTokens()).Cast(); - } - return 0; - } - - vl::Ptr JsonParse(const vl::WString& input, vl::Ptr table, vl::vint codeIndex) - { - vl::collections::List> errors; - return JsonParse(input, table, errors, codeIndex); - } - -/*********************************************************************** -Table Generation -***********************************************************************/ - - vl::Ptr JsonLoadTable() - { - vl::stream::MemoryStream stream; - JsonGetParserBuffer(stream); - vl::Ptr table=new vl::parsing::tabling::ParsingTable(stream); - table->Initialize(); - return table; - } - - } - } -} - -/*********************************************************************** -PARSING\XML\PARSINGXML.CPP -***********************************************************************/ - -namespace vl -{ - namespace parsing - { - namespace xml - { - using namespace stream; - using namespace collections; - using namespace regex; - -/*********************************************************************** -Unescaping Function Foward Declarations -***********************************************************************/ - - void XmlMergeTextFragment(vl::collections::List>& value, const vl::collections::List& tokens) - { - vint begin=-1; - vint end=-1; - for(vint i=value.Count()-1;i>=-1;i--) - { - if(i==-1) - { - if(end!=-1) begin=0; - } - else if(value[i].Cast()) - { - if(end==-1) end=i; - } - else - { - if(end!=-1) begin=i+1; - } - if(begin!=-1 && end!=-1) - { - vint tokenBegin=value[begin].Cast()->content.tokenIndex; - vint tokenEnd=value[end].Cast()->content.tokenIndex; - while(tokenBegin>0) - { - if(tokens.Get(tokenBegin-1).token==(vint)XmlParserTokenIndex::SPACE || tokens.Get(tokenBegin-1).token==-1) - { - tokenBegin--; - } - else - { - break; - } - } - while(tokenEnd xmlText=new XmlText; - xmlText->codeRange=range; - xmlText->content.codeRange=range; - xmlText->content.value=XmlUnescapeValue(text); - - value.RemoveRange(begin, end-begin+1); - value.Insert(begin, xmlText); - - begin=-1; - end=-1; - } - } - } - - void XmlUnescapeAttributeValue(vl::parsing::ParsingToken& value, const vl::collections::List& tokens) - { - value.value=XmlUnescapeValue(value.value.Sub(1, value.value.Length()-2)); - } - - void XmlUnescapeCData(vl::parsing::ParsingToken& value, const vl::collections::List& tokens) - { - value.value=XmlUnescapeCData(value.value); - } - - void XmlUnescapeComment(vl::parsing::ParsingToken& value, const vl::collections::List& tokens) - { - value.value=XmlUnescapeComment(value.value); - } - -/*********************************************************************** -XmlPrintVisitor -***********************************************************************/ - - class XmlPrintVisitor : public Object, public XmlNode::IVisitor - { - public: - TextWriter& writer; - - XmlPrintVisitor(TextWriter& _writer) - :writer(_writer) - { - } - - void Visit(XmlText* node) - { - writer.WriteString(XmlEscapeValue(node->content.value)); - } - - void Visit(XmlCData* node) - { - writer.WriteString(XmlEscapeCData(node->content.value)); - } - - void Visit(XmlAttribute* node) - { - writer.WriteString(node->name.value); - writer.WriteString(L"=\""); - writer.WriteString(XmlEscapeValue(node->value.value)); - writer.WriteString(L"\""); - } - - void Visit(XmlComment* node) - { - writer.WriteString(XmlEscapeComment(node->content.value)); - } - - void Visit(XmlElement* node) - { - writer.WriteChar(L'<'); - writer.WriteString(node->name.value); - FOREACH(Ptr, att, node->attributes) - { - writer.WriteChar(L' '); - att->Accept(this); - } - if(node->subNodes.Count()==0) - { - writer.WriteString(L"/>"); - } - else - { - writer.WriteChar(L'>'); - FOREACH(Ptr, subNode, node->subNodes) - { - subNode->Accept(this); - } - writer.WriteString(L"name.value); - writer.WriteChar(L'>'); - } - } - - void Visit(XmlInstruction* node) - { - writer.WriteString(L"name.value); - FOREACH(Ptr, att, node->attributes) - { - writer.WriteChar(L' '); - att->Accept(this); - } - writer.WriteString(L"?>"); - } - - void Visit(XmlDocument* node) - { - FOREACH(Ptr, prolog, node->prologs) - { - prolog->Accept(this); - } - node->rootElement->Accept(this); - } - }; - -/*********************************************************************** -API -***********************************************************************/ - - WString XmlEscapeValue(const WString& value) - { - WString result; - const wchar_t* reading=value.Buffer(); - while(wchar_t c=*reading++) - { - switch(c) - { - case L'<': - result+=L"<"; - break; - case L'>': - result+=L">"; - break; - case L'&': - result+=L"&"; - break; - case L'\'': - result+=L"'"; - break; - case L'\"': - result+=L"""; - break; - default: - result+=c; - } - } - return result; - } - - WString XmlUnescapeValue(const WString& value) - { - WString result; - const wchar_t* reading=value.Buffer(); - while(*reading) - { - if(wcsncmp(reading, L"<", 4)==0) - { - result+=L'<'; - reading+=4; - } - else if(wcsncmp(reading, L">", 4)==0) - { - result+=L'>'; - reading+=4; - } - else if(wcsncmp(reading, L"&", 5)==0) - { - result+=L'&'; - reading+=5; - } - else if(wcsncmp(reading, L"'", 6)==0) - { - result+=L'\''; - reading+=6; - } - else if(wcsncmp(reading, L""", 6)==0) - { - result+=L'\"'; - reading+=6; - } - else - { - result+=*reading++; - } - } - return result; - } - - WString XmlEscapeCData(const WString& value) - { - return L""; - } - - WString XmlUnescapeCData(const WString& value) - { - return value.Sub(9, value.Length()-12); - } - - WString XmlEscapeComment(const WString& value) - { - return L""; - } - - WString XmlUnescapeComment(const WString& value) - { - return value.Sub(4, value.Length()-7); - } - - void XmlPrint(Ptr node, stream::TextWriter& writer) - { - XmlPrintVisitor visitor(writer); - node->Accept(&visitor); - } - - void XmlPrintContent(Ptr element, stream::TextWriter& writer) - { - XmlPrintVisitor visitor(writer); - FOREACH(Ptr, node, element->subNodes) - { - node->Accept(&visitor); - } - } - - WString XmlToString(Ptr node) - { - MemoryStream stream; - { - StreamWriter writer(stream); - XmlPrint(node, writer); - } - stream.SeekFromBegin(0); - { - StreamReader reader(stream); - return reader.ReadToEnd(); - } - } - -/*********************************************************************** -Linq To Xml -***********************************************************************/ - - Ptr XmlGetAttribute(Ptr element, const WString& name) - { - return XmlGetAttribute(element.Obj(), name); - } - - Ptr XmlGetElement(Ptr element, const WString& name) - { - return XmlGetElement(element.Obj(), name); - } - - collections::LazyList> XmlGetElements(Ptr element) - { - return XmlGetElements(element.Obj()); - } - - collections::LazyList> XmlGetElements(Ptr element, const WString& name) - { - return XmlGetElements(element.Obj(), name); - } - - WString XmlGetValue(Ptr element) - { - return XmlGetValue(element.Obj()); - } - - Ptr XmlGetAttribute(XmlElement* element, const WString& name) - { - FOREACH(Ptr, att, element->attributes) - { - if(att->name.value==name) - { - return att; - } - } - return 0; - } - - Ptr XmlGetElement(XmlElement* element, const WString& name) - { - FOREACH(Ptr, node, element->subNodes) - { - Ptr subElement=node.Cast(); - if(subElement && subElement->name.value==name) - { - return subElement; - } - } - return 0; - } - - collections::LazyList> XmlGetElements(XmlElement* element) - { - return From(element->subNodes) - .FindType(); - } - - collections::LazyList> XmlGetElements(XmlElement* element, const WString& name) - { - return From(element->subNodes) - .FindType() - .Where([name](Ptr e){return e->name.value==name;}); - } - - WString XmlGetValue(XmlElement* element) - { - WString result; - FOREACH(Ptr, node, element->subNodes) - { - if(Ptr text=node.Cast()) - { - result+=text->content.value; - } - else if(Ptr text=node.Cast()) - { - result+=text->content.value; - } - } - return result; - } - -/*********************************************************************** -XmlElementWriter -***********************************************************************/ - - XmlElementWriter::XmlElementWriter(Ptr _element, const XmlElementWriter* _previousWriter) - :element(_element) - ,previousWriter(_previousWriter) - { - } - - XmlElementWriter::~XmlElementWriter() - { - } - - const XmlElementWriter& XmlElementWriter::Attribute(const WString& name, const WString& value)const - { - Ptr node=new XmlAttribute; - node->name.value=name; - node->value.value=value; - element->attributes.Add(node); - return *this; - } - - XmlElementWriter XmlElementWriter::Element(const WString& name)const - { - Ptr node=new XmlElement; - node->name.value=name; - element->subNodes.Add(node); - return XmlElementWriter(node, this); - } - - const XmlElementWriter& XmlElementWriter::End()const - { - return *previousWriter; - } - - const XmlElementWriter& XmlElementWriter::Text(const WString& value)const - { - Ptr node=new XmlText; - node->content.value=value; - element->subNodes.Add(node); - return *this; - } - - const XmlElementWriter& XmlElementWriter::CData(const WString& value)const - { - Ptr node=new XmlCData; - node->content.value=value; - element->subNodes.Add(node); - return *this; - } - - const XmlElementWriter& XmlElementWriter::Comment(const WString& value)const - { - Ptr node=new XmlComment; - node->content.value=value; - element->subNodes.Add(node); - return *this; - } - } - } -} - -/*********************************************************************** -PARSING\XML\PARSINGXML_AST.CPP -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Parser::ParsingXml.parser.txt - -This file is generated by: Vczh Parser Generator -***********************************************************************/ - - -namespace vl -{ - namespace parsing - { - namespace xml - { -/*********************************************************************** -Visitor Pattern Implementation -***********************************************************************/ - - void XmlText::Accept(XmlNode::IVisitor* visitor) - { - visitor->Visit(this); - } - - void XmlCData::Accept(XmlNode::IVisitor* visitor) - { - visitor->Visit(this); - } - - void XmlAttribute::Accept(XmlNode::IVisitor* visitor) - { - visitor->Visit(this); - } - - void XmlComment::Accept(XmlNode::IVisitor* visitor) - { - visitor->Visit(this); - } - - void XmlElement::Accept(XmlNode::IVisitor* visitor) - { - visitor->Visit(this); - } - - void XmlInstruction::Accept(XmlNode::IVisitor* visitor) - { - visitor->Visit(this); - } - - void XmlDocument::Accept(XmlNode::IVisitor* visitor) - { - visitor->Visit(this); - } - - } - } -} -namespace vl -{ - namespace reflection - { - namespace description - { -#ifndef VCZH_DEBUG_NO_REFLECTION - using namespace vl::parsing::xml; - -#define PARSING_TOKEN_FIELD(NAME)\ - CLASS_MEMBER_EXTERNALMETHOD_TEMPLATE(get_##NAME, NO_PARAMETER, vl::WString(ClassType::*)(), [](ClassType* node) { return node->NAME.value; }, L"*", L"*")\ - CLASS_MEMBER_EXTERNALMETHOD_TEMPLATE(set_##NAME, { L"value" }, void(ClassType::*)(const vl::WString&), [](ClassType* node, const vl::WString& value) { node->NAME.value = value; }, L"*", L"*")\ - CLASS_MEMBER_PROPERTY_REFERENCETEMPLATE(NAME, get_##NAME, set_##NAME, L"$This->$Name.value")\ - - IMPL_TYPE_INFO_RENAME(vl::parsing::xml::XmlNode, system::XmlNode) - IMPL_TYPE_INFO_RENAME(vl::parsing::xml::XmlText, system::XmlText) - IMPL_TYPE_INFO_RENAME(vl::parsing::xml::XmlCData, system::XmlCData) - IMPL_TYPE_INFO_RENAME(vl::parsing::xml::XmlAttribute, system::XmlAttribute) - IMPL_TYPE_INFO_RENAME(vl::parsing::xml::XmlComment, system::XmlComment) - IMPL_TYPE_INFO_RENAME(vl::parsing::xml::XmlElement, system::XmlElement) - IMPL_TYPE_INFO_RENAME(vl::parsing::xml::XmlInstruction, system::XmlInstruction) - IMPL_TYPE_INFO_RENAME(vl::parsing::xml::XmlDocument, system::XmlDocument) - IMPL_TYPE_INFO_RENAME(vl::parsing::xml::XmlNode::IVisitor, system::XmlNode::IVisitor) - - BEGIN_CLASS_MEMBER(XmlNode) - CLASS_MEMBER_METHOD_OVERLOAD(Accept, {L"visitor"}, void(XmlNode::*)(XmlNode::IVisitor* visitor)) - END_CLASS_MEMBER(XmlNode) - - BEGIN_CLASS_MEMBER(XmlText) - CLASS_MEMBER_BASE(XmlNode) - - CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) - - PARSING_TOKEN_FIELD(content) - END_CLASS_MEMBER(XmlText) - - BEGIN_CLASS_MEMBER(XmlCData) - CLASS_MEMBER_BASE(XmlNode) - - CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) - - PARSING_TOKEN_FIELD(content) - END_CLASS_MEMBER(XmlCData) - - BEGIN_CLASS_MEMBER(XmlAttribute) - CLASS_MEMBER_BASE(XmlNode) - - CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) - - PARSING_TOKEN_FIELD(name) - PARSING_TOKEN_FIELD(value) - END_CLASS_MEMBER(XmlAttribute) - - BEGIN_CLASS_MEMBER(XmlComment) - CLASS_MEMBER_BASE(XmlNode) - - CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) - - PARSING_TOKEN_FIELD(content) - END_CLASS_MEMBER(XmlComment) - - BEGIN_CLASS_MEMBER(XmlElement) - CLASS_MEMBER_BASE(XmlNode) - - CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) - - PARSING_TOKEN_FIELD(name) - PARSING_TOKEN_FIELD(closingName) - CLASS_MEMBER_FIELD(attributes) - CLASS_MEMBER_FIELD(subNodes) - END_CLASS_MEMBER(XmlElement) - - BEGIN_CLASS_MEMBER(XmlInstruction) - CLASS_MEMBER_BASE(XmlNode) - - CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) - - PARSING_TOKEN_FIELD(name) - CLASS_MEMBER_FIELD(attributes) - END_CLASS_MEMBER(XmlInstruction) - - BEGIN_CLASS_MEMBER(XmlDocument) - CLASS_MEMBER_BASE(XmlNode) - - CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) - - CLASS_MEMBER_FIELD(prologs) - CLASS_MEMBER_FIELD(rootElement) - END_CLASS_MEMBER(XmlDocument) - - BEGIN_INTERFACE_MEMBER(XmlNode::IVisitor) - CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(XmlNode::IVisitor::*)(XmlText* node)) - CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(XmlNode::IVisitor::*)(XmlCData* node)) - CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(XmlNode::IVisitor::*)(XmlAttribute* node)) - CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(XmlNode::IVisitor::*)(XmlComment* node)) - CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(XmlNode::IVisitor::*)(XmlElement* node)) - CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(XmlNode::IVisitor::*)(XmlInstruction* node)) - CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(XmlNode::IVisitor::*)(XmlDocument* node)) - END_INTERFACE_MEMBER(XmlNode) - -#undef PARSING_TOKEN_FIELD - - class XmlTypeLoader : public vl::Object, public ITypeLoader - { - public: - void Load(ITypeManager* manager) - { - ADD_TYPE_INFO(vl::parsing::xml::XmlNode) - ADD_TYPE_INFO(vl::parsing::xml::XmlText) - ADD_TYPE_INFO(vl::parsing::xml::XmlCData) - ADD_TYPE_INFO(vl::parsing::xml::XmlAttribute) - ADD_TYPE_INFO(vl::parsing::xml::XmlComment) - ADD_TYPE_INFO(vl::parsing::xml::XmlElement) - ADD_TYPE_INFO(vl::parsing::xml::XmlInstruction) - ADD_TYPE_INFO(vl::parsing::xml::XmlDocument) - ADD_TYPE_INFO(vl::parsing::xml::XmlNode::IVisitor) - } - - void Unload(ITypeManager* manager) - { - } - }; -#endif - - bool XmlLoadTypes() - { -#ifndef VCZH_DEBUG_NO_REFLECTION - ITypeManager* manager=GetGlobalTypeManager(); - if(manager) - { - Ptr loader=new XmlTypeLoader; - return manager->AddTypeLoader(loader); - } -#endif - return false; - } - } - } -} - -/*********************************************************************** -PARSING\XML\PARSINGXML_PARSER.CPP -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Parser::ParsingXml.parser.txt - -This file is generated by: Vczh Parser Generator -***********************************************************************/ - - -namespace vl -{ - namespace parsing - { - namespace xml - { -/*********************************************************************** -ParserText -***********************************************************************/ - -const wchar_t parserTextBuffer[] = -L"\r\n" L"" -L"\r\n" L"//////////////////////////////////////////////////////////////////" -L"\r\n" L"// AST" -L"\r\n" L"//////////////////////////////////////////////////////////////////" -L"\r\n" L"" -L"\r\n" L"class Node" -L"\r\n" L"{" -L"\r\n" L"}" -L"\r\n" L"" -L"\r\n" L"class Text : Node" -L"\r\n" L"{" -L"\r\n" L"\ttoken content;" -L"\r\n" L"}" -L"\r\n" L"" -L"\r\n" L"class CData : Node" -L"\r\n" L"{" -L"\r\n" L"\ttoken content (XmlUnescapeCData);" -L"\r\n" L"}" -L"\r\n" L"" -L"\r\n" L"class Attribute : Node" -L"\r\n" L"{" -L"\r\n" L"\ttoken name\t\t\t\t\t\t\t\t\t@Color(\"AttName\");" -L"\r\n" L"\ttoken value (XmlUnescapeAttributeValue)\t\t@Color(\"AttValue\");" -L"\r\n" L"}" -L"\r\n" L"" -L"\r\n" L"class Comment : Node" -L"\r\n" L"{" -L"\r\n" L"\ttoken content (XmlUnescapeComment);" -L"\r\n" L"}" -L"\r\n" L"" -L"\r\n" L"class Element : Node" -L"\r\n" L"{" -L"\r\n" L"\ttoken name\t\t\t\t\t\t\t\t\t@Color(\"TagName\");" -L"\r\n" L"\ttoken closingName\t\t\t\t\t\t\t@Color(\"TagName\");" -L"\r\n" L"\tAttribute[] attributes;" -L"\r\n" L"\tNode[] subNodes (XmlMergeTextFragment);" -L"\r\n" L"}" -L"\r\n" L"" -L"\r\n" L"class Instruction : Node" -L"\r\n" L"{" -L"\r\n" L"\ttoken name\t\t\t\t\t\t\t\t\t@Color(\"TagName\");" -L"\r\n" L"\tAttribute[] attributes;" -L"\r\n" L"}" -L"\r\n" L"" -L"\r\n" L"class Document : Node" -L"\r\n" L"{" -L"\r\n" L"\tNode[] prologs;" -L"\r\n" L"\tElement rootElement;" -L"\r\n" L"}" -L"\r\n" L"" -L"\r\n" L"//////////////////////////////////////////////////////////////////" -L"\r\n" L"// Lexer" -L"\r\n" L"//////////////////////////////////////////////////////////////////" -L"\r\n" L"" -L"\r\n" L"token INSTRUCTION_OPEN = \"/\"\t\t@Color(\"Boundary\");" -L"\r\n" L"token COMPLEX_ELEMENT_OPEN = \"/\"\t\t@Color(\"Boundary\");" -L"\r\n" L"token ELEMENT_OPEN = \"/<\"\t\t\t\t@Color(\"Boundary\");" -L"\r\n" L"token ELEMENT_CLOSE = \"/>\"\t\t\t\t@Color(\"Boundary\");" -L"\r\n" L"token EQUAL = \"/=\";" -L"\r\n" L"" -L"\r\n" L"token NAME = \"[a-zA-Z0-9:._/-]+\"\t\t\t\t\t\t\t\t@ContextColor();" -L"\r\n" L"token ATTVALUE = \"\"\"[^<>\"\"]*\"\"|\'[^<>\']*\'\"\t\t\t\t\t\t@ContextColor();" -L"\r\n" L"token COMMENT = \"/]|-[^/->]|--[^>])*--/>\"\t\t\t@Color(\"Comment\");" -L"\r\n" L"token CDATA = \"/])*/]/]/>\";" -L"\r\n" L"token TEXT = \"([^<>=\"\"\' /r/n/ta-zA-Z0-9:._/-])+|\"\"|\'\";" -L"\r\n" L"" -L"\r\n" L"discardtoken SPACE = \"/s+\";" -L"\r\n" L"" -L"\r\n" L"//////////////////////////////////////////////////////////////////" -L"\r\n" L"// Rules" -L"\r\n" L"//////////////////////////////////////////////////////////////////" -L"\r\n" L"" -L"\r\n" L"rule Attribute XAttribute = NAME:name \"=\" ATTVALUE:value as Attribute;" -L"\r\n" L"rule Text XText = (NAME:content | EQUAL:content | ATTVALUE:content | TEXT:content) as Text;" -L"\r\n" L"rule CData XCData = CDATA:content as CData;" -L"\r\n" L"rule Comment XComment = COMMENT:content as Comment;" -L"\r\n" L"rule Element XElement = \"<\" NAME:name {XAttribute:attributes} (\"/>\" | \">\" {XSubNode:subNodes} \"\") as Element;" -L"\r\n" L"rule Node XSubNode = !XText | !XCData | !XComment | !XElement;" -L"\r\n" L"rule Instruction XInstruction = \"\" as Instruction;" -L"\r\n" L"rule Document XDocument = {XInstruction:prologs | XComment:prologs} XElement:rootElement as Document;" -; - - vl::WString XmlGetParserTextBuffer() - { - return parserTextBuffer; - } - -/*********************************************************************** -SerializedTable -***********************************************************************/ - -const vint parserBufferLength = 4442; // 18926 bytes before compressing -const vint parserBufferBlock = 1024; -const vint parserBufferRemain = 346; -const vint parserBufferRows = 5; -const char* parserBuffer[] = { -"\x00\x0E\x00\x02\x83\x80\x07\x7D\x00\x82\x03\xFF\x45\x08\x82\x83\x86\x81\x21\x6F\x6C\x2F\x32\x37\x84\x87\x02\x86\x00\x17\x82\x94\x21\x37\x32\x27\x30\x6D\x65\x06\x98\x8A\x80\x8E\x86\x00\x10\x92\x94\x98\x8A\x88\x85\x96\x8E\x1E\xA0\xA2\x95\x88\x85\x90\x87\x93\x29\x93\xB4\x84\x8D\x94\x9F\x81\x20\x74\x74\x1F\x81\x93\x94\x86\x9A\x84\x38\x91\xBA\x98\x88\x04\xA7\x9F\xA0\x56\x61\x2C\x35\x33\x9C\x93\x92\x82\x49\xAA\xBB\x83\x8D\x9C\xAF\x80\x98\x43\xD5\x86\xB7\xA3\x81\xAF\xA4\x86\x4D\xE8\x83\x82\x2F\x35\x3A\x36\x32\x61\x72\x39\x25\xA5\x9C\xB1\x87\x81\x39\xAB\xAA\xBB\xB0\x04\xB6\xB6\xB8\x72\xF4\x84\x87\xA8\xA8\xBE\xA4\xBD\x08\xE9\x89\xCB\xBD\xB7\xB5\xB9\xB9\x5B\x82\x84\xC5\xB6\xC2\xAE\xA6\xBE\x7E\x8E\xC1\xD1\xC5\x86\xB8\x00\xB3\x88\x84\x8A\xC2\xDC\xC7\xBF\xC6\xC1\x09\x9E\xE0\xDC\xC3\xD3\x82\xC5\xCC\x80\x90\xE4\x8C\x08\x8C\xDB\x87\x37\x6E\x74\x25\x38\x34\x39\xBC\x8D\x82\x9C\xFF\x76\xC8\x83\xE0\x89\xDD\xDD\xBD\x87\xFF\xC8\xD2\xCA\xD5\xCB\xB3\x2E\xAC\x86\xCD\x31\x91\xDD\xD6\x81\x09\x18\x99\xE2\x80\xA4\x3A\x39\x34\x62\x75\x3A\xDF\x74\xF5\xF0\xF2\xE7\x0F\xC4\x21\x34\x31\x36\xF2\xF3\xAE\x02\xAD\x90\x94\xE5\x31\xDE\xF7\xF2\xD7\x80\x0A\xC4\x2F\x33\x31\x3B\xEA\x74\x37\x74\x78\x7C\x19\x43\x45\x10\x1B\x65\x00\x82\x83\x3F\x0B\x18\x4D\x82\x40\x49\x2E\x13\x1E\x77\x75\x23\x14\x1D\x1A\xB8\x4B\x84\x00\x46\x1B\x82\x4E\x13\x1B\x64\x22\x42\x81\x87\x08\x64\x84\x14\x72\x0B\x8D\x0A\x77\x8A\xDC\x41\x5F\x75\x78\xBA\x64\x84\x40\x89\x6E\x32\x42\x00\x8B\x08\x5B\x70\x01\x77\x2F\xA2\x75\x18\x7A\x00\x36\x12\x54\x55\x03\x26\x46\x91\x7A\xEB\x61\x14\x81\x4B\x63\x38\x6A\x6E\x7D\x02\x8B\x93\x74\x80\x52\x82\x4D\x93\x71\x50\xB7\x79\x7F\x7E\xFD\x7F\x75\x7C\x1D\x55\x80\x00\x1E\x1C\x4A\x67\x13\x1F\x82\x5B\x83\x4C\x7E\x7F\x00\x8F\x88\x42\x9B\x64\xAF\x14\x1F\x81\x09\x9F\x9B\x81\x98\x74\x80\x8A\x00\x46\x7B\x82\x4B\x7A\x77\xE0\x7E\x87\x99\x94\xD2\x42\x49\x9F\x97\x6E\x84\x4E\x9B\x18\x12\x73\x19\x1A\x1B\x31\x61\x4C\x64\x9E\x08\x80\x82\x8F\x40\x34\xB2\x4F\x6C\xA5\x75\x96\x77\x64\x00\x73\x35\x12\x1B\x87\x21\x83\xA7\x7D\xA2\x03\x6E\x91\x87\x84\x72\x15\x87\x84\x6E\x7D\x88\x41\xAF\x9F\x3D\xBA\x66\xAA\x7B\xA8\x82\x4A\xAA\x84\x14\x96\x88\x86\x1B\x97\x82\x49\xA5\x48\xC1\x80\x05\xB2\x89\xC8\x61\x97\x97\x93\x01\x82\x80\x04\x46\x31\x18\x4F\xB3\x6F\xD4\xB5\x4B\x82\x80\xD5\x86\x57\xB7\x7D\xD9\x96\xBB\xB6\x79\xDD\x83\x6F\xB6\x79\xD3\x88\x45\xB9\x12\x4E\x13\x14\x16\x14\x55\x03\x14\x15\x12\x4F\x0E\x1F\x17\x13\x50\x05\x1E\x13\xB1\x03\x6F\x0C\x0F\x0B\x3F\x3F\x6E\x65\x04\x18\x40\xC0\x85\xBA\xEB\xAD\xBF\xB9\xBC\x5F\x03\x1C\x13\x13\x53\x05\x18\xBE\x40\xFC\xAF\x0E\x0C\x67\x06\x18\x44\x06\xC5\x78\x4F\x1D\x10\x14\x4C\x05\x18\x17\x17\x45\x1D\xCD\x12\xBD\x54\x33\xB5\xBF\xBD\x1C\xB9\xBB\xBF\x0B\x37\x96\x48\xC4\x43\x17\xC2\x43\x14\xBA\x47\x1D\xC0\xCA\xC8\x24\xC9\xCB\xC1\xC3\x0F\xC0\x0F\x0B\xCF\x3E\x05\x9C\x5C\x41\xC3\x44\xD6\x80\xCE\x4E\x25\xC4\xBE\xBD\x2D\xC8\x4D\xD2\xBE\xC5\xBA\x84\x42\x8A\x0C\x54\xD0\x01\xC8\x45\x23\xC9\xD2\xCE\x0C\xC5\x1D\xD0\x41\x4F\xFE\x0E\x65\xAC\x85\x77\x46\x81\x14\x55\x01\x1C\x13\xD7\x03\x4F\xDD\x0D\xC5\xDA\xB7\x7D\xCE\x13\x41\x23\xC2\xC0\x42\x77\xDB\x11\x19\x0B\x7A\x01\x1D\x0A\x16\x30\x2D\x09\x0E\x0E\x2E\x1F\x1F\x09\x0B\x5D\x2B\x04\x81\xAE\xFA\x5F\xA1\x10\x15\x54\x16\x1A\xD9\x15\x45\x13\x08\x46\xE5\x02\x62\x0B\x16\x17\x3C\x3E\x02\x09\x17\x2A\x22\x0C\x1F\x09\x9B\xDD\xE7\x08\xE8\x27\x39\x75\xD2\x57\x2E\xCF\x4A\xC6\xD6\x54\x22\x08\x46\xEC\x10\xFB\xB1\x09\x0B\x2D\x28\x0B\xE7\xE1\x3E\x1D\x1C\x1D\x0B\xBB\xED\x0D\xEF\xEF\xC0\xDE\x1D\xED\x0A\x2A\x38\xE2\xC6\xD4\x03\x56\xD5\xD8\x52\x78\x44\x1F\xE1\x10\x2C\x18\x45\xF5\xED\x2F\x21\x0F\x0B\x16\x43\x12\xF4\x15\x10\xDB\xFA\xEE\x17\x0B\x5D\x3E\xE4\xFB\xEE\xE5\xFC\x14\xFB\xF9\xC6\xDD\x18\xF3\xFA\x5D\x12\xC4\xD9\x42\x23\xA9\xCB\x46\xC7\x54\x24\x08\x46\xFE\x02\x62\xFD\xE5\x0F\x22\x07\x04\x08\x2F\x02\x0F\x17\x2E\x0F\x05\xEC\x3C\x6E\xDF\x00\x72\x70\xC2\x46\x70\x71\x29\x0B\x04\x1F\x22\x77\x04\xC6\x4B\x44\x33\x40\x53\x08\x14\x41\x03\x09\x22\x02\x68\x21\x1F\x8F\x07\x1C\x2B\x0B\x74\xC9\x02\x41\x5A\x0C\x30\x6C\x42\x2A\x88\x0B\xEE\x49\x4D\x5C\x04\x25\x5D\x0B\xEA\x3C\x3C\x17\x12\x0F\x0D\x72\x53\x08\x7B\x72\x04\x0E\xC6\x6E\x48\x08\x20\x04\x04\x0F\x33\x89\x48", -"\x1F\x2A\x84\x20\x2C\x8E\x84\x7B\x25\x80\x01\xE1\x04\x8D\x86\x3A\x91\x2C\x1D\x73\x72\x21\x58\x40\x8B\x88\x4A\x81\x0E\x11\x98\x29\x88\x1A\xA1\x09\x4D\x02\x2F\x89\x18\x2E\x01\x07\x11\x18\x26\x8C\x02\x38\x8A\x17\xBE\x0A\x06\x10\x1D\x7B\x7A\x20\x0D\x8F\xB2\x5F\x40\x05\x30\x33\x0E\x8D\x5E\x80\x0B\x11\x83\x2D\x8B\x24\x41\x24\x21\x7F\x80\x02\x18\xB6\x88\x87\x39\x6F\x2E\x87\x03\x22\x8A\x18\xBE\x00\x04\x20\x20\x8A\x90\x53\x02\x54\xA9\x65\x04\x8A\x00\x31\x50\x0B\x91\x83\x54\x88\x65\x04\x8D\x1A\x18\x26\x93\x69\x98\x92\x24\x9B\x9C\x8C\x10\x21\x00\x0B\x27\x5C\x34\x08\x7C\x06\x94\x31\xAB\x95\x95\xF3\x20\x43\x2B\xA7\x97\x51\xDC\x0E\x97\x53\x58\x15\x97\x14\xFC\x43\x21\x5C\x95\x57\x4B\x2E\x13\x06\x03\x11\x33\x99\x50\xBA\x95\x94\x22\x1C\x06\x08\x20\x04\x6F\x91\x71\x88\x04\x35\x41\x24\x08\x7B\x00\x04\x2C\x3C\x41\x50\xBA\x2F\x98\xAD\x58\x95\x0D\x3B\xBD\x08\x04\x28\x00\x06\x08\x12\x6B\x98\x56\xA2\x06\x73\x40\x94\x9A\x28\x9A\x91\x45\x67\xA1\x54\x9D\xDD\x80\x07\x37\xC9\x9F\x05\x65\x8D\x9D\x08\xCF\x8C\x53\x1B\x0E\x50\x53\xB0\x22\x9E\x73\x20\x09\x05\x1D\xF7\x8A\x97\x06\x0A\x03\x88\xC7\x8D\x8D\x32\xF6\x95\x6E\x7C\xAD\x89\x9A\x65\x13\x99\x35\xD7\x90\x47\x88\xAD\x8B\x9B\x15\xBE\x98\x38\xE2\x94\x9D\x57\xA7\x9B\x99\x40\x0A\x9D\x26\x93\x9E\x9D\x51\xA5\x52\x9E\xE2\x9B\x5C\x43\xCE\x92\x8F\x46\x4F\x51\x52\x11\xBF\xA1\x40\x83\xA0\x04\x5D\x8F\x93\x9D\x93\x90\x87\x40\x32\x83\xA5\x4D\x84\x92\x4E\x45\x0F\x2E\xF3\x4D\x79\x91\x21\xBD\xA1\x44\x8C\x97\x94\x5F\x3E\x9D\x53\x5D\x8C\x27\x92\xBA\x8E\x06\x0D\x06\x18\x22\xAA\x86\x9F\x97\xB9\x28\x9A\x32\xCC\x9D\xA1\x67\x90\xA2\xA2\xD6\x8E\x44\x37\xDA\x92\xAD\x8C\xA8\xA1\x9C\xE3\x80\xA2\x39\x80\xA2\xA4\x93\x96\xA0\x04\xEF\x93\x92\x46\xF4\x92\x04\x20\xB7\x99\x9F\x2E\xBD\x9E\x4C\x7F\x9B\x98\x81\xB6\x8D\xA6\x58\xB4\x0C\x90\x28\x99\x59\x42\x42\x91\x95\x74\x04\x8C\x16\x18\x2B\xB1\x50\x88\xB5\x94\x77\xB2\x8E\x93\x74\x8C\x95\x22\x28\x6A\x6D\xF9\x93\xB1\x6E\x2F\x9F\x71\xC8\x53\x76\xA1\x20\x13\x8F\x66\xAC\x94\x0A\xFC\x59\xB0\x4B\x74\x14\xA4\x62\xCA\xAB\x31\x30\xB1\x97\x4B\x95\x97\x93\x6B\xB9\x34\x8D\x14\x18\x26\xB6\xA1\x93\xB4\x1D\x25\x93\x09\xD7\x64\x67\xB4\xCC\x54\xA6\x6E\xAC\xB4\x35\x30\xBA\x91\xB6\xBD\x91\xA9\x0C\x56\xA8\x20\xE6\x88\xA1\xB0\x5A\xB5\xAC\x57\xAC\xA0\x9B\xBD\xAA\x9C\xA2\x3E\x44\xAC\xA0\x66\xAF\x9A\xB4\x9D\xA3\xAD\xCB\x8D\xAC\x3C\xA5\xA0\x9F\xB9\xAA\xA3\xBA\xA0\xBA\x9C\x3F\xB0\xAC\xAF\x99\xBF\xAE\xA6\xB8\x87\xB8\x2F\xC6\xB1\xB0\x17\x37\x04\xB9\x04\x2E\xB8\x53\x80\x41\xBA\xF4\x9E\xAE\xBA\x13\xA5\xAD\x76\x97\xA2\xC0\x5B\x67\xAC\xA3\x6A\xAD\xBE\x78\xA4\xAD\x8D\xB8\x9B\x96\xBC\xF5\x9E\xBD\x4B\xFB\x9F\xA5\xB0\x00\x8A\xA6\x7E\xA4\xA1\x60\x83\xB8\xB1\xA1\x82\x26\x6A\x84\xBC\x37\x4F\x86\x94\x0C\xE4\x82\x22\x91\x8F\xAD\x93\x4D\xBA\xBA\xA6\x81\x32\x82\xB7\x23\xC1\xA8\x19\x1E\xC0\x00\xAB\x4A\x92\xB7\x49\xAC\x78\x76\x3D\x9B\x4C\x2F\x79\x30\x91\x61\x9D\xC4\x80\x2E\x02\x06\x30\x18\x26\xC8\xA1\x82\xCB\x97\x25\x91\xA5\x6A\xAB\x55\x57\xAF\x4E\x0F\x33\xE3\x45\x4D\x3B\xAC\x95\x85\x6F\x14\x3F\x66\xED\x84\xCA\x89\x26\x48\xA5\xFB\xB4\x8D\x1B\xF1\x43\x4F\xC0\xB4\xA2\xC9\x9E\x4B\xAA\x7C\xCF\xA9\xB9\xFA\xB4\x05\x98\x08\x30\xCF\x73\xCD\xAD\xBF\xC8\x95\xBA\x9A\x4D\xC1\xAF\x76\x83\xC5\x8F\x02\xF1\x9D\xBB\x08\xC5\x9E\x82\xD5\x97\xA9\xB7\x8E\xC7\xA4\xF3\x87\xBE\x9D\xEA\xB5\xC3\xBD\x98\xC4\xA6\x05\xA7\xA1\x98\xD9\xAA\xA1\xAD\xB6\xC8\xA2\xE9\x81\xC3\x9E\xD9\x94\xC1\x4D\xFF\xCB\xA3\x69\xA2\xD2\x4C\x8B\xCB\x92\xF2\xB2\xA8\xA5\x74\xB2\xC1\x68\xF9\xAC\xBD\x47\xEF\xB9\xB0\x37\xAB\xCE\xAC\x6D\xCD\xA8\x22\xF8\xBB\x20\xFA\xA9\xA1\x4A\xAB\xA0\xB5\xAF\x97\xBE\xCF\xDA\xB5\x57\xA7\xDE\xB9\xC1\x51\xC4\xD6\xAD\xA6\xCF\xC0\xAA\x8A\xDD\xAB\x09\xEB\xBE\x9F\xAE\xDA\xC1\x53\xC0\x0C\x88\x27\x8F\xCD\x55\xBE\x58\x35\x20\x84\x21\x90\x2C\x17\xDE\x55\xBF\x44\x8D\x14\x18\x23\xDD\x50\x9F\xD9\xDB\x6E\x1A\xAB\x0F\x52\xB7\xD2\x00\xFA\xCA\xD8\xC1\xDC\x9B\x5C\xBF\x00\xA1\xBF\xA7\xD9\xCA\x26\xC2\x90\x76\xBA\x35\xDB\x5E\xBB\xDC\x93\x31\x1C\x04\x46\x02\xE1\x95\x7F\xD0\xB5\xD9\x77\xC5\x0F\x85\x80\x80\x05\xCE\x92\x74\x09\x94\x6F\x9A\x90\x53\x21\xA3\xBF\xBF\xD9\xD6\x81\xAD\xC4\x00\x32\x81\xAB\x1B\x80\xAA\xA8\x18\x36\xC7\x9C\xFC\xBD\x90\x1D\xC0\x02\x47\x58\x08\xCD\x0F\x8E\x4C\xC7\x2E", -"\x43\xC9\x06\x48\xC8\x21\xCC\xC3\x8A\xE5\x52\xAA\x9F\xDE\xBF\x53\xC8\x99\x5E\xC6\xCB\x6A\xBA\xB2\xE7\x55\xC0\xCE\x2E\xCF\x94\xCD\xA1\xFF\xAA\xE5\xD4\xD5\x35\x2F\xB8\xEA\xDA\x8C\x1D\xDC\xE9\x6E\x01\x98\x29\x18\x23\xEA\x73\xFC\x50\xDB\x51\xCA\xDC\xAF\xFF\xB8\xCF\x5F\xDE\xD1\xDE\xDC\xA2\x9C\xBD\xCB\x96\xDF\xAB\xE0\xD8\x37\x06\xA3\x88\xD4\xDA\xEA\xD4\x4C\xE0\xAF\xDF\x60\xE2\x50\xAA\xE3\xE4\xA6\xA8\xF9\xDF\xDD\xDC\x9D\xDD\x18\xFF\xD4\xC8\x82\xC8\x26\xEF\x43\x86\xE1\x1B\xED\xD2\x9A\x11\x00\x80\x88\x0E\xFF\xB2\xC4\xC3\x45\xE3\x3B\xBF\xDE\xE4\x28\xEA\xE7\xDD\x04\x27\x6F\x94\xEE\xE0\x98\x1E\xE4\xC7\xB6\x83\x21\x90\x45\xB5\xE5\x91\x7A\xE2\x90\xD4\x9B\xF2\x21\xA7\xE6\xE8\xDD\x44\xC5\xDC\x42\x2A\xFA\xED\xD3\xD9\xED\xD2\xEB\xCD\xEE\xBB\xF0\xED\xD2\x61\xF3\xDD\xDE\x77\x90\xE8\x10\x77\xEF\xDF\xD0\xF8\xED\xA2\xC1\x9E\xEC\x41\x00\xFF\xF6\x1F\x47\xE4\xBA\x5F\xA6\xF3\x32\x89\xF0\xE2\xD0\x93\xE4\x2A\x34\xBF\xDD\xD2\x8C\x26\xDA\xD7\xFF\x51\x66\x08\x38\xFA\xB7\xD6\xF8\x37\x18\xEF\x2B\xF2\x03\x37\x6E\x22\xEB\xED\x90\xDE\xFE\xCA\x02\x18\x28\xFF\xDE\xFE\xCE\xFA\x32\x0F\x00\x23\xEF\xE7\xC5\xE0\xFE\xC9\xA8\x8C\xCD\xAA\xFD\x08\x38\xFF\xA4\x89\xB9\xF3\x28\xBC\x84\xC6\x56\x30\x44\x8A\x47\x4C\xF6\x70\x20\xA4\x70\x10\xB4\x63\x64\xFE\x74\x07\xA1\x77\x45\xFB\x72\x36\x47\x27\x58\xC8\x11\x7F\x08\x14\x81\x21\x6C\x7F\x85\x4B\x80\xF9\x62\x80\x43\x4F\x58\x1C\x68\x1C\x40\x62\x81\x22\x6B\x80\x90\x73\x10\x0E\x8F\x58\xE6\x7E\x69\xD8\x74\x10\xDA\x7C\x77\xFD\x7B\x43\x74\x04\x81\x04\x14\x81\x1C\x85\x7C\xBA\x1E\x03\x29\x82\x6C\x1A\x72\x43\x7C\x7B\x80\x07\x81\x48\x0E\x86\x70\xBE\x70\x75\x16\x08\x11\x45\x81\x46\x50\x73\x62\x0B\x80\x7E\x02\x17\x37\x35\x8B\x76\x43\x8C\x7D\x6E\x08\x7F\x04\x1A\x7F\x49\x8B\x80\x3B\x86\x82\x20\x0D\x7A\xAC\x27\x76\xE9\x6B\x62\x59\x60\x20\x54\x83\x10\xFA\x70\x63\x2F\x82\x45\x00\x8A\x85\x37\x61\x86\x4B\x60\x86\x5A\x64\x07\x3F\x8D\x4B\x30\x6B\x80\x0D\x8B\x85\x58\x6F\x86\x3E\x05\x82\x41\x67\x79\xB9\x18\x39\x08\x1E\x87\x96\x7C\x26\x98\x79\x81\x30\x81\x87\x02\x15\x83\x35\x7A\x87\x82\x4A\x72\x32\x83\x10\x16\x8A\x72\x2E\x0B\x80\x69\x87\x88\x76\x85\x73\x37\x55\x68\x63\x82\x10\xFA\x75\x68\x4A\x80\x83\x93\x80\x00\x35\x85\x68\x3E\x07\x89\x6E\x56\x88\x90\x4E\x56\x91\x80\x83\x75\x86\x54\x6E\x5B\x45\x29\x42\x87\x5E\x4B\x62\x5E\x44\x64\x68\x48\x10\xB5\x8A\x46\x45\x4D\x46\x6F\x4F\x3D\xC0\x54\x47\x7F\x59\x45\xC4\x5E\x1A\x09\x80\x5B\xF3\x52\x48\x51\x55\x03\xB7\x62\x10\xB9\x60\x5D\x95\x6B\x75\x0F\x53\x7B\xC0\x65\x7B\xF2\x67\x60\xA1\x6E\x51\x6C\x57\x6C\xE3\x5D\x60\x6E\x50\x61\xCE\x8B\x6A\x14\x6A\x57\x85\x70\x50\x19\x60\x58\xD3\x6F\x81\xBC\x11\x26\x17\x84\x64\x8D\x58\x10\xEB\x8D\x81\xC8\x17\x7C\xE9\x5A\x59\xA9\x55\x59\x97\x5C\x04\xBD\x83\x5A\x0D\x70\x39\x0F\x71\x71\x92\x58\x5A\xAF\x45\x5A\xA8\x47\x8F\xA9\x5F\x57\xAB\x59\x83\x79\x7A\x74\xEB\x7E\x69\x2E\x04\x03\xC2\x73\x10\xC4\x72\x78\xB2\x75\x78\x0C\x7C\x7C\xFC\x80\x02\xCF\x7D\x78\x0D\x7E\x67\xD3\x74\x1C\x4B\x72\x85\xA6\x8B\x7D\x5D\x88\x7A\x34\x0A\x7A\x04\x1C\x7A\x20\x90\x65\xBF\x2C\x76\x84\x71\x51\x5E\x70\x6F\xD2\x81\x76\x22\x04\x77\x65\x71\x92\x51\x61\x8C\x02\x1A\x18\x77\x8A\x27\xC5\x89\x93\xC0\x42\x03\xB8\x58\x10\x3F\x98\x45\x6C\x84\x69\x6E\x4E\x5B\x49\x32\x90\xC2\x53\x94\x74\x00\x04\x8A\x81\x88\x3E\x6B\x72\x0C\x1E\x26\x4E\x93\x64\x33\x01\x73\x04\x13\x73\x53\x9B\x64\x6D\x47\x73\x52\x80\x74\x3C\x7F\x4A\x3C\x9B\x65\x20\x0D\x65\x6F\x0F\x65\xDF\x4B\x7F\x44\x75\x48\x46\x77\x47\x48\x79\x1F\x7B\x42\x10\x7D\x4C\x1E\x40\x29\x45\xE1\x24\x3F\x5A\x21\x5F\x81\x5C\x29\x00\x2F\x1B\x1C\x04\x12\x02\x26\x8E\x74\x0D\x33\x88\x5F\x1B\x1E\x0E\x97\xF7\x16\x90\x15\x5A\x88\xFF\x6F\x1B\x20\x06\x98\xEE\x11\x85\x34\x9F\x2B\x21\x80\x75\xBF\x14\x3B\xDE\x2E\x1E\x6E\x84\x25\x86\x5A\x5B\xBF\x1C\x3F\x97\x96\x1E\x4D\x9A\x72\x8F\x4A\x72\xBF\x16\x02\x8E\x96\x1E\xA4\x80\x4F\x73\x3B\x49\xBF\x18\x02\xA7\x95\x1E\x10\x0F\x41\x09\x11\x1C\xBF\x1C\x19\x75\x97\x9B\xB8\x9B\x1C\xC1\x17\x80\x6C\x39\x9B\x00\x0C\x19\xB6\x96\x58\x3E\x16\x25\xF2\x8F\x1B\x6F\x90\x00\x71\x91\x06\x92\x11\x1C\x9C\x12\x9B\xBE\x9F\x9B\xCF\x9F\x3C\xCF\x34\x97\x5C\x45\x9D\xAE\x5E\x45\xCC\x15\x10\xBD\x96\x2C\xB7\x9C\x19\x3F\x94\x10\xCE\x9E\x9B\x73\x9E\x45\xC6\x96\x9D\x82\x49\x45\xC7\x9F\x9D", -"\xCF\x97\x9C\xC9\x91\x9E\xD1\x9D\x5A\xF0\x98\x53\xAC\x9F\x9E\xBA\x94\x12\x14\x34\x9F\xD4\x29\x9D\xFF\x0B\x9D\x9E\x15\x9B\x11\x80\x36\xE6\x92\x9D\xCF\x99\x9A\x93\x4B\x9D\xBF\x1F\x48\x87\x6D\x4D\x07\xA8\x97\x4D\x5F\x9C\xFA\x97\x9C\x04\x28\x9F\xCB\x94\x12\xF9\x15\x49\xB8\x9C\x9F\xFF\x93\xA0\x0C\xA0\x20\x9E\x1A\x9E\xBE\x94\xA0\xAC\x9A\x9F\x95\x49\x1F\xB8\x9E\x9E\x40\x21\x9D\x05\x8F\x25\x1D\xA8\x9F\x20\xA1\x22\xC1\x9D\x3A\xD1\x14\x9C\xA8\x5E\x2F\x11\x87\x81\xFA\x9C\x38\x24\xA7\x9B\x26\xA9\xA1\x1F\xAB\xA1\x2A\xA7\x5B\x2C\xA8\x4B\x85\x6F\xA2\x31\xA5\xA4\xA2\x54\x07\x34\xA6\x36\x61\x48\x58\xFA\x9C\x44\x39\xA5\x97\x3B\xAA\xA4\xEF\x99\xA2\xB9\x1B\xA2\xF4\x9D\xA2\x65\x04\xA4\xC3\x96\xA4\xC5\x9C\xA3\x9F\x1D\x4B\x4C\xA1\x1C\x34\x66\x72\x25\xAE\xA5\xFD\x97\x9B\x54\xA2\x58\x40\xA7\xA5\x42\xAE\x56\x5A\xAC\x3A\x5C\xA3\xA3\x9F\x25\x5C\xE7\x9A\x94\xFA\x9C\x9B\xF8\x91\xA5\xD0\x3C\xA6\x6A\x6B\x61\x6B\xA3\xA5\x6D\xA0\x4F\x6F\xA1\x1F\x86\x57\xA4\xE5\x9F\x8A\xD7\x99\x24\xFA\x9D\x88\x37\x99\xA7\x66\xA1\xA4\x7D\xAD\x54\x56\xA0\xA8\x4B\x53\xA4\xB7\x9A\x2C\x5D\xA2\xA5\xCF\x37\x81\x12\xA3\x9B\x24\x11\x82\xD1\x90\x9C\xB7\x91\x82\x8C\x60\x8E\x65\x0B\xA0\x91\xAB\x97\x83\x1C\x9C\x08\x9F\x9E\x83\xA4\x2D\x82\x98\x1C\x49\xAB\xA7\x22\x81\x20\xC1\x1B\x9D\xC5\x2E\x9F\x0C\x1E\xA1\x00\x0E\x9E\xB8\x91\xAB\xBC\x13\xAB\x9B\xA8\x58\xE9\x98\x9F\x80\x9E\xAB\x90\xA1\x9F\x85\x65\x97\xFA\x9C\x19\x34\x68\x9B\xAF\xAB\x29\x9B\x9A\x94\xA8\xA1\x9F\xBA\x5F\x0F\xEE\x9B\x9F\xF6\x31\x2E\xDE\x98\x11\xC8\xA5\x97\x61\x2C\x99\x73\xA2\x8C\xAE\x5A\x94\xC5\xAC\xA7\xD6\xAA\x94\xDF\xA4\xA9\xCA\xAE\x56\xDA\xA0\x48\xDD\x98\x11\x27\x0E\xAD\xF8\x91\xAE\xD4\xA3\xAE\x8D\xA5\xAE\x6F\x87\x9C\xF3\xA8\xAE\x74\xA1\x96\x74\x06\xA0\xC2\x90\xA7\x64\x96\x26\xBF\x11\x9A\x7C\x81\x20\xDB\x97\x80\xBA\xA1\x67\xF4\xA4\x9F\xF6\xAF\x86\xD5\xAF\xAF\xBA\x57\x9C\x0C\xB8\xA6\xB8\x4A\x5B\x02\xB0\xA3\x5B\xA5\xB0\x73\x07\xB0\x38\x29\x95\xB9\x12\xA1\x37\xA0\x7F\xF8\x92\xAA\x75\x9D\x33\x10\x53\xB1\xE4\xA6\x8C\x81\x51\x2E\xFA\x96\x72\x1A\x7D\xA9\x34\xB7\x9B\xFA\x95\x2C\x4C\x89\x9B\x18\x4E\x74\xF8\x98\xB0\x82\x83\xB2\x13\xA6\x14\x15\xA7\xB2\x5E\xA7\xB1\x75\x9E\xB3\x4F\x9B\xAA\x24\x13\xA6\xF8\x98\xA1\xF0\xA4\x9F\x48\xB0\x20\xAF\xA8\xA9\x72\xA3\x34\x2D\xB0\xB0\xF9\x91\x1C\x04\x23\xB3\x24\xB1\x1C\x26\x77\xA6\xF8\x95\xB2\x0C\x19\x89\xB9\x9E\xB4\x15\x89\xAC\xFF\xAA\x4B\xAF\xAA\xB2\x9A\x25\x8C\x04\x17\x49\x8B\x9A\xB4\x46\x1C\x19\x7E\x81\xAA\xF5\xA6\x58\xBA\x4C\xB2\xF9\xAE\xB2\x4D\x58\xAD\x24\x18\xAB\xF1\xAB\xAB\x0F\xBF\x9E\x7A\x9F\x25\x7A\xBD\x38\xF4\x5D\x54\xE7\xAC\xAE\x69\xB1\x58\xEB\xA8\xA2\x81\xA3\x49\xEF\xA9\x7D\x81\xB8\x10\xFD\xA0\x42\x77\xB0\xA3\x79\xB8\xAF\x88\xBC\xB7\x00\x2C\xAF\x68\xB7\xB5\x6A\xB3\xAA\x2C\x72\x10\x45\x7F\xB2\x38\x24\x10\x91\x79\xB0\x93\xBC\x82\x95\xBC\x6D\x83\xB1\x9D\x85\xB0\xB4\x56\xBB\xB7\xFB\x76\xB1\xA1\xB6\xBB\xA3\xB5\x97\x21\x87\xBA\x0D\xA9\xBA\x03\x1B\xBA\x3F\xB8\xA4\x61\xB1\x1C\x8C\x35\x01\x44\xBC\x10\x6B\xBB\xAD\x2B\xBD\xAA\x46\x38\x84\x52\x8C\xAC\xC1\x15\x49\x47\x85\xB3\x5D\xB6\x9F\x18\x17\x01\xC9\xBC\xB8\x2D\xB4\x9A\xC0\xBB\x63\x7B\x83\xBC\x0E\xA1\x1C\x9E\x18\x01\xD6\xB5\x9F\x46\x1C\x38\x64\xB7\xA1\x5E\xA8\xBC\xF4\x90\x99\x28\x98\x1B\xCB\xBC\x10\xC3\x27\xAA\x6E\xB3\x10\x70\xBE\x67\xB8\x9D\xA4\x18\x19\x01\xDB\xB4\x10\xAF\xA0\x24\x17\x9F\x1B\x88\x9E\x23\xD1\x9D\xAC\x18\x1A\x01\xFF\xBF\x9C\x93\x91\xBD\xCE\xB3\x10\xD5\x71\x99\x19\x2B\x9D\xAD\xBC\x79\xAF\xB3\x10\x97\xB0\x9E\xF8\x9D\xC0\x12\xCE\x06\xBF\x10\xBF\x58\x7F\x2B\xA0\xBF\xBE\xAD\xA7\x92\x21\xC8\x1B\x1B\xB5\xA4\x1D\xBB\x73\x65\x9F\xB1\xDF\xB7\x72\x2D\x73\xBC\x15\xC5\x7A\x17\xC4\xC3\x0C\x1F\xB8\xD9\x2C\xC1\xF1\xBE\xC1\x0F\xC2\x10\x11\xCB\xC3\xB8\xB4\xC2\xD4\x7D\x91\x1D\xC9\xC2\x5B\xAB\xC2\x55\x60\xB2\x0C\x12\xBC\x49\xB0\xB3\xAC\xAC\x10\x1B\x0B\xC0\xBE\x9A\x98\xFA\xB7\xBF\x55\x4E\x6F\x7E\x63\xC3\xDA\x98\x11\xEE\xBC\xAD\x5C\xC1\xBB\xCF\x94\xC5\x9E\x64\xC0\x3B\x9F\x6F\xC7\x9D\xC5\xD1\x95\xC0\xBA\x16\xC4\xF8\xB5\x8C\x18\x52\x28\x1F\xC5\xC2\x50\x7A\xC5\x8C\xA4\x2D\x9C\x15\xC7\x38\xC5\x2D\x62\xC2\x6C\x64\xCC\x66\x09\x92\x6C\xC7\x95\xC7\xB8\x9A\xC6\x65\x0C\xC6\x57\xCE\xC7\x00\x0F\xC6\xB6\x27\xB8\x38\x9B\xB9\xE7\xB2\xBD\x24\x1F\x1B\x1D\x0F\xC8\xD7", -"\xB2\xB4\x56\xC4\xC9\xC0\x11\xC9\x18\x1F\x01\x98\xC5\xC9\x35\x13\xA2\x52\xC0\x9D\xE0\xA5\xA8\x99\xA4\xAB\xC3\xA8\x22\xC6\xBC\xB9\xD0\xA8\x11\x53\xB4\xCA\x55\xB6\xCA\x94\x1B\xA4\xA8\xC3\x1B\xAA\xC5\xC3\xA2\xC1\x2E\x54\xBC\x2C\xC2\xA1\xCB\xB5\xA1\xB4\x35\x15\xC7\x4F\xAE\xC5\xCA\xB7\xA9\xAE\xCA\xCB\x8F\xA2\xCB\xBC\x1A\x9F\xBF\x11\x02\x9D\xCE\xC9\x83\x1A\xBE\xA1\xC3\xBF\x25\x23\x10\xCD\xB8\xC8\x6F\xB8\xC5\x63\xCE\xA9\x46\x1F\x1B\xB5\x8D\xCC\x4E\xC4\x12\x38\xBE\xCD\xD8\xBB\xCD\x18\x15\x02\xE2\xC5\xBC\x4B\xBF\xC2\xAB\xC3\xCC\xA3\xC0\xA3\x86\xAC\xB9\x38\x92\xAE\xCA\xC2\xAF\xE7\xCF\xCD\x46\x11\xCE\xF4\x9B\xB3\x0C\x19\xC1\x61\xC1\xB2\xDE\xB9\xC9\x96\xC6\xCD\xCF\x9A\xCF\x96\xBD\xB3\xFE\xC9\xB0\x72\xB5\x13\x4C\xB4\x9F\x66\xB4\x10\xFC\xC3\xC5\x07\xD3\xBC\xAD\xCE\xCE\xA5\xC4\xA7\x14\xB7\xAF\xF3\xC2\xB8\xF5\xC6\xB3\xC1\x13\xB4\xF9\xCE\xA5\xBC\xA8\x9B\x58\xA0\xD0\x9F\xC5\xCB\x75\x9D\xD0\x03\x11\xD2\x18\xB5\xA9\x6E\xA4\xCC\x14\xDF\xCA\x02\xA7\x17\xC8\xC6\xAB\x9F\xA6\xD2\xE1\x28\xD2\x02\x1A\xD2\x75\x98\xA5\x13\xD1\xA7\xC6\xCA\xA9\xBC\xC6\xA3\xC1\x1E\xA4\x4D\xB0\xD2\xB9\xBD\xB9\xF2\x9E\xA2\x2E\xDE\xD3\x86\xB7\xCC\xB5\xAA\x9F\x0B\xDF\x9E\x38\xD0\x00\x3A\xD1\x2E\x3C\xDB\xD4\x5B\xAF\xCE\xB5\xB8\xD4\xD7\xAB\x9B\x18\x16\xC8\xD4\x23\xD5\x55\xDD\x2D\x57\xDD\xCE\x4C\xD4\xBB\x2B\x46\x9E\x62\x4B\xA8\x36\xDD\x2D\x62\xD7\xD4\x38\x96\xA9\x66\xD9\xD5\x15\xDC\xCB\xA7\xC1\xAC\x1B\xD9\xD7\x98\xC0", -}; - - void XmlGetParserBuffer(vl::stream::MemoryStream& stream) - { - vl::stream::MemoryStream compressedStream; - for (vint i = 0; i < parserBufferRows; i++) - { - vint size = i == parserBufferRows - 1 ? parserBufferRemain : parserBufferBlock; - compressedStream.Write((void*)parserBuffer[i], size); - } - compressedStream.SeekFromBegin(0); - vl::stream::LzwDecoder decoder; - vl::stream::DecoderStream decoderStream(compressedStream, decoder); - vl::collections::Array buffer(65536); - while (true) - { - vl::vint size = decoderStream.Read(&buffer[0], 65536); - if (size == 0) break; - stream.Write(&buffer[0], size); - } - stream.SeekFromBegin(0); - } -/*********************************************************************** -Unescaping Function Foward Declarations -***********************************************************************/ - - extern void XmlMergeTextFragment(vl::collections::List>& value, const vl::collections::List& tokens); - extern void XmlUnescapeAttributeValue(vl::parsing::ParsingToken& value, const vl::collections::List& tokens); - extern void XmlUnescapeCData(vl::parsing::ParsingToken& value, const vl::collections::List& tokens); - extern void XmlUnescapeComment(vl::parsing::ParsingToken& value, const vl::collections::List& tokens); - -/*********************************************************************** -Parsing Tree Conversion Driver Implementation -***********************************************************************/ - - class XmlTreeConverter : public vl::parsing::ParsingTreeConverter - { - public: - using vl::parsing::ParsingTreeConverter::SetMember; - - void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) - { - } - - void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) - { - SetMember(tree->content, obj->GetMember(L"content"), tokens); - } - - void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) - { - if(SetMember(tree->content, obj->GetMember(L"content"), tokens)) - { - XmlUnescapeCData(tree->content, tokens); - } - } - - void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) - { - SetMember(tree->name, obj->GetMember(L"name"), tokens); - if(SetMember(tree->value, obj->GetMember(L"value"), tokens)) - { - XmlUnescapeAttributeValue(tree->value, tokens); - } - } - - void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) - { - if(SetMember(tree->content, obj->GetMember(L"content"), tokens)) - { - XmlUnescapeComment(tree->content, tokens); - } - } - - void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) - { - SetMember(tree->name, obj->GetMember(L"name"), tokens); - SetMember(tree->closingName, obj->GetMember(L"closingName"), tokens); - SetMember(tree->attributes, obj->GetMember(L"attributes"), tokens); - if(SetMember(tree->subNodes, obj->GetMember(L"subNodes"), tokens)) - { - XmlMergeTextFragment(tree->subNodes, tokens); - } - } - - void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) - { - SetMember(tree->name, obj->GetMember(L"name"), tokens); - SetMember(tree->attributes, obj->GetMember(L"attributes"), tokens); - } - - void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) - { - SetMember(tree->prologs, obj->GetMember(L"prologs"), tokens); - SetMember(tree->rootElement, obj->GetMember(L"rootElement"), tokens); - } - - vl::Ptr ConvertClass(vl::Ptr obj, const TokenList& tokens)override - { - if(obj->GetType()==L"Text") - { - vl::Ptr tree = new XmlText; - vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); - Fill(tree, obj, tokens); - Fill(tree.Cast(), obj, tokens); - return tree; - } - else if(obj->GetType()==L"CData") - { - vl::Ptr tree = new XmlCData; - vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); - Fill(tree, obj, tokens); - Fill(tree.Cast(), obj, tokens); - return tree; - } - else if(obj->GetType()==L"Attribute") - { - vl::Ptr tree = new XmlAttribute; - vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); - Fill(tree, obj, tokens); - Fill(tree.Cast(), obj, tokens); - return tree; - } - else if(obj->GetType()==L"Comment") - { - vl::Ptr tree = new XmlComment; - vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); - Fill(tree, obj, tokens); - Fill(tree.Cast(), obj, tokens); - return tree; - } - else if(obj->GetType()==L"Element") - { - vl::Ptr tree = new XmlElement; - vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); - Fill(tree, obj, tokens); - Fill(tree.Cast(), obj, tokens); - return tree; - } - else if(obj->GetType()==L"Instruction") - { - vl::Ptr tree = new XmlInstruction; - vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); - Fill(tree, obj, tokens); - Fill(tree.Cast(), obj, tokens); - return tree; - } - else if(obj->GetType()==L"Document") - { - vl::Ptr tree = new XmlDocument; - vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); - Fill(tree, obj, tokens); - Fill(tree.Cast(), obj, tokens); - return tree; - } - else - return 0; - } - }; - - vl::Ptr XmlConvertParsingTreeNode(vl::Ptr node, const vl::collections::List& tokens) - { - XmlTreeConverter converter; - vl::Ptr tree; - converter.SetMember(tree, node, tokens); - return tree; - } - -/*********************************************************************** -Parsing Tree Conversion Implementation -***********************************************************************/ - - vl::Ptr XmlText::Convert(vl::Ptr node, const vl::collections::List& tokens) - { - return XmlConvertParsingTreeNode(node, tokens).Cast(); - } - - vl::Ptr XmlCData::Convert(vl::Ptr node, const vl::collections::List& tokens) - { - return XmlConvertParsingTreeNode(node, tokens).Cast(); - } - - vl::Ptr XmlAttribute::Convert(vl::Ptr node, const vl::collections::List& tokens) - { - return XmlConvertParsingTreeNode(node, tokens).Cast(); - } - - vl::Ptr XmlComment::Convert(vl::Ptr node, const vl::collections::List& tokens) - { - return XmlConvertParsingTreeNode(node, tokens).Cast(); - } - - vl::Ptr XmlElement::Convert(vl::Ptr node, const vl::collections::List& tokens) - { - return XmlConvertParsingTreeNode(node, tokens).Cast(); - } - - vl::Ptr XmlInstruction::Convert(vl::Ptr node, const vl::collections::List& tokens) - { - return XmlConvertParsingTreeNode(node, tokens).Cast(); - } - - vl::Ptr XmlDocument::Convert(vl::Ptr node, const vl::collections::List& tokens) - { - return XmlConvertParsingTreeNode(node, tokens).Cast(); - } - -/*********************************************************************** -Parser Function -***********************************************************************/ - - vl::Ptr XmlParseDocumentAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex) - { - vl::parsing::tabling::ParsingState state(input, table, codeIndex); - state.Reset(L"XDocument"); - vl::Ptr parser=vl::parsing::tabling::CreateStrictParser(table); - vl::Ptr node=parser->Parse(state, errors); - return node; - } - - vl::Ptr XmlParseDocumentAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::vint codeIndex) - { - vl::collections::List> errors; - return XmlParseDocumentAsParsingTreeNode(input, table, errors, codeIndex); - } - - vl::Ptr XmlParseDocument(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex) - { - vl::parsing::tabling::ParsingState state(input, table, codeIndex); - state.Reset(L"XDocument"); - vl::Ptr parser=vl::parsing::tabling::CreateStrictParser(table); - vl::Ptr node=parser->Parse(state, errors); - if(node && errors.Count()==0) - { - return XmlConvertParsingTreeNode(node, state.GetTokens()).Cast(); - } - return 0; - } - - vl::Ptr XmlParseDocument(const vl::WString& input, vl::Ptr table, vl::vint codeIndex) - { - vl::collections::List> errors; - return XmlParseDocument(input, table, errors, codeIndex); - } - - vl::Ptr XmlParseElementAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex) - { - vl::parsing::tabling::ParsingState state(input, table, codeIndex); - state.Reset(L"XElement"); - vl::Ptr parser=vl::parsing::tabling::CreateStrictParser(table); - vl::Ptr node=parser->Parse(state, errors); - return node; - } - - vl::Ptr XmlParseElementAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::vint codeIndex) - { - vl::collections::List> errors; - return XmlParseElementAsParsingTreeNode(input, table, errors, codeIndex); - } - - vl::Ptr XmlParseElement(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex) - { - vl::parsing::tabling::ParsingState state(input, table, codeIndex); - state.Reset(L"XElement"); - vl::Ptr parser=vl::parsing::tabling::CreateStrictParser(table); - vl::Ptr node=parser->Parse(state, errors); - if(node && errors.Count()==0) - { - return XmlConvertParsingTreeNode(node, state.GetTokens()).Cast(); - } - return 0; - } - - vl::Ptr XmlParseElement(const vl::WString& input, vl::Ptr table, vl::vint codeIndex) - { - vl::collections::List> errors; - return XmlParseElement(input, table, errors, codeIndex); - } - -/*********************************************************************** -Table Generation -***********************************************************************/ - - vl::Ptr XmlLoadTable() - { - vl::stream::MemoryStream stream; - XmlGetParserBuffer(stream); - vl::Ptr table=new vl::parsing::tabling::ParsingTable(stream); - table->Initialize(); - return table; - } - - } - } -} - -/*********************************************************************** -REFLECTION\GUITYPEDESCRIPTOR.CPP -***********************************************************************/ - -namespace vl -{ - using namespace collections; - - namespace reflection - { - -/*********************************************************************** -DescriptableObject -***********************************************************************/ - -#ifndef VCZH_DEBUG_NO_REFLECTION - - bool DescriptableObject::IsAggregated() - { - return aggregationInfo != nullptr; - } - - vint DescriptableObject::GetAggregationSize() - { - CHECK_ERROR(IsAggregated(), L"vl::reflection::DescriptableObject::GetAggregationSize()#This function should not be called on non-aggregated objects."); - return aggregationSize; - } - - DescriptableObject* DescriptableObject::GetAggregationRoot() - { - CHECK_ERROR(IsAggregated(), L"vl::reflection::DescriptableObject::GetAggregationRoot()#This function should not be called on non-aggregated objects."); - return aggregationInfo[aggregationSize]; - } - - void DescriptableObject::SetAggregationRoot(DescriptableObject* value) - { - CHECK_ERROR(value != nullptr, L"vl::reflection::DescriptableObject::SetAggregationRoot(Descriptable*)#The root object should not null."); - CHECK_ERROR(value->IsAggregated() && value->GetAggregationRoot() == nullptr, L"vl::reflection::DescriptableObject::SetAggregationRoot(Descriptable*)#The root object should not have an aggregation root."); - if (!IsAggregated()) - { - InitializeAggregation(0); - } - aggregationInfo[aggregationSize] = value; - aggregationInfo[aggregationSize + 1] = value; - for (vint i = 0; i < aggregationSize; i++) - { - if (aggregationInfo[i]) - { - aggregationInfo[i]->SetAggregationRoot(value); - } - } - } - - DescriptableObject* DescriptableObject::GetAggregationParent(vint index) - { - CHECK_ERROR(IsAggregated(), L"vl::reflection::DescriptableObject::GetAggregationParent(vint)#This function should not be called on non-aggregated objects."); - CHECK_ERROR(0 <= index && index < aggregationSize, L"vl::reflection::DescriptableObject::GetAggregationParent(vint)#Index out of range."); - return aggregationInfo[index]; - } - - void DescriptableObject::SetAggregationParent(vint index, DescriptableObject* value) - { - CHECK_ERROR(IsAggregated(), L"vl::reflection::DescriptableObject::SetAggregationParent(vint, DescriptableObject*)#This function should not be called on non-aggregated objects."); - CHECK_ERROR(0 <= index && index < aggregationSize, L"vl::reflection::DescriptableObject::SetAggregationParent(vint, DescriptableObject*)#Index out of range."); - CHECK_ERROR(aggregationInfo[index] == nullptr, L"vl::reflection::DescriptableObject::SetAggregationParent(vint, DescriptableObject*)#This index has been used."); - CHECK_ERROR(value != nullptr, L"vl::reflection::DescriptableObject::SetAggregationParent(vint, DescriptableObject*)#Parent should not be null."); - CHECK_ERROR(!value->IsAggregated() || value->GetAggregationRoot() == nullptr, L"vl::reflection::DescriptableObject::SetAggregationParent(vint, DescriptableObject*)#Parent already has a aggregation root."); - CHECK_ERROR(value->referenceCounter == 0, L"vl::reflection::DescriptableObject::SetAggregationParent(vint, DescriptableObject*)#Parent should not be contained in any smart pointer."); - value->SetAggregationRoot(this); - aggregationInfo[index] = value; - } - - void DescriptableObject::SetAggregationParent(vint index, Ptr& value) - { - CHECK_ERROR(IsAggregated(), L"vl::reflection::DescriptableObject::SetAggregationParent(vint, Ptr&)#This function should not be called on non-aggregated objects."); - CHECK_ERROR(0 <= index && index < aggregationSize, L"vl::reflection::DescriptableObject::SetAggregationParent(vint, Ptr&)#Index out of range."); - CHECK_ERROR(aggregationInfo[index] == nullptr, L"vl::reflection::DescriptableObject::SetAggregationParent(vint, Ptr&)#This index has been used."); - CHECK_ERROR(value, L"vl::reflection::DescriptableObject::SetAggregationParent(vint, Ptr&)#Parent should not be null"); - CHECK_ERROR(!value->IsAggregated() || value->GetAggregationRoot() == nullptr, L"vl::reflection::DescriptableObject::SetAggregationParent(vint, Ptr&)#Parent already has a aggregation root."); - CHECK_ERROR(value->referenceCounter == 1, L"vl::reflection::DescriptableObject::SetAggregationParent(vint, Ptr&)#Parent should not be contained in any other smart pointer."); - value->SetAggregationRoot(this); - - auto parent = value.Detach(); - aggregationInfo[index] = parent; - } - - void DescriptableObject::InitializeAggregation(vint size) - { - CHECK_ERROR(!IsAggregated(), L"vl::reflection::DescriptableObject::InitializeAggregation(vint)#This function should not be called on aggregated objects."); - CHECK_ERROR(size >= 0, L"vl::reflection::DescriptableObject::InitializeAggregation(vint)#Size shout not be negative."); - aggregationSize = size; - aggregationInfo = new DescriptableObject*[size + 2]; - memset(aggregationInfo, 0, sizeof(*aggregationInfo) * (size + 2)); - } -#endif - - void DescriptableObject::FinalizeAggregation() - { -#ifndef VCZH_DEBUG_NO_REFLECTION - if (IsAggregated()) - { - if (auto root = GetAggregationRoot()) - { - if (aggregationInfo[aggregationSize + 1] == nullptr) - { - return; - } - else - { - aggregationInfo[aggregationSize + 1] = nullptr; - } - - if (!root->destructing) - { - destructing = true; - delete root; - } - } - } -#endif - } - - DescriptableObject::DescriptableObject() - :referenceCounter(0) - , sharedPtrDestructorProc(0) -#ifndef VCZH_DEBUG_NO_REFLECTION - , objectSize(0) - , typeDescriptor(0) - , destructing(false) - , aggregationInfo(nullptr) - , aggregationSize(-1) -#endif - { - } - - DescriptableObject::~DescriptableObject() - { -#ifndef VCZH_DEBUG_NO_REFLECTION - destructing = true; - if (IsAggregated()) - { - if (auto root = GetAggregationRoot()) - { - if (aggregationInfo[aggregationSize + 1] != nullptr) - { -#pragma warning (push) -#pragma warning (disable: 4297) - // Your class should call FinalizeAggregation in the destructor if it inherits from AggregatableDescription. - CHECK_ERROR(!IsAggregated(), L"vl::reflection::DescriptableObject::~DescriptableObject0()#FinalizeAggregation function should be called."); -#pragma warning (pop) - } - } - for (vint i = 0; i < aggregationSize; i++) - { - if (auto parent = GetAggregationParent(i)) - { - if (!parent->destructing) - { - delete parent; - } - } - } - delete[] aggregationInfo; - } -#endif - } - -#ifndef VCZH_DEBUG_NO_REFLECTION - - description::ITypeDescriptor* DescriptableObject::GetTypeDescriptor() - { - return typeDescriptor?*typeDescriptor:0; - } - -#endif - - Ptr DescriptableObject::GetInternalProperty(const WString& name) - { - if(!internalProperties) return 0; - vint index=internalProperties->Keys().IndexOf(name); - if(index==-1) return 0; - return internalProperties->Values().Get(index); - } - - void DescriptableObject::SetInternalProperty(const WString& name, Ptr value) - { - if(internalProperties) - { - vint index=internalProperties->Keys().IndexOf(name); - if(index==-1) - { - if(value) - { - internalProperties->Add(name, value); - } - } - else - { - if(value) - { - internalProperties->Set(name, value); - } - else - { - internalProperties->Remove(name); - if(internalProperties->Count()==0) - { - internalProperties=0; - } - } - } - } - else - { - if(value) - { - internalProperties=new InternalPropertyMap; - internalProperties->Add(name, value); - } - } - } - - bool DescriptableObject::Dispose(bool forceDisposing) - { -#ifndef VCZH_DEBUG_NO_REFLECTION - if (IsAggregated()) - { - if (auto root = GetAggregationRoot()) - { - return root->Dispose(forceDisposing); - } - } -#endif - - if (referenceCounter > 0 && forceDisposing) - { - throw description::ValueNotDisposableException(); - } - - if (sharedPtrDestructorProc) - { - return sharedPtrDestructorProc(this, forceDisposing); - } - else - { - delete this; - return true; - } - } - -#ifndef VCZH_DEBUG_NO_REFLECTION - - DescriptableObject* DescriptableObject::SafeGetAggregationRoot() - { - if (IsAggregated()) - { - if (auto root = GetAggregationRoot()) - { - return root; - } - } - return this; - } - -#endif - -/*********************************************************************** -description::Value -***********************************************************************/ - - namespace description - { - Value::Value(DescriptableObject* value) - :valueType(value ? RawPtr :Null) - ,rawPtr(nullptr) -#ifndef VCZH_DEBUG_NO_REFLECTION - ,typeDescriptor(0) -#endif - { -#ifndef VCZH_DEBUG_NO_REFLECTION - if (value) - { - rawPtr = value->SafeGetAggregationRoot(); - } -#else - rawPtr = value; -#endif - } - - Value::Value(Ptr value) - :valueType(value ? SharedPtr : Null) - ,rawPtr(nullptr) -#ifndef VCZH_DEBUG_NO_REFLECTION - ,typeDescriptor(0) -#endif - { -#ifndef VCZH_DEBUG_NO_REFLECTION - if (value) - { - rawPtr = value->SafeGetAggregationRoot(); - sharedPtr = rawPtr; - } -#else - rawPtr = value.Obj(); - sharedPtr = value; -#endif - } - - Value::Value(Ptr value, ITypeDescriptor* associatedTypeDescriptor) - :valueType(value ? BoxedValue : Null) - , rawPtr(nullptr) - , boxedValue(value) -#ifndef VCZH_DEBUG_NO_REFLECTION - , typeDescriptor(associatedTypeDescriptor) -#endif - { - } - - vint Value::Compare(const Value& a, const Value& b)const - { - switch (a.GetValueType()) - { - case Value::RawPtr: - case Value::SharedPtr: - switch (b.GetValueType()) - { - case Value::RawPtr: - case Value::SharedPtr: - { - auto pa = a.GetRawPtr(); - auto pb = b.GetRawPtr(); - if (pa < pb) return -1; - if (pa > pb) return 1; - return 0; - } - case Value::BoxedValue: - return -1; - default: - return 1; - } - case Value::BoxedValue: - switch (b.GetValueType()) - { - case Value::RawPtr: - case Value::SharedPtr: - return 1; - case Value::BoxedValue: - { -#ifndef VCZH_DEBUG_NO_REFLECTION - auto aSt = a.GetTypeDescriptor()->GetSerializableType(); - auto bSt = b.GetTypeDescriptor()->GetSerializableType(); - if (aSt) - { - if (bSt) - { - auto aSt = a.GetTypeDescriptor()->GetSerializableType(); - auto bSt = b.GetTypeDescriptor()->GetSerializableType(); - - WString aText; - WString bText; - aSt->Serialize(a, aText); - bSt->Serialize(b, bText); - if (aText < bText) return -1; - if (aText > bText) return 1; - return 0; - } - else - { - return 1; - } - } - else - { - if (bSt) - { - return -1; - } - else - { - if (a.GetTypeDescriptor() != b.GetTypeDescriptor()) - { - auto aText = a.GetTypeDescriptor()->GetTypeName(); - auto bText = b.GetTypeDescriptor()->GetTypeName(); - if (aText < bText) return -1; - if (aText > bText) return 1; - return 0; - } - - switch (a.GetTypeDescriptor()->GetTypeDescriptorFlags()) - { - case TypeDescriptorFlags::Struct: - { - auto td = a.GetTypeDescriptor(); - vint count = td->GetPropertyCount(); - for (vint i = 0; i < count; i++) - { - auto prop = td->GetProperty(i); - auto ap = prop->GetValue(a); - auto bp = prop->GetValue(b); - vint result = Compare(ap, bp); - if (result != 0) - { - return result; - } - } - } - return 0; - case TypeDescriptorFlags::FlagEnum: - case TypeDescriptorFlags::NormalEnum: - { - auto ai = a.GetTypeDescriptor()->GetEnumType()->FromEnum(a); - auto bi = a.GetTypeDescriptor()->GetEnumType()->FromEnum(b); - if (ai < bi) return -1; - if (ai > bi) return 1; - return 0; - } - default: - return 0; - } - } - } -#else - auto pa = a.GetBoxedValue(); - auto pb = b.GetBoxedValue(); - switch (pa->ComparePrimitive(pb)) - { - case IBoxedValue::Smaller: return -1; - case IBoxedValue::Greater: return 1; - case IBoxedValue::Equal: return 0; - default:; - } - if (pa.Obj() < pb.Obj()) return -1; - if (pa.Obj() > pb.Obj()) return 1; - return 0; -#endif - } - default: - return 1; - } - default: - switch (b.GetValueType()) - { - case Value::RawPtr: - case Value::SharedPtr: - case Value::BoxedValue: - return -1; - default: - return 0; - } - } - } - - Value::Value() - :valueType(Null) - ,rawPtr(0) -#ifndef VCZH_DEBUG_NO_REFLECTION - ,typeDescriptor(0) -#endif - { - } - - Value::Value(const Value& value) - :valueType(value.valueType) - ,rawPtr(value.rawPtr) - ,sharedPtr(value.sharedPtr) - ,boxedValue(value.boxedValue ? value.boxedValue->Copy() : nullptr) -#ifndef VCZH_DEBUG_NO_REFLECTION - ,typeDescriptor(value.typeDescriptor) -#endif - { - } - - Value& Value::operator=(const Value& value) - { - valueType = value.valueType; - rawPtr = value.rawPtr; - sharedPtr = value.sharedPtr; - boxedValue = value.boxedValue ? value.boxedValue->Copy() : nullptr; -#ifndef VCZH_DEBUG_NO_REFLECTION - typeDescriptor = value.typeDescriptor; -#endif - return *this; - } - - Value::ValueType Value::GetValueType()const - { - return valueType; - } - - DescriptableObject* Value::GetRawPtr()const - { - return rawPtr; - } - - Ptr Value::GetSharedPtr()const - { - return sharedPtr; - } - - Ptr Value::GetBoxedValue()const - { - return boxedValue; - } - - bool Value::IsNull()const - { - return valueType == Null; - } - -#ifndef VCZH_DEBUG_NO_REFLECTION - - ITypeDescriptor* Value::GetTypeDescriptor()const - { - switch(valueType) - { - case RawPtr: - case SharedPtr: - return rawPtr?rawPtr->GetTypeDescriptor():0; - case BoxedValue: - return typeDescriptor; - default:; - } - return 0; - } - - WString Value::GetTypeFriendlyName()const - { - switch(valueType) - { - case RawPtr: - return GetTypeDescriptor()->GetTypeName()+L"*"; - case SharedPtr: - return L"Ptr<"+GetTypeDescriptor()->GetTypeName()+L">"; - case BoxedValue: - return GetTypeDescriptor()->GetTypeName(); - default: - return L"null"; - } - } - - bool Value::CanConvertTo(ITypeDescriptor* targetType, ValueType targetValueType)const - { - if(targetType==GetGlobalTypeManager()->GetRootType()) - { - return true; - } - switch(valueType) - { - case Null: - return targetValueType != BoxedValue; - case RawPtr: - case SharedPtr: - if (targetValueType != RawPtr && targetValueType != SharedPtr) return false; - break; - case BoxedValue: - return targetValueType == BoxedValue; - } - return GetTypeDescriptor()->CanConvertTo(targetType); - } - - bool Value::CanConvertTo(ITypeInfo* targetType)const - { - if(valueType==Null && targetType->GetDecorator()==ITypeInfo::Nullable) - { - return true; - } - ValueType targetValueType=ValueType::Null; - { - ITypeInfo* currentType=targetType; - while(currentType) - { - switch(targetType->GetDecorator()) - { - case ITypeInfo::RawPtr: - targetValueType=RawPtr; - currentType=0; - break; - case ITypeInfo::SharedPtr: - targetValueType=SharedPtr; - currentType=0; - break; - case ITypeInfo::TypeDescriptor: - case ITypeInfo::Nullable: - targetValueType=BoxedValue; - currentType=0; - break; - default: - currentType=currentType->GetElementType(); - } - } - } - return CanConvertTo(targetType->GetTypeDescriptor(), targetValueType); - } - -#endif - - Value Value::From(DescriptableObject* value) - { - return Value(value); - } - - Value Value::From(Ptr value) - { - return Value(value); - } - - Value Value::From(Ptr value, ITypeDescriptor* type) - { - return Value(value, type); - } - -#ifndef VCZH_DEBUG_NO_REFLECTION - - IMethodInfo* Value::SelectMethod(IMethodGroupInfo* methodGroup, collections::Array& arguments) - { - if(methodGroup->GetMethodCount()==1) - { - return methodGroup->GetMethod(0); - } - - List methods; - for(vint i=0;iGetMethodCount();i++) - { - IMethodInfo* method=methodGroup->GetMethod(i); - if(method->GetParameterCount()==arguments.Count()) - { - methods.Add(method); - } - } - - if(methods.Count()==0) - { - throw ArgumentCountMismtatchException(methodGroup); - } - else if(methods.Count()==1) - { - return methods[0]; - } - else - { - for(vint i=0;iCheckArguments(arguments); - return method; - } - catch(const TypeDescriptorException&) - { - } - } - return methods[0]; - } - } - - Value Value::Create(ITypeDescriptor* type) - { - Array arguments; - return Create(type, arguments); - } - - Value Value::Create(ITypeDescriptor* type, collections::Array& arguments) - { - IMethodGroupInfo* methodGroup=type->GetConstructorGroup(); - if(!methodGroup) throw ConstructorNotExistsException(type); - - IMethodInfo* method=SelectMethod(methodGroup, arguments); - return method->Invoke(Value(), arguments); - } - - Value Value::Create(const WString& typeName) - { - Array arguments; - return Create(typeName, arguments); - } - - Value Value::Create(const WString& typeName, collections::Array& arguments) - { - ITypeDescriptor* type = vl::reflection::description::GetTypeDescriptor(typeName); - if(!type) throw TypeNotExistsException(typeName); - return Create(type, arguments); - } - - Value Value::InvokeStatic(const WString& typeName, const WString& name) - { - Array arguments; - return InvokeStatic(typeName, name, arguments); - } - - Value Value::InvokeStatic(const WString& typeName, const WString& name, collections::Array& arguments) - { - ITypeDescriptor* type=vl::reflection::description::GetTypeDescriptor(typeName); - if(!type) throw TypeNotExistsException(typeName); - - IMethodGroupInfo* methodGroup=type->GetMethodGroupByName(name, true); - if(!methodGroup) throw MemberNotExistsException(name, type); - - IMethodInfo* method=SelectMethod(methodGroup, arguments); - return method->Invoke(Value(), arguments); - } - - Value Value::GetProperty(const WString& name)const - { - ITypeDescriptor* type=GetTypeDescriptor(); - if(!type) throw ArgumentNullException(L"thisObject", name); - - IPropertyInfo* prop=type->GetPropertyByName(name, true); - if(!prop) throw MemberNotExistsException(name, type); - - return prop->GetValue(*this); - } - - void Value::SetProperty(const WString& name, const Value& newValue) - { - ITypeDescriptor* type=GetTypeDescriptor(); - if(!type) throw ArgumentNullException(L"thisObject", name); - - IPropertyInfo* prop=type->GetPropertyByName(name, true); - if(!prop) throw MemberNotExistsException(name, type); - - prop->SetValue(*this, newValue); - } - - Value Value::Invoke(const WString& name)const - { - Array arguments; - return Invoke(name, arguments); - } - - Value Value::Invoke(const WString& name, collections::Array& arguments)const - { - ITypeDescriptor* type=GetTypeDescriptor(); - if(!type) throw ArgumentNullException(L"thisObject", name); - - IMethodGroupInfo* methodGroup=type->GetMethodGroupByName(name, true); - if(!methodGroup) throw MemberNotExistsException(name, type); - - IMethodInfo* method=SelectMethod(methodGroup, arguments); - return method->Invoke(*this, arguments); - } - - Ptr Value::AttachEvent(const WString& name, const Value& function)const - { - ITypeDescriptor* type=GetTypeDescriptor(); - if(!type) throw ArgumentNullException(L"thisObject", name); - - IEventInfo* eventInfo=type->GetEventByName(name, true); - if(!eventInfo) throw MemberNotExistsException(name, type); - - Ptr proxy=UnboxValue>(function, Description::GetAssociatedTypeDescriptor(), L"function"); - return eventInfo->Attach(*this, proxy); - } - - bool Value::DetachEvent(const WString& name, Ptr handler)const - { - ITypeDescriptor* type = GetTypeDescriptor(); - if (!type) throw ArgumentNullException(L"thisObject", name); - - IEventInfo* eventInfo = type->GetEventByName(name, true); - if (!eventInfo) throw MemberNotExistsException(name, type); - - return eventInfo->Detach(*this, handler); - } - -#endif - - bool Value::DeleteRawPtr() - { - if(valueType!=RawPtr) return false; - if(!rawPtr) return false; - rawPtr->Dispose(true); - *this=Value(); - return true; - } - -#ifndef VCZH_DEBUG_NO_REFLECTION - -/*********************************************************************** -description::TypeManager -***********************************************************************/ - - class TypeManager : public Object, public ITypeManager - { - protected: - Dictionary> typeDescriptors; - List> typeLoaders; - ITypeDescriptor* rootType; - bool loaded; - - public: - TypeManager() - :rootType(0) - ,loaded(false) - { - } - - ~TypeManager() - { - Unload(); - } - - vint GetTypeDescriptorCount()override - { - return typeDescriptors.Values().Count(); - } - - ITypeDescriptor* GetTypeDescriptor(vint index)override - { - return typeDescriptors.Values().Get(index).Obj(); - } - - ITypeDescriptor* GetTypeDescriptor(const WString& name)override - { - vint index=typeDescriptors.Keys().IndexOf(name); - return index==-1?0:typeDescriptors.Values().Get(index).Obj(); - } - - bool SetTypeDescriptor(const WString& name, Ptr typeDescriptor)override - { - if(typeDescriptor && name!=typeDescriptor->GetTypeName()) - { - return false; - } - if(!typeDescriptors.Keys().Contains(name)) - { - if(typeDescriptor) - { - typeDescriptors.Add(name, typeDescriptor); - return true; - } - } - else - { - if(!typeDescriptor) - { - typeDescriptors.Remove(name); - return true; - } - } - return false; - } - - bool AddTypeLoader(Ptr typeLoader)override - { - vint index=typeLoaders.IndexOf(typeLoader.Obj()); - if(index==-1) - { - typeLoaders.Add(typeLoader); - if(loaded) - { - typeLoader->Load(this); - } - return true; - } - else - { - return false; - } - } - - bool RemoveTypeLoader(Ptr typeLoader)override - { - vint index=typeLoaders.IndexOf(typeLoader.Obj()); - if(index!=-1) - { - if(loaded) - { - typeLoader->Unload(this); - } - typeLoaders.RemoveAt(index); - return true; - } - else - { - return false; - } - } - - bool Load()override - { - if(!loaded) - { - loaded=true; - for(vint i=0;iLoad(this); - } - return true; - } - else - { - return false; - } - } - - bool Unload()override - { - if(loaded) - { - loaded=false; - rootType=0; - for(vint i=0;iUnload(this); - } - typeDescriptors.Clear(); - return true; - } - else - { - return false; - } - } - - bool Reload()override - { - Unload(); - Load(); - return true; - } - - bool IsLoaded()override - { - return loaded; - } - - ITypeDescriptor* GetRootType()override - { - if (!rootType) - { - rootType=description::GetTypeDescriptor(); - } - return rootType; - } - }; - -/*********************************************************************** -description::TypeManager helper functions -***********************************************************************/ - - ITypeManager* globalTypeManager=0; - bool initializedGlobalTypeManager=false; - - ITypeManager* GetGlobalTypeManager() - { - if(!initializedGlobalTypeManager) - { - initializedGlobalTypeManager=true; - globalTypeManager=new TypeManager; - } - return globalTypeManager; - } - - bool DestroyGlobalTypeManager() - { - if(initializedGlobalTypeManager && globalTypeManager) - { - delete globalTypeManager; - globalTypeManager=0; - return true; - } - else - { - return false; - } - } - - bool ResetGlobalTypeManager() - { - if(!DestroyGlobalTypeManager()) return false; - initializedGlobalTypeManager=false; - return true; - } - - ITypeDescriptor* GetTypeDescriptor(const WString& name) - { - if(globalTypeManager) - { - if(!globalTypeManager->IsLoaded()) - { - globalTypeManager->Load(); - } - return globalTypeManager->GetTypeDescriptor(name); - } - return 0; - } - -/*********************************************************************** -Cpp Helper Functions -***********************************************************************/ - - WString CppGetFullName(ITypeDescriptor* type) - { - if (auto cpp = type->GetCpp()) - { - if (cpp->GetFullName() == L"void" || cpp->GetFullName() == L"vl::reflection::description::VoidValue") - { - return L"void"; - } - else if (cpp->GetFullName() == L"float") - { - return L"float"; - } - else if (cpp->GetFullName() == L"double") - { - return L"double"; - } - else if (cpp->GetFullName() == L"bool") - { - return L"bool"; - } - else if (cpp->GetFullName() == L"wchar_t") - { - return L"wchar_t"; - } - else - { - return L"::" + cpp->GetFullName(); - } - } - else - { - return L"::vl::" + type->GetTypeName(); - } - } - - WString CppGetReferenceTemplate(IPropertyInfo* prop) - { - if (auto cpp = prop->GetCpp()) - { - return cpp->GetReferenceTemplate(); - } - else if ((prop->GetOwnerTypeDescriptor()->GetTypeDescriptorFlags() & TypeDescriptorFlags::ReferenceType) != TypeDescriptorFlags::Undefined) - { - return WString(L"$This->$Name", false); - } - else - { - return WString(L"$This.$Name", false); - } - } - - WString CppGetClosureTemplate(IMethodInfo* method) - { - if (auto cpp = method->GetCpp()) - { - return cpp->GetClosureTemplate(); - } - - if (method->IsStatic()) - { - return WString(L"::vl::Func<$Func>(&$Type::$Name)", false); - } - else - { - return WString(L"::vl::Func<$Func>($This, &$Type::$Name)", false); - } - } - - WString CppGetInvokeTemplate(IMethodInfo* method) - { - if (auto cpp = method->GetCpp()) - { - return cpp->GetInvokeTemplate(); - } - - if (method->GetOwnerMethodGroup() == method->GetOwnerTypeDescriptor()->GetConstructorGroup()) - { - return WString(L"new $Type($Arguments)", false); - } - else if (method->IsStatic()) - { - return WString(L"$Type::$Name($Arguments)", false); - } - else - { - return WString(L"$This->$Name($Arguments)", false); - } - } - - WString CppGetAttachTemplate(IEventInfo* ev) - { - auto cpp = ev->GetCpp(); - return cpp == nullptr ? WString(L"::vl::__vwsn::EventAttach($This->$Name, $Handler)", false) : cpp->GetAttachTemplate(); - } - - WString CppGetDetachTemplate(IEventInfo* ev) - { - auto cpp = ev->GetCpp(); - return cpp == nullptr ? WString(L"::vl::__vwsn::EventDetach($This->$Name, $Handler)", false) : cpp->GetDetachTemplate(); - } - - WString CppGetInvokeTemplate(IEventInfo* ev) - { - auto cpp = ev->GetCpp(); - return cpp == nullptr ? WString(L"::vl::__vwsn::EventInvoke($This->$Name)($Arguments)", false) : cpp->GetInvokeTemplate(); - } - - bool CppExists(ITypeDescriptor* type) - { - auto cpp = type->GetCpp(); - return cpp == nullptr || cpp->GetFullName() != L"*"; - } - - bool CppExists(IPropertyInfo* prop) - { - if (auto cpp = prop->GetCpp()) - { - return cpp->GetReferenceTemplate() != L"*"; - } - else if (auto method = prop->GetGetter()) - { - return CppExists(method); - } - else - { - return true; - } - } - - bool CppExists(IMethodInfo* method) - { - auto cpp = method->GetCpp(); - return cpp == nullptr || cpp->GetInvokeTemplate() != L"*"; - } - - bool CppExists(IEventInfo* ev) - { - auto cpp = ev->GetCpp(); - return cpp == nullptr || cpp->GetInvokeTemplate() != L"*"; - } - -#endif - } - } -} - -/*********************************************************************** -REFLECTION\GUITYPEDESCRIPTORBUILDER.CPP -***********************************************************************/ - -namespace vl -{ - using namespace collections; - - namespace reflection - { - namespace description - { - -#ifndef VCZH_DEBUG_NO_REFLECTION - -/*********************************************************************** -TypeDescriptorImplBase -***********************************************************************/ - - const WString& TypeDescriptorImplBase::GetFullName() - { - return cppFullTypeName; - } - - const TypeInfoContent* TypeDescriptorImplBase::GetTypeInfoContentInternal() - { - return typeInfoContent; - } - - TypeDescriptorImplBase::TypeDescriptorImplBase(TypeDescriptorFlags _typeDescriptorFlags, const TypeInfoContent* _typeInfoContent) - :typeDescriptorFlags(_typeDescriptorFlags) - , typeInfoContent(_typeInfoContent) - , typeName(_typeInfoContent->typeName, false) - { - switch (typeInfoContent->cppName) - { - case TypeInfoContent::VlppType: - break; - case TypeInfoContent::CppType: - cppFullTypeName = WString(typeInfoContent->typeName, false); - break; - case TypeInfoContent::Renamed: - cppFullTypeName = WString(typeInfoContent->cppFullTypeName, false); - break; - } - } - - TypeDescriptorImplBase::~TypeDescriptorImplBase() - { - } - - ITypeDescriptor::ICpp* TypeDescriptorImplBase::GetCpp() - { - return typeInfoContent->cppName == TypeInfoContent::VlppType ? nullptr : this; - } - - TypeDescriptorFlags TypeDescriptorImplBase::GetTypeDescriptorFlags() - { - return typeDescriptorFlags; - } - - const WString& TypeDescriptorImplBase::GetTypeName() - { - return typeName; - } - -/*********************************************************************** -ValueTypeDescriptorBase -***********************************************************************/ - - void ValueTypeDescriptorBase::LoadInternal() - { - } - - void ValueTypeDescriptorBase::Load() - { - if (!loaded) - { - loaded = true; - LoadInternal(); - } - } - - ValueTypeDescriptorBase::ValueTypeDescriptorBase(TypeDescriptorFlags _typeDescriptorFlags, const TypeInfoContent* _typeInfoContent) - :TypeDescriptorImplBase(_typeDescriptorFlags, _typeInfoContent) - , loaded(false) - { - } - - ValueTypeDescriptorBase::~ValueTypeDescriptorBase() - { - } - - bool ValueTypeDescriptorBase::IsAggregatable() - { - return false; - } - - IValueType* ValueTypeDescriptorBase::GetValueType() - { - Load(); - return valueType.Obj(); - } - - IEnumType* ValueTypeDescriptorBase::GetEnumType() - { - Load(); - return enumType.Obj(); - } - - ISerializableType* ValueTypeDescriptorBase::GetSerializableType() - { - Load(); - return serializableType.Obj(); - } - - vint ValueTypeDescriptorBase::GetBaseTypeDescriptorCount() - { - return 0; - } - - ITypeDescriptor* ValueTypeDescriptorBase::GetBaseTypeDescriptor(vint index) - { - return 0; - } - - bool ValueTypeDescriptorBase::CanConvertTo(ITypeDescriptor* targetType) - { - return this == targetType; - } - - vint ValueTypeDescriptorBase::GetPropertyCount() - { - return 0; - } - - IPropertyInfo* ValueTypeDescriptorBase::GetProperty(vint index) - { - return 0; - } - - bool ValueTypeDescriptorBase::IsPropertyExists(const WString& name, bool inheritable) - { - return false; - } - - IPropertyInfo* ValueTypeDescriptorBase::GetPropertyByName(const WString& name, bool inheritable) - { - return 0; - } - - vint ValueTypeDescriptorBase::GetEventCount() - { - return 0; - } - - IEventInfo* ValueTypeDescriptorBase::GetEvent(vint index) - { - return 0; - } - - bool ValueTypeDescriptorBase::IsEventExists(const WString& name, bool inheritable) - { - return false; - } - - IEventInfo* ValueTypeDescriptorBase::GetEventByName(const WString& name, bool inheritable) - { - return 0; - } - - vint ValueTypeDescriptorBase::GetMethodGroupCount() - { - return 0; - } - - IMethodGroupInfo* ValueTypeDescriptorBase::GetMethodGroup(vint index) - { - return 0; - } - - bool ValueTypeDescriptorBase::IsMethodGroupExists(const WString& name, bool inheritable) - { - return false; - } - - IMethodGroupInfo* ValueTypeDescriptorBase::GetMethodGroupByName(const WString& name, bool inheritable) - { - return 0; - } - - IMethodGroupInfo* ValueTypeDescriptorBase::GetConstructorGroup() - { - return 0; - } - -/*********************************************************************** -TypeDescriptorTypeInfo -***********************************************************************/ - - TypeDescriptorTypeInfo::TypeDescriptorTypeInfo(ITypeDescriptor* _typeDescriptor, TypeInfoHint _hint) - :typeDescriptor(_typeDescriptor) - , hint(_hint) - { - } - - TypeDescriptorTypeInfo::~TypeDescriptorTypeInfo() - { - } - - ITypeInfo::Decorator TypeDescriptorTypeInfo::GetDecorator() - { - return ITypeInfo::TypeDescriptor; - } - - TypeInfoHint TypeDescriptorTypeInfo::GetHint() - { - return hint; - } - - ITypeInfo* TypeDescriptorTypeInfo::GetElementType() - { - return nullptr; - } - - ITypeDescriptor* TypeDescriptorTypeInfo::GetTypeDescriptor() - { - return typeDescriptor; - } - - vint TypeDescriptorTypeInfo::GetGenericArgumentCount() - { - return 0; - } - - ITypeInfo* TypeDescriptorTypeInfo::GetGenericArgument(vint index) - { - return nullptr; - } - - WString TypeDescriptorTypeInfo::GetTypeFriendlyName() - { - return typeDescriptor->GetTypeName(); - } - -/*********************************************************************** -DecoratedTypeInfo -***********************************************************************/ - - DecoratedTypeInfo::DecoratedTypeInfo(Ptr _elementType) - :elementType(_elementType) - { - } - - DecoratedTypeInfo::~DecoratedTypeInfo() - { - } - - TypeInfoHint DecoratedTypeInfo::GetHint() - { - return elementType->GetHint(); - } - - ITypeInfo* DecoratedTypeInfo::GetElementType() - { - return elementType.Obj(); - } - - ITypeDescriptor* DecoratedTypeInfo::GetTypeDescriptor() - { - return elementType->GetTypeDescriptor(); - } - - vint DecoratedTypeInfo::GetGenericArgumentCount() - { - return 0; - } - - ITypeInfo* DecoratedTypeInfo::GetGenericArgument(vint index) - { - return nullptr; - } - -/*********************************************************************** -RawPtrTypeInfo -***********************************************************************/ - - RawPtrTypeInfo::RawPtrTypeInfo(Ptr _elementType) - :DecoratedTypeInfo(_elementType) - { - } - - RawPtrTypeInfo::~RawPtrTypeInfo() - { - } - - ITypeInfo::Decorator RawPtrTypeInfo::GetDecorator() - { - return ITypeInfo::RawPtr; - } - - WString RawPtrTypeInfo::GetTypeFriendlyName() - { - return elementType->GetTypeFriendlyName() + L"*"; - } - -/*********************************************************************** -SharedPtrTypeInfo -***********************************************************************/ - - SharedPtrTypeInfo::SharedPtrTypeInfo(Ptr _elementType) - :DecoratedTypeInfo(_elementType) - { - } - - SharedPtrTypeInfo::~SharedPtrTypeInfo() - { - } - - ITypeInfo::Decorator SharedPtrTypeInfo::GetDecorator() - { - return ITypeInfo::SharedPtr; - } - - WString SharedPtrTypeInfo::GetTypeFriendlyName() - { - return elementType->GetTypeFriendlyName() + L"^"; - } - -/*********************************************************************** -NullableTypeInfo -***********************************************************************/ - - NullableTypeInfo::NullableTypeInfo(Ptr _elementType) - :DecoratedTypeInfo(_elementType) - { - } - - NullableTypeInfo::~NullableTypeInfo() - { - } - - ITypeInfo::Decorator NullableTypeInfo::GetDecorator() - { - return ITypeInfo::Nullable; - } - - WString NullableTypeInfo::GetTypeFriendlyName() - { - return elementType->GetTypeFriendlyName() + L"?"; - } - -/*********************************************************************** -GenericTypeInfo -***********************************************************************/ - - GenericTypeInfo::GenericTypeInfo(Ptr _elementType) - :DecoratedTypeInfo(_elementType) - { - } - - GenericTypeInfo::~GenericTypeInfo() - { - } - - ITypeInfo::Decorator GenericTypeInfo::GetDecorator() - { - return ITypeInfo::Generic; - } - - vint GenericTypeInfo::GetGenericArgumentCount() - { - return genericArguments.Count(); - } - - ITypeInfo* GenericTypeInfo::GetGenericArgument(vint index) - { - return genericArguments[index].Obj(); - } - - WString GenericTypeInfo::GetTypeFriendlyName() - { - WString result = elementType->GetTypeFriendlyName() + L"<"; - FOREACH_INDEXER(Ptr, type, i, genericArguments) - { - WString result = elementType->GetTypeFriendlyName() + L"<"; - FOREACH_INDEXER(Ptr, type, i, genericArguments) - { - if (i>0) result += L", "; - result += type->GetTypeFriendlyName(); - } - result += L">"; - return result; - if (i>0) result += L", "; - result += type->GetTypeFriendlyName(); - } - result += L">"; - return result; - } - - void GenericTypeInfo::AddGenericArgument(Ptr value) - { - genericArguments.Add(value); - } - -/*********************************************************************** -ParameterInfoImpl -***********************************************************************/ - - ParameterInfoImpl::ParameterInfoImpl(IMethodInfo* _ownerMethod, const WString& _name, Ptr _type) - :ownerMethod(_ownerMethod) - ,name(_name) - ,type(_type) - { - } - - ParameterInfoImpl::~ParameterInfoImpl() - { - } - - ITypeDescriptor* ParameterInfoImpl::GetOwnerTypeDescriptor() - { - return ownerMethod->GetOwnerTypeDescriptor(); - } - - const WString& ParameterInfoImpl::GetName() - { - return name; - } - - ITypeInfo* ParameterInfoImpl::GetType() - { - return type.Obj(); - } - - IMethodInfo* ParameterInfoImpl::GetOwnerMethod() - { - return ownerMethod; - } - -/*********************************************************************** -MethodInfoImpl -***********************************************************************/ - - MethodInfoImpl::MethodInfoImpl(IMethodGroupInfo* _ownerMethodGroup, Ptr _return, bool _isStatic) - :ownerMethodGroup(_ownerMethodGroup) - ,ownerProperty(0) - ,returnInfo(_return) - ,isStatic(_isStatic) - { - } - - MethodInfoImpl::~MethodInfoImpl() - { - } - - ITypeDescriptor* MethodInfoImpl::GetOwnerTypeDescriptor() - { - return ownerMethodGroup->GetOwnerTypeDescriptor(); - } - - IPropertyInfo* MethodInfoImpl::GetOwnerProperty() - { - return ownerProperty; - } - - const WString& MethodInfoImpl::GetName() - { - return ownerMethodGroup->GetName(); - } - - IMethodGroupInfo* MethodInfoImpl::GetOwnerMethodGroup() - { - return ownerMethodGroup; - } - - vint MethodInfoImpl::GetParameterCount() - { - return parameters.Count(); - } - - IParameterInfo* MethodInfoImpl::GetParameter(vint index) - { - if(0<=index && index& arguments) - { - if(arguments.Count()!=parameters.Count()) - { - throw ArgumentCountMismtatchException(ownerMethodGroup); - } - for(vint i=0;iGetType())) - { - throw ArgumentTypeMismtatchException(parameters[i]->GetName(), parameters[i]->GetType(), arguments[i]); - } - } - } - - Value MethodInfoImpl::Invoke(const Value& thisObject, collections::Array& arguments) - { - if(thisObject.IsNull()) - { - if(!isStatic) - { - throw ArgumentNullException(L"thisObject", this); - } - } - else if(!thisObject.CanConvertTo(ownerMethodGroup->GetOwnerTypeDescriptor(), Value::RawPtr)) - { - throw ArgumentTypeMismtatchException(L"thisObject", ownerMethodGroup->GetOwnerTypeDescriptor(), Value::RawPtr, thisObject); - } - CheckArguments(arguments); - return InvokeInternal(thisObject, arguments); - } - - Value MethodInfoImpl::CreateFunctionProxy(const Value& thisObject) - { - if(thisObject.IsNull()) - { - if(!isStatic) - { - throw ArgumentNullException(L"thisObject", this); - } - } - else if(!thisObject.CanConvertTo(ownerMethodGroup->GetOwnerTypeDescriptor(), Value::RawPtr)) - { - throw ArgumentTypeMismtatchException(L"thisObject", ownerMethodGroup->GetOwnerTypeDescriptor(), Value::RawPtr, thisObject); - } - return CreateFunctionProxyInternal(thisObject); - } - - bool MethodInfoImpl::AddParameter(Ptr parameter) - { - for(vint i=0;iGetName()==parameter->GetName()) - { - return false; - } - } - parameters.Add(parameter); - return true; - } - - bool MethodInfoImpl::SetOwnerMethodgroup(IMethodGroupInfo* _ownerMethodGroup) - { - if(ownerMethodGroup) return false; - ownerMethodGroup=_ownerMethodGroup; - return true; - } - -/*********************************************************************** -MethodGroupInfoImpl -***********************************************************************/ - - MethodGroupInfoImpl::MethodGroupInfoImpl(ITypeDescriptor* _ownerTypeDescriptor, const WString& _name) - :ownerTypeDescriptor(_ownerTypeDescriptor) - ,name(_name) - { - } - - MethodGroupInfoImpl::~MethodGroupInfoImpl() - { - } - - ITypeDescriptor* MethodGroupInfoImpl::GetOwnerTypeDescriptor() - { - return ownerTypeDescriptor; - } - - const WString& MethodGroupInfoImpl::GetName() - { - return name; - } - - vint MethodGroupInfoImpl::GetMethodCount() - { - return methods.Count(); - } - - IMethodInfo* MethodGroupInfoImpl::GetMethod(vint index) - { - if(0<=index && index _method) - { - methods.Add(_method); - return true; - } - -/*********************************************************************** -EventInfoImpl -***********************************************************************/ - - EventInfoImpl::EventInfoImpl(ITypeDescriptor* _ownerTypeDescriptor, const WString& _name) - :ownerTypeDescriptor(_ownerTypeDescriptor) - ,name(_name) - { - } - - EventInfoImpl::~EventInfoImpl() - { - } - - ITypeDescriptor* EventInfoImpl::GetOwnerTypeDescriptor() - { - return ownerTypeDescriptor; - } - - ITypeInfo* EventInfoImpl::GetHandlerType() - { - if(!handlerType) - { - handlerType=GetHandlerTypeInternal(); - } - return handlerType.Obj(); - } - - vint EventInfoImpl::GetObservingPropertyCount() - { - return observingProperties.Count(); - } - - IPropertyInfo* EventInfoImpl::GetObservingProperty(vint index) - { - return observingProperties[index]; - } - - const WString& EventInfoImpl::GetName() - { - return name; - } - - Ptr EventInfoImpl::Attach(const Value& thisObject, Ptr handler) - { - if(thisObject.IsNull()) - { - throw ArgumentNullException(L"thisObject", this); - } - else if(!thisObject.CanConvertTo(ownerTypeDescriptor, Value::RawPtr)) - { - throw ArgumentTypeMismtatchException(L"thisObject", ownerTypeDescriptor, Value::RawPtr, thisObject); - } - - DescriptableObject* rawThisObject=thisObject.GetRawPtr(); - if(rawThisObject) - { - return AttachInternal(rawThisObject, handler); - } - else - { - return nullptr; - } - } - - bool EventInfoImpl::Detach(const Value& thisObject, Ptr handler) - { - if (thisObject.IsNull()) - { - throw ArgumentNullException(L"thisObject", this); - } - else if (!thisObject.CanConvertTo(ownerTypeDescriptor, Value::RawPtr)) - { - throw ArgumentTypeMismtatchException(L"thisObject", ownerTypeDescriptor, Value::RawPtr, thisObject); - } - - DescriptableObject* rawThisObject = thisObject.GetRawPtr(); - if (rawThisObject) - { - return DetachInternal(rawThisObject, handler); - } - else - { - return false; - } - } - - void EventInfoImpl::Invoke(const Value& thisObject, Ptr arguments) - { - if(thisObject.IsNull()) - { - throw ArgumentNullException(L"thisObject", this); - } - else if(!thisObject.CanConvertTo(ownerTypeDescriptor, Value::RawPtr)) - { - throw ArgumentTypeMismtatchException(L"thisObject", ownerTypeDescriptor, Value::RawPtr, thisObject); - } - - DescriptableObject* rawThisObject=thisObject.GetRawPtr(); - if(rawThisObject) - { - InvokeInternal(rawThisObject, arguments); - } - else - { - return; - } - } - -/*********************************************************************** -PropertyInfoImpl -***********************************************************************/ - - PropertyInfoImpl::PropertyInfoImpl(ITypeDescriptor* _ownerTypeDescriptor, const WString& _name, MethodInfoImpl* _getter, MethodInfoImpl* _setter, EventInfoImpl* _valueChangedEvent) - :ownerTypeDescriptor(_ownerTypeDescriptor) - ,name(_name) - ,getter(_getter) - ,setter(_setter) - ,valueChangedEvent(_valueChangedEvent) - { - if(getter) getter->ownerProperty=this; - if(setter) setter->ownerProperty=this; - if(valueChangedEvent) - { - valueChangedEvent->observingProperties.Add(this); - } - } - - PropertyInfoImpl::~PropertyInfoImpl() - { - } - - ITypeDescriptor* PropertyInfoImpl::GetOwnerTypeDescriptor() - { - return ownerTypeDescriptor; - } - - const WString& PropertyInfoImpl::GetName() - { - return name; - } - - IPropertyInfo::ICpp* PropertyInfoImpl::GetCpp() - { - return nullptr; - } - - bool PropertyInfoImpl::IsReadable() - { - return getter!=0; - } - - bool PropertyInfoImpl::IsWritable() - { - return setter!=0; - } - - ITypeInfo* PropertyInfoImpl::GetReturn() - { - return getter?getter->GetReturn():0; - } - - IMethodInfo* PropertyInfoImpl::GetGetter() - { - return getter; - } - - IMethodInfo* PropertyInfoImpl::GetSetter() - { - return setter; - } - - IEventInfo* PropertyInfoImpl::GetValueChangedEvent() - { - return valueChangedEvent; - } - - Value PropertyInfoImpl::GetValue(const Value& thisObject) - { - if(getter) - { - Array arguments; - return getter->Invoke(thisObject, arguments); - } - else - { - throw PropertyIsNotReadableException(this); - } - } - - void PropertyInfoImpl::SetValue(Value& thisObject, const Value& newValue) - { - if(setter) - { - Array arguments(1); - arguments[0]=newValue; - setter->Invoke(thisObject, arguments); - } - else - { - throw PropertyIsNotWritableException(this); - } - } - -/*********************************************************************** -PropertyInfoImpl_StaticCpp -***********************************************************************/ - - const WString& PropertyInfoImpl_StaticCpp::GetReferenceTemplate() - { - return referenceTemplate; - } - - PropertyInfoImpl_StaticCpp::PropertyInfoImpl_StaticCpp(ITypeDescriptor* _ownerTypeDescriptor, const WString& _name, MethodInfoImpl* _getter, MethodInfoImpl* _setter, EventInfoImpl* _valueChangedEvent, const WString& _referenceTemplate) - :PropertyInfoImpl(_ownerTypeDescriptor, _name, _getter, _setter, _valueChangedEvent) - , referenceTemplate(_referenceTemplate) - { - } - - PropertyInfoImpl_StaticCpp::~PropertyInfoImpl_StaticCpp() - { - } - - IPropertyInfo::ICpp* PropertyInfoImpl_StaticCpp::GetCpp() - { - return this; - } - -/*********************************************************************** -FieldInfoImpl -***********************************************************************/ - - FieldInfoImpl::FieldInfoImpl(ITypeDescriptor* _ownerTypeDescriptor, const WString& _name, Ptr _returnInfo) - :ownerTypeDescriptor(_ownerTypeDescriptor) - ,name(_name) - ,returnInfo(_returnInfo) - { - } - - FieldInfoImpl::~FieldInfoImpl() - { - } - - ITypeDescriptor* FieldInfoImpl::GetOwnerTypeDescriptor() - { - return ownerTypeDescriptor; - } - - const WString& FieldInfoImpl::GetName() - { - return name; - } - - bool FieldInfoImpl::IsReadable() - { - return true; - } - - bool FieldInfoImpl::IsWritable() - { - return true; - } - - ITypeInfo* FieldInfoImpl::GetReturn() - { - return returnInfo.Obj(); - } - - IMethodInfo* FieldInfoImpl::GetGetter() - { - return 0; - } - - IMethodInfo* FieldInfoImpl::GetSetter() - { - return 0; - } - - IEventInfo* FieldInfoImpl::GetValueChangedEvent() - { - return 0; - } - - Value FieldInfoImpl::GetValue(const Value& thisObject) - { - if(thisObject.IsNull()) - { - throw ArgumentNullException(L"thisObject", this); - } - else - { - auto td = thisObject.GetTypeDescriptor(); - auto valueType = td->GetValueType() ? Value::BoxedValue : Value::RawPtr; - if(!thisObject.CanConvertTo(ownerTypeDescriptor, valueType)) - { - throw ArgumentTypeMismtatchException(L"thisObject", ownerTypeDescriptor, valueType, thisObject); - } - } - return GetValueInternal(thisObject); - } - - void FieldInfoImpl::SetValue(Value& thisObject, const Value& newValue) - { - if(thisObject.IsNull()) - { - throw ArgumentNullException(L"thisObject", this); - } - else - { - auto td = thisObject.GetTypeDescriptor(); - auto valueType = td->GetValueType() ? Value::BoxedValue : Value::RawPtr; - if(!thisObject.CanConvertTo(ownerTypeDescriptor, valueType)) - { - throw ArgumentTypeMismtatchException(L"thisObject", ownerTypeDescriptor, valueType, thisObject); - } - } - if(!newValue.CanConvertTo(returnInfo.Obj())) - { - throw ArgumentTypeMismtatchException(L"newValue", returnInfo.Obj(), newValue); - } - SetValueInternal(thisObject, newValue); - } - -/*********************************************************************** -TypeDescriptorImpl -***********************************************************************/ - - MethodGroupInfoImpl* TypeDescriptorImpl::PrepareMethodGroup(const WString& name) - { - vint index=methodGroups.Keys().IndexOf(name); - if(index==-1) - { - Ptr methodGroup=new MethodGroupInfoImpl(this, name); - methodGroups.Add(name, methodGroup); - return methodGroup.Obj(); - } - else - { - return methodGroups.Values().Get(index).Obj(); - } - } - - MethodGroupInfoImpl* TypeDescriptorImpl::PrepareConstructorGroup() - { - if(!constructorGroup) - { - constructorGroup=new MethodGroupInfoImpl(this, L""); - } - return constructorGroup.Obj(); - } - - IPropertyInfo* TypeDescriptorImpl::AddProperty(Ptr value) - { - properties.Add(value->GetName(), value); - return value.Obj(); - } - - IEventInfo* TypeDescriptorImpl::AddEvent(Ptr value) - { - events.Add(value->GetName(), value); - return value.Obj(); - } - - IMethodInfo* TypeDescriptorImpl::AddMethod(const WString& name, Ptr value) - { - MethodGroupInfoImpl* methodGroup=PrepareMethodGroup(name); - value->SetOwnerMethodgroup(methodGroup); - methodGroup->AddMethod(value); - return value.Obj(); - } - - IMethodInfo* TypeDescriptorImpl::AddConstructor(Ptr value) - { - MethodGroupInfoImpl* methodGroup=PrepareConstructorGroup(); - value->SetOwnerMethodgroup(methodGroup); - methodGroup->AddMethod(value); - return value.Obj(); - } - - void TypeDescriptorImpl::AddBaseType(ITypeDescriptor* value) - { - baseTypeDescriptors.Add(value); - } - - void TypeDescriptorImpl::Load() - { - if(!loaded) - { - loaded=true; - LoadInternal(); - } - } - - TypeDescriptorImpl::TypeDescriptorImpl(TypeDescriptorFlags _typeDescriptorFlags, const TypeInfoContent* _typeInfoContent) - :TypeDescriptorImplBase(_typeDescriptorFlags, _typeInfoContent) - ,loaded(false) - { - } - - TypeDescriptorImpl::~TypeDescriptorImpl() - { - } - - bool TypeDescriptorImpl::IsAggregatable() - { - return false; - } - - IValueType* TypeDescriptorImpl::GetValueType() - { - return nullptr; - } - - IEnumType* TypeDescriptorImpl::GetEnumType() - { - return nullptr; - } - - ISerializableType* TypeDescriptorImpl::GetSerializableType() - { - return nullptr; - } - - vint TypeDescriptorImpl::GetBaseTypeDescriptorCount() - { - Load(); - return baseTypeDescriptors.Count(); - } - - ITypeDescriptor* TypeDescriptorImpl::GetBaseTypeDescriptor(vint index) - { - Load(); - if(0<=index && indexCanConvertTo(targetType)) return true; - } - return false; - } - - vint TypeDescriptorImpl::GetPropertyCount() - { - Load(); - return properties.Count(); - } - - IPropertyInfo* TypeDescriptorImpl::GetProperty(vint index) - { - Load(); - if(0<=index && indexIsPropertyExists(name, true)) - { - return true; - } - } - } - return false; - } - - IPropertyInfo* TypeDescriptorImpl::GetPropertyByName(const WString& name, bool inheritable) - { - Load(); - vint index=properties.Keys().IndexOf(name); - if(index!=-1) - { - return properties.Values().Get(index).Obj(); - } - if(inheritable) - { - for(vint i=0;iGetPropertyByName(name, true); - if(result) - { - return result; - } - } - } - return 0; - } - - vint TypeDescriptorImpl::GetEventCount() - { - Load(); - return events.Count(); - } - - IEventInfo* TypeDescriptorImpl::GetEvent(vint index) - { - Load(); - if(0<=index && indexIsEventExists(name, true)) - { - return true; - } - } - } - return false; - } - - IEventInfo* TypeDescriptorImpl::GetEventByName(const WString& name, bool inheritable) - { - Load(); - vint index=events.Keys().IndexOf(name); - if(index!=-1) - { - return events.Values().Get(index).Obj(); - } - if(inheritable) - { - for(vint i=0;iGetEventByName(name, true); - if(result) - { - return result; - } - } - } - return 0; - } - - vint TypeDescriptorImpl::GetMethodGroupCount() - { - Load(); - return methodGroups.Count(); - } - - IMethodGroupInfo* TypeDescriptorImpl::GetMethodGroup(vint index) - { - Load(); - if(0<=index && indexIsMethodGroupExists(name, true)) - { - return true; - } - } - } - return false; - } - - IMethodGroupInfo* TypeDescriptorImpl::GetMethodGroupByName(const WString& name, bool inheritable) - { - Load(); - vint index=methodGroups.Keys().IndexOf(name); - if(index!=-1) - { - return methodGroups.Values().Get(index).Obj(); - } - if(inheritable) - { - for(vint i=0;iGetMethodGroupByName(name, true); - if(result) - { - return result; - } - } - } - return 0; - } - - IMethodGroupInfo* TypeDescriptorImpl::GetConstructorGroup() - { - Load(); - return constructorGroup.Obj(); - } -#endif - -/*********************************************************************** -Function Related -***********************************************************************/ - - namespace internal_helper - { - void UnboxSpecifiedParameter(Ptr arguments, vint index) - { - } - -#ifndef VCZH_DEBUG_NO_REFLECTION - void UnboxSpecifiedParameter(MethodInfoImpl* methodInfo, collections::Array& arguments, vint index) - { - } -#endif - - void AddValueToList(Ptr arguments) - { - } - } - } - } -} - -/*********************************************************************** -REFLECTION\GUITYPEDESCRIPTORPREDEFINED.CPP -***********************************************************************/ - -namespace vl -{ - using namespace collections; - - namespace reflection - { - namespace description - { - -/*********************************************************************** -IValueEnumerable -***********************************************************************/ - - Ptr IValueEnumerable::Create(collections::LazyList values) - { - Ptr> enumerable = new LazyList(values); - return new ValueEnumerableWrapper>>(enumerable); - } - -/*********************************************************************** -IValueList -***********************************************************************/ - - Ptr IValueList::Create() - { - return Create(LazyList()); - } - - Ptr IValueList::Create(Ptr values) - { - return Create(GetLazyList(values)); - } - - Ptr IValueList::Create(collections::LazyList values) - { - Ptr> list = new List; - CopyFrom(*list.Obj(), values); - return new ValueListWrapper>>(list); - } - -/*********************************************************************** -IObservableList -***********************************************************************/ - - class ReversedObservableList : public ObservableListBase - { - protected: - - void NotifyUpdateInternal(vint start, vint count, vint newCount)override - { - if (observableList) - { - observableList->ItemChanged(start, count, newCount); - } - } - public: - IValueObservableList* observableList = nullptr; - }; - - Ptr IValueObservableList::Create() - { - return Create(LazyList()); - } - - Ptr IValueObservableList::Create(Ptr values) - { - return Create(GetLazyList(values)); - } - - Ptr IValueObservableList::Create(collections::LazyList values) - { - auto list = MakePtr(); - CopyFrom(*list.Obj(), values); - auto wrapper = MakePtr>>(list); - list->observableList = wrapper.Obj(); - return wrapper; - } - -/*********************************************************************** -IValueDictionary -***********************************************************************/ - - Ptr IValueDictionary::Create() - { - Ptr> dictionary = new Dictionary; - return new ValueDictionaryWrapper>>(dictionary); - } - - Ptr IValueDictionary::Create(Ptr values) - { - Ptr> dictionary = new Dictionary; - CopyFrom(*dictionary.Obj(), GetLazyList(values)); - return new ValueDictionaryWrapper>>(dictionary); - } - - Ptr IValueDictionary::Create(collections::LazyList> values) - { - Ptr> dictionary = new Dictionary; - CopyFrom(*dictionary.Obj(), values); - return new ValueDictionaryWrapper>>(dictionary); - } - -/*********************************************************************** -IValueException -***********************************************************************/ - - class DefaultValueException : public Object, public IValueException - { - protected: - WString message; - - public: - DefaultValueException(const WString& _message) - :message(_message) - { - } - -#pragma push_macro("GetMessage") -#if defined GetMessage -#undef GetMessage -#endif - WString GetMessage()override - { - return message; - } -#pragma pop_macro("GetMessage") - - bool GetFatal()override - { - return false; - } - - Ptr GetCallStack()override - { - return nullptr; - } - }; - - Ptr IValueException::Create(const WString& message) - { - return new DefaultValueException(message); - } - -/*********************************************************************** -CoroutineResult -***********************************************************************/ - - Value CoroutineResult::GetResult() - { - return result; - } - - void CoroutineResult::SetResult(const Value& value) - { - result = value; - } - - Ptr CoroutineResult::GetFailure() - { - return failure; - } - - void CoroutineResult::SetFailure(Ptr value) - { - failure = value; - } - -/*********************************************************************** -EnumerableCoroutine -***********************************************************************/ - - class CoroutineEnumerator : public Object, public virtual EnumerableCoroutine::IImpl, public Description - { - protected: - EnumerableCoroutine::Creator creator; - Ptr coroutine; - Value current; - vint index = -1; - Ptr joining; - - public: - CoroutineEnumerator(const EnumerableCoroutine::Creator& _creator) - :creator(_creator) - { - } - - Value GetCurrent()override - { - return current; - } - - vint GetIndex()override - { - return index; - } - - bool Next()override - { - if (!coroutine) - { - coroutine = creator(this); - } - - while (coroutine->GetStatus() == CoroutineStatus::Waiting) - { - if (joining) - { - if (joining->Next()) - { - current = joining->GetCurrent(); - index++; - return true; - } - else - { - joining = nullptr; - } - } - - coroutine->Resume(true, nullptr); - if (coroutine->GetStatus() != CoroutineStatus::Waiting) - { - break; - } - - if (!joining) - { - index++; - return true; - } - } - return false; - } - - void OnYield(const Value& value)override - { - current = value; - joining = nullptr; - } - - void OnJoin(Ptr value)override - { - if (!value) - { - throw Exception(L"Cannot join a null collection."); - } - current = Value(); - joining = value->CreateEnumerator(); - } - }; - - class CoroutineEnumerable : public Object, public virtual IValueEnumerable, public Description - { - protected: - EnumerableCoroutine::Creator creator; - - public: - CoroutineEnumerable(const EnumerableCoroutine::Creator& _creator) - :creator(_creator) - { - } - - Ptr CreateEnumerator()override - { - return new CoroutineEnumerator(creator); - } - }; - - void EnumerableCoroutine::YieldAndPause(IImpl* impl, const Value& value) - { - impl->OnYield(value); - } - - void EnumerableCoroutine::JoinAndPause(IImpl* impl, Ptr value) - { - impl->OnJoin(value); - } - - void EnumerableCoroutine::ReturnAndExit(IImpl* impl) - { - } - - Ptr EnumerableCoroutine::Create(const Creator& creator) - { - return new CoroutineEnumerable(creator); - } - -/*********************************************************************** -IAsync -***********************************************************************/ - - class DelayAsync : public Object, public virtual IAsync, public Description - { - protected: - SpinLock lock; - vint milliseconds; - AsyncStatus status = AsyncStatus::Ready; - - public: - DelayAsync(vint _milliseconds) - :milliseconds(_milliseconds) - { - } - - AsyncStatus GetStatus()override - { - return status; - } - - bool Execute(const Func)>& _callback)override - { - SPIN_LOCK(lock) - { - if (status != AsyncStatus::Ready) return false; - status = AsyncStatus::Executing; - IAsyncScheduler::GetSchedulerForCurrentThread()->DelayExecute([async = Ptr(this), callback = _callback]() - { - if (callback) - { - callback(nullptr); - } - }, milliseconds); - } - return true; - } - }; - - Ptr IAsync::Delay(vint milliseconds) - { - return new DelayAsync(milliseconds); - } - -/*********************************************************************** -IFuture -***********************************************************************/ - - class FutureAndPromiseAsync : public virtual IFuture, public virtual IPromise, public Description - { - public: - SpinLock lock; - AsyncStatus status = AsyncStatus::Ready; - Ptr cr; - Func)> callback; - - void ExecuteCallbackAndClear() - { - status = AsyncStatus::Stopped; - if (callback) - { - callback(cr); - } - cr = nullptr; - callback = {}; - } - - template - bool Send(F f) - { - SPIN_LOCK(lock) - { - if (status == AsyncStatus::Stopped || cr) return false; - cr = MakePtr(); - f(); - if (status == AsyncStatus::Executing) - { - ExecuteCallbackAndClear(); - } - } - return true; - } - - AsyncStatus GetStatus()override - { - return status; - } - - bool Execute(const Func)>& _callback)override - { - SPIN_LOCK(lock) - { - if (status != AsyncStatus::Ready) return false; - callback = _callback; - if (cr) - { - ExecuteCallbackAndClear(); - } - else - { - status = AsyncStatus::Executing; - } - } - return true; - } - - Ptr GetPromise()override - { - return this; - } - - bool SendResult(const Value& result)override - { - return Send([=]() - { - cr->SetResult(result); - }); - } - - bool SendFailure(Ptr failure)override - { - return Send([=]() - { - cr->SetFailure(failure); - }); - } - }; - - Ptr IFuture::Create() - { - return new FutureAndPromiseAsync(); - } - -/*********************************************************************** -IAsyncScheduler -***********************************************************************/ - - class AsyncSchedulerMap - { - public: - Dictionary> schedulers; - Ptr defaultScheduler; - }; - - AsyncSchedulerMap* asyncSchedulerMap = nullptr; - SpinLock asyncSchedulerLock; - -#define ENSURE_ASYNC_SCHEDULER_MAP\ - if (!asyncSchedulerMap) asyncSchedulerMap = new AsyncSchedulerMap; - -#define DISPOSE_ASYNC_SCHEDULER_MAP_IF_NECESSARY\ - if (asyncSchedulerMap->schedulers.Count() == 0 && !asyncSchedulerMap->defaultScheduler)\ - {\ - delete asyncSchedulerMap;\ - asyncSchedulerMap = nullptr;\ - }\ - - void IAsyncScheduler::RegisterDefaultScheduler(Ptr scheduler) - { - SPIN_LOCK(asyncSchedulerLock) - { - ENSURE_ASYNC_SCHEDULER_MAP - CHECK_ERROR(!asyncSchedulerMap->defaultScheduler, L"IAsyncScheduler::RegisterDefaultScheduler()#A default scheduler has already been registered."); - asyncSchedulerMap->defaultScheduler = scheduler; - } - } - - void IAsyncScheduler::RegisterSchedulerForCurrentThread(Ptr scheduler) - { - SPIN_LOCK(asyncSchedulerLock) - { - ENSURE_ASYNC_SCHEDULER_MAP - CHECK_ERROR(!asyncSchedulerMap->schedulers.Keys().Contains(Thread::GetCurrentThreadId()), L"IAsyncScheduler::RegisterDefaultScheduler()#A scheduler for this thread has already been registered."); - asyncSchedulerMap->schedulers.Add(Thread::GetCurrentThreadId(), scheduler); - } - } - - Ptr IAsyncScheduler::UnregisterDefaultScheduler() - { - Ptr scheduler; - SPIN_LOCK(asyncSchedulerLock) - { - if (asyncSchedulerMap) - { - scheduler = asyncSchedulerMap->defaultScheduler; - asyncSchedulerMap->defaultScheduler = nullptr; - DISPOSE_ASYNC_SCHEDULER_MAP_IF_NECESSARY - } - } - return scheduler; - } - - Ptr IAsyncScheduler::UnregisterSchedulerForCurrentThread() - { - Ptr scheduler; - SPIN_LOCK(asyncSchedulerLock) - { - if (asyncSchedulerMap) - { - vint index = asyncSchedulerMap->schedulers.Keys().IndexOf(Thread::GetCurrentThreadId()); - if (index != -1) - { - scheduler = asyncSchedulerMap->schedulers.Values()[index]; - asyncSchedulerMap->schedulers.Remove(Thread::GetCurrentThreadId()); - } - DISPOSE_ASYNC_SCHEDULER_MAP_IF_NECESSARY - } - } - return scheduler; - } - -#undef ENSURE_ASYNC_SCHEDULER_MAP -#undef DISPOSE_ASYNC_SCHEDULER_MAP_IF_NECESSARY - - Ptr IAsyncScheduler::GetSchedulerForCurrentThread() - { - Ptr scheduler; - SPIN_LOCK(asyncSchedulerLock) - { - CHECK_ERROR(asyncSchedulerMap != nullptr, L"IAsyncScheduler::GetSchedulerForCurrentThread()#There is no scheduler registered for the current thread."); - vint index = asyncSchedulerMap->schedulers.Keys().IndexOf(Thread::GetCurrentThreadId()); - if (index != -1) - { - scheduler = asyncSchedulerMap->schedulers.Values()[index]; - } - else if (asyncSchedulerMap->defaultScheduler) - { - scheduler = asyncSchedulerMap->defaultScheduler; - } - else - { - CHECK_FAIL(L"IAsyncScheduler::GetSchedulerForCurrentThread()#There is no scheduler registered for the current thread."); - } - } - return scheduler; - } - -/*********************************************************************** -AsyncCoroutine -***********************************************************************/ - - class CoroutineAsync : public Object, public virtual AsyncCoroutine::IImpl, public Description - { - protected: - Ptr coroutine; - AsyncCoroutine::Creator creator; - Ptr scheduler; - Func)> callback; - Value result; - - public: - CoroutineAsync(AsyncCoroutine::Creator _creator) - :creator(_creator) - { - } - - AsyncStatus GetStatus()override - { - if (!coroutine) - { - return AsyncStatus::Ready; - } - else if (coroutine->GetStatus() != CoroutineStatus::Stopped) - { - return AsyncStatus::Executing; - } - else - { - return AsyncStatus::Stopped; - } - } - - bool Execute(const Func)>& _callback)override - { - if (coroutine) return false; - scheduler = IAsyncScheduler::GetSchedulerForCurrentThread(); - callback = _callback; - coroutine = creator(this); - OnContinue(nullptr); - return true; - } - - Ptr GetScheduler()override - { - return scheduler; - } - - void OnContinue(Ptr output)override - { - scheduler->Execute([async = Ptr(this), output]() - { - async->coroutine->Resume(false, output); - if (async->coroutine->GetStatus() == CoroutineStatus::Stopped && async->callback) - { - auto result = MakePtr(); - if (async->coroutine->GetFailure()) - { - result->SetFailure(async->coroutine->GetFailure()); - } - else - { - result->SetResult(async->result); - } - async->callback(result); - } - }); - } - - void OnReturn(const Value& value)override - { - result = value; - } - }; - - void AsyncCoroutine::AwaitAndRead(IImpl* impl, Ptr value) - { - value->Execute([async = Ptr(impl)](auto output) - { - async->OnContinue(output); - }); - } - - void AsyncCoroutine::ReturnAndExit(IImpl* impl, const Value& value) - { - impl->OnReturn(value); - } - - Ptr AsyncCoroutine::Create(const Creator& creator) - { - return new CoroutineAsync(creator); - } - void AsyncCoroutine::CreateAndRun(const Creator& creator) - { - MakePtr(creator)->Execute( - [](Ptr cr) - { - if (cr->GetFailure()) - { -#pragma push_macro("GetMessage") -#if defined GetMessage -#undef GetMessage -#endif - throw Exception(cr->GetFailure()->GetMessage()); -#pragma pop_macro("GetMessage") - } - }); - } - -/*********************************************************************** -Libraries -***********************************************************************/ - - namespace system_sys - { - class ReverseEnumerable : public Object, public IValueEnumerable - { - protected: - Ptr list; - - class Enumerator : public Object, public IValueEnumerator - { - protected: - Ptr list; - vint index; - - public: - Enumerator(Ptr _list) - :list(_list), index(_list->GetCount()) - { - } - - Value GetCurrent() - { - return list->Get(index); - } - - vint GetIndex() - { - return list->GetCount() - 1 - index; - } - - bool Next() - { - if (index <= 0) return false; - index--; - return true; - } - }; - - public: - ReverseEnumerable(Ptr _list) - :list(_list) - { - } - - Ptr CreateEnumerator()override - { - return MakePtr(list); - } - }; - } - - Ptr Sys::ReverseEnumerable(Ptr value) - { - auto list = value.Cast(); - if (!list) - { - list = IValueList::Create(GetLazyList(value)); - } - return new system_sys::ReverseEnumerable(list); - } - -#define DEFINE_COMPARE(TYPE)\ - vint Sys::Compare(TYPE a, TYPE b)\ - {\ - auto result = TypedValueSerializerProvider::Compare(a, b);\ - switch (result)\ - {\ - case IBoxedValue::Smaller: return -1;\ - case IBoxedValue::Greater: return 1;\ - case IBoxedValue::Equal: return 0;\ - default:\ - CHECK_FAIL(L"Unexpected compare result.");\ - }\ - }\ - - REFLECTION_PREDEFINED_PRIMITIVE_TYPES(DEFINE_COMPARE) - DEFINE_COMPARE(DateTime) -#undef DEFINE_COMPARE - -#define DEFINE_MINMAX(TYPE)\ - TYPE Math::Min(TYPE a, TYPE b)\ - {\ - return Sys::Compare(a, b) < 0 ? a : b;\ - }\ - TYPE Math::Max(TYPE a, TYPE b)\ - {\ - return Sys::Compare(a, b) > 0 ? a : b;\ - }\ - - REFLECTION_PREDEFINED_PRIMITIVE_TYPES(DEFINE_MINMAX) - DEFINE_MINMAX(DateTime) -#undef DEFINE_MINMAX - } - } -} - -/*********************************************************************** -REFLECTION\GUITYPEDESCRIPTORREFLECTION.CPP -***********************************************************************/ -#include -#include - -namespace vl -{ - using namespace collections; - using namespace regex; - - namespace reflection - { - namespace description - { - -/*********************************************************************** -TypeName -***********************************************************************/ - -#ifndef VCZH_DEBUG_NO_REFLECTION - - IMPL_TYPE_INFO_RENAME(vl::reflection::description::Sys, system::Sys) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::Math, system::Math) - IMPL_TYPE_INFO_RENAME(void, system::Void) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::VoidValue, system::Void) - IMPL_TYPE_INFO_RENAME(vl::reflection::IDescriptable, system::Interface) - IMPL_TYPE_INFO_RENAME(vl::reflection::DescriptableObject, system::ReferenceType) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::Value, system::Object) - IMPL_TYPE_INFO_RENAME(vl::vuint8_t, system::UInt8) - IMPL_TYPE_INFO_RENAME(vl::vuint16_t, system::UInt16) - IMPL_TYPE_INFO_RENAME(vl::vuint32_t, system::UInt32) - IMPL_TYPE_INFO_RENAME(vl::vuint64_t, system::UInt64) - IMPL_TYPE_INFO_RENAME(vl::vint8_t, system::Int8) - IMPL_TYPE_INFO_RENAME(vl::vint16_t, system::Int16) - IMPL_TYPE_INFO_RENAME(vl::vint32_t, system::Int32) - IMPL_TYPE_INFO_RENAME(vl::vint64_t, system::Int64) - IMPL_TYPE_INFO_RENAME(float, system::Single) - IMPL_TYPE_INFO_RENAME(double, system::Double) - IMPL_TYPE_INFO_RENAME(bool, system::Boolean) - IMPL_TYPE_INFO_RENAME(wchar_t, system::Char) - IMPL_TYPE_INFO_RENAME(vl::WString, system::String) - IMPL_TYPE_INFO_RENAME(vl::DateTime, system::DateTime) - IMPL_TYPE_INFO_RENAME(vl::Locale, system::Locale) - - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueEnumerator, system::Enumerator) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueEnumerable, system::Enumerable) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueReadonlyList, system::ReadonlyList) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueList, system::List) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueObservableList, system::ObservableList) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueReadonlyDictionary, system::ReadonlyDictionary) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueDictionary, system::Dictionary) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueInterfaceProxy, system::InterfaceProxy) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueFunctionProxy, system::Function) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueSubscription, system::Subscription) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueCallStack, system::CallStack) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueException, system::Exception) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::CoroutineStatus, system::CoroutineStatus) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::CoroutineResult, system::CoroutineResult) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::ICoroutine, system::Coroutine) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::EnumerableCoroutine::IImpl, system::EnumerableCoroutine::IImpl) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::EnumerableCoroutine, system::EnumerableCoroutine) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::AsyncStatus, system::AsyncStatus) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IAsync, system::Async) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IPromise, system::Promise) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IFuture, system::Future) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IAsyncScheduler, system::AsyncScheduler) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::AsyncCoroutine::IImpl, system::AsyncCoroutine::IImpl) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::AsyncCoroutine, system::AsyncCoroutine) - - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IBoxedValue, system::reflection::BoxedValue) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IBoxedValue::CompareResult, system::reflection::ValueType::CompareResult) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IValueType, system::reflection::ValueType) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IEnumType, system::reflection::EnumType) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::ISerializableType, system::reflection::SerializableType) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::ITypeInfo, system::reflection::TypeInfo) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::ITypeInfo::Decorator, system::reflection::TypeInfo::Decorator) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IMemberInfo, system::reflection::MemberInfo) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IEventHandler, system::reflection::EventHandler) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IEventInfo, system::reflection::EventInfo) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IPropertyInfo, system::reflection::PropertyInfo) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IParameterInfo, system::reflection::ParameterInfo) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IMethodInfo, system::reflection::MethodInfo) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::IMethodGroupInfo, system::reflection::MethodGroupInfo) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::TypeDescriptorFlags, system::reflection::TypeDescriptorFlags) - IMPL_TYPE_INFO_RENAME(vl::reflection::description::ITypeDescriptor, system::reflection::TypeDescriptor) - -#endif - -/*********************************************************************** -TypedValueSerializerProvider -***********************************************************************/ - -#define DEFINE_COMPARE(TYPENAME)\ - IBoxedValue::CompareResult TypedValueSerializerProvider::Compare(const TYPENAME& a, const TYPENAME& b)\ - {\ - if (a < b) return IBoxedValue::Smaller;\ - if (a > b) return IBoxedValue::Greater;\ - return IBoxedValue::Equal;\ - }\ - - REFLECTION_PREDEFINED_PRIMITIVE_TYPES(DEFINE_COMPARE) - -#undef DEFINE_COMPARE - - vuint8_t TypedValueSerializerProvider::GetDefaultValue() - { - return 0; - } - - bool TypedValueSerializerProvider::Serialize(const vuint8_t& input, WString& output) - { - output = u64tow(input); - return true; - } - - bool TypedValueSerializerProvider::Deserialize(const WString& input, vuint8_t& output) - { - bool success = false; - vuint64_t result = wtou64_test(input, success); - if (!success) return false; - if (result>_UI8_MAX) return false; - output = (vuint8_t)result; - return true; - } - - //--------------------------------------- - - vuint16_t TypedValueSerializerProvider::GetDefaultValue() - { - return 0; - } - - bool TypedValueSerializerProvider::Serialize(const vuint16_t& input, WString& output) - { - output = u64tow(input); - return true; - } - - bool TypedValueSerializerProvider::Deserialize(const WString& input, vuint16_t& output) - { - bool success = false; - vuint64_t result = wtou64_test(input, success); - if (!success) return false; - if (result>_UI16_MAX) return false; - output = (vuint16_t)result; - return true; - } - - //--------------------------------------- - - vuint32_t TypedValueSerializerProvider::GetDefaultValue() - { - return 0; - } - - bool TypedValueSerializerProvider::Serialize(const vuint32_t& input, WString& output) - { - output = u64tow(input); - return true; - } - - bool TypedValueSerializerProvider::Deserialize(const WString& input, vuint32_t& output) - { - bool success = false; - vuint64_t result = wtou64_test(input, success); - if (!success) return false; - if (result>_UI32_MAX) return false; - output = (vuint32_t)result; - return true; - } - - //--------------------------------------- - - vuint64_t TypedValueSerializerProvider::GetDefaultValue() - { - return 0; - } - - bool TypedValueSerializerProvider::Serialize(const vuint64_t& input, WString& output) - { - output = u64tow(input); - return true; - } - - bool TypedValueSerializerProvider::Deserialize(const WString& input, vuint64_t& output) - { - bool success = false; - vuint64_t result = wtou64_test(input, success); - if (!success) return false; - output = result; - return true; - } - - //--------------------------------------- - - vint8_t TypedValueSerializerProvider::GetDefaultValue() - { - return 0; - } - - bool TypedValueSerializerProvider::Serialize(const vint8_t& input, WString& output) - { - output = i64tow(input); - return true; - } - - bool TypedValueSerializerProvider::Deserialize(const WString& input, vint8_t& output) - { - bool success = false; - vint64_t result = wtoi64_test(input, success); - if (!success) return false; - if (result<_I8_MIN || result>_I8_MAX) return false; - output = (vint8_t)result; - return true; - } - - //--------------------------------------- - - vint16_t TypedValueSerializerProvider::GetDefaultValue() - { - return 0; - } - - bool TypedValueSerializerProvider::Serialize(const vint16_t& input, WString& output) - { - output = i64tow(input); - return true; - } - - bool TypedValueSerializerProvider::Deserialize(const WString& input, vint16_t& output) - { - bool success = false; - vint64_t result = wtoi64_test(input, success); - if (!success) return false; - if (result<_I16_MIN || result>_I16_MAX) return false; - output = (vint16_t)result; - return true; - } - - //--------------------------------------- - - vint32_t TypedValueSerializerProvider::GetDefaultValue() - { - return 0; - } - - bool TypedValueSerializerProvider::Serialize(const vint32_t& input, WString& output) - { - output = i64tow(input); - return true; - } - - bool TypedValueSerializerProvider::Deserialize(const WString& input, vint32_t& output) - { - bool success = false; - vint64_t result = wtoi64_test(input, success); - if (!success) return false; - if (result<_I32_MIN || result>_I32_MAX) return false; - output = (vint32_t)result; - return true; - } - - //--------------------------------------- - - vint64_t TypedValueSerializerProvider::GetDefaultValue() - { - return 0; - } - - bool TypedValueSerializerProvider::Serialize(const vint64_t& input, WString& output) - { - output = i64tow(input); - return true; - } - - bool TypedValueSerializerProvider::Deserialize(const WString& input, vint64_t& output) - { - bool success = false; - vint64_t result = wtoi64_test(input, success); - if (!success) return false; - output = result; - return true; - } - - //--------------------------------------- - - float TypedValueSerializerProvider::GetDefaultValue() - { - return 0; - } - - bool TypedValueSerializerProvider::Serialize(const float& input, WString& output) - { - output = ftow(input); - return true; - } - - bool TypedValueSerializerProvider::Deserialize(const WString& input, float& output) - { - bool success = false; - double result = wtof_test(input, success); - if (!success) return false; - if (result<-FLT_MAX || result>FLT_MAX) return false; - output = (float)result; - return true; - } - - //--------------------------------------- - - double TypedValueSerializerProvider::GetDefaultValue() - { - return 0; - } - - bool TypedValueSerializerProvider::Serialize(const double& input, WString& output) - { - output = ftow(input); - return true; - } - - bool TypedValueSerializerProvider::Deserialize(const WString& input, double& output) - { - bool success = false; - double result = wtof_test(input, success); - if (!success) return false; - output = result; - return true; - } - - //--------------------------------------- - - wchar_t TypedValueSerializerProvider::GetDefaultValue() - { - return 0; - } - - bool TypedValueSerializerProvider::Serialize(const wchar_t& input, WString& output) - { - output = input ? WString(input) : L""; - return true; - } - - bool TypedValueSerializerProvider::Deserialize(const WString& input, wchar_t& output) - { - if (input.Length()>1) return false; - output = input.Length() == 0 ? 0 : input[0]; - return true; - } - - //--------------------------------------- - - WString TypedValueSerializerProvider::GetDefaultValue() - { - return L""; - } - - bool TypedValueSerializerProvider::Serialize(const WString& input, WString& output) - { - output = input; - return true; - } - - bool TypedValueSerializerProvider::Deserialize(const WString& input, WString& output) - { - output = input; - return true; - } - - //--------------------------------------- - - bool TypedValueSerializerProvider::GetDefaultValue() - { - return false; - } - - bool TypedValueSerializerProvider::Serialize(const bool& input, WString& output) - { - output = input ? L"true" : L"false"; - return true; - } - - bool TypedValueSerializerProvider::Deserialize(const WString& input, bool& output) - { - output = input == L"true"; - return input == L"true" || input == L"false"; - } - - //--------------------------------------- - - Locale TypedValueSerializerProvider::GetDefaultValue() - { - return Locale(); - } - - bool TypedValueSerializerProvider::Serialize(const Locale& input, WString& output) - { - output = input.GetName(); - return true; - } - - bool TypedValueSerializerProvider::Deserialize(const WString& input, Locale& output) - { - output = Locale(input); - return true; - } - -/*********************************************************************** -DateTimeValueSerializer -***********************************************************************/ - - BEGIN_GLOBAL_STORAGE_CLASS(DateTimeSerializerStorage) - Regex* regexDateTime = nullptr; - - INITIALIZE_GLOBAL_STORAGE_CLASS - regexDateTime = new Regex(L"(/d/d/d/d)-(/d/d)-(/d/d) (/d/d):(/d/d):(/d/d).(/d/d/d)"); - - FINALIZE_GLOBAL_STORAGE_CLASS - delete regexDateTime; - regexDateTime = nullptr; - - END_GLOBAL_STORAGE_CLASS(DateTimeSerializerStorage) - - DateTime TypedValueSerializerProvider::GetDefaultValue() - { - return DateTime(); - } - - WString FormatDigits(vint number, vint length) - { - WString result = itow(number); - while (result.Length() < length) - { - result = L"0" + result; - } - return result; - } - - bool TypedValueSerializerProvider::Serialize(const DateTime& input, WString& output) - { - output = - FormatDigits(input.year, 4) + L"-" + FormatDigits(input.month, 2) + L"-" + FormatDigits(input.day, 2) + L" " + - FormatDigits(input.hour, 2) + L":" + FormatDigits(input.minute, 2) + L":" + FormatDigits(input.second, 2) + L"." + - FormatDigits(input.milliseconds, 3); - return true; - } - - bool TypedValueSerializerProvider::Deserialize(const WString& input, DateTime& output) - { - Ptr match = GetDateTimeSerializerStorage().regexDateTime->Match(input); - if (!match) return false; - if (!match->Success()) return false; - if (match->Result().Start() != 0) return false; - if (match->Result().Length() != input.Length()) return false; - - vint year = wtoi(match->Groups()[L"Y"].Get(0).Value()); - vint month = wtoi(match->Groups()[L"M"].Get(0).Value()); - vint day = wtoi(match->Groups()[L"D"].Get(0).Value()); - vint hour = wtoi(match->Groups()[L"h"].Get(0).Value()); - vint minute = wtoi(match->Groups()[L"m"].Get(0).Value()); - vint second = wtoi(match->Groups()[L"s"].Get(0).Value()); - vint milliseconds = wtoi(match->Groups()[L"ms"].Get(0).Value()); - - output = DateTime::FromDateTime(year, month, day, hour, minute, second, milliseconds); - return true; - } - - IBoxedValue::CompareResult TypedValueSerializerProvider::Compare(const DateTime& a, const DateTime& b) - { - auto ta = a.filetime; - auto tb = b.filetime; - if (ta < tb) return IBoxedValue::Smaller; - if (ta > tb) return IBoxedValue::Greater; - return IBoxedValue::Equal; - } - -/*********************************************************************** -Helper Functions -***********************************************************************/ - -#ifndef VCZH_DEBUG_NO_REFLECTION - - vint ITypeDescriptor_GetTypeDescriptorCount() - { - return GetGlobalTypeManager()->GetTypeDescriptorCount(); - } - - ITypeDescriptor* ITypeDescriptor_GetTypeDescriptor(vint index) - { - return GetGlobalTypeManager()->GetTypeDescriptor(index); - } - - ITypeDescriptor* ITypeDescriptor_GetTypeDescriptor(const WString& name) - { - return GetGlobalTypeManager()->GetTypeDescriptor(name); - } - - ITypeDescriptor* ITypeDescriptor_GetTypeDescriptor(const Value& value) - { - return value.GetTypeDescriptor(); - } - -#else - - vint ITypeDescriptor_GetTypeDescriptorCount() - { - return 0; - } - - ITypeDescriptor* ITypeDescriptor_GetTypeDescriptor(vint index) - { - return nullptr; - } - - ITypeDescriptor* ITypeDescriptor_GetTypeDescriptor(const WString& name) - { - return nullptr; - } - - ITypeDescriptor* ITypeDescriptor_GetTypeDescriptor(const Value& value) - { - return nullptr; - } - -#endif - -/*********************************************************************** -LoadPredefinedTypes -***********************************************************************/ - -#ifndef VCZH_DEBUG_NO_REFLECTION - -#define _ , - - template<> - struct CustomTypeDescriptorSelector - { - public: - class CustomTypeDescriptorImpl : public TypeDescriptorImpl - { - public: - CustomTypeDescriptorImpl() - :TypeDescriptorImpl(TypeDescriptorFlags::Class, &TypeInfo::content) - { - Description::SetAssociatedTypeDescroptor(this); - } - ~CustomTypeDescriptorImpl() - { - Description::SetAssociatedTypeDescroptor(0); - } - protected: - void LoadInternal()override - { - } - }; - }; - -#define PT(TYPE) PT_##TYPE -#define PT_vint Int -#define PT_vint8_t Int8 -#define PT_vint16_t Int16 -#define PT_vint32_t Int32 -#define PT_vint64_t Int64 -#define PT_vuint8_t UInt8 -#define PT_vuint16_t UInt16 -#define PT_vuint32_t UInt32 -#define PT_vuint64_t UInt64 -#define PT_float Single -#define PT_double Double -#define PT_bool Bool -#define PT_wchar_t Char -#define PT_WString String -#define PT_Locale Locale -#define PT_DateTime DateTime -#define PT_CONCAT_(A, B) A##B -#define PT_CONCAT(A, B) PT_CONCAT_(A, B) - - BEGIN_CLASS_MEMBER(Sys) - CLASS_MEMBER_STATIC_METHOD(Len, { L"value" }) - CLASS_MEMBER_STATIC_METHOD(Left, { L"value" _ L"length" }) - CLASS_MEMBER_STATIC_METHOD(Right, { L"value" _ L"length" }) - CLASS_MEMBER_STATIC_METHOD(Mid, { L"value" _ L"start" _ L"length" }) - CLASS_MEMBER_STATIC_METHOD(Find, { L"value" _ L"substr" }) - CLASS_MEMBER_STATIC_METHOD(ReverseEnumerable, { L"value" }) -#pragma push_macro("CompareString") -#if defined CompareString -#undef CompareString -#endif -#define DEFINE_COMPARE(TYPE) CLASS_MEMBER_STATIC_EXTERNALMETHOD(PT_CONCAT(Compare, PT(TYPE)), PROTECT_PARAMETERS({L"a" _ L"b"}), vint(*)(TYPE, TYPE), vl::reflection::description::Sys::Compare) - REFLECTION_PREDEFINED_PRIMITIVE_TYPES(DEFINE_COMPARE) - DEFINE_COMPARE(DateTime) - DEFINE_COMPARE(vint) -#undef DEFINE_COMPARE -#pragma pop_macro("CompareString") - END_CLASS_MEMBER(Sys) - - BEGIN_CLASS_MEMBER(Math) - CLASS_MEMBER_STATIC_EXTERNALMETHOD(AbsInt8, { L"value" }, vint8_t(*)(vint8_t), vl::reflection::description::Math::Abs) - CLASS_MEMBER_STATIC_EXTERNALMETHOD(AbsInt16, { L"value" }, vint16_t(*)(vint16_t), vl::reflection::description::Math::Abs) - CLASS_MEMBER_STATIC_EXTERNALMETHOD(AbsInt32, { L"value" }, vint32_t(*)(vint32_t), vl::reflection::description::Math::Abs) - CLASS_MEMBER_STATIC_EXTERNALMETHOD(AbsInt64, { L"value" }, vint64_t(*)(vint64_t), vl::reflection::description::Math::Abs) - CLASS_MEMBER_STATIC_EXTERNALMETHOD(AbsSingle, { L"value" }, float(*)(float), vl::reflection::description::Math::Abs) - CLASS_MEMBER_STATIC_EXTERNALMETHOD(AbsDouble, { L"value" }, double(*)(double), vl::reflection::description::Math::Abs) - -#define DEFINE_MINMAX(TYPE)\ - CLASS_MEMBER_STATIC_EXTERNALMETHOD(PT_CONCAT(Min, PT(TYPE)), PROTECT_PARAMETERS({L"a" _ L"b"}), TYPE(*)(TYPE, TYPE), vl::reflection::description::Math::Min)\ - CLASS_MEMBER_STATIC_EXTERNALMETHOD(PT_CONCAT(Max, PT(TYPE)), PROTECT_PARAMETERS({L"a" _ L"b"}), TYPE(*)(TYPE, TYPE), vl::reflection::description::Math::Max)\ - - REFLECTION_PREDEFINED_PRIMITIVE_TYPES(DEFINE_MINMAX) - DEFINE_MINMAX(DateTime) - DEFINE_MINMAX(vint) -#undef DEFINE_MINMAX - - CLASS_MEMBER_STATIC_METHOD(Sin, { L"value" }) - CLASS_MEMBER_STATIC_METHOD(Cos, { L"value" }) - CLASS_MEMBER_STATIC_METHOD(Tan, { L"value" }) - CLASS_MEMBER_STATIC_METHOD(ASin, { L"value" }) - CLASS_MEMBER_STATIC_METHOD(ACos, { L"value" }) - CLASS_MEMBER_STATIC_METHOD(ATan, { L"value" }) - CLASS_MEMBER_STATIC_METHOD(ATan2, { L"x" _ L"y" }) - - CLASS_MEMBER_STATIC_METHOD(Exp, { L"value" }) - CLASS_MEMBER_STATIC_METHOD(LogN, { L"value" }) - CLASS_MEMBER_STATIC_METHOD(Log10, { L"value" }) - CLASS_MEMBER_STATIC_METHOD(Log, { L"value" _ L"base" }) - CLASS_MEMBER_STATIC_METHOD(Pow, { L"value" _ L"power" }) - CLASS_MEMBER_STATIC_METHOD(Ceil, { L"value" }) - CLASS_MEMBER_STATIC_METHOD(Floor, { L"value" }) - CLASS_MEMBER_STATIC_METHOD(Round, { L"value" }) - CLASS_MEMBER_STATIC_METHOD(Trunc, { L"value" }) - - CLASS_MEMBER_STATIC_METHOD(CeilI, { L"value" }) - CLASS_MEMBER_STATIC_METHOD(FloorI, { L"value" }) - CLASS_MEMBER_STATIC_METHOD(RoundI, { L"value" }) - CLASS_MEMBER_STATIC_METHOD(TruncI, { L"value" }) - END_CLASS_MEMBER(Math) - -#undef PT -#undef PT_vint8_t -#undef PT_vint16_t -#undef PT_vint32_t -#undef PT_vint64_t -#undef PT_vuint8_t -#undef PT_vuint16_t -#undef PT_vuint32_t -#undef PT_vuint64_t -#undef PT_float -#undef PT_double -#undef PT_bool -#undef PT_wchar_t -#undef PT_WString -#undef PT_DateTime -#undef PT_CONCAT_ -#undef PT_CONCAT - - BEGIN_STRUCT_MEMBER_FLAG(VoidValue, TypeDescriptorFlags::Primitive) - END_STRUCT_MEMBER(VoidValue) - - BEGIN_INTERFACE_MEMBER_NOPROXY_FLAG(IDescriptable, TypeDescriptorFlags::IDescriptable) - END_INTERFACE_MEMBER(IDescriptable) - - BEGIN_STRUCT_MEMBER(DateTime) - valueType = new SerializableValueType(); - serializableType = new SerializableType(); - STRUCT_MEMBER(year) - STRUCT_MEMBER(month) - STRUCT_MEMBER(dayOfWeek) - STRUCT_MEMBER(day) - STRUCT_MEMBER(hour) - STRUCT_MEMBER(minute) - STRUCT_MEMBER(second) - STRUCT_MEMBER(milliseconds) - END_STRUCT_MEMBER(DateTime) - - BEGIN_INTERFACE_MEMBER(IValueEnumerator) - CLASS_MEMBER_PROPERTY_READONLY_FAST(Current) - CLASS_MEMBER_PROPERTY_READONLY_FAST(Index) - CLASS_MEMBER_METHOD(Next, NO_PARAMETER) - END_INTERFACE_MEMBER(IValueEnumerator) - - BEGIN_INTERFACE_MEMBER(IValueEnumerable) - CLASS_MEMBER_METHOD(CreateEnumerator, NO_PARAMETER) - END_INTERFACE_MEMBER(IValueEnumerable) - - BEGIN_INTERFACE_MEMBER(IValueReadonlyList) - CLASS_MEMBER_BASE(IValueEnumerable) - CLASS_MEMBER_PROPERTY_READONLY_FAST(Count) - CLASS_MEMBER_METHOD(Get, { L"index" }) - CLASS_MEMBER_METHOD(Contains, { L"value" }) - CLASS_MEMBER_METHOD(IndexOf, { L"value" }) - END_INTERFACE_MEMBER(IValueReadonlyList) - - BEGIN_INTERFACE_MEMBER(IValueList) - CLASS_MEMBER_BASE(IValueReadonlyList) - CLASS_MEMBER_EXTERNALCTOR(Ptr(), NO_PARAMETER, vl::reflection::description::IValueList::Create) - CLASS_MEMBER_EXTERNALCTOR(Ptr(Ptr), { L"values" }, vl::reflection::description::IValueList::Create) - - CLASS_MEMBER_METHOD(Set, { L"index" _ L"value" }) - CLASS_MEMBER_METHOD(Add, { L"value" }) - CLASS_MEMBER_METHOD(Insert, { L"index" _ L"value" }) - CLASS_MEMBER_METHOD(Remove, { L"value" }) - CLASS_MEMBER_METHOD(RemoveAt, { L"index" }) - CLASS_MEMBER_METHOD(Clear, NO_PARAMETER) - END_INTERFACE_MEMBER(IValueList) - - BEGIN_INTERFACE_MEMBER(IValueObservableList) - CLASS_MEMBER_BASE(IValueList) - CLASS_MEMBER_EXTERNALCTOR(Ptr(), NO_PARAMETER, vl::reflection::description::IValueObservableList::Create) - CLASS_MEMBER_EXTERNALCTOR(Ptr(Ptr), { L"values" }, vl::reflection::description::IValueObservableList::Create) - - CLASS_MEMBER_EVENT(ItemChanged) - END_INTERFACE_MEMBER(IValueObservableList) - - BEGIN_INTERFACE_MEMBER(IValueReadonlyDictionary) - CLASS_MEMBER_PROPERTY_READONLY_FAST(Keys) - CLASS_MEMBER_PROPERTY_READONLY_FAST(Values) - CLASS_MEMBER_PROPERTY_READONLY_FAST(Count) - CLASS_MEMBER_METHOD(Get, { L"key" }) - END_INTERFACE_MEMBER(IValueReadonlyDictionary) - - BEGIN_INTERFACE_MEMBER(IValueDictionary) - CLASS_MEMBER_BASE(IValueReadonlyDictionary) - CLASS_MEMBER_EXTERNALCTOR(Ptr(), NO_PARAMETER, vl::reflection::description::IValueDictionary::Create) - CLASS_MEMBER_EXTERNALCTOR(Ptr(Ptr), { L"values" }, vl::reflection::description::IValueDictionary::Create) - CLASS_MEMBER_METHOD(Set, { L"key" _ L"value" }) - CLASS_MEMBER_METHOD(Remove, { L"key" }) - CLASS_MEMBER_METHOD(Clear, NO_PARAMETER) - END_INTERFACE_MEMBER(IValueDictionary) - - BEGIN_INTERFACE_MEMBER_NOPROXY(IValueInterfaceProxy) - CLASS_MEMBER_METHOD(Invoke, { L"methodInfo" _ L"arguments" }) - END_INTERFACE_MEMBER(IValueInterfaceProxy) - - BEGIN_INTERFACE_MEMBER_NOPROXY(IValueFunctionProxy) - CLASS_MEMBER_METHOD(Invoke, { L"arguments" }) - END_INTERFACE_MEMBER(IValueFunctionProxy) - - BEGIN_INTERFACE_MEMBER(IValueSubscription) - CLASS_MEMBER_EVENT(ValueChanged) - CLASS_MEMBER_METHOD(Open, NO_PARAMETER) - CLASS_MEMBER_METHOD(Update, NO_PARAMETER) - CLASS_MEMBER_METHOD(Close, NO_PARAMETER) - END_CLASS_MEMBER(IValueSubscription) - - BEGIN_INTERFACE_MEMBER_NOPROXY(IValueCallStack) - CLASS_MEMBER_PROPERTY_READONLY_FAST(LocalVariables) - CLASS_MEMBER_PROPERTY_READONLY_FAST(LocalArguments) - CLASS_MEMBER_PROPERTY_READONLY_FAST(CapturedVariables) - CLASS_MEMBER_PROPERTY_READONLY_FAST(GlobalVariables) - CLASS_MEMBER_PROPERTY_READONLY_FAST(FunctionName) - CLASS_MEMBER_PROPERTY_READONLY_FAST(SourceCodeBeforeCodegen) - CLASS_MEMBER_PROPERTY_READONLY_FAST(SourceCodeAfterCodegen) - CLASS_MEMBER_PROPERTY_READONLY_FAST(RowBeforeCodegen) - CLASS_MEMBER_PROPERTY_READONLY_FAST(RowAfterCodegen) - END_INTERFACE_MEMBER(IValueCallStack) - - BEGIN_INTERFACE_MEMBER_NOPROXY(IValueException) -#pragma push_macro("GetMessage") -#if defined GetMessage -#undef GetMessage -#endif - CLASS_MEMBER_PROPERTY_READONLY_FAST(Message) -#pragma pop_macro("GetMessage") - CLASS_MEMBER_PROPERTY_READONLY_FAST(Fatal) - CLASS_MEMBER_PROPERTY_READONLY_FAST(CallStack) - END_INTERFACE_MEMBER(IValueException) - - BEGIN_ENUM_ITEM(CoroutineStatus) - ENUM_CLASS_ITEM(Waiting) - ENUM_CLASS_ITEM(Executing) - ENUM_CLASS_ITEM(Stopped) - END_ENUM_ITEM(CoroutineStatus) - - BEGIN_INTERFACE_MEMBER(ICoroutine) - CLASS_MEMBER_METHOD(Resume, { L"raiseException" _ L"output" }) - CLASS_MEMBER_PROPERTY_READONLY_FAST(Failure) - CLASS_MEMBER_PROPERTY_READONLY_FAST(Status) - END_INTERFACE_MEMBER(ICoroutine) - - BEGIN_CLASS_MEMBER(CoroutineResult) - CLASS_MEMBER_CONSTRUCTOR(Ptr(), NO_PARAMETER) - CLASS_MEMBER_PROPERTY_FAST(Result) - CLASS_MEMBER_PROPERTY_FAST(Failure) - END_CLASS_MEMBER(CoroutineResult) - - BEGIN_INTERFACE_MEMBER_NOPROXY(EnumerableCoroutine::IImpl) - CLASS_MEMBER_BASE(IValueEnumerator) - END_INTERFACE_MEMBER(EnumerableCoroutine::IImpl) - - BEGIN_CLASS_MEMBER(EnumerableCoroutine) - CLASS_MEMBER_STATIC_METHOD(YieldAndPause, { L"impl" _ L"value" }) - CLASS_MEMBER_STATIC_METHOD(JoinAndPause, { L"impl" _ L"value" }) - CLASS_MEMBER_STATIC_METHOD(ReturnAndExit, { L"impl" }) - CLASS_MEMBER_STATIC_METHOD(Create, { L"creator" }) - END_CLASS_MEMBER(EnumerableCoroutine) - - BEGIN_ENUM_ITEM(AsyncStatus) - ENUM_CLASS_ITEM(Ready) - ENUM_CLASS_ITEM(Executing) - ENUM_CLASS_ITEM(Stopped) - END_ENUM_ITEM(AsyncStatus) - - BEGIN_INTERFACE_MEMBER(IAsync) - CLASS_MEMBER_PROPERTY_READONLY_FAST(Status) - CLASS_MEMBER_METHOD(Execute, { L"callback" }) - CLASS_MEMBER_STATIC_METHOD(Delay, { L"milliseconds" }) - END_INTERFACE_MEMBER(IAsync) - - BEGIN_INTERFACE_MEMBER_NOPROXY(IPromise) - CLASS_MEMBER_METHOD(SendResult, { L"result" }) - CLASS_MEMBER_METHOD(SendFailure, { L"failure" }) - END_INTERFACE_MEMBER(IPromise) - - BEGIN_INTERFACE_MEMBER_NOPROXY(IFuture) - CLASS_MEMBER_BASE(IAsync) - CLASS_MEMBER_BASE(IPromise) - CLASS_MEMBER_PROPERTY_READONLY_FAST(Promise) - CLASS_MEMBER_STATIC_METHOD(Create, NO_PARAMETER) - END_INTERFACE_MEMBER(IFuture) - - BEGIN_INTERFACE_MEMBER_NOPROXY(IAsyncScheduler) - CLASS_MEMBER_METHOD(Execute, { L"callback" }) - CLASS_MEMBER_METHOD(ExecuteInBackground, { L"callback" }) - CLASS_MEMBER_METHOD(DelayExecute, { L"callback" _ L"milliseconds" }) - CLASS_MEMBER_STATIC_METHOD(GetSchedulerForCurrentThread, NO_PARAMETER) - END_INTERFACE_MEMBER(IAsyncScheduler) - - BEGIN_INTERFACE_MEMBER_NOPROXY(AsyncCoroutine::IImpl) - CLASS_MEMBER_BASE(IAsync) - END_INTERFACE_MEMBER(AsyncCoroutine::IImpl) - - BEGIN_CLASS_MEMBER(AsyncCoroutine) - CLASS_MEMBER_STATIC_METHOD(AwaitAndRead, { L"impl" _ L"value" }) - CLASS_MEMBER_STATIC_METHOD(ReturnAndExit, { L"impl" _ L"value"}) - CLASS_MEMBER_STATIC_METHOD(Create, { L"creator" }) - CLASS_MEMBER_STATIC_METHOD(CreateAndRun, { L"creator" }) - END_CLASS_MEMBER(AsyncCoroutine) - - BEGIN_INTERFACE_MEMBER_NOPROXY(IBoxedValue) - CLASS_MEMBER_METHOD(Copy, NO_PARAMETER) - END_INTERFACE_MEMBER(IBoxedValue) - - BEGIN_ENUM_ITEM(IBoxedValue::CompareResult) - ENUM_ITEM_NAMESPACE(IBoxedValue) - - ENUM_NAMESPACE_ITEM(Smaller) - ENUM_NAMESPACE_ITEM(Greater) - ENUM_NAMESPACE_ITEM(Equal) - ENUM_NAMESPACE_ITEM(NotComparable) - END_ENUM_ITEM(ITypeInfo::Decorator) - - BEGIN_INTERFACE_MEMBER_NOPROXY(IValueType) - CLASS_MEMBER_METHOD(CreateDefault, NO_PARAMETER) - CLASS_MEMBER_METHOD(Compare, { L"a" _ L"b" }) - END_INTERFACE_MEMBER(IValueType) - - BEGIN_INTERFACE_MEMBER_NOPROXY(IEnumType) - CLASS_MEMBER_METHOD(IsFlagEnum, NO_PARAMETER) - CLASS_MEMBER_METHOD(GetItemCount, NO_PARAMETER) - CLASS_MEMBER_METHOD(GetItemName, { L"index" }) - CLASS_MEMBER_METHOD(GetItemValue, { L"index" }) - CLASS_MEMBER_METHOD(IndexOfItem, { L"name" }) - CLASS_MEMBER_METHOD(ToEnum, { L"value" }) - CLASS_MEMBER_METHOD(FromEnum, { L"value" }) - END_INTERFACE_MEMBER(IEnumType) - - BEGIN_INTERFACE_MEMBER_NOPROXY(ISerializableType) - CLASS_MEMBER_METHOD(Serialize, { L"input" _ L"output" }) - CLASS_MEMBER_METHOD(Deserialize, { L"input" _ L"output" }) - END_INTERFACE_MEMBER(ISerializableType) - - BEGIN_INTERFACE_MEMBER_NOPROXY(ITypeInfo) - CLASS_MEMBER_PROPERTY_READONLY_FAST(Decorator) - CLASS_MEMBER_PROPERTY_READONLY_FAST(ElementType) - CLASS_MEMBER_PROPERTY_READONLY_FAST(TypeDescriptor) - CLASS_MEMBER_PROPERTY_READONLY_FAST(GenericArgumentCount) - CLASS_MEMBER_PROPERTY_READONLY_FAST(TypeFriendlyName) - - CLASS_MEMBER_METHOD(GetGenericArgument, { L"index" }) - END_INTERFACE_MEMBER(ITypeInfo) - - BEGIN_ENUM_ITEM(ITypeInfo::Decorator) - ENUM_ITEM_NAMESPACE(ITypeInfo) - - ENUM_NAMESPACE_ITEM(RawPtr) - ENUM_NAMESPACE_ITEM(SharedPtr) - ENUM_NAMESPACE_ITEM(Nullable) - ENUM_NAMESPACE_ITEM(TypeDescriptor) - ENUM_NAMESPACE_ITEM(Generic) - END_ENUM_ITEM(ITypeInfo::Decorator) - - BEGIN_INTERFACE_MEMBER_NOPROXY(IMemberInfo) - CLASS_MEMBER_PROPERTY_READONLY_FAST(OwnerTypeDescriptor) - CLASS_MEMBER_PROPERTY_READONLY_FAST(Name) - END_INTERFACE_MEMBER(IMemberInfo) - - BEGIN_INTERFACE_MEMBER_NOPROXY(IEventHandler) - CLASS_MEMBER_METHOD(IsAttached, NO_PARAMETER) - END_INTERFACE_MEMBER(IEventHandler) - - BEGIN_INTERFACE_MEMBER_NOPROXY(IEventInfo) - CLASS_MEMBER_BASE(IMemberInfo) - - CLASS_MEMBER_PROPERTY_READONLY_FAST(HandlerType) - CLASS_MEMBER_PROPERTY_READONLY_FAST(ObservingPropertyCount) - - CLASS_MEMBER_METHOD(GetObservingProperty, { L"index" }) - CLASS_MEMBER_METHOD(Attach, { L"thisObject" _ L"handler" }) - CLASS_MEMBER_METHOD(Invoke, { L"thisObject" _ L"arguments" }) - END_INTERFACE_MEMBER(IEventInfo) - - BEGIN_INTERFACE_MEMBER_NOPROXY(IPropertyInfo) - CLASS_MEMBER_BASE(IMemberInfo) - - CLASS_MEMBER_PROPERTY_READONLY_FAST(Return) - CLASS_MEMBER_PROPERTY_READONLY_FAST(Getter) - CLASS_MEMBER_PROPERTY_READONLY_FAST(Setter) - CLASS_MEMBER_PROPERTY_READONLY_FAST(ValueChangedEvent) - - CLASS_MEMBER_METHOD(IsReadable, NO_PARAMETER) - CLASS_MEMBER_METHOD(IsWritable, NO_PARAMETER) - CLASS_MEMBER_METHOD(GetValue, { L"thisObject" }) - CLASS_MEMBER_METHOD(SetValue, { L"thisObject" _ L"newValue" }) - END_INTERFACE_MEMBER(IPropertyInfo) - - BEGIN_INTERFACE_MEMBER_NOPROXY(IParameterInfo) - CLASS_MEMBER_BASE(IMemberInfo) - - CLASS_MEMBER_PROPERTY_READONLY_FAST(Type) - CLASS_MEMBER_PROPERTY_READONLY_FAST(OwnerMethod) - END_CLASS_MEMBER(IParameterInfo) - - BEGIN_INTERFACE_MEMBER_NOPROXY(IMethodInfo) - CLASS_MEMBER_BASE(IMemberInfo) - - CLASS_MEMBER_PROPERTY_READONLY_FAST(OwnerMethodGroup) - CLASS_MEMBER_PROPERTY_READONLY_FAST(OwnerProperty) - CLASS_MEMBER_PROPERTY_READONLY_FAST(ParameterCount) - CLASS_MEMBER_PROPERTY_READONLY_FAST(Return) - - CLASS_MEMBER_METHOD(GetParameter, { L"index" }) - CLASS_MEMBER_METHOD(IsStatic, NO_PARAMETER) - CLASS_MEMBER_METHOD(CheckArguments, { L"arguments" }) - CLASS_MEMBER_METHOD(Invoke, { L"thisObject" _ L"arguments" }) - CLASS_MEMBER_BASE(IMemberInfo) - END_INTERFACE_MEMBER(IMethodInfo) - - BEGIN_INTERFACE_MEMBER_NOPROXY(IMethodGroupInfo) - CLASS_MEMBER_BASE(IMemberInfo) - - CLASS_MEMBER_PROPERTY_READONLY_FAST(MethodCount) - - CLASS_MEMBER_METHOD(GetMethod, { L"index" }) - END_INTERFACE_MEMBER(IMethodGroupInfo) - - BEGIN_ENUM_ITEM_MERGABLE(TypeDescriptorFlags) - ENUM_CLASS_ITEM(Object) - ENUM_CLASS_ITEM(IDescriptable) - ENUM_CLASS_ITEM(Class) - ENUM_CLASS_ITEM(Interface) - ENUM_CLASS_ITEM(Primitive) - ENUM_CLASS_ITEM(Struct) - ENUM_CLASS_ITEM(FlagEnum) - ENUM_CLASS_ITEM(NormalEnum) - END_ENUM_ITEM(TypeDescriptorFlags) - - BEGIN_INTERFACE_MEMBER_NOPROXY(ITypeDescriptor) - CLASS_MEMBER_PROPERTY_READONLY_FAST(TypeDescriptorFlags) - CLASS_MEMBER_PROPERTY_READONLY_FAST(TypeName) - CLASS_MEMBER_PROPERTY_READONLY_FAST(ValueType) - CLASS_MEMBER_PROPERTY_READONLY_FAST(EnumType) - CLASS_MEMBER_PROPERTY_READONLY_FAST(SerializableType) - CLASS_MEMBER_PROPERTY_READONLY_FAST(BaseTypeDescriptorCount) - CLASS_MEMBER_PROPERTY_READONLY_FAST(PropertyCount) - CLASS_MEMBER_PROPERTY_READONLY_FAST(EventCount) - CLASS_MEMBER_PROPERTY_READONLY_FAST(MethodGroupCount) - CLASS_MEMBER_PROPERTY_READONLY_FAST(ConstructorGroup) - - CLASS_MEMBER_METHOD(GetBaseTypeDescriptor, { L"index" }) - CLASS_MEMBER_METHOD(CanConvertTo, { L"targetType" }) - CLASS_MEMBER_METHOD(GetProperty, { L"index" }) - CLASS_MEMBER_METHOD(IsPropertyExists, { L"name" _ L"inheritable" }) - CLASS_MEMBER_METHOD(GetPropertyByName, { L"name" _ L"inheritable" }) - CLASS_MEMBER_METHOD(GetEvent, { L"index" }) - CLASS_MEMBER_METHOD(IsEventExists, { L"name" _ L"inheritable" }) - CLASS_MEMBER_METHOD(GetEventByName, { L"name" _ L"inheritable" }) - CLASS_MEMBER_METHOD(GetMethodGroup, { L"index" }) - CLASS_MEMBER_METHOD(IsMethodGroupExists, { L"name" _ L"inheritable" }) - CLASS_MEMBER_METHOD(GetMethodGroupByName, { L"name" _ L"inheritable" }) - - CLASS_MEMBER_STATIC_EXTERNALMETHOD(GetTypeDescriptorCount, NO_PARAMETER, vint(*)(), vl::reflection::description::ITypeDescriptor_GetTypeDescriptorCount) - CLASS_MEMBER_STATIC_EXTERNALMETHOD(GetTypeDescriptor, { L"index" }, ITypeDescriptor*(*)(vint), vl::reflection::description::ITypeDescriptor_GetTypeDescriptor) - CLASS_MEMBER_STATIC_EXTERNALMETHOD(GetTypeDescriptor, { L"name" }, ITypeDescriptor*(*)(const WString&), vl::reflection::description::ITypeDescriptor_GetTypeDescriptor) - CLASS_MEMBER_STATIC_EXTERNALMETHOD(GetTypeDescriptor, { L"value" }, ITypeDescriptor*(*)(const Value&), vl::reflection::description::ITypeDescriptor_GetTypeDescriptor) - END_INTERFACE_MEMBER(ITypeDescriptor) -#undef _ - - class PredefinedTypeLoader : public Object, public ITypeLoader - { - public: - void Load(ITypeManager* manager)override - { - manager->SetTypeDescriptor(TypeInfo::content.typeName, new TypedValueTypeDescriptorBase); -#define ADD_PRIMITIVE_TYPE(TYPE) manager->SetTypeDescriptor(TypeInfo::content.typeName, new PrimitiveTypeDescriptor()); - REFLECTION_PREDEFINED_PRIMITIVE_TYPES(ADD_PRIMITIVE_TYPE) -#undef ADD_PRIMITIVE_TYPE - REFLECTION_PREDEFINED_COMPLEX_TYPES(ADD_TYPE_INFO, VoidValue) - } - - void Unload(ITypeManager* manager)override - { - } - }; - -#endif - - bool LoadPredefinedTypes() - { -#ifndef VCZH_DEBUG_NO_REFLECTION - ITypeManager* manager = GetGlobalTypeManager(); - if (manager) - { - Ptr loader = new PredefinedTypeLoader; - return manager->AddTypeLoader(loader); - } -#endif - return false; - } - } - } -} - -/*********************************************************************** -REFLECTION\GUITYPEDESCRIPTOR_LOG.CPP -***********************************************************************/ - -namespace vl -{ - namespace reflection - { - namespace description - { - using namespace collections; - -#ifndef VCZH_DEBUG_NO_REFLECTION - -/*********************************************************************** -LogTypeManager (enum) -***********************************************************************/ - - void LogTypeManager_Enum(stream::TextWriter& writer, ITypeDescriptor* type) - { - writer.WriteLine((type->GetTypeDescriptorFlags() == TypeDescriptorFlags::FlagEnum ? L"flags " : L"enum ") + type->GetTypeName()); - writer.WriteLine(L"{"); - - auto enumType = type->GetEnumType(); - for (vint j = 0; j < enumType->GetItemCount(); j++) - { - writer.WriteLine(L" " + enumType->GetItemName(j) + L" = " + u64tow(enumType->GetItemValue(j)) + L","); - } - - writer.WriteLine(L"}"); - } - -/*********************************************************************** -LogTypeManager (struct) -***********************************************************************/ - - void LogTypeManager_Struct(stream::TextWriter& writer, ITypeDescriptor* type) - { - writer.WriteLine(L"struct " + type->GetTypeName()); - writer.WriteLine(L"{"); - for (vint j = 0; jGetPropertyCount(); j++) - { - IPropertyInfo* info = type->GetProperty(j); - writer.WriteLine(L" " + info->GetReturn()->GetTypeFriendlyName() + L" " + info->GetName() + L";"); - } - writer.WriteLine(L"}"); - } - -/*********************************************************************** -LogTypeManager (data) -***********************************************************************/ - - void LogTypeManager_Data(stream::TextWriter& writer, ITypeDescriptor* type) - { - writer.WriteLine(L"primitive " + type->GetTypeName() + L";"); - } - -/*********************************************************************** -LogTypeManager (class) -***********************************************************************/ - - void LogTypeManager_PrintEvents(stream::TextWriter& writer, ITypeDescriptor* type) - { - bool printed = false; - for (vint j = 0; jGetEventCount(); j++) - { - printed = true; - IEventInfo* info = type->GetEvent(j); - writer.WriteString(L" event " + info->GetHandlerType()->GetTypeFriendlyName() + L" " + info->GetName() + L"{"); - if (info->GetObservingPropertyCount()>0) - { - writer.WriteString(L" observing "); - vint count = +info->GetObservingPropertyCount(); - for (vint i = 0; i0) writer.WriteString(L", "); - writer.WriteString(info->GetObservingProperty(i)->GetName()); - } - writer.WriteString(L";"); - } - writer.WriteLine(L"};"); - } - if (printed) - { - writer.WriteLine(L""); - } - } - - void LogTypeManager_PrintProperties(stream::TextWriter& writer, ITypeDescriptor* type, List& propertyAccessors) - { - bool printed = false; - for (vint j = 0; jGetPropertyCount(); j++) - { - printed = true; - IPropertyInfo* info = type->GetProperty(j); - writer.WriteString(L" property " + info->GetReturn()->GetTypeFriendlyName() + L" " + info->GetName() + L"{"); - if (info->GetGetter()) - { - propertyAccessors.Add(info->GetGetter()); - writer.WriteString(L" getter " + info->GetGetter()->GetName() + L";"); - } - if (info->GetSetter()) - { - propertyAccessors.Add(info->GetSetter()); - writer.WriteString(L" setter " + info->GetSetter()->GetName() + L";"); - } - if (info->GetValueChangedEvent()) - { - writer.WriteString(L" raising " + info->GetValueChangedEvent()->GetName() + L";"); - } - writer.WriteLine(L"}"); - } - if (printed) - { - writer.WriteLine(L""); - } - } - - void LogTypeManager_PrintMethods(stream::TextWriter& writer, ITypeDescriptor* type, const List& propertyAccessors, bool isPropertyAccessor) - { - bool printed = false; - for (vint j = 0; jGetMethodGroupCount(); j++) - { - IMethodGroupInfo* group = type->GetMethodGroup(j); - for (vint k = 0; kGetMethodCount(); k++) - { - IMethodInfo* info = group->GetMethod(k); - if (propertyAccessors.Contains(info) == isPropertyAccessor) - { - printed = true; - writer.WriteString(WString(L" ") + (info->IsStatic() ? L"static " : L"") + (isPropertyAccessor ? L"accessor " : L"function ") + info->GetReturn()->GetTypeFriendlyName()); - writer.WriteString(L" " + info->GetName() + L"("); - for (vint l = 0; lGetParameterCount(); l++) - { - if (l>0) writer.WriteString(L", "); - IParameterInfo* parameter = info->GetParameter(l); - writer.WriteString(parameter->GetType()->GetTypeFriendlyName() + L" " + parameter->GetName()); - } - writer.WriteLine(L");"); - } - } - } - if (printed) - { - writer.WriteLine(L""); - } - } - - void LogTypeManager_PrintConstructors(stream::TextWriter& writer, ITypeDescriptor* type) - { - if (IMethodGroupInfo* group = type->GetConstructorGroup()) - { - for (vint k = 0; kGetMethodCount(); k++) - { - IMethodInfo* info = group->GetMethod(k); - writer.WriteString(L" constructor " + info->GetReturn()->GetTypeFriendlyName()); - writer.WriteString(L" " + info->GetName() + L"("); - for (vint l = 0; lGetParameterCount(); l++) - { - if (l>0) writer.WriteString(L", "); - IParameterInfo* parameter = info->GetParameter(l); - writer.WriteString(parameter->GetType()->GetTypeFriendlyName() + L" " + parameter->GetName()); - } - writer.WriteLine(L");"); - } - } - } - - void LogTypeManager_Class(stream::TextWriter& writer, ITypeDescriptor* type) - { - bool acceptProxy = false; - bool isInterface = (type->GetTypeDescriptorFlags() & TypeDescriptorFlags::InterfaceType) != TypeDescriptorFlags::Undefined; - writer.WriteString((isInterface ? L"interface " : L"class ") + type->GetTypeName()); - for (vint j = 0; jGetBaseTypeDescriptorCount(); j++) - { - writer.WriteString(j == 0 ? L" : " : L", "); - writer.WriteString(type->GetBaseTypeDescriptor(j)->GetTypeName()); - } - writer.WriteLine(L""); - writer.WriteLine(L"{"); - - List propertyAccessors; - LogTypeManager_PrintEvents(writer, type); - LogTypeManager_PrintProperties(writer, type, propertyAccessors); - LogTypeManager_PrintMethods(writer, type, propertyAccessors, false); - LogTypeManager_PrintMethods(writer, type, propertyAccessors, true); - LogTypeManager_PrintConstructors(writer, type); - - writer.WriteLine(L"}"); - } - -/*********************************************************************** -LogTypeManager -***********************************************************************/ - - bool IsInterfaceType(ITypeDescriptor* typeDescriptor, bool& acceptProxy) - { - bool containsConstructor = false; - if (IMethodGroupInfo* group = typeDescriptor->GetConstructorGroup()) - { - containsConstructor = group->GetMethodCount() > 0; - if (group->GetMethodCount() == 1) - { - if (IMethodInfo* info = group->GetMethod(0)) - { - if (info->GetParameterCount() == 1 && info->GetParameter(0)->GetType()->GetTypeDescriptor()->GetTypeName() == TypeInfo::content.typeName) - { - acceptProxy = true; - return true; - } - } - } - } - - if (!containsConstructor) - { - if (typeDescriptor->GetTypeName() == TypeInfo::content.typeName) - { - return true; - } - else - { - for (vint i = 0; i < typeDescriptor->GetBaseTypeDescriptorCount(); i++) - { - bool _acceptProxy = false; - if (!IsInterfaceType(typeDescriptor->GetBaseTypeDescriptor(i), _acceptProxy)) - { - return false; - } - } - const wchar_t* name = typeDescriptor->GetTypeName().Buffer(); - while (const wchar_t* next = ::wcschr(name, L':')) - { - name = next + 1; - } - return name[0] == L'I' && (L'A' <= name[1] && name[1] <= L'Z'); - } - } - return false; - } - - void LogTypeManager(stream::TextWriter& writer) - { - for (vint i = 0; i < GetGlobalTypeManager()->GetTypeDescriptorCount(); i++) - { - ITypeDescriptor* type = GetGlobalTypeManager()->GetTypeDescriptor(i); - - switch (type->GetTypeDescriptorFlags()) - { - case TypeDescriptorFlags::Object: - case TypeDescriptorFlags::IDescriptable: - case TypeDescriptorFlags::Class: - case TypeDescriptorFlags::Interface: - LogTypeManager_Class(writer, type); - break; - case TypeDescriptorFlags::FlagEnum: - case TypeDescriptorFlags::NormalEnum: - LogTypeManager_Enum(writer, type); - break; - case TypeDescriptorFlags::Primitive: - LogTypeManager_Data(writer, type); - break; - case TypeDescriptorFlags::Struct: - LogTypeManager_Struct(writer, type); - break; - default:; - } - writer.WriteLine(L""); - } - } - -#endif - } - } -} - -/*********************************************************************** -REGEX\REGEX.CPP -***********************************************************************/ - -namespace vl -{ - namespace regex - { - using namespace collections; - using namespace regex_internal; - -/*********************************************************************** -RegexString -***********************************************************************/ - - RegexString::RegexString(vint _start) - :start(_start) - ,length(0) - { - } - - RegexString::RegexString(const WString& _string, vint _start, vint _length) - :value(_length==0?L"":_string.Sub(_start, _length)) - ,start(_start) - ,length(_length) - { - } - - vint RegexString::Start()const - { - return start; - } - - vint RegexString::Length()const - { - return length; - } - - const WString& RegexString::Value()const - { - return value; - } - - bool RegexString::operator==(const RegexString& string)const - { - return start==string.start && length==string.length && value==string.value; - } - -/*********************************************************************** -RegexMatch -***********************************************************************/ - - RegexMatch::RegexMatch(const WString& _string, PureResult* _result) - :success(true) - ,result(_string, _result->start, _result->length) - { - } - - RegexMatch::RegexMatch(const WString& _string, RichResult* _result, RichInterpretor* _rich) - :success(true) - ,result(_string, _result->start, _result->length) - { - for(vint i=0;i<_result->captures.Count();i++) - { - CaptureRecord& capture=_result->captures[i]; - if(capture.capture==-1) - { - captures.Add(RegexString(_string, capture.start, capture.length)); - } - else - { - groups.Add(_rich->CaptureNames().Get(capture.capture), RegexString(_string, capture.start, capture.length)); - } - } - } - - RegexMatch::RegexMatch(const RegexString& _result) - :success(false) - ,result(_result) - { - } - - bool RegexMatch::Success()const - { - return success; - } - - const RegexString& RegexMatch::Result()const - { - return result; - } - - const RegexMatch::CaptureList& RegexMatch::Captures()const - { - return captures; - } - - const RegexMatch::CaptureGroup& RegexMatch::Groups()const - { - return groups; - } - -/*********************************************************************** -Regex -***********************************************************************/ - - void Regex::Process(const WString& text, bool keepEmpty, bool keepSuccess, bool keepFail, RegexMatch::List& matches)const - { - if(rich) - { - const wchar_t* start=text.Buffer(); - const wchar_t* input=start; - RichResult result; - while(rich->Match(input, start, result)) - { - vint offset=input-start; - if(keepFail) - { - if(result.start>offset || keepEmpty) - { - matches.Add(new RegexMatch(RegexString(text, offset, result.start-offset))); - } - } - if(keepSuccess) - { - matches.Add(new RegexMatch(text, &result, rich)); - } - input=start+result.start+result.length; - } - if(keepFail) - { - vint remain=input-start; - vint length=text.Length()-remain; - if(length || keepEmpty) - { - matches.Add(new RegexMatch(RegexString(text, remain, length))); - } - } - } - else - { - const wchar_t* start=text.Buffer(); - const wchar_t* input=start; - PureResult result; - while(pure->Match(input, start, result)) - { - vint offset=input-start; - if(keepFail) - { - if(result.start>offset || keepEmpty) - { - matches.Add(new RegexMatch(RegexString(text, offset, result.start-offset))); - } - } - if(keepSuccess) - { - matches.Add(new RegexMatch(text, &result)); - } - input=start+result.start+result.length; - } - if(keepFail) - { - vint remain=input-start; - vint length=text.Length()-remain; - if(length || keepEmpty) - { - matches.Add(new RegexMatch(RegexString(text, remain, length))); - } - } - } - } - - Regex::Regex(const WString& code, bool preferPure) - :pure(0) - ,rich(0) - { - CharRange::List subsets; - RegexExpression::Ref regex=ParseRegexExpression(code); - Expression::Ref expression=regex->Merge(); - expression->NormalizeCharSet(subsets); - - bool pureRequired=false; - bool richRequired=false; - if(preferPure) - { - if(expression->HasNoExtension()) - { - pureRequired=true; - } - else - { - if(expression->CanTreatAsPure()) - { - pureRequired=true; - richRequired=true; - } - else - { - richRequired=true; - } - } - } - else - { - richRequired=true; - } - - try - { - if(pureRequired) - { - Dictionary nfaStateMap; - Group dfaStateMap; - Automaton::Ref eNfa=expression->GenerateEpsilonNfa(); - Automaton::Ref nfa=EpsilonNfaToNfa(eNfa, PureEpsilonChecker, nfaStateMap); - Automaton::Ref dfa=NfaToDfa(nfa, dfaStateMap); - pure=new PureInterpretor(dfa, subsets); - } - if(richRequired) - { - Dictionary nfaStateMap; - Group dfaStateMap; - Automaton::Ref eNfa=expression->GenerateEpsilonNfa(); - Automaton::Ref nfa=EpsilonNfaToNfa(eNfa, RichEpsilonChecker, nfaStateMap); - Automaton::Ref dfa=NfaToDfa(nfa, dfaStateMap); - rich=new RichInterpretor(dfa); - } - } - catch(...) - { - if(pure)delete pure; - if(rich)delete rich; - throw; - } - } - - Regex::~Regex() - { - if(pure)delete pure; - if(rich)delete rich; - } - - bool Regex::IsPureMatch()const - { - return rich?false:true; - } - - bool Regex::IsPureTest()const - { - return pure?true:false; - } - - RegexMatch::Ref Regex::MatchHead(const WString& text)const - { - if(rich) - { - RichResult result; - if(rich->MatchHead(text.Buffer(), text.Buffer(), result)) - { - return new RegexMatch(text, &result, rich); - } - else - { - return 0; - } - } - else - { - PureResult result; - if(pure->MatchHead(text.Buffer(), text.Buffer(), result)) - { - return new RegexMatch(text, &result); - } - else - { - return 0; - } - } - } - - RegexMatch::Ref Regex::Match(const WString& text)const - { - if(rich) - { - RichResult result; - if(rich->Match(text.Buffer(), text.Buffer(), result)) - { - return new RegexMatch(text, &result, rich); - } - else - { - return 0; - } - } - else - { - PureResult result; - if(pure->Match(text.Buffer(), text.Buffer(), result)) - { - return new RegexMatch(text, &result); - } - else - { - return 0; - } - } - } - - bool Regex::TestHead(const WString& text)const - { - if(pure) - { - PureResult result; - return pure->MatchHead(text.Buffer(), text.Buffer(), result); - } - else - { - RichResult result; - return rich->MatchHead(text.Buffer(), text.Buffer(), result); - } - } - - bool Regex::Test(const WString& text)const - { - if(pure) - { - PureResult result; - return pure->Match(text.Buffer(), text.Buffer(), result); - } - else - { - RichResult result; - return rich->Match(text.Buffer(), text.Buffer(), result); - } - } - - void Regex::Search(const WString& text, RegexMatch::List& matches)const - { - Process(text, false, true, false, matches); - } - - void Regex::Split(const WString& text, bool keepEmptyMatch, RegexMatch::List& matches)const - { - Process(text, keepEmptyMatch, false, true, matches); - } - - void Regex::Cut(const WString& text, bool keepEmptyMatch, RegexMatch::List& matches)const - { - Process(text, keepEmptyMatch, true, true, matches); - } - -/*********************************************************************** -RegexTokens -***********************************************************************/ - - bool RegexToken::operator==(const RegexToken& _token)const - { - return length==_token.length && token==_token.token && reading==_token.reading; - } - - bool RegexToken::operator==(const wchar_t* _token)const - { - return wcslen(_token)==length && wcsncmp(reading, _token, length)==0; - } - - class RegexTokenEnumerator : public Object, public IEnumerator - { - protected: - RegexToken token; - vint index; - - PureInterpretor* pure; - const Array& stateTokens; - const wchar_t* start; - vint codeIndex; - - const wchar_t* reading; - vint rowStart; - vint columnStart; - bool cacheAvailable; - RegexToken cacheToken; - - public: - RegexTokenEnumerator(const RegexTokenEnumerator& enumerator) - :token(enumerator.token) - ,index(enumerator.index) - ,pure(enumerator.pure) - ,stateTokens(enumerator.stateTokens) - ,reading(enumerator.reading) - ,start(enumerator.start) - ,rowStart(enumerator.rowStart) - ,columnStart(enumerator.columnStart) - ,codeIndex(enumerator.codeIndex) - ,cacheAvailable(enumerator.cacheAvailable) - ,cacheToken(enumerator.cacheToken) - { - } - - RegexTokenEnumerator(PureInterpretor* _pure, const Array& _stateTokens, const wchar_t* _start, vint _codeIndex) - :index(-1) - ,pure(_pure) - ,stateTokens(_stateTokens) - ,reading(_start) - ,start(_start) - ,rowStart(0) - ,columnStart(0) - ,codeIndex(_codeIndex) - ,cacheAvailable(false) - { - } - - IEnumerator* Clone()const - { - return new RegexTokenEnumerator(*this); - } - - const RegexToken& Current()const - { - return token; - } - - vint Index()const - { - return index; - } - - bool Next() - { - if(!cacheAvailable && !*reading) return false; - if(cacheAvailable) - { - token=cacheToken; - cacheAvailable=false; - } - else - { - token.reading=reading; - token.start=0; - token.length=0; - token.token=-2; - token.completeToken=true; - } - token.rowStart=rowStart; - token.columnStart=columnStart; - token.rowEnd=rowStart; - token.columnEnd=columnStart; - token.codeIndex=codeIndex; - - PureResult result; - while(*reading) - { - vint id=-1; - bool completeToken=true; - if(!pure->MatchHead(reading, start, result)) - { - result.start=reading-start; - - if(id==-1 && result.terminateState!=-1) - { - vint state=pure->GetRelatedFinalState(result.terminateState); - if(state!=-1) - { - id=stateTokens[state]; - } - } - - if(id==-1) - { - result.length=1; - } - else - { - completeToken=false; - } - } - else - { - id=stateTokens.Get(result.finalState); - } - if(token.token==-2) - { - token.start=result.start; - token.length=result.length; - token.token=id; - token.completeToken=completeToken; - } - else if(token.token==id && id==-1) - { - token.length+=result.length; - } - else - { - cacheAvailable=true; - cacheToken.reading=reading; - cacheToken.start=result.start; - cacheToken.length=result.length; - cacheToken.codeIndex=codeIndex; - cacheToken.token=id; - cacheToken.completeToken=completeToken; - } - reading+=result.length; - if(cacheAvailable) - { - break; - } - } - - index++; - - for(vint i=0;i& tokens, bool(*discard)(vint)) - { - while(Next()) - { - if(!discard(token.token)) - { - tokens.Add(token); - } - } - } - }; - - RegexTokens::RegexTokens(PureInterpretor* _pure, const Array& _stateTokens, const WString& _code, vint _codeIndex) - :pure(_pure) - ,stateTokens(_stateTokens) - ,code(_code) - ,codeIndex(_codeIndex) - { - } - - RegexTokens::RegexTokens(const RegexTokens& tokens) - :pure(tokens.pure) - ,stateTokens(tokens.stateTokens) - ,code(tokens.code) - ,codeIndex(tokens.codeIndex) - { - } - - IEnumerator* RegexTokens::CreateEnumerator()const - { - return new RegexTokenEnumerator(pure, stateTokens, code.Buffer(), codeIndex); - } - - bool DefaultDiscard(vint token) - { - return false; - } - - void RegexTokens::ReadToEnd(collections::List& tokens, bool(*discard)(vint))const - { - if(discard==0) - { - discard=&DefaultDiscard; - } - RegexTokenEnumerator(pure, stateTokens, code.Buffer(), codeIndex).ReadToEnd(tokens, discard); - } - -/*********************************************************************** -RegexLexerWalker -***********************************************************************/ - - RegexLexerWalker::RegexLexerWalker(PureInterpretor* _pure, const Array& _stateTokens) - :pure(_pure) - ,stateTokens(_stateTokens) - { - } - - RegexLexerWalker::RegexLexerWalker(const RegexLexerWalker& walker) - :pure(walker.pure) - ,stateTokens(walker.stateTokens) - { - } - - RegexLexerWalker::~RegexLexerWalker() - { - } - - vint RegexLexerWalker::GetStartState()const - { - return pure->GetStartState(); - } - - vint RegexLexerWalker::GetRelatedToken(vint state)const - { - vint finalState=pure->GetRelatedFinalState(state); - return finalState==-1?-1:stateTokens.Get(finalState); - } - - void RegexLexerWalker::Walk(wchar_t input, vint& state, vint& token, bool& finalState, bool& previousTokenStop)const - { - vint previousState=state; - token=-1; - finalState=false; - previousTokenStop=false; - if(state==-1) - { - state=pure->GetStartState(); - previousTokenStop=true; - } - - state=pure->Transit(input, state); - if(state==-1) - { - previousTokenStop=true; - if(previousState==-1) - { - finalState=true; - return; - } - else if(pure->IsFinalState(previousState)) - { - state=pure->Transit(input, pure->GetStartState()); - } - } - if(pure->IsFinalState(state)) - { - token=stateTokens.Get(state); - finalState=true; - return; - } - else - { - finalState=state==-1; - return; - } - } - - vint RegexLexerWalker::Walk(wchar_t input, vint state)const - { - vint token=-1; - bool finalState=false; - bool previousTokenStop=false; - Walk(input, state, token, finalState, previousTokenStop); - return state; - } - - bool RegexLexerWalker::IsClosedToken(const wchar_t* input, vint length)const - { - vint state=pure->GetStartState(); - for(vint i=0;iTransit(input[i], state); - if(state==-1) return true; - if(pure->IsDeadState(state)) return true; - } - return false; - } - - bool RegexLexerWalker::IsClosedToken(const WString& input)const - { - return IsClosedToken(input.Buffer(), input.Length()); - } - -/*********************************************************************** -RegexLexerColorizer -***********************************************************************/ - - RegexLexerColorizer::RegexLexerColorizer(const RegexLexerWalker& _walker) - :walker(_walker) - ,currentState(_walker.GetStartState()) - { - } - - RegexLexerColorizer::RegexLexerColorizer(const RegexLexerColorizer& colorizer) - :walker(colorizer.walker) - ,currentState(colorizer.currentState) - { - } - - RegexLexerColorizer::~RegexLexerColorizer() - { - } - - void RegexLexerColorizer::Reset(vint state) - { - currentState=state; - } - - void RegexLexerColorizer::Pass(wchar_t input) - { - currentState=walker.Walk(input, currentState); - } - - vint RegexLexerColorizer::GetStartState()const - { - return walker.GetStartState(); - } - - vint RegexLexerColorizer::GetCurrentState()const - { - return currentState; - } - - void RegexLexerColorizer::Colorize(const wchar_t* input, vint length, TokenProc tokenProc, void* tokenProcArgument) - { - vint start=0; - vint stop=0; - vint state=-1; - vint token=-1; - - vint index=0; - vint currentToken=-1; - bool finalState=false; - bool previousTokenStop=false; - - while(index0) - { - tokenProc(tokenProcArgument, start, tokenLength, token); - currentState=state; - start=stop; - index=stop-1; - state=-1; - token=-1; - finalState=false; - } - else if(stop& tokens) - :pure(0) - { - //构造所有DFA - List expressions; - List dfas; - CharRange::List subsets; - Ptr> enumerator=tokens.CreateEnumerator(); - while(enumerator->Next()) - { - const WString& code=enumerator->Current(); - - RegexExpression::Ref regex=ParseRegexExpression(code); - Expression::Ref expression=regex->Merge(); - expression->CollectCharSet(subsets); - expressions.Add(expression); - } - for(vint i=0;i nfaStateMap; - Group dfaStateMap; - Expression::Ref expression=expressions[i]; - expression->ApplyCharSet(subsets); - Automaton::Ref eNfa=expression->GenerateEpsilonNfa(); - Automaton::Ref nfa=EpsilonNfaToNfa(eNfa, PureEpsilonChecker, nfaStateMap); - Automaton::Ref dfa=NfaToDfa(nfa, dfaStateMap); - dfas.Add(dfa); - } - - //为每一个DFA设置标记 - for(vint i=0;istates.Count();j++) - { - if(dfa->states[j]->finalState) - { - dfa->states[j]->userData=(void*)i; - } - else - { - dfa->states[j]->userData=(void*)dfas.Count(); - } - } - } - - //将DFA组合成大的e-NFA - Automaton::Ref bigEnfa=new Automaton; - for(vint i=0;istates, dfas[i]->states); - CopyFrom(bigEnfa->transitions, dfas[i]->transitions); - } - bigEnfa->startState=bigEnfa->NewState(); - for(vint i=0;iNewEpsilon(bigEnfa->startState, dfas[i]->startState); - } - - //转换成DFA - Dictionary nfaStateMap; - Group dfaStateMap; - Automaton::Ref bigNfa=EpsilonNfaToNfa(bigEnfa, PureEpsilonChecker, nfaStateMap); - for(vint i=0;iuserData; - nfaStateMap.Keys()[i]->userData=userData; - } - Automaton::Ref bigDfa=NfaToDfa(bigNfa, dfaStateMap); - for(vint i=0;iuserData; - for(vint j=1;juserData; - if(userData>newData) - { - userData=newData; - } - } - dfaStateMap.Keys()[i]->userData=userData; - } - - //构造状态机 - pure=new PureInterpretor(bigDfa, subsets); - stateTokens.Resize(bigDfa->states.Count()); - for(vint i=0;istates[i]->userData; - stateTokens[i]=(vint)userData; - } - } - - RegexLexer::~RegexLexer() - { - if(pure)delete pure; - } - - RegexTokens RegexLexer::Parse(const WString& code, vint codeIndex)const - { - pure->PrepareForRelatedFinalStateTable(); - return RegexTokens(pure, stateTokens, code, codeIndex); - } - - RegexLexerWalker RegexLexer::Walk()const - { - pure->PrepareForRelatedFinalStateTable(); - return RegexLexerWalker(pure, stateTokens); - } - - RegexLexerColorizer RegexLexer::Colorize()const - { - return RegexLexerColorizer(Walk()); - } - } -} - -/*********************************************************************** -REGEX\REGEXAUTOMATON.CPP +.\REGEX\REGEXAUTOMATON.CPP ***********************************************************************/ namespace vl @@ -21406,95 +19482,7 @@ Automaton } /*********************************************************************** -REGEX\REGEXDATA.CPP -***********************************************************************/ - -namespace vl -{ - namespace regex_internal - { - -/*********************************************************************** -CharRange -***********************************************************************/ - - CharRange::CharRange() - :begin(L'\0') - ,end(L'\0') - { - } - - CharRange::CharRange(wchar_t _begin, wchar_t _end) - :begin(_begin) - ,end(_end) - { - } - - bool CharRange::operator<(CharRange item)const - { - return end(CharRange item)const - { - return item.end=(CharRange item)const - { - return *this>item || *this==item; - } - - bool CharRange::operator==(CharRange item)const - { - return begin==item.begin && end==item.end; - } - - bool CharRange::operator!=(CharRange item)const - { - return begin!=item.begin || item.end!=end; - } - - bool CharRange::operator<(wchar_t item)const - { - return end(wchar_t item)const - { - return item=(wchar_t item)const - { - return item<=end; - } - - bool CharRange::operator==(wchar_t item)const - { - return begin<=item && item<=end; - } - - bool CharRange::operator!=(wchar_t item)const - { - return item>& value, const vl::collections::List& tokens) + { + vint begin=-1; + vint end=-1; + for(vint i=value.Count()-1;i>=-1;i--) + { + if(i==-1) + { + if(end!=-1) begin=0; + } + else if(value[i].Cast()) + { + if(end==-1) end=i; + } + else + { + if(end!=-1) begin=i+1; + } + if(begin!=-1 && end!=-1) + { + vint tokenBegin=value[begin].Cast()->content.tokenIndex; + vint tokenEnd=value[end].Cast()->content.tokenIndex; + while(tokenBegin>0) + { + if(tokens.Get(tokenBegin-1).token==(vint)XmlParserTokenIndex::SPACE || tokens.Get(tokenBegin-1).token==-1) + { + tokenBegin--; + } + else + { + break; + } + } + while(tokenEnd xmlText=new XmlText; + xmlText->codeRange=range; + xmlText->content.codeRange=range; + xmlText->content.value=XmlUnescapeValue(text); + + value.RemoveRange(begin, end-begin+1); + value.Insert(begin, xmlText); + + begin=-1; + end=-1; + } + } + } + + void XmlUnescapeAttributeValue(vl::parsing::ParsingToken& value, const vl::collections::List& tokens) + { + value.value=XmlUnescapeValue(value.value.Sub(1, value.value.Length()-2)); + } + + void XmlUnescapeCData(vl::parsing::ParsingToken& value, const vl::collections::List& tokens) + { + value.value=XmlUnescapeCData(value.value); + } + + void XmlUnescapeComment(vl::parsing::ParsingToken& value, const vl::collections::List& tokens) + { + value.value=XmlUnescapeComment(value.value); + } + +/*********************************************************************** +XmlPrintVisitor +***********************************************************************/ + + class XmlPrintVisitor : public Object, public XmlNode::IVisitor + { + public: + TextWriter& writer; + + XmlPrintVisitor(TextWriter& _writer) + :writer(_writer) + { + } + + void Visit(XmlText* node) + { + writer.WriteString(XmlEscapeValue(node->content.value)); + } + + void Visit(XmlCData* node) + { + writer.WriteString(XmlEscapeCData(node->content.value)); + } + + void Visit(XmlAttribute* node) + { + writer.WriteString(node->name.value); + writer.WriteString(L"=\""); + writer.WriteString(XmlEscapeValue(node->value.value)); + writer.WriteString(L"\""); + } + + void Visit(XmlComment* node) + { + writer.WriteString(XmlEscapeComment(node->content.value)); + } + + void Visit(XmlElement* node) + { + writer.WriteChar(L'<'); + writer.WriteString(node->name.value); + FOREACH(Ptr, att, node->attributes) + { + writer.WriteChar(L' '); + att->Accept(this); + } + if(node->subNodes.Count()==0) + { + writer.WriteString(L"/>"); + } + else + { + writer.WriteChar(L'>'); + FOREACH(Ptr, subNode, node->subNodes) + { + subNode->Accept(this); + } + writer.WriteString(L"name.value); + writer.WriteChar(L'>'); + } + } + + void Visit(XmlInstruction* node) + { + writer.WriteString(L"name.value); + FOREACH(Ptr, att, node->attributes) + { + writer.WriteChar(L' '); + att->Accept(this); + } + writer.WriteString(L"?>"); + } + + void Visit(XmlDocument* node) + { + FOREACH(Ptr, prolog, node->prologs) + { + prolog->Accept(this); + } + node->rootElement->Accept(this); + } + }; + +/*********************************************************************** +API +***********************************************************************/ + + WString XmlEscapeValue(const WString& value) + { + WString result; + const wchar_t* reading=value.Buffer(); + while(wchar_t c=*reading++) + { + switch(c) + { + case L'<': + result+=L"<"; + break; + case L'>': + result+=L">"; + break; + case L'&': + result+=L"&"; + break; + case L'\'': + result+=L"'"; + break; + case L'\"': + result+=L"""; + break; + default: + result+=c; + } + } + return result; + } + + WString XmlUnescapeValue(const WString& value) + { + WString result; + const wchar_t* reading=value.Buffer(); + while(*reading) + { + if(wcsncmp(reading, L"<", 4)==0) + { + result+=L'<'; + reading+=4; + } + else if(wcsncmp(reading, L">", 4)==0) + { + result+=L'>'; + reading+=4; + } + else if(wcsncmp(reading, L"&", 5)==0) + { + result+=L'&'; + reading+=5; + } + else if(wcsncmp(reading, L"'", 6)==0) + { + result+=L'\''; + reading+=6; + } + else if(wcsncmp(reading, L""", 6)==0) + { + result+=L'\"'; + reading+=6; + } + else + { + result+=*reading++; + } + } + return result; + } + + WString XmlEscapeCData(const WString& value) + { + return L""; + } + + WString XmlUnescapeCData(const WString& value) + { + return value.Sub(9, value.Length()-12); + } + + WString XmlEscapeComment(const WString& value) + { + return L""; + } + + WString XmlUnescapeComment(const WString& value) + { + return value.Sub(4, value.Length()-7); + } + + void XmlPrint(Ptr node, stream::TextWriter& writer) + { + XmlPrintVisitor visitor(writer); + node->Accept(&visitor); + } + + void XmlPrintContent(Ptr element, stream::TextWriter& writer) + { + XmlPrintVisitor visitor(writer); + FOREACH(Ptr, node, element->subNodes) + { + node->Accept(&visitor); + } + } + + WString XmlToString(Ptr node) + { + MemoryStream stream; + { + StreamWriter writer(stream); + XmlPrint(node, writer); + } + stream.SeekFromBegin(0); + { + StreamReader reader(stream); + return reader.ReadToEnd(); + } + } + +/*********************************************************************** +Linq To Xml +***********************************************************************/ + + Ptr XmlGetAttribute(Ptr element, const WString& name) + { + return XmlGetAttribute(element.Obj(), name); + } + + Ptr XmlGetElement(Ptr element, const WString& name) + { + return XmlGetElement(element.Obj(), name); + } + + collections::LazyList> XmlGetElements(Ptr element) + { + return XmlGetElements(element.Obj()); + } + + collections::LazyList> XmlGetElements(Ptr element, const WString& name) + { + return XmlGetElements(element.Obj(), name); + } + + WString XmlGetValue(Ptr element) + { + return XmlGetValue(element.Obj()); + } + + Ptr XmlGetAttribute(XmlElement* element, const WString& name) + { + FOREACH(Ptr, att, element->attributes) + { + if(att->name.value==name) + { + return att; + } + } + return 0; + } + + Ptr XmlGetElement(XmlElement* element, const WString& name) + { + FOREACH(Ptr, node, element->subNodes) + { + Ptr subElement=node.Cast(); + if(subElement && subElement->name.value==name) + { + return subElement; + } + } + return 0; + } + + collections::LazyList> XmlGetElements(XmlElement* element) + { + return From(element->subNodes) + .FindType(); + } + + collections::LazyList> XmlGetElements(XmlElement* element, const WString& name) + { + return From(element->subNodes) + .FindType() + .Where([name](Ptr e){return e->name.value==name;}); + } + + WString XmlGetValue(XmlElement* element) + { + WString result; + FOREACH(Ptr, node, element->subNodes) + { + if(Ptr text=node.Cast()) + { + result+=text->content.value; + } + else if(Ptr text=node.Cast()) + { + result+=text->content.value; + } + } + return result; + } + +/*********************************************************************** +XmlElementWriter +***********************************************************************/ + + XmlElementWriter::XmlElementWriter(Ptr _element, const XmlElementWriter* _previousWriter) + :element(_element) + ,previousWriter(_previousWriter) + { + } + + XmlElementWriter::~XmlElementWriter() + { + } + + const XmlElementWriter& XmlElementWriter::Attribute(const WString& name, const WString& value)const + { + Ptr node=new XmlAttribute; + node->name.value=name; + node->value.value=value; + element->attributes.Add(node); + return *this; + } + + XmlElementWriter XmlElementWriter::Element(const WString& name)const + { + Ptr node=new XmlElement; + node->name.value=name; + element->subNodes.Add(node); + return XmlElementWriter(node, this); + } + + const XmlElementWriter& XmlElementWriter::End()const + { + return *previousWriter; + } + + const XmlElementWriter& XmlElementWriter::Text(const WString& value)const + { + Ptr node=new XmlText; + node->content.value=value; + element->subNodes.Add(node); + return *this; + } + + const XmlElementWriter& XmlElementWriter::CData(const WString& value)const + { + Ptr node=new XmlCData; + node->content.value=value; + element->subNodes.Add(node); + return *this; + } + + const XmlElementWriter& XmlElementWriter::Comment(const WString& value)const + { + Ptr node=new XmlComment; + node->content.value=value; + element->subNodes.Add(node); + return *this; + } + } + } +} + + +/*********************************************************************** +.\PARSING\XML\PARSINGXML_AST.CPP +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Parser::ParsingXml.parser.txt + +This file is generated by: Vczh Parser Generator +***********************************************************************/ + + +namespace vl +{ + namespace parsing + { + namespace xml + { +/*********************************************************************** +Visitor Pattern Implementation +***********************************************************************/ + + void XmlText::Accept(XmlNode::IVisitor* visitor) + { + visitor->Visit(this); + } + + void XmlCData::Accept(XmlNode::IVisitor* visitor) + { + visitor->Visit(this); + } + + void XmlAttribute::Accept(XmlNode::IVisitor* visitor) + { + visitor->Visit(this); + } + + void XmlComment::Accept(XmlNode::IVisitor* visitor) + { + visitor->Visit(this); + } + + void XmlElement::Accept(XmlNode::IVisitor* visitor) + { + visitor->Visit(this); + } + + void XmlInstruction::Accept(XmlNode::IVisitor* visitor) + { + visitor->Visit(this); + } + + void XmlDocument::Accept(XmlNode::IVisitor* visitor) + { + visitor->Visit(this); + } + + } + } +} +namespace vl +{ + namespace reflection + { + namespace description + { +#ifndef VCZH_DEBUG_NO_REFLECTION + using namespace vl::parsing::xml; + +#define PARSING_TOKEN_FIELD(NAME)\ + CLASS_MEMBER_EXTERNALMETHOD_TEMPLATE(get_##NAME, NO_PARAMETER, vl::WString(ClassType::*)(), [](ClassType* node) { return node->NAME.value; }, L"*", L"*")\ + CLASS_MEMBER_EXTERNALMETHOD_TEMPLATE(set_##NAME, { L"value" }, void(ClassType::*)(const vl::WString&), [](ClassType* node, const vl::WString& value) { node->NAME.value = value; }, L"*", L"*")\ + CLASS_MEMBER_PROPERTY_REFERENCETEMPLATE(NAME, get_##NAME, set_##NAME, L"$This->$Name.value")\ + + IMPL_TYPE_INFO_RENAME(vl::parsing::xml::XmlNode, system::XmlNode) + IMPL_TYPE_INFO_RENAME(vl::parsing::xml::XmlText, system::XmlText) + IMPL_TYPE_INFO_RENAME(vl::parsing::xml::XmlCData, system::XmlCData) + IMPL_TYPE_INFO_RENAME(vl::parsing::xml::XmlAttribute, system::XmlAttribute) + IMPL_TYPE_INFO_RENAME(vl::parsing::xml::XmlComment, system::XmlComment) + IMPL_TYPE_INFO_RENAME(vl::parsing::xml::XmlElement, system::XmlElement) + IMPL_TYPE_INFO_RENAME(vl::parsing::xml::XmlInstruction, system::XmlInstruction) + IMPL_TYPE_INFO_RENAME(vl::parsing::xml::XmlDocument, system::XmlDocument) + IMPL_TYPE_INFO_RENAME(vl::parsing::xml::XmlNode::IVisitor, system::XmlNode::IVisitor) + + BEGIN_CLASS_MEMBER(XmlNode) + CLASS_MEMBER_METHOD_OVERLOAD(Accept, {L"visitor"}, void(XmlNode::*)(XmlNode::IVisitor* visitor)) + END_CLASS_MEMBER(XmlNode) + + BEGIN_CLASS_MEMBER(XmlText) + CLASS_MEMBER_BASE(XmlNode) + + CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) + + PARSING_TOKEN_FIELD(content) + END_CLASS_MEMBER(XmlText) + + BEGIN_CLASS_MEMBER(XmlCData) + CLASS_MEMBER_BASE(XmlNode) + + CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) + + PARSING_TOKEN_FIELD(content) + END_CLASS_MEMBER(XmlCData) + + BEGIN_CLASS_MEMBER(XmlAttribute) + CLASS_MEMBER_BASE(XmlNode) + + CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) + + PARSING_TOKEN_FIELD(name) + PARSING_TOKEN_FIELD(value) + END_CLASS_MEMBER(XmlAttribute) + + BEGIN_CLASS_MEMBER(XmlComment) + CLASS_MEMBER_BASE(XmlNode) + + CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) + + PARSING_TOKEN_FIELD(content) + END_CLASS_MEMBER(XmlComment) + + BEGIN_CLASS_MEMBER(XmlElement) + CLASS_MEMBER_BASE(XmlNode) + + CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) + + PARSING_TOKEN_FIELD(name) + PARSING_TOKEN_FIELD(closingName) + CLASS_MEMBER_FIELD(attributes) + CLASS_MEMBER_FIELD(subNodes) + END_CLASS_MEMBER(XmlElement) + + BEGIN_CLASS_MEMBER(XmlInstruction) + CLASS_MEMBER_BASE(XmlNode) + + CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) + + PARSING_TOKEN_FIELD(name) + CLASS_MEMBER_FIELD(attributes) + END_CLASS_MEMBER(XmlInstruction) + + BEGIN_CLASS_MEMBER(XmlDocument) + CLASS_MEMBER_BASE(XmlNode) + + CLASS_MEMBER_CONSTRUCTOR(vl::Ptr(), NO_PARAMETER) + + CLASS_MEMBER_FIELD(prologs) + CLASS_MEMBER_FIELD(rootElement) + END_CLASS_MEMBER(XmlDocument) + + BEGIN_INTERFACE_MEMBER(XmlNode::IVisitor) + CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(XmlNode::IVisitor::*)(XmlText* node)) + CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(XmlNode::IVisitor::*)(XmlCData* node)) + CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(XmlNode::IVisitor::*)(XmlAttribute* node)) + CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(XmlNode::IVisitor::*)(XmlComment* node)) + CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(XmlNode::IVisitor::*)(XmlElement* node)) + CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(XmlNode::IVisitor::*)(XmlInstruction* node)) + CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(XmlNode::IVisitor::*)(XmlDocument* node)) + END_INTERFACE_MEMBER(XmlNode) + +#undef PARSING_TOKEN_FIELD + + class XmlTypeLoader : public vl::Object, public ITypeLoader + { + public: + void Load(ITypeManager* manager) + { + ADD_TYPE_INFO(vl::parsing::xml::XmlNode) + ADD_TYPE_INFO(vl::parsing::xml::XmlText) + ADD_TYPE_INFO(vl::parsing::xml::XmlCData) + ADD_TYPE_INFO(vl::parsing::xml::XmlAttribute) + ADD_TYPE_INFO(vl::parsing::xml::XmlComment) + ADD_TYPE_INFO(vl::parsing::xml::XmlElement) + ADD_TYPE_INFO(vl::parsing::xml::XmlInstruction) + ADD_TYPE_INFO(vl::parsing::xml::XmlDocument) + ADD_TYPE_INFO(vl::parsing::xml::XmlNode::IVisitor) + } + + void Unload(ITypeManager* manager) + { + } + }; +#endif + + bool XmlLoadTypes() + { +#ifndef VCZH_DEBUG_NO_REFLECTION + ITypeManager* manager=GetGlobalTypeManager(); + if(manager) + { + Ptr loader=new XmlTypeLoader; + return manager->AddTypeLoader(loader); + } +#endif + return false; + } + } + } +} + + +/*********************************************************************** +.\PARSING\XML\PARSINGXML_PARSER.CPP +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Parser::ParsingXml.parser.txt + +This file is generated by: Vczh Parser Generator +***********************************************************************/ + + +namespace vl +{ + namespace parsing + { + namespace xml + { +/*********************************************************************** +ParserText +***********************************************************************/ + +const wchar_t parserTextBuffer[] = +L"\r\n" L"" +L"\r\n" L"//////////////////////////////////////////////////////////////////" +L"\r\n" L"// AST" +L"\r\n" L"//////////////////////////////////////////////////////////////////" +L"\r\n" L"" +L"\r\n" L"class Node" +L"\r\n" L"{" +L"\r\n" L"}" +L"\r\n" L"" +L"\r\n" L"class Text : Node" +L"\r\n" L"{" +L"\r\n" L"\ttoken content;" +L"\r\n" L"}" +L"\r\n" L"" +L"\r\n" L"class CData : Node" +L"\r\n" L"{" +L"\r\n" L"\ttoken content (XmlUnescapeCData);" +L"\r\n" L"}" +L"\r\n" L"" +L"\r\n" L"class Attribute : Node" +L"\r\n" L"{" +L"\r\n" L"\ttoken name\t\t\t\t\t\t\t\t\t@Color(\"AttName\");" +L"\r\n" L"\ttoken value (XmlUnescapeAttributeValue)\t\t@Color(\"AttValue\");" +L"\r\n" L"}" +L"\r\n" L"" +L"\r\n" L"class Comment : Node" +L"\r\n" L"{" +L"\r\n" L"\ttoken content (XmlUnescapeComment);" +L"\r\n" L"}" +L"\r\n" L"" +L"\r\n" L"class Element : Node" +L"\r\n" L"{" +L"\r\n" L"\ttoken name\t\t\t\t\t\t\t\t\t@Color(\"TagName\");" +L"\r\n" L"\ttoken closingName\t\t\t\t\t\t\t@Color(\"TagName\");" +L"\r\n" L"\tAttribute[] attributes;" +L"\r\n" L"\tNode[] subNodes (XmlMergeTextFragment);" +L"\r\n" L"}" +L"\r\n" L"" +L"\r\n" L"class Instruction : Node" +L"\r\n" L"{" +L"\r\n" L"\ttoken name\t\t\t\t\t\t\t\t\t@Color(\"TagName\");" +L"\r\n" L"\tAttribute[] attributes;" +L"\r\n" L"}" +L"\r\n" L"" +L"\r\n" L"class Document : Node" +L"\r\n" L"{" +L"\r\n" L"\tNode[] prologs;" +L"\r\n" L"\tElement rootElement;" +L"\r\n" L"}" +L"\r\n" L"" +L"\r\n" L"//////////////////////////////////////////////////////////////////" +L"\r\n" L"// Lexer" +L"\r\n" L"//////////////////////////////////////////////////////////////////" +L"\r\n" L"" +L"\r\n" L"token INSTRUCTION_OPEN = \"/\"\t\t@Color(\"Boundary\");" +L"\r\n" L"token COMPLEX_ELEMENT_OPEN = \"/\"\t\t@Color(\"Boundary\");" +L"\r\n" L"token ELEMENT_OPEN = \"/<\"\t\t\t\t@Color(\"Boundary\");" +L"\r\n" L"token ELEMENT_CLOSE = \"/>\"\t\t\t\t@Color(\"Boundary\");" +L"\r\n" L"token EQUAL = \"/=\";" +L"\r\n" L"" +L"\r\n" L"token NAME = \"[a-zA-Z0-9:._/-]+\"\t\t\t\t\t\t\t\t@ContextColor();" +L"\r\n" L"token ATTVALUE = \"\"\"[^<>\"\"]*\"\"|\'[^<>\']*\'\"\t\t\t\t\t\t@ContextColor();" +L"\r\n" L"token COMMENT = \"/]|-[^/->]|--[^>])*--/>\"\t\t\t@Color(\"Comment\");" +L"\r\n" L"token CDATA = \"/])*/]/]/>\";" +L"\r\n" L"token TEXT = \"([^<>=\"\"\' /r/n/ta-zA-Z0-9:._/-])+|\"\"|\'\";" +L"\r\n" L"" +L"\r\n" L"discardtoken SPACE = \"/s+\";" +L"\r\n" L"" +L"\r\n" L"//////////////////////////////////////////////////////////////////" +L"\r\n" L"// Rules" +L"\r\n" L"//////////////////////////////////////////////////////////////////" +L"\r\n" L"" +L"\r\n" L"rule Attribute XAttribute = NAME:name \"=\" ATTVALUE:value as Attribute;" +L"\r\n" L"rule Text XText = (NAME:content | EQUAL:content | ATTVALUE:content | TEXT:content) as Text;" +L"\r\n" L"rule CData XCData = CDATA:content as CData;" +L"\r\n" L"rule Comment XComment = COMMENT:content as Comment;" +L"\r\n" L"rule Element XElement = \"<\" NAME:name {XAttribute:attributes} (\"/>\" | \">\" {XSubNode:subNodes} \"\") as Element;" +L"\r\n" L"rule Node XSubNode = !XText | !XCData | !XComment | !XElement;" +L"\r\n" L"rule Instruction XInstruction = \"\" as Instruction;" +L"\r\n" L"rule Document XDocument = {XInstruction:prologs | XComment:prologs} XElement:rootElement as Document;" +; + + vl::WString XmlGetParserTextBuffer() + { + return parserTextBuffer; + } + +/*********************************************************************** +SerializedTable +***********************************************************************/ + +const vint parserBufferLength = 4442; // 18926 bytes before compressing +const vint parserBufferBlock = 1024; +const vint parserBufferRemain = 346; +const vint parserBufferRows = 5; +const char* parserBuffer[] = { +"\x00\x0E\x00\x02\x83\x80\x07\x7D\x00\x82\x03\xFF\x45\x08\x82\x83\x86\x81\x21\x6F\x6C\x2F\x32\x37\x84\x87\x02\x86\x00\x17\x82\x94\x21\x37\x32\x27\x30\x6D\x65\x06\x98\x8A\x80\x8E\x86\x00\x10\x92\x94\x98\x8A\x88\x85\x96\x8E\x1E\xA0\xA2\x95\x88\x85\x90\x87\x93\x29\x93\xB4\x84\x8D\x94\x9F\x81\x20\x74\x74\x1F\x81\x93\x94\x86\x9A\x84\x38\x91\xBA\x98\x88\x04\xA7\x9F\xA0\x56\x61\x2C\x35\x33\x9C\x93\x92\x82\x49\xAA\xBB\x83\x8D\x9C\xAF\x80\x98\x43\xD5\x86\xB7\xA3\x81\xAF\xA4\x86\x4D\xE8\x83\x82\x2F\x35\x3A\x36\x32\x61\x72\x39\x25\xA5\x9C\xB1\x87\x81\x39\xAB\xAA\xBB\xB0\x04\xB6\xB6\xB8\x72\xF4\x84\x87\xA8\xA8\xBE\xA4\xBD\x08\xE9\x89\xCB\xBD\xB7\xB5\xB9\xB9\x5B\x82\x84\xC5\xB6\xC2\xAE\xA6\xBE\x7E\x8E\xC1\xD1\xC5\x86\xB8\x00\xB3\x88\x84\x8A\xC2\xDC\xC7\xBF\xC6\xC1\x09\x9E\xE0\xDC\xC3\xD3\x82\xC5\xCC\x80\x90\xE4\x8C\x08\x8C\xDB\x87\x37\x6E\x74\x25\x38\x34\x39\xBC\x8D\x82\x9C\xFF\x76\xC8\x83\xE0\x89\xDD\xDD\xBD\x87\xFF\xC8\xD2\xCA\xD5\xCB\xB3\x2E\xAC\x86\xCD\x31\x91\xDD\xD6\x81\x09\x18\x99\xE2\x80\xA4\x3A\x39\x34\x62\x75\x3A\xDF\x74\xF5\xF0\xF2\xE7\x0F\xC4\x21\x34\x31\x36\xF2\xF3\xAE\x02\xAD\x90\x94\xE5\x31\xDE\xF7\xF2\xD7\x80\x0A\xC4\x2F\x33\x31\x3B\xEA\x74\x37\x74\x78\x7C\x19\x43\x45\x10\x1B\x65\x00\x82\x83\x3F\x0B\x18\x4D\x82\x40\x49\x2E\x13\x1E\x77\x75\x23\x14\x1D\x1A\xB8\x4B\x84\x00\x46\x1B\x82\x4E\x13\x1B\x64\x22\x42\x81\x87\x08\x64\x84\x14\x72\x0B\x8D\x0A\x77\x8A\xDC\x41\x5F\x75\x78\xBA\x64\x84\x40\x89\x6E\x32\x42\x00\x8B\x08\x5B\x70\x01\x77\x2F\xA2\x75\x18\x7A\x00\x36\x12\x54\x55\x03\x26\x46\x91\x7A\xEB\x61\x14\x81\x4B\x63\x38\x6A\x6E\x7D\x02\x8B\x93\x74\x80\x52\x82\x4D\x93\x71\x50\xB7\x79\x7F\x7E\xFD\x7F\x75\x7C\x1D\x55\x80\x00\x1E\x1C\x4A\x67\x13\x1F\x82\x5B\x83\x4C\x7E\x7F\x00\x8F\x88\x42\x9B\x64\xAF\x14\x1F\x81\x09\x9F\x9B\x81\x98\x74\x80\x8A\x00\x46\x7B\x82\x4B\x7A\x77\xE0\x7E\x87\x99\x94\xD2\x42\x49\x9F\x97\x6E\x84\x4E\x9B\x18\x12\x73\x19\x1A\x1B\x31\x61\x4C\x64\x9E\x08\x80\x82\x8F\x40\x34\xB2\x4F\x6C\xA5\x75\x96\x77\x64\x00\x73\x35\x12\x1B\x87\x21\x83\xA7\x7D\xA2\x03\x6E\x91\x87\x84\x72\x15\x87\x84\x6E\x7D\x88\x41\xAF\x9F\x3D\xBA\x66\xAA\x7B\xA8\x82\x4A\xAA\x84\x14\x96\x88\x86\x1B\x97\x82\x49\xA5\x48\xC1\x80\x05\xB2\x89\xC8\x61\x97\x97\x93\x01\x82\x80\x04\x46\x31\x18\x4F\xB3\x6F\xD4\xB5\x4B\x82\x80\xD5\x86\x57\xB7\x7D\xD9\x96\xBB\xB6\x79\xDD\x83\x6F\xB6\x79\xD3\x88\x45\xB9\x12\x4E\x13\x14\x16\x14\x55\x03\x14\x15\x12\x4F\x0E\x1F\x17\x13\x50\x05\x1E\x13\xB1\x03\x6F\x0C\x0F\x0B\x3F\x3F\x6E\x65\x04\x18\x40\xC0\x85\xBA\xEB\xAD\xBF\xB9\xBC\x5F\x03\x1C\x13\x13\x53\x05\x18\xBE\x40\xFC\xAF\x0E\x0C\x67\x06\x18\x44\x06\xC5\x78\x4F\x1D\x10\x14\x4C\x05\x18\x17\x17\x45\x1D\xCD\x12\xBD\x54\x33\xB5\xBF\xBD\x1C\xB9\xBB\xBF\x0B\x37\x96\x48\xC4\x43\x17\xC2\x43\x14\xBA\x47\x1D\xC0\xCA\xC8\x24\xC9\xCB\xC1\xC3\x0F\xC0\x0F\x0B\xCF\x3E\x05\x9C\x5C\x41\xC3\x44\xD6\x80\xCE\x4E\x25\xC4\xBE\xBD\x2D\xC8\x4D\xD2\xBE\xC5\xBA\x84\x42\x8A\x0C\x54\xD0\x01\xC8\x45\x23\xC9\xD2\xCE\x0C\xC5\x1D\xD0\x41\x4F\xFE\x0E\x65\xAC\x85\x77\x46\x81\x14\x55\x01\x1C\x13\xD7\x03\x4F\xDD\x0D\xC5\xDA\xB7\x7D\xCE\x13\x41\x23\xC2\xC0\x42\x77\xDB\x11\x19\x0B\x7A\x01\x1D\x0A\x16\x30\x2D\x09\x0E\x0E\x2E\x1F\x1F\x09\x0B\x5D\x2B\x04\x81\xAE\xFA\x5F\xA1\x10\x15\x54\x16\x1A\xD9\x15\x45\x13\x08\x46\xE5\x02\x62\x0B\x16\x17\x3C\x3E\x02\x09\x17\x2A\x22\x0C\x1F\x09\x9B\xDD\xE7\x08\xE8\x27\x39\x75\xD2\x57\x2E\xCF\x4A\xC6\xD6\x54\x22\x08\x46\xEC\x10\xFB\xB1\x09\x0B\x2D\x28\x0B\xE7\xE1\x3E\x1D\x1C\x1D\x0B\xBB\xED\x0D\xEF\xEF\xC0\xDE\x1D\xED\x0A\x2A\x38\xE2\xC6\xD4\x03\x56\xD5\xD8\x52\x78\x44\x1F\xE1\x10\x2C\x18\x45\xF5\xED\x2F\x21\x0F\x0B\x16\x43\x12\xF4\x15\x10\xDB\xFA\xEE\x17\x0B\x5D\x3E\xE4\xFB\xEE\xE5\xFC\x14\xFB\xF9\xC6\xDD\x18\xF3\xFA\x5D\x12\xC4\xD9\x42\x23\xA9\xCB\x46\xC7\x54\x24\x08\x46\xFE\x02\x62\xFD\xE5\x0F\x22\x07\x04\x08\x2F\x02\x0F\x17\x2E\x0F\x05\xEC\x3C\x6E\xDF\x00\x72\x70\xC2\x46\x70\x71\x29\x0B\x04\x1F\x22\x77\x04\xC6\x4B\x44\x33\x40\x53\x08\x14\x41\x03\x09\x22\x02\x68\x21\x1F\x8F\x07\x1C\x2B\x0B\x74\xC9\x02\x41\x5A\x0C\x30\x6C\x42\x2A\x88\x0B\xEE\x49\x4D\x5C\x04\x25\x5D\x0B\xEA\x3C\x3C\x17\x12\x0F\x0D\x72\x53\x08\x7B\x72\x04\x0E\xC6\x6E\x48\x08\x20\x04\x04\x0F\x33\x89\x48", +"\x1F\x2A\x84\x20\x2C\x8E\x84\x7B\x25\x80\x01\xE1\x04\x8D\x86\x3A\x91\x2C\x1D\x73\x72\x21\x58\x40\x8B\x88\x4A\x81\x0E\x11\x98\x29\x88\x1A\xA1\x09\x4D\x02\x2F\x89\x18\x2E\x01\x07\x11\x18\x26\x8C\x02\x38\x8A\x17\xBE\x0A\x06\x10\x1D\x7B\x7A\x20\x0D\x8F\xB2\x5F\x40\x05\x30\x33\x0E\x8D\x5E\x80\x0B\x11\x83\x2D\x8B\x24\x41\x24\x21\x7F\x80\x02\x18\xB6\x88\x87\x39\x6F\x2E\x87\x03\x22\x8A\x18\xBE\x00\x04\x20\x20\x8A\x90\x53\x02\x54\xA9\x65\x04\x8A\x00\x31\x50\x0B\x91\x83\x54\x88\x65\x04\x8D\x1A\x18\x26\x93\x69\x98\x92\x24\x9B\x9C\x8C\x10\x21\x00\x0B\x27\x5C\x34\x08\x7C\x06\x94\x31\xAB\x95\x95\xF3\x20\x43\x2B\xA7\x97\x51\xDC\x0E\x97\x53\x58\x15\x97\x14\xFC\x43\x21\x5C\x95\x57\x4B\x2E\x13\x06\x03\x11\x33\x99\x50\xBA\x95\x94\x22\x1C\x06\x08\x20\x04\x6F\x91\x71\x88\x04\x35\x41\x24\x08\x7B\x00\x04\x2C\x3C\x41\x50\xBA\x2F\x98\xAD\x58\x95\x0D\x3B\xBD\x08\x04\x28\x00\x06\x08\x12\x6B\x98\x56\xA2\x06\x73\x40\x94\x9A\x28\x9A\x91\x45\x67\xA1\x54\x9D\xDD\x80\x07\x37\xC9\x9F\x05\x65\x8D\x9D\x08\xCF\x8C\x53\x1B\x0E\x50\x53\xB0\x22\x9E\x73\x20\x09\x05\x1D\xF7\x8A\x97\x06\x0A\x03\x88\xC7\x8D\x8D\x32\xF6\x95\x6E\x7C\xAD\x89\x9A\x65\x13\x99\x35\xD7\x90\x47\x88\xAD\x8B\x9B\x15\xBE\x98\x38\xE2\x94\x9D\x57\xA7\x9B\x99\x40\x0A\x9D\x26\x93\x9E\x9D\x51\xA5\x52\x9E\xE2\x9B\x5C\x43\xCE\x92\x8F\x46\x4F\x51\x52\x11\xBF\xA1\x40\x83\xA0\x04\x5D\x8F\x93\x9D\x93\x90\x87\x40\x32\x83\xA5\x4D\x84\x92\x4E\x45\x0F\x2E\xF3\x4D\x79\x91\x21\xBD\xA1\x44\x8C\x97\x94\x5F\x3E\x9D\x53\x5D\x8C\x27\x92\xBA\x8E\x06\x0D\x06\x18\x22\xAA\x86\x9F\x97\xB9\x28\x9A\x32\xCC\x9D\xA1\x67\x90\xA2\xA2\xD6\x8E\x44\x37\xDA\x92\xAD\x8C\xA8\xA1\x9C\xE3\x80\xA2\x39\x80\xA2\xA4\x93\x96\xA0\x04\xEF\x93\x92\x46\xF4\x92\x04\x20\xB7\x99\x9F\x2E\xBD\x9E\x4C\x7F\x9B\x98\x81\xB6\x8D\xA6\x58\xB4\x0C\x90\x28\x99\x59\x42\x42\x91\x95\x74\x04\x8C\x16\x18\x2B\xB1\x50\x88\xB5\x94\x77\xB2\x8E\x93\x74\x8C\x95\x22\x28\x6A\x6D\xF9\x93\xB1\x6E\x2F\x9F\x71\xC8\x53\x76\xA1\x20\x13\x8F\x66\xAC\x94\x0A\xFC\x59\xB0\x4B\x74\x14\xA4\x62\xCA\xAB\x31\x30\xB1\x97\x4B\x95\x97\x93\x6B\xB9\x34\x8D\x14\x18\x26\xB6\xA1\x93\xB4\x1D\x25\x93\x09\xD7\x64\x67\xB4\xCC\x54\xA6\x6E\xAC\xB4\x35\x30\xBA\x91\xB6\xBD\x91\xA9\x0C\x56\xA8\x20\xE6\x88\xA1\xB0\x5A\xB5\xAC\x57\xAC\xA0\x9B\xBD\xAA\x9C\xA2\x3E\x44\xAC\xA0\x66\xAF\x9A\xB4\x9D\xA3\xAD\xCB\x8D\xAC\x3C\xA5\xA0\x9F\xB9\xAA\xA3\xBA\xA0\xBA\x9C\x3F\xB0\xAC\xAF\x99\xBF\xAE\xA6\xB8\x87\xB8\x2F\xC6\xB1\xB0\x17\x37\x04\xB9\x04\x2E\xB8\x53\x80\x41\xBA\xF4\x9E\xAE\xBA\x13\xA5\xAD\x76\x97\xA2\xC0\x5B\x67\xAC\xA3\x6A\xAD\xBE\x78\xA4\xAD\x8D\xB8\x9B\x96\xBC\xF5\x9E\xBD\x4B\xFB\x9F\xA5\xB0\x00\x8A\xA6\x7E\xA4\xA1\x60\x83\xB8\xB1\xA1\x82\x26\x6A\x84\xBC\x37\x4F\x86\x94\x0C\xE4\x82\x22\x91\x8F\xAD\x93\x4D\xBA\xBA\xA6\x81\x32\x82\xB7\x23\xC1\xA8\x19\x1E\xC0\x00\xAB\x4A\x92\xB7\x49\xAC\x78\x76\x3D\x9B\x4C\x2F\x79\x30\x91\x61\x9D\xC4\x80\x2E\x02\x06\x30\x18\x26\xC8\xA1\x82\xCB\x97\x25\x91\xA5\x6A\xAB\x55\x57\xAF\x4E\x0F\x33\xE3\x45\x4D\x3B\xAC\x95\x85\x6F\x14\x3F\x66\xED\x84\xCA\x89\x26\x48\xA5\xFB\xB4\x8D\x1B\xF1\x43\x4F\xC0\xB4\xA2\xC9\x9E\x4B\xAA\x7C\xCF\xA9\xB9\xFA\xB4\x05\x98\x08\x30\xCF\x73\xCD\xAD\xBF\xC8\x95\xBA\x9A\x4D\xC1\xAF\x76\x83\xC5\x8F\x02\xF1\x9D\xBB\x08\xC5\x9E\x82\xD5\x97\xA9\xB7\x8E\xC7\xA4\xF3\x87\xBE\x9D\xEA\xB5\xC3\xBD\x98\xC4\xA6\x05\xA7\xA1\x98\xD9\xAA\xA1\xAD\xB6\xC8\xA2\xE9\x81\xC3\x9E\xD9\x94\xC1\x4D\xFF\xCB\xA3\x69\xA2\xD2\x4C\x8B\xCB\x92\xF2\xB2\xA8\xA5\x74\xB2\xC1\x68\xF9\xAC\xBD\x47\xEF\xB9\xB0\x37\xAB\xCE\xAC\x6D\xCD\xA8\x22\xF8\xBB\x20\xFA\xA9\xA1\x4A\xAB\xA0\xB5\xAF\x97\xBE\xCF\xDA\xB5\x57\xA7\xDE\xB9\xC1\x51\xC4\xD6\xAD\xA6\xCF\xC0\xAA\x8A\xDD\xAB\x09\xEB\xBE\x9F\xAE\xDA\xC1\x53\xC0\x0C\x88\x27\x8F\xCD\x55\xBE\x58\x35\x20\x84\x21\x90\x2C\x17\xDE\x55\xBF\x44\x8D\x14\x18\x23\xDD\x50\x9F\xD9\xDB\x6E\x1A\xAB\x0F\x52\xB7\xD2\x00\xFA\xCA\xD8\xC1\xDC\x9B\x5C\xBF\x00\xA1\xBF\xA7\xD9\xCA\x26\xC2\x90\x76\xBA\x35\xDB\x5E\xBB\xDC\x93\x31\x1C\x04\x46\x02\xE1\x95\x7F\xD0\xB5\xD9\x77\xC5\x0F\x85\x80\x80\x05\xCE\x92\x74\x09\x94\x6F\x9A\x90\x53\x21\xA3\xBF\xBF\xD9\xD6\x81\xAD\xC4\x00\x32\x81\xAB\x1B\x80\xAA\xA8\x18\x36\xC7\x9C\xFC\xBD\x90\x1D\xC0\x02\x47\x58\x08\xCD\x0F\x8E\x4C\xC7\x2E", +"\x43\xC9\x06\x48\xC8\x21\xCC\xC3\x8A\xE5\x52\xAA\x9F\xDE\xBF\x53\xC8\x99\x5E\xC6\xCB\x6A\xBA\xB2\xE7\x55\xC0\xCE\x2E\xCF\x94\xCD\xA1\xFF\xAA\xE5\xD4\xD5\x35\x2F\xB8\xEA\xDA\x8C\x1D\xDC\xE9\x6E\x01\x98\x29\x18\x23\xEA\x73\xFC\x50\xDB\x51\xCA\xDC\xAF\xFF\xB8\xCF\x5F\xDE\xD1\xDE\xDC\xA2\x9C\xBD\xCB\x96\xDF\xAB\xE0\xD8\x37\x06\xA3\x88\xD4\xDA\xEA\xD4\x4C\xE0\xAF\xDF\x60\xE2\x50\xAA\xE3\xE4\xA6\xA8\xF9\xDF\xDD\xDC\x9D\xDD\x18\xFF\xD4\xC8\x82\xC8\x26\xEF\x43\x86\xE1\x1B\xED\xD2\x9A\x11\x00\x80\x88\x0E\xFF\xB2\xC4\xC3\x45\xE3\x3B\xBF\xDE\xE4\x28\xEA\xE7\xDD\x04\x27\x6F\x94\xEE\xE0\x98\x1E\xE4\xC7\xB6\x83\x21\x90\x45\xB5\xE5\x91\x7A\xE2\x90\xD4\x9B\xF2\x21\xA7\xE6\xE8\xDD\x44\xC5\xDC\x42\x2A\xFA\xED\xD3\xD9\xED\xD2\xEB\xCD\xEE\xBB\xF0\xED\xD2\x61\xF3\xDD\xDE\x77\x90\xE8\x10\x77\xEF\xDF\xD0\xF8\xED\xA2\xC1\x9E\xEC\x41\x00\xFF\xF6\x1F\x47\xE4\xBA\x5F\xA6\xF3\x32\x89\xF0\xE2\xD0\x93\xE4\x2A\x34\xBF\xDD\xD2\x8C\x26\xDA\xD7\xFF\x51\x66\x08\x38\xFA\xB7\xD6\xF8\x37\x18\xEF\x2B\xF2\x03\x37\x6E\x22\xEB\xED\x90\xDE\xFE\xCA\x02\x18\x28\xFF\xDE\xFE\xCE\xFA\x32\x0F\x00\x23\xEF\xE7\xC5\xE0\xFE\xC9\xA8\x8C\xCD\xAA\xFD\x08\x38\xFF\xA4\x89\xB9\xF3\x28\xBC\x84\xC6\x56\x30\x44\x8A\x47\x4C\xF6\x70\x20\xA4\x70\x10\xB4\x63\x64\xFE\x74\x07\xA1\x77\x45\xFB\x72\x36\x47\x27\x58\xC8\x11\x7F\x08\x14\x81\x21\x6C\x7F\x85\x4B\x80\xF9\x62\x80\x43\x4F\x58\x1C\x68\x1C\x40\x62\x81\x22\x6B\x80\x90\x73\x10\x0E\x8F\x58\xE6\x7E\x69\xD8\x74\x10\xDA\x7C\x77\xFD\x7B\x43\x74\x04\x81\x04\x14\x81\x1C\x85\x7C\xBA\x1E\x03\x29\x82\x6C\x1A\x72\x43\x7C\x7B\x80\x07\x81\x48\x0E\x86\x70\xBE\x70\x75\x16\x08\x11\x45\x81\x46\x50\x73\x62\x0B\x80\x7E\x02\x17\x37\x35\x8B\x76\x43\x8C\x7D\x6E\x08\x7F\x04\x1A\x7F\x49\x8B\x80\x3B\x86\x82\x20\x0D\x7A\xAC\x27\x76\xE9\x6B\x62\x59\x60\x20\x54\x83\x10\xFA\x70\x63\x2F\x82\x45\x00\x8A\x85\x37\x61\x86\x4B\x60\x86\x5A\x64\x07\x3F\x8D\x4B\x30\x6B\x80\x0D\x8B\x85\x58\x6F\x86\x3E\x05\x82\x41\x67\x79\xB9\x18\x39\x08\x1E\x87\x96\x7C\x26\x98\x79\x81\x30\x81\x87\x02\x15\x83\x35\x7A\x87\x82\x4A\x72\x32\x83\x10\x16\x8A\x72\x2E\x0B\x80\x69\x87\x88\x76\x85\x73\x37\x55\x68\x63\x82\x10\xFA\x75\x68\x4A\x80\x83\x93\x80\x00\x35\x85\x68\x3E\x07\x89\x6E\x56\x88\x90\x4E\x56\x91\x80\x83\x75\x86\x54\x6E\x5B\x45\x29\x42\x87\x5E\x4B\x62\x5E\x44\x64\x68\x48\x10\xB5\x8A\x46\x45\x4D\x46\x6F\x4F\x3D\xC0\x54\x47\x7F\x59\x45\xC4\x5E\x1A\x09\x80\x5B\xF3\x52\x48\x51\x55\x03\xB7\x62\x10\xB9\x60\x5D\x95\x6B\x75\x0F\x53\x7B\xC0\x65\x7B\xF2\x67\x60\xA1\x6E\x51\x6C\x57\x6C\xE3\x5D\x60\x6E\x50\x61\xCE\x8B\x6A\x14\x6A\x57\x85\x70\x50\x19\x60\x58\xD3\x6F\x81\xBC\x11\x26\x17\x84\x64\x8D\x58\x10\xEB\x8D\x81\xC8\x17\x7C\xE9\x5A\x59\xA9\x55\x59\x97\x5C\x04\xBD\x83\x5A\x0D\x70\x39\x0F\x71\x71\x92\x58\x5A\xAF\x45\x5A\xA8\x47\x8F\xA9\x5F\x57\xAB\x59\x83\x79\x7A\x74\xEB\x7E\x69\x2E\x04\x03\xC2\x73\x10\xC4\x72\x78\xB2\x75\x78\x0C\x7C\x7C\xFC\x80\x02\xCF\x7D\x78\x0D\x7E\x67\xD3\x74\x1C\x4B\x72\x85\xA6\x8B\x7D\x5D\x88\x7A\x34\x0A\x7A\x04\x1C\x7A\x20\x90\x65\xBF\x2C\x76\x84\x71\x51\x5E\x70\x6F\xD2\x81\x76\x22\x04\x77\x65\x71\x92\x51\x61\x8C\x02\x1A\x18\x77\x8A\x27\xC5\x89\x93\xC0\x42\x03\xB8\x58\x10\x3F\x98\x45\x6C\x84\x69\x6E\x4E\x5B\x49\x32\x90\xC2\x53\x94\x74\x00\x04\x8A\x81\x88\x3E\x6B\x72\x0C\x1E\x26\x4E\x93\x64\x33\x01\x73\x04\x13\x73\x53\x9B\x64\x6D\x47\x73\x52\x80\x74\x3C\x7F\x4A\x3C\x9B\x65\x20\x0D\x65\x6F\x0F\x65\xDF\x4B\x7F\x44\x75\x48\x46\x77\x47\x48\x79\x1F\x7B\x42\x10\x7D\x4C\x1E\x40\x29\x45\xE1\x24\x3F\x5A\x21\x5F\x81\x5C\x29\x00\x2F\x1B\x1C\x04\x12\x02\x26\x8E\x74\x0D\x33\x88\x5F\x1B\x1E\x0E\x97\xF7\x16\x90\x15\x5A\x88\xFF\x6F\x1B\x20\x06\x98\xEE\x11\x85\x34\x9F\x2B\x21\x80\x75\xBF\x14\x3B\xDE\x2E\x1E\x6E\x84\x25\x86\x5A\x5B\xBF\x1C\x3F\x97\x96\x1E\x4D\x9A\x72\x8F\x4A\x72\xBF\x16\x02\x8E\x96\x1E\xA4\x80\x4F\x73\x3B\x49\xBF\x18\x02\xA7\x95\x1E\x10\x0F\x41\x09\x11\x1C\xBF\x1C\x19\x75\x97\x9B\xB8\x9B\x1C\xC1\x17\x80\x6C\x39\x9B\x00\x0C\x19\xB6\x96\x58\x3E\x16\x25\xF2\x8F\x1B\x6F\x90\x00\x71\x91\x06\x92\x11\x1C\x9C\x12\x9B\xBE\x9F\x9B\xCF\x9F\x3C\xCF\x34\x97\x5C\x45\x9D\xAE\x5E\x45\xCC\x15\x10\xBD\x96\x2C\xB7\x9C\x19\x3F\x94\x10\xCE\x9E\x9B\x73\x9E\x45\xC6\x96\x9D\x82\x49\x45\xC7\x9F\x9D", +"\xCF\x97\x9C\xC9\x91\x9E\xD1\x9D\x5A\xF0\x98\x53\xAC\x9F\x9E\xBA\x94\x12\x14\x34\x9F\xD4\x29\x9D\xFF\x0B\x9D\x9E\x15\x9B\x11\x80\x36\xE6\x92\x9D\xCF\x99\x9A\x93\x4B\x9D\xBF\x1F\x48\x87\x6D\x4D\x07\xA8\x97\x4D\x5F\x9C\xFA\x97\x9C\x04\x28\x9F\xCB\x94\x12\xF9\x15\x49\xB8\x9C\x9F\xFF\x93\xA0\x0C\xA0\x20\x9E\x1A\x9E\xBE\x94\xA0\xAC\x9A\x9F\x95\x49\x1F\xB8\x9E\x9E\x40\x21\x9D\x05\x8F\x25\x1D\xA8\x9F\x20\xA1\x22\xC1\x9D\x3A\xD1\x14\x9C\xA8\x5E\x2F\x11\x87\x81\xFA\x9C\x38\x24\xA7\x9B\x26\xA9\xA1\x1F\xAB\xA1\x2A\xA7\x5B\x2C\xA8\x4B\x85\x6F\xA2\x31\xA5\xA4\xA2\x54\x07\x34\xA6\x36\x61\x48\x58\xFA\x9C\x44\x39\xA5\x97\x3B\xAA\xA4\xEF\x99\xA2\xB9\x1B\xA2\xF4\x9D\xA2\x65\x04\xA4\xC3\x96\xA4\xC5\x9C\xA3\x9F\x1D\x4B\x4C\xA1\x1C\x34\x66\x72\x25\xAE\xA5\xFD\x97\x9B\x54\xA2\x58\x40\xA7\xA5\x42\xAE\x56\x5A\xAC\x3A\x5C\xA3\xA3\x9F\x25\x5C\xE7\x9A\x94\xFA\x9C\x9B\xF8\x91\xA5\xD0\x3C\xA6\x6A\x6B\x61\x6B\xA3\xA5\x6D\xA0\x4F\x6F\xA1\x1F\x86\x57\xA4\xE5\x9F\x8A\xD7\x99\x24\xFA\x9D\x88\x37\x99\xA7\x66\xA1\xA4\x7D\xAD\x54\x56\xA0\xA8\x4B\x53\xA4\xB7\x9A\x2C\x5D\xA2\xA5\xCF\x37\x81\x12\xA3\x9B\x24\x11\x82\xD1\x90\x9C\xB7\x91\x82\x8C\x60\x8E\x65\x0B\xA0\x91\xAB\x97\x83\x1C\x9C\x08\x9F\x9E\x83\xA4\x2D\x82\x98\x1C\x49\xAB\xA7\x22\x81\x20\xC1\x1B\x9D\xC5\x2E\x9F\x0C\x1E\xA1\x00\x0E\x9E\xB8\x91\xAB\xBC\x13\xAB\x9B\xA8\x58\xE9\x98\x9F\x80\x9E\xAB\x90\xA1\x9F\x85\x65\x97\xFA\x9C\x19\x34\x68\x9B\xAF\xAB\x29\x9B\x9A\x94\xA8\xA1\x9F\xBA\x5F\x0F\xEE\x9B\x9F\xF6\x31\x2E\xDE\x98\x11\xC8\xA5\x97\x61\x2C\x99\x73\xA2\x8C\xAE\x5A\x94\xC5\xAC\xA7\xD6\xAA\x94\xDF\xA4\xA9\xCA\xAE\x56\xDA\xA0\x48\xDD\x98\x11\x27\x0E\xAD\xF8\x91\xAE\xD4\xA3\xAE\x8D\xA5\xAE\x6F\x87\x9C\xF3\xA8\xAE\x74\xA1\x96\x74\x06\xA0\xC2\x90\xA7\x64\x96\x26\xBF\x11\x9A\x7C\x81\x20\xDB\x97\x80\xBA\xA1\x67\xF4\xA4\x9F\xF6\xAF\x86\xD5\xAF\xAF\xBA\x57\x9C\x0C\xB8\xA6\xB8\x4A\x5B\x02\xB0\xA3\x5B\xA5\xB0\x73\x07\xB0\x38\x29\x95\xB9\x12\xA1\x37\xA0\x7F\xF8\x92\xAA\x75\x9D\x33\x10\x53\xB1\xE4\xA6\x8C\x81\x51\x2E\xFA\x96\x72\x1A\x7D\xA9\x34\xB7\x9B\xFA\x95\x2C\x4C\x89\x9B\x18\x4E\x74\xF8\x98\xB0\x82\x83\xB2\x13\xA6\x14\x15\xA7\xB2\x5E\xA7\xB1\x75\x9E\xB3\x4F\x9B\xAA\x24\x13\xA6\xF8\x98\xA1\xF0\xA4\x9F\x48\xB0\x20\xAF\xA8\xA9\x72\xA3\x34\x2D\xB0\xB0\xF9\x91\x1C\x04\x23\xB3\x24\xB1\x1C\x26\x77\xA6\xF8\x95\xB2\x0C\x19\x89\xB9\x9E\xB4\x15\x89\xAC\xFF\xAA\x4B\xAF\xAA\xB2\x9A\x25\x8C\x04\x17\x49\x8B\x9A\xB4\x46\x1C\x19\x7E\x81\xAA\xF5\xA6\x58\xBA\x4C\xB2\xF9\xAE\xB2\x4D\x58\xAD\x24\x18\xAB\xF1\xAB\xAB\x0F\xBF\x9E\x7A\x9F\x25\x7A\xBD\x38\xF4\x5D\x54\xE7\xAC\xAE\x69\xB1\x58\xEB\xA8\xA2\x81\xA3\x49\xEF\xA9\x7D\x81\xB8\x10\xFD\xA0\x42\x77\xB0\xA3\x79\xB8\xAF\x88\xBC\xB7\x00\x2C\xAF\x68\xB7\xB5\x6A\xB3\xAA\x2C\x72\x10\x45\x7F\xB2\x38\x24\x10\x91\x79\xB0\x93\xBC\x82\x95\xBC\x6D\x83\xB1\x9D\x85\xB0\xB4\x56\xBB\xB7\xFB\x76\xB1\xA1\xB6\xBB\xA3\xB5\x97\x21\x87\xBA\x0D\xA9\xBA\x03\x1B\xBA\x3F\xB8\xA4\x61\xB1\x1C\x8C\x35\x01\x44\xBC\x10\x6B\xBB\xAD\x2B\xBD\xAA\x46\x38\x84\x52\x8C\xAC\xC1\x15\x49\x47\x85\xB3\x5D\xB6\x9F\x18\x17\x01\xC9\xBC\xB8\x2D\xB4\x9A\xC0\xBB\x63\x7B\x83\xBC\x0E\xA1\x1C\x9E\x18\x01\xD6\xB5\x9F\x46\x1C\x38\x64\xB7\xA1\x5E\xA8\xBC\xF4\x90\x99\x28\x98\x1B\xCB\xBC\x10\xC3\x27\xAA\x6E\xB3\x10\x70\xBE\x67\xB8\x9D\xA4\x18\x19\x01\xDB\xB4\x10\xAF\xA0\x24\x17\x9F\x1B\x88\x9E\x23\xD1\x9D\xAC\x18\x1A\x01\xFF\xBF\x9C\x93\x91\xBD\xCE\xB3\x10\xD5\x71\x99\x19\x2B\x9D\xAD\xBC\x79\xAF\xB3\x10\x97\xB0\x9E\xF8\x9D\xC0\x12\xCE\x06\xBF\x10\xBF\x58\x7F\x2B\xA0\xBF\xBE\xAD\xA7\x92\x21\xC8\x1B\x1B\xB5\xA4\x1D\xBB\x73\x65\x9F\xB1\xDF\xB7\x72\x2D\x73\xBC\x15\xC5\x7A\x17\xC4\xC3\x0C\x1F\xB8\xD9\x2C\xC1\xF1\xBE\xC1\x0F\xC2\x10\x11\xCB\xC3\xB8\xB4\xC2\xD4\x7D\x91\x1D\xC9\xC2\x5B\xAB\xC2\x55\x60\xB2\x0C\x12\xBC\x49\xB0\xB3\xAC\xAC\x10\x1B\x0B\xC0\xBE\x9A\x98\xFA\xB7\xBF\x55\x4E\x6F\x7E\x63\xC3\xDA\x98\x11\xEE\xBC\xAD\x5C\xC1\xBB\xCF\x94\xC5\x9E\x64\xC0\x3B\x9F\x6F\xC7\x9D\xC5\xD1\x95\xC0\xBA\x16\xC4\xF8\xB5\x8C\x18\x52\x28\x1F\xC5\xC2\x50\x7A\xC5\x8C\xA4\x2D\x9C\x15\xC7\x38\xC5\x2D\x62\xC2\x6C\x64\xCC\x66\x09\x92\x6C\xC7\x95\xC7\xB8\x9A\xC6\x65\x0C\xC6\x57\xCE\xC7\x00\x0F\xC6\xB6\x27\xB8\x38\x9B\xB9\xE7\xB2\xBD\x24\x1F\x1B\x1D\x0F\xC8\xD7", +"\xB2\xB4\x56\xC4\xC9\xC0\x11\xC9\x18\x1F\x01\x98\xC5\xC9\x35\x13\xA2\x52\xC0\x9D\xE0\xA5\xA8\x99\xA4\xAB\xC3\xA8\x22\xC6\xBC\xB9\xD0\xA8\x11\x53\xB4\xCA\x55\xB6\xCA\x94\x1B\xA4\xA8\xC3\x1B\xAA\xC5\xC3\xA2\xC1\x2E\x54\xBC\x2C\xC2\xA1\xCB\xB5\xA1\xB4\x35\x15\xC7\x4F\xAE\xC5\xCA\xB7\xA9\xAE\xCA\xCB\x8F\xA2\xCB\xBC\x1A\x9F\xBF\x11\x02\x9D\xCE\xC9\x83\x1A\xBE\xA1\xC3\xBF\x25\x23\x10\xCD\xB8\xC8\x6F\xB8\xC5\x63\xCE\xA9\x46\x1F\x1B\xB5\x8D\xCC\x4E\xC4\x12\x38\xBE\xCD\xD8\xBB\xCD\x18\x15\x02\xE2\xC5\xBC\x4B\xBF\xC2\xAB\xC3\xCC\xA3\xC0\xA3\x86\xAC\xB9\x38\x92\xAE\xCA\xC2\xAF\xE7\xCF\xCD\x46\x11\xCE\xF4\x9B\xB3\x0C\x19\xC1\x61\xC1\xB2\xDE\xB9\xC9\x96\xC6\xCD\xCF\x9A\xCF\x96\xBD\xB3\xFE\xC9\xB0\x72\xB5\x13\x4C\xB4\x9F\x66\xB4\x10\xFC\xC3\xC5\x07\xD3\xBC\xAD\xCE\xCE\xA5\xC4\xA7\x14\xB7\xAF\xF3\xC2\xB8\xF5\xC6\xB3\xC1\x13\xB4\xF9\xCE\xA5\xBC\xA8\x9B\x58\xA0\xD0\x9F\xC5\xCB\x75\x9D\xD0\x03\x11\xD2\x18\xB5\xA9\x6E\xA4\xCC\x14\xDF\xCA\x02\xA7\x17\xC8\xC6\xAB\x9F\xA6\xD2\xE1\x28\xD2\x02\x1A\xD2\x75\x98\xA5\x13\xD1\xA7\xC6\xCA\xA9\xBC\xC6\xA3\xC1\x1E\xA4\x4D\xB0\xD2\xB9\xBD\xB9\xF2\x9E\xA2\x2E\xDE\xD3\x86\xB7\xCC\xB5\xAA\x9F\x0B\xDF\x9E\x38\xD0\x00\x3A\xD1\x2E\x3C\xDB\xD4\x5B\xAF\xCE\xB5\xB8\xD4\xD7\xAB\x9B\x18\x16\xC8\xD4\x23\xD5\x55\xDD\x2D\x57\xDD\xCE\x4C\xD4\xBB\x2B\x46\x9E\x62\x4B\xA8\x36\xDD\x2D\x62\xD7\xD4\x38\x96\xA9\x66\xD9\xD5\x15\xDC\xCB\xA7\xC1\xAC\x1B\xD9\xD7\x98\xC0", +}; + + void XmlGetParserBuffer(vl::stream::MemoryStream& stream) + { + vl::stream::MemoryStream compressedStream; + for (vint i = 0; i < parserBufferRows; i++) + { + vint size = i == parserBufferRows - 1 ? parserBufferRemain : parserBufferBlock; + compressedStream.Write((void*)parserBuffer[i], size); + } + compressedStream.SeekFromBegin(0); + vl::stream::LzwDecoder decoder; + vl::stream::DecoderStream decoderStream(compressedStream, decoder); + vl::collections::Array buffer(65536); + while (true) + { + vl::vint size = decoderStream.Read(&buffer[0], 65536); + if (size == 0) break; + stream.Write(&buffer[0], size); + } + stream.SeekFromBegin(0); + } +/*********************************************************************** +Unescaping Function Foward Declarations +***********************************************************************/ + + extern void XmlMergeTextFragment(vl::collections::List>& value, const vl::collections::List& tokens); + extern void XmlUnescapeAttributeValue(vl::parsing::ParsingToken& value, const vl::collections::List& tokens); + extern void XmlUnescapeCData(vl::parsing::ParsingToken& value, const vl::collections::List& tokens); + extern void XmlUnescapeComment(vl::parsing::ParsingToken& value, const vl::collections::List& tokens); + +/*********************************************************************** +Parsing Tree Conversion Driver Implementation +***********************************************************************/ + + class XmlTreeConverter : public vl::parsing::ParsingTreeConverter + { + public: + using vl::parsing::ParsingTreeConverter::SetMember; + + void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) + { + } + + void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) + { + SetMember(tree->content, obj->GetMember(L"content"), tokens); + } + + void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) + { + if(SetMember(tree->content, obj->GetMember(L"content"), tokens)) + { + XmlUnescapeCData(tree->content, tokens); + } + } + + void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) + { + SetMember(tree->name, obj->GetMember(L"name"), tokens); + if(SetMember(tree->value, obj->GetMember(L"value"), tokens)) + { + XmlUnescapeAttributeValue(tree->value, tokens); + } + } + + void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) + { + if(SetMember(tree->content, obj->GetMember(L"content"), tokens)) + { + XmlUnescapeComment(tree->content, tokens); + } + } + + void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) + { + SetMember(tree->name, obj->GetMember(L"name"), tokens); + SetMember(tree->closingName, obj->GetMember(L"closingName"), tokens); + SetMember(tree->attributes, obj->GetMember(L"attributes"), tokens); + if(SetMember(tree->subNodes, obj->GetMember(L"subNodes"), tokens)) + { + XmlMergeTextFragment(tree->subNodes, tokens); + } + } + + void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) + { + SetMember(tree->name, obj->GetMember(L"name"), tokens); + SetMember(tree->attributes, obj->GetMember(L"attributes"), tokens); + } + + void Fill(vl::Ptr tree, vl::Ptr obj, const TokenList& tokens) + { + SetMember(tree->prologs, obj->GetMember(L"prologs"), tokens); + SetMember(tree->rootElement, obj->GetMember(L"rootElement"), tokens); + } + + vl::Ptr ConvertClass(vl::Ptr obj, const TokenList& tokens)override + { + if(obj->GetType()==L"Text") + { + vl::Ptr tree = new XmlText; + vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); + Fill(tree, obj, tokens); + Fill(tree.Cast(), obj, tokens); + return tree; + } + else if(obj->GetType()==L"CData") + { + vl::Ptr tree = new XmlCData; + vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); + Fill(tree, obj, tokens); + Fill(tree.Cast(), obj, tokens); + return tree; + } + else if(obj->GetType()==L"Attribute") + { + vl::Ptr tree = new XmlAttribute; + vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); + Fill(tree, obj, tokens); + Fill(tree.Cast(), obj, tokens); + return tree; + } + else if(obj->GetType()==L"Comment") + { + vl::Ptr tree = new XmlComment; + vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); + Fill(tree, obj, tokens); + Fill(tree.Cast(), obj, tokens); + return tree; + } + else if(obj->GetType()==L"Element") + { + vl::Ptr tree = new XmlElement; + vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); + Fill(tree, obj, tokens); + Fill(tree.Cast(), obj, tokens); + return tree; + } + else if(obj->GetType()==L"Instruction") + { + vl::Ptr tree = new XmlInstruction; + vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); + Fill(tree, obj, tokens); + Fill(tree.Cast(), obj, tokens); + return tree; + } + else if(obj->GetType()==L"Document") + { + vl::Ptr tree = new XmlDocument; + vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules()); + Fill(tree, obj, tokens); + Fill(tree.Cast(), obj, tokens); + return tree; + } + else + return 0; + } + }; + + vl::Ptr XmlConvertParsingTreeNode(vl::Ptr node, const vl::collections::List& tokens) + { + XmlTreeConverter converter; + vl::Ptr tree; + converter.SetMember(tree, node, tokens); + return tree; + } + +/*********************************************************************** +Parsing Tree Conversion Implementation +***********************************************************************/ + + vl::Ptr XmlText::Convert(vl::Ptr node, const vl::collections::List& tokens) + { + return XmlConvertParsingTreeNode(node, tokens).Cast(); + } + + vl::Ptr XmlCData::Convert(vl::Ptr node, const vl::collections::List& tokens) + { + return XmlConvertParsingTreeNode(node, tokens).Cast(); + } + + vl::Ptr XmlAttribute::Convert(vl::Ptr node, const vl::collections::List& tokens) + { + return XmlConvertParsingTreeNode(node, tokens).Cast(); + } + + vl::Ptr XmlComment::Convert(vl::Ptr node, const vl::collections::List& tokens) + { + return XmlConvertParsingTreeNode(node, tokens).Cast(); + } + + vl::Ptr XmlElement::Convert(vl::Ptr node, const vl::collections::List& tokens) + { + return XmlConvertParsingTreeNode(node, tokens).Cast(); + } + + vl::Ptr XmlInstruction::Convert(vl::Ptr node, const vl::collections::List& tokens) + { + return XmlConvertParsingTreeNode(node, tokens).Cast(); + } + + vl::Ptr XmlDocument::Convert(vl::Ptr node, const vl::collections::List& tokens) + { + return XmlConvertParsingTreeNode(node, tokens).Cast(); + } + +/*********************************************************************** +Parser Function +***********************************************************************/ + + vl::Ptr XmlParseDocumentAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex) + { + vl::parsing::tabling::ParsingState state(input, table, codeIndex); + state.Reset(L"XDocument"); + vl::Ptr parser=vl::parsing::tabling::CreateStrictParser(table); + vl::Ptr node=parser->Parse(state, errors); + return node; + } + + vl::Ptr XmlParseDocumentAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::vint codeIndex) + { + vl::collections::List> errors; + return XmlParseDocumentAsParsingTreeNode(input, table, errors, codeIndex); + } + + vl::Ptr XmlParseDocument(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex) + { + vl::parsing::tabling::ParsingState state(input, table, codeIndex); + state.Reset(L"XDocument"); + vl::Ptr parser=vl::parsing::tabling::CreateStrictParser(table); + vl::Ptr node=parser->Parse(state, errors); + if(node && errors.Count()==0) + { + return XmlConvertParsingTreeNode(node, state.GetTokens()).Cast(); + } + return 0; + } + + vl::Ptr XmlParseDocument(const vl::WString& input, vl::Ptr table, vl::vint codeIndex) + { + vl::collections::List> errors; + return XmlParseDocument(input, table, errors, codeIndex); + } + + vl::Ptr XmlParseElementAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex) + { + vl::parsing::tabling::ParsingState state(input, table, codeIndex); + state.Reset(L"XElement"); + vl::Ptr parser=vl::parsing::tabling::CreateStrictParser(table); + vl::Ptr node=parser->Parse(state, errors); + return node; + } + + vl::Ptr XmlParseElementAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::vint codeIndex) + { + vl::collections::List> errors; + return XmlParseElementAsParsingTreeNode(input, table, errors, codeIndex); + } + + vl::Ptr XmlParseElement(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex) + { + vl::parsing::tabling::ParsingState state(input, table, codeIndex); + state.Reset(L"XElement"); + vl::Ptr parser=vl::parsing::tabling::CreateStrictParser(table); + vl::Ptr node=parser->Parse(state, errors); + if(node && errors.Count()==0) + { + return XmlConvertParsingTreeNode(node, state.GetTokens()).Cast(); + } + return 0; + } + + vl::Ptr XmlParseElement(const vl::WString& input, vl::Ptr table, vl::vint codeIndex) + { + vl::collections::List> errors; + return XmlParseElement(input, table, errors, codeIndex); + } + +/*********************************************************************** +Table Generation +***********************************************************************/ + + vl::Ptr XmlLoadTable() + { + vl::stream::MemoryStream stream; + XmlGetParserBuffer(stream); + vl::Ptr table=new vl::parsing::tabling::ParsingTable(stream); + table->Initialize(); + return table; + } + + } + } +} + + +/*********************************************************************** +.\REFLECTION\GUITYPEDESCRIPTORPREDEFINED.CPP +***********************************************************************/ + +namespace vl +{ + using namespace collections; + + namespace reflection + { + namespace description + { + +/*********************************************************************** +IValueEnumerable +***********************************************************************/ + + Ptr IValueEnumerable::Create(collections::LazyList values) + { + Ptr> enumerable = new LazyList(values); + return new ValueEnumerableWrapper>>(enumerable); + } + +/*********************************************************************** +IValueList +***********************************************************************/ + + Ptr IValueList::Create() + { + return Create(LazyList()); + } + + Ptr IValueList::Create(Ptr values) + { + return Create(GetLazyList(values)); + } + + Ptr IValueList::Create(collections::LazyList values) + { + Ptr> list = new List; + CopyFrom(*list.Obj(), values); + return new ValueListWrapper>>(list); + } + +/*********************************************************************** +IObservableList +***********************************************************************/ + + class ReversedObservableList : public ObservableListBase + { + protected: + + void NotifyUpdateInternal(vint start, vint count, vint newCount)override + { + if (observableList) + { + observableList->ItemChanged(start, count, newCount); + } + } + public: + IValueObservableList* observableList = nullptr; + }; + + Ptr IValueObservableList::Create() + { + return Create(LazyList()); + } + + Ptr IValueObservableList::Create(Ptr values) + { + return Create(GetLazyList(values)); + } + + Ptr IValueObservableList::Create(collections::LazyList values) + { + auto list = MakePtr(); + CopyFrom(*list.Obj(), values); + auto wrapper = MakePtr>>(list); + list->observableList = wrapper.Obj(); + return wrapper; + } + +/*********************************************************************** +IValueDictionary +***********************************************************************/ + + Ptr IValueDictionary::Create() + { + Ptr> dictionary = new Dictionary; + return new ValueDictionaryWrapper>>(dictionary); + } + + Ptr IValueDictionary::Create(Ptr values) + { + Ptr> dictionary = new Dictionary; + CopyFrom(*dictionary.Obj(), GetLazyList(values)); + return new ValueDictionaryWrapper>>(dictionary); + } + + Ptr IValueDictionary::Create(collections::LazyList> values) + { + Ptr> dictionary = new Dictionary; + CopyFrom(*dictionary.Obj(), values); + return new ValueDictionaryWrapper>>(dictionary); + } + +/*********************************************************************** +IValueException +***********************************************************************/ + + class DefaultValueException : public Object, public IValueException + { + protected: + WString message; + + public: + DefaultValueException(const WString& _message) + :message(_message) + { + } + +#pragma push_macro("GetMessage") +#if defined GetMessage +#undef GetMessage +#endif + WString GetMessage()override + { + return message; + } +#pragma pop_macro("GetMessage") + + bool GetFatal()override + { + return false; + } + + Ptr GetCallStack()override + { + return nullptr; + } + }; + + Ptr IValueException::Create(const WString& message) + { + return new DefaultValueException(message); + } + +/*********************************************************************** +CoroutineResult +***********************************************************************/ + + Value CoroutineResult::GetResult() + { + return result; + } + + void CoroutineResult::SetResult(const Value& value) + { + result = value; + } + + Ptr CoroutineResult::GetFailure() + { + return failure; + } + + void CoroutineResult::SetFailure(Ptr value) + { + failure = value; + } + +/*********************************************************************** +EnumerableCoroutine +***********************************************************************/ + + class CoroutineEnumerator : public Object, public virtual EnumerableCoroutine::IImpl, public Description + { + protected: + EnumerableCoroutine::Creator creator; + Ptr coroutine; + Value current; + vint index = -1; + Ptr joining; + + public: + CoroutineEnumerator(const EnumerableCoroutine::Creator& _creator) + :creator(_creator) + { + } + + Value GetCurrent()override + { + return current; + } + + vint GetIndex()override + { + return index; + } + + bool Next()override + { + if (!coroutine) + { + coroutine = creator(this); + } + + while (coroutine->GetStatus() == CoroutineStatus::Waiting) + { + if (joining) + { + if (joining->Next()) + { + current = joining->GetCurrent(); + index++; + return true; + } + else + { + joining = nullptr; + } + } + + coroutine->Resume(true, nullptr); + if (coroutine->GetStatus() != CoroutineStatus::Waiting) + { + break; + } + + if (!joining) + { + index++; + return true; + } + } + return false; + } + + void OnYield(const Value& value)override + { + current = value; + joining = nullptr; + } + + void OnJoin(Ptr value)override + { + if (!value) + { + throw Exception(L"Cannot join a null collection."); + } + current = Value(); + joining = value->CreateEnumerator(); + } + }; + + class CoroutineEnumerable : public Object, public virtual IValueEnumerable, public Description + { + protected: + EnumerableCoroutine::Creator creator; + + public: + CoroutineEnumerable(const EnumerableCoroutine::Creator& _creator) + :creator(_creator) + { + } + + Ptr CreateEnumerator()override + { + return new CoroutineEnumerator(creator); + } + }; + + void EnumerableCoroutine::YieldAndPause(IImpl* impl, const Value& value) + { + impl->OnYield(value); + } + + void EnumerableCoroutine::JoinAndPause(IImpl* impl, Ptr value) + { + impl->OnJoin(value); + } + + void EnumerableCoroutine::ReturnAndExit(IImpl* impl) + { + } + + Ptr EnumerableCoroutine::Create(const Creator& creator) + { + return new CoroutineEnumerable(creator); + } + +/*********************************************************************** +IAsync +***********************************************************************/ + + class DelayAsync : public Object, public virtual IAsync, public Description + { + protected: + SpinLock lock; + vint milliseconds; + AsyncStatus status = AsyncStatus::Ready; + + public: + DelayAsync(vint _milliseconds) + :milliseconds(_milliseconds) + { + } + + AsyncStatus GetStatus()override + { + return status; + } + + bool Execute(const Func)>& _callback)override + { + SPIN_LOCK(lock) + { + if (status != AsyncStatus::Ready) return false; + status = AsyncStatus::Executing; + IAsyncScheduler::GetSchedulerForCurrentThread()->DelayExecute([async = Ptr(this), callback = _callback]() + { + if (callback) + { + callback(nullptr); + } + }, milliseconds); + } + return true; + } + }; + + Ptr IAsync::Delay(vint milliseconds) + { + return new DelayAsync(milliseconds); + } + +/*********************************************************************** +IFuture +***********************************************************************/ + + class FutureAndPromiseAsync : public virtual IFuture, public virtual IPromise, public Description + { + public: + SpinLock lock; + AsyncStatus status = AsyncStatus::Ready; + Ptr cr; + Func)> callback; + + void ExecuteCallbackAndClear() + { + status = AsyncStatus::Stopped; + if (callback) + { + callback(cr); + } + cr = nullptr; + callback = {}; + } + + template + bool Send(F f) + { + SPIN_LOCK(lock) + { + if (status == AsyncStatus::Stopped || cr) return false; + cr = MakePtr(); + f(); + if (status == AsyncStatus::Executing) + { + ExecuteCallbackAndClear(); + } + } + return true; + } + + AsyncStatus GetStatus()override + { + return status; + } + + bool Execute(const Func)>& _callback)override + { + SPIN_LOCK(lock) + { + if (status != AsyncStatus::Ready) return false; + callback = _callback; + if (cr) + { + ExecuteCallbackAndClear(); + } + else + { + status = AsyncStatus::Executing; + } + } + return true; + } + + Ptr GetPromise()override + { + return this; + } + + bool SendResult(const Value& result)override + { + return Send([=]() + { + cr->SetResult(result); + }); + } + + bool SendFailure(Ptr failure)override + { + return Send([=]() + { + cr->SetFailure(failure); + }); + } + }; + + Ptr IFuture::Create() + { + return new FutureAndPromiseAsync(); + } + +/*********************************************************************** +IAsyncScheduler +***********************************************************************/ + + class AsyncSchedulerMap + { + public: + Dictionary> schedulers; + Ptr defaultScheduler; + }; + + AsyncSchedulerMap* asyncSchedulerMap = nullptr; + SpinLock asyncSchedulerLock; + +#define ENSURE_ASYNC_SCHEDULER_MAP\ + if (!asyncSchedulerMap) asyncSchedulerMap = new AsyncSchedulerMap; + +#define DISPOSE_ASYNC_SCHEDULER_MAP_IF_NECESSARY\ + if (asyncSchedulerMap->schedulers.Count() == 0 && !asyncSchedulerMap->defaultScheduler)\ + {\ + delete asyncSchedulerMap;\ + asyncSchedulerMap = nullptr;\ + }\ + + void IAsyncScheduler::RegisterDefaultScheduler(Ptr scheduler) + { + SPIN_LOCK(asyncSchedulerLock) + { + ENSURE_ASYNC_SCHEDULER_MAP + CHECK_ERROR(!asyncSchedulerMap->defaultScheduler, L"IAsyncScheduler::RegisterDefaultScheduler()#A default scheduler has already been registered."); + asyncSchedulerMap->defaultScheduler = scheduler; + } + } + + void IAsyncScheduler::RegisterSchedulerForCurrentThread(Ptr scheduler) + { + SPIN_LOCK(asyncSchedulerLock) + { + ENSURE_ASYNC_SCHEDULER_MAP + CHECK_ERROR(!asyncSchedulerMap->schedulers.Keys().Contains(Thread::GetCurrentThreadId()), L"IAsyncScheduler::RegisterDefaultScheduler()#A scheduler for this thread has already been registered."); + asyncSchedulerMap->schedulers.Add(Thread::GetCurrentThreadId(), scheduler); + } + } + + Ptr IAsyncScheduler::UnregisterDefaultScheduler() + { + Ptr scheduler; + SPIN_LOCK(asyncSchedulerLock) + { + if (asyncSchedulerMap) + { + scheduler = asyncSchedulerMap->defaultScheduler; + asyncSchedulerMap->defaultScheduler = nullptr; + DISPOSE_ASYNC_SCHEDULER_MAP_IF_NECESSARY + } + } + return scheduler; + } + + Ptr IAsyncScheduler::UnregisterSchedulerForCurrentThread() + { + Ptr scheduler; + SPIN_LOCK(asyncSchedulerLock) + { + if (asyncSchedulerMap) + { + vint index = asyncSchedulerMap->schedulers.Keys().IndexOf(Thread::GetCurrentThreadId()); + if (index != -1) + { + scheduler = asyncSchedulerMap->schedulers.Values()[index]; + asyncSchedulerMap->schedulers.Remove(Thread::GetCurrentThreadId()); + } + DISPOSE_ASYNC_SCHEDULER_MAP_IF_NECESSARY + } + } + return scheduler; + } + +#undef ENSURE_ASYNC_SCHEDULER_MAP +#undef DISPOSE_ASYNC_SCHEDULER_MAP_IF_NECESSARY + + Ptr IAsyncScheduler::GetSchedulerForCurrentThread() + { + Ptr scheduler; + SPIN_LOCK(asyncSchedulerLock) + { + CHECK_ERROR(asyncSchedulerMap != nullptr, L"IAsyncScheduler::GetSchedulerForCurrentThread()#There is no scheduler registered for the current thread."); + vint index = asyncSchedulerMap->schedulers.Keys().IndexOf(Thread::GetCurrentThreadId()); + if (index != -1) + { + scheduler = asyncSchedulerMap->schedulers.Values()[index]; + } + else if (asyncSchedulerMap->defaultScheduler) + { + scheduler = asyncSchedulerMap->defaultScheduler; + } + else + { + CHECK_FAIL(L"IAsyncScheduler::GetSchedulerForCurrentThread()#There is no scheduler registered for the current thread."); + } + } + return scheduler; + } + +/*********************************************************************** +AsyncCoroutine +***********************************************************************/ + + class CoroutineAsync : public Object, public virtual AsyncCoroutine::IImpl, public Description + { + protected: + Ptr coroutine; + AsyncCoroutine::Creator creator; + Ptr scheduler; + Func)> callback; + Value result; + + public: + CoroutineAsync(AsyncCoroutine::Creator _creator) + :creator(_creator) + { + } + + AsyncStatus GetStatus()override + { + if (!coroutine) + { + return AsyncStatus::Ready; + } + else if (coroutine->GetStatus() != CoroutineStatus::Stopped) + { + return AsyncStatus::Executing; + } + else + { + return AsyncStatus::Stopped; + } + } + + bool Execute(const Func)>& _callback)override + { + if (coroutine) return false; + scheduler = IAsyncScheduler::GetSchedulerForCurrentThread(); + callback = _callback; + coroutine = creator(this); + OnContinue(nullptr); + return true; + } + + Ptr GetScheduler()override + { + return scheduler; + } + + void OnContinue(Ptr output)override + { + scheduler->Execute([async = Ptr(this), output]() + { + async->coroutine->Resume(false, output); + if (async->coroutine->GetStatus() == CoroutineStatus::Stopped && async->callback) + { + auto result = MakePtr(); + if (async->coroutine->GetFailure()) + { + result->SetFailure(async->coroutine->GetFailure()); + } + else + { + result->SetResult(async->result); + } + async->callback(result); + } + }); + } + + void OnReturn(const Value& value)override + { + result = value; + } + }; + + void AsyncCoroutine::AwaitAndRead(IImpl* impl, Ptr value) + { + value->Execute([async = Ptr(impl)](auto output) + { + async->OnContinue(output); + }); + } + + void AsyncCoroutine::ReturnAndExit(IImpl* impl, const Value& value) + { + impl->OnReturn(value); + } + + Ptr AsyncCoroutine::Create(const Creator& creator) + { + return new CoroutineAsync(creator); + } + void AsyncCoroutine::CreateAndRun(const Creator& creator) + { + MakePtr(creator)->Execute( + [](Ptr cr) + { + if (cr->GetFailure()) + { +#pragma push_macro("GetMessage") +#if defined GetMessage +#undef GetMessage +#endif + throw Exception(cr->GetFailure()->GetMessage()); +#pragma pop_macro("GetMessage") + } + }); + } + +/*********************************************************************** +Libraries +***********************************************************************/ + + namespace system_sys + { + class ReverseEnumerable : public Object, public IValueEnumerable + { + protected: + Ptr list; + + class Enumerator : public Object, public IValueEnumerator + { + protected: + Ptr list; + vint index; + + public: + Enumerator(Ptr _list) + :list(_list), index(_list->GetCount()) + { + } + + Value GetCurrent() + { + return list->Get(index); + } + + vint GetIndex() + { + return list->GetCount() - 1 - index; + } + + bool Next() + { + if (index <= 0) return false; + index--; + return true; + } + }; + + public: + ReverseEnumerable(Ptr _list) + :list(_list) + { + } + + Ptr CreateEnumerator()override + { + return MakePtr(list); + } + }; + } + + Ptr Sys::ReverseEnumerable(Ptr value) + { + auto list = value.Cast(); + if (!list) + { + list = IValueList::Create(GetLazyList(value)); + } + return new system_sys::ReverseEnumerable(list); + } + +#define DEFINE_COMPARE(TYPE)\ + vint Sys::Compare(TYPE a, TYPE b)\ + {\ + auto result = TypedValueSerializerProvider::Compare(a, b);\ + switch (result)\ + {\ + case IBoxedValue::Smaller: return -1;\ + case IBoxedValue::Greater: return 1;\ + case IBoxedValue::Equal: return 0;\ + default:\ + CHECK_FAIL(L"Unexpected compare result.");\ + }\ + }\ + + REFLECTION_PREDEFINED_PRIMITIVE_TYPES(DEFINE_COMPARE) + DEFINE_COMPARE(DateTime) +#undef DEFINE_COMPARE + +#define DEFINE_MINMAX(TYPE)\ + TYPE Math::Min(TYPE a, TYPE b)\ + {\ + return Sys::Compare(a, b) < 0 ? a : b;\ + }\ + TYPE Math::Max(TYPE a, TYPE b)\ + {\ + return Sys::Compare(a, b) > 0 ? a : b;\ + }\ + + REFLECTION_PREDEFINED_PRIMITIVE_TYPES(DEFINE_MINMAX) + DEFINE_MINMAX(DateTime) +#undef DEFINE_MINMAX + } + } +} + + +/*********************************************************************** +.\THREADING.CPP +***********************************************************************/ +#ifdef VCZH_MSVC + +namespace vl +{ + using namespace threading_internal; + using namespace collections; + +/*********************************************************************** +WaitableObject +***********************************************************************/ + + namespace threading_internal + { + struct WaitableData + { + HANDLE handle; + + WaitableData(HANDLE _handle) + :handle(_handle) + { + } + }; + } + + WaitableObject::WaitableObject() + :waitableData(0) + { + } + + void WaitableObject::SetData(threading_internal::WaitableData* data) + { + waitableData=data; + } + + bool WaitableObject::IsCreated() + { + return waitableData!=0; + } + + bool WaitableObject::Wait() + { + return WaitForTime(INFINITE); + } + + bool WaitableObject::WaitForTime(vint ms) + { + if(IsCreated()) + { + if(WaitForSingleObject(waitableData->handle, (DWORD)ms)==WAIT_OBJECT_0) + { + return true; + } + } + return false; + } + + bool WaitableObject::WaitAll(WaitableObject** objects, vint count) + { + Array handles(count); + for(vint i=0;iwaitableData->handle; + } + DWORD result=WaitForMultipleObjects((DWORD)count, &handles[0], TRUE, INFINITE); + return result==WAIT_OBJECT_0 || result==WAIT_ABANDONED_0; + + } + + bool WaitableObject::WaitAllForTime(WaitableObject** objects, vint count, vint ms) + { + Array handles(count); + for(vint i=0;iwaitableData->handle; + } + DWORD result=WaitForMultipleObjects((DWORD)count, &handles[0], TRUE, (DWORD)ms); + return result==WAIT_OBJECT_0 || result==WAIT_ABANDONED_0; + } + + vint WaitableObject::WaitAny(WaitableObject** objects, vint count, bool* abandoned) + { + Array handles(count); + for(vint i=0;iwaitableData->handle; + } + DWORD result=WaitForMultipleObjects((DWORD)count, &handles[0], FALSE, INFINITE); + if(WAIT_OBJECT_0 <= result && result handles(count); + for(vint i=0;iwaitableData->handle; + } + DWORD result=WaitForMultipleObjects((DWORD)count, &handles[0], FALSE, (DWORD)ms); + if(WAIT_OBJECT_0 <= result && resultdeleteAfterStopped; + ThreadLocalStorage::FixStorages(); + try + { + procedure(this, argument); + threadState=Thread::Stopped; + ThreadLocalStorage::ClearStorages(); + } + catch (...) + { + ThreadLocalStorage::ClearStorages(); + throw; + } + if(deleteAfterStopped) + { + delete this; + } + } + public: + ProceduredThread(Thread::ThreadProcedure _procedure, void* _argument, bool _deleteAfterStopped) + :procedure(_procedure) + ,argument(_argument) + ,deleteAfterStopped(_deleteAfterStopped) + { + } + }; + + class LambdaThread : public Thread + { + private: + Func procedure; + bool deleteAfterStopped; + + protected: + void Run() + { + bool deleteAfterStopped = this->deleteAfterStopped; + ThreadLocalStorage::FixStorages(); + try + { + procedure(); + threadState=Thread::Stopped; + ThreadLocalStorage::ClearStorages(); + } + catch (...) + { + ThreadLocalStorage::ClearStorages(); + throw; + } + if(deleteAfterStopped) + { + delete this; + } + } + public: + LambdaThread(const Func& _procedure, bool _deleteAfterStopped) + :procedure(_procedure) + ,deleteAfterStopped(_deleteAfterStopped) + { + } + }; + } + + void InternalThreadProc(Thread* thread) + { + thread->Run(); + } + + DWORD WINAPI InternalThreadProcWrapper(LPVOID lpParameter) + { + InternalThreadProc((Thread*)lpParameter); + return 0; + } + + Thread::Thread() + { + internalData=new ThreadData; + internalData->handle=CreateThread(NULL, 0, InternalThreadProcWrapper, this, CREATE_SUSPENDED, &internalData->id); + threadState=Thread::NotStarted; + SetData(internalData); + } + + Thread::~Thread() + { + if (internalData) + { + Stop(); + CloseHandle(internalData->handle); + delete internalData; + } + } + + Thread* Thread::CreateAndStart(ThreadProcedure procedure, void* argument, bool deleteAfterStopped) + { + if(procedure) + { + Thread* thread=new ProceduredThread(procedure, argument, deleteAfterStopped); + if(thread->Start()) + { + return thread; + } + else + { + delete thread; + } + } + return 0; + } + + Thread* Thread::CreateAndStart(const Func& procedure, bool deleteAfterStopped) + { + Thread* thread=new LambdaThread(procedure, deleteAfterStopped); + if(thread->Start()) + { + return thread; + } + else + { + delete thread; + } + return 0; + } + + void Thread::Sleep(vint ms) + { + ::Sleep((DWORD)ms); + } + + + vint Thread::GetCPUCount() + { + SYSTEM_INFO info; + GetSystemInfo(&info); + return info.dwNumberOfProcessors; + } + + vint Thread::GetCurrentThreadId() + { + return (vint)::GetCurrentThreadId(); + } + + bool Thread::Start() + { + if(threadState==Thread::NotStarted && internalData->handle!=NULL) + { + if(ResumeThread(internalData->handle)!=-1) + { + threadState=Thread::Running; + return true; + } + } + return false; + } + + bool Thread::Stop() + { + if(internalData->handle!=NULL) + { + if (SuspendThread(internalData->handle) != -1) + { + threadState=Thread::Stopped; + return true; + } + } + return false; + } + + Thread::ThreadState Thread::GetState() + { + return threadState; + } + + void Thread::SetCPU(vint index) + { + SetThreadAffinityMask(internalData->handle, ((vint)1 << index)); + } + +/*********************************************************************** +Mutex +***********************************************************************/ + + namespace threading_internal + { + struct MutexData : public WaitableData + { + MutexData(HANDLE _handle) + :WaitableData(_handle) + { + } + }; + } + + Mutex::Mutex() + :internalData(0) + { + } + + Mutex::~Mutex() + { + if(internalData) + { + CloseHandle(internalData->handle); + delete internalData; + } + } + + bool Mutex::Create(bool owned, const WString& name) + { + if(IsCreated())return false; + BOOL aOwned=owned?TRUE:FALSE; + LPCTSTR aName=name==L""?NULL:name.Buffer(); + HANDLE handle=CreateMutex(NULL, aOwned, aName); + if(handle) + { + internalData=new MutexData(handle); + SetData(internalData); + } + return IsCreated(); + } + + bool Mutex::Open(bool inheritable, const WString& name) + { + if(IsCreated())return false; + BOOL aInteritable=inheritable?TRUE:FALSE; + HANDLE handle=OpenMutex(SYNCHRONIZE, aInteritable, name.Buffer()); + if(handle) + { + internalData=new MutexData(handle); + SetData(internalData); + } + return IsCreated(); + } + + bool Mutex::Release() + { + if(IsCreated()) + { + return ReleaseMutex(internalData->handle)!=0; + } + return false; + } + +/*********************************************************************** +Semaphore +***********************************************************************/ + + namespace threading_internal + { + struct SemaphoreData : public WaitableData + { + SemaphoreData(HANDLE _handle) + :WaitableData(_handle) + { + } + }; + } + + Semaphore::Semaphore() + :internalData(0) + { + } + + Semaphore::~Semaphore() + { + if(internalData) + { + CloseHandle(internalData->handle); + delete internalData; + } + } + + bool Semaphore::Create(vint initialCount, vint maxCount, const WString& name) + { + if(IsCreated())return false; + LONG aInitial=(LONG)initialCount; + LONG aMax=(LONG)maxCount; + LPCTSTR aName=name==L""?NULL:name.Buffer(); + HANDLE handle=CreateSemaphore(NULL, aInitial, aMax, aName); + if(handle) + { + internalData=new SemaphoreData(handle); + SetData(internalData); + } + return IsCreated(); + } + + bool Semaphore::Open(bool inheritable, const WString& name) + { + if(IsCreated())return false; + BOOL aInteritable=inheritable?TRUE:FALSE; + HANDLE handle=OpenSemaphore(SYNCHRONIZE, aInteritable, name.Buffer()); + if(handle) + { + internalData=new SemaphoreData(handle); + SetData(internalData); + } + return IsCreated(); + } + + bool Semaphore::Release() + { + if(IsCreated()) + { + return Release(1)!=-1; + } + return false; + } + + vint Semaphore::Release(vint count) + { + if(IsCreated()) + { + LONG previous=-1; + if(ReleaseSemaphore(internalData->handle, (LONG)count, &previous)!=0) + { + return (vint)previous; + } + } + return -1; + } + +/*********************************************************************** +EventObject +***********************************************************************/ + + namespace threading_internal + { + struct EventData : public WaitableData + { + EventData(HANDLE _handle) + :WaitableData(_handle) + { + } + }; + } + + EventObject::EventObject() + :internalData(0) + { + } + + EventObject::~EventObject() + { + if(internalData) + { + CloseHandle(internalData->handle); + delete internalData; + } + } + + bool EventObject::CreateAutoUnsignal(bool signaled, const WString& name) + { + if(IsCreated())return false; + BOOL aSignaled=signaled?TRUE:FALSE; + LPCTSTR aName=name==L""?NULL:name.Buffer(); + HANDLE handle=CreateEvent(NULL, FALSE, aSignaled, aName); + if(handle) + { + internalData=new EventData(handle); + SetData(internalData); + } + return IsCreated(); + } + + bool EventObject::CreateManualUnsignal(bool signaled, const WString& name) + { + if(IsCreated())return false; + BOOL aSignaled=signaled?TRUE:FALSE; + LPCTSTR aName=name==L""?NULL:name.Buffer(); + HANDLE handle=CreateEvent(NULL, TRUE, aSignaled, aName); + if(handle) + { + internalData=new EventData(handle); + SetData(internalData); + } + return IsCreated(); + } + + bool EventObject::Open(bool inheritable, const WString& name) + { + if(IsCreated())return false; + BOOL aInteritable=inheritable?TRUE:FALSE; + HANDLE handle=OpenEvent(SYNCHRONIZE, aInteritable, name.Buffer()); + if(handle) + { + internalData=new EventData(handle); + SetData(internalData); + } + return IsCreated(); + } + + bool EventObject::Signal() + { + if(IsCreated()) + { + return SetEvent(internalData->handle)!=0; + } + return false; + } + + bool EventObject::Unsignal() + { + if(IsCreated()) + { + return ResetEvent(internalData->handle)!=0; + } + return false; + } + +/*********************************************************************** +ThreadPoolLite +***********************************************************************/ + + struct ThreadPoolQueueProcArgument + { + void(*proc)(void*); + void* argument; + }; + + DWORD WINAPI ThreadPoolQueueProc(void* argument) + { + Ptr proc=(ThreadPoolQueueProcArgument*)argument; + ThreadLocalStorage::FixStorages(); + try + { + proc->proc(proc->argument); + ThreadLocalStorage::ClearStorages(); + } + catch (...) + { + ThreadLocalStorage::ClearStorages(); + } + return 0; + } + + DWORD WINAPI ThreadPoolQueueFunc(void* argument) + { + Ptr> proc=(Func*)argument; + ThreadLocalStorage::FixStorages(); + try + { + (*proc.Obj())(); + ThreadLocalStorage::ClearStorages(); + } + catch (...) + { + ThreadLocalStorage::ClearStorages(); + } + return 0; + } + + ThreadPoolLite::ThreadPoolLite() + { + } + + ThreadPoolLite::~ThreadPoolLite() + { + } + + bool ThreadPoolLite::Queue(void(*proc)(void*), void* argument) + { + ThreadPoolQueueProcArgument* p=new ThreadPoolQueueProcArgument; + p->proc=proc; + p->argument=argument; + if(QueueUserWorkItem(&ThreadPoolQueueProc, p, WT_EXECUTEDEFAULT)) + { + return true; + } + else + { + delete p; + return false; + } + } + + bool ThreadPoolLite::Queue(const Func& proc) + { + Func* p=new Func(proc); + if(QueueUserWorkItem(&ThreadPoolQueueFunc, p, WT_EXECUTEDEFAULT)) + { + return true; + } + else + { + delete p; + return false; + } + } + +/*********************************************************************** +CriticalSection +***********************************************************************/ + + namespace threading_internal + { + struct CriticalSectionData + { + CRITICAL_SECTION criticalSection; + }; + } + + CriticalSection::Scope::Scope(CriticalSection& _criticalSection) + :criticalSection(&_criticalSection) + { + criticalSection->Enter(); + } + + CriticalSection::Scope::~Scope() + { + criticalSection->Leave(); + } + + CriticalSection::CriticalSection() + { + internalData=new CriticalSectionData; + InitializeCriticalSection(&internalData->criticalSection); + } + + CriticalSection::~CriticalSection() + { + DeleteCriticalSection(&internalData->criticalSection); + delete internalData; + } + + bool CriticalSection::TryEnter() + { + return TryEnterCriticalSection(&internalData->criticalSection)!=0; + } + + void CriticalSection::Enter() + { + EnterCriticalSection(&internalData->criticalSection); + } + + void CriticalSection::Leave() + { + LeaveCriticalSection(&internalData->criticalSection); + } + +/*********************************************************************** +ReaderWriterLock +***********************************************************************/ + + namespace threading_internal + { + struct ReaderWriterLockData + { + SRWLOCK lock; + }; + } + + ReaderWriterLock::ReaderScope::ReaderScope(ReaderWriterLock& _lock) + :lock(&_lock) + { + lock->EnterReader(); + } + + ReaderWriterLock::ReaderScope::~ReaderScope() + { + lock->LeaveReader(); + } + + ReaderWriterLock::WriterScope::WriterScope(ReaderWriterLock& _lock) + :lock(&_lock) + { + lock->EnterWriter(); + } + + ReaderWriterLock::WriterScope::~WriterScope() + { + lock->LeaveWriter(); + } + + ReaderWriterLock::ReaderWriterLock() + :internalData(new threading_internal::ReaderWriterLockData) + { + InitializeSRWLock(&internalData->lock); + } + + ReaderWriterLock::~ReaderWriterLock() + { + delete internalData; + } + + bool ReaderWriterLock::TryEnterReader() + { + return TryAcquireSRWLockShared(&internalData->lock)!=0; + } + + void ReaderWriterLock::EnterReader() + { + AcquireSRWLockShared(&internalData->lock); + } + + void ReaderWriterLock::LeaveReader() + { + ReleaseSRWLockShared(&internalData->lock); + } + + bool ReaderWriterLock::TryEnterWriter() + { + return TryAcquireSRWLockExclusive(&internalData->lock)!=0; + } + + void ReaderWriterLock::EnterWriter() + { + AcquireSRWLockExclusive(&internalData->lock); + } + + void ReaderWriterLock::LeaveWriter() + { + ReleaseSRWLockExclusive(&internalData->lock); + } + +/*********************************************************************** +ConditionVariable +***********************************************************************/ + + namespace threading_internal + { + struct ConditionVariableData + { + CONDITION_VARIABLE variable; + }; + } + + ConditionVariable::ConditionVariable() + :internalData(new threading_internal::ConditionVariableData) + { + InitializeConditionVariable(&internalData->variable); + } + + ConditionVariable::~ConditionVariable() + { + delete internalData; + } + + bool ConditionVariable::SleepWith(CriticalSection& cs) + { + return SleepConditionVariableCS(&internalData->variable, &cs.internalData->criticalSection, INFINITE)!=0; + } + + bool ConditionVariable::SleepWithForTime(CriticalSection& cs, vint ms) + { + return SleepConditionVariableCS(&internalData->variable, &cs.internalData->criticalSection, (DWORD)ms)!=0; + } + + bool ConditionVariable::SleepWithReader(ReaderWriterLock& lock) + { + return SleepConditionVariableSRW(&internalData->variable, &lock.internalData->lock, INFINITE, CONDITION_VARIABLE_LOCKMODE_SHARED)!=0; + } + + bool ConditionVariable::SleepWithReaderForTime(ReaderWriterLock& lock, vint ms) + { + return SleepConditionVariableSRW(&internalData->variable, &lock.internalData->lock, (DWORD)ms, CONDITION_VARIABLE_LOCKMODE_SHARED)!=0; + } + + bool ConditionVariable::SleepWithWriter(ReaderWriterLock& lock) + { + return SleepConditionVariableSRW(&internalData->variable, &lock.internalData->lock, INFINITE, 0)!=0; + } + + bool ConditionVariable::SleepWithWriterForTime(ReaderWriterLock& lock, vint ms) + { + return SleepConditionVariableSRW(&internalData->variable, &lock.internalData->lock, (DWORD)ms, 0)!=0; + } + + void ConditionVariable::WakeOnePending() + { + WakeConditionVariable(&internalData->variable); + } + + void ConditionVariable::WakeAllPendings() + { + WakeAllConditionVariable(&internalData->variable); + } + +/*********************************************************************** +SpinLock +***********************************************************************/ + + SpinLock::Scope::Scope(SpinLock& _spinLock) + :spinLock(&_spinLock) + { + spinLock->Enter(); + } + + SpinLock::Scope::~Scope() + { + spinLock->Leave(); + } + + SpinLock::SpinLock() + :token(0) + { + } + + SpinLock::~SpinLock() + { + } + + bool SpinLock::TryEnter() + { + return _InterlockedExchange(&token, 1)==0; + } + + void SpinLock::Enter() + { + while(_InterlockedCompareExchange(&token, 1, 0)!=0) + { + while(token!=0) _mm_pause(); + } + } + + void SpinLock::Leave() + { + _InterlockedExchange(&token, 0); + } + +/*********************************************************************** +ThreadLocalStorage +***********************************************************************/ + +#define KEY ((DWORD&)key) + + ThreadLocalStorage::ThreadLocalStorage(Destructor _destructor) + :destructor(_destructor) + { + static_assert(sizeof(key) >= sizeof(DWORD), "ThreadLocalStorage's key storage is not large enouth."); + PushStorage(this); + KEY = TlsAlloc(); + CHECK_ERROR(KEY != TLS_OUT_OF_INDEXES, L"vl::ThreadLocalStorage::ThreadLocalStorage()#Failed to alloc new thread local storage index."); + } + + ThreadLocalStorage::~ThreadLocalStorage() + { + TlsFree(KEY); + } + + void* ThreadLocalStorage::Get() + { + CHECK_ERROR(!disposed, L"vl::ThreadLocalStorage::Get()#Cannot access a disposed ThreadLocalStorage."); + return TlsGetValue(KEY); + } + + void ThreadLocalStorage::Set(void* data) + { + CHECK_ERROR(!disposed, L"vl::ThreadLocalStorage::Set()#Cannot access a disposed ThreadLocalStorage."); + TlsSetValue(KEY, data); + } + +#undef KEY +} +#endif + +/*********************************************************************** +ThreadLocalStorage Common Implementations +***********************************************************************/ + +namespace vl +{ + void ThreadLocalStorage::Clear() + { + CHECK_ERROR(!disposed, L"vl::ThreadLocalStorage::Clear()#Cannot access a disposed ThreadLocalStorage."); + if(destructor) + { + if (auto data = Get()) + { + destructor(data); + } + } + Set(nullptr); + } + + void ThreadLocalStorage::Dispose() + { + CHECK_ERROR(!disposed, L"vl::ThreadLocalStorage::Dispose()#Cannot access a disposed ThreadLocalStorage."); + Clear(); + disposed = true; + } + + struct TlsStorageLink + { + ThreadLocalStorage* storage = nullptr; + TlsStorageLink* next = nullptr; + }; + + volatile bool tlsFixed = false; + TlsStorageLink* tlsHead = nullptr; + TlsStorageLink** tlsTail = &tlsHead; + + void ThreadLocalStorage::PushStorage(ThreadLocalStorage* storage) + { + CHECK_ERROR(!tlsFixed, L"vl::ThreadLocalStorage::PushStorage(ThreadLocalStorage*)#Cannot create new ThreadLocalStorage instance after calling ThreadLocalStorage::FixStorages()."); + auto link = new TlsStorageLink; + link->storage = storage; + *tlsTail = link; + tlsTail = &link->next; + } + + void ThreadLocalStorage::FixStorages() + { + tlsFixed = true; + } + + void ThreadLocalStorage::ClearStorages() + { + FixStorages(); + auto current = tlsHead; + while (current) + { + current->storage->Clear(); + current = current->next; + } + } + + void ThreadLocalStorage::DisposeStorages() + { + FixStorages(); + auto current = tlsHead; + tlsHead = nullptr; + tlsTail = nullptr; + while (current) + { + current->storage->Dispose(); + + auto temp = current; + current = current->next; + delete temp; + } + } +} + + +/*********************************************************************** +.\THREADINGLINUX.CPP +***********************************************************************/ +#ifdef VCZH_GCC +#include +#include +#include +#include +#if defined(__APPLE__) || defined(__APPLE_CC__) +#include +#endif + + +namespace vl +{ + using namespace threading_internal; + using namespace collections; + + +/*********************************************************************** +Thread +***********************************************************************/ + + namespace threading_internal + { + struct ThreadData + { + pthread_t id; + EventObject ev; + }; + + class ProceduredThread : public Thread + { + private: + Thread::ThreadProcedure procedure; + void* argument; + bool deleteAfterStopped; + + protected: + void Run() + { + bool deleteAfterStopped = this->deleteAfterStopped; + ThreadLocalStorage::FixStorages(); + try + { + procedure(this, argument); + threadState=Thread::Stopped; + internalData->ev.Signal(); + ThreadLocalStorage::ClearStorages(); + } + catch (...) + { + ThreadLocalStorage::ClearStorages(); + throw; + } + if(deleteAfterStopped) + { + delete this; + } + } + public: + ProceduredThread(Thread::ThreadProcedure _procedure, void* _argument, bool _deleteAfterStopped) + :procedure(_procedure) + ,argument(_argument) + ,deleteAfterStopped(_deleteAfterStopped) + { + } + }; + + class LambdaThread : public Thread + { + private: + Func procedure; + bool deleteAfterStopped; + + protected: + void Run() + { + bool deleteAfterStopped = this->deleteAfterStopped; + ThreadLocalStorage::FixStorages(); + try + { + procedure(); + threadState=Thread::Stopped; + internalData->ev.Signal(); + ThreadLocalStorage::ClearStorages(); + } + catch (...) + { + ThreadLocalStorage::ClearStorages(); + throw; + } + if(deleteAfterStopped) + { + delete this; + } + } + public: + LambdaThread(const Func& _procedure, bool _deleteAfterStopped) + :procedure(_procedure) + ,deleteAfterStopped(_deleteAfterStopped) + { + } + }; + } + + void InternalThreadProc(Thread* thread) + { + thread->Run(); + } + + void* InternalThreadProcWrapper(void* lpParameter) + { + InternalThreadProc((Thread*)lpParameter); + return 0; + } + + Thread::Thread() + { + internalData=new ThreadData; + internalData->ev.CreateManualUnsignal(false); + threadState=Thread::NotStarted; + } + + Thread::~Thread() + { + if (internalData) + { + Stop(); + if (threadState!=Thread::NotStarted) + { + pthread_detach(internalData->id); + } + delete internalData; + } + } + + Thread* Thread::CreateAndStart(ThreadProcedure procedure, void* argument, bool deleteAfterStopped) + { + if(procedure) + { + Thread* thread=new ProceduredThread(procedure, argument, deleteAfterStopped); + if(thread->Start()) + { + return thread; + } + else + { + delete thread; + } + } + return 0; + } + + Thread* Thread::CreateAndStart(const Func& procedure, bool deleteAfterStopped) + { + Thread* thread=new LambdaThread(procedure, deleteAfterStopped); + if(thread->Start()) + { + return thread; + } + else + { + delete thread; + } + return 0; + } + + void Thread::Sleep(vint ms) + { + if (ms >= 1000) + { + sleep(ms / 1000); + } + if (ms % 1000) + { + usleep((ms % 1000) * 1000); + } + } + + vint Thread::GetCPUCount() + { + return (vint)sysconf(_SC_NPROCESSORS_ONLN); + } + + vint Thread::GetCurrentThreadId() + { + return (vint)::pthread_self(); + } + + bool Thread::Start() + { + if(threadState==Thread::NotStarted) + { + if(pthread_create(&internalData->id, nullptr, &InternalThreadProcWrapper, this)==0) + { + threadState=Thread::Running; + return true; + } + } + return false; + } + + bool Thread::Wait() + { + return internalData->ev.Wait(); + } + + bool Thread::Stop() + { + if (threadState==Thread::Running) + { + if(pthread_cancel(internalData->id)==0) + { + threadState=Thread::Stopped; + internalData->ev.Signal(); + return true; + } + } + return false; + } + + Thread::ThreadState Thread::GetState() + { + return threadState; + } + +/*********************************************************************** +Mutex +***********************************************************************/ + + namespace threading_internal + { + struct MutexData + { + Semaphore sem; + }; + }; + + Mutex::Mutex() + { + internalData = new MutexData; + } + + Mutex::~Mutex() + { + delete internalData; + } + + bool Mutex::Create(bool owned, const WString& name) + { + return internalData->sem.Create(owned ? 0 : 1, 1, name); + } + + bool Mutex::Open(bool inheritable, const WString& name) + { + return internalData->sem.Open(inheritable, name); + } + + bool Mutex::Release() + { + return internalData->sem.Release(); + } + + bool Mutex::Wait() + { + return internalData->sem.Wait(); + } + +/*********************************************************************** +Semaphore +***********************************************************************/ + + namespace threading_internal + { + struct SemaphoreData + { + sem_t semUnnamed; + sem_t* semNamed = nullptr; + }; + } + + Semaphore::Semaphore() + :internalData(0) + { + } + + Semaphore::~Semaphore() + { + if (internalData) + { + if (internalData->semNamed) + { + sem_close(internalData->semNamed); + } + else + { + sem_destroy(&internalData->semUnnamed); + } + delete internalData; + } + } + + bool Semaphore::Create(vint initialCount, vint maxCount, const WString& name) + { + if (internalData) return false; + if (initialCount > maxCount) return false; + + internalData = new SemaphoreData; +#if defined(__APPLE__) + + AString auuid; + if(name.Length() == 0) + { + CFUUIDRef cfuuid = CFUUIDCreate(kCFAllocatorDefault); + CFStringRef cfstr = CFUUIDCreateString(kCFAllocatorDefault, cfuuid); + auuid = CFStringGetCStringPtr(cfstr, kCFStringEncodingASCII); + + CFRelease(cfstr); + CFRelease(cfuuid); + } + auuid = auuid.Insert(0, "/"); + // OSX SEM_NAME_LENGTH = 31 + if(auuid.Length() >= 30) + auuid = auuid.Sub(0, 30); + + if ((internalData->semNamed = sem_open(auuid.Buffer(), O_CREAT, O_RDWR, initialCount)) == SEM_FAILED) + { + delete internalData; + internalData = 0; + return false; + } + +#else + if (name == L"") + { + if(sem_init(&internalData->semUnnamed, 0, (int)initialCount) == -1) + { + delete internalData; + internalData = 0; + return false; + } + } + else + { + AString astr = wtoa(name); + + if ((internalData->semNamed = sem_open(astr.Buffer(), O_CREAT, 0777, initialCount)) == SEM_FAILED) + { + delete internalData; + internalData = 0; + return false; + } + } +#endif + + Release(initialCount); + return true; + } + + bool Semaphore::Open(bool inheritable, const WString& name) + { + if (internalData) return false; + if (inheritable) return false; + + internalData = new SemaphoreData; + if (!(internalData->semNamed = sem_open(wtoa(name).Buffer(), 0))) + { + delete internalData; + internalData = 0; + return false; + } + + return true; + } + + bool Semaphore::Release() + { + return Release(1); + } + + vint Semaphore::Release(vint count) + { + for (vint i = 0; i < count; i++) + { + if (internalData->semNamed) + { + sem_post(internalData->semNamed); + } + else + { + sem_post(&internalData->semUnnamed); + } + } + return true; + } + + bool Semaphore::Wait() + { + if (internalData->semNamed) + { + return sem_wait(internalData->semNamed) == 0; + } + else + { + return sem_wait(&internalData->semUnnamed) == 0; + } + } + +/*********************************************************************** +EventObject +***********************************************************************/ + + namespace threading_internal + { + struct EventData + { + bool autoReset; + volatile bool signaled; + CriticalSection mutex; + ConditionVariable cond; + volatile vint counter = 0; + }; + } + + EventObject::EventObject() + { + internalData = nullptr; + } + + EventObject::~EventObject() + { + if (internalData) + { + delete internalData; + } + } + + bool EventObject::CreateAutoUnsignal(bool signaled, const WString& name) + { + if (name!=L"") return false; + if (internalData) return false; + + internalData = new EventData; + internalData->autoReset = true; + internalData->signaled = signaled; + return true; + } + + bool EventObject::CreateManualUnsignal(bool signaled, const WString& name) + { + if (name!=L"") return false; + if (internalData) return false; + + internalData = new EventData; + internalData->autoReset = false; + internalData->signaled = signaled; + return true; + } + + bool EventObject::Signal() + { + if (!internalData) return false; + + internalData->mutex.Enter(); + internalData->signaled = true; + if (internalData->counter) + { + if (internalData->autoReset) + { + internalData->cond.WakeOnePending(); + internalData->signaled = false; + } + else + { + internalData->cond.WakeAllPendings(); + } + } + internalData->mutex.Leave(); + return true; + } + + bool EventObject::Unsignal() + { + if (!internalData) return false; + + internalData->mutex.Enter(); + internalData->signaled = false; + internalData->mutex.Leave(); + return true; + } + + bool EventObject::Wait() + { + if (!internalData) return false; + + internalData->mutex.Enter(); + if (internalData->signaled) + { + if (internalData->autoReset) + { + internalData->signaled = false; + } + } + else + { + internalData->counter++; + internalData->cond.SleepWith(internalData->mutex); + internalData->counter--; + } + internalData->mutex.Leave(); + return true; + } + +/*********************************************************************** +ThreadPoolLite +***********************************************************************/ + + namespace threading_internal + { + struct ThreadPoolTask + { + Func task; + Ptr next; + }; + + struct ThreadPoolData + { + Semaphore semaphore; + EventObject taskFinishEvent; + Ptr taskBegin; + Ptr* taskEnd = nullptr; + volatile bool stopping = false; + List taskThreads; + }; + + SpinLock threadPoolLock; + ThreadPoolData* threadPoolData = nullptr; + + void ThreadPoolProc(Thread* thread, void* argument) + { + while (true) + { + Ptr task; + + threadPoolData->semaphore.Wait(); + SPIN_LOCK(threadPoolLock) + { + if (threadPoolData->taskBegin) + { + task = threadPoolData->taskBegin; + threadPoolData->taskBegin = task->next; + } + + if (!threadPoolData->taskBegin) + { + threadPoolData->taskEnd = &threadPoolData->taskBegin; + threadPoolData->taskFinishEvent.Signal(); + } + } + + if (task) + { + ThreadLocalStorage::FixStorages(); + try + { + task->task(); + ThreadLocalStorage::ClearStorages(); + } + catch (...) + { + ThreadLocalStorage::ClearStorages(); + } + } + else if (threadPoolData->stopping) + { + return; + } + } + } + + bool ThreadPoolQueue(const Func& proc) + { + SPIN_LOCK(threadPoolLock) + { + if (!threadPoolData) + { + threadPoolData = new ThreadPoolData; + threadPoolData->semaphore.Create(0, 65536); + threadPoolData->taskFinishEvent.CreateManualUnsignal(false); + threadPoolData->taskEnd = &threadPoolData->taskBegin; + + for (vint i = 0; i < Thread::GetCPUCount() * 4; i++) + { + threadPoolData->taskThreads.Add(Thread::CreateAndStart(&ThreadPoolProc, nullptr, false)); + } + } + + if (threadPoolData) + { + if (threadPoolData->stopping) + { + return false; + } + + auto task = MakePtr(); + task->task = proc; + *threadPoolData->taskEnd = task; + threadPoolData->taskEnd = &task->next; + threadPoolData->semaphore.Release(); + threadPoolData->taskFinishEvent.Unsignal(); + } + } + return true; + } + + bool ThreadPoolStop(bool discardPendingTasks) + { + SPIN_LOCK(threadPoolLock) + { + if (!threadPoolData) return false; + if (threadPoolData->stopping) return false; + + threadPoolData->stopping = true; + if (discardPendingTasks) + { + threadPoolData->taskEnd = &threadPoolData->taskBegin; + threadPoolData->taskBegin = nullptr; + } + + threadPoolData->semaphore.Release(threadPoolData->taskThreads.Count()); + } + + threadPoolData->taskFinishEvent.Wait(); + for (vint i = 0; i < threadPoolData->taskThreads.Count(); i++) + { + auto thread = threadPoolData->taskThreads[i]; + thread->Wait(); + delete thread; + } + threadPoolData->taskThreads.Clear(); + + SPIN_LOCK(threadPoolLock) + { + delete threadPoolData; + threadPoolData = nullptr; + } + return true; + } + } + + ThreadPoolLite::ThreadPoolLite() + { + } + + ThreadPoolLite::~ThreadPoolLite() + { + } + + bool ThreadPoolLite::Queue(void(*proc)(void*), void* argument) + { + return ThreadPoolQueue([proc, argument](){proc(argument);}); + } + + bool ThreadPoolLite::Queue(const Func& proc) + { + return ThreadPoolQueue(proc); + } + + bool ThreadPoolLite::Stop(bool discardPendingTasks) + { + return ThreadPoolStop(discardPendingTasks); + } + +/*********************************************************************** +CriticalSection +***********************************************************************/ + + namespace threading_internal + { + struct CriticalSectionData + { + pthread_mutex_t mutex; + }; + } + + CriticalSection::CriticalSection() + { + internalData = new CriticalSectionData; + pthread_mutex_init(&internalData->mutex, nullptr); + } + + CriticalSection::~CriticalSection() + { + pthread_mutex_destroy(&internalData->mutex); + delete internalData; + } + + bool CriticalSection::TryEnter() + { + return pthread_mutex_trylock(&internalData->mutex) == 0; + } + + void CriticalSection::Enter() + { + pthread_mutex_lock(&internalData->mutex); + } + + void CriticalSection::Leave() + { + pthread_mutex_unlock(&internalData->mutex); + } + + CriticalSection::Scope::Scope(CriticalSection& _criticalSection) + :criticalSection(&_criticalSection) + { + criticalSection->Enter(); + } + + CriticalSection::Scope::~Scope() + { + criticalSection->Leave(); + } + +/*********************************************************************** +ReaderWriterLock +***********************************************************************/ + + namespace threading_internal + { + struct ReaderWriterLockData + { + pthread_rwlock_t rwlock; + }; + } + + ReaderWriterLock::ReaderWriterLock() + { + internalData = new ReaderWriterLockData; + pthread_rwlock_init(&internalData->rwlock, nullptr); + } + + ReaderWriterLock::~ReaderWriterLock() + { + pthread_rwlock_destroy(&internalData->rwlock); + delete internalData; + } + + bool ReaderWriterLock::TryEnterReader() + { + return pthread_rwlock_tryrdlock(&internalData->rwlock) == 0; + } + + void ReaderWriterLock::EnterReader() + { + pthread_rwlock_rdlock(&internalData->rwlock); + } + + void ReaderWriterLock::LeaveReader() + { + pthread_rwlock_unlock(&internalData->rwlock); + } + + bool ReaderWriterLock::TryEnterWriter() + { + return pthread_rwlock_trywrlock(&internalData->rwlock) == 0; + } + + void ReaderWriterLock::EnterWriter() + { + pthread_rwlock_wrlock(&internalData->rwlock); + } + + void ReaderWriterLock::LeaveWriter() + { + pthread_rwlock_unlock(&internalData->rwlock); + } + + ReaderWriterLock::ReaderScope::ReaderScope(ReaderWriterLock& _lock) + :lock(&_lock) + { + lock->EnterReader(); + } + + ReaderWriterLock::ReaderScope::~ReaderScope() + { + lock->LeaveReader(); + } + + ReaderWriterLock::WriterScope::WriterScope(ReaderWriterLock& _lock) + :lock(&_lock) + { + lock->EnterWriter(); + } + + ReaderWriterLock::WriterScope::~WriterScope() + { + lock->LeaveReader(); + } + +/*********************************************************************** +ConditionVariable +***********************************************************************/ + + namespace threading_internal + { + struct ConditionVariableData + { + pthread_cond_t cond; + }; + } + + ConditionVariable::ConditionVariable() + { + internalData = new ConditionVariableData; + pthread_cond_init(&internalData->cond, nullptr); + } + + ConditionVariable::~ConditionVariable() + { + pthread_cond_destroy(&internalData->cond); + delete internalData; + } + + bool ConditionVariable::SleepWith(CriticalSection& cs) + { + return pthread_cond_wait(&internalData->cond, &cs.internalData->mutex) == 0; + } + + void ConditionVariable::WakeOnePending() + { + pthread_cond_signal(&internalData->cond); + } + + void ConditionVariable::WakeAllPendings() + { + pthread_cond_broadcast(&internalData->cond); + } + +/*********************************************************************** +SpinLock +***********************************************************************/ + + SpinLock::Scope::Scope(SpinLock& _spinLock) + :spinLock(&_spinLock) + { + spinLock->Enter(); + } + + SpinLock::Scope::~Scope() + { + spinLock->Leave(); + } + + SpinLock::SpinLock() + :token(0) + { + } + + SpinLock::~SpinLock() + { + } + + bool SpinLock::TryEnter() + { + return __sync_lock_test_and_set(&token, 1)==0; + } + + void SpinLock::Enter() + { + while(__sync_val_compare_and_swap(&token, 0, 1)!=0) + { + while(token!=0) _mm_pause(); + } + } + + void SpinLock::Leave() + { + __sync_lock_test_and_set(&token, 0); + } + +/*********************************************************************** +ThreadLocalStorage +***********************************************************************/ + +#define KEY ((pthread_key_t&)key) + + ThreadLocalStorage::ThreadLocalStorage(Destructor _destructor) + :destructor(_destructor) + { + static_assert(sizeof(key) >= sizeof(pthread_key_t), "ThreadLocalStorage's key storage is not large enouth."); + PushStorage(this); + auto error = pthread_key_create(&KEY, destructor); + CHECK_ERROR(error != EAGAIN && error != ENOMEM, L"vl::ThreadLocalStorage::ThreadLocalStorage()#Failed to create a thread local storage index."); + } + + ThreadLocalStorage::~ThreadLocalStorage() + { + pthread_key_delete(KEY); + } + + void* ThreadLocalStorage::Get() + { + CHECK_ERROR(!disposed, L"vl::ThreadLocalStorage::Get()#Cannot access a disposed ThreadLocalStorage."); + return pthread_getspecific(KEY); + } + + void ThreadLocalStorage::Set(void* data) + { + CHECK_ERROR(!disposed, L"vl::ThreadLocalStorage::Set()#Cannot access a disposed ThreadLocalStorage."); + pthread_setspecific(KEY, data); + } + +#undef KEY +} +#endif + + +/*********************************************************************** +.\REGEX\REGEXPURE.CPP ***********************************************************************/ namespace vl @@ -23358,7 +25073,907 @@ PureInterpretor } /*********************************************************************** -REGEX\REGEXRICH.CPP +.\REGEX\REGEX.CPP +***********************************************************************/ + +namespace vl +{ + namespace regex + { + using namespace collections; + using namespace regex_internal; + +/*********************************************************************** +RegexString +***********************************************************************/ + + RegexString::RegexString(vint _start) + :start(_start) + ,length(0) + { + } + + RegexString::RegexString(const WString& _string, vint _start, vint _length) + :value(_length==0?L"":_string.Sub(_start, _length)) + ,start(_start) + ,length(_length) + { + } + + vint RegexString::Start()const + { + return start; + } + + vint RegexString::Length()const + { + return length; + } + + const WString& RegexString::Value()const + { + return value; + } + + bool RegexString::operator==(const RegexString& string)const + { + return start==string.start && length==string.length && value==string.value; + } + +/*********************************************************************** +RegexMatch +***********************************************************************/ + + RegexMatch::RegexMatch(const WString& _string, PureResult* _result) + :success(true) + ,result(_string, _result->start, _result->length) + { + } + + RegexMatch::RegexMatch(const WString& _string, RichResult* _result, RichInterpretor* _rich) + :success(true) + ,result(_string, _result->start, _result->length) + { + for(vint i=0;i<_result->captures.Count();i++) + { + CaptureRecord& capture=_result->captures[i]; + if(capture.capture==-1) + { + captures.Add(RegexString(_string, capture.start, capture.length)); + } + else + { + groups.Add(_rich->CaptureNames().Get(capture.capture), RegexString(_string, capture.start, capture.length)); + } + } + } + + RegexMatch::RegexMatch(const RegexString& _result) + :success(false) + ,result(_result) + { + } + + bool RegexMatch::Success()const + { + return success; + } + + const RegexString& RegexMatch::Result()const + { + return result; + } + + const RegexMatch::CaptureList& RegexMatch::Captures()const + { + return captures; + } + + const RegexMatch::CaptureGroup& RegexMatch::Groups()const + { + return groups; + } + +/*********************************************************************** +Regex +***********************************************************************/ + + void Regex::Process(const WString& text, bool keepEmpty, bool keepSuccess, bool keepFail, RegexMatch::List& matches)const + { + if(rich) + { + const wchar_t* start=text.Buffer(); + const wchar_t* input=start; + RichResult result; + while(rich->Match(input, start, result)) + { + vint offset=input-start; + if(keepFail) + { + if(result.start>offset || keepEmpty) + { + matches.Add(new RegexMatch(RegexString(text, offset, result.start-offset))); + } + } + if(keepSuccess) + { + matches.Add(new RegexMatch(text, &result, rich)); + } + input=start+result.start+result.length; + } + if(keepFail) + { + vint remain=input-start; + vint length=text.Length()-remain; + if(length || keepEmpty) + { + matches.Add(new RegexMatch(RegexString(text, remain, length))); + } + } + } + else + { + const wchar_t* start=text.Buffer(); + const wchar_t* input=start; + PureResult result; + while(pure->Match(input, start, result)) + { + vint offset=input-start; + if(keepFail) + { + if(result.start>offset || keepEmpty) + { + matches.Add(new RegexMatch(RegexString(text, offset, result.start-offset))); + } + } + if(keepSuccess) + { + matches.Add(new RegexMatch(text, &result)); + } + input=start+result.start+result.length; + } + if(keepFail) + { + vint remain=input-start; + vint length=text.Length()-remain; + if(length || keepEmpty) + { + matches.Add(new RegexMatch(RegexString(text, remain, length))); + } + } + } + } + + Regex::Regex(const WString& code, bool preferPure) + :pure(0) + ,rich(0) + { + CharRange::List subsets; + RegexExpression::Ref regex=ParseRegexExpression(code); + Expression::Ref expression=regex->Merge(); + expression->NormalizeCharSet(subsets); + + bool pureRequired=false; + bool richRequired=false; + if(preferPure) + { + if(expression->HasNoExtension()) + { + pureRequired=true; + } + else + { + if(expression->CanTreatAsPure()) + { + pureRequired=true; + richRequired=true; + } + else + { + richRequired=true; + } + } + } + else + { + richRequired=true; + } + + try + { + if(pureRequired) + { + Dictionary nfaStateMap; + Group dfaStateMap; + Automaton::Ref eNfa=expression->GenerateEpsilonNfa(); + Automaton::Ref nfa=EpsilonNfaToNfa(eNfa, PureEpsilonChecker, nfaStateMap); + Automaton::Ref dfa=NfaToDfa(nfa, dfaStateMap); + pure=new PureInterpretor(dfa, subsets); + } + if(richRequired) + { + Dictionary nfaStateMap; + Group dfaStateMap; + Automaton::Ref eNfa=expression->GenerateEpsilonNfa(); + Automaton::Ref nfa=EpsilonNfaToNfa(eNfa, RichEpsilonChecker, nfaStateMap); + Automaton::Ref dfa=NfaToDfa(nfa, dfaStateMap); + rich=new RichInterpretor(dfa); + } + } + catch(...) + { + if(pure)delete pure; + if(rich)delete rich; + throw; + } + } + + Regex::~Regex() + { + if(pure)delete pure; + if(rich)delete rich; + } + + bool Regex::IsPureMatch()const + { + return rich?false:true; + } + + bool Regex::IsPureTest()const + { + return pure?true:false; + } + + RegexMatch::Ref Regex::MatchHead(const WString& text)const + { + if(rich) + { + RichResult result; + if(rich->MatchHead(text.Buffer(), text.Buffer(), result)) + { + return new RegexMatch(text, &result, rich); + } + else + { + return 0; + } + } + else + { + PureResult result; + if(pure->MatchHead(text.Buffer(), text.Buffer(), result)) + { + return new RegexMatch(text, &result); + } + else + { + return 0; + } + } + } + + RegexMatch::Ref Regex::Match(const WString& text)const + { + if(rich) + { + RichResult result; + if(rich->Match(text.Buffer(), text.Buffer(), result)) + { + return new RegexMatch(text, &result, rich); + } + else + { + return 0; + } + } + else + { + PureResult result; + if(pure->Match(text.Buffer(), text.Buffer(), result)) + { + return new RegexMatch(text, &result); + } + else + { + return 0; + } + } + } + + bool Regex::TestHead(const WString& text)const + { + if(pure) + { + PureResult result; + return pure->MatchHead(text.Buffer(), text.Buffer(), result); + } + else + { + RichResult result; + return rich->MatchHead(text.Buffer(), text.Buffer(), result); + } + } + + bool Regex::Test(const WString& text)const + { + if(pure) + { + PureResult result; + return pure->Match(text.Buffer(), text.Buffer(), result); + } + else + { + RichResult result; + return rich->Match(text.Buffer(), text.Buffer(), result); + } + } + + void Regex::Search(const WString& text, RegexMatch::List& matches)const + { + Process(text, false, true, false, matches); + } + + void Regex::Split(const WString& text, bool keepEmptyMatch, RegexMatch::List& matches)const + { + Process(text, keepEmptyMatch, false, true, matches); + } + + void Regex::Cut(const WString& text, bool keepEmptyMatch, RegexMatch::List& matches)const + { + Process(text, keepEmptyMatch, true, true, matches); + } + +/*********************************************************************** +RegexTokens +***********************************************************************/ + + bool RegexToken::operator==(const RegexToken& _token)const + { + return length==_token.length && token==_token.token && reading==_token.reading; + } + + bool RegexToken::operator==(const wchar_t* _token)const + { + return wcslen(_token)==length && wcsncmp(reading, _token, length)==0; + } + + class RegexTokenEnumerator : public Object, public IEnumerator + { + protected: + RegexToken token; + vint index; + + PureInterpretor* pure; + const Array& stateTokens; + const wchar_t* start; + vint codeIndex; + + const wchar_t* reading; + vint rowStart; + vint columnStart; + bool cacheAvailable; + RegexToken cacheToken; + + public: + RegexTokenEnumerator(const RegexTokenEnumerator& enumerator) + :token(enumerator.token) + ,index(enumerator.index) + ,pure(enumerator.pure) + ,stateTokens(enumerator.stateTokens) + ,reading(enumerator.reading) + ,start(enumerator.start) + ,rowStart(enumerator.rowStart) + ,columnStart(enumerator.columnStart) + ,codeIndex(enumerator.codeIndex) + ,cacheAvailable(enumerator.cacheAvailable) + ,cacheToken(enumerator.cacheToken) + { + } + + RegexTokenEnumerator(PureInterpretor* _pure, const Array& _stateTokens, const wchar_t* _start, vint _codeIndex) + :index(-1) + ,pure(_pure) + ,stateTokens(_stateTokens) + ,reading(_start) + ,start(_start) + ,rowStart(0) + ,columnStart(0) + ,codeIndex(_codeIndex) + ,cacheAvailable(false) + { + } + + IEnumerator* Clone()const + { + return new RegexTokenEnumerator(*this); + } + + const RegexToken& Current()const + { + return token; + } + + vint Index()const + { + return index; + } + + bool Next() + { + if(!cacheAvailable && !*reading) return false; + if(cacheAvailable) + { + token=cacheToken; + cacheAvailable=false; + } + else + { + token.reading=reading; + token.start=0; + token.length=0; + token.token=-2; + token.completeToken=true; + } + token.rowStart=rowStart; + token.columnStart=columnStart; + token.rowEnd=rowStart; + token.columnEnd=columnStart; + token.codeIndex=codeIndex; + + PureResult result; + while(*reading) + { + vint id=-1; + bool completeToken=true; + if(!pure->MatchHead(reading, start, result)) + { + result.start=reading-start; + + if(id==-1 && result.terminateState!=-1) + { + vint state=pure->GetRelatedFinalState(result.terminateState); + if(state!=-1) + { + id=stateTokens[state]; + } + } + + if(id==-1) + { + result.length=1; + } + else + { + completeToken=false; + } + } + else + { + id=stateTokens.Get(result.finalState); + } + if(token.token==-2) + { + token.start=result.start; + token.length=result.length; + token.token=id; + token.completeToken=completeToken; + } + else if(token.token==id && id==-1) + { + token.length+=result.length; + } + else + { + cacheAvailable=true; + cacheToken.reading=reading; + cacheToken.start=result.start; + cacheToken.length=result.length; + cacheToken.codeIndex=codeIndex; + cacheToken.token=id; + cacheToken.completeToken=completeToken; + } + reading+=result.length; + if(cacheAvailable) + { + break; + } + } + + index++; + + for(vint i=0;i& tokens, bool(*discard)(vint)) + { + while(Next()) + { + if(!discard(token.token)) + { + tokens.Add(token); + } + } + } + }; + + RegexTokens::RegexTokens(PureInterpretor* _pure, const Array& _stateTokens, const WString& _code, vint _codeIndex) + :pure(_pure) + ,stateTokens(_stateTokens) + ,code(_code) + ,codeIndex(_codeIndex) + { + } + + RegexTokens::RegexTokens(const RegexTokens& tokens) + :pure(tokens.pure) + ,stateTokens(tokens.stateTokens) + ,code(tokens.code) + ,codeIndex(tokens.codeIndex) + { + } + + IEnumerator* RegexTokens::CreateEnumerator()const + { + return new RegexTokenEnumerator(pure, stateTokens, code.Buffer(), codeIndex); + } + + bool DefaultDiscard(vint token) + { + return false; + } + + void RegexTokens::ReadToEnd(collections::List& tokens, bool(*discard)(vint))const + { + if(discard==0) + { + discard=&DefaultDiscard; + } + RegexTokenEnumerator(pure, stateTokens, code.Buffer(), codeIndex).ReadToEnd(tokens, discard); + } + +/*********************************************************************** +RegexLexerWalker +***********************************************************************/ + + RegexLexerWalker::RegexLexerWalker(PureInterpretor* _pure, const Array& _stateTokens) + :pure(_pure) + ,stateTokens(_stateTokens) + { + } + + RegexLexerWalker::RegexLexerWalker(const RegexLexerWalker& walker) + :pure(walker.pure) + ,stateTokens(walker.stateTokens) + { + } + + RegexLexerWalker::~RegexLexerWalker() + { + } + + vint RegexLexerWalker::GetStartState()const + { + return pure->GetStartState(); + } + + vint RegexLexerWalker::GetRelatedToken(vint state)const + { + vint finalState=pure->GetRelatedFinalState(state); + return finalState==-1?-1:stateTokens.Get(finalState); + } + + void RegexLexerWalker::Walk(wchar_t input, vint& state, vint& token, bool& finalState, bool& previousTokenStop)const + { + vint previousState=state; + token=-1; + finalState=false; + previousTokenStop=false; + if(state==-1) + { + state=pure->GetStartState(); + previousTokenStop=true; + } + + state=pure->Transit(input, state); + if(state==-1) + { + previousTokenStop=true; + if(previousState==-1) + { + finalState=true; + return; + } + else if(pure->IsFinalState(previousState)) + { + state=pure->Transit(input, pure->GetStartState()); + } + } + if(pure->IsFinalState(state)) + { + token=stateTokens.Get(state); + finalState=true; + return; + } + else + { + finalState=state==-1; + return; + } + } + + vint RegexLexerWalker::Walk(wchar_t input, vint state)const + { + vint token=-1; + bool finalState=false; + bool previousTokenStop=false; + Walk(input, state, token, finalState, previousTokenStop); + return state; + } + + bool RegexLexerWalker::IsClosedToken(const wchar_t* input, vint length)const + { + vint state=pure->GetStartState(); + for(vint i=0;iTransit(input[i], state); + if(state==-1) return true; + if(pure->IsDeadState(state)) return true; + } + return false; + } + + bool RegexLexerWalker::IsClosedToken(const WString& input)const + { + return IsClosedToken(input.Buffer(), input.Length()); + } + +/*********************************************************************** +RegexLexerColorizer +***********************************************************************/ + + RegexLexerColorizer::RegexLexerColorizer(const RegexLexerWalker& _walker) + :walker(_walker) + ,currentState(_walker.GetStartState()) + { + } + + RegexLexerColorizer::RegexLexerColorizer(const RegexLexerColorizer& colorizer) + :walker(colorizer.walker) + ,currentState(colorizer.currentState) + { + } + + RegexLexerColorizer::~RegexLexerColorizer() + { + } + + void RegexLexerColorizer::Reset(vint state) + { + currentState=state; + } + + void RegexLexerColorizer::Pass(wchar_t input) + { + currentState=walker.Walk(input, currentState); + } + + vint RegexLexerColorizer::GetStartState()const + { + return walker.GetStartState(); + } + + vint RegexLexerColorizer::GetCurrentState()const + { + return currentState; + } + + void RegexLexerColorizer::Colorize(const wchar_t* input, vint length, TokenProc tokenProc, void* tokenProcArgument) + { + vint start=0; + vint stop=0; + vint state=-1; + vint token=-1; + + vint index=0; + vint currentToken=-1; + bool finalState=false; + bool previousTokenStop=false; + + while(index0) + { + tokenProc(tokenProcArgument, start, tokenLength, token); + currentState=state; + start=stop; + index=stop-1; + state=-1; + token=-1; + finalState=false; + } + else if(stop& tokens) + :pure(0) + { + //构造所有DFA + List expressions; + List dfas; + CharRange::List subsets; + Ptr> enumerator=tokens.CreateEnumerator(); + while(enumerator->Next()) + { + const WString& code=enumerator->Current(); + + RegexExpression::Ref regex=ParseRegexExpression(code); + Expression::Ref expression=regex->Merge(); + expression->CollectCharSet(subsets); + expressions.Add(expression); + } + for(vint i=0;i nfaStateMap; + Group dfaStateMap; + Expression::Ref expression=expressions[i]; + expression->ApplyCharSet(subsets); + Automaton::Ref eNfa=expression->GenerateEpsilonNfa(); + Automaton::Ref nfa=EpsilonNfaToNfa(eNfa, PureEpsilonChecker, nfaStateMap); + Automaton::Ref dfa=NfaToDfa(nfa, dfaStateMap); + dfas.Add(dfa); + } + + //为每一个DFA设置标记 + for(vint i=0;istates.Count();j++) + { + if(dfa->states[j]->finalState) + { + dfa->states[j]->userData=(void*)i; + } + else + { + dfa->states[j]->userData=(void*)dfas.Count(); + } + } + } + + //将DFA组合成大的e-NFA + Automaton::Ref bigEnfa=new Automaton; + for(vint i=0;istates, dfas[i]->states); + CopyFrom(bigEnfa->transitions, dfas[i]->transitions); + } + bigEnfa->startState=bigEnfa->NewState(); + for(vint i=0;iNewEpsilon(bigEnfa->startState, dfas[i]->startState); + } + + //转换成DFA + Dictionary nfaStateMap; + Group dfaStateMap; + Automaton::Ref bigNfa=EpsilonNfaToNfa(bigEnfa, PureEpsilonChecker, nfaStateMap); + for(vint i=0;iuserData; + nfaStateMap.Keys()[i]->userData=userData; + } + Automaton::Ref bigDfa=NfaToDfa(bigNfa, dfaStateMap); + for(vint i=0;iuserData; + for(vint j=1;juserData; + if(userData>newData) + { + userData=newData; + } + } + dfaStateMap.Keys()[i]->userData=userData; + } + + //构造状态机 + pure=new PureInterpretor(bigDfa, subsets); + stateTokens.Resize(bigDfa->states.Count()); + for(vint i=0;istates[i]->userData; + stateTokens[i]=(vint)userData; + } + } + + RegexLexer::~RegexLexer() + { + if(pure)delete pure; + } + + RegexTokens RegexLexer::Parse(const WString& code, vint codeIndex)const + { + pure->PrepareForRelatedFinalStateTable(); + return RegexTokens(pure, stateTokens, code, codeIndex); + } + + RegexLexerWalker RegexLexer::Walk()const + { + pure->PrepareForRelatedFinalStateTable(); + return RegexLexerWalker(pure, stateTokens); + } + + RegexLexerColorizer RegexLexer::Colorize()const + { + return RegexLexerColorizer(Walk()); + } + } +} + +/*********************************************************************** +.\REGEX\REGEXRICH.CPP ***********************************************************************/ namespace vl @@ -23793,7 +26408,7 @@ RichInterpretor } /*********************************************************************** -REGEX\REGEXWRITER.CPP +.\REGEX\REGEXWRITER.CPP ***********************************************************************/ namespace vl @@ -23975,592 +26590,7 @@ RegexNode } /*********************************************************************** -STREAM\ACCESSOR.CPP -***********************************************************************/ - -namespace vl -{ - namespace stream - { - using namespace collections; - -/*********************************************************************** -TextReader -***********************************************************************/ - - WString TextReader::ReadString(vint length) - { - wchar_t* buffer=new wchar_t[length+1]; - vint i=0; - for(;i0 && result[result.Length()-1]==L'\r') - { - return result.Left(result.Length()-1); - } - else - { - return result; - } - } - - WString TextReader::ReadToEnd() - { - WString result; - auto buffer = new wchar_t[65537]; - buffer[0]=L'\0'; - vint i=0; - while(true) - { - wchar_t c=ReadChar(); - if(c==L'\0') - { - buffer[i]=L'\0'; - result+=buffer; - buffer[0]=L'\0'; - i=0; - break; - } - else - { - if(i==65536) - { - buffer[i]=L'\0'; - result+=buffer; - buffer[0]=L'\0'; - i=0; - } - buffer[i++]=c; - } - } - result+=buffer; - delete[] buffer; - return result; - } - -/*********************************************************************** -TextWriter -***********************************************************************/ - - void TextWriter::WriteString(const wchar_t* string, vint charCount) - { - while(*string) - { - WriteChar(*string++); - } - } - - void TextWriter::WriteString(const wchar_t* string) - { - WriteString(string, (vint)wcslen(string)); - } - - void TextWriter::WriteString(const WString& string) - { - if(string.Length()) - { - WriteString(string.Buffer(), string.Length()); - } - } - - void TextWriter::WriteLine(const wchar_t* string, vint charCount) - { - WriteString(string, charCount); - WriteString(L"\r\n", 2); - } - - void TextWriter::WriteLine(const wchar_t* string) - { - WriteString(string); - WriteString(L"\r\n", 2); - } - - void TextWriter::WriteLine(const WString& string) - { - WriteString(string); - WriteString(L"\r\n", 2); - } - - namespace monospace_tabling - { - void WriteBorderLine(TextWriter& writer, Array& columnWidths, vint columns) - { - writer.WriteChar(L'+'); - for(vint i=0;i& columnWidths, vint rowHeight, vint columns, Array& tableByRow, vint startRow) - { - vint cellStart=startRow*columns; - for(vint r=0;r=length;i--) - { - writer.WriteChar(L' '); - } - writer.WriteChar(L'|'); - } - writer.WriteLine(L""); - } - } - } - using namespace monospace_tabling; - - void TextWriter::WriteMonospacedEnglishTable(collections::Array& tableByRow, vint rows, vint columns) - { - Array rowHeights(rows); - Array columnWidths(columns); - for(vint i=0;iremain) length=remain; - WString result=string.Sub(current, length); - current+=length; - return result; - } - } - - WString StringReader::ReadLine() - { - PrepareIfLastCallIsReadLine(); - if(IsEnd()) - { - return L""; - } - else - { - vint lineEnd=current; - while(lineEndRead(&buffer, sizeof(buffer))==0) - { - stream=0; - return 0; - } - else - { - return buffer; - } - } - else - { - return L'\0'; - } - } - -/*********************************************************************** -StreamWriter -***********************************************************************/ - - StreamWriter::StreamWriter(IStream& _stream) - :stream(&_stream) - { - } - - void StreamWriter::WriteChar(wchar_t c) - { - stream->Write(&c, sizeof(c)); - } - - void StreamWriter::WriteString(const wchar_t* string, vint charCount) - { - stream->Write((void*)string, charCount*sizeof(*string)); - } - -/*********************************************************************** -EncoderStream -***********************************************************************/ - - EncoderStream::EncoderStream(IStream& _stream, IEncoder& _encoder) - :stream(&_stream) - ,encoder(&_encoder) - ,position(0) - { - encoder->Setup(stream); - } - - EncoderStream::~EncoderStream() - { - Close(); - } - - bool EncoderStream::CanRead()const - { - return false; - } - - bool EncoderStream::CanWrite()const - { - return IsAvailable(); - } - - bool EncoderStream::CanSeek()const - { - return false; - } - - bool EncoderStream::CanPeek()const - { - return false; - } - - bool EncoderStream::IsLimited()const - { - return stream!=0 && stream->IsLimited(); - } - - bool EncoderStream::IsAvailable()const - { - return stream!=0 && stream->IsAvailable(); - } - - void EncoderStream::Close() - { - encoder->Close(); - stream=0; - } - - pos_t EncoderStream::Position()const - { - return IsAvailable()?position:-1; - } - - pos_t EncoderStream::Size()const - { - return -1; - } - - void EncoderStream::Seek(pos_t _size) - { - CHECK_FAIL(L"EncoderStream::Seek(pos_t)#Operation not supported."); - } - - void EncoderStream::SeekFromBegin(pos_t _size) - { - CHECK_FAIL(L"EncoderStream::SeekFromBegin(pos_t)#Operation not supported."); - } - - void EncoderStream::SeekFromEnd(pos_t _size) - { - CHECK_FAIL(L"EncoderStream::SeekFromEnd(pos_t)#Operation not supported."); - } - - vint EncoderStream::Read(void* _buffer, vint _size) - { - CHECK_FAIL(L"EncoderStream::Read(void*, vint)#Operation not supported."); - } - - vint EncoderStream::Write(void* _buffer, vint _size) - { - vint result=encoder->Write(_buffer, _size); - if(result>=0) - { - position+=result; - } - return result; - } - - vint EncoderStream::Peek(void* _buffer, vint _size) - { - CHECK_FAIL(L"EncoderStream::Peek(void*, vint)#Operation not supported."); - } - -/*********************************************************************** -DecoderStream -***********************************************************************/ - - DecoderStream::DecoderStream(IStream& _stream, IDecoder& _decoder) - :stream(&_stream) - ,decoder(&_decoder) - ,position(0) - { - decoder->Setup(stream); - } - - DecoderStream::~DecoderStream() - { - Close(); - } - - bool DecoderStream::CanRead()const - { - return IsAvailable(); - } - - bool DecoderStream::CanWrite()const - { - return false; - } - - bool DecoderStream::CanSeek()const - { - return false; - } - - bool DecoderStream::CanPeek()const - { - return false; - } - - bool DecoderStream::IsLimited()const - { - return stream!=0 && stream->IsLimited(); - } - - bool DecoderStream::IsAvailable()const - { - return stream!=0 && stream->IsAvailable(); - } - - void DecoderStream::Close() - { - decoder->Close(); - stream=0; - } - - pos_t DecoderStream::Position()const - { - return IsAvailable()?position:-1; - } - - pos_t DecoderStream::Size()const - { - return -1; - } - - void DecoderStream::Seek(pos_t _size) - { - CHECK_FAIL(L"DecoderStream::Seek(pos_t)#Operation not supported."); - } - - void DecoderStream::SeekFromBegin(pos_t _size) - { - CHECK_FAIL(L"DecoderStream::SeekFromBegin(pos_t)#Operation not supported."); - } - - void DecoderStream::SeekFromEnd(pos_t _size) - { - CHECK_FAIL(L"DecoderStream::SeekFromEnd(pos_t)#Operation not supported."); - } - - vint DecoderStream::Read(void* _buffer, vint _size) - { - vint result=decoder->Read(_buffer, _size); - if(result>=0) - { - position+=result; - } - return result; - } - - vint DecoderStream::Write(void* _buffer, vint _size) - { - CHECK_FAIL(L"DecoderStream::Write(void*, vint)#Operation not supported."); - } - - vint DecoderStream::Peek(void* _buffer, vint _size) - { - CHECK_FAIL(L"DecoderStream::Peek(void*, vint)#Operation not supported."); - } - } -} - -/*********************************************************************** -STREAM\BROADCASTSTREAM.CPP +.\STREAM\BROADCASTSTREAM.CPP ***********************************************************************/ namespace vl @@ -24670,7 +26700,7 @@ BroadcastStream } /*********************************************************************** -STREAM\CACHESTREAM.CPP +.\STREAM\CACHESTREAM.CPP ***********************************************************************/ namespace vl @@ -24974,2014 +27004,7 @@ CacheStream } /*********************************************************************** -STREAM\CHARFORMAT.CPP -***********************************************************************/ -#if defined VCZH_MSVC -#elif defined VCZH_GCC -#endif - -namespace vl -{ - namespace stream - { - -/*********************************************************************** -CharEncoder -***********************************************************************/ - - CharEncoder::CharEncoder() - :stream(0) - ,cacheSize(0) - { - } - - void CharEncoder::Setup(IStream* _stream) - { - stream=_stream; - } - - void CharEncoder::Close() - { - } - - vint CharEncoder::Write(void* _buffer, vint _size) - { - const vint all=cacheSize+_size; - const vint chars=all/sizeof(wchar_t); - const vint bytes=chars*sizeof(wchar_t); - wchar_t* unicode=0; - bool needToFree=false; - vint result=0; - - if(chars) - { - if(cacheSize>0) - { - unicode=new wchar_t[chars]; - memcpy(unicode, cacheBuffer, cacheSize); - memcpy(((vuint8_t*)unicode)+cacheSize, _buffer, bytes-cacheSize); - needToFree=true; - } - else - { - unicode=(wchar_t*)_buffer; - } - result=WriteString(unicode, chars)*sizeof(wchar_t)-cacheSize; - cacheSize=0; - } - - if(needToFree) - { - delete[] unicode; - } - if(all-bytes>0) - { - cacheSize=all-bytes; - memcpy(cacheBuffer, (vuint8_t*)_buffer+_size-cacheSize, cacheSize); - result+=cacheSize; - } - return result; - } - -/*********************************************************************** -CharDecoder -***********************************************************************/ - - CharDecoder::CharDecoder() - :stream(0) - ,cacheSize(0) - { - } - - void CharDecoder::Setup(IStream* _stream) - { - stream=_stream; - } - - void CharDecoder::Close() - { - } - - vint CharDecoder::Read(void* _buffer, vint _size) - { - vuint8_t* unicode=(vuint8_t*)_buffer; - vint result=0; - { - vint index=0; - while(cacheSize>0 && _size>0) - { - *unicode++=cacheBuffer[index]++; - cacheSize--; - _size--; - result++; - } - } - - const vint chars=_size/sizeof(wchar_t); - vint bytes=ReadString((wchar_t*)unicode, chars)*sizeof(wchar_t); - result+=bytes; - _size-=bytes; - unicode+=bytes; - - if(_size>0) - { - wchar_t c; - if(ReadString(&c, 1)==1) - { - cacheSize=sizeof(wchar_t)-_size; - memcpy(unicode, &c, _size); - memcpy(cacheBuffer, (vuint8_t*)&c+_size, cacheSize); - result+=_size; - } - } - return result; - } - -/*********************************************************************** -Mbcs -***********************************************************************/ - - vint MbcsEncoder::WriteString(wchar_t* _buffer, vint chars) - { -#if defined VCZH_MSVC - vint length=WideCharToMultiByte(CP_THREAD_ACP, 0, _buffer, (int)chars, NULL, NULL, NULL, NULL); - char* mbcs=new char[length]; - WideCharToMultiByte(CP_THREAD_ACP, 0, _buffer, (int)chars, mbcs, (int)length, NULL, NULL); - vint result=stream->Write(mbcs, length); - delete[] mbcs; -#elif defined VCZH_GCC - WString w(_buffer, chars); - AString a=wtoa(w); - vint length=a.Length(); - vint result=stream->Write((void*)a.Buffer(), length); -#endif - if(result==length) - { - return chars; - } - else - { - Close(); - return 0; - } - } - - vint MbcsDecoder::ReadString(wchar_t* _buffer, vint chars) - { - char* source=new char[chars*2]; - char* reading=source; - vint readed=0; - while(readedRead(reading, 1)!=1) - { - break; - } -#if defined VCZH_MSVC - if(IsDBCSLeadByte(*reading)) -#elif defined VCZH_GCC - if((vint8_t)*reading<0) -#endif - { - if(stream->Read(reading+1, 1)!=1) - { - break; - } - reading+=2; - } - else - { - reading++; - } - readed++; - } -#if defined VCZH_MSVC - MultiByteToWideChar(CP_THREAD_ACP, 0, source, (int)(reading-source), _buffer, (int)chars); -#elif defined VCZH_GCC - AString a(source, (vint)(reading-source)); - WString w=atow(a); - memcpy(_buffer, w.Buffer(), readed*sizeof(wchar_t)); -#endif - delete[] source; - return readed; - } - -/*********************************************************************** -Utf-16 -***********************************************************************/ - - vint Utf16Encoder::WriteString(wchar_t* _buffer, vint chars) - { -#if defined VCZH_MSVC - return stream->Write(_buffer, chars*sizeof(wchar_t))/sizeof(wchar_t); -#elif defined VCZH_GCC - vint writed = 0; - vuint16_t utf16 = 0; - vuint8_t* utf16buf = (vuint8_t*)&utf16; - while (writed < chars) - { - wchar_t w = *_buffer++; - if (w < 0x10000) - { - utf16 = (vuint16_t)w; - if (stream->Write(&utf16buf[0], 1) != 1) break; - if (stream->Write(&utf16buf[1], 1) != 1) break; - } - else if (w < 0x110000) - { - wchar_t inc = w - 0x10000; - - utf16 = (vuint16_t)(inc / 0x400) + 0xD800; - if (stream->Write(&utf16buf[0], 1) != 1) break; - if (stream->Write(&utf16buf[1], 1) != 1) break; - - utf16 = (vuint16_t)(inc % 0x400) + 0xDC00; - if (stream->Write(&utf16buf[0], 1) != 1) break; - if (stream->Write(&utf16buf[1], 1) != 1) break; - } - else - { - break; - } - writed++; - } - if(writed!=chars) - { - Close(); - } - return writed; -#endif - } - - vint Utf16Decoder::ReadString(wchar_t* _buffer, vint chars) - { -#if defined VCZH_MSVC - return stream->Read(_buffer, chars*sizeof(wchar_t))/sizeof(wchar_t); -#elif defined VCZH_GCC - wchar_t* writing = _buffer; - while (writing - _buffer < chars) - { - vuint16_t utf16_1 = 0; - vuint16_t utf16_2 = 0; - - if (stream->Read(&utf16_1, 2) != 2) break; - if (utf16_1 < 0xD800 || utf16_1 > 0xDFFF) - { - *writing++ = (wchar_t)utf16_1; - } - else if (utf16_1 < 0xDC00) - { - if (stream->Read(&utf16_2, 2) != 2) break; - if (0xDC00 <= utf16_2 && utf16_2 <= 0xDFFF) - { - *writing++ = (wchar_t)(utf16_1 - 0xD800) * 0x400 + (wchar_t)(utf16_2 - 0xDC00) + 0x10000; - } - else - { - break; - } - } - else - { - break; - } - } - return writing - _buffer; -#endif - } - -/*********************************************************************** -Utf-16-be -***********************************************************************/ - - vint Utf16BEEncoder::WriteString(wchar_t* _buffer, vint chars) - { -#if defined VCZH_MSVC - vint writed=0; - while(writedWrite(((unsigned char*)_buffer)+1, 1)!=1) - { - break; - } - if(stream->Write(_buffer, 1)!=1) - { - break; - } - _buffer++; - writed++; - } - if(writed!=chars) - { - Close(); - } - return writed; -#elif defined VCZH_GCC - vint writed = 0; - vuint16_t utf16 = 0; - vuint8_t* utf16buf = (vuint8_t*)&utf16; - while (writed < chars) - { - wchar_t w = *_buffer++; - if (w < 0x10000) - { - utf16 = (vuint16_t)w; - if (stream->Write(&utf16buf[1], 1) != 1) break; - if (stream->Write(&utf16buf[0], 1) != 1) break; - } - else if (w < 0x110000) - { - wchar_t inc = w - 0x10000; - - utf16 = (vuint16_t)(inc / 0x400) + 0xD800; - if (stream->Write(&utf16buf[1], 1) != 1) break; - if (stream->Write(&utf16buf[0], 1) != 1) break; - - utf16 = (vuint16_t)(inc % 0x400) + 0xDC00; - if (stream->Write(&utf16buf[1], 1) != 1) break; - if (stream->Write(&utf16buf[0], 1) != 1) break; - } - else - { - break; - } - writed++; - } - if(writed!=chars) - { - Close(); - } - return writed; -#endif - } - - vint Utf16BEDecoder::ReadString(wchar_t* _buffer, vint chars) - { -#if defined VCZH_MSVC - chars=stream->Read(_buffer, chars*sizeof(wchar_t))/sizeof(wchar_t); - unsigned char* unicode=(unsigned char*)_buffer; - for(vint i=0;iRead(&utf16_1, 2) != 2) break; - - utf16buf = (vuint8_t*)&utf16_1; - utf16buf_temp = utf16buf[0]; - utf16buf[0] = utf16buf[1]; - utf16buf[1] = utf16buf_temp; - - if (utf16_1 < 0xD800 || utf16_1 > 0xDFFF) - { - *writing++ = (wchar_t)utf16_1; - } - else if (utf16_1 < 0xDC00) - { - if (stream->Read(&utf16_2, 2) != 2) break; - - utf16buf = (vuint8_t*)&utf16_2; - utf16buf_temp = utf16buf[0]; - utf16buf[0] = utf16buf[1]; - utf16buf[1] = utf16buf_temp; - - if (0xDC00 <= utf16_2 && utf16_2 <= 0xDFFF) - { - *writing++ = (wchar_t)(utf16_1 - 0xD800) * 0x400 + (wchar_t)(utf16_2 - 0xDC00) + 0x10000; - } - else - { - break; - } - } - else - { - break; - } - } - return writing - _buffer; -#endif - } - -/*********************************************************************** -Utf8 -***********************************************************************/ - - vint Utf8Encoder::WriteString(wchar_t* _buffer, vint chars) - { -#if defined VCZH_MSVC - vint length=WideCharToMultiByte(CP_UTF8, 0, _buffer, (int)chars, NULL, NULL, NULL, NULL); - char* mbcs=new char[length]; - WideCharToMultiByte(CP_UTF8, 0, _buffer, (int)chars, mbcs, (int)length, NULL, NULL); - vint result=stream->Write(mbcs, length); - delete[] mbcs; - if(result==length) - { - return chars; - } - else - { - Close(); - return 0; - } -#elif defined VCZH_GCC - vint writed = 0; - while (writed < chars) - { - wchar_t w = *_buffer++; - vuint8_t utf8[4]; - if (w < 0x80) - { - utf8[0] = (vuint8_t)w; - if (stream->Write(utf8, 1) != 1) break; - } - else if (w < 0x800) - { - utf8[0] = 0xC0 + ((w & 0x7C0) >> 6); - utf8[1] = 0x80 + (w & 0x3F); - if (stream->Write(utf8, 2) != 2) break; - } - else if (w < 0x10000) - { - utf8[0] = 0xE0 + ((w & 0xF000) >> 12); - utf8[1] = 0x80 + ((w & 0xFC0) >> 6); - utf8[2] = 0x80 + (w & 0x3F); - if (stream->Write(utf8, 3) != 3) break; - } - else if (w < 0x110000) // only accept UTF-16 range - { - utf8[0] = 0xF0 + ((w & 0x1C0000) >> 18); - utf8[1] = 0x80 + ((w & 0x3F000) >> 12); - utf8[2] = 0x80 + ((w & 0xFC0) >> 6); - utf8[3] = 0x80 + (w & 0x3F); - if (stream->Write(utf8, 4) != 4) break; - } - else - { - break; - } - writed++; - } - if(writed!=chars) - { - Close(); - } - return writed; -#endif - } - - Utf8Decoder::Utf8Decoder() -#if defined VCZH_MSVC - :cache(0) - ,cacheAvailable(false) -#endif - { - } - - vint Utf8Decoder::ReadString(wchar_t* _buffer, vint chars) - { - vuint8_t source[4]; -#if defined VCZH_MSVC - wchar_t target[2]; -#endif - wchar_t* writing=_buffer; - vint readed=0; - vint sourceCount=0; - - while(readedRead(source, 1)!=1) - { - break; - } - if((*source & 0xF0) == 0xF0) - { - if(stream->Read(source+1, 3)!=3) - { - break; - } - sourceCount=4; - } - else if((*source & 0xE0) == 0xE0) - { - if(stream->Read(source+1, 2)!=2) - { - break; - } - sourceCount=3; - } - else if((*source & 0xC0) == 0xC0) - { - if(stream->Read(source+1, 1)!=1) - { - break; - } - sourceCount=2; - } - else - { - sourceCount=1; - } -#if defined VCZH_MSVC - int targetCount=MultiByteToWideChar(CP_UTF8, 0, (char*)source, (int)sourceCount, target, 2); - if(targetCount==1) - { - *writing++=target[0]; - } - else if(targetCount==2) - { - *writing++=target[0]; - cache=target[1]; - cacheAvailable=true; - } - else - { - break; - } - } -#elif defined VCZH_GCC - if (sourceCount == 1) - { - *writing++ = (wchar_t)source[0]; - } - else if (sourceCount == 2) - { - *writing++ = (((wchar_t)source[0] & 0x1F) << 6) + ((wchar_t)source[1] & 0x3F); - } - else if (sourceCount == 3) - { - *writing++ = (((wchar_t)source[0] & 0xF) << 12) + (((wchar_t)source[1] & 0x3F) << 6) + ((wchar_t)source[2] & 0x3F); - } - else if (sourceCount == 4) - { - *writing++ = (((wchar_t)source[0] & 0x7) << 18) + (((wchar_t)source[1] & 0x3F) << 12) + (((wchar_t)source[2] & 0x3F) << 6) + ((wchar_t)source[3] & 0x3F); - } - else - { - break; - } -#endif - readed++; - } - return readed; - } - -/*********************************************************************** -BomEncoder -***********************************************************************/ - - BomEncoder::BomEncoder(Encoding _encoding) - :encoding(_encoding) - ,encoder(0) - { - switch(encoding) - { - case Mbcs: - encoder=new MbcsEncoder; - break; - case Utf8: - encoder=new Utf8Encoder; - break; - case Utf16: - encoder=new Utf16Encoder; - break; - case Utf16BE: - encoder=new Utf16BEEncoder; - break; - } - } - - BomEncoder::~BomEncoder() - { - Close(); - } - - void BomEncoder::Setup(IStream* _stream) - { - switch(encoding) - { - case Mbcs: - break; - case Utf8: - _stream->Write((void*)"\xEF\xBB\xBF", 3); - break; - case Utf16: - _stream->Write((void*)"\xFF\xFE", 2); - break; - case Utf16BE: - _stream->Write((void*)"\xFE\xFF", 2); - break; - } - encoder->Setup(_stream); - } - - void BomEncoder::Close() - { - if(encoder) - { - encoder->Close(); - delete encoder; - encoder=0; - } - } - - vint BomEncoder::Write(void* _buffer, vint _size) - { - return encoder->Write(_buffer, _size); - } - -/*********************************************************************** -BomDecoder -***********************************************************************/ - - BomDecoder::BomStream::BomStream(IStream* _stream, char* _bom, vint _bomLength) - :stream(_stream) - ,bomPosition(0) - ,bomLength(_bomLength) - { - memcpy(bom, _bom, bomLength); - } - - bool BomDecoder::BomStream::CanRead()const - { - return IsAvailable(); - } - - bool BomDecoder::BomStream::CanWrite()const - { - return false; - } - - bool BomDecoder::BomStream::CanSeek()const - { - return false; - } - - bool BomDecoder::BomStream::CanPeek()const - { - return false; - } - - bool BomDecoder::BomStream::IsLimited()const - { - return stream!=0 && stream->IsLimited(); - } - - bool BomDecoder::BomStream::IsAvailable()const - { - return stream!=0 && stream->IsAvailable(); - } - - void BomDecoder::BomStream::Close() - { - stream=0; - } - - pos_t BomDecoder::BomStream::Position()const - { - return IsAvailable()?bomPosition+stream->Position():-1; - } - - pos_t BomDecoder::BomStream::Size()const - { - return -1; - } - - void BomDecoder::BomStream::Seek(pos_t _size) - { - CHECK_FAIL(L"BomDecoder::BomStream::Seek(pos_t)#Operation not supported."); - } - - void BomDecoder::BomStream::SeekFromBegin(pos_t _size) - { - CHECK_FAIL(L"BomDecoder::BomStream::SeekFromBegin(pos_t)#Operation not supported."); - } - - void BomDecoder::BomStream::SeekFromEnd(pos_t _size) - { - CHECK_FAIL(L"BomDecoder::BomStream::SeekFromEnd(pos_t)#Operation not supported."); - } - - vint BomDecoder::BomStream::Read(void* _buffer, vint _size) - { - vint result=0; - unsigned char* buffer=(unsigned char*)_buffer; - if(bomPositionRead(buffer, _size); - } - return result; - } - - vint BomDecoder::BomStream::Write(void* _buffer, vint _size) - { - CHECK_FAIL(L"BomDecoder::BomStream::Write(void*, vint)#Operation not supported."); - } - - vint BomDecoder::BomStream::Peek(void* _buffer, vint _size) - { - CHECK_FAIL(L"BomDecoder::BomStream::Peek(void*, vint)#Operation not supported."); - } - - BomDecoder::BomDecoder() - :decoder(0) - { - } - - BomDecoder::~BomDecoder() - { - Close(); - } - - void BomDecoder::Setup(IStream* _stream) - { - char bom[3]={0}; - vint length=_stream->Read(bom, sizeof(bom)); - if(strncmp(bom, "\xEF\xBB\xBF", 3)==0) - { - decoder=new Utf8Decoder; - stream=new BomStream(_stream, bom+3, 0); - } - else if(strncmp(bom, "\xFF\xFE", 2)==0) - { - decoder=new Utf16Decoder; - stream=new BomStream(_stream, bom+2, 1); - } - else if(strncmp(bom, "\xFE\xFF", 2)==0) - { - decoder=new Utf16BEDecoder; - stream=new BomStream(_stream, bom+2, 1); - } - else - { - decoder=new MbcsDecoder; - stream=new BomStream(_stream, bom, 3); - } - decoder->Setup(stream); - } - - void BomDecoder::Close() - { - if(decoder) - { - decoder->Close(); - delete decoder; - decoder=0; - stream->Close(); - delete stream; - stream=0; - } - } - - vint BomDecoder::Read(void* _buffer, vint _size) - { - return decoder->Read(_buffer, _size); - } - -/*********************************************************************** -CharEncoder -***********************************************************************/ - - bool CanBeMbcs(unsigned char* buffer, vint size) - { - for(vint i=0;i - bool GetEncodingResult(int(&tests)[Count], bool(&results)[Count], int test) - { - for (vint i = 0; i < Count; i++) - { - if (tests[i] & test) - { - if (results[i]) return true; - } - } - return false; - } -#endif - - void TestEncoding(unsigned char* buffer, vint size, BomEncoder::Encoding& encoding, bool& containsBom) - { - if (size >= 3 && strncmp((char*)buffer, "\xEF\xBB\xBF", 3) == 0) - { - encoding = BomEncoder::Utf8; - containsBom = true; - } - else if (size >= 2 && strncmp((char*)buffer, "\xFF\xFE", 2) == 0) - { - encoding = BomEncoder::Utf16; - containsBom = true; - } - else if (size >= 2 && strncmp((char*)buffer, "\xFE\xFF", 2) == 0) - { - encoding = BomEncoder::Utf16BE; - containsBom = true; - } - else - { - encoding = BomEncoder::Mbcs; - containsBom = false; - - bool utf16HitSurrogatePairs = false; - bool utf16BEHitSurrogatePairs = false; - bool roughMbcs = CanBeMbcs(buffer, size); - bool roughUtf8 = CanBeUtf8(buffer, size); - bool roughUtf16 = CanBeUtf16(buffer, size, utf16HitSurrogatePairs); - bool roughUtf16BE = CanBeUtf16BE(buffer, size, utf16BEHitSurrogatePairs); - - vint roughCount = (roughMbcs ? 1 : 0) + (roughUtf8 ? 1 : 0) + (roughUtf16 ? 1 : 0) + (roughUtf16BE ? 1 : 0); - if (roughCount == 1) - { - if (roughUtf8) encoding = BomEncoder::Utf8; - else if (roughUtf16) encoding = BomEncoder::Utf16; - else if (roughUtf16BE) encoding = BomEncoder::Utf16BE; - } - else if (roughCount > 1) - { -#if defined VCZH_MSVC - int tests[] = - { - IS_TEXT_UNICODE_REVERSE_ASCII16, - IS_TEXT_UNICODE_REVERSE_STATISTICS, - IS_TEXT_UNICODE_REVERSE_CONTROLS, - - IS_TEXT_UNICODE_ASCII16, - IS_TEXT_UNICODE_STATISTICS, - IS_TEXT_UNICODE_CONTROLS, - - IS_TEXT_UNICODE_ILLEGAL_CHARS, - IS_TEXT_UNICODE_ODD_LENGTH, - IS_TEXT_UNICODE_NULL_BYTES, - }; - - const vint TestCount = sizeof(tests) / sizeof(*tests); - bool results[TestCount]; - for (vint i = 0; i < TestCount; i++) - { - int test = tests[i]; - results[i] = IsTextUnicode(buffer, (int)size, &test) != 0; - } - - if (size % 2 == 0 - && !GetEncodingResult(tests, results, IS_TEXT_UNICODE_REVERSE_ASCII16) - && !GetEncodingResult(tests, results, IS_TEXT_UNICODE_REVERSE_STATISTICS) - && !GetEncodingResult(tests, results, IS_TEXT_UNICODE_REVERSE_CONTROLS) - ) - { - for (vint i = 0; i < size; i += 2) - { - unsigned char c = buffer[i]; - buffer[i] = buffer[i + 1]; - buffer[i + 1] = c; - } - // 3 = (count of reverse group) = (count of unicode group) - for (vint i = 0; i < 3; i++) - { - int test = tests[i + 3]; - results[i] = IsTextUnicode(buffer, (int)size, &test) != 0; - } - for (vint i = 0; i < size; i += 2) - { - unsigned char c = buffer[i]; - buffer[i] = buffer[i + 1]; - buffer[i + 1] = c; - } - } - - if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_NOT_UNICODE_MASK)) - { - if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_NOT_ASCII_MASK)) - { - encoding = BomEncoder::Utf8; - } - else if (roughUtf8 || !roughMbcs) - { - encoding = BomEncoder::Utf8; - } - } - else if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_ASCII16)) - { - encoding = BomEncoder::Utf16; - } - else if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_REVERSE_ASCII16)) - { - encoding = BomEncoder::Utf16BE; - } - else if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_CONTROLS)) - { - encoding = BomEncoder::Utf16; - } - else if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_REVERSE_CONTROLS)) - { - encoding = BomEncoder::Utf16BE; - } - else - { - if (!roughUtf8) - { - if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_STATISTICS)) - { - encoding = BomEncoder::Utf16; - } - else if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_STATISTICS)) - { - encoding = BomEncoder::Utf16BE; - } - } - else if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_NOT_UNICODE_MASK)) - { - encoding = BomEncoder::Utf8; - } - else if (roughUtf8 || !roughMbcs) - { - encoding = BomEncoder::Utf8; - } - } -#elif defined VCZH_GCC - if (roughUtf16 && roughUtf16BE && !roughUtf8) - { - if (utf16BEHitSurrogatePairs && !utf16HitSurrogatePairs) - { - encoding = BomEncoder::Utf16BE; - } - else - { - encoding = BomEncoder::Utf16; - } - } - else - { - encoding = BomEncoder::Utf8; - } -#endif - } - } - } - } -} - -/*********************************************************************** -STREAM\COMPRESSIONSTREAM.CPP -***********************************************************************/ - -namespace vl -{ - namespace stream - { - using namespace lzw; - -/*********************************************************************** -LzwBase -***********************************************************************/ - - void LzwBase::UpdateIndexBits() - { - if (nextIndex >=2 && (nextIndex & (nextIndex - 1)) == 0) - { - indexBits++; - } - } - - lzw::Code* LzwBase::CreateCode(lzw::Code* prefix, vuint8_t byte) - { - if (nextIndex < MaxDictionarySize) - { - Code* code = codeAllocator.Create(); - code->byte = byte; - code->code = nextIndex; - code->parent = prefix; - code->size = prefix->size + 1; - prefix->children.Set(byte, code, mapAllocator); - nextIndex++; - - return code; - } - else - { - return 0; - } - } - - LzwBase::LzwBase() - :codeAllocator(65536) - , mapAllocator(1048576) - { - root = codeAllocator.Create(); - - for (vint i = 0; i < 256; i++) - { - UpdateIndexBits(); - CreateCode(root, (vuint8_t)i); - } - } - - LzwBase::LzwBase(bool (&existingBytes)[256]) - { - root = codeAllocator.Create(); - for (vint i = 0; i < 256; i++) - { - if (existingBytes[i]) - { - UpdateIndexBits(); - CreateCode(root, (vuint8_t)i); - } - } - - if (indexBits < 8) - { - eofIndex = nextIndex++; - } - } - - LzwBase::~LzwBase() - { - } - -/*********************************************************************** -LzwEncoder -***********************************************************************/ - - void LzwEncoder::Flush() - { - vint written = 0; - vint bufferUsedSize = bufferUsedBits / 8; - if (bufferUsedBits % 8 != 0) - { - bufferUsedSize++; - } - while (written < bufferUsedSize) - { - vint size = stream->Write(buffer + written, bufferUsedSize - written); - CHECK_ERROR(size != 0, L"LzwEncoder::Flush()#Failed to flush the lzw buffer."); - written += size; - } - bufferUsedBits = 0; - } - - vuint8_t highMarks[9] = { 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF }; - vuint8_t lowMarks[9] = { 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF }; - - void LzwEncoder::WriteNumber(vint number, vint bitSize) - { - vint bitStart = 0; - vint bitStep = 8 - bufferUsedBits % 8; - if (bitStep > bitSize) - { - bitStep = bitSize; - } - while (bitStart < bitSize) - { - if(bufferUsedBits == BufferSize * 8) - { - Flush(); - } - - vint writeStart = bufferUsedBits % 8; - vint byteIndex = bufferUsedBits / 8; - vuint8_t byte = buffer[byteIndex]; - byte &= highMarks[writeStart]; - - vuint8_t content = (vuint8_t)((number >> bitStart)&lowMarks[bitStep]) << (8 - writeStart - bitStep); - byte |= content; - - buffer[byteIndex] = byte; - bufferUsedBits += bitStep; - - bitStart += bitStep; - vint remain = bitSize - bitStart; - bitStep = remain < 8 ? remain : 8; - } - } - - LzwEncoder::LzwEncoder() - { - prefix = root; - } - - LzwEncoder::LzwEncoder(bool (&existingBytes)[256]) - :LzwBase(existingBytes) - { - prefix = root; - } - - LzwEncoder::~LzwEncoder() - { - } - - void LzwEncoder::Setup(IStream* _stream) - { - stream = _stream; - } - - void LzwEncoder::Close() - { - if (prefix != root) - { - WriteNumber(prefix->code, indexBits); - prefix = root; - } - - vint remain = 8 - bufferUsedBits % 8; - if (remain != 8 && remain >= indexBits) - { - CHECK_ERROR(eofIndex != -1, L"LzwEncoder::Close()#Internal error."); - WriteNumber(eofIndex, indexBits); - } - Flush(); - } - - vint LzwEncoder::Write(void* _buffer, vint _size) - { - vuint8_t* bytes = (vuint8_t*)_buffer; - for (vint i = 0; i < _size; i++) - { - vuint8_t byte = bytes[i]; - Code* next = prefix->children.Get(byte); - if (next) - { - prefix = next; - } - else - { - WriteNumber(prefix->code, indexBits); - - if (nextIndex < MaxDictionarySize) - { - UpdateIndexBits(); - CreateCode(prefix, byte); - } - prefix = root->children.Get(byte); - } - } - return _size; - } - -/*********************************************************************** -LzwDecoder -***********************************************************************/ - - bool LzwDecoder::ReadNumber(vint& number, vint bitSize) - { - number = 0; - if (inputBufferSize == -1) - { - return false; - } - - vint remainBits = inputBufferSize * 8 - inputBufferUsedBits; - vint writtenBits = 0; - vint bitStep = 8 - inputBufferUsedBits % 8; - if (bitStep > bitSize) - { - bitStep = bitSize; - } - while (writtenBits < bitSize) - { - if (remainBits == 0) - { - inputBufferSize = stream->Read(inputBuffer, BufferSize); - if (inputBufferSize == 0) - { - inputBufferSize = -1; - return false; - } - remainBits = inputBufferSize * 8; - inputBufferUsedBits = 0; - } - - vuint8_t byte = inputBuffer[inputBufferUsedBits / 8]; - byte >>= (8 - inputBufferUsedBits % 8 - bitStep); - byte &= lowMarks[bitStep]; - number |= byte << writtenBits; - - inputBufferUsedBits += bitStep; - remainBits -= bitStep; - writtenBits += bitStep; - vint remain = bitSize - writtenBits; - bitStep = remain < 8 ? remain : 8; - } - - return true; - } - - void LzwDecoder::PrepareOutputBuffer(vint size) - { - if (outputBuffer.Count() < size) - { - outputBuffer.Resize(size); - } - outputBufferSize = size; - } - - void LzwDecoder::ExpandCodeToOutputBuffer(lzw::Code* code) - { - vuint8_t* outputByte = &outputBuffer[0] + code->size; - Code* current = code; - while (current != root) - { - *(--outputByte) = current->byte; - current = current->parent; - } - outputBufferUsedBytes = 0; - } - - LzwDecoder::LzwDecoder() - { - for (vint i = 0; i < 256; i++) - { - dictionary.Add(root->children.Get((vuint8_t)i)); - } - } - - LzwDecoder::LzwDecoder(bool (&existingBytes)[256]) - :LzwBase(existingBytes) - { - for (vint i = 0; i < 256; i++) - { - if (existingBytes[i]) - { - dictionary.Add(root->children.Get((vuint8_t)i)); - } - } - if (eofIndex != -1) - { - dictionary.Add(0); - } - } - - LzwDecoder::~LzwDecoder() - { - } - - void LzwDecoder::Setup(IStream* _stream) - { - stream = _stream; - } - - void LzwDecoder::Close() - { - } - - vint LzwDecoder::Read(void* _buffer, vint _size) - { - vint written = 0; - vuint8_t* bytes = (vuint8_t*)_buffer; - while (written < _size) - { - vint expect = _size - written; - vint remain = outputBufferSize - outputBufferUsedBytes; - if (remain == 0) - { - vint index = 0; - if (!ReadNumber(index, indexBits) || index == eofIndex) - { - break; - } - - Code* prefix = 0; - if (index == dictionary.Count()) - { - prefix = lastCode; - PrepareOutputBuffer(prefix->size + 1); - ExpandCodeToOutputBuffer(prefix); - outputBuffer[outputBufferSize - 1] = outputBuffer[0]; - } - else - { - prefix = dictionary[index]; - PrepareOutputBuffer(prefix->size); - ExpandCodeToOutputBuffer(prefix); - } - - if (nextIndex < MaxDictionarySize) - { - if (lastCode) - { - dictionary.Add(CreateCode(lastCode, outputBuffer[0])); - } - UpdateIndexBits(); - } - lastCode = dictionary[index]; - } - else - { - if (remain > expect) - { - remain = expect; - } - memcpy(bytes + written, &outputBuffer[outputBufferUsedBytes], remain); - - outputBufferUsedBytes += remain; - written += remain; - } - } - return written; - } - } -} - -/*********************************************************************** -STREAM\FILESTREAM.CPP -***********************************************************************/ -#if defined VCZH_GCC -#endif - -namespace vl -{ - namespace stream - { - -#if defined VCZH_GCC - void _fseeki64(FILE* file, pos_t offset, int origin) - { - fseek(file, (long)offset, origin); - } -#endif - -/*********************************************************************** -FileStream -***********************************************************************/ - - FileStream::FileStream(const WString& fileName, AccessRight _accessRight) - :accessRight(_accessRight) - { - const wchar_t* mode=L"rb"; - switch(accessRight) - { - case ReadOnly: - mode=L"rb"; - break; - case WriteOnly: - mode=L"wb"; - break; - case ReadWrite: - mode=L"w+b"; - break; - } - -#if defined VCZH_MSVC - if(_wfopen_s(&file, fileName.Buffer(), mode)!=0) - { - file=0; - } -#elif defined VCZH_GCC - AString fileNameA = wtoa(fileName); - AString modeA = wtoa(mode); - file = fopen(fileNameA.Buffer(), modeA.Buffer()); -#endif - } - - FileStream::~FileStream() - { - Close(); - } - - bool FileStream::CanRead()const - { - return file!=0 && (accessRight==ReadOnly || accessRight==ReadWrite); - } - - bool FileStream::CanWrite()const - { - return file!=0 && (accessRight==WriteOnly || accessRight==ReadWrite); - } - - bool FileStream::CanSeek()const - { - return file!=0; - } - - bool FileStream::CanPeek()const - { - return file!=0 && (accessRight==ReadOnly || accessRight==ReadWrite); - } - - bool FileStream::IsLimited()const - { - return file!=0 && accessRight==ReadOnly; - } - - bool FileStream::IsAvailable()const - { - return file!=0; - } - - void FileStream::Close() - { - if(file!=0) - { - fclose(file); - file=0; - } - } - - pos_t FileStream::Position()const - { - if(file!=0) - { -#if defined VCZH_MSVC - fpos_t position=0; - if(fgetpos(file, &position)==0) - { - return position; - } -#elif defined VCZH_GCC - return (pos_t)ftell(file); -#endif - } - return -1; - } - - pos_t FileStream::Size()const - { - if(file!=0) - { -#if defined VCZH_MSVC - fpos_t position=0; - if(fgetpos(file, &position)==0) - { - if(fseek(file, 0, SEEK_END)==0) - { - pos_t size=Position(); - if(fsetpos(file, &position)==0) - { - return size; - } - } - } -#elif defined VCZH_GCC - long position = ftell(file); - fseek(file, 0, SEEK_END); - long size=ftell(file); - fseek(file, position, SEEK_SET); - return (pos_t)size; -#endif - } - return -1; - } - - void FileStream::Seek(pos_t _size) - { - if(Position()+_size>Size()) - { - _fseeki64(file, 0, SEEK_END); - } - else if(Position()+_size<0) - { - _fseeki64(file, 0, SEEK_SET); - } - else - { - _fseeki64(file, _size, SEEK_CUR); - } - } - - void FileStream::SeekFromBegin(pos_t _size) - { - if(_size>Size()) - { - _fseeki64(file, 0, SEEK_END); - } - else if(_size<0) - { - _fseeki64(file, 0, SEEK_SET); - } - else - { - _fseeki64(file, _size, SEEK_SET); - } - } - - void FileStream::SeekFromEnd(pos_t _size) - { - if(_size<0) - { - _fseeki64(file, 0, SEEK_END); - } - else if(_size>Size()) - { - _fseeki64(file, 0, SEEK_SET); - } - else - { - _fseeki64(file, -_size, SEEK_END); - } - } - - vint FileStream::Read(void* _buffer, vint _size) - { - CHECK_ERROR(file!=0, L"FileStream::Read(pos_t)#Stream is closed, cannot perform this operation."); - CHECK_ERROR(_size>=0, L"FileStream::Read(void*, vint)#Argument size cannot be negative."); - return fread(_buffer, 1, _size, file); - } - - vint FileStream::Write(void* _buffer, vint _size) - { - CHECK_ERROR(file!=0, L"FileStream::Write(pos_t)#Stream is closed, cannot perform this operation."); - CHECK_ERROR(_size>=0, L"FileStream::Write(void*, vint)#Argument size cannot be negative."); - return fwrite(_buffer, 1, _size, file); - } - - vint FileStream::Peek(void* _buffer, vint _size) - { - CHECK_ERROR(file!=0, L"FileStream::Peek(pos_t)#Stream is closed, cannot perform this operation."); - CHECK_ERROR(_size>=0, L"FileStream::Peek(void*, vint)#Argument size cannot be negative."); -#if defined VCZH_MSVC - fpos_t position=0; - if(fgetpos(file, &position)==0) - { - size_t count=fread(_buffer, 1, _size, file); - if(fsetpos(file, &position)==0) - { - return count; - } - } - return -1; -#elif defined VCZH_GCC - long position=ftell(file); - size_t count=fread(_buffer, 1, _size, file); - fseek(file, position, SEEK_SET); - return count; -#endif - } - } -} - -/*********************************************************************** -STREAM\MEMORYSTREAM.CPP -***********************************************************************/ - -namespace vl -{ - namespace stream - { -/*********************************************************************** -MemoryStream -***********************************************************************/ - - void MemoryStream::PrepareSpace(vint totalSpace) - { - if(totalSpace>capacity) - { - totalSpace=(totalSpace/block+1)*block; - char* newBuffer=new char[totalSpace]; - if(buffer) - { - memcpy(newBuffer, buffer, size); - delete[] buffer; - } - buffer=newBuffer; - capacity=totalSpace; - } - } - - MemoryStream::MemoryStream(vint _block) - :block(_block) - ,buffer(0) - ,size(0) - ,position(0) - ,capacity(0) - { - if(block<=0) - { - block=65536; - } - } - - MemoryStream::~MemoryStream() - { - Close(); - } - - bool MemoryStream::CanRead()const - { - return block!=0; - } - - bool MemoryStream::CanWrite()const - { - return block!=0; - } - - bool MemoryStream::CanSeek()const - { - return block!=0; - } - - bool MemoryStream::CanPeek()const - { - return block!=0; - } - - bool MemoryStream::IsLimited()const - { - return false; - } - - bool MemoryStream::IsAvailable()const - { - return block!=0; - } - - void MemoryStream::Close() - { - if(buffer) - { - delete[] buffer; - } - block=0; - buffer=0; - size=-1; - position=-1; - capacity=0; - } - - pos_t MemoryStream::Position()const - { - return position; - } - - pos_t MemoryStream::Size()const - { - return size; - } - - void MemoryStream::Seek(pos_t _size) - { - SeekFromBegin(position+_size); - } - - void MemoryStream::SeekFromBegin(pos_t _size) - { - CHECK_ERROR(block!=0, L"MemoryStream::SeekFromBegin(pos_t)#Stream is closed, cannot perform this operation."); - vint expected=(vint)_size; - if(expected<0) - { - position=0; - } - else if(expected>=size) - { - position=size; - } - else - { - position=expected; - } - } - - void MemoryStream::SeekFromEnd(pos_t _size) - { - SeekFromBegin(size-_size); - } - - vint MemoryStream::Read(void* _buffer, vint _size) - { - CHECK_ERROR(block!=0, L"MemoryStream::Read(pos_t)#Stream is closed, cannot perform this operation."); - CHECK_ERROR(_size>=0, L"MemoryStream::Read(void*, vint)#Argument size cannot be negative."); - vint max=size-position; - if(_size>max) - { - _size=max; - } - memmove(_buffer, buffer+position, _size); - position+=_size; - return _size; - } - - vint MemoryStream::Write(void* _buffer, vint _size) - { - CHECK_ERROR(block!=0, L"MemoryStream::Write(pos_t)#Stream is closed, cannot perform this operation."); - CHECK_ERROR(_size>=0, L"MemoryStream::Write(void*, vint)#Argument size cannot be negative."); - PrepareSpace(size+_size); - memmove(buffer+position, _buffer, _size); - position+=_size; - if(size=0, L"MemoryStream::Peek(void*, vint)#Argument size cannot be negative."); - vint max=size-position; - if(_size>max) - { - _size=max; - } - memmove(_buffer, buffer+position, _size); - return _size; - } - - void* MemoryStream::GetInternalBuffer() - { - return buffer; - } - } -} - -/*********************************************************************** -STREAM\MEMORYWRAPPERSTREAM.CPP -***********************************************************************/ - -namespace vl -{ - namespace stream - { -/*********************************************************************** -MemoryWrapperStream -***********************************************************************/ - - MemoryWrapperStream::MemoryWrapperStream(void* _buffer, vint _size) - :buffer((char*)_buffer) - ,size(_size) - ,position(0) - { - if(size<=0) - { - buffer=0; - size=0; - } - } - - MemoryWrapperStream::~MemoryWrapperStream() - { - } - - bool MemoryWrapperStream::CanRead()const - { - return buffer!=0; - } - - bool MemoryWrapperStream::CanWrite()const - { - return buffer!=0; - } - - bool MemoryWrapperStream::CanSeek()const - { - return buffer!=0; - } - - bool MemoryWrapperStream::CanPeek()const - { - return buffer!=0; - } - - bool MemoryWrapperStream::IsLimited()const - { - return buffer!=0; - } - - bool MemoryWrapperStream::IsAvailable()const - { - return buffer!=0; - } - - void MemoryWrapperStream::Close() - { - buffer=0; - size=-1; - position=-1; - } - - pos_t MemoryWrapperStream::Position()const - { - return position; - } - - pos_t MemoryWrapperStream::Size()const - { - return size; - } - - void MemoryWrapperStream::Seek(pos_t _size) - { - SeekFromBegin(position+_size); - } - - void MemoryWrapperStream::SeekFromBegin(pos_t _size) - { - CHECK_ERROR(buffer!=0, L"MemoryWrapperStream::SeekFromBegin(pos_t)#Stream is closed, cannot perform this operation."); - vint expected=(vint)_size; - if(expected<0) - { - position=0; - } - else if(expected>=size) - { - position=size; - } - else - { - position=expected; - } - } - - void MemoryWrapperStream::SeekFromEnd(pos_t _size) - { - SeekFromBegin(size-_size); - } - - vint MemoryWrapperStream::Read(void* _buffer, vint _size) - { - CHECK_ERROR(buffer!=0, L"MemoryWrapperStream::Read(pos_t)#Stream is closed, cannot perform this operation."); - CHECK_ERROR(_size>=0, L"MemoryWrapperStream::Read(void*, vint)#Argument size cannot be negative."); - vint max=size-position; - if(_size>max) - { - _size=max; - } - memmove(_buffer, buffer+position, _size); - position+=_size; - return _size; - } - - vint MemoryWrapperStream::Write(void* _buffer, vint _size) - { - CHECK_ERROR(buffer!=0, L"MemoryWrapperStream::Write(pos_t)#Stream is closed, cannot perform this operation."); - CHECK_ERROR(_size>=0, L"MemoryWrapperStream::Write(void*, vint)#Argument size cannot be negative."); - vint max=size-position; - if(_size>max) - { - _size=max; - } - memmove(buffer+position, _buffer, _size); - position+=_size; - return _size; - } - - vint MemoryWrapperStream::Peek(void* _buffer, vint _size) - { - CHECK_ERROR(buffer!=0, L"MemoryWrapperStream::Peek(pos_t)#Stream is closed, cannot perform this operation."); - CHECK_ERROR(_size>=0, L"MemoryWrapperStream::Peek(void*, vint)#Argument size cannot be negative."); - vint max=size-position; - if(_size>max) - { - _size=max; - } - memmove(_buffer, buffer+position, _size); - return _size; - } - } -} - -/*********************************************************************** -STREAM\RECORDERSTREAM.CPP +.\STREAM\RECORDERSTREAM.CPP ***********************************************************************/ namespace vl @@ -27083,7 +27106,7 @@ RecorderStream } /*********************************************************************** -UNITTEST\UNITTEST.CPP +.\UNITTEST\UNITTEST.CPP ***********************************************************************/ #if defined VCZH_MSVC #endif @@ -27164,3 +27187,4 @@ UnitTest } } } + diff --git a/Import/Vlpp.h b/Import/Vlpp.h index 8e377857..4ca24abe 100644 --- a/Import/Vlpp.h +++ b/Import/Vlpp.h @@ -4,7 +4,7 @@ DEVELOPER: Zihan Chen(vczh) ***********************************************************************/ /*********************************************************************** -BASIC.H +.\BASIC.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -736,684 +736,122 @@ namespace vl #endif + /*********************************************************************** -STRING.H +.\COLLECTIONS\PAIR.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 Developer: Zihan Chen(vczh) -Data Structure::String +Data Structure::Pair Classes: - AString :Mbcs字符串 - WString :Utf-16字符串 + Pair :二元组 ***********************************************************************/ -#ifndef VCZH_STRING -#define VCZH_STRING +#ifndef VCZH_COLLECTIONS_PAIR +#define VCZH_COLLECTIONS_PAIR -#include namespace vl { - /// A type representing a string. - /// Type of a character. - template - class ObjectString : public Object + namespace collections { - private: - static const T zero; - - mutable T* buffer; - mutable volatile vint* counter; - mutable vint start; - mutable vint length; - mutable vint realLength; - - static vint CalculateLength(const T* buffer) + /// A type representing a pair of key and value. + /// Type of the key. + /// Type of the value. + template + class Pair { - vint result=0; - while(*buffer++)result++; - return result; - } + public: + /// The key. + K key; + /// The value. + V value; - static vint Compare(const T* bufA, const ObjectString& strB) - { - const T* bufB=strB.buffer+strB.start; - const T* bufAOld=bufA; - vint length=strB.length; - while(length-- && *bufA) + Pair() { - vint diff=*bufA++-*bufB++; - if(diff!=0) - { - return diff; - } - }; - return CalculateLength(bufAOld)-strB.length; - } - - public: - - static vint Compare(const ObjectString& strA, const ObjectString& strB) - { - const T* bufA=strA.buffer+strA.start; - const T* bufB=strB.buffer+strB.start; - vint length=strA.length& pair) + { + key=pair.key; + value=pair.value; + } + + vint CompareTo(const Pair& pair)const + { + if(keypair.key) + { + return 1; + } + else if(valuepair.value) + { + return 1; + } + else + { + return 0; } } - } - ObjectString(const ObjectString& string, vint _start, vint _length) - { - if(_length<=0) + bool operator==(const Pair& pair)const { - buffer=(T*)&zero; - counter=0; - start=0; - length=0; - realLength=0; + return CompareTo(pair)==0; } - else + + bool operator!=(const Pair& pair)const { - buffer=string.buffer; - counter=string.counter; - start=string.start+_start; - length=_length; - realLength=string.realLength; - Inc(); + return CompareTo(pair)!=0; } - } - ObjectString(const ObjectString& dest, const ObjectString& source, vint index, vint count) - { - if(index==0 && count==dest.length && source.length==0) + bool operator<(const Pair& pair)const { - buffer=(T*)&zero; - counter=0; - start=0; - length=0; - realLength=0; + return CompareTo(pair)<0; } - else + + bool operator<=(const Pair& pair)const { - counter=new vint(1); - start=0; - length=dest.length-count+source.length; - realLength=length; - buffer=new T[length+1]; - memcpy(buffer, dest.buffer+dest.start, sizeof(T)*index); - memcpy(buffer+index, source.buffer+source.start, sizeof(T)*source.length); - memcpy(buffer+index+source.length, (dest.buffer+dest.start+index+count), sizeof(T)*(dest.length-index-count)); - buffer[length]=0; + return CompareTo(pair)<=0; } - } - public: - static ObjectString Empty; - /// Create an empty string. - ObjectString() - { - buffer=(T*)&zero; - counter=0; - start=0; - length=0; - realLength=0; - } - - /// Create a string continaing one character. - /// The character. - ObjectString(const T& _char) - { - counter=new vint(1); - start=0; - length=1; - buffer=new T[2]; - buffer[0]=_char; - buffer[1]=0; - realLength=length; - } - - /// Copy a string. - /// Memory to copy. It does not have to contain the zero terminator. - /// Size of the content in characters. - ObjectString(const T* _buffer, vint _length) - { - if(_length<=0) + bool operator>(const Pair& pair)const { - buffer=(T*)&zero; - counter=0; - start=0; - length=0; - realLength=0; + return CompareTo(pair)>0; } - else + + bool operator>=(const Pair& pair)const { - buffer=new T[_length+1]; - memcpy(buffer, _buffer, _length*sizeof(T)); - buffer[_length]=0; - counter=new vint(1); - start=0; - length=_length; - realLength=_length; + return CompareTo(pair)>=0; } - } - - /// Copy a string. - /// Memory to copy. It should have to contain the zero terminator. - /// Set to true to copy the memory. Set to false to use the memory directly. - ObjectString(const T* _buffer, bool copy = true) - { - CHECK_ERROR(_buffer!=0, L"ObjectString::ObjectString(const T*, bool)#Cannot construct a string from nullptr."); - if(copy) - { - counter=new vint(1); - start=0; - length=CalculateLength(_buffer); - buffer=new T[length+1]; - memcpy(buffer, _buffer, sizeof(T)*(length+1)); - realLength=length; - } - else - { - buffer=(T*)_buffer; - counter=0; - start=0; - length=CalculateLength(_buffer); - realLength=length; - } - } - - /// Copy a string. - /// The string to copy. - ObjectString(const ObjectString& string) - { - buffer=string.buffer; - counter=string.counter; - start=string.start; - length=string.length; - realLength=string.realLength; - Inc(); - } - - /// Move a string. - /// The string to move. - ObjectString(ObjectString&& string) - { - buffer=string.buffer; - counter=string.counter; - start=string.start; - length=string.length; - realLength=string.realLength; - - string.buffer=(T*)&zero; - string.counter=0; - string.start=0; - string.length=0; - string.realLength=0; - } + }; + } - ~ObjectString() - { - Dec(); - } - - /// Get the zero-terminated buffer in the string. Copying parts of a string does not necessarily create a new buffer, so in some situation the string will not actually points to a zero-terminated buffer. In this case, this function will copy the content to a new buffer with a zero terminator and return. - /// Returns the buffer. - const T* Buffer()const - { - if(start+length!=realLength) - { - T* newBuffer=new T[length+1]; - memcpy(newBuffer, buffer+start, sizeof(T)*length); - newBuffer[length]=0; - Dec(); - buffer=newBuffer; - counter=new vint(1); - start=0; - realLength=length; - } - return buffer+start; - } - - ObjectString& operator=(const ObjectString& string) - { - if(this!=&string) - { - Dec(); - buffer=string.buffer; - counter=string.counter; - start=string.start; - length=string.length; - realLength=string.realLength; - Inc(); - } - return *this; - } - - ObjectString& operator=(ObjectString&& string) - { - if(this!=&string) - { - Dec(); - buffer=string.buffer; - counter=string.counter; - start=string.start; - length=string.length; - realLength=string.realLength; - - string.buffer=(T*)&zero; - string.counter=0; - string.start=0; - string.length=0; - string.realLength=0; - } - return *this; - } - - ObjectString& operator+=(const ObjectString& string) - { - return *this=*this+string; - } - - ObjectString operator+(const ObjectString& string)const - { - return ObjectString(*this, string, length, 0); - } - - bool operator==(const ObjectString& string)const - { - return Compare(*this, string)==0; - } - - bool operator!=(const ObjectString& string)const - { - return Compare(*this, string)!=0; - } - - bool operator>(const ObjectString& string)const - { - return Compare(*this, string)>0; - } - - bool operator>=(const ObjectString& string)const - { - return Compare(*this, string)>=0; - } - - bool operator<(const ObjectString& string)const - { - return Compare(*this, string)<0; - } - - bool operator<=(const ObjectString& string)const - { - return Compare(*this, string)<=0; - } - - bool operator==(const T* buffer)const - { - return Compare(buffer, *this)==0; - } - - bool operator!=(const T* buffer)const - { - return Compare(buffer, *this)!=0; - } - - bool operator>(const T* buffer)const - { - return Compare(buffer, *this)<0; - } - - bool operator>=(const T* buffer)const - { - return Compare(buffer, *this)<=0; - } - - bool operator<(const T* buffer)const - { - return Compare(buffer, *this)>0; - } - - bool operator<=(const T* buffer)const - { - return Compare(buffer, *this)>=0; - } - - T operator[](vint index)const - { - CHECK_ERROR(index>=0 && index:operator[](vint)#Argument index not in range."); - return buffer[start+index]; - } - - /// Get the size of the string in characters. - /// The size. - vint Length()const - { - return length; - } - - /// Find a character. - /// The position of the character. Returns -1 if it doesn not exist. - /// The character to find. - vint IndexOf(T c)const - { - const T* reading=buffer+start; - for(vint i=0;iCopy the beginning of the string. - /// The copied string. - /// Size of characters to copy. - ObjectString Left(vint count)const - { - CHECK_ERROR(count>=0 && count<=length, L"ObjectString::Left(vint)#Argument count not in range."); - return ObjectString(*this, 0, count); - } - - /// Copy the ending of the string. - /// The copied string. - /// Size of characters to copy. - ObjectString Right(vint count)const - { - CHECK_ERROR(count>=0 && count<=length, L"ObjectString::Right(vint)#Argument count not in range."); - return ObjectString(*this, length-count, count); - } - - /// Copy the middle of the string. - /// The copied string. - /// Position of characters to copy. - /// Size of characters to copy. - ObjectString Sub(vint index, vint count)const - { - CHECK_ERROR(index>=0 && index<=length, L"ObjectString::Sub(vint, vint)#Argument index not in range."); - CHECK_ERROR(index+count>=0 && index+count<=length, L"ObjectString::Sub(vint, vint)#Argument count not in range."); - return ObjectString(*this, index, count); - } - - /// Copy the beginning and the end of the string. - /// The copied string. - /// Position of characters NOT to copy. - /// Size of characters NOT to copy. - ObjectString Remove(vint index, vint count)const - { - CHECK_ERROR(index>=0 && index::Remove(vint, vint)#Argument index not in range."); - CHECK_ERROR(index+count>=0 && index+count<=length, L"ObjectString::Remove(vint, vint)#Argument count not in range."); - return ObjectString(*this, ObjectString(), index, count); - } - - /// Make a new string by inserting a string in this string. - /// The copied string. - /// Position of characters to insert. - /// The string to be inserted in this string. - ObjectString Insert(vint index, const ObjectString& string)const - { - CHECK_ERROR(index>=0 && index<=length, L"ObjectString::Insert(vint)#Argument count not in range."); - return ObjectString(*this, string, index, 0); - } - - friend bool operator<(const T* left, const ObjectString& right) - { - return Compare(left, right)<0; - } - - friend bool operator<=(const T* left, const ObjectString& right) - { - return Compare(left, right)<=0; - } - - friend bool operator>(const T* left, const ObjectString& right) - { - return Compare(left, right)>0; - } - - friend bool operator>=(const T* left, const ObjectString& right) - { - return Compare(left, right)>=0; - } - - friend bool operator==(const T* left, const ObjectString& right) - { - return Compare(left, right)==0; - } - - friend bool operator!=(const T* left, const ObjectString& right) - { - return Compare(left, right)!=0; - } - - friend ObjectString operator+(const T* left, const ObjectString& right) - { - return ObjectString(left, false)+right; - } + template + struct POD> + { + static const bool Result=POD::Result && POD::Result; }; - - template - ObjectString ObjectString::Empty=ObjectString(); - template - const T ObjectString::zero=0; - - /// Ansi string. - typedef ObjectString AString; - /// Unicode string. - typedef ObjectString WString; - - /// Convert a string to an signed integer. - /// The converted number. If the convert failed, the result is undefined. - /// The string to convert. - /// Returns true if this operation succeeded. - extern vint atoi_test(const AString& string, bool& success); - /// Convert a string to an signed integer. - /// The converted number. If the convert failed, the result is undefined. - /// The string to convert. - /// Returns true if this operation succeeded. - extern vint wtoi_test(const WString& string, bool& success); - /// Convert a string to an signed 64-bits integer. - /// The converted number. If the convert failed, the result is undefined. - /// The string to convert. - /// Returns true if this operation succeeded. - extern vint64_t atoi64_test(const AString& string, bool& success); - /// Convert a string to an signed 64-bits integer. - /// The converted number. If the convert failed, the result is undefined. - /// The string to convert. - /// Returns true if this operation succeeded. - extern vint64_t wtoi64_test(const WString& string, bool& success); - /// Convert a string to an unsigned integer. - /// The converted number. If the convert failed, the result is undefined. - /// The string to convert. - /// Returns true if this operation succeeded. - extern vuint atou_test(const AString& string, bool& success); - /// Convert a string to an unsigned integer. - /// The converted number. If the convert failed, the result is undefined. - /// The string to convert. - /// Returns true if this operation succeeded. - extern vuint wtou_test(const WString& string, bool& success); - /// Convert a string to a 64-bits unsigned integer. - /// The converted number. If the convert failed, the result is undefined. - /// The string to convert. - /// Returns true if this operation succeeded. - extern vuint64_t atou64_test(const AString& string, bool& success); - /// Convert a string to a 64-bits unsigned integer. - /// The converted number. If the convert failed, the result is undefined. - /// The string to convert. - /// Returns true if this operation succeeded. - extern vuint64_t wtou64_test(const WString& string, bool& success); - /// Convert a string to 64-bits floating point number. - /// The converted number. If the convert failed, the result is undefined. - /// The string to convert. - /// Returns true if this operation succeeded. - extern double atof_test(const AString& string, bool& success); - /// Convert a string to 64-bits floating point number. - /// The converted number. If the convert failed, the result is undefined. - /// The string to convert. - /// Returns true if this operation succeeded. - extern double wtof_test(const WString& string, bool& success); - - /// Convert a string to an signed integer. - /// The converted number. If the convert failed, the result is undefined. - /// The string to convert. - extern vint atoi(const AString& string); - /// Convert a string to an signed integer. - /// The converted number. If the convert failed, the result is undefined. - /// The string to convert. - extern vint wtoi(const WString& string); - /// Convert a string to an signed 64-bits integer. - /// The converted number. If the convert failed, the result is undefined. - /// The string to convert. - extern vint64_t atoi64(const AString& string); - /// Convert a string to an signed 64-bits integer. - /// The converted number. If the convert failed, the result is undefined. - /// The string to convert. - extern vint64_t wtoi64(const WString& string); - /// Convert a string to an unsigned integer. - /// The converted number. If the convert failed, the result is undefined. - /// The string to convert. - extern vuint atou(const AString& string); - /// Convert a string to an unsigned integer. - /// The converted number. If the convert failed, the result is undefined. - /// The string to convert. - extern vuint wtou(const WString& string); - /// Convert a string to a 64-bits unsigned integer. - /// The converted number. If the convert failed, the result is undefined. - /// The string to convert. - extern vuint64_t atou64(const AString& string); - /// Convert a string to a 64-bits unsigned integer. - /// The converted number. If the convert failed, the result is undefined. - /// The string to convert. - extern vuint64_t wtou64(const WString& string); - /// Convert a string to a 64-bits floating point number. - /// The converted number. If the convert failed, the result is undefined. - /// The string to convert. - extern double atof(const AString& string); - /// Convert a string to a 64-bits floating point number. - /// The converted number. If the convert failed, the result is undefined. - /// The string to convert. - extern double wtof(const WString& string); - - /// Convert a signed interger to a string. - /// The converted string. - /// The number to convert. - extern AString itoa(vint number); - /// Convert a signed interger to a string. - /// The converted string. - /// The number to convert. - extern WString itow(vint number); - /// Convert a 64-bits signed interger to a string. - /// The converted string. - /// The number to convert. - extern AString i64toa(vint64_t number); - /// Convert a 64-bits signed interger to a string. - /// The converted string. - /// The number to convert. - extern WString i64tow(vint64_t number); - /// Convert an unsigned interger to a string. - /// The converted string. - /// The number to convert. - extern AString utoa(vuint number); - /// Convert an unsigned interger to a string. - /// The converted string. - /// The number to convert. - extern WString utow(vuint number); - /// Convert a 64-bits unsigned interger to a string. - /// The converted string. - /// The number to convert. - extern AString u64toa(vuint64_t number); - /// Convert a 64-bits unsigned interger to a string. - /// The converted string. - /// The number to convert. - extern WString u64tow(vuint64_t number); - /// Convert a 64-bits floating pointer number to a string. - /// The converted string. - /// The number to convert. - extern AString ftoa(double number); - /// Convert a 64-bits floating pointer number to a string. - /// The converted string. - /// The number to convert. - extern WString ftow(double number); - - extern vint _wtoa(const wchar_t* w, char* a, vint chars); - /// Convert an Unicode string to an Ansi string. - /// The converted string. - /// The string to convert. - extern AString wtoa(const WString& string); - extern vint _atow(const char* a, wchar_t* w, vint chars); - /// Convert an Ansi string to an Unicode string. - /// The converted string. - /// The string to convert. - extern WString atow(const AString& string); - /// Convert all letters to lower case letters. - /// The converted string. - /// The string to convert. - extern AString alower(const AString& string); - /// Convert all letters to lower case letters. - /// The converted string. - /// The string to convert. - extern WString wlower(const WString& string); - /// Convert all letters to upper case letters. - /// The converted string. - /// The string to convert. - extern AString aupper(const AString& string); - /// Convert all letters to upper case letters. - /// The converted string. - /// The string to convert. - extern WString wupper(const WString& string); - -#if defined VCZH_GCC - extern void _itoa_s(vint32_t value, char* buffer, size_t size, vint radix); - extern void _itow_s(vint32_t value, wchar_t* buffer, size_t size, vint radix); - extern void _i64toa_s(vint64_t value, char* buffer, size_t size, vint radix); - extern void _i64tow_s(vint64_t value, wchar_t* buffer, size_t size, vint radix); - extern void _uitoa_s(vuint32_t value, char* buffer, size_t size, vint radix); - extern void _uitow_s(vuint32_t value, wchar_t* buffer, size_t size, vint radix); - extern void _ui64toa_s(vuint64_t value, char* buffer, size_t size, vint radix); - extern void _ui64tow_s(vuint64_t value, wchar_t* buffer, size_t size, vint radix); - extern void _gcvt_s(char* buffer, size_t size, double value, vint numberOfDigits); - extern void _strlwr_s(char* buffer, size_t size); - extern void _strupr_s(char* buffer, size_t size); - extern void _wcslwr_s(wchar_t* buffer, size_t size); - extern void _wcsupr_s(wchar_t* buffer, size_t size); -#endif } #endif /*********************************************************************** -POINTER.H +.\POINTER.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -2040,540 +1478,7 @@ Traits #endif /*********************************************************************** -FUNCTION.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Framework::Function - -Classes: - Func :函数对象 - -Functions: - Curry :: (A->B) -> A -> B :参数拆分 - Combine :: (A->B) -> (A->C) -> (B->C->D) -> (A->D) :函数组合 -***********************************************************************/ -#ifndef VCZH_FUNCTION -#define VCZH_FUNCTION -namespace vl -{ - -/*********************************************************************** -vl::Func -***********************************************************************/ - - template - class Func - { - }; - - namespace internal_invokers - { - template - class Invoker : public Object - { - public: - virtual R Invoke(TArgs&& ...args) = 0; - }; - - //------------------------------------------------------ - - template - class StaticInvoker : public Invoker - { - protected: - R(*function)(TArgs ...args); - - public: - StaticInvoker(R(*_function)(TArgs...)) - :function(_function) - { - } - - R Invoke(TArgs&& ...args)override - { - return function(ForwardValue(args)...); - } - }; - - //------------------------------------------------------ - - template - class MemberInvoker : public Invoker - { - protected: - C* sender; - R(C::*function)(TArgs ...args); - - public: - MemberInvoker(C* _sender, R(C::*_function)(TArgs ...args)) - :sender(_sender) - ,function(_function) - { - } - - R Invoke(TArgs&& ...args)override - { - return (sender->*function)(ForwardValue(args)...); - } - }; - - //------------------------------------------------------ - - template - class ObjectInvoker : public Invoker - { - protected: - C function; - - public: - ObjectInvoker(const C& _function) - :function(_function) - { - } - - R Invoke(TArgs&& ...args)override - { - return function(ForwardValue(args)...); - } - }; - - //------------------------------------------------------ - - template - class ObjectInvoker : public Invoker - { - protected: - C function; - - public: - ObjectInvoker(const C& _function) - :function(_function) - { - } - - void Invoke(TArgs&& ...args)override - { - function(ForwardValue(args)...); - } - }; - } - - /// A type representing a function reference. - /// The return type. - /// Types of parameters. - template - class Func : public Object - { - protected: - Ptr> invoker; - public: - typedef R FunctionType(TArgs...); - typedef R ResultType; - - /// Create a null function reference. - Func() - { - } - - /// Copy a function reference. - /// The function reference to copy. - Func(const Func& function) - { - invoker=function.invoker; - } - - /// Create a reference using a function pointer. - /// The function pointer. - Func(R(*function)(TArgs...)) - { - invoker=new internal_invokers::StaticInvoker(function); - } - - /// Create a reference using a method. - /// Type of the class that has the method. - /// The object that has the method. - /// The function pointer. - template - Func(C* sender, R(C::*function)(TArgs...)) - { - invoker=new internal_invokers::MemberInvoker(sender, function); - } - - /// Create a reference using a function object. - /// Type of the function object. - /// The function object. It could be a lambda expression. - template - Func(const C& function) - { - invoker=new internal_invokers::ObjectInvoker(function); - } - - /// Invoke the function. - /// Returns the function result. - /// Arguments to invoke the function. - R operator()(TArgs ...args)const - { - return invoker->Invoke(ForwardValue(args)...); - } - - bool operator==(const Func& function)const - { - return invoker == function.invoker; - } - - bool operator!=(const Func& function)const - { - return invoker != function.invoker; - } - - /// Test is the reference a null reference. - /// Returns true if it is not a null reference. - operator bool()const - { - return invoker; - } - }; - -/*********************************************************************** -vl::function_lambda::LambdaRetriveType -***********************************************************************/ - - namespace function_lambda - { - template - struct LambdaRetriveType - { - typedef vint Type; - typedef vint FunctionType; - typedef vint ResultType; - }; - - template - struct FunctionObjectRetriveType - { - typedef typename LambdaRetriveType::Type Type; - typedef typename LambdaRetriveType::FunctionType FunctionType; - typedef typename LambdaRetriveType::ResultType ResultType; - }; - - template - struct LambdaRetriveType - { - typedef Func Type; - typedef R(FunctionType)(TArgs...); - typedef R ResultType; - }; - - template - struct LambdaRetriveType - { - typedef Func Type; - typedef R(FunctionType)(TArgs...); - typedef R ResultType; - }; - - template - struct FunctionObjectRetriveType - { - typedef Func Type; - typedef R(FunctionType)(TArgs...); - typedef R ResultType; - }; - - /// Create a function reference to a function object or a lambda expression, with all type information autotimatically inferred. You can use the macro called "LAMBDA" to refer to this function. - /// Type of the function object or the lambda expression. - /// The function reference. - /// The function object or the lambda expression. - template - typename LambdaRetriveType::Type Lambda(T functionObject) - { - return functionObject; - } - - /// Create a function reference to a function pointer, with all type information autotimatically inferred. You can use the macro called "FUNCTION" to refer to this function. - /// Type of the function pointer. - /// The function reference. - /// The function pointer. - template - typename FunctionObjectRetriveType::Type ConvertToFunction(T functionObject) - { - return functionObject; - } - -#define LAMBDA vl::function_lambda::Lambda -#define FUNCTION vl::function_lambda::ConvertToFunction -#define FUNCTION_TYPE(T) typename vl::function_lambda::FunctionObjectRetriveType::Type -#define FUNCTION_RESULT_TYPE(T) typename vl::function_lambda::FunctionObjectRetriveType::ResultType - } - -/*********************************************************************** -vl::function_binding::Binding -***********************************************************************/ - - namespace function_binding - { - template - struct Binding - { - }; - - template - struct CR{typedef const T& Type;}; - template - struct CR{typedef T& Type;}; - template - struct CR{typedef const T& Type;}; - template - struct CR{typedef const T& Type;}; - - template - struct Binding - { - typedef R FunctionType(T0, TArgs...); - typedef R CurriedType(TArgs...); - typedef T0 FirstParameterType; - - class Binder : public Object - { - protected: - Func target; - T0 firstArgument; - public: - Binder(const Func& _target, T0 _firstArgument) - :target(_target) - ,firstArgument(ForwardValue(_firstArgument)) - { - } - - R operator()(TArgs ...args)const - { - return target(firstArgument, args...); - } - }; - - class Currier : public Object - { - protected: - Func target; - public: - Currier(const Func& _target) - :target(_target) - { - } - - Func operator()(T0 firstArgument)const - { - return Binder(target, firstArgument); - } - }; - }; - } - - /// Currize a function. Currizing means to create a new function whose argument is the first argument of the original function. Calling this function will return another function reference whose arguments is all remain arguments of the original function. Calling the returned function will call the original function. - /// Type of the function. - /// The currized function. - /// The function pointer to currize. - template - Func::CurriedType>(typename function_binding::Binding::FirstParameterType)> - Curry(T* function) - { - return typename function_binding::Binding::Currier(function); - } - - /// Currize a function. Currizing means to create a new function whose argument is the first argument of the original function. Calling this function will return another function reference whose arguments is all remain arguments of the original function. Calling the returned function will call the original function. - /// Type of the function. - /// The currized function. - /// The function reference to currize. - template - Func::CurriedType>(typename function_binding::Binding::FirstParameterType)> - Curry(const Func& function) - { - return typename function_binding::Binding::Currier(function); - } - -/*********************************************************************** -vl::function_combining::Combining -***********************************************************************/ - - namespace function_combining - { - template - class Combining - { - }; - - template - class Combining : public Object - { - protected: - Func function1; - Func function2; - Func converter; - public: - typedef R1 FirstFunctionType(TArgs...); - typedef R2 SecondFunctionType(TArgs...); - typedef R ConverterFunctionType(R1, R2); - typedef R FinalFunctionType(TArgs...); - - Combining(const Func& _function1, const Func& _function2, const Func& _converter) - :function1(_function1) - ,function2(_function2) - ,converter(_converter) - { - } - - R operator()(TArgs&& ...args)const - { - return converter(function1(ForwardValue(args)...), function2(ForwardValue(args)...)); - } - }; - } - - /// Combine two functions with a converter function. The two functions to combine should have the same argument types. The converter function will use the return values of the two function to calculate the final value. - /// Type of the first function. - /// Type of the second function. - /// Type of the converter function. - /// A new function whose argument list are the same of the two functions to provide. Calling this function will call function1, function2 and converter in order to calculate the final value. - /// The converter function. - /// The first function. - /// The second function. - template - Func::FinalFunctionType> - Combine(Func converter, Func function1, Func function2) - { - return function_combining::Combining(function1, function2, converter); - } - - /// Use the converter function to create a combiner, who will receive two function and use to create a combined function. This function assumes the result types of the two provided function in the future are the same, and the converter function will not change the result type. - /// Type of the two functions to combine. - /// The combiner. - /// The converter function. - template - Func(Func,Func)> Combiner(const Func::ResultType(typename Func::ResultType,typename Func::ResultType)>& converter) - { - typedef typename Func::ResultType R; - return Curry(Func,Func,Func)>(Combine)(converter); - } -} -#endif - -/*********************************************************************** -COLLECTIONS\PAIR.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Data Structure::Pair - -Classes: - Pair :二元组 -***********************************************************************/ - -#ifndef VCZH_COLLECTIONS_PAIR -#define VCZH_COLLECTIONS_PAIR - - -namespace vl -{ - namespace collections - { - /// A type representing a pair of key and value. - /// Type of the key. - /// Type of the value. - template - class Pair - { - public: - /// The key. - K key; - /// The value. - V value; - - Pair() - { - } - - Pair(const K& _key, const V& _value) - { - key=_key; - value=_value; - } - - Pair(const Pair& pair) - { - key=pair.key; - value=pair.value; - } - - vint CompareTo(const Pair& pair)const - { - if(keypair.key) - { - return 1; - } - else if(valuepair.value) - { - return 1; - } - else - { - return 0; - } - } - - bool operator==(const Pair& pair)const - { - return CompareTo(pair)==0; - } - - bool operator!=(const Pair& pair)const - { - return CompareTo(pair)!=0; - } - - bool operator<(const Pair& pair)const - { - return CompareTo(pair)<0; - } - - bool operator<=(const Pair& pair)const - { - return CompareTo(pair)<=0; - } - - bool operator>(const Pair& pair)const - { - return CompareTo(pair)>0; - } - - bool operator>=(const Pair& pair)const - { - return CompareTo(pair)>=0; - } - }; - } - - template - struct POD> - { - static const bool Result=POD::Result && POD::Result; - }; -} - -#endif - -/*********************************************************************** -COLLECTIONS\INTERFACES.H +.\COLLECTIONS\INTERFACES.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -2684,8 +1589,9 @@ namespace vl #endif + /*********************************************************************** -COLLECTIONS\LIST.H +.\COLLECTIONS\LIST.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -3592,8 +2498,9 @@ Random Access #endif + /*********************************************************************** -COLLECTIONS\DICTIONARY.H +.\COLLECTIONS\DICTIONARY.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -4105,12 +3012,12 @@ namespace vl { if (firstIndex < firstCount) { - WString firstKey = first.Keys()[firstIndex]; + auto firstKey = first.Keys()[firstIndex]; const List& firstValues = first.GetByIndex(firstIndex); if (secondIndex < secondCount) { - WString secondKey = second.Keys()[secondIndex]; + auto secondKey = second.Keys()[secondIndex]; const List& secondValues = second.GetByIndex(secondIndex); if (firstKey < secondKey) @@ -4140,7 +3047,7 @@ namespace vl { if (secondIndex < secondCount) { - WString secondKey = second.Keys()[secondIndex]; + auto secondKey = second.Keys()[secondIndex]; const List& secondValues = second.GetByIndex(secondIndex); discardSecond(secondKey, secondValues); @@ -4191,950 +3098,7 @@ namespace vl #endif /*********************************************************************** -STREAM\INTERFACES.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Stream::Interfaces - -Interfaces: - IStream :流 -***********************************************************************/ - -#ifndef VCZH_STREAM_INTERFACES -#define VCZH_STREAM_INTERFACES - - -namespace vl -{ - namespace stream - { - /// - /// Interface for streams. Stream functions are grouped into 5 categories: - /// 1) Feature testing functions. - /// 2) Read functions, available only if [M:vl.stream.IStream.CanRead] returns true. - /// 3) Peek functions, available only if [M:vl.stream.IStream.CanPeek] returns true. - /// 4) Write functions, available only if [M:vl.stream.IStream.CanWrite] returns true. - /// 5) Seek functions, available only if [M:vl.stream.IStream.CanSeek] returns true. - /// 6) Size functions, available only if [M:vl.stream.IStream.IsLimited] returns true. But there are still some streams knows that the content is limited, but the size is unknown. In this case, [M:vl.stream.IStream.Size] will return -1. - /// - class IStream : public virtual Interface - { - public: - /// Test if the stream is readable. - /// Returns true if the stream is readable. - virtual bool CanRead()const=0; - /// Test if the stream is writable. - /// Returns true if the stream is writable. - virtual bool CanWrite()const=0; - /// Test if the stream is seekable. - /// Returns true if the stream is seekable. - virtual bool CanSeek()const=0; - /// Test if the stream is peekable. - /// Returns true if the stream is peekable. - virtual bool CanPeek()const=0; - /// Test if the content of the stream is limited. A writable stream can also be limited, it means that you can only write a limited content to the stream. - /// Returns true if the content of the stream is limited. - virtual bool IsLimited()const=0; - /// Test if the stream is available. For example, if you create a readable [T:vl.stream.FileStream] giving a wrong file name, it will be unavailable. - /// Returns true if the stream is available. - virtual bool IsAvailable()const=0; - /// Close the stream. - virtual void Close()=0; - /// Get the current position in the stream. - /// The position in the stream. Returns -1 if the stream is not available. - virtual pos_t Position()const=0; - /// Get the size of the content.. - /// The size of the content. Returns -1 if the size is unknown or the stream is not available. - virtual pos_t Size()const=0; - /// Step forward or backward from the current position. Will throw exception if the stream is not seekable or not available. - /// The length of the step. - virtual void Seek(pos_t _size)=0; - /// Step fowward from the beginning. Will throw exception if the stream is not seekable or not available. - /// The length of the step. - virtual void SeekFromBegin(pos_t _size)=0; - /// Step backward from the end. Will throw exception if the stream is not seekable or not available. - /// The length of the step. - virtual void SeekFromEnd(pos_t _size)=0; - /// Read from the current position and step forward. Will throw exception if the stream is not readable or not available. - /// Returns the actual size of the content that is read. Returns 0 indicates that the stream reaches the end if the stream is limited. - /// A buffer to store the content. - /// The size of the content that is expected to read. - virtual vint Read(void* _buffer, vint _size)=0; - /// Write to the current position and step forward. Will throw exception if the stream is not writable or not available. - /// Returns the actual size of the content that is written. Returns 0 indicates that the stream reaches the end if the stream is limited. - /// A buffer storing the content to write. - /// The size of the content that is expected to write. - virtual vint Write(void* _buffer, vint _size)=0; - /// Read from the current position but not step forward. Will throw exception if the stream is not peekable or not available. - /// Returns the actual size of the content that is read. Returns 0 indicates that the stream reaches the end if the stream is limited. - /// A buffer to store the content. - /// The size of the content that is expected to peek. - virtual vint Peek(void* _buffer, vint _size)=0; - }; - - /// Encoder interface. This interface defines a writable transformation from one stream to another stream. You can create a [T:vl.stream.EncoderStream] after you have an encoder. - class IEncoder : public Interface - { - public: - /// Set a target writable stream. The function will transform the content and write to this tream. - /// The target writable stream. - virtual void Setup(IStream* _stream)=0; - /// Stop the transformation, ensuring all written content is transformed to the target stream. - virtual void Close()=0; - /// Transform content and write to the target stream. This function may cache something to increase performance, so it cannot expect that all transformed content will be written to the target stream immediately. - /// Returns the actual size of the content before transforming that is written. The content is treated as being written even it is cached and not actually write to the target stream. - /// A buffer storing the content to write. - /// The size of the content that is expected to write. - virtual vint Write(void* _buffer, vint _size)=0; - }; - - /// Decoder interface. This interface defines a readable transformation from one stream to another stream. You can create a [T:vl.stream.DecoderStream] after you have an decoder. - class IDecoder : public Interface - { - public: - /// Set a target readable stream. The function will read from this tream and transform the content. - /// The target readable stream. - virtual void Setup(IStream* _stream)=0; - /// Stop the transformation. - virtual void Close()=0; - /// Read from the target stream and transform the content. - /// Returns the actual size of the content after transforming that is read. - /// A buffer to store the content. - /// The size of the content that is expected to read. - virtual vint Read(void* _buffer, vint _size)=0; - }; - } -} - -#endif - -/*********************************************************************** -STREAM\MEMORYSTREAM.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Stream::MemoryStream - -Interfaces: - MemoryStream :内存流 -***********************************************************************/ - -#ifndef VCZH_STREAM_MEMORYSTREAM -#define VCZH_STREAM_MEMORYSTREAM - - -namespace vl -{ - namespace stream - { - /// A readable, writable, seekable and peekable stream that stores everything in memory. - class MemoryStream : public Object, public virtual IStream - { - protected: - vint block; - char* buffer; - vint size; - vint position; - vint capacity; - - void PrepareSpace(vint totalSpace); - public: - /// Create a stream. - /// Size for each allocation. The stream will only allocate new memory of size "_block" when it reaches the end and has to extend. - MemoryStream(vint _block=65536); - ~MemoryStream(); - - bool CanRead()const; - bool CanWrite()const; - bool CanSeek()const; - bool CanPeek()const; - bool IsLimited()const; - bool IsAvailable()const; - void Close(); - pos_t Position()const; - pos_t Size()const; - void Seek(pos_t _size); - void SeekFromBegin(pos_t _size); - void SeekFromEnd(pos_t _size); - vint Read(void* _buffer, vint _size); - vint Write(void* _buffer, vint _size); - vint Peek(void* _buffer, vint _size); - void* GetInternalBuffer(); - }; - } -} - -#endif - -/*********************************************************************** -STREAM\MEMORYWRAPPERSTREAM.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Stream::MemoryWrapperStream - -Interfaces: - MemoryWrapperStream :内存代理流 -***********************************************************************/ - -#ifndef VCZH_STREAM_MEMORYWRAPPERSTREAM -#define VCZH_STREAM_MEMORYWRAPPERSTREAM - - -namespace vl -{ - namespace stream - { - /// A readable, writable, seekable and peekable stream that operates a buffer. - class MemoryWrapperStream : public Object, public virtual IStream - { - protected: - char* buffer; - vint size; - vint position; - public: - /// Create a stream. - /// The buffer to operate. - /// Size of the buffer. - MemoryWrapperStream(void* _buffer, vint _size); - ~MemoryWrapperStream(); - - bool CanRead()const; - bool CanWrite()const; - bool CanSeek()const; - bool CanPeek()const; - bool IsLimited()const; - bool IsAvailable()const; - void Close(); - pos_t Position()const; - pos_t Size()const; - void Seek(pos_t _size); - void SeekFromBegin(pos_t _size); - void SeekFromEnd(pos_t _size); - vint Read(void* _buffer, vint _size); - vint Write(void* _buffer, vint _size); - vint Peek(void* _buffer, vint _size); - }; - } -} - -#endif - -/*********************************************************************** -STREAM\CHARFORMAT.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Stream::CharFormat - -Classes: - CharEncoder :字符串编码器基类 - CharDecoder :字符串解码器基类 - MbcsEncoder :Mbcs编码器 - MbcsDecoder :Mbcs解码器 - Utf16Encoder :Utf16编码器 - Utf16Decoder :Utf16解码器 - Utf16BEEncoder :Utf16 Big Endian编码器 - Utf16BEDecoder :Utf16 Big Endian解码器 - Utf8Encoder :Utf8编码器 - Utf8Decoder :Utf8解码器 - BomEncoder :BOM相关编码器 - BomDecoder :BOM相关解码器 -***********************************************************************/ - -#ifndef VCZH_STREAM_CHARFORMAT -#define VCZH_STREAM_CHARFORMAT - - -namespace vl -{ - namespace stream - { - - /*编码资料 - UCS-4和UTF-8的对应关系: - U-00000000 - U-0000007F: 0xxxxxxx - U-00000080 - U-000007FF: 110xxxxx 10xxxxxx - U-00000800 - U-0000FFFF: 1110xxxx 10xxxxxx 10xxxxxx - U-00010000 - U-001FFFFF: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - U-00200000 - U-03FFFFFF: 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx - U-04000000 - U-7FFFFFFF: 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx - BOM: - FFFE =Unicode (vceUtf16) - FEFF =Unicode Big Endian (vceUtf16_be) - EFBBBF =UTF-8 (vceUtf8) - other =MBCS(GBK) (vceMbcs) - */ - -/*********************************************************************** -字符串编码解码基类 -***********************************************************************/ - - /// Base type of all character encoder. - class CharEncoder : public Object, public IEncoder - { - protected: - IStream* stream; - vuint8_t cacheBuffer[sizeof(wchar_t)]; - vint cacheSize; - - virtual vint WriteString(wchar_t* _buffer, vint chars)=0; - public: - CharEncoder(); - - void Setup(IStream* _stream); - void Close(); - vint Write(void* _buffer, vint _size); - }; - - /// Base type of all character decoder. - class CharDecoder : public Object, public IDecoder - { - protected: - IStream* stream; - vuint8_t cacheBuffer[sizeof(wchar_t)]; - vint cacheSize; - - virtual vint ReadString(wchar_t* _buffer, vint chars)=0; - public: - CharDecoder(); - - void Setup(IStream* _stream); - void Close(); - vint Read(void* _buffer, vint _size); - }; - -/*********************************************************************** -Mbcs -***********************************************************************/ - - /// Encoder to transform text in a local code page from wchar_t. - class MbcsEncoder : public CharEncoder - { - protected: - vint WriteString(wchar_t* _buffer, vint chars); - }; - - /// Encoder to transform text in a local code page to wchar_t. - class MbcsDecoder : public CharDecoder - { - protected: - vint ReadString(wchar_t* _buffer, vint chars); - }; - -/*********************************************************************** -Utf-16 -***********************************************************************/ - - /// Encoder to transform UTF-16 text from wchar_t. - class Utf16Encoder : public CharEncoder - { - protected: - vint WriteString(wchar_t* _buffer, vint chars); - }; - - /// Decoder to transform UTF-16 text to wchar_t. - class Utf16Decoder : public CharDecoder - { - protected: - vint ReadString(wchar_t* _buffer, vint chars); - }; - -/*********************************************************************** -Utf-16-be -***********************************************************************/ - - /// Encoder to transform big endian UTF-16 text from wchar_t. - class Utf16BEEncoder : public CharEncoder - { - protected: - vint WriteString(wchar_t* _buffer, vint chars); - }; - - /// Decoder to transform big endian UTF-16 text to wchar_t. - class Utf16BEDecoder : public CharDecoder - { - protected: - vint ReadString(wchar_t* _buffer, vint chars); - }; - -/*********************************************************************** -Utf-8 -***********************************************************************/ - - /// Encoder to transform UTF-8 text from wchar_t. - class Utf8Encoder : public CharEncoder - { - protected: - vint WriteString(wchar_t* _buffer, vint chars); - }; - - /// Decoder to transform UTF-8 text to wchar_t. - class Utf8Decoder : public CharDecoder - { - protected: -#if defined VCZH_MSVC - wchar_t cache; - bool cacheAvailable; -#endif - vint ReadString(wchar_t* _buffer, vint chars); - public: - Utf8Decoder(); - }; - -/*********************************************************************** -Bom -***********************************************************************/ - - /// Encoder to transform text from wchar_t. A BOM will be added at the beginning. - class BomEncoder : public Object, public IEncoder - { - public: - /// Text encoding. - enum Encoding - { - /// Multi-bytes character string. - Mbcs, - /// UTF-8. - Utf8, - /// UTF-16. - Utf16, - /// Big endian UTF-16. - Utf16BE - }; - protected: - Encoding encoding; - IEncoder* encoder; - public: - /// Create an encoder. - /// Specified encoding. - BomEncoder(Encoding _encoding); - ~BomEncoder(); - - void Setup(IStream* _stream); - void Close(); - vint Write(void* _buffer, vint _size); - }; - - /// Decoder to transform text to wchar_t. This decoder depends on the BOM information at the beginning to decide the format of the input. - class BomDecoder : public Object, public IDecoder - { - private: - class BomStream : public Object, public IStream - { - protected: - IStream* stream; - char bom[3]; - vint bomLength; - vint bomPosition; - public: - BomStream(IStream* _stream, char* _bom, vint _bomLength); - - bool CanRead()const; - bool CanWrite()const; - bool CanSeek()const; - bool CanPeek()const; - bool IsLimited()const; - bool IsAvailable()const; - void Close(); - pos_t Position()const; - pos_t Size()const; - void Seek(pos_t _size); - void SeekFromBegin(pos_t _size); - void SeekFromEnd(pos_t _size); - vint Read(void* _buffer, vint _size); - vint Write(void* _buffer, vint _size); - vint Peek(void* _buffer, vint _size); - }; - protected: - IDecoder* decoder; - IStream* stream; - - public: - /// Create an decoder. - BomDecoder(); - ~BomDecoder(); - - void Setup(IStream* _stream); - void Close(); - vint Read(void* _buffer, vint _size); - }; - -/*********************************************************************** -Encoding Test -***********************************************************************/ - - /// Guess the text encoding in a buffer. - /// The buffer to guess. - /// Size of the buffer in bytes. - /// Returns the most possible encoding. - /// Returns true if the BOM information is at the beginning of the buffer. - extern void TestEncoding(unsigned char* buffer, vint size, BomEncoder::Encoding& encoding, bool& containsBom); - -/*********************************************************************** -Serialization -***********************************************************************/ - - namespace internal - { - template - struct Reader - { - stream::IStream& input; - T context; - - Reader(stream::IStream& _input) - :input(_input) - , context(nullptr) - { - } - }; - - template - struct Writer - { - stream::IStream& output; - T context; - - Writer(stream::IStream& _output) - :output(_output) - , context(nullptr) - { - } - }; - - using ContextFreeReader = Reader; - using ContextFreeWriter = Writer; - - template - struct Serialization - { - template - static void IO(TIO& io, T& value); - }; - - template - Reader& operator<<(Reader& reader, TValue& value) - { - Serialization::IO(reader, value); - return reader; - } - - template - Writer& operator<<(Writer& writer, TValue& value) - { - Serialization::IO(writer, value); - return writer; - } - - //--------------------------------------------- - - template<> - struct Serialization - { - template - static void IO(Reader& reader, vint64_t& value) - { - if (reader.input.Read(&value, sizeof(value)) != sizeof(value)) - { - CHECK_FAIL(L"Deserialization failed."); - } - } - - template - static void IO(Writer& writer, vint64_t& value) - { - if (writer.output.Write(&value, sizeof(value)) != sizeof(value)) - { - CHECK_FAIL(L"Serialization failed."); - } - } - }; - - template<> - struct Serialization - { - template - static void IO(Reader& reader, vint32_t& value) - { - vint64_t v = 0; - Serialization::IO(reader, v); - value = (vint32_t)v; - } - - template - static void IO(Writer& writer, vint32_t& value) - { - vint64_t v = (vint64_t)value; - Serialization::IO(writer, v); - } - }; - - template<> - struct Serialization - { - template - static void IO(Reader& reader, bool& value) - { - vint8_t v = 0; - if (reader.input.Read(&v, sizeof(v)) != sizeof(v)) - { - CHECK_FAIL(L"Deserialization failed."); - } - else - { - value = v == -1; - } - } - - template - static void IO(Writer& writer, bool& value) - { - vint8_t v = value ? -1 : 0; - if (writer.output.Write(&v, sizeof(v)) != sizeof(v)) - { - CHECK_FAIL(L"Serialization failed."); - } - } - }; - - template - struct Serialization> - { - template - static void IO(Reader& reader, Ptr& value) - { - bool notNull = false; - reader << notNull; - if (notNull) - { - value = new T; - Serialization::IO(reader, *value.Obj()); - } - else - { - value = 0; - } - } - - template - static void IO(Writer& writer, Ptr& value) - { - bool notNull = value; - writer << notNull; - if (notNull) - { - Serialization::IO(writer, *value.Obj()); - } - } - }; - - template - struct Serialization> - { - template - static void IO(Reader& reader, Nullable& value) - { - bool notNull = false; - reader << notNull; - if (notNull) - { - T data; - Serialization::IO(reader, data); - value = Nullable(data); - } - else - { - value = Nullable(); - } - } - - template - static void IO(Writer& writer, Nullable& value) - { - bool notNull = value; - writer << notNull; - if (notNull) - { - T data = value.Value(); - Serialization::IO(writer, data); - } - } - }; - - template<> - struct Serialization - { - template - static void IO(Reader& reader, WString& value) - { - vint count = -1; - reader << count; - if (count > 0) - { - MemoryStream stream; - reader << (IStream&)stream; - Utf8Decoder decoder; - decoder.Setup(&stream); - - collections::Array stringBuffer(count + 1); - vint stringSize = decoder.Read(&stringBuffer[0], count * sizeof(wchar_t)); - stringBuffer[stringSize / sizeof(wchar_t)] = 0; - - value = &stringBuffer[0]; - } - else - { - value = L""; - } - } - - template - static void IO(Writer& writer, WString& value) - { - vint count = value.Length(); - writer << count; - if (count > 0) - { - MemoryStream stream; - { - Utf8Encoder encoder; - encoder.Setup(&stream); - encoder.Write((void*)value.Buffer(), count * sizeof(wchar_t)); - } - writer << (IStream&)stream; - } - } - }; - - template - struct Serialization> - { - template - static void IO(Reader& reader, collections::List& value) - { - vint32_t count = -1; - reader << count; - value.Clear(); - for (vint i = 0; i < count; i++) - { - T t; - reader << t; - value.Add(t); - } - } - - template - static void IO(Writer& writer, collections::List& value) - { - vint32_t count = (vint32_t)value.Count(); - writer << count; - for (vint i = 0; i < count; i++) - { - writer << value[i]; - } - } - }; - - template - struct Serialization> - { - template - static void IO(Reader& reader, collections::Array& value) - { - vint32_t count = -1; - reader << count; - value.Resize(count); - for (vint i = 0; i < count; i++) - { - reader << value[i]; - } - } - - template - static void IO(Writer& writer, collections::Array& value) - { - vint32_t count = (vint32_t)value.Count(); - writer << count; - for (vint i = 0; i < count; i++) - { - writer << value[i]; - } - } - }; - - template - struct Serialization> - { - template - static void IO(Reader& reader, collections::Dictionary& value) - { - vint32_t count = -1; - reader << count; - value.Clear(); - for (vint i = 0; i < count; i++) - { - K k; - V v; - reader << k << v; - value.Add(k, v); - } - } - - template - static void IO(Writer& writer, collections::Dictionary& value) - { - vint32_t count = (vint32_t)value.Count(); - writer << count; - for (vint i = 0; i < count; i++) - { - K k = value.Keys()[i]; - V v = value.Values()[i]; - writer << k << v; - } - } - }; - - template - struct Serialization> - { - template - static void IO(Reader& reader, collections::Group& value) - { - vint32_t count = -1; - reader << count; - value.Clear(); - for (vint i = 0; i < count; i++) - { - K k; - collections::List v; - reader << k << v; - for (vint j = 0; j < v.Count(); j++) - { - value.Add(k, v[j]); - } - } - } - - template - static void IO(Writer& writer, collections::Group& value) - { - vint32_t count = (vint32_t)value.Count(); - writer << count; - for (vint i = 0; i < count; i++) - { - K k = value.Keys()[i]; - collections::List& v = const_cast&>(value.GetByIndex(i)); - writer << k << v; - } - } - }; - - template<> - struct Serialization - { - template - static void IO(Reader& reader, stream::IStream& value) - { - vint32_t count = 0; - reader.input.Read(&count, sizeof(count)); - - if (count > 0) - { - vint length = 0; - collections::Array buffer(count); - value.SeekFromBegin(0); - length = reader.input.Read(&buffer[0], count); - if (length != count) - { - CHECK_FAIL(L"Deserialization failed."); - } - length = value.Write(&buffer[0], count); - if (length != count) - { - CHECK_FAIL(L"Deserialization failed."); - } - value.SeekFromBegin(0); - } - } - - template - static void IO(Writer& writer, stream::IStream& value) - { - vint32_t count = (vint32_t)value.Size(); - writer.output.Write(&count, sizeof(count)); - - if (count > 0) - { - vint length = 0; - collections::Array buffer(count); - value.SeekFromBegin(0); - length = value.Read(&buffer[0], count); - if (length != count) - { - CHECK_FAIL(L"Serialization failed."); - } - length = writer.output.Write(&buffer[0], count); - if (length != count) - { - CHECK_FAIL(L"Serialization failed."); - } - value.SeekFromBegin(0); - } - } - }; - - //--------------------------------------------- - -#define BEGIN_SERIALIZATION(TYPE)\ - template<>\ - struct Serialization\ - {\ - template\ - static void IO(TIO& op, TYPE& value)\ - {\ - op\ - -#define SERIALIZE(FIELD)\ - << value.FIELD\ - -#define END_SERIALIZATION\ - ;\ - }\ - };\ - -#define SERIALIZE_ENUM(TYPE)\ - template<>\ - struct Serialization\ - {\ - template\ - static void IO(Reader& reader, TYPE& value)\ - {\ - vint32_t v = 0;\ - Serialization::IO(reader, v);\ - value = (TYPE)v;\ - }\ - template\ - static void IO(Writer& writer, TYPE& value)\ - {\ - vint32_t v = (vint32_t)value;\ - Serialization::IO(writer, v);\ - }\ - };\ - - } - } -} - -#endif - -/*********************************************************************** -COLLECTIONS\OPERATIONCOPYFROM.H +.\COLLECTIONS\OPERATIONCOPYFROM.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -5318,7 +3282,7 @@ namespace vl #endif /*********************************************************************** -COLLECTIONS\OPERATIONENUMERABLE.H +.\COLLECTIONS\OPERATIONENUMERABLE.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -5552,171 +3516,9 @@ namespace vl #endif -/*********************************************************************** -COLLECTIONS\OPERATIONSELECT.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Data Structure::Operations - -***********************************************************************/ - -#ifndef VCZH_COLLECTIONS_OPERATIONSELECT -#define VCZH_COLLECTIONS_OPERATIONSELECT - - -namespace vl -{ - namespace collections - { /*********************************************************************** -Select -***********************************************************************/ - - template - class SelectEnumerator : public virtual IEnumerator - { - protected: - IEnumerator* enumerator; - Func selector; - K current; - public: - SelectEnumerator(IEnumerator* _enumerator, const Func& _selector, K _current=K()) - :enumerator(_enumerator) - ,selector(_selector) - ,current(_current) - { - } - - ~SelectEnumerator() - { - delete enumerator; - } - - IEnumerator* Clone()const override - { - return new SelectEnumerator(enumerator->Clone(), selector, current); - } - - const K& Current()const override - { - return current; - } - - vint Index()const override - { - return enumerator->Index(); - } - - bool Next()override - { - if(enumerator->Next()) - { - current=selector(enumerator->Current()); - return true; - } - else - { - return false; - } - } - - void Reset()override - { - enumerator->Reset(); - } - }; - } -} - -#endif - -/*********************************************************************** -COLLECTIONS\OPERATIONWHERE.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Data Structure::Operations - -***********************************************************************/ - -#ifndef VCZH_COLLECTIONS_OPERATIONWHERE -#define VCZH_COLLECTIONS_OPERATIONWHERE - - -namespace vl -{ - namespace collections - { -/*********************************************************************** -Where -***********************************************************************/ - - template - class WhereEnumerator : public virtual IEnumerator - { - protected: - IEnumerator* enumerator; - Func selector; - vint index; - - public: - WhereEnumerator(IEnumerator* _enumerator, const Func& _selector, vint _index=-1) - :enumerator(_enumerator) - ,selector(_selector) - ,index(_index) - { - } - - ~WhereEnumerator() - { - delete enumerator; - } - - IEnumerator* Clone()const override - { - return new WhereEnumerator(enumerator->Clone(), selector, index); - } - - const T& Current()const override - { - return enumerator->Current(); - } - - vint Index()const override - { - return index; - } - - bool Next()override - { - while(enumerator->Next()) - { - if(selector(enumerator->Current())) - { - index++; - return true; - } - } - return false; - } - - void Reset()override - { - enumerator->Reset(); - index=-1; - } - }; - } -} - -#endif - -/*********************************************************************** -COLLECTIONS\OPERATIONCONCAT.H +.\COLLECTIONS\OPERATIONCONCAT.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -5823,7 +3625,191 @@ Concat #endif /*********************************************************************** -COLLECTIONS\OPERATIONSEQUENCE.H +.\COLLECTIONS\OPERATIONFOREACH.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Data Structure::Operations + +扩展: + 实现一个函数重载IteratorType CreateForEachIterator(const CollectionType& collection); + CollectionType是所需要的容器类型 + IteratorType继承自ForEachIterator + 必须写在vl::collections命名空间里 +***********************************************************************/ + +#ifndef VCZH_COLLECTIONS_FOREACH +#define VCZH_COLLECTIONS_FOREACH + +namespace vl +{ + namespace collections + { + +/*********************************************************************** +ForEach基础设施 +***********************************************************************/ + + template + class ForEachIterator : public Object + { + public: + virtual bool Next(T& variable)const=0; + + operator bool()const + { + return true; + } + }; + +/*********************************************************************** +IEnumerable支持 +***********************************************************************/ + + template + class EnumerableForEachIterator : public ForEachIterator + { + protected: + Ptr> enumerator; + public: + EnumerableForEachIterator(const IEnumerable& enumerable) + :enumerator(enumerable.CreateEnumerator()) + { + } + + EnumerableForEachIterator(const EnumerableForEachIterator& enumerableIterator) + :enumerator(enumerableIterator.enumerator) + { + } + + bool Next(T& variable)const + { + if(enumerator->Next()) + { + variable=enumerator->Current(); + return true; + } + else + { + return false; + } + } + }; + + template + EnumerableForEachIterator CreateForEachIterator(const IEnumerable& enumerable) + { + return enumerable; + } + +/*********************************************************************** +ForEach宏 +***********************************************************************/ + +#define FOREACH(TYPE, VARIABLE, COLLECTION)\ + SCOPE_VARIABLE(const ::vl::collections::ForEachIterator&, __foreach_iterator__, ::vl::collections::CreateForEachIterator(COLLECTION))\ + for(TYPE VARIABLE;__foreach_iterator__.Next(VARIABLE);) + +#define FOREACH_INDEXER(TYPE, VARIABLE, INDEXER, COLLECTION)\ + SCOPE_VARIABLE(const ::vl::collections::ForEachIterator&, __foreach_iterator__, ::vl::collections::CreateForEachIterator(COLLECTION))\ + SCOPE_VARIABLE(vint, INDEXER, 0)\ + for(TYPE VARIABLE;__foreach_iterator__.Next(VARIABLE);INDEXER++) + } +} + +#endif + +/*********************************************************************** +.\COLLECTIONS\OPERATIONPAIR.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Data Structure::Operations + +***********************************************************************/ + +#ifndef VCZH_COLLECTIONS_OPERATIONPAIR +#define VCZH_COLLECTIONS_OPERATIONPAIR + + +namespace vl +{ + namespace collections + { + +/*********************************************************************** +Pairwise +***********************************************************************/ + + template + class PairwiseEnumerator : public virtual IEnumerator> + { + protected: + IEnumerator* enumerator1; + IEnumerator* enumerator2; + Pair current; + public: + PairwiseEnumerator(IEnumerator* _enumerator1, IEnumerator* _enumerator2, Pair _current=Pair()) + :enumerator1(_enumerator1) + ,enumerator2(_enumerator2) + ,current(_current) + { + } + + ~PairwiseEnumerator() + { + delete enumerator1; + delete enumerator2; + } + + IEnumerator>* Clone()const override + { + return new PairwiseEnumerator(enumerator1->Clone(), enumerator2->Clone(), current); + } + + const Pair& Current()const override + { + return current; + } + + vint Index()const override + { + return enumerator1->Index(); + } + + bool Next()override + { + if(enumerator1->Next() && enumerator2->Next()) + { + current=Pair(enumerator1->Current(), enumerator2->Current()); + return true; + } + else + { + return false; + } + } + + void Reset()override + { + enumerator1->Reset(); + enumerator2->Reset(); + } + + bool Evaluated()const override + { + return enumerator1->Evaluated() && enumerator2->Evaluated(); + } + }; + } +} + +#endif + +/*********************************************************************** +.\COLLECTIONS\OPERATIONSEQUENCE.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -6261,7 +4247,7 @@ FromIterator #endif /*********************************************************************** -COLLECTIONS\OPERATIONSET.H +.\COLLECTIONS\OPERATIONSET.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -6351,7 +4337,428 @@ Intersect/Except #endif /*********************************************************************** -COLLECTIONS\OPERATIONPAIR.H +.\FUNCTION.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Framework::Function + +Classes: + Func :函数对象 + +Functions: + Curry :: (A->B) -> A -> B :参数拆分 + Combine :: (A->B) -> (A->C) -> (B->C->D) -> (A->D) :函数组合 +***********************************************************************/ +#ifndef VCZH_FUNCTION +#define VCZH_FUNCTION +#include +namespace vl +{ + +/*********************************************************************** +vl::Func +***********************************************************************/ + + template + class Func + { + }; + + namespace internal_invokers + { + template + class Invoker : public Object + { + public: + virtual R Invoke(TArgs&& ...args) = 0; + }; + + //------------------------------------------------------ + + template + class StaticInvoker : public Invoker + { + protected: + R(*function)(TArgs ...args); + + public: + StaticInvoker(R(*_function)(TArgs...)) + :function(_function) + { + } + + R Invoke(TArgs&& ...args)override + { + return function(ForwardValue(args)...); + } + }; + + //------------------------------------------------------ + + template + class MemberInvoker : public Invoker + { + protected: + C* sender; + R(C::*function)(TArgs ...args); + + public: + MemberInvoker(C* _sender, R(C::*_function)(TArgs ...args)) + :sender(_sender) + ,function(_function) + { + } + + R Invoke(TArgs&& ...args)override + { + return (sender->*function)(ForwardValue(args)...); + } + }; + + //------------------------------------------------------ + + template + class ObjectInvoker : public Invoker + { + protected: + C function; + + public: + ObjectInvoker(const C& _function) + :function(_function) + { + } + + R Invoke(TArgs&& ...args)override + { + return function(ForwardValue(args)...); + } + }; + + //------------------------------------------------------ + + template + class ObjectInvoker : public Invoker + { + protected: + C function; + + public: + ObjectInvoker(const C& _function) + :function(_function) + { + } + + void Invoke(TArgs&& ...args)override + { + function(ForwardValue(args)...); + } + }; + } + + /// A type representing a function reference. + /// The return type. + /// Types of parameters. + template + class Func : public Object + { + protected: + Ptr> invoker; + public: + typedef R FunctionType(TArgs...); + typedef R ResultType; + + /// Create a null function reference. + Func() + { + } + + /// Copy a function reference. + /// The function reference to copy. + Func(const Func& function) + { + invoker=function.invoker; + } + + /// Create a reference using a function pointer. + /// The function pointer. + Func(R(*function)(TArgs...)) + { + invoker=new internal_invokers::StaticInvoker(function); + } + + /// Create a reference using a method. + /// Type of the class that has the method. + /// The object that has the method. + /// The function pointer. + template + Func(C* sender, R(C::*function)(TArgs...)) + { + invoker=new internal_invokers::MemberInvoker(sender, function); + } + + /// Create a reference using a function object. + /// Type of the function object. + /// The function object. It could be a lambda expression. + template + Func(const C& function) + { + invoker=new internal_invokers::ObjectInvoker(function); + } + + /// Invoke the function. + /// Returns the function result. + /// Arguments to invoke the function. + R operator()(TArgs ...args)const + { + return invoker->Invoke(ForwardValue(args)...); + } + + bool operator==(const Func& function)const + { + return invoker == function.invoker; + } + + bool operator!=(const Func& function)const + { + return invoker != function.invoker; + } + + /// Test is the reference a null reference. + /// Returns true if it is not a null reference. + operator bool()const + { + return invoker; + } + }; + +/*********************************************************************** +vl::function_lambda::LambdaRetriveType +***********************************************************************/ + + namespace function_lambda + { + template + struct LambdaRetriveType + { + typedef vint Type; + typedef vint FunctionType; + typedef vint ResultType; + }; + + template + struct FunctionObjectRetriveType + { + typedef typename LambdaRetriveType::Type Type; + typedef typename LambdaRetriveType::FunctionType FunctionType; + typedef typename LambdaRetriveType::ResultType ResultType; + }; + + template + struct LambdaRetriveType + { + typedef Func Type; + typedef R(FunctionType)(TArgs...); + typedef R ResultType; + }; + + template + struct LambdaRetriveType + { + typedef Func Type; + typedef R(FunctionType)(TArgs...); + typedef R ResultType; + }; + + template + struct FunctionObjectRetriveType + { + typedef Func Type; + typedef R(FunctionType)(TArgs...); + typedef R ResultType; + }; + + /// Create a function reference to a function object or a lambda expression, with all type information autotimatically inferred. You can use the macro called "LAMBDA" to refer to this function. + /// Type of the function object or the lambda expression. + /// The function reference. + /// The function object or the lambda expression. + template + typename LambdaRetriveType::Type Lambda(T functionObject) + { + return functionObject; + } + + /// Create a function reference to a function pointer, with all type information autotimatically inferred. You can use the macro called "FUNCTION" to refer to this function. + /// Type of the function pointer. + /// The function reference. + /// The function pointer. + template + typename FunctionObjectRetriveType::Type ConvertToFunction(T functionObject) + { + return functionObject; + } + +#define LAMBDA vl::function_lambda::Lambda +#define FUNCTION vl::function_lambda::ConvertToFunction +#define FUNCTION_TYPE(T) typename vl::function_lambda::FunctionObjectRetriveType::Type +#define FUNCTION_RESULT_TYPE(T) typename vl::function_lambda::FunctionObjectRetriveType::ResultType + } + +/*********************************************************************** +vl::function_binding::Binding +***********************************************************************/ + + namespace function_binding + { + template + struct Binding + { + }; + + template + struct CR{typedef const T& Type;}; + template + struct CR{typedef T& Type;}; + template + struct CR{typedef const T& Type;}; + template + struct CR{typedef const T& Type;}; + + template + struct Binding + { + typedef R FunctionType(T0, TArgs...); + typedef R CurriedType(TArgs...); + typedef T0 FirstParameterType; + + class Binder : public Object + { + protected: + Func target; + T0 firstArgument; + public: + Binder(const Func& _target, T0 _firstArgument) + :target(_target) + ,firstArgument(ForwardValue(_firstArgument)) + { + } + + R operator()(TArgs ...args)const + { + return target(firstArgument, args...); + } + }; + + class Currier : public Object + { + protected: + Func target; + public: + Currier(const Func& _target) + :target(_target) + { + } + + Func operator()(T0 firstArgument)const + { + return Binder(target, firstArgument); + } + }; + }; + } + + /// Currize a function. Currizing means to create a new function whose argument is the first argument of the original function. Calling this function will return another function reference whose arguments is all remain arguments of the original function. Calling the returned function will call the original function. + /// Type of the function. + /// The currized function. + /// The function pointer to currize. + template + Func::CurriedType>(typename function_binding::Binding::FirstParameterType)> + Curry(T* function) + { + return typename function_binding::Binding::Currier(function); + } + + /// Currize a function. Currizing means to create a new function whose argument is the first argument of the original function. Calling this function will return another function reference whose arguments is all remain arguments of the original function. Calling the returned function will call the original function. + /// Type of the function. + /// The currized function. + /// The function reference to currize. + template + Func::CurriedType>(typename function_binding::Binding::FirstParameterType)> + Curry(const Func& function) + { + return typename function_binding::Binding::Currier(function); + } + +/*********************************************************************** +vl::function_combining::Combining +***********************************************************************/ + + namespace function_combining + { + template + class Combining + { + }; + + template + class Combining : public Object + { + protected: + Func function1; + Func function2; + Func converter; + public: + typedef R1 FirstFunctionType(TArgs...); + typedef R2 SecondFunctionType(TArgs...); + typedef R ConverterFunctionType(R1, R2); + typedef R FinalFunctionType(TArgs...); + + Combining(const Func& _function1, const Func& _function2, const Func& _converter) + :function1(_function1) + ,function2(_function2) + ,converter(_converter) + { + } + + R operator()(TArgs&& ...args)const + { + return converter(function1(ForwardValue(args)...), function2(ForwardValue(args)...)); + } + }; + } + + /// Combine two functions with a converter function. The two functions to combine should have the same argument types. The converter function will use the return values of the two function to calculate the final value. + /// Type of the first function. + /// Type of the second function. + /// Type of the converter function. + /// A new function whose argument list are the same of the two functions to provide. Calling this function will call function1, function2 and converter in order to calculate the final value. + /// The converter function. + /// The first function. + /// The second function. + template + Func::FinalFunctionType> + Combine(Func converter, Func function1, Func function2) + { + return function_combining::Combining(function1, function2, converter); + } + + /// Use the converter function to create a combiner, who will receive two function and use to create a combined function. This function assumes the result types of the two provided function in the future are the same, and the converter function will not change the result type. + /// Type of the two functions to combine. + /// The combiner. + /// The converter function. + template + Func(Func,Func)> Combiner(const Func::ResultType(typename Func::ResultType,typename Func::ResultType)>& converter) + { + typedef typename Func::ResultType R; + return Curry(Func,Func,Func)>(Combine)(converter); + } +} +#endif + +/*********************************************************************** +.\COLLECTIONS\OPERATIONSELECT.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -6360,8 +4767,8 @@ Data Structure::Operations ***********************************************************************/ -#ifndef VCZH_COLLECTIONS_OPERATIONPAIR -#define VCZH_COLLECTIONS_OPERATIONPAIR +#ifndef VCZH_COLLECTIONS_OPERATIONSELECT +#define VCZH_COLLECTIONS_OPERATIONSELECT namespace vl @@ -6370,50 +4777,49 @@ namespace vl { /*********************************************************************** -Pairwise +Select ***********************************************************************/ - template - class PairwiseEnumerator : public virtual IEnumerator> + template + class SelectEnumerator : public virtual IEnumerator { protected: - IEnumerator* enumerator1; - IEnumerator* enumerator2; - Pair current; + IEnumerator* enumerator; + Func selector; + K current; public: - PairwiseEnumerator(IEnumerator* _enumerator1, IEnumerator* _enumerator2, Pair _current=Pair()) - :enumerator1(_enumerator1) - ,enumerator2(_enumerator2) + SelectEnumerator(IEnumerator* _enumerator, const Func& _selector, K _current=K()) + :enumerator(_enumerator) + ,selector(_selector) ,current(_current) { } - ~PairwiseEnumerator() + ~SelectEnumerator() { - delete enumerator1; - delete enumerator2; + delete enumerator; } - IEnumerator>* Clone()const override + IEnumerator* Clone()const override { - return new PairwiseEnumerator(enumerator1->Clone(), enumerator2->Clone(), current); + return new SelectEnumerator(enumerator->Clone(), selector, current); } - const Pair& Current()const override + const K& Current()const override { return current; } vint Index()const override { - return enumerator1->Index(); + return enumerator->Index(); } bool Next()override { - if(enumerator1->Next() && enumerator2->Next()) + if(enumerator->Next()) { - current=Pair(enumerator1->Current(), enumerator2->Current()); + current=selector(enumerator->Current()); return true; } else @@ -6424,13 +4830,7 @@ Pairwise void Reset()override { - enumerator1->Reset(); - enumerator2->Reset(); - } - - bool Evaluated()const override - { - return enumerator1->Evaluated() && enumerator2->Evaluated(); + enumerator->Reset(); } }; } @@ -6439,7 +4839,7 @@ Pairwise #endif /*********************************************************************** -COLLECTIONS\OPERATIONSTRING.H +.\COLLECTIONS\OPERATIONWHERE.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -6448,1120 +4848,80 @@ Data Structure::Operations ***********************************************************************/ -#ifndef VCZH_COLLECTIONS_OPERATIONSTRING -#define VCZH_COLLECTIONS_OPERATIONSTRING +#ifndef VCZH_COLLECTIONS_OPERATIONWHERE +#define VCZH_COLLECTIONS_OPERATIONWHERE namespace vl { namespace collections { - template - void CopyFrom(Ds& ds, const ObjectString& ss, bool append=false) - { - const S* buffer=ss.Buffer(); - vint count=ss.Length(); - CopyFrom(ds, buffer, count, append); - } - - template - void CopyFrom(ObjectString& ds, const Ss& ss, bool append=false) - { - Array da(ds.Buffer(), ds.Length()); - CopyFrom(da, ss, append); - if(da.Count()==0) - { - ds=ObjectString(); - } - else - { - ds=ObjectString(&da[0], da.Count()); - } - } - } -} - -#endif - /*********************************************************************** -COLLECTIONS\OPERATIONFOREACH.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Data Structure::Operations - -扩展: - 实现一个函数重载IteratorType CreateForEachIterator(const CollectionType& collection); - CollectionType是所需要的容器类型 - IteratorType继承自ForEachIterator - 必须写在vl::collections命名空间里 -***********************************************************************/ - -#ifndef VCZH_COLLECTIONS_FOREACH -#define VCZH_COLLECTIONS_FOREACH - -namespace vl -{ - namespace collections - { - -/*********************************************************************** -ForEach基础设施 +Where ***********************************************************************/ template - class ForEachIterator : public Object - { - public: - virtual bool Next(T& variable)const=0; - - operator bool()const - { - return true; - } - }; - -/*********************************************************************** -IEnumerable支持 -***********************************************************************/ - - template - class EnumerableForEachIterator : public ForEachIterator + class WhereEnumerator : public virtual IEnumerator { protected: - Ptr> enumerator; + IEnumerator* enumerator; + Func selector; + vint index; + public: - EnumerableForEachIterator(const IEnumerable& enumerable) - :enumerator(enumerable.CreateEnumerator()) + WhereEnumerator(IEnumerator* _enumerator, const Func& _selector, vint _index=-1) + :enumerator(_enumerator) + ,selector(_selector) + ,index(_index) { } - EnumerableForEachIterator(const EnumerableForEachIterator& enumerableIterator) - :enumerator(enumerableIterator.enumerator) + ~WhereEnumerator() { + delete enumerator; } - bool Next(T& variable)const + IEnumerator* Clone()const override { - if(enumerator->Next()) + return new WhereEnumerator(enumerator->Clone(), selector, index); + } + + const T& Current()const override + { + return enumerator->Current(); + } + + vint Index()const override + { + return index; + } + + bool Next()override + { + while(enumerator->Next()) { - variable=enumerator->Current(); - return true; - } - else - { - return false; + if(selector(enumerator->Current())) + { + index++; + return true; + } } + return false; + } + + void Reset()override + { + enumerator->Reset(); + index=-1; } }; - - template - EnumerableForEachIterator CreateForEachIterator(const IEnumerable& enumerable) - { - return enumerable; - } - -/*********************************************************************** -ForEach宏 -***********************************************************************/ - -#define FOREACH(TYPE, VARIABLE, COLLECTION)\ - SCOPE_VARIABLE(const ::vl::collections::ForEachIterator&, __foreach_iterator__, ::vl::collections::CreateForEachIterator(COLLECTION))\ - for(TYPE VARIABLE;__foreach_iterator__.Next(VARIABLE);) - -#define FOREACH_INDEXER(TYPE, VARIABLE, INDEXER, COLLECTION)\ - SCOPE_VARIABLE(const ::vl::collections::ForEachIterator&, __foreach_iterator__, ::vl::collections::CreateForEachIterator(COLLECTION))\ - SCOPE_VARIABLE(vint, INDEXER, 0)\ - for(TYPE VARIABLE;__foreach_iterator__.Next(VARIABLE);INDEXER++) } } #endif /*********************************************************************** -REGEX\REGEX.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Regex::Regular Expression - -Classes: - RegexString :字符串匹配结果 - RegexMatch :匹配结果 - Regex :正则表达式引擎 - RegexToken :词法记号 - RegexTokens :词法记号表 - RegexLexer :词法分析器 -***********************************************************************/ - -#ifndef VCZH_REGEX_REGEX -#define VCZH_REGEX_REGEX - - -namespace vl -{ - namespace regex_internal - { - class PureResult; - class PureInterpretor; - class RichResult; - class RichInterpretor; - } - - namespace regex - { - -/*********************************************************************** -正则表达式引擎数据结构 -***********************************************************************/ - - /// A type representing a fragment of the input string. - class RegexString : public Object - { - protected: - WString value; - vint start; - vint length; - - public: - RegexString(vint _start=0); - RegexString(const WString& _string, vint _start, vint _length); - - /// The position of the input string. - /// The position. - vint Start()const; - /// The size of the fragment in characters. - /// The size. - vint Length()const; - /// Get the fragment. - /// The fragment. - const WString& Value()const; - bool operator==(const RegexString& string)const; - }; - - /// A type representing a match of the input string. - class RegexMatch : public Object, private NotCopyable - { - friend class Regex; - public: - typedef Ptr Ref; - typedef collections::List List; - typedef collections::List CaptureList; - typedef collections::Group CaptureGroup; - protected: - collections::List captures; - collections::Group groups; - bool success; - RegexString result; - - RegexMatch(const WString& _string, regex_internal::PureResult* _result); - RegexMatch(const WString& _string, regex_internal::RichResult* _result, regex_internal::RichInterpretor* _rich); - RegexMatch(const RegexString& _result); - public: - - /// Test if this match is a success match or a failed match. A failed match will only appear when calling [M:vl.regex.Regex.Split] or [M:vl.regex.Regex.Cut]. In other cases, failed matches are either not included in the result, or become null pointers. - /// Returns true if this match is a success match. - bool Success()const; - /// Get the whole fragment that matches. - /// The whole fragment. - const RegexString& Result()const; - /// Get all fragments that are captured. - /// All fragments that are captured. - const CaptureList& Captures()const; - /// Get all fragments that are captured by named groups. - /// All fragments that are captured. - const CaptureGroup& Groups()const; - }; - -/*********************************************************************** -正则表达式引擎 -***********************************************************************/ - - /// , \^, \$, \!, \=: represents itself - /// Escaped characters in charset defined in a square bracket: - /// \r: the CR character - /// \n: the LF character - /// \t: the tab character - /// \-, \[, \], \\, \/, \^, \$: represents itself - /// 4) Loops: - /// regex{3}: repeats 3 times - /// regex{3,}: repeats 3 or more times - /// regex{1,3}: repeats 1 to 3 times - /// regex?: repeats 0 or 1 times - /// regex*: repeats 0 or more times - /// regex+: repeats 1 or more times - /// if you add a "?" right after a loop, it means repeating as less as possible (DFA incompatible) - /// 5) Capturing: (DFA incompatible) - /// (regex): No capturing, just change the operators' association - /// (?regex): Capture matched fragment - /// (?regex): Capture matched fragment in a named group called "name" - /// (<$i>): Match the i-th captured fragment, begins from 0 - /// (<$name;i>): Match the i-th captured fragment in the named group called "name", begins from 0 - /// (<$name>): Match any captured fragment in the named group called "name" - /// 6) MISC - /// (=regex): The prefix of the following text should match the regex, but it is not counted in the whole match (DFA incompatible) - /// (!regex): Any prefix of the following text should not match the regex, and it is not counted in the whole match (DFA incompatible) - /// (<#name>regex): Name the regex "name", and it applies here - /// (<&name>): Copy the named regex "name" here and apply - /// ]]> - class Regex : public Object, private NotCopyable - { - protected: - regex_internal::PureInterpretor* pure; - regex_internal::RichInterpretor* rich; - - void Process(const WString& text, bool keepEmpty, bool keepSuccess, bool keepFail, RegexMatch::List& matches)const; - public: - /// Create a regular expression. - /// The regular expression in a string. - /// Set to true to tell the Regex to use DFA if possible. - Regex(const WString& code, bool preferPure=true); - ~Regex(); - - /// Test does the Regex uses DFA to match a string. - /// Returns true if DFA is used. - bool IsPureMatch()const; - /// Test does the Regex uses DFA to test a string. Test means ignoring all capturing requirements. - /// Returns true if DFA is used. - bool IsPureTest()const; - - /// Match a prefix of the text. - /// Returns the match. Returns null if failed. - /// The text to match. - RegexMatch::Ref MatchHead(const WString& text)const; - /// Match a fragment of the text. - /// Returns the match. Returns null if failed. - /// The text to match. - RegexMatch::Ref Match(const WString& text)const; - /// Match a prefix of the text, ignoring all capturing requirements. - /// Returns true if succeeded. - /// The text to match. - bool TestHead(const WString& text)const; - /// Match a fragment of the text, ignoring all capturing requirements. - /// Returns true if succeeded. - /// The text to match. - bool Test(const WString& text)const; - /// Find all matched fragments of the text, returning all matched fragments. - /// The text to match. - /// All successful matches. - void Search(const WString& text, RegexMatch::List& matches)const; - /// Split the text by matched fragments, returning all unmatched fragments. - /// The text to match. - /// Set to true to keep all empty matches. - /// All failed matches. - void Split(const WString& text, bool keepEmptyMatch, RegexMatch::List& matches)const; - /// Cut the text by matched fragments, returning all matched or unmatched fragments. - /// The text to match. - /// Set to true to keep all empty matches. - /// All successful and failed matches. - void Cut(const WString& text, bool keepEmptyMatch, RegexMatch::List& matches)const; - }; - -/*********************************************************************** -正则表达式词法分析器 -***********************************************************************/ - - /// A token. - class RegexToken - { - public: - /// Position in the input string. - vint start; - /// Size of this token in characters. - vint length; - /// The token id, begins at 0, represents the regular expression in the list that matches this token. -1 means this token is produced by an error. - vint token; - /// The pointer to where this token starts in the input string . - const wchar_t* reading; - /// The argument value from [M:vl.regex.RegexLexer.Parse]. - vint codeIndex; - /// True if this token is complete. False if this token does not end here. - bool completeToken; - - /// Row number of the first character, begins at 0. - vint rowStart; - /// Column number of the first character, begins at 0. - vint columnStart; - /// Row number of the last character, begins at 0. - vint rowEnd; - /// Column number of the last character, begins at 0. - vint columnEnd; - - bool operator==(const RegexToken& _token)const; - bool operator==(const wchar_t* _token)const; - }; - - /// Token collection representing the result from the lexical analyzer. - class RegexTokens : public Object, public collections::IEnumerable - { - friend class RegexLexer; - protected: - regex_internal::PureInterpretor* pure; - const collections::Array& stateTokens; - WString code; - vint codeIndex; - - RegexTokens(regex_internal::PureInterpretor* _pure, const collections::Array& _stateTokens, const WString& _code, vint _codeIndex); - public: - RegexTokens(const RegexTokens& tokens); - - collections::IEnumerator* CreateEnumerator()const; - - /// Copy all tokens. - /// Returns all tokens. - /// A callback to decide which kind of tokens to discard. The input is [F:vl.regex.RegexToken.token]. Returns true to discard this kind of tokens. - void ReadToEnd(collections::List& tokens, bool(*discard)(vint)=0)const; - }; - - /// Lexical walker. - class RegexLexerWalker : public Object - { - friend class RegexLexer; - protected: - regex_internal::PureInterpretor* pure; - const collections::Array& stateTokens; - - RegexLexerWalker(regex_internal::PureInterpretor* _pure, const collections::Array& _stateTokens); - public: - RegexLexerWalker(const RegexLexerWalker& walker); - ~RegexLexerWalker(); - - /// Get the start DFA state number, which represents the correct state before parsing any input. - /// The DFA state number. - vint GetStartState()const; - /// Test if this state can only lead to the end of one kind of token. - /// Returns the token index if this state can only lead to the end of one kind of token. Returns -1 if not. - /// The DFA state number. - vint GetRelatedToken(vint state)const; - /// Step forward by one character. - /// The input character. - /// The current state. Returns the new current state when this function returns. - /// Returns the token index at the end of the token. - /// Returns true if it reach the end of the token. - /// Returns true if the last character is the end of the token. - void Walk(wchar_t input, vint& state, vint& token, bool& finalState, bool& previousTokenStop)const; - /// Step forward by one character. - /// Returns the new current state. - /// The input character. - /// The current state. - vint Walk(wchar_t input, vint state)const; - /// Test if the input text is a complete token. - /// Returns true if the input text is a complete token. - /// The input text. - /// Size of the input text in characters. - bool IsClosedToken(const wchar_t* input, vint length)const; - /// Test if the input is a complete token. - /// Returns true if the input text is a complete token. - /// The input text. - bool IsClosedToken(const WString& input)const; - }; - - /// Lexical colorizer. - class RegexLexerColorizer : public Object - { - friend class RegexLexer; - public: - typedef void(*TokenProc)(void* argument, vint start, vint length, vint token); - - protected: - RegexLexerWalker walker; - vint currentState; - - RegexLexerColorizer(const RegexLexerWalker& _walker); - public: - RegexLexerColorizer(const RegexLexerColorizer& colorizer); - ~RegexLexerColorizer(); - - /// Reset the colorizer using the DFA state number. - /// The DFA state number. - void Reset(vint state); - /// Step forward by one character. - /// The input character. - void Pass(wchar_t input); - /// Get the start DFA state number, which represents the correct state before colorizing any characters. - /// The DFA state number. - vint GetStartState()const; - /// Get the current DFA state number. - /// The DFA state number. - vint GetCurrentState()const; - /// Colorize a text. - /// The text to colorize. - /// Size of the text in characters. - /// Colorizer callback. This callback will be called if any token is found.. - /// The argument to call the callback. - void Colorize(const wchar_t* input, vint length, TokenProc tokenProc, void* tokenProcArgument); - }; - - /// Lexical analyzer. - class RegexLexer : public Object, private NotCopyable - { - protected: - regex_internal::PureInterpretor* pure; - collections::Array ids; - collections::Array stateTokens; - public: - /// Create a lexical analyzer by a set of regular expressions. [F:vl.regex.RegexToken.token] will be the index of the matched regular expression. - /// The regular expressions. - RegexLexer(const collections::IEnumerable& tokens); - ~RegexLexer(); - - /// Tokenize a input text. - /// The result. - /// The text to tokenize. - /// Extra information that will store in [F:vl.regex.RegexToken.codeIndex]. - RegexTokens Parse(const WString& code, vint codeIndex=-1)const; - /// Create a equivalence walker from this lexical analyzer. - /// The walker. - RegexLexerWalker Walk()const; - /// Create a equivalence colorizer from this lexical analyzer. - /// The colorizer. - RegexLexerColorizer Colorize()const; - }; - } -} - -#endif - -/*********************************************************************** -STREAM\ACCESSOR.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Stream::Accessor - -Classes: - TextReader :字符串阅读器 - TextWriter :字符串书写器 - StreamReader :流阅读器 - StreamWriter :流书写器 - EncoderStream :编码流 - DecoderStream :解码流 -***********************************************************************/ - -#ifndef VCZH_STREAM_ACCESSOR -#define VCZH_STREAM_ACCESSOR - - -namespace vl -{ - namespace stream - { - -/*********************************************************************** -流控制器 -***********************************************************************/ - - /// Text reader. All line breaks are normalized to CRLF regardless the format in the source. - class TextReader : public Object, private NotCopyable - { - public: - /// Test does the reader reach the end or not. - /// Returns true if the reader reaches the end. - virtual bool IsEnd()=0; - /// Read a single character. - /// The character. - virtual wchar_t ReadChar()=0; - /// Read a string of a specified size. - /// The string. - /// Expected length of the string to read. - virtual WString ReadString(vint length); - /// Read a string until a line breaks is reached. - /// The string. It does not contain the line break. - virtual WString ReadLine(); - /// Read everying remain. - /// The string. - virtual WString ReadToEnd(); - }; - - /// Text writer. - class TextWriter : public Object, private NotCopyable - { - public: - /// Write a single character. - /// The character to write. - virtual void WriteChar(wchar_t c)=0; - /// Write a string. - /// Buffer to the string to write. - /// Size of the string in characters not including the zero terminator. - virtual void WriteString(const wchar_t* string, vint charCount); - /// Write a string. - /// Buffer to the zero terminated string to write. - virtual void WriteString(const wchar_t* string); - /// Write a string. - /// The string to write. - virtual void WriteString(const WString& string); - /// Write a string with a CRLF. - /// Buffer to the string to write. - /// Size of the string in characters not including the zero terminator. - virtual void WriteLine(const wchar_t* string, vint charCount); - /// Write a string with a CRLF. - /// Buffer to the zero terminated string to write. - virtual void WriteLine(const wchar_t* string); - /// Write a string with a CRLF. - /// The string to write. - virtual void WriteLine(const WString& string); - - virtual void WriteMonospacedEnglishTable(collections::Array& tableByRow, vint rows, vint columns); - }; - - /// Text reader from a string. - class StringReader : public TextReader - { - protected: - WString string; - vint current; - bool lastCallIsReadLine; - - void PrepareIfLastCallIsReadLine(); - public: - /// Create a text reader. - /// The string to read. - StringReader(const WString& _string); - - bool IsEnd(); - wchar_t ReadChar(); - WString ReadString(vint length); - WString ReadLine(); - WString ReadToEnd(); - }; - - /// Text reader from a stream. - class StreamReader : public TextReader - { - protected: - IStream* stream; - public: - /// Create a text reader. - /// The stream to read. - StreamReader(IStream& _stream); - - bool IsEnd(); - wchar_t ReadChar(); - }; - - /// Text writer to a stream. - class StreamWriter : public TextWriter - { - protected: - IStream* stream; - public: - /// Create a text writer. - /// The stream to write. - StreamWriter(IStream& _stream); - using TextWriter::WriteString; - - void WriteChar(wchar_t c); - void WriteString(const wchar_t* string, vint charCount); - }; - -/*********************************************************************** -编码解码 -***********************************************************************/ - - /// Encoder stream, a writable stream using an [T:vl.stream.IEncoder] to transform content. - class EncoderStream : public virtual IStream - { - protected: - IStream* stream; - IEncoder* encoder; - pos_t position; - - public: - /// Create a stream. - /// The target stream to write. - /// The encoder to transform content. - EncoderStream(IStream& _stream, IEncoder& _encoder); - ~EncoderStream(); - - bool CanRead()const; - bool CanWrite()const; - bool CanSeek()const; - bool CanPeek()const; - bool IsLimited()const; - bool IsAvailable()const; - void Close(); - pos_t Position()const; - pos_t Size()const; - void Seek(pos_t _size); - void SeekFromBegin(pos_t _size); - void SeekFromEnd(pos_t _size); - vint Read(void* _buffer, vint _size); - vint Write(void* _buffer, vint _size); - vint Peek(void* _buffer, vint _size); - }; - - /// Decoder stream, a readable stream using an [T:vl.stream.IDecoder] to transform content. - class DecoderStream : public virtual IStream - { - protected: - IStream* stream; - IDecoder* decoder; - pos_t position; - - public: - /// Create a stream. - /// The target stream to read. - /// The decoder to transform content. - DecoderStream(IStream& _stream, IDecoder& _decoder); - ~DecoderStream(); - - bool CanRead()const; - bool CanWrite()const; - bool CanSeek()const; - bool CanPeek()const; - bool IsLimited()const; - bool IsAvailable()const; - void Close(); - pos_t Position()const; - pos_t Size()const; - void Seek(pos_t _size); - void SeekFromBegin(pos_t _size); - void SeekFromEnd(pos_t _size); - vint Read(void* _buffer, vint _size); - vint Write(void* _buffer, vint _size); - vint Peek(void* _buffer, vint _size); - }; - } -} - -#endif - -/*********************************************************************** -STREAM\COMPRESSIONSTREAM.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Stream::CharFormat - -Classes: -***********************************************************************/ - -#ifndef VCZH_STREAM_COMPRESSIONSTREAM -#define VCZH_STREAM_COMPRESSIONSTREAM - - -namespace vl -{ - namespace stream - { - -/*********************************************************************** -Compression -***********************************************************************/ - - namespace lzw - { - static const vint BufferSize = 1024; - static const vint MaxDictionarySize = 1 << 24; - - struct Code - { - typedef collections::PushOnlyAllocator CodeAllocator; - typedef collections::ByteObjectMap::Allocator MapAllocator; - - vuint8_t byte = 0; - vint code = -1; - Code* parent = 0; - vint size = 0; - collections::ByteObjectMap children; - }; - } - - class LzwBase : public Object - { - protected: - lzw::Code::CodeAllocator codeAllocator; - lzw::Code::MapAllocator mapAllocator; - lzw::Code* root; - vint eofIndex = -1; - vint nextIndex = 0; - vint indexBits = 1; - - void UpdateIndexBits(); - lzw::Code* CreateCode(lzw::Code* parent, vuint8_t byte); - - LzwBase(); - LzwBase(bool (&existingBytes)[256]); - ~LzwBase(); - }; - - /// An encoder to compress using Lzw algorithm. - class LzwEncoder : public LzwBase, public IEncoder - { - protected: - IStream* stream = 0; - - vuint8_t buffer[lzw::BufferSize]; - vint bufferUsedBits = 0; - lzw::Code* prefix; - - void Flush(); - void WriteNumber(vint number, vint bitSize); - public: - /// Create an encoder. - LzwEncoder(); - /// Create an encoder and tell it which byte will never appear in the data before compression. - /// An array to tell the encoder which byte will never appear in the data before compression. - LzwEncoder(bool (&existingBytes)[256]); - ~LzwEncoder(); - - void Setup(IStream* _stream)override; - void Close()override; - vint Write(void* _buffer, vint _size)override; - }; - - /// An decoder to decompress using Lzw algorithm. - class LzwDecoder :public LzwBase, public IDecoder - { - protected: - IStream* stream = 0; - collections::List dictionary; - lzw::Code* lastCode = 0; - - vuint8_t inputBuffer[lzw::BufferSize]; - vint inputBufferSize = 0; - vint inputBufferUsedBits = 0; - - collections::Array outputBuffer; - vint outputBufferSize = 0; - vint outputBufferUsedBytes = 0; - - bool ReadNumber(vint& number, vint bitSize); - void PrepareOutputBuffer(vint size); - void ExpandCodeToOutputBuffer(lzw::Code* code); - public: - /// Create an decoder. - LzwDecoder(); - /// Create an decoder and tell it which byte will never appear in the data before compression. - /// An array to tell the encoder which byte will never appear in the data before compression. - LzwDecoder(bool (&existingBytes)[256]); - ~LzwDecoder(); - - void Setup(IStream* _stream)override; - void Close()override; - vint Read(void* _buffer, vint _size)override; - }; - } -} - -#endif - -/*********************************************************************** -LOCALE.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Framework::Locale - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_LOCALE -#define VCZH_LOCALE - - -namespace vl -{ - /// Locale awared operations. Macro "INVLOC" is a shortcut to get a invariant locale. - class Locale : public Object - { - protected: - WString localeName; - - public: - Locale(const WString& _localeName=WString::Empty); - ~Locale(); - - bool operator==(const Locale& value)const { return localeName==value.localeName; } - bool operator!=(const Locale& value)const { return localeName!=value.localeName; } - bool operator<(const Locale& value)const { return localeName(const Locale& value)const { return localeName>value.localeName; } - bool operator>=(const Locale& value)const { return localeName>=value.localeName; } - - /// Get the invariant locale. - /// The invariant locale. - static Locale Invariant(); - /// Get the system default locale. This locale controls the code page that used by the the system to interpret ANSI string buffers. - /// The system default locale. - static Locale SystemDefault(); - /// Get the user default locale. This locale reflect the user's setting. - /// The user default locale. - static Locale UserDefault(); - /// Get all supported locales. - /// All supported locales. - static void Enumerate(collections::List& locales); - - /// Get the name of the locale. - /// The name of the locale. - const WString& GetName()const; - - /// Get all short date formats for the locale. - /// The formats. - void GetShortDateFormats(collections::List& formats)const; - /// Get all long date formats for the locale. - /// The formats. - void GetLongDateFormats(collections::List& formats)const; - /// Get all Year-Month date formats for the locale. - /// The formats. - void GetYearMonthDateFormats(collections::List& formats)const; - /// Get all long time formats for the locale. - /// The formats. - void GetLongTimeFormats(collections::List& formats)const; - /// Get all short time formats for the locale. - /// The formats. - void GetShortTimeFormats(collections::List& formats)const; - - /// Convert a date to a formatted string. - /// The formatted string. - /// The format to use. - /// The date to convert. - WString FormatDate(const WString& format, DateTime date)const; - /// Convert a time to a formatted string. - /// The formatted string. - /// The format to use. - /// The time to convert. - WString FormatTime(const WString& format, DateTime time)const; -#ifdef VCZH_MSVC - /// Convert a number to a formatted string. - /// The formatted string. - /// The number to convert. - WString FormatNumber(const WString& number)const; - /// Convert a currency (money) to a formatted string. - /// The formatted string. - /// The currency to convert. - WString FormatCurrency(const WString& currency)const; -#endif - - /// Get the short display string of a day of week. - /// The display string. - /// Day of week, begins from 0 as Sunday. - WString GetShortDayOfWeekName(vint dayOfWeek)const; - /// Get the long display string of a day of week. - /// The display string. - /// Day of week, begins from 0 as Sunday. - WString GetLongDayOfWeekName(vint dayOfWeek)const; - /// Get the short display string of a month. - /// The display string. - /// Month, begins from 1 as January. - WString GetShortMonthName(vint month)const; - /// Get the long display string of a month. - /// The display string. - /// Month, begins from 1 as January. - WString GetLongMonthName(vint month)const; - -#ifdef VCZH_MSVC - /// Convert characters to the full width. - /// The converted string. - /// The string to convert. - WString ToFullWidth(const WString& str)const; - /// Convert characters to the half width. - /// The converted string. - /// The string to convert. - WString ToHalfWidth(const WString& str)const; - /// Convert characters to the Hiragana. - /// The converted string. - /// The string to convert. - WString ToHiragana(const WString& str)const; - /// Convert characters to the Katagana. - /// The converted string. - /// The string to convert. - WString ToKatagana(const WString& str)const; -#endif - - /// Convert characters to the lower case using the file system rule. - /// The converted string. - /// The string to convert. - WString ToLower(const WString& str)const; - /// Convert characters to the upper case using the file system rule. - /// The converted string. - /// The string to convert. - WString ToUpper(const WString& str)const; - /// Convert characters to the lower case using the linguistic rule. - /// The converted string. - /// The string to convert. - WString ToLinguisticLower(const WString& str)const; - /// Convert characters to the upper case using the linguistic rule. - /// The converted string. - /// The string to convert. - WString ToLinguisticUpper(const WString& str)const; - -#ifdef VCZH_MSVC - /// Convert characters to Simplified Chinese. - /// The converted string. - /// The string to convert. - WString ToSimplifiedChinese(const WString& str)const; - /// Convert characters to the Traditional Chinese. - /// The converted string. - /// The string to convert. - WString ToTraditionalChinese(const WString& str)const; - /// Convert characters to the tile case, in which the first letter of each major word is capitalized. - /// The converted string. - /// The string to convert. - WString ToTileCase(const WString& str)const; -#endif - - /// Mergable flags controlling how to normalize a string. - enum Normalization - { - /// Do nothing. - None=0, - /// Ignore case using the file system rule. - IgnoreCase=1, -#ifdef VCZH_MSVC - /// Ignore case using the linguistic rule. - IgnoreCaseLinguistic=2, - /// Ignore the difference between between hiragana and katakana characters. - IgnoreKanaType=4, - /// Ignore nonspacing characters. - IgnoreNonSpace=8, - /// Ignore symbols and punctuation. - IgnoreSymbol=16, - /// Ignore the difference between half-width and full-width characters. - IgnoreWidth=32, - /// Treat digits as numbers during sorting. - DigitsAsNumbers=64, - /// Treat punctuation the same as symbols. - StringSoft=128, -#endif - }; - - /// Compare two strings. - /// Returns 0 if two strings are equal. Returns a positive number if the first string is larger. Returns a negative number if the second string is larger. When sorting strings, larger strings are put after then smaller strings. - /// The first string to compare. - /// The second string to compare. - /// Flags controlling how to normalize a string. - vint Compare(const WString& s1, const WString& s2, Normalization normalization)const; - /// Compare two strings to test binary equivalence. - /// Returns 0 if two strings are equal. Returns a positive number if the first string is larger. Returns a negative number if the second string is larger. When sorting strings, larger strings are put after then smaller strings. - /// The first string to compare. - /// The second string to compare. - vint CompareOrdinal(const WString& s1, const WString& s2)const; - /// Compare two strings to test binary equivalence, ignoring case. - /// Returns 0 if two strings are equal. Returns a positive number if the first string is larger. Returns a negative number if the second string is larger. When sorting strings, larger strings are put after then smaller strings. - /// The first string to compare. - /// The second string to compare. - vint CompareOrdinalIgnoreCase(const WString& s1, const WString& s2)const; - /// Find the first position that the sub string appears in a text. - /// Returns a pair of numbers, the first number indicating the position in the text, the second number indicating the size of the equivalence sub string in the text. For some normalization, the found sub string may be binary different to the string you want to find. - /// The text to find the sub string. - /// The sub string to match. - /// Flags controlling how to normalize a string. - collections::Pair FindFirst(const WString& text, const WString& find, Normalization normalization)const; - /// Find the last position that the sub string appears in a text. - /// Returns a pair of numbers, the first number indicating the position in the text, the second number indicating the size of the equivalence sub string in the text. For some normalization, the found sub string may be binary different to the string you want to find. - /// The text to find the sub string. - /// The sub string to match. - /// Flags controlling how to normalize a string. - collections::Pair FindLast(const WString& text, const WString& find, Normalization normalization)const; - /// Test is the prefix of the text equivalence to the provided sub string. - /// Returns true if the prefix of the text equivalence to the provided sub string. - /// The text to test the prefix. - /// The sub string to match. - /// Flags controlling how to normalize a string. - bool StartsWith(const WString& text, const WString& find, Normalization normalization)const; - /// Test is the postfix of the text equivalence to the provided sub string. - /// Returns true if the postfix of the text equivalence to the provided sub string. - /// The text to test the postfix. - /// The sub string to match. - /// Flags controlling how to normalize a string. - bool EndsWith(const WString& text, const WString& find, Normalization normalization)const; - }; - -#define INVLOC vl::Locale::Invariant() -} - -#endif - -/*********************************************************************** -EXCEPTION.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Framework::Exception - -Classes: - Exception :异常 - ArgumentException :预料的的参数错误 -***********************************************************************/ - -#ifndef VCZH_EXCEPTION -#define VCZH_EXCEPTION - - -namespace vl -{ - /// Base type of all exceptions. - class Exception : public Object - { - protected: - WString message; - - public: - Exception(const WString& _message=WString::Empty); - - const WString& Message()const; - }; - - class ArgumentException : public Exception - { - protected: - WString function; - WString name; - - public: - ArgumentException(const WString& _message=WString::Empty, const WString& _function=WString::Empty, const WString& _name=WString::Empty); - - const WString& GetFunction()const; - const WString& GetName()const; - }; - - class ParsingException : public Exception - { - protected: - vint position; - WString expression; - - public: - ParsingException(const WString& _message, const WString& _expression, vint _position); - - const WString& GetExpression()const; - vint GetPosition()const; - }; -} - -#endif - -/*********************************************************************** -EVENT.H +.\EVENT.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -7670,8 +5030,849 @@ namespace vl } #endif + /*********************************************************************** -COLLECTIONS\OPERATION.H +.\LAZY.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Framework::Lazy Evaluation + +Classes: + Lazy :惰性对象 + +***********************************************************************/ + +#ifndef VCZH_LAZY +#define VCZH_LAZY + + +namespace vl +{ + /// A type representing a lazy evaluation. + /// The type of the evaluation result. + template + class Lazy : public Object + { + protected: + class Internal + { + public: + Func evaluator; + T value; + bool evaluated; + }; + + Ptr internalValue; + public: + /// Create an empty evaluation. + Lazy() + { + } + + /// Create an evaluation using a function. + /// The function. + Lazy(const Func& evaluator) + { + internalValue=new Internal; + internalValue->evaluated=false; + internalValue->evaluator=evaluator; + } + + /// Create an evaluation using the result directly. + /// The result that you have already known.0 + Lazy(const T& value) + { + internalValue=new Internal; + internalValue->evaluated=true; + internalValue->value=value; + } + + /// Copy an evaluation. + /// The evaluation to copy. + Lazy(const Lazy& lazy) + :internalValue(lazy.internalValue) + { + } + + Lazy& operator=(const Func& evaluator) + { + internalValue=new Internal; + internalValue->evaluated=false; + internalValue->evaluator=evaluator; + return *this; + } + + Lazy& operator=(const T& value) + { + internalValue=new Internal; + internalValue->evaluated=true; + internalValue->value=value; + return *this; + } + + Lazy& operator=(const Lazy& lazy) + { + internalValue=lazy.internalValue; + return *this; + } + + /// Get the evaluation result. If it has not been calculated yet, it will run the evaluation and cache the result. You will not need to calculate for the second time. + /// The evaluation result. + const T& Value()const + { + if(!internalValue->evaluated) + { + internalValue->evaluated=true; + internalValue->value=internalValue->evaluator(); + internalValue->evaluator=Func(); + } + return internalValue->value; + } + + /// Test if it has already been evaluated or not. + /// Returns true if it has already been evaluated. + const bool IsEvaluated()const + { + return internalValue->evaluated; + } + + /// Test if it is an empty evaluation or not. + /// Returns true if it is not empty. + const bool IsAvailable()const + { + return internalValue; + } + }; +} + +#endif + + +/*********************************************************************** +.\STRING.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Data Structure::String + +Classes: + AString :Mbcs字符串 + WString :Utf-16字符串 +***********************************************************************/ + +#ifndef VCZH_STRING +#define VCZH_STRING + + +namespace vl +{ + /// A type representing a string. + /// Type of a character. + template + class ObjectString : public Object + { + private: + static const T zero; + + mutable T* buffer; + mutable volatile vint* counter; + mutable vint start; + mutable vint length; + mutable vint realLength; + + static vint CalculateLength(const T* buffer) + { + vint result=0; + while(*buffer++)result++; + return result; + } + + static vint Compare(const T* bufA, const ObjectString& strB) + { + const T* bufB=strB.buffer+strB.start; + const T* bufAOld=bufA; + vint length=strB.length; + while(length-- && *bufA) + { + vint diff=*bufA++-*bufB++; + if(diff!=0) + { + return diff; + } + }; + return CalculateLength(bufAOld)-strB.length; + } + + public: + + static vint Compare(const ObjectString& strA, const ObjectString& strB) + { + const T* bufA=strA.buffer+strA.start; + const T* bufB=strB.buffer+strB.start; + vint length=strA.length& string, vint _start, vint _length) + { + if(_length<=0) + { + buffer=(T*)&zero; + counter=0; + start=0; + length=0; + realLength=0; + } + else + { + buffer=string.buffer; + counter=string.counter; + start=string.start+_start; + length=_length; + realLength=string.realLength; + Inc(); + } + } + + ObjectString(const ObjectString& dest, const ObjectString& source, vint index, vint count) + { + if(index==0 && count==dest.length && source.length==0) + { + buffer=(T*)&zero; + counter=0; + start=0; + length=0; + realLength=0; + } + else + { + counter=new vint(1); + start=0; + length=dest.length-count+source.length; + realLength=length; + buffer=new T[length+1]; + memcpy(buffer, dest.buffer+dest.start, sizeof(T)*index); + memcpy(buffer+index, source.buffer+source.start, sizeof(T)*source.length); + memcpy(buffer+index+source.length, (dest.buffer+dest.start+index+count), sizeof(T)*(dest.length-index-count)); + buffer[length]=0; + } + } + public: + static ObjectString Empty; + + /// Create an empty string. + ObjectString() + { + buffer=(T*)&zero; + counter=0; + start=0; + length=0; + realLength=0; + } + + /// Create a string continaing one character. + /// The character. + ObjectString(const T& _char) + { + counter=new vint(1); + start=0; + length=1; + buffer=new T[2]; + buffer[0]=_char; + buffer[1]=0; + realLength=length; + } + + /// Copy a string. + /// Memory to copy. It does not have to contain the zero terminator. + /// Size of the content in characters. + ObjectString(const T* _buffer, vint _length) + { + if(_length<=0) + { + buffer=(T*)&zero; + counter=0; + start=0; + length=0; + realLength=0; + } + else + { + buffer=new T[_length+1]; + memcpy(buffer, _buffer, _length*sizeof(T)); + buffer[_length]=0; + counter=new vint(1); + start=0; + length=_length; + realLength=_length; + } + } + + /// Copy a string. + /// Memory to copy. It should have to contain the zero terminator. + /// Set to true to copy the memory. Set to false to use the memory directly. + ObjectString(const T* _buffer, bool copy = true) + { + CHECK_ERROR(_buffer!=0, L"ObjectString::ObjectString(const T*, bool)#Cannot construct a string from nullptr."); + if(copy) + { + counter=new vint(1); + start=0; + length=CalculateLength(_buffer); + buffer=new T[length+1]; + memcpy(buffer, _buffer, sizeof(T)*(length+1)); + realLength=length; + } + else + { + buffer=(T*)_buffer; + counter=0; + start=0; + length=CalculateLength(_buffer); + realLength=length; + } + } + + /// Copy a string. + /// The string to copy. + ObjectString(const ObjectString& string) + { + buffer=string.buffer; + counter=string.counter; + start=string.start; + length=string.length; + realLength=string.realLength; + Inc(); + } + + /// Move a string. + /// The string to move. + ObjectString(ObjectString&& string) + { + buffer=string.buffer; + counter=string.counter; + start=string.start; + length=string.length; + realLength=string.realLength; + + string.buffer=(T*)&zero; + string.counter=0; + string.start=0; + string.length=0; + string.realLength=0; + } + + ~ObjectString() + { + Dec(); + } + + /// Get the zero-terminated buffer in the string. Copying parts of a string does not necessarily create a new buffer, so in some situation the string will not actually points to a zero-terminated buffer. In this case, this function will copy the content to a new buffer with a zero terminator and return. + /// Returns the buffer. + const T* Buffer()const + { + if(start+length!=realLength) + { + T* newBuffer=new T[length+1]; + memcpy(newBuffer, buffer+start, sizeof(T)*length); + newBuffer[length]=0; + Dec(); + buffer=newBuffer; + counter=new vint(1); + start=0; + realLength=length; + } + return buffer+start; + } + + ObjectString& operator=(const ObjectString& string) + { + if(this!=&string) + { + Dec(); + buffer=string.buffer; + counter=string.counter; + start=string.start; + length=string.length; + realLength=string.realLength; + Inc(); + } + return *this; + } + + ObjectString& operator=(ObjectString&& string) + { + if(this!=&string) + { + Dec(); + buffer=string.buffer; + counter=string.counter; + start=string.start; + length=string.length; + realLength=string.realLength; + + string.buffer=(T*)&zero; + string.counter=0; + string.start=0; + string.length=0; + string.realLength=0; + } + return *this; + } + + ObjectString& operator+=(const ObjectString& string) + { + return *this=*this+string; + } + + ObjectString operator+(const ObjectString& string)const + { + return ObjectString(*this, string, length, 0); + } + + bool operator==(const ObjectString& string)const + { + return Compare(*this, string)==0; + } + + bool operator!=(const ObjectString& string)const + { + return Compare(*this, string)!=0; + } + + bool operator>(const ObjectString& string)const + { + return Compare(*this, string)>0; + } + + bool operator>=(const ObjectString& string)const + { + return Compare(*this, string)>=0; + } + + bool operator<(const ObjectString& string)const + { + return Compare(*this, string)<0; + } + + bool operator<=(const ObjectString& string)const + { + return Compare(*this, string)<=0; + } + + bool operator==(const T* buffer)const + { + return Compare(buffer, *this)==0; + } + + bool operator!=(const T* buffer)const + { + return Compare(buffer, *this)!=0; + } + + bool operator>(const T* buffer)const + { + return Compare(buffer, *this)<0; + } + + bool operator>=(const T* buffer)const + { + return Compare(buffer, *this)<=0; + } + + bool operator<(const T* buffer)const + { + return Compare(buffer, *this)>0; + } + + bool operator<=(const T* buffer)const + { + return Compare(buffer, *this)>=0; + } + + T operator[](vint index)const + { + CHECK_ERROR(index>=0 && index:operator[](vint)#Argument index not in range."); + return buffer[start+index]; + } + + /// Get the size of the string in characters. + /// The size. + vint Length()const + { + return length; + } + + /// Find a character. + /// The position of the character. Returns -1 if it doesn not exist. + /// The character to find. + vint IndexOf(T c)const + { + const T* reading=buffer+start; + for(vint i=0;iCopy the beginning of the string. + /// The copied string. + /// Size of characters to copy. + ObjectString Left(vint count)const + { + CHECK_ERROR(count>=0 && count<=length, L"ObjectString::Left(vint)#Argument count not in range."); + return ObjectString(*this, 0, count); + } + + /// Copy the ending of the string. + /// The copied string. + /// Size of characters to copy. + ObjectString Right(vint count)const + { + CHECK_ERROR(count>=0 && count<=length, L"ObjectString::Right(vint)#Argument count not in range."); + return ObjectString(*this, length-count, count); + } + + /// Copy the middle of the string. + /// The copied string. + /// Position of characters to copy. + /// Size of characters to copy. + ObjectString Sub(vint index, vint count)const + { + CHECK_ERROR(index>=0 && index<=length, L"ObjectString::Sub(vint, vint)#Argument index not in range."); + CHECK_ERROR(index+count>=0 && index+count<=length, L"ObjectString::Sub(vint, vint)#Argument count not in range."); + return ObjectString(*this, index, count); + } + + /// Copy the beginning and the end of the string. + /// The copied string. + /// Position of characters NOT to copy. + /// Size of characters NOT to copy. + ObjectString Remove(vint index, vint count)const + { + CHECK_ERROR(index>=0 && index::Remove(vint, vint)#Argument index not in range."); + CHECK_ERROR(index+count>=0 && index+count<=length, L"ObjectString::Remove(vint, vint)#Argument count not in range."); + return ObjectString(*this, ObjectString(), index, count); + } + + /// Make a new string by inserting a string in this string. + /// The copied string. + /// Position of characters to insert. + /// The string to be inserted in this string. + ObjectString Insert(vint index, const ObjectString& string)const + { + CHECK_ERROR(index>=0 && index<=length, L"ObjectString::Insert(vint)#Argument count not in range."); + return ObjectString(*this, string, index, 0); + } + + friend bool operator<(const T* left, const ObjectString& right) + { + return Compare(left, right)<0; + } + + friend bool operator<=(const T* left, const ObjectString& right) + { + return Compare(left, right)<=0; + } + + friend bool operator>(const T* left, const ObjectString& right) + { + return Compare(left, right)>0; + } + + friend bool operator>=(const T* left, const ObjectString& right) + { + return Compare(left, right)>=0; + } + + friend bool operator==(const T* left, const ObjectString& right) + { + return Compare(left, right)==0; + } + + friend bool operator!=(const T* left, const ObjectString& right) + { + return Compare(left, right)!=0; + } + + friend ObjectString operator+(const T* left, const ObjectString& right) + { + return ObjectString(left, false)+right; + } + }; + + template + ObjectString ObjectString::Empty=ObjectString(); + template + const T ObjectString::zero=0; + + /// Ansi string. + typedef ObjectString AString; + /// Unicode string. + typedef ObjectString WString; + + /// Convert a string to an signed integer. + /// The converted number. If the convert failed, the result is undefined. + /// The string to convert. + /// Returns true if this operation succeeded. + extern vint atoi_test(const AString& string, bool& success); + /// Convert a string to an signed integer. + /// The converted number. If the convert failed, the result is undefined. + /// The string to convert. + /// Returns true if this operation succeeded. + extern vint wtoi_test(const WString& string, bool& success); + /// Convert a string to an signed 64-bits integer. + /// The converted number. If the convert failed, the result is undefined. + /// The string to convert. + /// Returns true if this operation succeeded. + extern vint64_t atoi64_test(const AString& string, bool& success); + /// Convert a string to an signed 64-bits integer. + /// The converted number. If the convert failed, the result is undefined. + /// The string to convert. + /// Returns true if this operation succeeded. + extern vint64_t wtoi64_test(const WString& string, bool& success); + /// Convert a string to an unsigned integer. + /// The converted number. If the convert failed, the result is undefined. + /// The string to convert. + /// Returns true if this operation succeeded. + extern vuint atou_test(const AString& string, bool& success); + /// Convert a string to an unsigned integer. + /// The converted number. If the convert failed, the result is undefined. + /// The string to convert. + /// Returns true if this operation succeeded. + extern vuint wtou_test(const WString& string, bool& success); + /// Convert a string to a 64-bits unsigned integer. + /// The converted number. If the convert failed, the result is undefined. + /// The string to convert. + /// Returns true if this operation succeeded. + extern vuint64_t atou64_test(const AString& string, bool& success); + /// Convert a string to a 64-bits unsigned integer. + /// The converted number. If the convert failed, the result is undefined. + /// The string to convert. + /// Returns true if this operation succeeded. + extern vuint64_t wtou64_test(const WString& string, bool& success); + /// Convert a string to 64-bits floating point number. + /// The converted number. If the convert failed, the result is undefined. + /// The string to convert. + /// Returns true if this operation succeeded. + extern double atof_test(const AString& string, bool& success); + /// Convert a string to 64-bits floating point number. + /// The converted number. If the convert failed, the result is undefined. + /// The string to convert. + /// Returns true if this operation succeeded. + extern double wtof_test(const WString& string, bool& success); + + /// Convert a string to an signed integer. + /// The converted number. If the convert failed, the result is undefined. + /// The string to convert. + extern vint atoi(const AString& string); + /// Convert a string to an signed integer. + /// The converted number. If the convert failed, the result is undefined. + /// The string to convert. + extern vint wtoi(const WString& string); + /// Convert a string to an signed 64-bits integer. + /// The converted number. If the convert failed, the result is undefined. + /// The string to convert. + extern vint64_t atoi64(const AString& string); + /// Convert a string to an signed 64-bits integer. + /// The converted number. If the convert failed, the result is undefined. + /// The string to convert. + extern vint64_t wtoi64(const WString& string); + /// Convert a string to an unsigned integer. + /// The converted number. If the convert failed, the result is undefined. + /// The string to convert. + extern vuint atou(const AString& string); + /// Convert a string to an unsigned integer. + /// The converted number. If the convert failed, the result is undefined. + /// The string to convert. + extern vuint wtou(const WString& string); + /// Convert a string to a 64-bits unsigned integer. + /// The converted number. If the convert failed, the result is undefined. + /// The string to convert. + extern vuint64_t atou64(const AString& string); + /// Convert a string to a 64-bits unsigned integer. + /// The converted number. If the convert failed, the result is undefined. + /// The string to convert. + extern vuint64_t wtou64(const WString& string); + /// Convert a string to a 64-bits floating point number. + /// The converted number. If the convert failed, the result is undefined. + /// The string to convert. + extern double atof(const AString& string); + /// Convert a string to a 64-bits floating point number. + /// The converted number. If the convert failed, the result is undefined. + /// The string to convert. + extern double wtof(const WString& string); + + /// Convert a signed interger to a string. + /// The converted string. + /// The number to convert. + extern AString itoa(vint number); + /// Convert a signed interger to a string. + /// The converted string. + /// The number to convert. + extern WString itow(vint number); + /// Convert a 64-bits signed interger to a string. + /// The converted string. + /// The number to convert. + extern AString i64toa(vint64_t number); + /// Convert a 64-bits signed interger to a string. + /// The converted string. + /// The number to convert. + extern WString i64tow(vint64_t number); + /// Convert an unsigned interger to a string. + /// The converted string. + /// The number to convert. + extern AString utoa(vuint number); + /// Convert an unsigned interger to a string. + /// The converted string. + /// The number to convert. + extern WString utow(vuint number); + /// Convert a 64-bits unsigned interger to a string. + /// The converted string. + /// The number to convert. + extern AString u64toa(vuint64_t number); + /// Convert a 64-bits unsigned interger to a string. + /// The converted string. + /// The number to convert. + extern WString u64tow(vuint64_t number); + /// Convert a 64-bits floating pointer number to a string. + /// The converted string. + /// The number to convert. + extern AString ftoa(double number); + /// Convert a 64-bits floating pointer number to a string. + /// The converted string. + /// The number to convert. + extern WString ftow(double number); + + extern vint _wtoa(const wchar_t* w, char* a, vint chars); + /// Convert an Unicode string to an Ansi string. + /// The converted string. + /// The string to convert. + extern AString wtoa(const WString& string); + extern vint _atow(const char* a, wchar_t* w, vint chars); + /// Convert an Ansi string to an Unicode string. + /// The converted string. + /// The string to convert. + extern WString atow(const AString& string); + /// Convert all letters to lower case letters. + /// The converted string. + /// The string to convert. + extern AString alower(const AString& string); + /// Convert all letters to lower case letters. + /// The converted string. + /// The string to convert. + extern WString wlower(const WString& string); + /// Convert all letters to upper case letters. + /// The converted string. + /// The string to convert. + extern AString aupper(const AString& string); + /// Convert all letters to upper case letters. + /// The converted string. + /// The string to convert. + extern WString wupper(const WString& string); + +#if defined VCZH_GCC + extern void _itoa_s(vint32_t value, char* buffer, size_t size, vint radix); + extern void _itow_s(vint32_t value, wchar_t* buffer, size_t size, vint radix); + extern void _i64toa_s(vint64_t value, char* buffer, size_t size, vint radix); + extern void _i64tow_s(vint64_t value, wchar_t* buffer, size_t size, vint radix); + extern void _uitoa_s(vuint32_t value, char* buffer, size_t size, vint radix); + extern void _uitow_s(vuint32_t value, wchar_t* buffer, size_t size, vint radix); + extern void _ui64toa_s(vuint64_t value, char* buffer, size_t size, vint radix); + extern void _ui64tow_s(vuint64_t value, wchar_t* buffer, size_t size, vint radix); + extern void _gcvt_s(char* buffer, size_t size, double value, vint numberOfDigits); + extern void _strlwr_s(char* buffer, size_t size); + extern void _strupr_s(char* buffer, size_t size); + extern void _wcslwr_s(wchar_t* buffer, size_t size); + extern void _wcsupr_s(wchar_t* buffer, size_t size); +#endif +} + +#endif + + +/*********************************************************************** +.\COLLECTIONS\OPERATIONSTRING.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Data Structure::Operations + +***********************************************************************/ + +#ifndef VCZH_COLLECTIONS_OPERATIONSTRING +#define VCZH_COLLECTIONS_OPERATIONSTRING + + +namespace vl +{ + namespace collections + { + template + void CopyFrom(Ds& ds, const ObjectString& ss, bool append=false) + { + const S* buffer=ss.Buffer(); + vint count=ss.Length(); + CopyFrom(ds, buffer, count, append); + } + + template + void CopyFrom(ObjectString& ds, const Ss& ss, bool append=false) + { + Array da(ds.Buffer(), ds.Length()); + CopyFrom(da, ss, append); + if(da.Count()==0) + { + ds=ObjectString(); + } + else + { + ds=ObjectString(&da[0], da.Count()); + } + } + } +} + +#endif + +/*********************************************************************** +.\COLLECTIONS\OPERATION.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -8056,7 +6257,7 @@ LazyList bool IsEmpty()const { Ptr> enumerator=CreateEnumerator(); - return enumerator->Next(); + return !enumerator->Next(); } //------------------------------------------------------- @@ -8231,8 +6432,1964 @@ LazyList #endif + /*********************************************************************** -REFLECTION\GUITYPEDESCRIPTOR.H +.\CONSOLE.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +UI::Console + +***********************************************************************/ + +#ifndef VCZH_CONSOLE +#define VCZH_CONSOLE + + +namespace vl +{ + namespace console + { + /// A Static class for command line window operations. + class Console abstract + { + public: + /// Write to the command line window. + /// Content to write. + /// Size of the content in wchar_t. The zero terminator is not included. + static void Write(const wchar_t* string, vint length); + + /// Write to the command line window. + /// Content to write. + static void Write(const wchar_t* string); + + /// Write to the command line window. + /// Content to write. + static void Write(const WString& string); + + /// Write to the command line window with a CRLF. + /// Content to write. + static void WriteLine(const WString& string); + + /// Read from the command line window. + /// The whole line read from the command line window. + static WString Read(); + + static void SetColor(bool red, bool green, bool blue, bool light); + static void SetTitle(const WString& string); + }; + } +} + +#endif + +/*********************************************************************** +.\EXCEPTION.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Framework::Exception + +Classes: + Exception :异常 + ArgumentException :预料的的参数错误 +***********************************************************************/ + +#ifndef VCZH_EXCEPTION +#define VCZH_EXCEPTION + + +namespace vl +{ + /// Base type of all exceptions. + class Exception : public Object + { + protected: + WString message; + + public: + Exception(const WString& _message=WString::Empty); + + const WString& Message()const; + }; + + class ArgumentException : public Exception + { + protected: + WString function; + WString name; + + public: + ArgumentException(const WString& _message=WString::Empty, const WString& _function=WString::Empty, const WString& _name=WString::Empty); + + const WString& GetFunction()const; + const WString& GetName()const; + }; + + class ParsingException : public Exception + { + protected: + vint position; + WString expression; + + public: + ParsingException(const WString& _message, const WString& _expression, vint _position); + + const WString& GetExpression()const; + vint GetPosition()const; + }; +} + +#endif + +/*********************************************************************** +.\GLOBALSTORAGE.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Framework::Global Storage + +Classes: + GlobalStorage :全局对象 + +***********************************************************************/ + +#ifndef VCZH_GLOBALSTORAGE +#define VCZH_GLOBALSTORAGE + + +namespace vl +{ + /// ) + /// + /// INITIALIZE_GLOBAL_STORAGE_CLASS + /// + /// FINALIZE_GLOBAL_STORAGE_CLASS + /// + /// END_GLOBAL_STORAGE_CLASS + /// Then you have a global storage. You can only use this global storage in the current cpp file. [M:vl.InitializeGlobalStorage] should be called before using any global storage. [M:vl.FinalizeGlobalStorage] is encouraged to call if you think you will not use any global storages anymore. It will reduce noices when you want to detect memory leaks. + /// If the key of the global variable is called Key, and the variable you want to access is called Variable, then you can use GetKey()->Variable to access that variable. The GetKey function is created in the macro calls before. + /// ]]> + class GlobalStorage : public Object, private NotCopyable + { + private: + bool cleared; + public: + GlobalStorage(const wchar_t* key); + ~GlobalStorage(); + + bool Cleared(); + virtual void ClearResource()=0; + }; + + extern GlobalStorage* GetGlobalStorage(const wchar_t* key); + extern GlobalStorage* GetGlobalStorage(const WString& key); + + /// Initialize the global storage. + extern void InitializeGlobalStorage(); + /// Finalize the global storage. + extern void FinalizeGlobalStorage(); +} + +#define BEGIN_GLOBAL_STORAGE_CLASS(NAME)\ + class NAME : public vl::GlobalStorage\ + {\ + public:\ + NAME()\ + :vl::GlobalStorage(L ## #NAME)\ + {\ + InitializeClearResource();\ + }\ + ~NAME()\ + {\ + if(!Cleared())ClearResource();\ + }\ + +#define INITIALIZE_GLOBAL_STORAGE_CLASS\ + void InitializeClearResource()\ + {\ + +#define FINALIZE_GLOBAL_STORAGE_CLASS\ + }\ + void ClearResource()\ + {\ + +#define END_GLOBAL_STORAGE_CLASS(NAME)\ + }\ + };\ + NAME& Get##NAME()\ + {\ + static NAME __global_storage_##NAME;\ + return __global_storage_##NAME;\ + }\ + +#define EXTERN_GLOBAL_STORAGE_CLASS(NAME)\ + class NAME;\ + extern NAME& Get##NAME();\ + +#endif + + +/*********************************************************************** +.\HTTPUTILITY.H +***********************************************************************/ +#ifndef VCZH_HTTPUTILITY +#define VCZH_HTTPUTILITY + + +#ifdef VCZH_MSVC + +namespace vl +{ + +/*********************************************************************** +HTTP Utility +***********************************************************************/ + + /// A type representing an http requiest. + class HttpRequest + { + typedef collections::Array BodyBuffer; + typedef collections::List StringList; + typedef collections::Dictionary HeaderMap; + public: + /// Name of the server, like "gaclib.net". + WString server; + /// Port of the server, like 80. + vint port; + /// Query of the request, like "/GettingStart.html". + WString query; + /// Set to true if the request uses SSL. + bool secure; + /// User name to authorize. Set to empty if you don't want to provide it. + WString username; + /// Password to authorize. Set to empty if you don't want to provide it. + WString password; + /// HTTP method, like "GET", "POST", "PUT", "DELETE", etc. + WString method; + /// Cookie. Set to empty if you don't want to provide it. + WString cookie; + /// Request body. This is a binary array using an array container to char. + BodyBuffer body; + /// Content type, like "text/xml". + WString contentType; + /// Accept type list, elements of it like "text/xml". + StringList acceptTypes; + /// A dictionary to contain extra headers. + HeaderMap extraHeaders; + + /// Create an empty request. + HttpRequest(); + + /// Set , , and fields for you using an URL. + /// Returns true if this operation succeeded. + /// The URL. + bool SetHost(const WString& inputQuery); + + /// Fill the body with a text using UTF-8 encoding. + /// The text to fill. + void SetBodyUtf8(const WString& bodyString); + }; + + /// A type representing an http response. + class HttpResponse + { + typedef collections::Array BodyBuffer; + public: + /// Status code, like 200. + vint statusCode; + /// Response body. This is a binary array using an array container to char. + BodyBuffer body; + /// Returned cookie from the server. + WString cookie; + + HttpResponse(); + + /// If you believe the server returns a text in UTF-8, use it to decode the body. + /// The response body as text. + WString GetBodyUtf8(); + }; + + /// Send an http request and receive a response. + /// Returns true if this operation succeeded. Even the server returns 404 will be treated as success, because you get the response. + /// The request. + /// The response. + extern bool HttpQuery(const HttpRequest& request, HttpResponse& response); + + /// Encode a text as part of the url. This function can be used to create arguments in an URL. + /// The encoded text. + /// The text to encode. + extern WString UrlEncodeQuery(const WString& query); +} + +#endif + +#endif + + +/*********************************************************************** +.\LOCALE.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Framework::Locale + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_LOCALE +#define VCZH_LOCALE + + +namespace vl +{ + /// Locale awared operations. Macro "INVLOC" is a shortcut to get a invariant locale. + class Locale : public Object + { + protected: + WString localeName; + + public: + Locale(const WString& _localeName=WString::Empty); + ~Locale(); + + bool operator==(const Locale& value)const { return localeName==value.localeName; } + bool operator!=(const Locale& value)const { return localeName!=value.localeName; } + bool operator<(const Locale& value)const { return localeName(const Locale& value)const { return localeName>value.localeName; } + bool operator>=(const Locale& value)const { return localeName>=value.localeName; } + + /// Get the invariant locale. + /// The invariant locale. + static Locale Invariant(); + /// Get the system default locale. This locale controls the code page that used by the the system to interpret ANSI string buffers. + /// The system default locale. + static Locale SystemDefault(); + /// Get the user default locale. This locale reflect the user's setting. + /// The user default locale. + static Locale UserDefault(); + /// Get all supported locales. + /// All supported locales. + static void Enumerate(collections::List& locales); + + /// Get the name of the locale. + /// The name of the locale. + const WString& GetName()const; + + /// Get all short date formats for the locale. + /// The formats. + void GetShortDateFormats(collections::List& formats)const; + /// Get all long date formats for the locale. + /// The formats. + void GetLongDateFormats(collections::List& formats)const; + /// Get all Year-Month date formats for the locale. + /// The formats. + void GetYearMonthDateFormats(collections::List& formats)const; + /// Get all long time formats for the locale. + /// The formats. + void GetLongTimeFormats(collections::List& formats)const; + /// Get all short time formats for the locale. + /// The formats. + void GetShortTimeFormats(collections::List& formats)const; + + /// Convert a date to a formatted string. + /// The formatted string. + /// The format to use. + /// The date to convert. + WString FormatDate(const WString& format, DateTime date)const; + /// Convert a time to a formatted string. + /// The formatted string. + /// The format to use. + /// The time to convert. + WString FormatTime(const WString& format, DateTime time)const; +#ifdef VCZH_MSVC + /// Convert a number to a formatted string. + /// The formatted string. + /// The number to convert. + WString FormatNumber(const WString& number)const; + /// Convert a currency (money) to a formatted string. + /// The formatted string. + /// The currency to convert. + WString FormatCurrency(const WString& currency)const; +#endif + + /// Get the short display string of a day of week. + /// The display string. + /// Day of week, begins from 0 as Sunday. + WString GetShortDayOfWeekName(vint dayOfWeek)const; + /// Get the long display string of a day of week. + /// The display string. + /// Day of week, begins from 0 as Sunday. + WString GetLongDayOfWeekName(vint dayOfWeek)const; + /// Get the short display string of a month. + /// The display string. + /// Month, begins from 1 as January. + WString GetShortMonthName(vint month)const; + /// Get the long display string of a month. + /// The display string. + /// Month, begins from 1 as January. + WString GetLongMonthName(vint month)const; + +#ifdef VCZH_MSVC + /// Convert characters to the full width. + /// The converted string. + /// The string to convert. + WString ToFullWidth(const WString& str)const; + /// Convert characters to the half width. + /// The converted string. + /// The string to convert. + WString ToHalfWidth(const WString& str)const; + /// Convert characters to the Hiragana. + /// The converted string. + /// The string to convert. + WString ToHiragana(const WString& str)const; + /// Convert characters to the Katagana. + /// The converted string. + /// The string to convert. + WString ToKatagana(const WString& str)const; +#endif + + /// Convert characters to the lower case using the file system rule. + /// The converted string. + /// The string to convert. + WString ToLower(const WString& str)const; + /// Convert characters to the upper case using the file system rule. + /// The converted string. + /// The string to convert. + WString ToUpper(const WString& str)const; + /// Convert characters to the lower case using the linguistic rule. + /// The converted string. + /// The string to convert. + WString ToLinguisticLower(const WString& str)const; + /// Convert characters to the upper case using the linguistic rule. + /// The converted string. + /// The string to convert. + WString ToLinguisticUpper(const WString& str)const; + +#ifdef VCZH_MSVC + /// Convert characters to Simplified Chinese. + /// The converted string. + /// The string to convert. + WString ToSimplifiedChinese(const WString& str)const; + /// Convert characters to the Traditional Chinese. + /// The converted string. + /// The string to convert. + WString ToTraditionalChinese(const WString& str)const; + /// Convert characters to the tile case, in which the first letter of each major word is capitalized. + /// The converted string. + /// The string to convert. + WString ToTileCase(const WString& str)const; +#endif + + /// Mergable flags controlling how to normalize a string. + enum Normalization + { + /// Do nothing. + None=0, + /// Ignore case using the file system rule. + IgnoreCase=1, +#ifdef VCZH_MSVC + /// Ignore case using the linguistic rule. + IgnoreCaseLinguistic=2, + /// Ignore the difference between between hiragana and katakana characters. + IgnoreKanaType=4, + /// Ignore nonspacing characters. + IgnoreNonSpace=8, + /// Ignore symbols and punctuation. + IgnoreSymbol=16, + /// Ignore the difference between half-width and full-width characters. + IgnoreWidth=32, + /// Treat digits as numbers during sorting. + DigitsAsNumbers=64, + /// Treat punctuation the same as symbols. + StringSoft=128, +#endif + }; + + /// Compare two strings. + /// Returns 0 if two strings are equal. Returns a positive number if the first string is larger. Returns a negative number if the second string is larger. When sorting strings, larger strings are put after then smaller strings. + /// The first string to compare. + /// The second string to compare. + /// Flags controlling how to normalize a string. + vint Compare(const WString& s1, const WString& s2, Normalization normalization)const; + /// Compare two strings to test binary equivalence. + /// Returns 0 if two strings are equal. Returns a positive number if the first string is larger. Returns a negative number if the second string is larger. When sorting strings, larger strings are put after then smaller strings. + /// The first string to compare. + /// The second string to compare. + vint CompareOrdinal(const WString& s1, const WString& s2)const; + /// Compare two strings to test binary equivalence, ignoring case. + /// Returns 0 if two strings are equal. Returns a positive number if the first string is larger. Returns a negative number if the second string is larger. When sorting strings, larger strings are put after then smaller strings. + /// The first string to compare. + /// The second string to compare. + vint CompareOrdinalIgnoreCase(const WString& s1, const WString& s2)const; + /// Find the first position that the sub string appears in a text. + /// Returns a pair of numbers, the first number indicating the position in the text, the second number indicating the size of the equivalence sub string in the text. For some normalization, the found sub string may be binary different to the string you want to find. + /// The text to find the sub string. + /// The sub string to match. + /// Flags controlling how to normalize a string. + collections::Pair FindFirst(const WString& text, const WString& find, Normalization normalization)const; + /// Find the last position that the sub string appears in a text. + /// Returns a pair of numbers, the first number indicating the position in the text, the second number indicating the size of the equivalence sub string in the text. For some normalization, the found sub string may be binary different to the string you want to find. + /// The text to find the sub string. + /// The sub string to match. + /// Flags controlling how to normalize a string. + collections::Pair FindLast(const WString& text, const WString& find, Normalization normalization)const; + /// Test is the prefix of the text equivalence to the provided sub string. + /// Returns true if the prefix of the text equivalence to the provided sub string. + /// The text to test the prefix. + /// The sub string to match. + /// Flags controlling how to normalize a string. + bool StartsWith(const WString& text, const WString& find, Normalization normalization)const; + /// Test is the postfix of the text equivalence to the provided sub string. + /// Returns true if the postfix of the text equivalence to the provided sub string. + /// The text to test the postfix. + /// The sub string to match. + /// Flags controlling how to normalize a string. + bool EndsWith(const WString& text, const WString& find, Normalization normalization)const; + }; + +#define INVLOC vl::Locale::Invariant() +} + +#endif + +/*********************************************************************** +.\REGEX\REGEX.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Regex::Regular Expression + +Classes: + RegexString :字符串匹配结果 + RegexMatch :匹配结果 + Regex :正则表达式引擎 + RegexToken :词法记号 + RegexTokens :词法记号表 + RegexLexer :词法分析器 +***********************************************************************/ + +#ifndef VCZH_REGEX_REGEX +#define VCZH_REGEX_REGEX + + +namespace vl +{ + namespace regex_internal + { + class PureResult; + class PureInterpretor; + class RichResult; + class RichInterpretor; + } + + namespace regex + { + +/*********************************************************************** +正则表达式引擎数据结构 +***********************************************************************/ + + /// A type representing a fragment of the input string. + class RegexString : public Object + { + protected: + WString value; + vint start; + vint length; + + public: + RegexString(vint _start=0); + RegexString(const WString& _string, vint _start, vint _length); + + /// The position of the input string. + /// The position. + vint Start()const; + /// The size of the fragment in characters. + /// The size. + vint Length()const; + /// Get the fragment. + /// The fragment. + const WString& Value()const; + bool operator==(const RegexString& string)const; + }; + + /// A type representing a match of the input string. + class RegexMatch : public Object, private NotCopyable + { + friend class Regex; + public: + typedef Ptr Ref; + typedef collections::List List; + typedef collections::List CaptureList; + typedef collections::Group CaptureGroup; + protected: + collections::List captures; + collections::Group groups; + bool success; + RegexString result; + + RegexMatch(const WString& _string, regex_internal::PureResult* _result); + RegexMatch(const WString& _string, regex_internal::RichResult* _result, regex_internal::RichInterpretor* _rich); + RegexMatch(const RegexString& _result); + public: + + /// Test if this match is a success match or a failed match. A failed match will only appear when calling [M:vl.regex.Regex.Split] or [M:vl.regex.Regex.Cut]. In other cases, failed matches are either not included in the result, or become null pointers. + /// Returns true if this match is a success match. + bool Success()const; + /// Get the whole fragment that matches. + /// The whole fragment. + const RegexString& Result()const; + /// Get all fragments that are captured. + /// All fragments that are captured. + const CaptureList& Captures()const; + /// Get all fragments that are captured by named groups. + /// All fragments that are captured. + const CaptureGroup& Groups()const; + }; + +/*********************************************************************** +正则表达式引擎 +***********************************************************************/ + + /// , \^, \$, \!, \=: represents itself + /// Escaped characters in charset defined in a square bracket: + /// \r: the CR character + /// \n: the LF character + /// \t: the tab character + /// \-, \[, \], \\, \/, \^, \$: represents itself + /// 4) Loops: + /// regex{3}: repeats 3 times + /// regex{3,}: repeats 3 or more times + /// regex{1,3}: repeats 1 to 3 times + /// regex?: repeats 0 or 1 times + /// regex*: repeats 0 or more times + /// regex+: repeats 1 or more times + /// if you add a "?" right after a loop, it means repeating as less as possible (DFA incompatible) + /// 5) Capturing: (DFA incompatible) + /// (regex): No capturing, just change the operators' association + /// (?regex): Capture matched fragment + /// (regex): Capture matched fragment in a named group called "name" + /// (<$i>): Match the i-th captured fragment, begins from 0 + /// (<$name;i>): Match the i-th captured fragment in the named group called "name", begins from 0 + /// (<$name>): Match any captured fragment in the named group called "name" + /// 6) MISC + /// (=regex): The prefix of the following text should match the regex, but it is not counted in the whole match (DFA incompatible) + /// (!regex): Any prefix of the following text should not match the regex, and it is not counted in the whole match (DFA incompatible) + /// (<#name>regex): Name the regex "name", and it applies here + /// (<&name>): Copy the named regex "name" here and apply + /// ]]> + class Regex : public Object, private NotCopyable + { + protected: + regex_internal::PureInterpretor* pure; + regex_internal::RichInterpretor* rich; + + void Process(const WString& text, bool keepEmpty, bool keepSuccess, bool keepFail, RegexMatch::List& matches)const; + public: + /// Create a regular expression. + /// The regular expression in a string. + /// Set to true to tell the Regex to use DFA if possible. + Regex(const WString& code, bool preferPure=true); + ~Regex(); + + /// Test does the Regex uses DFA to match a string. + /// Returns true if DFA is used. + bool IsPureMatch()const; + /// Test does the Regex uses DFA to test a string. Test means ignoring all capturing requirements. + /// Returns true if DFA is used. + bool IsPureTest()const; + + /// Match a prefix of the text. + /// Returns the match. Returns null if failed. + /// The text to match. + RegexMatch::Ref MatchHead(const WString& text)const; + /// Match a fragment of the text. + /// Returns the match. Returns null if failed. + /// The text to match. + RegexMatch::Ref Match(const WString& text)const; + /// Match a prefix of the text, ignoring all capturing requirements. + /// Returns true if succeeded. + /// The text to match. + bool TestHead(const WString& text)const; + /// Match a fragment of the text, ignoring all capturing requirements. + /// Returns true if succeeded. + /// The text to match. + bool Test(const WString& text)const; + /// Find all matched fragments of the text, returning all matched fragments. + /// The text to match. + /// All successful matches. + void Search(const WString& text, RegexMatch::List& matches)const; + /// Split the text by matched fragments, returning all unmatched fragments. + /// The text to match. + /// Set to true to keep all empty matches. + /// All failed matches. + void Split(const WString& text, bool keepEmptyMatch, RegexMatch::List& matches)const; + /// Cut the text by matched fragments, returning all matched or unmatched fragments. + /// The text to match. + /// Set to true to keep all empty matches. + /// All successful and failed matches. + void Cut(const WString& text, bool keepEmptyMatch, RegexMatch::List& matches)const; + }; + +/*********************************************************************** +正则表达式词法分析器 +***********************************************************************/ + + /// A token. + class RegexToken + { + public: + /// Position in the input string. + vint start; + /// Size of this token in characters. + vint length; + /// The token id, begins at 0, represents the regular expression in the list that matches this token. -1 means this token is produced by an error. + vint token; + /// The pointer to where this token starts in the input string . + const wchar_t* reading; + /// The argument value from [M:vl.regex.RegexLexer.Parse]. + vint codeIndex; + /// True if this token is complete. False if this token does not end here. + bool completeToken; + + /// Row number of the first character, begins at 0. + vint rowStart; + /// Column number of the first character, begins at 0. + vint columnStart; + /// Row number of the last character, begins at 0. + vint rowEnd; + /// Column number of the last character, begins at 0. + vint columnEnd; + + bool operator==(const RegexToken& _token)const; + bool operator==(const wchar_t* _token)const; + }; + + /// Token collection representing the result from the lexical analyzer. + class RegexTokens : public Object, public collections::IEnumerable + { + friend class RegexLexer; + protected: + regex_internal::PureInterpretor* pure; + const collections::Array& stateTokens; + WString code; + vint codeIndex; + + RegexTokens(regex_internal::PureInterpretor* _pure, const collections::Array& _stateTokens, const WString& _code, vint _codeIndex); + public: + RegexTokens(const RegexTokens& tokens); + + collections::IEnumerator* CreateEnumerator()const; + + /// Copy all tokens. + /// Returns all tokens. + /// A callback to decide which kind of tokens to discard. The input is [F:vl.regex.RegexToken.token]. Returns true to discard this kind of tokens. + void ReadToEnd(collections::List& tokens, bool(*discard)(vint)=0)const; + }; + + /// Lexical walker. + class RegexLexerWalker : public Object + { + friend class RegexLexer; + protected: + regex_internal::PureInterpretor* pure; + const collections::Array& stateTokens; + + RegexLexerWalker(regex_internal::PureInterpretor* _pure, const collections::Array& _stateTokens); + public: + RegexLexerWalker(const RegexLexerWalker& walker); + ~RegexLexerWalker(); + + /// Get the start DFA state number, which represents the correct state before parsing any input. + /// The DFA state number. + vint GetStartState()const; + /// Test if this state can only lead to the end of one kind of token. + /// Returns the token index if this state can only lead to the end of one kind of token. Returns -1 if not. + /// The DFA state number. + vint GetRelatedToken(vint state)const; + /// Step forward by one character. + /// The input character. + /// The current state. Returns the new current state when this function returns. + /// Returns the token index at the end of the token. + /// Returns true if it reach the end of the token. + /// Returns true if the last character is the end of the token. + void Walk(wchar_t input, vint& state, vint& token, bool& finalState, bool& previousTokenStop)const; + /// Step forward by one character. + /// Returns the new current state. + /// The input character. + /// The current state. + vint Walk(wchar_t input, vint state)const; + /// Test if the input text is a complete token. + /// Returns true if the input text is a complete token. + /// The input text. + /// Size of the input text in characters. + bool IsClosedToken(const wchar_t* input, vint length)const; + /// Test if the input is a complete token. + /// Returns true if the input text is a complete token. + /// The input text. + bool IsClosedToken(const WString& input)const; + }; + + /// Lexical colorizer. + class RegexLexerColorizer : public Object + { + friend class RegexLexer; + public: + typedef void(*TokenProc)(void* argument, vint start, vint length, vint token); + + protected: + RegexLexerWalker walker; + vint currentState; + + RegexLexerColorizer(const RegexLexerWalker& _walker); + public: + RegexLexerColorizer(const RegexLexerColorizer& colorizer); + ~RegexLexerColorizer(); + + /// Reset the colorizer using the DFA state number. + /// The DFA state number. + void Reset(vint state); + /// Step forward by one character. + /// The input character. + void Pass(wchar_t input); + /// Get the start DFA state number, which represents the correct state before colorizing any characters. + /// The DFA state number. + vint GetStartState()const; + /// Get the current DFA state number. + /// The DFA state number. + vint GetCurrentState()const; + /// Colorize a text. + /// The text to colorize. + /// Size of the text in characters. + /// Colorizer callback. This callback will be called if any token is found.. + /// The argument to call the callback. + void Colorize(const wchar_t* input, vint length, TokenProc tokenProc, void* tokenProcArgument); + }; + + /// Lexical analyzer. + class RegexLexer : public Object, private NotCopyable + { + protected: + regex_internal::PureInterpretor* pure; + collections::Array ids; + collections::Array stateTokens; + public: + /// Create a lexical analyzer by a set of regular expressions. [F:vl.regex.RegexToken.token] will be the index of the matched regular expression. + /// The regular expressions. + RegexLexer(const collections::IEnumerable& tokens); + ~RegexLexer(); + + /// Tokenize a input text. + /// The result. + /// The text to tokenize. + /// Extra information that will store in [F:vl.regex.RegexToken.codeIndex]. + RegexTokens Parse(const WString& code, vint codeIndex=-1)const; + /// Create a equivalence walker from this lexical analyzer. + /// The walker. + RegexLexerWalker Walk()const; + /// Create a equivalence colorizer from this lexical analyzer. + /// The colorizer. + RegexLexerColorizer Colorize()const; + }; + } +} + +#endif + +/*********************************************************************** +.\REGEX\REGEXDATA.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Regex::Basic Data Structure + +Classes: +***********************************************************************/ + +#ifndef VCZH_REGEX_REGEXDATA +#define VCZH_REGEX_REGEXDATA + + +namespace vl +{ + namespace regex_internal + { + +/*********************************************************************** +基础数据结构 +***********************************************************************/ + + class CharRange + { + public: + typedef collections::SortedList List; + + wchar_t begin; + wchar_t end; + + CharRange(); + CharRange(wchar_t _begin, wchar_t _end); + + bool operator<(CharRange item)const; + bool operator<=(CharRange item)const; + bool operator>(CharRange item)const; + bool operator>=(CharRange item)const; + bool operator==(CharRange item)const; + bool operator!=(CharRange item)const; + + bool operator<(wchar_t item)const; + bool operator<=(wchar_t item)const; + bool operator>(wchar_t item)const; + bool operator>=(wchar_t item)const; + bool operator==(wchar_t item)const; + bool operator!=(wchar_t item)const; + }; + } + + template<> + struct POD + { + static const bool Result=true; + }; +} + +#endif + +/*********************************************************************** +.\REGEX\REGEXAUTOMATON.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Regex::RegexAutomaton + +Classes: + State :状态 + Transition :转换 + Automaton :状态机 + +Functions: + EpsilonNfaToNfa :去Epsilon + NfaToDfa :NFA转DFA +***********************************************************************/ + +#ifndef VCZH_REGEX_REGEXAUTOMATON +#define VCZH_REGEX_REGEXAUTOMATON + + +namespace vl +{ + namespace regex_internal + { + class State; + class Transition; + + class Transition + { + public: + enum Type + { + Chars, //range为字符范围 + Epsilon, + BeginString, + EndString, + Nop, //无动作(不可消除epsilon,用来控制优先级) + Capture, //capture为捕获频道 + Match, //capture为捕获频道,index为匹配的位置,-1代表匹配频道下面的所有项目 + Positive, //正向匹配 + Negative, //反向匹配 + NegativeFail, //反向匹配失败 + End //Capture, Position, Negative + }; + + State* source; + State* target; + CharRange range; + Type type; + vint capture; + vint index; + }; + + class State + { + public: + collections::List transitions; + collections::List inputs; + bool finalState; + void* userData; + }; + + class Automaton + { + public: + typedef Ptr Ref; + + collections::List> states; + collections::List> transitions; + collections::List captureNames; + State* startState; + + Automaton(); + + State* NewState(); + Transition* NewTransition(State* start, State* end); + Transition* NewChars(State* start, State* end, CharRange range); + Transition* NewEpsilon(State* start, State* end); + Transition* NewBeginString(State* start, State* end); + Transition* NewEndString(State* start, State* end); + Transition* NewNop(State* start, State* end); + Transition* NewCapture(State* start, State* end, vint capture); + Transition* NewMatch(State* start, State* end, vint capture, vint index=-1); + Transition* NewPositive(State* start, State* end); + Transition* NewNegative(State* start, State* end); + Transition* NewNegativeFail(State* start, State* end); + Transition* NewEnd(State* start, State* end); + }; + + extern bool PureEpsilonChecker(Transition* transition); + extern bool RichEpsilonChecker(Transition* transition); + extern bool AreEqual(Transition* transA, Transition* transB); + extern Automaton::Ref EpsilonNfaToNfa(Automaton::Ref source, bool(*epsilonChecker)(Transition*), collections::Dictionary& nfaStateMap); + extern Automaton::Ref NfaToDfa(Automaton::Ref source, collections::Group& dfaStateMap); + } +} + +#endif + +/*********************************************************************** +.\REGEX\REGEXEXPRESSION.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Regex::RegexExpression + +Classes: + Expression :表达式基类 | + CharSetExpression :字符集表达式 | a, [a-b], [^a-b0_9], \.rnt\/()+*?{}[]<>^$!=SsDdLlWw, [\rnt-[]\/^$] + LoopExpression :循环表达式 | a{3}, a{3,}, a{1,3}, a+, a*, a?, LOOP? + SequenceExpression :顺序表达式 | ab + AlternateExpression :选择表达式 | a|b + BeginExpression :【非纯】字符串起始表达式 | ^ + EndExpression :【非纯】字符串末尾表达式 | $ + CaptureExpression :【非纯】捕获表达式 | (expr), (?expr) + MatchExpression :【非纯】匹配表达式 | (<$name>), (<$name;i>), (<$i>) + PositiveExpression :【非纯】正向预查表达式 | (=expr) + NegativeExpression :【非纯】反向预查表达式 | (!expr) + UsingExpression :引用表达式 | (<#name1>expr)...(<&name1>)... + + RegexExpression :正则表达式 + +Functions: + ParseRegexExpression :将字符串分析为RegexExpression对象,如果语法有问题则抛异常 +***********************************************************************/ + +#ifndef VCZH_REGEX_REGEXEXPRESSION +#define VCZH_REGEX_REGEXEXPRESSION + + +namespace vl +{ + namespace regex_internal + { + class IRegexExpressionAlgorithm; + +/*********************************************************************** +正则表达式表达式树 +***********************************************************************/ + + class Expression : public Object, private NotCopyable + { + public: + typedef Ptr Ref; + typedef collections::Dictionary Map; + + virtual void Apply(IRegexExpressionAlgorithm& algorithm)=0; + bool IsEqual(Expression* expression); + bool HasNoExtension(); + bool CanTreatAsPure(); + void NormalizeCharSet(CharRange::List& subsets); + void CollectCharSet(CharRange::List& subsets); + void ApplyCharSet(CharRange::List& subsets); + Automaton::Ref GenerateEpsilonNfa(); + }; + + class CharSetExpression : public Expression + { + public: + CharRange::List ranges; + bool reverse; + + bool AddRangeWithConflict(CharRange range); + void Apply(IRegexExpressionAlgorithm& algorithm); + }; + + class LoopExpression : public Expression + { + public: + Expression::Ref expression; //被循环表达式 + vint min; //下限 + vint max; //上限,-1代表无限 + bool preferLong; //长匹配优先 + + void Apply(IRegexExpressionAlgorithm& algorithm); + }; + + class SequenceExpression : public Expression + { + public: + Expression::Ref left; //左表达式 + Expression::Ref right; //右表达式 + + void Apply(IRegexExpressionAlgorithm& algorithm); + }; + + class AlternateExpression : public Expression + { + public: + Expression::Ref left; //左表达式 + Expression::Ref right; //右表达式 + + void Apply(IRegexExpressionAlgorithm& algorithm); + }; + + class BeginExpression: public Expression + { + public: + + void Apply(IRegexExpressionAlgorithm& algorithm); + }; + + class EndExpression : public Expression + { + public: + + void Apply(IRegexExpressionAlgorithm& algorithm); + }; + + class CaptureExpression : public Expression + { + public: + WString name; //捕获名,空代表缺省捕获 + Expression::Ref expression; //被捕获表达式 + + void Apply(IRegexExpressionAlgorithm& algorithm); + }; + + class MatchExpression : public Expression + { + public: + WString name; //捕获名,空代表缺省捕获 + vint index; //捕获序号,-1代表非空捕获的所有项 + + void Apply(IRegexExpressionAlgorithm& algorithm); + }; + + class PositiveExpression : public Expression + { + public: + Expression::Ref expression; //正向匹配表达式 + + void Apply(IRegexExpressionAlgorithm& algorithm); + }; + + class NegativeExpression : public Expression + { + public: + Expression::Ref expression; //反向匹配表达式 + + void Apply(IRegexExpressionAlgorithm& algorithm); + }; + + class UsingExpression : public Expression + { + public: + WString name; //引用名 + + void Apply(IRegexExpressionAlgorithm& algorithm); + }; + + class RegexExpression : public Object, private NotCopyable + { + public: + typedef Ptr Ref; + + Expression::Map definitions; //命名子表达式 + Expression::Ref expression; //主表达式 + + Expression::Ref Merge(); + }; + +/*********************************************************************** +算法基类 +***********************************************************************/ + + class IRegexExpressionAlgorithm : public Interface + { + public: + virtual void Visit(CharSetExpression* expression)=0; + virtual void Visit(LoopExpression* expression)=0; + virtual void Visit(SequenceExpression* expression)=0; + virtual void Visit(AlternateExpression* expression)=0; + virtual void Visit(BeginExpression* expression)=0; + virtual void Visit(EndExpression* expression)=0; + virtual void Visit(CaptureExpression* expression)=0; + virtual void Visit(MatchExpression* expression)=0; + virtual void Visit(PositiveExpression* expression)=0; + virtual void Visit(NegativeExpression* expression)=0; + virtual void Visit(UsingExpression* expression)=0; + }; + + template + class RegexExpressionAlgorithm : public Object, public IRegexExpressionAlgorithm + { + private: + ReturnType returnValue; + ParameterType* parameterValue; + public: + + ReturnType Invoke(Expression* expression, ParameterType parameter) + { + parameterValue=¶meter; + expression->Apply(*this); + return returnValue; + } + + ReturnType Invoke(Expression::Ref expression, ParameterType parameter) + { + parameterValue=¶meter; + expression->Apply(*this); + return returnValue; + } + + virtual ReturnType Apply(CharSetExpression* expression, ParameterType parameter)=0; + virtual ReturnType Apply(LoopExpression* expression, ParameterType parameter)=0; + virtual ReturnType Apply(SequenceExpression* expression, ParameterType parameter)=0; + virtual ReturnType Apply(AlternateExpression* expression, ParameterType parameter)=0; + virtual ReturnType Apply(BeginExpression* expression, ParameterType parameter)=0; + virtual ReturnType Apply(EndExpression* expression, ParameterType parameter)=0; + virtual ReturnType Apply(CaptureExpression* expression, ParameterType parameter)=0; + virtual ReturnType Apply(MatchExpression* expression, ParameterType parameter)=0; + virtual ReturnType Apply(PositiveExpression* expression, ParameterType parameter)=0; + virtual ReturnType Apply(NegativeExpression* expression, ParameterType parameter)=0; + virtual ReturnType Apply(UsingExpression* expression, ParameterType parameter)=0; + public: + void Visit(CharSetExpression* expression) + { + returnValue=Apply(expression, *parameterValue); + } + + void Visit(LoopExpression* expression) + { + returnValue=Apply(expression, *parameterValue); + } + + void Visit(SequenceExpression* expression) + { + returnValue=Apply(expression, *parameterValue); + } + + void Visit(AlternateExpression* expression) + { + returnValue=Apply(expression, *parameterValue); + } + + void Visit(BeginExpression* expression) + { + returnValue=Apply(expression, *parameterValue); + } + + void Visit(EndExpression* expression) + { + returnValue=Apply(expression, *parameterValue); + } + + void Visit(CaptureExpression* expression) + { + returnValue=Apply(expression, *parameterValue); + } + + void Visit(MatchExpression* expression) + { + returnValue=Apply(expression, *parameterValue); + } + + void Visit(PositiveExpression* expression) + { + returnValue=Apply(expression, *parameterValue); + } + + void Visit(NegativeExpression* expression) + { + returnValue=Apply(expression, *parameterValue); + } + + void Visit(UsingExpression* expression) + { + returnValue=Apply(expression, *parameterValue); + } + }; + + template + class RegexExpressionAlgorithm : public Object, public IRegexExpressionAlgorithm + { + private: + ParameterType* parameterValue; + public: + + void Invoke(Expression* expression, ParameterType parameter) + { + parameterValue=¶meter; + expression->Apply(*this); + } + + void Invoke(Expression::Ref expression, ParameterType parameter) + { + parameterValue=¶meter; + expression->Apply(*this); + } + + virtual void Apply(CharSetExpression* expression, ParameterType parameter)=0; + virtual void Apply(LoopExpression* expression, ParameterType parameter)=0; + virtual void Apply(SequenceExpression* expression, ParameterType parameter)=0; + virtual void Apply(AlternateExpression* expression, ParameterType parameter)=0; + virtual void Apply(BeginExpression* expression, ParameterType parameter)=0; + virtual void Apply(EndExpression* expression, ParameterType parameter)=0; + virtual void Apply(CaptureExpression* expression, ParameterType parameter)=0; + virtual void Apply(MatchExpression* expression, ParameterType parameter)=0; + virtual void Apply(PositiveExpression* expression, ParameterType parameter)=0; + virtual void Apply(NegativeExpression* expression, ParameterType parameter)=0; + virtual void Apply(UsingExpression* expression, ParameterType parameter)=0; + public: + void Visit(CharSetExpression* expression) + { + Apply(expression, *parameterValue); + } + + void Visit(LoopExpression* expression) + { + Apply(expression, *parameterValue); + } + + void Visit(SequenceExpression* expression) + { + Apply(expression, *parameterValue); + } + + void Visit(AlternateExpression* expression) + { + Apply(expression, *parameterValue); + } + + void Visit(BeginExpression* expression) + { + Apply(expression, *parameterValue); + } + + void Visit(EndExpression* expression) + { + Apply(expression, *parameterValue); + } + + void Visit(CaptureExpression* expression) + { + Apply(expression, *parameterValue); + } + + void Visit(MatchExpression* expression) + { + Apply(expression, *parameterValue); + } + + void Visit(PositiveExpression* expression) + { + Apply(expression, *parameterValue); + } + + void Visit(NegativeExpression* expression) + { + Apply(expression, *parameterValue); + } + + void Visit(UsingExpression* expression) + { + Apply(expression, *parameterValue); + } + }; + +/*********************************************************************** +辅助函数 +***********************************************************************/ + + extern Ptr ParseLoop(const wchar_t*& input); + extern Ptr ParseCharSet(const wchar_t*& input); + extern Ptr ParseFunction(const wchar_t*& input); + extern Ptr ParseUnit(const wchar_t*& input); + extern Ptr ParseJoin(const wchar_t*& input); + extern Ptr ParseAlt(const wchar_t*& input); + extern Ptr ParseExpression(const wchar_t*& input); + extern RegexExpression::Ref ParseRegexExpression(const WString& code); + + extern WString EscapeTextForRegex(const WString& literalString); + extern WString UnescapeTextForRegex(const WString& escapedText); + extern WString NormalizeEscapedTextForRegex(const WString& escapedText); + extern bool IsRegexEscapedLiteralString(const WString& regex); + } +} + +#endif + +/*********************************************************************** +.\REGEX\REGEXPURE.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Regex::RegexInterpretor + +Classes: + PureInterpretor :正则表达式纯模拟器 +***********************************************************************/ + +#ifndef VCZH_REGEX_REGEXPURE +#define VCZH_REGEX_REGEXPURE + + +namespace vl +{ + namespace regex_internal + { + class PureResult + { + public: + vint start; + vint length; + vint finalState; + vint terminateState; + }; + + class PureInterpretor : public Object + { + protected: +#if defined VCZH_MSVC + static const vint SupportedCharCount = 0x10000; // UTF-16 +#elif defined VCZH_GCC + static const vint SupportedCharCount = 0x110000; // UTF-32 +#endif + + vint charMap[SupportedCharCount]; // char -> char set index + vint** transition; // (state * char set index) -> state* + bool* finalState; // state -> bool + vint* relatedFinalState; // sate -> (finalState or -1) + vint stateCount; + vint charSetCount; + vint startState; + public: + PureInterpretor(Automaton::Ref dfa, CharRange::List& subsets); + ~PureInterpretor(); + + bool MatchHead(const wchar_t* input, const wchar_t* start, PureResult& result); + bool Match(const wchar_t* input, const wchar_t* start, PureResult& result); + + vint GetStartState(); + vint Transit(wchar_t input, vint state); + bool IsFinalState(vint state); + bool IsDeadState(vint state); + + void PrepareForRelatedFinalStateTable(); + vint GetRelatedFinalState(vint state); + }; + } +} + +#endif + +/*********************************************************************** +.\REGEX\REGEXRICH.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Regex::RegexInterpretor + +Classes: + RichInterpretor :正则表达式完全模拟器 +***********************************************************************/ + +#ifndef VCZH_REGEX_REGEXRICH +#define VCZH_REGEX_REGEXRICH + + +namespace vl +{ + namespace regex_internal + { + class CaptureRecord + { + public: + vint capture; + vint start; + vint length; + + bool operator==(const CaptureRecord& record)const; + }; + } + + template<> + struct POD + { + static const bool Result=true; + }; + + namespace regex_internal + { + class RichResult + { + public: + vint start; + vint length; + collections::List captures; + }; + + class RichInterpretor : public Object + { + public: + protected: + class UserData + { + public: + bool NeedKeepState; + }; + + Automaton::Ref dfa; + UserData* datas; + public: + RichInterpretor(Automaton::Ref _dfa); + ~RichInterpretor(); + + bool MatchHead(const wchar_t* input, const wchar_t* start, RichResult& result); + bool Match(const wchar_t* input, const wchar_t* start, RichResult& result); + const collections::List& CaptureNames(); + }; + }; +} + +#endif + +/*********************************************************************** +.\REGEX\REGEXWRITER.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Regex::RegexWriter + +Classes: +***********************************************************************/ + +#ifndef VCZH_REGEX_REGEXWRITER +#define VCZH_REGEX_REGEXWRITER + + +namespace vl +{ + namespace regex + { + class RegexNode : public Object + { + public: + vl::regex_internal::Expression::Ref expression; + + RegexNode(vl::regex_internal::Expression::Ref _expression); + + RegexNode Some()const; + RegexNode Any()const; + RegexNode Opt()const; + RegexNode Loop(vint min, vint max)const; + RegexNode AtLeast(vint min)const; + RegexNode operator+(const RegexNode& node)const; + RegexNode operator|(const RegexNode& node)const; + RegexNode operator+()const; + RegexNode operator-()const; + RegexNode operator!()const; + RegexNode operator%(const RegexNode& node)const; + }; + + extern RegexNode rCapture(const WString& name, const RegexNode& node); + extern RegexNode rUsing(const WString& name); + extern RegexNode rMatch(const WString& name, vint index=-1); + extern RegexNode rMatch(vint index); + extern RegexNode rBegin(); + extern RegexNode rEnd(); + extern RegexNode rC(wchar_t a, wchar_t b=L'\0'); + extern RegexNode r_d(); + extern RegexNode r_l(); + extern RegexNode r_w(); + extern RegexNode rAnyChar(); + } +} + +#endif + +/*********************************************************************** +.\STREAM\INTERFACES.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Stream::Interfaces + +Interfaces: + IStream :流 +***********************************************************************/ + +#ifndef VCZH_STREAM_INTERFACES +#define VCZH_STREAM_INTERFACES + + +namespace vl +{ + namespace stream + { + /// + /// Interface for streams. Stream functions are grouped into 5 categories: + /// 1) Feature testing functions. + /// 2) Read functions, available only if [M:vl.stream.IStream.CanRead] returns true. + /// 3) Peek functions, available only if [M:vl.stream.IStream.CanPeek] returns true. + /// 4) Write functions, available only if [M:vl.stream.IStream.CanWrite] returns true. + /// 5) Seek functions, available only if [M:vl.stream.IStream.CanSeek] returns true. + /// 6) Size functions, available only if [M:vl.stream.IStream.IsLimited] returns true. But there are still some streams knows that the content is limited, but the size is unknown. In this case, [M:vl.stream.IStream.Size] will return -1. + /// + class IStream : public virtual Interface + { + public: + /// Test if the stream is readable. + /// Returns true if the stream is readable. + virtual bool CanRead()const=0; + /// Test if the stream is writable. + /// Returns true if the stream is writable. + virtual bool CanWrite()const=0; + /// Test if the stream is seekable. + /// Returns true if the stream is seekable. + virtual bool CanSeek()const=0; + /// Test if the stream is peekable. + /// Returns true if the stream is peekable. + virtual bool CanPeek()const=0; + /// Test if the content of the stream is limited. A writable stream can also be limited, it means that you can only write a limited content to the stream. + /// Returns true if the content of the stream is limited. + virtual bool IsLimited()const=0; + /// Test if the stream is available. For example, if you create a readable [T:vl.stream.FileStream] giving a wrong file name, it will be unavailable. + /// Returns true if the stream is available. + virtual bool IsAvailable()const=0; + /// Close the stream. + virtual void Close()=0; + /// Get the current position in the stream. + /// The position in the stream. Returns -1 if the stream is not available. + virtual pos_t Position()const=0; + /// Get the size of the content.. + /// The size of the content. Returns -1 if the size is unknown or the stream is not available. + virtual pos_t Size()const=0; + /// Step forward or backward from the current position. Will throw exception if the stream is not seekable or not available. + /// The length of the step. + virtual void Seek(pos_t _size)=0; + /// Step fowward from the beginning. Will throw exception if the stream is not seekable or not available. + /// The length of the step. + virtual void SeekFromBegin(pos_t _size)=0; + /// Step backward from the end. Will throw exception if the stream is not seekable or not available. + /// The length of the step. + virtual void SeekFromEnd(pos_t _size)=0; + /// Read from the current position and step forward. Will throw exception if the stream is not readable or not available. + /// Returns the actual size of the content that is read. Returns 0 indicates that the stream reaches the end if the stream is limited. + /// A buffer to store the content. + /// The size of the content that is expected to read. + virtual vint Read(void* _buffer, vint _size)=0; + /// Write to the current position and step forward. Will throw exception if the stream is not writable or not available. + /// Returns the actual size of the content that is written. Returns 0 indicates that the stream reaches the end if the stream is limited. + /// A buffer storing the content to write. + /// The size of the content that is expected to write. + virtual vint Write(void* _buffer, vint _size)=0; + /// Read from the current position but not step forward. Will throw exception if the stream is not peekable or not available. + /// Returns the actual size of the content that is read. Returns 0 indicates that the stream reaches the end if the stream is limited. + /// A buffer to store the content. + /// The size of the content that is expected to peek. + virtual vint Peek(void* _buffer, vint _size)=0; + }; + + /// Encoder interface. This interface defines a writable transformation from one stream to another stream. You can create a [T:vl.stream.EncoderStream] after you have an encoder. + class IEncoder : public Interface + { + public: + /// Set a target writable stream. The function will transform the content and write to this tream. + /// The target writable stream. + virtual void Setup(IStream* _stream)=0; + /// Stop the transformation, ensuring all written content is transformed to the target stream. + virtual void Close()=0; + /// Transform content and write to the target stream. This function may cache something to increase performance, so it cannot expect that all transformed content will be written to the target stream immediately. + /// Returns the actual size of the content before transforming that is written. The content is treated as being written even it is cached and not actually write to the target stream. + /// A buffer storing the content to write. + /// The size of the content that is expected to write. + virtual vint Write(void* _buffer, vint _size)=0; + }; + + /// Decoder interface. This interface defines a readable transformation from one stream to another stream. You can create a [T:vl.stream.DecoderStream] after you have an decoder. + class IDecoder : public Interface + { + public: + /// Set a target readable stream. The function will read from this tream and transform the content. + /// The target readable stream. + virtual void Setup(IStream* _stream)=0; + /// Stop the transformation. + virtual void Close()=0; + /// Read from the target stream and transform the content. + /// Returns the actual size of the content after transforming that is read. + /// A buffer to store the content. + /// The size of the content that is expected to read. + virtual vint Read(void* _buffer, vint _size)=0; + }; + } +} + +#endif + +/*********************************************************************** +.\STREAM\ACCESSOR.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Stream::Accessor + +Classes: + TextReader :字符串阅读器 + TextWriter :字符串书写器 + StreamReader :流阅读器 + StreamWriter :流书写器 + EncoderStream :编码流 + DecoderStream :解码流 +***********************************************************************/ + +#ifndef VCZH_STREAM_ACCESSOR +#define VCZH_STREAM_ACCESSOR + + +namespace vl +{ + namespace stream + { + +/*********************************************************************** +流控制器 +***********************************************************************/ + + /// Text reader. All line breaks are normalized to CRLF regardless the format in the source. + class TextReader : public Object, private NotCopyable + { + public: + /// Test does the reader reach the end or not. + /// Returns true if the reader reaches the end. + virtual bool IsEnd()=0; + /// Read a single character. + /// The character. + virtual wchar_t ReadChar()=0; + /// Read a string of a specified size. + /// The string. + /// Expected length of the string to read. + virtual WString ReadString(vint length); + /// Read a string until a line breaks is reached. + /// The string. It does not contain the line break. + virtual WString ReadLine(); + /// Read everying remain. + /// The string. + virtual WString ReadToEnd(); + }; + + /// Text writer. + class TextWriter : public Object, private NotCopyable + { + public: + /// Write a single character. + /// The character to write. + virtual void WriteChar(wchar_t c)=0; + /// Write a string. + /// Buffer to the string to write. + /// Size of the string in characters not including the zero terminator. + virtual void WriteString(const wchar_t* string, vint charCount); + /// Write a string. + /// Buffer to the zero terminated string to write. + virtual void WriteString(const wchar_t* string); + /// Write a string. + /// The string to write. + virtual void WriteString(const WString& string); + /// Write a string with a CRLF. + /// Buffer to the string to write. + /// Size of the string in characters not including the zero terminator. + virtual void WriteLine(const wchar_t* string, vint charCount); + /// Write a string with a CRLF. + /// Buffer to the zero terminated string to write. + virtual void WriteLine(const wchar_t* string); + /// Write a string with a CRLF. + /// The string to write. + virtual void WriteLine(const WString& string); + + virtual void WriteMonospacedEnglishTable(collections::Array& tableByRow, vint rows, vint columns); + }; + + /// Text reader from a string. + class StringReader : public TextReader + { + protected: + WString string; + vint current; + bool lastCallIsReadLine; + + void PrepareIfLastCallIsReadLine(); + public: + /// Create a text reader. + /// The string to read. + StringReader(const WString& _string); + + bool IsEnd(); + wchar_t ReadChar(); + WString ReadString(vint length); + WString ReadLine(); + WString ReadToEnd(); + }; + + /// Text reader from a stream. + class StreamReader : public TextReader + { + protected: + IStream* stream; + public: + /// Create a text reader. + /// The stream to read. + StreamReader(IStream& _stream); + + bool IsEnd(); + wchar_t ReadChar(); + }; + + /// Text writer to a stream. + class StreamWriter : public TextWriter + { + protected: + IStream* stream; + public: + /// Create a text writer. + /// The stream to write. + StreamWriter(IStream& _stream); + using TextWriter::WriteString; + + void WriteChar(wchar_t c); + void WriteString(const wchar_t* string, vint charCount); + }; + +/*********************************************************************** +编码解码 +***********************************************************************/ + + /// Encoder stream, a writable stream using an [T:vl.stream.IEncoder] to transform content. + class EncoderStream : public virtual IStream + { + protected: + IStream* stream; + IEncoder* encoder; + pos_t position; + + public: + /// Create a stream. + /// The target stream to write. + /// The encoder to transform content. + EncoderStream(IStream& _stream, IEncoder& _encoder); + ~EncoderStream(); + + bool CanRead()const; + bool CanWrite()const; + bool CanSeek()const; + bool CanPeek()const; + bool IsLimited()const; + bool IsAvailable()const; + void Close(); + pos_t Position()const; + pos_t Size()const; + void Seek(pos_t _size); + void SeekFromBegin(pos_t _size); + void SeekFromEnd(pos_t _size); + vint Read(void* _buffer, vint _size); + vint Write(void* _buffer, vint _size); + vint Peek(void* _buffer, vint _size); + }; + + /// Decoder stream, a readable stream using an [T:vl.stream.IDecoder] to transform content. + class DecoderStream : public virtual IStream + { + protected: + IStream* stream; + IDecoder* decoder; + pos_t position; + + public: + /// Create a stream. + /// The target stream to read. + /// The decoder to transform content. + DecoderStream(IStream& _stream, IDecoder& _decoder); + ~DecoderStream(); + + bool CanRead()const; + bool CanWrite()const; + bool CanSeek()const; + bool CanPeek()const; + bool IsLimited()const; + bool IsAvailable()const; + void Close(); + pos_t Position()const; + pos_t Size()const; + void Seek(pos_t _size); + void SeekFromBegin(pos_t _size); + void SeekFromEnd(pos_t _size); + vint Read(void* _buffer, vint _size); + vint Write(void* _buffer, vint _size); + vint Peek(void* _buffer, vint _size); + }; + } +} + +#endif + +/*********************************************************************** +.\REFLECTION\GUITYPEDESCRIPTOR.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -9413,1498 +9570,7 @@ Exceptions #endif /*********************************************************************** -PARSING\PARSINGTREE.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Parsing::Parsing Tree - -Classes: -***********************************************************************/ - -#ifndef VCZH_PARSING_PARSINGTREE -#define VCZH_PARSING_PARSINGTREE - - -namespace vl -{ - namespace parsing - { - -/*********************************************************************** -Location -***********************************************************************/ - - /// A type representing text position. - struct ParsingTextPos - { - static const vint UnknownValue=-2; - /// Character index, begins at 0. - vint index; - /// Row number, begins at 0. - vint row; - /// Column number, begins at 0. - vint column; - - ParsingTextPos() - :index(UnknownValue) - ,row(UnknownValue) - ,column(UnknownValue) - { - } - - ParsingTextPos(vint _index) - :index(_index) - ,row(UnknownValue) - ,column(UnknownValue) - { - } - - ParsingTextPos(vint _row, vint _column) - :index(UnknownValue) - ,row(_row) - ,column(_column) - { - } - - ParsingTextPos(vint _index, vint _row, vint _column) - :index(_index) - ,row(_row) - ,column(_column) - { - } - - /// Test if this position a valid position. - /// Returns true if this position is a valid position. - bool IsInvalid()const - { - return index < 0 && row < 0 && column < 0; - } - - static vint Compare(const ParsingTextPos& a, const ParsingTextPos& b) - { - if (a.IsInvalid() && b.IsInvalid()) - { - return 0; - } - else if (a.IsInvalid()) - { - return -1; - } - else if (b.IsInvalid()) - { - return 1; - } - else if (a.index >= 0 && b.index >= 0) - { - return a.index - b.index; - } - else if (a.row >= 0 && a.column >= 0 && b.row >= 0 && b.column >= 0) - { - if (a.row == b.row) - { - return a.column - b.column; - } - else - { - return a.row - b.row; - } - } - else - { - return 0; - } - } - - bool operator==(const ParsingTextPos& pos)const{return Compare(*this, pos)==0;} - bool operator!=(const ParsingTextPos& pos)const{return Compare(*this, pos)!=0;} - bool operator<(const ParsingTextPos& pos)const{return Compare(*this, pos)<0;} - bool operator<=(const ParsingTextPos& pos)const{return Compare(*this, pos)<=0;} - bool operator>(const ParsingTextPos& pos)const{return Compare(*this, pos)>0;} - bool operator>=(const ParsingTextPos& pos)const{return Compare(*this, pos)>=0;} - }; - - /// A type representing text range. - struct ParsingTextRange - { - /// Text position for the first character. - ParsingTextPos start; - /// Text position for the last character. - ParsingTextPos end; - /// Code index, refer to [F:vl.regex.RegexToken.codeIndex] - vint codeIndex; - - ParsingTextRange() - :codeIndex(-1) - { - end.index=-1; - end.column=-1; - } - - ParsingTextRange(const ParsingTextPos& _start, const ParsingTextPos& _end, vint _codeIndex = -1) - :start(_start) - , end(_end) - , codeIndex(_codeIndex) - { - } - - ParsingTextRange(const regex::RegexToken* startToken, const regex::RegexToken* endToken) - :codeIndex(startToken->codeIndex) - { - start.index=startToken->start; - start.row=startToken->rowStart; - start.column=startToken->columnStart; - end.index=endToken->start+endToken->length-1; - end.row=endToken->rowEnd; - end.column=endToken->columnEnd; - } - - bool operator==(const ParsingTextRange& range)const{return start==range.start && end==range.end;} - bool operator!=(const ParsingTextRange& range)const{return start!=range.start || end!=range.end;} - bool Contains(const ParsingTextPos& pos)const{return start<=pos && pos<=end;} - bool Contains(const ParsingTextRange& range)const{return start<=range.start && range.end<=end;} - }; - } - - namespace stream - { - namespace internal - { - BEGIN_SERIALIZATION(parsing::ParsingTextPos) - SERIALIZE(index) - SERIALIZE(row) - SERIALIZE(column) - END_SERIALIZATION - - BEGIN_SERIALIZATION(parsing::ParsingTextRange) - SERIALIZE(start) - SERIALIZE(end) - SERIALIZE(codeIndex) - END_SERIALIZATION - } - } - - namespace parsing - { -/*********************************************************************** -General Syntax Tree -***********************************************************************/ - - class ParsingTreeNode; - class ParsingTreeToken; - class ParsingTreeObject; - class ParsingTreeArray; - - /// Abstract syntax tree. - class ParsingTreeNode : public Object, public reflection::Description - { - public: - class IVisitor : public Interface - { - public: - virtual void Visit(ParsingTreeToken* node)=0; - virtual void Visit(ParsingTreeObject* node)=0; - virtual void Visit(ParsingTreeArray* node)=0; - }; - - class TraversalVisitor : public Object, public IVisitor - { - public: - enum TraverseDirection - { - ByTextPosition, - ByStorePosition - }; - protected: - TraverseDirection direction; - public: - TraversalVisitor(TraverseDirection _direction); - - virtual void BeforeVisit(ParsingTreeToken* node); - virtual void AfterVisit(ParsingTreeToken* node); - virtual void BeforeVisit(ParsingTreeObject* node); - virtual void AfterVisit(ParsingTreeObject* node); - virtual void BeforeVisit(ParsingTreeArray* node); - virtual void AfterVisit(ParsingTreeArray* node); - - virtual void Visit(ParsingTreeToken* node)override; - virtual void Visit(ParsingTreeObject* node)override; - virtual void Visit(ParsingTreeArray* node)override; - }; - protected: - typedef collections::List> NodeList; - - ParsingTextRange codeRange; - ParsingTreeNode* parent; - NodeList cachedOrderedSubNodes; - - virtual const NodeList& GetSubNodesInternal()=0; - bool BeforeAddChild(Ptr node); - void AfterAddChild(Ptr node); - bool BeforeRemoveChild(Ptr node); - void AfterRemoveChild(Ptr node); - public: - ParsingTreeNode(const ParsingTextRange& _codeRange); - ~ParsingTreeNode(); - - virtual void Accept(IVisitor* visitor)=0; - virtual Ptr Clone()=0; - ParsingTextRange GetCodeRange(); - void SetCodeRange(const ParsingTextRange& range); - - /// Precalculate for enhance searching performance for this node and all child nodes. - void InitializeQueryCache(); - /// Clear all cache made by . - void ClearQueryCache(); - /// Get the parent node. Using this function requires running before. - /// The parent node. - ParsingTreeNode* GetParent(); - /// Get the child nodes. Using this function requires running before. - /// The child nodes. - const NodeList& GetSubNodes(); - - /// Find a direct child node at the position. Using this function requires running before. - /// The found node. - /// The position. - ParsingTreeNode* FindSubNode(const ParsingTextPos& position); - /// Find a direct child node at the range. Using this function requires running before. - /// The found node. - /// The range. - ParsingTreeNode* FindSubNode(const ParsingTextRange& range); - /// Find a most deepest indirect child node at the position. Using this function requires running before. - /// The found node. - /// The position. - ParsingTreeNode* FindDeepestNode(const ParsingTextPos& position); - /// Find a most deepest indirect child node at the range. Using this function requires running before. - /// The found node. - /// The range. - ParsingTreeNode* FindDeepestNode(const ParsingTextRange& range); - }; - - /// Representing a token node in a abstract syntax tree. - class ParsingTreeToken : public ParsingTreeNode, public reflection::Description - { - protected: - WString value; - vint tokenIndex; - - const NodeList& GetSubNodesInternal()override; - public: - ParsingTreeToken(const WString& _value, vint _tokenIndex=-1, const ParsingTextRange& _codeRange=ParsingTextRange()); - ~ParsingTreeToken(); - - void Accept(IVisitor* visitor)override; - Ptr Clone()override; - vint GetTokenIndex(); - void SetTokenIndex(vint _tokenIndex); - /// Get the content of the token. - /// The content of the token. - const WString& GetValue(); - void SetValue(const WString& _value); - }; - - /// Representing an object node in a abstract syntax tree. - class ParsingTreeObject : public ParsingTreeNode, public reflection::Description - { - protected: - typedef collections::Dictionary> NodeMap; - typedef collections::SortedList NameList; - typedef collections::List RuleList; - - WString type; - NodeMap members; - RuleList rules; - - const NodeList& GetSubNodesInternal()override; - public: - ParsingTreeObject(const WString& _type=L"", const ParsingTextRange& _codeRange=ParsingTextRange()); - ~ParsingTreeObject(); - - void Accept(IVisitor* visitor)override; - Ptr Clone()override; - /// Get the type name of the object. - /// The type name of the object. - const WString& GetType(); - void SetType(const WString& _type); - /// Get all fields of the object. - /// All fields of the object. - NodeMap& GetMembers(); - /// Get a field of the object by the field name. - /// The field of the object. - /// The field name. - Ptr GetMember(const WString& name); - bool SetMember(const WString& name, Ptr node); - bool RemoveMember(const WString& name); - /// Get all field names. - /// All field names of the object. - const NameList& GetMemberNames(); - /// Get names of all rules that return this object. - /// Names of all rules. - RuleList& GetCreatorRules(); - }; - - /// Representing an array node in a abstract syntax tree. - class ParsingTreeArray : public ParsingTreeNode, public reflection::Description - { - protected: - typedef collections::List> NodeArray; - - WString elementType; - NodeArray items; - - const NodeList& GetSubNodesInternal()override; - public: - ParsingTreeArray(const WString& _elementType=L"", const ParsingTextRange& _codeRange=ParsingTextRange()); - ~ParsingTreeArray(); - - void Accept(IVisitor* visitor)override; - Ptr Clone()override; - /// Get the type of all elements. It could be different from any actual element's type, but it should at least be the base types of them. - /// The type of all elements. - const WString& GetElementType(); - void SetElementType(const WString& _elementType); - /// Get all elements in this array. - /// All elements in this array. - NodeArray& GetItems(); - /// Get a specified element in this array by the index. - /// The element. - /// The index of the element. - Ptr GetItem(vint index); - bool SetItem(vint index, Ptr node); - bool AddItem(Ptr node); - bool InsertItem(vint index, Ptr node); - bool RemoveItem(vint index); - bool RemoveItem(ParsingTreeNode* node); - vint IndexOfItem(ParsingTreeNode* node); - bool ContainsItem(ParsingTreeNode* node); - vint Count(); - bool Clear(); - }; - -/*********************************************************************** -语法树基础设施 -***********************************************************************/ - - /// Base type of all strong typed syntax tree. Normally all strong typed syntax tree are generated from a grammar file using ParserGen.exe in Tools project. See [T:vl.parsing.tabling.ParsingTable] for details. - class ParsingTreeCustomBase : public Object, public reflection::Description - { - public: - /// Range of all tokens that form this object. - ParsingTextRange codeRange; - /// Names of all rules that return this object. - collections::List creatorRules; - }; - - /// Strong typed token syntax node, for all class fields of type "token" in the grammar file. See [T:vl.parsing.tabling.ParsingTable] for details. - class ParsingToken : public ParsingTreeCustomBase, public reflection::Description - { - public: - /// Type of the token, representing the index of a regular expression that creates this token in the regular expression list in the grammar file. - vint tokenIndex; - /// Content of the token. - WString value; - - ParsingToken():tokenIndex(-1){} - }; - - /// Error. - class ParsingError : public Object, public reflection::Description - { - public: - /// Range where the error happens. - ParsingTextRange codeRange; - /// Token at which the error happens. - const regex::RegexToken* token; - /// A syntax tree that contains this error. - ParsingTreeCustomBase* parsingTree; - /// The error message. - WString errorMessage; - - ParsingError(); - ParsingError(const WString& _errorMessage); - ParsingError(const regex::RegexToken* _token, const WString& _errorMessage); - ParsingError(ParsingTreeCustomBase* _parsingTree, const WString& _errorMessage); - ~ParsingError(); - }; - -/*********************************************************************** -Syntax Tree Serialization Helper -***********************************************************************/ - - class ParsingTreeConverter : public Object - { - public: - typedef collections::List TokenList; - - virtual Ptr ConvertClass(Ptr obj, const TokenList& tokens)=0; - - bool SetMember(ParsingToken& member, Ptr node, const TokenList& tokens) - { - Ptr token=node.Cast(); - if(token) - { - member.tokenIndex=token->GetTokenIndex(); - member.value=token->GetValue(); - member.codeRange=token->GetCodeRange(); - return true; - } - return false; - } - - template - bool SetMember(collections::List& member, Ptr node, const TokenList& tokens) - { - Ptr arr=node.Cast(); - if(arr) - { - member.Clear(); - vint count=arr->Count(); - for(vint i=0;iGetItem(i), tokens); - member.Add(t); - } - return true; - } - return false; - } - - template - bool SetMember(Ptr& member, Ptr node, const TokenList& tokens) - { - Ptr obj=node.Cast(); - if(obj) - { - Ptr tree=ConvertClass(obj, tokens); - if(tree) - { - tree->codeRange=node->GetCodeRange(); - member=tree.Cast(); - return member; - } - } - return false; - } - }; - -/*********************************************************************** -Logging -***********************************************************************/ - - class IParsingPrintNodeRecorder : public virtual Interface - { - public: - virtual void Record(ParsingTreeCustomBase* node, const ParsingTextRange& range) = 0; - }; - - class ParsingEmptyPrintNodeRecorder : public Object, public virtual IParsingPrintNodeRecorder - { - public: - ParsingEmptyPrintNodeRecorder(); - ~ParsingEmptyPrintNodeRecorder(); - - void Record(ParsingTreeCustomBase* node, const ParsingTextRange& range)override; - }; - - class ParsingMultiplePrintNodeRecorder : public Object, public virtual IParsingPrintNodeRecorder - { - typedef collections::List> RecorderList; - protected: - RecorderList recorders; - - public: - ParsingMultiplePrintNodeRecorder(); - ~ParsingMultiplePrintNodeRecorder(); - - void AddRecorder(Ptr recorder); - void Record(ParsingTreeCustomBase* node, const ParsingTextRange& range)override; - }; - - class ParsingOriginalLocationRecorder : public Object, public virtual IParsingPrintNodeRecorder - { - protected: - Ptr recorder; - - public: - ParsingOriginalLocationRecorder(Ptr _recorder); - ~ParsingOriginalLocationRecorder(); - - void Record(ParsingTreeCustomBase* node, const ParsingTextRange& range)override; - }; - - class ParsingGeneratedLocationRecorder : public Object, public virtual IParsingPrintNodeRecorder - { - typedef collections::Dictionary RangeMap; - protected: - RangeMap& rangeMap; - - public: - ParsingGeneratedLocationRecorder(RangeMap& _rangeMap); - ~ParsingGeneratedLocationRecorder(); - - void Record(ParsingTreeCustomBase* node, const ParsingTextRange& range)override; - }; - - class ParsingUpdateLocationRecorder : public Object, public virtual IParsingPrintNodeRecorder - { - public: - ParsingUpdateLocationRecorder(); - ~ParsingUpdateLocationRecorder(); - - void Record(ParsingTreeCustomBase* node, const ParsingTextRange& range)override; - }; - - class ParsingWriter : public stream::TextWriter - { - typedef collections::Pair NodePosPair; - typedef collections::List NodePosList; - protected: - stream::TextWriter& writer; - Ptr recorder; - vint codeIndex; - ParsingTextPos lastPos; - ParsingTextPos currentPos; - NodePosList nodePositions; - - void HandleChar(wchar_t c); - public: - ParsingWriter(stream::TextWriter& _writer, Ptr _recorder = nullptr, vint _codeIndex = -1); - ~ParsingWriter(); - - using stream::TextWriter::WriteString; - void WriteChar(wchar_t c)override; - void WriteString(const wchar_t* string, vint charCount)override; - void BeforePrint(ParsingTreeCustomBase* node); - void AfterPrint(ParsingTreeCustomBase* node); - }; - - extern void Log(ParsingTreeNode* node, const WString& originalInput, stream::TextWriter& writer, const WString& prefix=L""); - } -} - -#endif - -/*********************************************************************** -PARSING\PARSINGTABLE.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Parsing::Table - -Classes: -***********************************************************************/ - -#ifndef VCZH_PARSING_PARSINGTABLE -#define VCZH_PARSING_PARSINGTABLE - - -namespace vl -{ - namespace parsing - { - namespace tabling - { - -/*********************************************************************** -跳转表 -***********************************************************************/ - - /// " // (multiple) e.g. "../Import/Vlpp.h" - /// classPrefix: // (single) A prefix that will be add before all generated types and function. e.g. Xml - /// guard: // (single) The C++ header guard pattern macro name. e.g. VCZH_PARSING_XML_PARSINGXML_PARSER - /// namespace: // (single) Namespaces separated by "." to contain the generated code. e.g. vl.parsing.xml - /// reflection: // (single) Namespaces separated by "." to contain the name of reflectable types. In most of the cases this should be the same as namespace. e.g. vl.parsing.xml - /// parser:() // (multiple) Pair a function name to a rule name. ParserGen.exe will generate a function called "" to parse the input using rule named "". e.g. ParseDocument(XDocument) - /// ambiguity:(enabled|disabled) // (single) Set to "enabled" indicating that the grammar is by design to have ambiguity. - /// serialization:(enabled|disabled) // (single) Set to "enabled" to serialize the parsing table as binary in the generated C++ code, so that when the "LoadTable" function is called to load the table, it can deserialize from the binary data directly, instead of parsing the grammar again. But the grammar text will always be contained in the generated C++ code regardless of the value of "serialization", it can always be retrived using the "GetParserTextBuffer" function. - /// grammar: // (single) Configuration ends here. All content after "grammar:" will be treated as the grammar to define the input. - /// - /// Here is the brief description of the grammar. - /// The grammar is formed by 3 parts: types, token definitions and rule definitions. There is only one character escaping in strings: "", which means the " character. - /// - /// 1) Types: - /// You can write attributes like @AttributeName("argument1", "argument2", ...) in the middle of types. But attributes don't affect the parsing. All attribute definitions will be stored in the generated parsing table, and who uses the table defines how attributes work. Multiple attributes are separated by ",". - /// - /// a) Enum: - /// enum EnumName - /// { - /// Item1 , - /// Item2 , - /// ... // cannot skip the last "," - /// } - /// - /// b) Class: - /// class Name [ambiguous(AmbiguousType)] [: ParentType] - /// { - /// Type name [(UnescapingFunction)] ; - /// } - /// - /// UnescapingFunction is a callback, which will be called when the contained type is fully constructed. The generated C++ code will define forward declarations of all unescaping functions in the cpp file. You should implement them in other places, or you will get linking errors. - /// - /// If the grammar enables ambiguity, then the parsing result may contain ambiguous results for the same part of the input. For example, in C++: - /// A*B; - /// has two meaning (if we only consider context-free parsing): multiplication expression and pointer variable definition. - /// So if the grammar doesn't enable ambiguity, ParserGen.exe will refuce to generate C++ codes because the grammar is wrong. - /// If the grammar enables ambiguity, than the syntax tree should be defined like this: - /// - /// class Statement ambiguous(AmbiguousStatement) - /// { - /// } - /// - /// class AmbiguousStatement : Statement // due to the definition of "Statement" class, "AmbiguousStatement" should inherit from "Statement" - /// { - /// Statement[] items; // required by naming convention - /// } - /// - /// class ExpressionStatement : Statement - /// { - /// Expression expression; - /// } - /// - /// class VariableDefinitionStatement : Statement - /// { - /// Type type; - /// token name; - /// } - /// - /// So for the "A*B;" part in the whole input, it will becomes an AmbiguousStatement, in which the "items" field contains 2 instance of "ExpressionStatement" and "VariableDefinitionStatement". - /// And you can write C++ code to resolve the ambiguity in later passes. - /// - /// c) Type references: - /// Types can be defined globally or inside classes. Generic type is not supported. When you want to refer to a specific type, it could be: - /// token: Store a token, which will becomes [T:vl.parsing.ParsingToken]. - /// Type[]: Array, which will becomes [T:vl.collections.List`2] to the element type. Token cannot be the element of arrays. - /// ClassName: Instance of a specified type, which will becomes [T:vl.Ptr`1] to that type. - /// OuterClass.InnerClass: Refer to the "InnerClass" defined inside the "OuterClass". - /// - /// 2) Token definitions: - /// token TokenName = "regular expression" ; - /// discardtoken TokenName = "regular expression"; - /// - /// "discardtoken" means if such a token is identified, it will not appear in the lexical analyzing result. And you cannot refer to names of "discardtoken" in the grammar. - /// - /// 3) Rule definitions: - /// rule RuleType RuleName - /// = Grammar1 - /// = Grammar2 - /// ... - /// ; - /// - /// It means rule "RuleName" is defined by those grammars, and matching this rule will create an instance of "RuleType" or its whatever types that inheriting "RuleType". - /// - /// 4) Grammars: - /// RuleName: Defines an input that matches a rule. - /// TokenName: Defines an input that formed by the specified token. - /// "StringConstant": Defins an input that formed by exactly the string constant. This constant should define a token in the token list. - /// Grammar : FieldName: Defines an input that matches Grammar (should be either a rule name or a token name), and the result will be stored in field "FieldName" of a class, whose type will appear later. - /// !Grammar: Defines an input that matches Grammar, and the rule will return the result from this grammar. The input should still match other part of the rule, but result of other parts are ignored. - /// [Grammar]: Defines an input that, if match Grammar, will returns the result from that grammar; if not, the result is null. - /// {Grammar}: Defines an input that matches 0, 1 or more Grammar. - /// (Grammar): Defins an input that matches the the grammar. Brackets is only for changing operator associations. - /// Grammar1 Grammar2: Defines an input that should match Grammar1 right before Grammar2. - /// Grammar1 | Grammar2: Defines an input that match either Grammar1 or Grammar2. - /// Grammar as Type: Defines an input that matches the Grammar, and the whole branch of the rule creates an instance of type "Type" - /// Grammar with { FieldName = Value }: Defins an input that matches the Grammar, and will assign "Value", which should be an enum item, to the field "FieldName" of the created instance. - /// - /// 5) Example - /// Here is an example to parse expression containing +, -, *, /, () and numbers:\ - /// - /// include:"Vlpp.h" - /// classPrefix:Calc - /// guard:VCZH_CALCULATOR_PARSER - /// namespace:vl.calculator - /// reflection:vl.calculator - /// parser:ParseExpression(Expr) - /// ambiguity:disabled - /// serialization:enabled - /// grammar: - /// - /// class Expression - /// { - /// } - /// - /// enum BinaryOperator - /// { - /// Add, Sub, Mul, Div, - /// } - /// - /// class NumberExpression : Expression - /// { - /// token number; - /// } - /// - /// class BinaryExpression : Expression - /// { - /// BinaryOperator op; - /// Expression left; - /// Expression right; - /// } - /// - /// token ADD "\+" - /// token SUB "-" - /// token MUL "\*" - /// token DIV "\/" - /// token NUMBER "\d+(.\d+)?" - /// token OPEN "(" - /// token CLOSE ")" - /// - /// rule Expression Factor - /// = NUMBER : number as NumberExpression - /// = "(" !Expr ")" - /// ; - /// rule Expression Term - /// = !Factor - /// = Term : left "*" Factor : right as BinaryExpression with {op = "Mul"} - /// = Term : left "/" Factor : right as BinaryExpression with {op = "Div"} - /// ; - /// rule Expression Expr - /// = !Term - /// = Expr : left "+" Term : right as BinaryExpression with {op = "Add"} - /// = Expr : left "-" Term : right as BinaryExpression with {op = "Sub"} - /// ; - /// - /// After using ParserGen.exe to generate C++ codes, you can do this: - /// auto table = CalcLoadTable(); // this table can be used several times, don't load each type for each parsing, it will have a big performance overhead. - /// List> errors; - /// auto expression = CalcParseExpression(L"(1+2) * (3+4)", table, errors); // it should be a Ptr, will returns nullptr if the input is wrong, with all errors filled into the "errors" variable. - /// You don't need to define the "errors" if you don't actually care how the input is wrong. There will be a overloaded version of CalcParseExpression that doesn't need the error list. - /// - /// If you want to parse a wrong input and do automatic error recovering, which means if the input is not too wrong, you can still get a syntax tree, but some fields are null, with errors filled into the "error" variable. It will be a little complex: - /// auto table = CalcLoadTable(); // Load the table. - /// ParsingState state(L"(1+2) * (3+4)", table); // Initialize a state with the input and the table. - /// state.Reset(L"Expr"); // Set the rule to parse. - /// auto parser = CreateAutoRecoverParser(table); // Create an appropriate automatic error recoverable parser. - /// List> errors; // Define an error list. - /// auto node = parser->Parse(state, errors); // Parse to get an abstract syntax tree, which is a Ptr. - /// if (node) - /// { - /// auto expression = CalcConvertParsingTreeNode(node, state.GetTokens()).Cast(); - /// } - /// - /// After you get a strong typed syntax tree, you can use the generated visitor interface to do something, like evaluate the results of the expression: - /// class Evaluator : public Object, public virtual CalcExpression::IVisitor - /// { - /// private: - /// double result; - /// - /// double Call(CalcExpression* node) - /// { - /// node->Accept(this); - /// return result; - /// } - /// - /// public: - /// - /// static double Evaluate(CalcExpression* node) - /// { - /// return Evaluator().Call(node); - /// } - /// - /// void Visit(CalcNumberExpression* node)override - /// { - /// return wtof(node->number.value); - /// } - /// - /// void Visit(CalcBinaryExpression* node)override - /// { - /// auto left = Calc(node->left.Obj()); - /// auto right = Calc(node->right.Obj()); - /// switch (node->op) - /// { - /// case CalcBinaryOperator::Add: - /// result = left + right; - /// break; - /// case CalcBinaryOperator::Sub: - /// result = left 0 right; - /// break; - /// case CalcBinaryOperator::Mul: - /// result = left * right; - /// break; - /// case CalcBinaryOperator::Div: - /// result = left / right; - /// break; - /// } - /// } - /// }; - /// - /// Nullable EvaluateExpression(const WString& input) - /// { - /// static auto table = CalcLoadTable(); - /// auto expression = CalcParseExpression(input, table); - /// Nulllable result; - /// if (expression) - /// { - /// result = Evaluator::Evaulate(expression.Obj()); - /// } - /// return result; - /// } - /// - /// ]]> - class ParsingTable : public Object - { - public: - static const vint TokenBegin=0; - static const vint TokenFinish=1; - static const vint NormalReduce=2; - static const vint LeftRecursiveReduce=3; - static const vint UserTokenStart=4; - - class AttributeInfo : public Object - { - public: - WString name; - collections::List arguments; - - AttributeInfo(const WString& _name = L"") - :name(_name) - { - } - - AttributeInfo* Argument(const WString& argument) - { - arguments.Add(argument); - return this; - } - }; - - class AttributeInfoList : public Object - { - public: - collections::List> attributes; - - Ptr FindFirst(const WString& name); - }; - - class TreeTypeInfo - { - public: - WString type; - vint attributeIndex; - - TreeTypeInfo() - :attributeIndex(-1) - { - } - - TreeTypeInfo(const WString& _type, vint _attributeIndex) - :type(_type) - ,attributeIndex(_attributeIndex) - { - } - }; - - class TreeFieldInfo - { - public: - WString type; - WString field; - vint attributeIndex; - - TreeFieldInfo() - :attributeIndex(-1) - { - } - - TreeFieldInfo(const WString& _type, const WString& _field, vint _attributeIndex) - :type(_type) - ,field(_field) - ,attributeIndex(_attributeIndex) - { - } - }; - - class TokenInfo - { - public: - WString name; - WString regex; - vint regexTokenIndex; - vint attributeIndex; - - TokenInfo() - :regexTokenIndex(-1) - ,attributeIndex(-1) - { - } - - TokenInfo(const WString& _name, const WString& _regex, vint _attributeIndex) - :name(_name) - ,regex(_regex) - ,regexTokenIndex(-1) - ,attributeIndex(_attributeIndex) - { - } - }; - - class StateInfo - { - public: - WString ruleName; - WString stateName; - WString stateExpression; - - WString ruleAmbiguousType; // filled in Initialize() - - StateInfo() - { - } - - StateInfo(const WString& _ruleName, const WString& _stateName, const WString& _stateExpression) - :ruleName(_ruleName) - ,stateName(_stateName) - ,stateExpression(_stateExpression) - { - } - }; - - class RuleInfo - { - public: - WString name; - WString type; - WString ambiguousType; - vint rootStartState; - vint attributeIndex; - - RuleInfo() - :rootStartState(-1) - ,attributeIndex(-1) - { - } - - RuleInfo(const WString& _name, const WString& _type, const WString& _ambiguousType, vint _rootStartState, vint _attributeIndex) - :name(_name) - ,type(_type) - ,ambiguousType(_ambiguousType) - ,rootStartState(_rootStartState) - ,attributeIndex(_attributeIndex) - { - } - }; - - class Instruction - { - public: - enum InstructionType - { - Create, - Assign, - Item, - Using, - Setter, - Shift, - Reduce, - LeftRecursiveReduce, - }; - - InstructionType instructionType; - vint stateParameter; - WString nameParameter; - WString value; - WString creatorRule; - - Instruction() - :instructionType(Create) - ,stateParameter(0) - { - } - - Instruction(InstructionType _instructionType, vint _stateParameter, const WString& _nameParameter, const WString& _value, const WString& _creatorRule) - :instructionType(_instructionType) - ,stateParameter(_stateParameter) - ,nameParameter(_nameParameter) - ,value(_value) - ,creatorRule(_creatorRule) - { - } - }; - - class LookAheadInfo - { - public: - collections::List tokens; - vint state; - - LookAheadInfo() - :state(-1) - { - } - - enum PrefixResult - { - Prefix, - Equal, - NotPrefix, - }; - - static PrefixResult TestPrefix(Ptr a, Ptr b); - static void WalkInternal(Ptr table, Ptr previous, vint state, collections::SortedList& walkedStates, collections::List>& newInfos); - static void Walk(Ptr table, Ptr previous, vint state, collections::List>& newInfos); - }; - - class TransitionItem - { - public: - vint token; - vint targetState; - collections::List> lookAheads; - collections::List stackPattern; - collections::List instructions; - - enum OrderResult - { - CorrectOrder, - WrongOrder, - SameOrder, - UnknownOrder, - }; - - TransitionItem(){} - - TransitionItem(vint _token, vint _targetState) - :token(_token) - ,targetState(_targetState) - { - } - - static OrderResult CheckOrder(Ptr t1, Ptr t2, bool forceGivingOrder); - static vint Compare(Ptr t1, Ptr t2); - }; - - class TransitionBag - { - public: - collections::List> transitionItems; - }; - - protected: - // metadata - bool ambiguity; - collections::Array> attributeInfos; - collections::Array treeTypeInfos; - collections::Array treeFieldInfos; - - // LALR table - vint tokenCount; // tokenInfos.Count() + discardTokenInfos.Count() - vint stateCount; // stateInfos.Count() - collections::Array tokenInfos; - collections::Array discardTokenInfos; - collections::Array stateInfos; - collections::Array ruleInfos; - collections::Array> transitionBags; - - // generated data - Ptr lexer; - collections::Dictionary ruleMap; - collections::Dictionary treeTypeInfoMap; - collections::Dictionary, vint> treeFieldInfoMap; - - template - void IO(TIO& io); - - public: - ParsingTable(vint _attributeInfoCount, vint _treeTypeInfoCount, vint _treeFieldInfoCount, vint _tokenCount, vint _discardTokenCount, vint _stateCount, vint _ruleCount); - /// Deserialize the parsing table from a stream. should be before using this table. - /// The stream. - ParsingTable(stream::IStream& input); - ~ParsingTable(); - - /// Serialize the parsing table to a stream. - /// The stream. - void Serialize(stream::IStream& output); - - bool GetAmbiguity(); - void SetAmbiguity(bool value); - - vint GetAttributeInfoCount(); - Ptr GetAttributeInfo(vint index); - void SetAttributeInfo(vint index, Ptr info); - - vint GetTreeTypeInfoCount(); - const TreeTypeInfo& GetTreeTypeInfo(vint index); - const TreeTypeInfo& GetTreeTypeInfo(const WString& type); - void SetTreeTypeInfo(vint index, const TreeTypeInfo& info); - - vint GetTreeFieldInfoCount(); - const TreeFieldInfo& GetTreeFieldInfo(vint index); - const TreeFieldInfo& GetTreeFieldInfo(const WString& type, const WString& field); - void SetTreeFieldInfo(vint index, const TreeFieldInfo& info); - - vint GetTokenCount(); - const TokenInfo& GetTokenInfo(vint token); - void SetTokenInfo(vint token, const TokenInfo& info); - - vint GetDiscardTokenCount(); - const TokenInfo& GetDiscardTokenInfo(vint token); - void SetDiscardTokenInfo(vint token, const TokenInfo& info); - - vint GetStateCount(); - const StateInfo& GetStateInfo(vint state); - void SetStateInfo(vint state, const StateInfo& info); - - vint GetRuleCount(); - const RuleInfo& GetRuleInfo(const WString& ruleName); - const RuleInfo& GetRuleInfo(vint rule); - void SetRuleInfo(vint rule, const RuleInfo& info); - - const regex::RegexLexer& GetLexer(); - Ptr GetTransitionBag(vint state, vint token); - void SetTransitionBag(vint state, vint token, Ptr bag); - /// Initialize the parsing table. This function should be called after deserializing the table from a string. - void Initialize(); - bool IsInputToken(vint regexTokenIndex); - vint GetTableTokenIndex(vint regexTokenIndex); - vint GetTableDiscardTokenIndex(vint regexTokenIndex); - }; - -/*********************************************************************** -辅助函数 -***********************************************************************/ - - extern void Log(Ptr table, stream::TextWriter& writer); - } - } -} - -#endif - -/*********************************************************************** -PARSING\PARSINGSTATE.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Parsing::State - -Classes: -***********************************************************************/ - -#ifndef VCZH_PARSING_PARSINGSTATE -#define VCZH_PARSING_PARSINGSTATE - - -namespace vl -{ - namespace parsing - { - namespace tabling - { - -/*********************************************************************** -语法分析器 -***********************************************************************/ - - class ParsingTokenWalker : public Object - { - protected: - class LookAheadEnumerator : public Object, public collections::IEnumerator - { - protected: - const ParsingTokenWalker* walker; - vint firstToken; - vint currentToken; - vint currentValue; - vint index; - - public: - LookAheadEnumerator(const ParsingTokenWalker* _walker, vint _currentToken); - LookAheadEnumerator(const LookAheadEnumerator& _enumerator); - - collections::IEnumerator* Clone()const override; - const vint& Current()const override; - vint Index()const override; - bool Next()override; - void Reset()override; - }; - - class TokenLookAhead : public Object, public collections::IEnumerable - { - protected: - const ParsingTokenWalker* walker; - public: - TokenLookAhead(const ParsingTokenWalker* _talker); - - collections::IEnumerator* CreateEnumerator()const override; - }; - - class ReduceLookAhead : public Object, public collections::IEnumerable - { - protected: - const ParsingTokenWalker* walker; - public: - ReduceLookAhead(const ParsingTokenWalker* _walker); - - collections::IEnumerator* CreateEnumerator()const override; - }; - - protected: - collections::List& tokens; - Ptr table; - vint currentToken; - TokenLookAhead tokenLookAhead; - ReduceLookAhead reduceLookAhead; - - vint GetNextIndex(vint index)const; - vint GetTableTokenIndex(vint index)const; - public: - ParsingTokenWalker(collections::List& _tokens, Ptr _table); - ~ParsingTokenWalker(); - - const collections::IEnumerable& GetTokenLookahead()const; - const collections::IEnumerable& GetReduceLookahead()const; - void Reset(); - bool Move(); - vint GetTableTokenIndex()const; - regex::RegexToken* GetRegexToken()const; - vint GetTokenIndexInStream()const; - }; - - class ParsingState : public Object - { - public: - struct ShiftReduceRange - { - regex::RegexToken* shiftToken; - regex::RegexToken* reduceToken; - - ShiftReduceRange() - :shiftToken(0) - ,reduceToken(0) - { - } - }; - - struct TransitionResult - { - enum TransitionType - { - ExecuteInstructions, - AmbiguityBegin, - AmbiguityBranch, - AmbiguityEnd, - SkipToken, - }; - - TransitionType transitionType; - vint ambiguityAffectedStackNodeCount; - WString ambiguityNodeType; - - vint tableTokenIndex; - vint tableStateSource; - vint tableStateTarget; - vint tokenIndexInStream; - regex::RegexToken* token; - - ParsingTable::TransitionItem* transition; - vint instructionBegin; - vint instructionCount; - Ptr> shiftReduceRanges; - - TransitionResult(TransitionType _transitionType=ExecuteInstructions) - :transitionType(_transitionType) - ,ambiguityAffectedStackNodeCount(0) - ,tableTokenIndex(-1) - ,tableStateSource(-1) - ,tableStateTarget(-1) - ,tokenIndexInStream(-1) - ,token(0) - ,transition(0) - ,instructionBegin(-1) - ,instructionCount(-1) - { - } - - operator bool()const - { - return transitionType!=ExecuteInstructions || transition!=0; - } - - void AddShiftReduceRange(regex::RegexToken* shiftToken, regex::RegexToken* reduceToken) - { - ShiftReduceRange range; - range.shiftToken=shiftToken; - range.reduceToken=reduceToken; - if(!shiftReduceRanges) - { - shiftReduceRanges=new collections::List(); - } - shiftReduceRanges->Add(range); - } - }; - - struct Future - { - vint currentState; - vint reduceStateCount; - collections::List shiftStates; - regex::RegexToken* selectedRegexToken; - vint selectedToken; - ParsingTable::TransitionItem* selectedItem; - Future* previous; - Future* next; - - Future() - :currentState(-1) - ,reduceStateCount(0) - ,selectedRegexToken(0) - ,selectedToken(-1) - ,selectedItem(0) - ,previous(0) - ,next(0) - { - } - - Future* Clone() - { - Future* future = new Future; - future->currentState = currentState; - future->reduceStateCount = reduceStateCount; - CopyFrom(future->shiftStates, shiftStates); - future->selectedRegexToken = selectedRegexToken; - future->selectedToken = selectedToken; - future->selectedItem = selectedItem; - future->previous = previous; - return future; - } - }; - - struct StateGroup - { - collections::List stateStack; - vint currentState; - vint tokenSequenceIndex; - - collections::List shiftTokenStack; - regex::RegexToken* shiftToken; - regex::RegexToken* reduceToken; - - StateGroup(); - StateGroup(const ParsingTable::RuleInfo& info); - StateGroup(const StateGroup& group); - }; - private: - WString input; - Ptr table; - collections::List tokens; - Ptr walker; - - WString parsingRule; - vint parsingRuleStartState; - Ptr stateGroup; - public: - ParsingState(const WString& _input, Ptr _table, vint codeIndex=-1); - ~ParsingState(); - - const WString& GetInput(); - Ptr GetTable(); - const collections::List& GetTokens(); - regex::RegexToken* GetToken(vint index); - - vint Reset(const WString& rule); - WString GetParsingRule(); - vint GetParsingRuleStartState(); - vint GetCurrentToken(); - vint GetCurrentTableTokenIndex(); - const collections::List& GetStateStack(); - vint GetCurrentState(); - void SkipCurrentToken(); - - bool TestTransitionItemInFuture(vint tableTokenIndex, Future* future, ParsingTable::TransitionItem* item, const collections::IEnumerable* lookAheadTokens); - ParsingTable::TransitionItem* MatchTokenInFuture(vint tableTokenIndex, Future* future, const collections::IEnumerable* lookAheadTokens); - ParsingTable::TransitionItem* MatchToken(vint tableTokenIndex, const collections::IEnumerable* lookAheadTokens); - void RunTransitionInFuture(ParsingTable::TransitionItem* transition, Future* previous, Future* now); - ParsingState::TransitionResult RunTransition(ParsingTable::TransitionItem* transition, regex::RegexToken* regexToken, vint instructionBegin, vint instructionCount, bool lastPart); - ParsingState::TransitionResult RunTransition(ParsingTable::TransitionItem* transition, regex::RegexToken* regexToken); - - bool ReadTokenInFuture(vint tableTokenIndex, Future* previous, Future* now, const collections::IEnumerable* lookAheadTokens); - TransitionResult ReadToken(vint tableTokenIndex, regex::RegexToken* regexToken, const collections::IEnumerable* lookAheadTokens); - TransitionResult ReadToken(); - - bool TestExplore(vint tableTokenIndex, Future* previous); - bool Explore(vint tableTokenIndex, Future* previous, collections::List& possibilities); - bool ExploreStep(collections::List& previousFutures, vint start, vint count, collections::List& possibilities); - bool ExploreNormalReduce(collections::List& previousFutures, vint start, vint count, collections::List& possibilities); - bool ExploreLeftRecursiveReduce(collections::List& previousFutures, vint start, vint count, collections::List& possibilities); - Future* ExploreCreateRootFuture(); - - Ptr TakeSnapshot(); - void RestoreSnapshot(Ptr group); - }; - -/*********************************************************************** -语法树生成器 -***********************************************************************/ - - class ParsingTransitionProcessor : public Object - { - public: - virtual void Reset()=0; - virtual bool Run(const ParsingState::TransitionResult& result)=0; - virtual bool GetProcessingAmbiguityBranch()=0; - }; - - class ParsingTreeBuilder : public ParsingTransitionProcessor - { - protected: - Ptr createdObject; - Ptr operationTarget; - collections::List> nodeStack; - - bool processingAmbiguityBranch; - Ptr ambiguityBranchCreatedObject; - Ptr ambiguityBranchOperationTarget; - vint ambiguityBranchSharedNodeCount; - collections::List> ambiguityBranchNodeStack; - collections::List> ambiguityNodes; - public: - ParsingTreeBuilder(); - ~ParsingTreeBuilder(); - - void Reset()override; - bool Run(const ParsingState::TransitionResult& result)override; - bool GetProcessingAmbiguityBranch()override; - Ptr GetNode()const; - }; - - class ParsingTransitionCollector : public ParsingTransitionProcessor - { - typedef collections::List TransitionResultList; - protected: - vint ambiguityBegin; - TransitionResultList transitions; - - collections::Dictionary ambiguityBeginToEnds; - collections::Group ambiguityBeginToBranches; - collections::Dictionary ambiguityBranchToBegins; - public: - ParsingTransitionCollector(); - ~ParsingTransitionCollector(); - - void Reset()override; - bool Run(const ParsingState::TransitionResult& result)override; - bool GetProcessingAmbiguityBranch()override; - - const TransitionResultList& GetTransitions()const; - vint GetAmbiguityEndFromBegin(vint transitionIndex)const; - const collections::List& GetAmbiguityBranchesFromBegin(vint transitionIndex)const; - vint GetAmbiguityBeginFromBranch(vint transitionIndex)const; - }; - } - } -} - -#endif - -/*********************************************************************** -REFLECTION\GUITYPEDESCRIPTORPREDEFINED.H +.\REFLECTION\GUITYPEDESCRIPTORPREDEFINED.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -11295,10 +9961,6 @@ Libraries static double Floor(double value) { return floor(value); } static double Round(double value) { return round(value); } static double Trunc(double value) { return trunc(value); } - static vint64_t CeilI(double value) { return (vint64_t)ceil(value); } - static vint64_t FloorI(double value) { return (vint64_t)floor(value); } - static vint64_t RoundI(double value) { return (vint64_t)round(value); } - static vint64_t TruncI(double value) { return (vint64_t)trunc(value); } }; } } @@ -11306,8 +9968,9 @@ Libraries #endif + /*********************************************************************** -REFLECTION\GUITYPEDESCRIPTORBUILDER.H +.\REFLECTION\GUITYPEDESCRIPTORBUILDER.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -12480,8 +11143,9 @@ StructTypeDescriptor #endif + /*********************************************************************** -REFLECTION\GUITYPEDESCRIPTORBUILDER_CONTAINER.H +.\REFLECTION\GUITYPEDESCRIPTORBUILDER_CONTAINER.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -13453,7 +12117,342 @@ ParameterAccessor #endif /*********************************************************************** -REFLECTION\GUITYPEDESCRIPTORCPPHELPER.H +.\REFLECTION\GUITYPEDESCRIPTORBUILDER_STRUCT.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Framework::Reflection + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_REFLECTION_GUITYPEDESCRIPTORBUILDER_STRUCT +#define VCZH_REFLECTION_GUITYPEDESCRIPTORBUILDER_STRUCT + + +namespace vl +{ + namespace reflection + { + namespace description + { + +/*********************************************************************** +DetailTypeInfoRetriver +***********************************************************************/ + + template + struct DetailTypeInfoRetriver + { + static const ITypeInfo::Decorator Decorator=ITypeInfo::TypeDescriptor; + typedef T Type; + typedef T TempValueType; + typedef T& ResultReferenceType; + typedef T ResultNonReferenceType; + +#ifndef VCZH_DEBUG_NO_REFLECTION + static Ptr CreateTypeInfo(TypeInfoHint hint) + { + return MakePtr(GetTypeDescriptor(), hint); + } +#endif + }; + + template + struct DetailTypeInfoRetriver + { + typedef DetailTypeInfoRetriver UpLevelRetriver; + + static const ITypeInfo::Decorator Decorator=UpLevelRetriver::Decorator; + typedef typename UpLevelRetriver::Type Type; + typedef T TempValueType; + typedef const T& ResultReferenceType; + typedef const T ResultNonReferenceType; + +#ifndef VCZH_DEBUG_NO_REFLECTION + static Ptr CreateTypeInfo(TypeInfoHint hint) + { + return TypeInfoRetriver::CreateTypeInfo(); + } +#endif + }; + + template + struct DetailTypeInfoRetriver + { + typedef DetailTypeInfoRetriver UpLevelRetriver; + + static const ITypeInfo::Decorator Decorator=UpLevelRetriver::Decorator; + typedef typename UpLevelRetriver::Type Type; + typedef T TempValueType; + typedef T& ResultReferenceType; + typedef T ResultNonReferenceType; + +#ifndef VCZH_DEBUG_NO_REFLECTION + static Ptr CreateTypeInfo(TypeInfoHint hint) + { + return TypeInfoRetriver::CreateTypeInfo(); + } +#endif + }; + + template + struct DetailTypeInfoRetriver + { + typedef DetailTypeInfoRetriver UpLevelRetriver; + + static const ITypeInfo::Decorator Decorator=ITypeInfo::RawPtr; + typedef typename UpLevelRetriver::Type Type; + typedef T* TempValueType; + typedef T*& ResultReferenceType; + typedef T* ResultNonReferenceType; + +#ifndef VCZH_DEBUG_NO_REFLECTION + static Ptr CreateTypeInfo(TypeInfoHint hint) + { + return MakePtr(TypeInfoRetriver::CreateTypeInfo()); + } +#endif + }; + + template + struct DetailTypeInfoRetriver, TypeFlags::NonGenericType> + { + typedef DetailTypeInfoRetriver UpLevelRetriver; + + static const ITypeInfo::Decorator Decorator=ITypeInfo::SharedPtr; + typedef typename UpLevelRetriver::Type Type; + typedef Ptr TempValueType; + typedef Ptr& ResultReferenceType; + typedef Ptr ResultNonReferenceType; + +#ifndef VCZH_DEBUG_NO_REFLECTION + static Ptr CreateTypeInfo(TypeInfoHint hint) + { + return MakePtr(TypeInfoRetriver::CreateTypeInfo()); + } +#endif + }; + + template + struct DetailTypeInfoRetriver, TypeFlags::NonGenericType> + { + typedef DetailTypeInfoRetriver UpLevelRetriver; + + static const ITypeInfo::Decorator Decorator=ITypeInfo::Nullable; + typedef typename UpLevelRetriver::Type Type; + typedef Nullable TempValueType; + typedef Nullable& ResultReferenceType; + typedef Nullable ResultNonReferenceType; + +#ifndef VCZH_DEBUG_NO_REFLECTION + static Ptr CreateTypeInfo(TypeInfoHint hint) + { + return MakePtr(TypeInfoRetriver::CreateTypeInfo()); + } +#endif + }; + + template + struct DetailTypeInfoRetriver + { + typedef DetailTypeInfoRetriver UpLevelRetriver; + + static const ITypeInfo::Decorator Decorator=UpLevelRetriver::Decorator; + typedef typename UpLevelRetriver::Type Type; + typedef typename UpLevelRetriver::TempValueType TempValueType; + typedef T& ResultReferenceType; + typedef T ResultNonReferenceType; + +#ifndef VCZH_DEBUG_NO_REFLECTION + static Ptr CreateTypeInfo(TypeInfoHint hint) + { + return TypeInfoRetriver::CreateTypeInfo(); + } +#endif + }; + + template<> + struct TypeInfoRetriver : public TypeInfoRetriver + { + }; + +/*********************************************************************** +ParameterAccessor +***********************************************************************/ + + template + struct ParameterAccessor + { + static Value BoxParameter(const T& object, ITypeDescriptor* typeDescriptor) + { + return BoxValue(object, typeDescriptor); + } + + static void UnboxParameter(const Value& value, T& result, ITypeDescriptor* typeDescriptor, const WString& valueName) + { + result=UnboxValue(value, typeDescriptor, valueName); + } + }; + + template + struct ValueAccessor + { + static Value BoxValue(T* object, ITypeDescriptor* typeDescriptor) + { + return Value::From(object); + } + + static T* UnboxValue(const Value& value, ITypeDescriptor* typeDescriptor, const WString& valueName) + { + if(value.IsNull()) return nullptr; + T* result = nullptr; + if (value.GetRawPtr()) + { + result = value.GetRawPtr()->SafeAggregationCast(); + } + if(!result) + { +#ifndef VCZH_DEBUG_NO_REFLECTION + if(!typeDescriptor) + { + typeDescriptor=GetTypeDescriptor(); + } + throw ArgumentTypeMismtatchException(valueName, typeDescriptor, Value::RawPtr, value); +#else + CHECK_FAIL(L"vl::reflection::description::UnboxValue()#Argument type mismatch."); +#endif + } + return result; + } + }; + + template + struct ValueAccessor, ITypeInfo::SharedPtr> + { + static Value BoxValue(Ptr object, ITypeDescriptor* typeDescriptor) + { + return Value::From(object); + } + + static Ptr UnboxValue(const Value& value, ITypeDescriptor* typeDescriptor, const WString& valueName) + { + if (value.IsNull()) return nullptr; + Ptr result; + if(value.GetValueType()==Value::RawPtr || value.GetValueType()==Value::SharedPtr) + { + result = value.GetRawPtr()->SafeAggregationCast(); + } + if(!result) + { +#ifndef VCZH_DEBUG_NO_REFLECTION + if(!typeDescriptor) + { + typeDescriptor=GetTypeDescriptor(); + } + throw ArgumentTypeMismtatchException(valueName, typeDescriptor, Value::SharedPtr, value); +#else + CHECK_FAIL(L"vl::reflection::description::UnboxValue()#Argument type mismatch."); +#endif + } + return result; + } + }; + + template + struct ValueAccessor, ITypeInfo::Nullable> + { + static Value BoxValue(Nullable object, ITypeDescriptor* typeDescriptor) + { + return object?ValueAccessor::BoxValue(object.Value(), typeDescriptor):Value(); + } + + static Nullable UnboxValue(const Value& value, ITypeDescriptor* typeDescriptor, const WString& valueName) + { + if(value.IsNull()) + { + return Nullable(); + } + else + { + return ValueAccessor::UnboxValue(value, typeDescriptor, valueName); + } + } + }; + + template + struct ValueAccessor + { + static Value BoxValue(const T& object, ITypeDescriptor* typeDescriptor) + { +#ifndef VCZH_DEBUG_NO_REFLECTION + if(!typeDescriptor) + { + typeDescriptor = GetTypeDescriptor::Type>(); + } +#endif + using Type = typename vl::RemoveCVR::Type; + return Value::From(new IValueType::TypedBox(object), typeDescriptor); + } + + static T UnboxValue(const Value& value, ITypeDescriptor* typeDescriptor, const WString& valueName) + { + using Type = typename vl::RemoveCVR::Type; + if (auto unboxedValue = value.GetBoxedValue().Cast>()) + { + return unboxedValue->value; + } + else + { +#ifndef VCZH_DEBUG_NO_REFLECTION + if (!typeDescriptor) + { + typeDescriptor = GetTypeDescriptor::Type>(); + } + throw ArgumentTypeMismtatchException(valueName, typeDescriptor, Value::BoxedValue, value); +#else + CHECK_FAIL(L"vl::reflection::description::UnboxValue()#Argument type mismatch."); +#endif + } + } + }; + + template<> + struct ValueAccessor + { + static Value BoxValue(const Value& object, ITypeDescriptor* typeDescriptor) + { + return object; + } + + static Value UnboxValue(const Value& value, ITypeDescriptor* typeDescriptor, const WString& valueName) + { + return value; + } + }; + + template<> + struct ValueAccessor + { + static Value BoxValue(const VoidValue& object, ITypeDescriptor* typeDescriptor) + { + return Value(); + } + + static VoidValue UnboxValue(const Value& value, ITypeDescriptor* typeDescriptor, const WString& valueName) + { + return VoidValue(); + } + }; + } + } +} + +#endif + +/*********************************************************************** +.\REFLECTION\GUITYPEDESCRIPTORCPPHELPER.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -13830,7 +12829,7 @@ namespace vl #endif /*********************************************************************** -REFLECTION\GUITYPEDESCRIPTORBUILDER_FUNCTION.H +.\REFLECTION\GUITYPEDESCRIPTORBUILDER_FUNCTION.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -14440,342 +13439,7 @@ CustomEventInfoImpl #endif /*********************************************************************** -REFLECTION\GUITYPEDESCRIPTORBUILDER_STRUCT.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Framework::Reflection - -Interfaces: -***********************************************************************/ - -#ifndef VCZH_REFLECTION_GUITYPEDESCRIPTORBUILDER_STRUCT -#define VCZH_REFLECTION_GUITYPEDESCRIPTORBUILDER_STRUCT - - -namespace vl -{ - namespace reflection - { - namespace description - { - -/*********************************************************************** -DetailTypeInfoRetriver -***********************************************************************/ - - template - struct DetailTypeInfoRetriver - { - static const ITypeInfo::Decorator Decorator=ITypeInfo::TypeDescriptor; - typedef T Type; - typedef T TempValueType; - typedef T& ResultReferenceType; - typedef T ResultNonReferenceType; - -#ifndef VCZH_DEBUG_NO_REFLECTION - static Ptr CreateTypeInfo(TypeInfoHint hint) - { - return MakePtr(GetTypeDescriptor(), hint); - } -#endif - }; - - template - struct DetailTypeInfoRetriver - { - typedef DetailTypeInfoRetriver UpLevelRetriver; - - static const ITypeInfo::Decorator Decorator=UpLevelRetriver::Decorator; - typedef typename UpLevelRetriver::Type Type; - typedef T TempValueType; - typedef const T& ResultReferenceType; - typedef const T ResultNonReferenceType; - -#ifndef VCZH_DEBUG_NO_REFLECTION - static Ptr CreateTypeInfo(TypeInfoHint hint) - { - return TypeInfoRetriver::CreateTypeInfo(); - } -#endif - }; - - template - struct DetailTypeInfoRetriver - { - typedef DetailTypeInfoRetriver UpLevelRetriver; - - static const ITypeInfo::Decorator Decorator=UpLevelRetriver::Decorator; - typedef typename UpLevelRetriver::Type Type; - typedef T TempValueType; - typedef T& ResultReferenceType; - typedef T ResultNonReferenceType; - -#ifndef VCZH_DEBUG_NO_REFLECTION - static Ptr CreateTypeInfo(TypeInfoHint hint) - { - return TypeInfoRetriver::CreateTypeInfo(); - } -#endif - }; - - template - struct DetailTypeInfoRetriver - { - typedef DetailTypeInfoRetriver UpLevelRetriver; - - static const ITypeInfo::Decorator Decorator=ITypeInfo::RawPtr; - typedef typename UpLevelRetriver::Type Type; - typedef T* TempValueType; - typedef T*& ResultReferenceType; - typedef T* ResultNonReferenceType; - -#ifndef VCZH_DEBUG_NO_REFLECTION - static Ptr CreateTypeInfo(TypeInfoHint hint) - { - return MakePtr(TypeInfoRetriver::CreateTypeInfo()); - } -#endif - }; - - template - struct DetailTypeInfoRetriver, TypeFlags::NonGenericType> - { - typedef DetailTypeInfoRetriver UpLevelRetriver; - - static const ITypeInfo::Decorator Decorator=ITypeInfo::SharedPtr; - typedef typename UpLevelRetriver::Type Type; - typedef Ptr TempValueType; - typedef Ptr& ResultReferenceType; - typedef Ptr ResultNonReferenceType; - -#ifndef VCZH_DEBUG_NO_REFLECTION - static Ptr CreateTypeInfo(TypeInfoHint hint) - { - return MakePtr(TypeInfoRetriver::CreateTypeInfo()); - } -#endif - }; - - template - struct DetailTypeInfoRetriver, TypeFlags::NonGenericType> - { - typedef DetailTypeInfoRetriver UpLevelRetriver; - - static const ITypeInfo::Decorator Decorator=ITypeInfo::Nullable; - typedef typename UpLevelRetriver::Type Type; - typedef Nullable TempValueType; - typedef Nullable& ResultReferenceType; - typedef Nullable ResultNonReferenceType; - -#ifndef VCZH_DEBUG_NO_REFLECTION - static Ptr CreateTypeInfo(TypeInfoHint hint) - { - return MakePtr(TypeInfoRetriver::CreateTypeInfo()); - } -#endif - }; - - template - struct DetailTypeInfoRetriver - { - typedef DetailTypeInfoRetriver UpLevelRetriver; - - static const ITypeInfo::Decorator Decorator=UpLevelRetriver::Decorator; - typedef typename UpLevelRetriver::Type Type; - typedef typename UpLevelRetriver::TempValueType TempValueType; - typedef T& ResultReferenceType; - typedef T ResultNonReferenceType; - -#ifndef VCZH_DEBUG_NO_REFLECTION - static Ptr CreateTypeInfo(TypeInfoHint hint) - { - return TypeInfoRetriver::CreateTypeInfo(); - } -#endif - }; - - template<> - struct TypeInfoRetriver : public TypeInfoRetriver - { - }; - -/*********************************************************************** -ParameterAccessor -***********************************************************************/ - - template - struct ParameterAccessor - { - static Value BoxParameter(const T& object, ITypeDescriptor* typeDescriptor) - { - return BoxValue(object, typeDescriptor); - } - - static void UnboxParameter(const Value& value, T& result, ITypeDescriptor* typeDescriptor, const WString& valueName) - { - result=UnboxValue(value, typeDescriptor, valueName); - } - }; - - template - struct ValueAccessor - { - static Value BoxValue(T* object, ITypeDescriptor* typeDescriptor) - { - return Value::From(object); - } - - static T* UnboxValue(const Value& value, ITypeDescriptor* typeDescriptor, const WString& valueName) - { - if(value.IsNull()) return nullptr; - T* result = nullptr; - if (value.GetRawPtr()) - { - result = value.GetRawPtr()->SafeAggregationCast(); - } - if(!result) - { -#ifndef VCZH_DEBUG_NO_REFLECTION - if(!typeDescriptor) - { - typeDescriptor=GetTypeDescriptor(); - } - throw ArgumentTypeMismtatchException(valueName, typeDescriptor, Value::RawPtr, value); -#else - CHECK_FAIL(L"vl::reflection::description::UnboxValue()#Argument type mismatch."); -#endif - } - return result; - } - }; - - template - struct ValueAccessor, ITypeInfo::SharedPtr> - { - static Value BoxValue(Ptr object, ITypeDescriptor* typeDescriptor) - { - return Value::From(object); - } - - static Ptr UnboxValue(const Value& value, ITypeDescriptor* typeDescriptor, const WString& valueName) - { - if (value.IsNull()) return nullptr; - Ptr result; - if(value.GetValueType()==Value::RawPtr || value.GetValueType()==Value::SharedPtr) - { - result = value.GetRawPtr()->SafeAggregationCast(); - } - if(!result) - { -#ifndef VCZH_DEBUG_NO_REFLECTION - if(!typeDescriptor) - { - typeDescriptor=GetTypeDescriptor(); - } - throw ArgumentTypeMismtatchException(valueName, typeDescriptor, Value::SharedPtr, value); -#else - CHECK_FAIL(L"vl::reflection::description::UnboxValue()#Argument type mismatch."); -#endif - } - return result; - } - }; - - template - struct ValueAccessor, ITypeInfo::Nullable> - { - static Value BoxValue(Nullable object, ITypeDescriptor* typeDescriptor) - { - return object?ValueAccessor::BoxValue(object.Value(), typeDescriptor):Value(); - } - - static Nullable UnboxValue(const Value& value, ITypeDescriptor* typeDescriptor, const WString& valueName) - { - if(value.IsNull()) - { - return Nullable(); - } - else - { - return ValueAccessor::UnboxValue(value, typeDescriptor, valueName); - } - } - }; - - template - struct ValueAccessor - { - static Value BoxValue(const T& object, ITypeDescriptor* typeDescriptor) - { -#ifndef VCZH_DEBUG_NO_REFLECTION - if(!typeDescriptor) - { - typeDescriptor = GetTypeDescriptor::Type>(); - } -#endif - using Type = typename vl::RemoveCVR::Type; - return Value::From(new IValueType::TypedBox(object), typeDescriptor); - } - - static T UnboxValue(const Value& value, ITypeDescriptor* typeDescriptor, const WString& valueName) - { - using Type = typename vl::RemoveCVR::Type; - if (auto unboxedValue = value.GetBoxedValue().Cast>()) - { - return unboxedValue->value; - } - else - { -#ifndef VCZH_DEBUG_NO_REFLECTION - if (!typeDescriptor) - { - typeDescriptor = GetTypeDescriptor::Type>(); - } - throw ArgumentTypeMismtatchException(valueName, typeDescriptor, Value::BoxedValue, value); -#else - CHECK_FAIL(L"vl::reflection::description::UnboxValue()#Argument type mismatch."); -#endif - } - } - }; - - template<> - struct ValueAccessor - { - static Value BoxValue(const Value& object, ITypeDescriptor* typeDescriptor) - { - return object; - } - - static Value UnboxValue(const Value& value, ITypeDescriptor* typeDescriptor, const WString& valueName) - { - return value; - } - }; - - template<> - struct ValueAccessor - { - static Value BoxValue(const VoidValue& object, ITypeDescriptor* typeDescriptor) - { - return Value(); - } - - static VoidValue UnboxValue(const Value& value, ITypeDescriptor* typeDescriptor, const WString& valueName) - { - return VoidValue(); - } - }; - } - } -} - -#endif - -/*********************************************************************** -REFLECTION\GUITYPEDESCRIPTORMACROS.H +.\REFLECTION\GUITYPEDESCRIPTORMACROS.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -15352,8 +14016,9 @@ Property #endif #endif + /*********************************************************************** -REFLECTION\GUITYPEDESCRIPTORREFLECTION.H +.\REFLECTION\GUITYPEDESCRIPTORREFLECTION.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -15663,8 +14328,1920 @@ LoadPredefinedTypes #endif + /*********************************************************************** -PARSING\PARSINGDEFINITIONS.H +.\STREAM\BROADCASTSTREAM.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Stream::BroadcastStream + +Interfaces: + BroadcastStream :广播流 +***********************************************************************/ + +#ifndef VCZH_STREAM_BROADCASTSTREAM +#define VCZH_STREAM_BROADCASTSTREAM + + +namespace vl +{ + namespace stream + { + /// A writable stream that copy written content to multiple target streams. + class BroadcastStream : public Object, public virtual IStream + { + typedef collections::List StreamList; + protected: + bool closed; + pos_t position; + StreamList streams; + public: + /// Create a strema. + BroadcastStream(); + ~BroadcastStream(); + + /// Get the list of target streams. You can add streams to this list, or remove streams from this list. + /// The list of target streams. + StreamList& Targets(); + bool CanRead()const; + bool CanWrite()const; + bool CanSeek()const; + bool CanPeek()const; + bool IsLimited()const; + bool IsAvailable()const; + void Close(); + pos_t Position()const; + pos_t Size()const; + void Seek(pos_t _size); + void SeekFromBegin(pos_t _size); + void SeekFromEnd(pos_t _size); + vint Read(void* _buffer, vint _size); + vint Write(void* _buffer, vint _size); + vint Peek(void* _buffer, vint _size); + }; + } +} + +#endif + +/*********************************************************************** +.\STREAM\CACHESTREAM.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Stream::CacheStream + +Interfaces: + CacheStream :缓冲流 +***********************************************************************/ + +#ifndef VCZH_STREAM_CACHESTREAM +#define VCZH_STREAM_CACHESTREAM + + +namespace vl +{ + namespace stream + { + /// + /// A cache stream. Features (readable, writable, seekable, peekable) are enabled according to the target stream. + /// When you read from the cache strema, it will read a specified size of content from the target stream first and cache, reducing the numbers of operations on the target stream. + /// When you write to the cache strema, it will save them to a buffer, and write to the target stream until the buffer reaches a specified size, reducing the numbers of operations on the target stream. + /// + class CacheStream : public Object, public virtual IStream + { + protected: + IStream* target; + vint block; + pos_t start; + pos_t position; + + char* buffer; + vint dirtyStart; + vint dirtyLength; + vint availableLength; + pos_t operatedSize; + + void Flush(); + void Load(pos_t _position); + vint InternalRead(void* _buffer, vint _size); + vint InternalWrite(void* _buffer, vint _size); + public: + /// Create a cache stream using a target stream. + /// The target stream. + /// Size of the cache. + CacheStream(IStream& _target, vint _block=65536); + ~CacheStream(); + + bool CanRead()const; + bool CanWrite()const; + bool CanSeek()const; + bool CanPeek()const; + bool IsLimited()const; + bool IsAvailable()const; + void Close(); + pos_t Position()const; + pos_t Size()const; + void Seek(pos_t _size); + void SeekFromBegin(pos_t _size); + void SeekFromEnd(pos_t _size); + vint Read(void* _buffer, vint _size); + vint Write(void* _buffer, vint _size); + vint Peek(void* _buffer, vint _size); + }; + } +} + +#endif + +/*********************************************************************** +.\STREAM\COMPRESSIONSTREAM.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Stream::CharFormat + +Classes: +***********************************************************************/ + +#ifndef VCZH_STREAM_COMPRESSIONSTREAM +#define VCZH_STREAM_COMPRESSIONSTREAM + + +namespace vl +{ + namespace stream + { + +/*********************************************************************** +Compression +***********************************************************************/ + + namespace lzw + { + static const vint BufferSize = 1024; + static const vint MaxDictionarySize = 1 << 24; + + struct Code + { + typedef collections::PushOnlyAllocator CodeAllocator; + typedef collections::ByteObjectMap::Allocator MapAllocator; + + vuint8_t byte = 0; + vint code = -1; + Code* parent = 0; + vint size = 0; + collections::ByteObjectMap children; + }; + } + + class LzwBase : public Object + { + protected: + lzw::Code::CodeAllocator codeAllocator; + lzw::Code::MapAllocator mapAllocator; + lzw::Code* root; + vint eofIndex = -1; + vint nextIndex = 0; + vint indexBits = 1; + + void UpdateIndexBits(); + lzw::Code* CreateCode(lzw::Code* parent, vuint8_t byte); + + LzwBase(); + LzwBase(bool (&existingBytes)[256]); + ~LzwBase(); + }; + + /// An encoder to compress using Lzw algorithm. + class LzwEncoder : public LzwBase, public IEncoder + { + protected: + IStream* stream = 0; + + vuint8_t buffer[lzw::BufferSize]; + vint bufferUsedBits = 0; + lzw::Code* prefix; + + void Flush(); + void WriteNumber(vint number, vint bitSize); + public: + /// Create an encoder. + LzwEncoder(); + /// Create an encoder and tell it which byte will never appear in the data before compression. + /// An array to tell the encoder which byte will never appear in the data before compression. + LzwEncoder(bool (&existingBytes)[256]); + ~LzwEncoder(); + + void Setup(IStream* _stream)override; + void Close()override; + vint Write(void* _buffer, vint _size)override; + }; + + /// An decoder to decompress using Lzw algorithm. + class LzwDecoder :public LzwBase, public IDecoder + { + protected: + IStream* stream = 0; + collections::List dictionary; + lzw::Code* lastCode = 0; + + vuint8_t inputBuffer[lzw::BufferSize]; + vint inputBufferSize = 0; + vint inputBufferUsedBits = 0; + + collections::Array outputBuffer; + vint outputBufferSize = 0; + vint outputBufferUsedBytes = 0; + + bool ReadNumber(vint& number, vint bitSize); + void PrepareOutputBuffer(vint size); + void ExpandCodeToOutputBuffer(lzw::Code* code); + public: + /// Create an decoder. + LzwDecoder(); + /// Create an decoder and tell it which byte will never appear in the data before compression. + /// An array to tell the encoder which byte will never appear in the data before compression. + LzwDecoder(bool (&existingBytes)[256]); + ~LzwDecoder(); + + void Setup(IStream* _stream)override; + void Close()override; + vint Read(void* _buffer, vint _size)override; + }; + } +} + +#endif + +/*********************************************************************** +.\STREAM\FILESTREAM.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Stream::FileStream + +Interfaces: + FileStream :文件流 +***********************************************************************/ + +#ifndef VCZH_STREAM_FILESTREAM +#define VCZH_STREAM_FILESTREAM + +#include + +namespace vl +{ + namespace stream + { + /// A file stream. It is readable when you use [F:vl.stream.FileStream.AccessRight.ReadOnly] or [F:vl.stream.FileStream.AccessRight.ReadWrite] to create the stream. It is writable when you use [F:vl.stream.FileStream.AccessRight.WriteOnly] or [F:vl.stream.FileStream.AccessRight.ReadWrite] to create the stream. + class FileStream : public Object, public virtual IStream + { + public: + /// Access to the file. + enum AccessRight + { + /// The file is opened to read. + ReadOnly, + /// The file is opened to write. + WriteOnly, + /// The file is opened to both read and write. + ReadWrite + }; + protected: + AccessRight accessRight; + FILE* file; + public: + /// Create a stream. + /// File to operate. + /// Operations want to perform on the file. + FileStream(const WString& fileName, AccessRight _accessRight); + ~FileStream(); + + bool CanRead()const; + bool CanWrite()const; + bool CanSeek()const; + bool CanPeek()const; + bool IsLimited()const; + bool IsAvailable()const; + void Close(); + pos_t Position()const; + pos_t Size()const; + void Seek(pos_t _size); + void SeekFromBegin(pos_t _size); + void SeekFromEnd(pos_t _size); + vint Read(void* _buffer, vint _size); + vint Write(void* _buffer, vint _size); + vint Peek(void* _buffer, vint _size); + }; + } +} + +#endif + +/*********************************************************************** +.\STREAM\MEMORYSTREAM.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Stream::MemoryStream + +Interfaces: + MemoryStream :内存流 +***********************************************************************/ + +#ifndef VCZH_STREAM_MEMORYSTREAM +#define VCZH_STREAM_MEMORYSTREAM + + +namespace vl +{ + namespace stream + { + /// A readable, writable, seekable and peekable stream that stores everything in memory. + class MemoryStream : public Object, public virtual IStream + { + protected: + vint block; + char* buffer; + vint size; + vint position; + vint capacity; + + void PrepareSpace(vint totalSpace); + public: + /// Create a stream. + /// Size for each allocation. The stream will only allocate new memory of size "_block" when it reaches the end and has to extend. + MemoryStream(vint _block=65536); + ~MemoryStream(); + + bool CanRead()const; + bool CanWrite()const; + bool CanSeek()const; + bool CanPeek()const; + bool IsLimited()const; + bool IsAvailable()const; + void Close(); + pos_t Position()const; + pos_t Size()const; + void Seek(pos_t _size); + void SeekFromBegin(pos_t _size); + void SeekFromEnd(pos_t _size); + vint Read(void* _buffer, vint _size); + vint Write(void* _buffer, vint _size); + vint Peek(void* _buffer, vint _size); + void* GetInternalBuffer(); + }; + } +} + +#endif + +/*********************************************************************** +.\STREAM\MEMORYWRAPPERSTREAM.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Stream::MemoryWrapperStream + +Interfaces: + MemoryWrapperStream :内存代理流 +***********************************************************************/ + +#ifndef VCZH_STREAM_MEMORYWRAPPERSTREAM +#define VCZH_STREAM_MEMORYWRAPPERSTREAM + + +namespace vl +{ + namespace stream + { + /// A readable, writable, seekable and peekable stream that operates a buffer. + class MemoryWrapperStream : public Object, public virtual IStream + { + protected: + char* buffer; + vint size; + vint position; + public: + /// Create a stream. + /// The buffer to operate. + /// Size of the buffer. + MemoryWrapperStream(void* _buffer, vint _size); + ~MemoryWrapperStream(); + + bool CanRead()const; + bool CanWrite()const; + bool CanSeek()const; + bool CanPeek()const; + bool IsLimited()const; + bool IsAvailable()const; + void Close(); + pos_t Position()const; + pos_t Size()const; + void Seek(pos_t _size); + void SeekFromBegin(pos_t _size); + void SeekFromEnd(pos_t _size); + vint Read(void* _buffer, vint _size); + vint Write(void* _buffer, vint _size); + vint Peek(void* _buffer, vint _size); + }; + } +} + +#endif + +/*********************************************************************** +.\STREAM\CHARFORMAT.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Stream::CharFormat + +Classes: + CharEncoder :字符串编码器基类 + CharDecoder :字符串解码器基类 + MbcsEncoder :Mbcs编码器 + MbcsDecoder :Mbcs解码器 + Utf16Encoder :Utf16编码器 + Utf16Decoder :Utf16解码器 + Utf16BEEncoder :Utf16 Big Endian编码器 + Utf16BEDecoder :Utf16 Big Endian解码器 + Utf8Encoder :Utf8编码器 + Utf8Decoder :Utf8解码器 + BomEncoder :BOM相关编码器 + BomDecoder :BOM相关解码器 +***********************************************************************/ + +#ifndef VCZH_STREAM_CHARFORMAT +#define VCZH_STREAM_CHARFORMAT + + +namespace vl +{ + namespace stream + { + + /*编码资料 + UCS-4和UTF-8的对应关系: + U-00000000 - U-0000007F: 0xxxxxxx + U-00000080 - U-000007FF: 110xxxxx 10xxxxxx + U-00000800 - U-0000FFFF: 1110xxxx 10xxxxxx 10xxxxxx + U-00010000 - U-001FFFFF: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx + U-00200000 - U-03FFFFFF: 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx + U-04000000 - U-7FFFFFFF: 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx + BOM: + FFFE =Unicode (vceUtf16) + FEFF =Unicode Big Endian (vceUtf16_be) + EFBBBF =UTF-8 (vceUtf8) + other =MBCS(GBK) (vceMbcs) + */ + +/*********************************************************************** +字符串编码解码基类 +***********************************************************************/ + + /// Base type of all character encoder. + class CharEncoder : public Object, public IEncoder + { + protected: + IStream* stream; + vuint8_t cacheBuffer[sizeof(wchar_t)]; + vint cacheSize; + + virtual vint WriteString(wchar_t* _buffer, vint chars)=0; + public: + CharEncoder(); + + void Setup(IStream* _stream); + void Close(); + vint Write(void* _buffer, vint _size); + }; + + /// Base type of all character decoder. + class CharDecoder : public Object, public IDecoder + { + protected: + IStream* stream; + vuint8_t cacheBuffer[sizeof(wchar_t)]; + vint cacheSize; + + virtual vint ReadString(wchar_t* _buffer, vint chars)=0; + public: + CharDecoder(); + + void Setup(IStream* _stream); + void Close(); + vint Read(void* _buffer, vint _size); + }; + +/*********************************************************************** +Mbcs +***********************************************************************/ + + /// Encoder to transform text in a local code page from wchar_t. + class MbcsEncoder : public CharEncoder + { + protected: + vint WriteString(wchar_t* _buffer, vint chars); + }; + + /// Encoder to transform text in a local code page to wchar_t. + class MbcsDecoder : public CharDecoder + { + protected: + vint ReadString(wchar_t* _buffer, vint chars); + }; + +/*********************************************************************** +Utf-16 +***********************************************************************/ + + /// Encoder to transform UTF-16 text from wchar_t. + class Utf16Encoder : public CharEncoder + { + protected: + vint WriteString(wchar_t* _buffer, vint chars); + }; + + /// Decoder to transform UTF-16 text to wchar_t. + class Utf16Decoder : public CharDecoder + { + protected: + vint ReadString(wchar_t* _buffer, vint chars); + }; + +/*********************************************************************** +Utf-16-be +***********************************************************************/ + + /// Encoder to transform big endian UTF-16 text from wchar_t. + class Utf16BEEncoder : public CharEncoder + { + protected: + vint WriteString(wchar_t* _buffer, vint chars); + }; + + /// Decoder to transform big endian UTF-16 text to wchar_t. + class Utf16BEDecoder : public CharDecoder + { + protected: + vint ReadString(wchar_t* _buffer, vint chars); + }; + +/*********************************************************************** +Utf-8 +***********************************************************************/ + + /// Encoder to transform UTF-8 text from wchar_t. + class Utf8Encoder : public CharEncoder + { + protected: + vint WriteString(wchar_t* _buffer, vint chars); + }; + + /// Decoder to transform UTF-8 text to wchar_t. + class Utf8Decoder : public CharDecoder + { + protected: +#if defined VCZH_MSVC + wchar_t cache; + bool cacheAvailable; +#endif + vint ReadString(wchar_t* _buffer, vint chars); + public: + Utf8Decoder(); + }; + +/*********************************************************************** +Bom +***********************************************************************/ + + /// Encoder to transform text from wchar_t. A BOM will be added at the beginning. + class BomEncoder : public Object, public IEncoder + { + public: + /// Text encoding. + enum Encoding + { + /// Multi-bytes character string. + Mbcs, + /// UTF-8. + Utf8, + /// UTF-16. + Utf16, + /// Big endian UTF-16. + Utf16BE + }; + protected: + Encoding encoding; + IEncoder* encoder; + public: + /// Create an encoder. + /// Specified encoding. + BomEncoder(Encoding _encoding); + ~BomEncoder(); + + void Setup(IStream* _stream); + void Close(); + vint Write(void* _buffer, vint _size); + }; + + /// Decoder to transform text to wchar_t. This decoder depends on the BOM information at the beginning to decide the format of the input. + class BomDecoder : public Object, public IDecoder + { + private: + class BomStream : public Object, public IStream + { + protected: + IStream* stream; + char bom[3]; + vint bomLength; + vint bomPosition; + public: + BomStream(IStream* _stream, char* _bom, vint _bomLength); + + bool CanRead()const; + bool CanWrite()const; + bool CanSeek()const; + bool CanPeek()const; + bool IsLimited()const; + bool IsAvailable()const; + void Close(); + pos_t Position()const; + pos_t Size()const; + void Seek(pos_t _size); + void SeekFromBegin(pos_t _size); + void SeekFromEnd(pos_t _size); + vint Read(void* _buffer, vint _size); + vint Write(void* _buffer, vint _size); + vint Peek(void* _buffer, vint _size); + }; + protected: + IDecoder* decoder; + IStream* stream; + + public: + /// Create an decoder. + BomDecoder(); + ~BomDecoder(); + + void Setup(IStream* _stream); + void Close(); + vint Read(void* _buffer, vint _size); + }; + +/*********************************************************************** +Encoding Test +***********************************************************************/ + + /// Guess the text encoding in a buffer. + /// The buffer to guess. + /// Size of the buffer in bytes. + /// Returns the most possible encoding. + /// Returns true if the BOM information is at the beginning of the buffer. + extern void TestEncoding(unsigned char* buffer, vint size, BomEncoder::Encoding& encoding, bool& containsBom); + +/*********************************************************************** +Serialization +***********************************************************************/ + + namespace internal + { + template + struct Reader + { + stream::IStream& input; + T context; + + Reader(stream::IStream& _input) + :input(_input) + , context(nullptr) + { + } + }; + + template + struct Writer + { + stream::IStream& output; + T context; + + Writer(stream::IStream& _output) + :output(_output) + , context(nullptr) + { + } + }; + + using ContextFreeReader = Reader; + using ContextFreeWriter = Writer; + + template + struct Serialization + { + template + static void IO(TIO& io, T& value); + }; + + template + Reader& operator<<(Reader& reader, TValue& value) + { + Serialization::IO(reader, value); + return reader; + } + + template + Writer& operator<<(Writer& writer, TValue& value) + { + Serialization::IO(writer, value); + return writer; + } + + //--------------------------------------------- + + template<> + struct Serialization + { + template + static void IO(Reader& reader, vint64_t& value) + { + if (reader.input.Read(&value, sizeof(value)) != sizeof(value)) + { + CHECK_FAIL(L"Deserialization failed."); + } + } + + template + static void IO(Writer& writer, vint64_t& value) + { + if (writer.output.Write(&value, sizeof(value)) != sizeof(value)) + { + CHECK_FAIL(L"Serialization failed."); + } + } + }; + + template<> + struct Serialization + { + template + static void IO(Reader& reader, vint32_t& value) + { + vint64_t v = 0; + Serialization::IO(reader, v); + value = (vint32_t)v; + } + + template + static void IO(Writer& writer, vint32_t& value) + { + vint64_t v = (vint64_t)value; + Serialization::IO(writer, v); + } + }; + + template<> + struct Serialization + { + template + static void IO(Reader& reader, bool& value) + { + vint8_t v = 0; + if (reader.input.Read(&v, sizeof(v)) != sizeof(v)) + { + CHECK_FAIL(L"Deserialization failed."); + } + else + { + value = v == -1; + } + } + + template + static void IO(Writer& writer, bool& value) + { + vint8_t v = value ? -1 : 0; + if (writer.output.Write(&v, sizeof(v)) != sizeof(v)) + { + CHECK_FAIL(L"Serialization failed."); + } + } + }; + + template + struct Serialization> + { + template + static void IO(Reader& reader, Ptr& value) + { + bool notNull = false; + reader << notNull; + if (notNull) + { + value = new T; + Serialization::IO(reader, *value.Obj()); + } + else + { + value = 0; + } + } + + template + static void IO(Writer& writer, Ptr& value) + { + bool notNull = value; + writer << notNull; + if (notNull) + { + Serialization::IO(writer, *value.Obj()); + } + } + }; + + template + struct Serialization> + { + template + static void IO(Reader& reader, Nullable& value) + { + bool notNull = false; + reader << notNull; + if (notNull) + { + T data; + Serialization::IO(reader, data); + value = Nullable(data); + } + else + { + value = Nullable(); + } + } + + template + static void IO(Writer& writer, Nullable& value) + { + bool notNull = value; + writer << notNull; + if (notNull) + { + T data = value.Value(); + Serialization::IO(writer, data); + } + } + }; + + template<> + struct Serialization + { + template + static void IO(Reader& reader, WString& value) + { + vint count = -1; + reader << count; + if (count > 0) + { + MemoryStream stream; + reader << (IStream&)stream; + Utf8Decoder decoder; + decoder.Setup(&stream); + + collections::Array stringBuffer(count + 1); + vint stringSize = decoder.Read(&stringBuffer[0], count * sizeof(wchar_t)); + stringBuffer[stringSize / sizeof(wchar_t)] = 0; + + value = &stringBuffer[0]; + } + else + { + value = L""; + } + } + + template + static void IO(Writer& writer, WString& value) + { + vint count = value.Length(); + writer << count; + if (count > 0) + { + MemoryStream stream; + { + Utf8Encoder encoder; + encoder.Setup(&stream); + encoder.Write((void*)value.Buffer(), count * sizeof(wchar_t)); + } + writer << (IStream&)stream; + } + } + }; + + template + struct Serialization> + { + template + static void IO(Reader& reader, collections::List& value) + { + vint32_t count = -1; + reader << count; + value.Clear(); + for (vint i = 0; i < count; i++) + { + T t; + reader << t; + value.Add(t); + } + } + + template + static void IO(Writer& writer, collections::List& value) + { + vint32_t count = (vint32_t)value.Count(); + writer << count; + for (vint i = 0; i < count; i++) + { + writer << value[i]; + } + } + }; + + template + struct Serialization> + { + template + static void IO(Reader& reader, collections::Array& value) + { + vint32_t count = -1; + reader << count; + value.Resize(count); + for (vint i = 0; i < count; i++) + { + reader << value[i]; + } + } + + template + static void IO(Writer& writer, collections::Array& value) + { + vint32_t count = (vint32_t)value.Count(); + writer << count; + for (vint i = 0; i < count; i++) + { + writer << value[i]; + } + } + }; + + template + struct Serialization> + { + template + static void IO(Reader& reader, collections::Dictionary& value) + { + vint32_t count = -1; + reader << count; + value.Clear(); + for (vint i = 0; i < count; i++) + { + K k; + V v; + reader << k << v; + value.Add(k, v); + } + } + + template + static void IO(Writer& writer, collections::Dictionary& value) + { + vint32_t count = (vint32_t)value.Count(); + writer << count; + for (vint i = 0; i < count; i++) + { + K k = value.Keys()[i]; + V v = value.Values()[i]; + writer << k << v; + } + } + }; + + template + struct Serialization> + { + template + static void IO(Reader& reader, collections::Group& value) + { + vint32_t count = -1; + reader << count; + value.Clear(); + for (vint i = 0; i < count; i++) + { + K k; + collections::List v; + reader << k << v; + for (vint j = 0; j < v.Count(); j++) + { + value.Add(k, v[j]); + } + } + } + + template + static void IO(Writer& writer, collections::Group& value) + { + vint32_t count = (vint32_t)value.Count(); + writer << count; + for (vint i = 0; i < count; i++) + { + K k = value.Keys()[i]; + collections::List& v = const_cast&>(value.GetByIndex(i)); + writer << k << v; + } + } + }; + + template<> + struct Serialization + { + template + static void IO(Reader& reader, stream::IStream& value) + { + vint32_t count = 0; + reader.input.Read(&count, sizeof(count)); + + if (count > 0) + { + vint length = 0; + collections::Array buffer(count); + value.SeekFromBegin(0); + length = reader.input.Read(&buffer[0], count); + if (length != count) + { + CHECK_FAIL(L"Deserialization failed."); + } + length = value.Write(&buffer[0], count); + if (length != count) + { + CHECK_FAIL(L"Deserialization failed."); + } + value.SeekFromBegin(0); + } + } + + template + static void IO(Writer& writer, stream::IStream& value) + { + vint32_t count = (vint32_t)value.Size(); + writer.output.Write(&count, sizeof(count)); + + if (count > 0) + { + vint length = 0; + collections::Array buffer(count); + value.SeekFromBegin(0); + length = value.Read(&buffer[0], count); + if (length != count) + { + CHECK_FAIL(L"Serialization failed."); + } + length = writer.output.Write(&buffer[0], count); + if (length != count) + { + CHECK_FAIL(L"Serialization failed."); + } + value.SeekFromBegin(0); + } + } + }; + + //--------------------------------------------- + +#define BEGIN_SERIALIZATION(TYPE)\ + template<>\ + struct Serialization\ + {\ + template\ + static void IO(TIO& op, TYPE& value)\ + {\ + op\ + +#define SERIALIZE(FIELD)\ + << value.FIELD\ + +#define END_SERIALIZATION\ + ;\ + }\ + };\ + +#define SERIALIZE_ENUM(TYPE)\ + template<>\ + struct Serialization\ + {\ + template\ + static void IO(Reader& reader, TYPE& value)\ + {\ + vint32_t v = 0;\ + Serialization::IO(reader, v);\ + value = (TYPE)v;\ + }\ + template\ + static void IO(Writer& writer, TYPE& value)\ + {\ + vint32_t v = (vint32_t)value;\ + Serialization::IO(writer, v);\ + }\ + };\ + + } + } +} + +#endif + + +/*********************************************************************** +.\FILESYSTEM.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Framework::FileSystem + +***********************************************************************/ + +#ifndef VCZH_FILESYSTEM +#define VCZH_FILESYSTEM + + +namespace vl +{ + namespace filesystem + { + /// A type representing a file path. + class FilePath : public Object + { + protected: + WString fullPath; + + void Initialize(); + + static void GetPathComponents(WString path, collections::List& components); + static WString ComponentsToPath(const collections::List& components); + public: +#if defined VCZH_MSVC + static const wchar_t Delimiter = L'\\'; +#elif defined VCZH_GCC + static const wchar_t Delimiter = L'/'; +#endif + + /// Create a root path. + FilePath(); + /// Create a file path. + /// Content of the file path. If it is a relative path, it will be converted to an absolute path. + FilePath(const WString& _filePath); + /// Create a file path. + /// Content of the file path. If it is a relative path, it will be converted to an absolute path. + FilePath(const wchar_t* _filePath); + /// Copy a file path. + /// The file path to copy. + FilePath(const FilePath& _filePath); + ~FilePath(); + + static vint Compare(const FilePath& a, const FilePath& b); + bool operator==(const FilePath& filePath)const{ return Compare(*this, filePath) == 0; } + bool operator!=(const FilePath& filePath)const{ return Compare(*this, filePath) != 0; } + bool operator< (const FilePath& filePath)const{ return Compare(*this, filePath) < 0; } + bool operator<=(const FilePath& filePath)const{ return Compare(*this, filePath) <= 0; } + bool operator> (const FilePath& filePath)const{ return Compare(*this, filePath) > 0; } + bool operator>=(const FilePath& filePath)const{ return Compare(*this, filePath) >= 0; } + + /// Concat an absolute path and a relative path. + /// The result absolute path. + /// The relative path to concat. + FilePath operator/(const WString& relativePath)const; + + /// Test if the file path is a file. + /// Returns true if the file path is a file. + bool IsFile()const; + /// Test if the file path is a folder. + /// Returns true if the file path is a folder. + bool IsFolder()const; + /// Test if the file path is a the root of all file system objects. + /// Returns true if the file path is the root of all file system objects. + bool IsRoot()const; + + /// Get the last piece of names in the file path. + /// The last piece of names in the file path. + WString GetName()const; + /// Get the containing folder of this file path. + /// The containing folder. + FilePath GetFolder()const; + /// Get the content of the file path. + /// The content of the file path. + WString GetFullPath()const; + /// Calculate the relative path using a referencing folder. + /// The relative path. + /// The referencing folder. + WString GetRelativePathFor(const FilePath& _filePath); + + }; + + /// Representing a file reference. + class File : public Object + { + private: + FilePath filePath; + + public: + /// Create an empty reference. + File(); + /// Create a reference to a specified file. + /// The specified file. + File(const FilePath& _filePath); + ~File(); + + /// Get the file path of the file. + /// The file path. + const FilePath& GetFilePath()const; + + /// Get the content of the file as text with encoding testing. + /// The content of the file. + /// Returns false if this operation succeeded. + /// The content of the file. + /// The encoding. + /// True if there is BOM. + bool ReadAllTextWithEncodingTesting(WString& text, stream::BomEncoder::Encoding& encoding, bool& containsBom); + /// Get the content of the file as text. + /// The content of the file. + WString ReadAllTextByBom()const; + /// Get the content of the file as text. + /// Returns false if this operation succeeded. + /// The content of the file. + bool ReadAllTextByBom(WString& text)const; + /// Get the content of the file as text. + /// Returns false if this operation succeeded. + /// The content of the file. + bool ReadAllLinesByBom(collections::List& lines)const; + + /// Write text to the file. + /// Returns false if this operation succeeded. + /// The text to write. + /// Set to true to add a corresponding BOM at the beginning of the file according to the encoding. + /// The text encoding. + bool WriteAllText(const WString& text, bool bom = true, stream::BomEncoder::Encoding encoding = stream::BomEncoder::Utf16); + /// Write text to the file. + /// Returns false if this operation succeeded. + /// The text to write. + /// Set to true to add a corresponding BOM at the beginning of the file according to the encoding. + /// The text encoding. + bool WriteAllLines(collections::List& lines, bool bom = true, stream::BomEncoder::Encoding encoding = stream::BomEncoder::Utf16); + + /// Test does the file exist or not. + /// Returns true if the file exists. + bool Exists()const; + /// Delete the file. + /// Returns true if this operation succeeded. + bool Delete()const; + /// Rename the file in the same folder. + /// Returns true if this operation succeeded. + /// The new file name. + bool Rename(const WString& newName)const; + }; + + /// Representing a folder reference. + class Folder : public Object + { + private: + FilePath filePath; + + public: + /// Create a root reference. + Folder(); + /// Create a reference to a specified folder. + /// The specified folder. + Folder(const FilePath& _filePath); + ~Folder(); + + /// Get the file path of the folder. + /// The file path. + const FilePath& GetFilePath()const; + /// Get all folders in this folder. + /// Returns true if this operation succeeded. + /// All folders. + bool GetFolders(collections::List& folders)const; + /// Get all files in this folder. + /// Returns true if this operation succeeded. + /// All files. + bool GetFiles(collections::List& files)const; + + /// Test does the folder exist or not. + /// Returns true if the folder exists. + bool Exists()const; + /// Create the folder. + /// Returns true if this operation succeeded. + /// Set to true to create all parent folders if necessary. + bool Create(bool recursively)const; + /// Delete the folder. + /// Returns true if this operation succeeded. + /// Set to true to delete everything in the folder. + bool Delete(bool recursively)const; + /// Rename the folder in the same folder. + /// Returns true if this operation succeeded. + /// The new folder name. + bool Rename(const WString& newName)const; + }; + } +} + +#endif + + +/*********************************************************************** +.\PARSING\PARSINGTREE.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Parsing::Parsing Tree + +Classes: +***********************************************************************/ + +#ifndef VCZH_PARSING_PARSINGTREE +#define VCZH_PARSING_PARSINGTREE + + +namespace vl +{ + namespace parsing + { + +/*********************************************************************** +Location +***********************************************************************/ + + /// A type representing text position. + struct ParsingTextPos + { + static const vint UnknownValue=-2; + /// Character index, begins at 0. + vint index; + /// Row number, begins at 0. + vint row; + /// Column number, begins at 0. + vint column; + + ParsingTextPos() + :index(UnknownValue) + ,row(UnknownValue) + ,column(UnknownValue) + { + } + + ParsingTextPos(vint _index) + :index(_index) + ,row(UnknownValue) + ,column(UnknownValue) + { + } + + ParsingTextPos(vint _row, vint _column) + :index(UnknownValue) + ,row(_row) + ,column(_column) + { + } + + ParsingTextPos(vint _index, vint _row, vint _column) + :index(_index) + ,row(_row) + ,column(_column) + { + } + + /// Test if this position a valid position. + /// Returns true if this position is a valid position. + bool IsInvalid()const + { + return index < 0 && row < 0 && column < 0; + } + + static vint Compare(const ParsingTextPos& a, const ParsingTextPos& b) + { + if (a.IsInvalid() && b.IsInvalid()) + { + return 0; + } + else if (a.IsInvalid()) + { + return -1; + } + else if (b.IsInvalid()) + { + return 1; + } + else if (a.index >= 0 && b.index >= 0) + { + return a.index - b.index; + } + else if (a.row >= 0 && a.column >= 0 && b.row >= 0 && b.column >= 0) + { + if (a.row == b.row) + { + return a.column - b.column; + } + else + { + return a.row - b.row; + } + } + else + { + return 0; + } + } + + bool operator==(const ParsingTextPos& pos)const{return Compare(*this, pos)==0;} + bool operator!=(const ParsingTextPos& pos)const{return Compare(*this, pos)!=0;} + bool operator<(const ParsingTextPos& pos)const{return Compare(*this, pos)<0;} + bool operator<=(const ParsingTextPos& pos)const{return Compare(*this, pos)<=0;} + bool operator>(const ParsingTextPos& pos)const{return Compare(*this, pos)>0;} + bool operator>=(const ParsingTextPos& pos)const{return Compare(*this, pos)>=0;} + }; + + /// A type representing text range. + struct ParsingTextRange + { + /// Text position for the first character. + ParsingTextPos start; + /// Text position for the last character. + ParsingTextPos end; + /// Code index, refer to [F:vl.regex.RegexToken.codeIndex] + vint codeIndex; + + ParsingTextRange() + :codeIndex(-1) + { + end.index=-1; + end.column=-1; + } + + ParsingTextRange(const ParsingTextPos& _start, const ParsingTextPos& _end, vint _codeIndex = -1) + :start(_start) + , end(_end) + , codeIndex(_codeIndex) + { + } + + ParsingTextRange(const regex::RegexToken* startToken, const regex::RegexToken* endToken) + :codeIndex(startToken->codeIndex) + { + start.index=startToken->start; + start.row=startToken->rowStart; + start.column=startToken->columnStart; + end.index=endToken->start+endToken->length-1; + end.row=endToken->rowEnd; + end.column=endToken->columnEnd; + } + + bool operator==(const ParsingTextRange& range)const{return start==range.start && end==range.end;} + bool operator!=(const ParsingTextRange& range)const{return start!=range.start || end!=range.end;} + bool Contains(const ParsingTextPos& pos)const{return start<=pos && pos<=end;} + bool Contains(const ParsingTextRange& range)const{return start<=range.start && range.end<=end;} + }; + } + + namespace stream + { + namespace internal + { + BEGIN_SERIALIZATION(parsing::ParsingTextPos) + SERIALIZE(index) + SERIALIZE(row) + SERIALIZE(column) + END_SERIALIZATION + + BEGIN_SERIALIZATION(parsing::ParsingTextRange) + SERIALIZE(start) + SERIALIZE(end) + SERIALIZE(codeIndex) + END_SERIALIZATION + } + } + + namespace parsing + { +/*********************************************************************** +General Syntax Tree +***********************************************************************/ + + class ParsingTreeNode; + class ParsingTreeToken; + class ParsingTreeObject; + class ParsingTreeArray; + + /// Abstract syntax tree. + class ParsingTreeNode : public Object, public reflection::Description + { + public: + class IVisitor : public Interface + { + public: + virtual void Visit(ParsingTreeToken* node)=0; + virtual void Visit(ParsingTreeObject* node)=0; + virtual void Visit(ParsingTreeArray* node)=0; + }; + + class TraversalVisitor : public Object, public IVisitor + { + public: + enum TraverseDirection + { + ByTextPosition, + ByStorePosition + }; + protected: + TraverseDirection direction; + public: + TraversalVisitor(TraverseDirection _direction); + + virtual void BeforeVisit(ParsingTreeToken* node); + virtual void AfterVisit(ParsingTreeToken* node); + virtual void BeforeVisit(ParsingTreeObject* node); + virtual void AfterVisit(ParsingTreeObject* node); + virtual void BeforeVisit(ParsingTreeArray* node); + virtual void AfterVisit(ParsingTreeArray* node); + + virtual void Visit(ParsingTreeToken* node)override; + virtual void Visit(ParsingTreeObject* node)override; + virtual void Visit(ParsingTreeArray* node)override; + }; + protected: + typedef collections::List> NodeList; + + ParsingTextRange codeRange; + ParsingTreeNode* parent; + NodeList cachedOrderedSubNodes; + + virtual const NodeList& GetSubNodesInternal()=0; + bool BeforeAddChild(Ptr node); + void AfterAddChild(Ptr node); + bool BeforeRemoveChild(Ptr node); + void AfterRemoveChild(Ptr node); + public: + ParsingTreeNode(const ParsingTextRange& _codeRange); + ~ParsingTreeNode(); + + virtual void Accept(IVisitor* visitor)=0; + virtual Ptr Clone()=0; + ParsingTextRange GetCodeRange(); + void SetCodeRange(const ParsingTextRange& range); + + /// Precalculate for enhance searching performance for this node and all child nodes. + void InitializeQueryCache(); + /// Clear all cache made by . + void ClearQueryCache(); + /// Get the parent node. Using this function requires running before. + /// The parent node. + ParsingTreeNode* GetParent(); + /// Get the child nodes. Using this function requires running before. + /// The child nodes. + const NodeList& GetSubNodes(); + + /// Find a direct child node at the position. Using this function requires running before. + /// The found node. + /// The position. + ParsingTreeNode* FindSubNode(const ParsingTextPos& position); + /// Find a direct child node at the range. Using this function requires running before. + /// The found node. + /// The range. + ParsingTreeNode* FindSubNode(const ParsingTextRange& range); + /// Find a most deepest indirect child node at the position. Using this function requires running before. + /// The found node. + /// The position. + ParsingTreeNode* FindDeepestNode(const ParsingTextPos& position); + /// Find a most deepest indirect child node at the range. Using this function requires running before. + /// The found node. + /// The range. + ParsingTreeNode* FindDeepestNode(const ParsingTextRange& range); + }; + + /// Representing a token node in a abstract syntax tree. + class ParsingTreeToken : public ParsingTreeNode, public reflection::Description + { + protected: + WString value; + vint tokenIndex; + + const NodeList& GetSubNodesInternal()override; + public: + ParsingTreeToken(const WString& _value, vint _tokenIndex=-1, const ParsingTextRange& _codeRange=ParsingTextRange()); + ~ParsingTreeToken(); + + void Accept(IVisitor* visitor)override; + Ptr Clone()override; + vint GetTokenIndex(); + void SetTokenIndex(vint _tokenIndex); + /// Get the content of the token. + /// The content of the token. + const WString& GetValue(); + void SetValue(const WString& _value); + }; + + /// Representing an object node in a abstract syntax tree. + class ParsingTreeObject : public ParsingTreeNode, public reflection::Description + { + protected: + typedef collections::Dictionary> NodeMap; + typedef collections::SortedList NameList; + typedef collections::List RuleList; + + WString type; + NodeMap members; + RuleList rules; + + const NodeList& GetSubNodesInternal()override; + public: + ParsingTreeObject(const WString& _type=L"", const ParsingTextRange& _codeRange=ParsingTextRange()); + ~ParsingTreeObject(); + + void Accept(IVisitor* visitor)override; + Ptr Clone()override; + /// Get the type name of the object. + /// The type name of the object. + const WString& GetType(); + void SetType(const WString& _type); + /// Get all fields of the object. + /// All fields of the object. + NodeMap& GetMembers(); + /// Get a field of the object by the field name. + /// The field of the object. + /// The field name. + Ptr GetMember(const WString& name); + bool SetMember(const WString& name, Ptr node); + bool RemoveMember(const WString& name); + /// Get all field names. + /// All field names of the object. + const NameList& GetMemberNames(); + /// Get names of all rules that return this object. + /// Names of all rules. + RuleList& GetCreatorRules(); + }; + + /// Representing an array node in a abstract syntax tree. + class ParsingTreeArray : public ParsingTreeNode, public reflection::Description + { + protected: + typedef collections::List> NodeArray; + + WString elementType; + NodeArray items; + + const NodeList& GetSubNodesInternal()override; + public: + ParsingTreeArray(const WString& _elementType=L"", const ParsingTextRange& _codeRange=ParsingTextRange()); + ~ParsingTreeArray(); + + void Accept(IVisitor* visitor)override; + Ptr Clone()override; + /// Get the type of all elements. It could be different from any actual element's type, but it should at least be the base types of them. + /// The type of all elements. + const WString& GetElementType(); + void SetElementType(const WString& _elementType); + /// Get all elements in this array. + /// All elements in this array. + NodeArray& GetItems(); + /// Get a specified element in this array by the index. + /// The element. + /// The index of the element. + Ptr GetItem(vint index); + bool SetItem(vint index, Ptr node); + bool AddItem(Ptr node); + bool InsertItem(vint index, Ptr node); + bool RemoveItem(vint index); + bool RemoveItem(ParsingTreeNode* node); + vint IndexOfItem(ParsingTreeNode* node); + bool ContainsItem(ParsingTreeNode* node); + vint Count(); + bool Clear(); + }; + +/*********************************************************************** +语法树基础设施 +***********************************************************************/ + + /// Base type of all strong typed syntax tree. Normally all strong typed syntax tree are generated from a grammar file using ParserGen.exe in Tools project. See [T:vl.parsing.tabling.ParsingTable] for details. + class ParsingTreeCustomBase : public Object, public reflection::Description + { + public: + /// Range of all tokens that form this object. + ParsingTextRange codeRange; + /// Names of all rules that return this object. + collections::List creatorRules; + }; + + /// Strong typed token syntax node, for all class fields of type "token" in the grammar file. See [T:vl.parsing.tabling.ParsingTable] for details. + class ParsingToken : public ParsingTreeCustomBase, public reflection::Description + { + public: + /// Type of the token, representing the index of a regular expression that creates this token in the regular expression list in the grammar file. + vint tokenIndex; + /// Content of the token. + WString value; + + ParsingToken():tokenIndex(-1){} + }; + + /// Error. + class ParsingError : public Object, public reflection::Description + { + public: + /// Range where the error happens. + ParsingTextRange codeRange; + /// Token at which the error happens. + const regex::RegexToken* token; + /// A syntax tree that contains this error. + ParsingTreeCustomBase* parsingTree; + /// The error message. + WString errorMessage; + + ParsingError(); + ParsingError(const WString& _errorMessage); + ParsingError(const regex::RegexToken* _token, const WString& _errorMessage); + ParsingError(ParsingTreeCustomBase* _parsingTree, const WString& _errorMessage); + ~ParsingError(); + }; + +/*********************************************************************** +Syntax Tree Serialization Helper +***********************************************************************/ + + class ParsingTreeConverter : public Object + { + public: + typedef collections::List TokenList; + + virtual Ptr ConvertClass(Ptr obj, const TokenList& tokens)=0; + + bool SetMember(ParsingToken& member, Ptr node, const TokenList& tokens) + { + Ptr token=node.Cast(); + if(token) + { + member.tokenIndex=token->GetTokenIndex(); + member.value=token->GetValue(); + member.codeRange=token->GetCodeRange(); + return true; + } + return false; + } + + template + bool SetMember(collections::List& member, Ptr node, const TokenList& tokens) + { + Ptr arr=node.Cast(); + if(arr) + { + member.Clear(); + vint count=arr->Count(); + for(vint i=0;iGetItem(i), tokens); + member.Add(t); + } + return true; + } + return false; + } + + template + bool SetMember(Ptr& member, Ptr node, const TokenList& tokens) + { + Ptr obj=node.Cast(); + if(obj) + { + Ptr tree=ConvertClass(obj, tokens); + if(tree) + { + tree->codeRange=node->GetCodeRange(); + member=tree.Cast(); + return member; + } + } + return false; + } + }; + +/*********************************************************************** +Logging +***********************************************************************/ + + class IParsingPrintNodeRecorder : public virtual Interface + { + public: + virtual void Record(ParsingTreeCustomBase* node, const ParsingTextRange& range) = 0; + }; + + class ParsingEmptyPrintNodeRecorder : public Object, public virtual IParsingPrintNodeRecorder + { + public: + ParsingEmptyPrintNodeRecorder(); + ~ParsingEmptyPrintNodeRecorder(); + + void Record(ParsingTreeCustomBase* node, const ParsingTextRange& range)override; + }; + + class ParsingMultiplePrintNodeRecorder : public Object, public virtual IParsingPrintNodeRecorder + { + typedef collections::List> RecorderList; + protected: + RecorderList recorders; + + public: + ParsingMultiplePrintNodeRecorder(); + ~ParsingMultiplePrintNodeRecorder(); + + void AddRecorder(Ptr recorder); + void Record(ParsingTreeCustomBase* node, const ParsingTextRange& range)override; + }; + + class ParsingOriginalLocationRecorder : public Object, public virtual IParsingPrintNodeRecorder + { + protected: + Ptr recorder; + + public: + ParsingOriginalLocationRecorder(Ptr _recorder); + ~ParsingOriginalLocationRecorder(); + + void Record(ParsingTreeCustomBase* node, const ParsingTextRange& range)override; + }; + + class ParsingGeneratedLocationRecorder : public Object, public virtual IParsingPrintNodeRecorder + { + typedef collections::Dictionary RangeMap; + protected: + RangeMap& rangeMap; + + public: + ParsingGeneratedLocationRecorder(RangeMap& _rangeMap); + ~ParsingGeneratedLocationRecorder(); + + void Record(ParsingTreeCustomBase* node, const ParsingTextRange& range)override; + }; + + class ParsingUpdateLocationRecorder : public Object, public virtual IParsingPrintNodeRecorder + { + public: + ParsingUpdateLocationRecorder(); + ~ParsingUpdateLocationRecorder(); + + void Record(ParsingTreeCustomBase* node, const ParsingTextRange& range)override; + }; + + class ParsingWriter : public stream::TextWriter + { + typedef collections::Pair NodePosPair; + typedef collections::List NodePosList; + protected: + stream::TextWriter& writer; + Ptr recorder; + vint codeIndex; + ParsingTextPos lastPos; + ParsingTextPos currentPos; + NodePosList nodePositions; + + void HandleChar(wchar_t c); + public: + ParsingWriter(stream::TextWriter& _writer, Ptr _recorder = nullptr, vint _codeIndex = -1); + ~ParsingWriter(); + + using stream::TextWriter::WriteString; + void WriteChar(wchar_t c)override; + void WriteString(const wchar_t* string, vint charCount)override; + void BeforePrint(ParsingTreeCustomBase* node); + void AfterPrint(ParsingTreeCustomBase* node); + }; + + extern void Log(ParsingTreeNode* node, const WString& originalInput, stream::TextWriter& writer, const WString& prefix=L""); + } +} + +#endif + + +/*********************************************************************** +.\PARSING\PARSINGDEFINITIONS.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -16171,7 +16748,7 @@ namespace vl #endif /*********************************************************************** -PARSING\PARSINGANALYZER.H +.\PARSING\PARSINGANALYZER.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -16347,19 +16924,20 @@ namespace vl #endif + /*********************************************************************** -PARSING\PARSING.H +.\PARSING\PARSINGTABLE.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 Developer: Zihan Chen(vczh) -Parsing::Parser +Parsing::Table Classes: ***********************************************************************/ -#ifndef VCZH_PARSING_PARSING -#define VCZH_PARSING_PARSING +#ifndef VCZH_PARSING_PARSINGTABLE +#define VCZH_PARSING_PARSINGTABLE namespace vl @@ -16370,201 +16948,567 @@ namespace vl { /*********************************************************************** -语法分析器通用策略 +跳转表 ***********************************************************************/ - /// Base type of all parser strategy. - class ParsingGeneralParser : public Object + /// " // (multiple) e.g. "../Import/Vlpp.h" + /// classPrefix: // (single) A prefix that will be add before all generated types and function. e.g. Xml + /// guard: // (single) The C++ header guard pattern macro name. e.g. VCZH_PARSING_XML_PARSINGXML_PARSER + /// namespace: // (single) Namespaces separated by "." to contain the generated code. e.g. vl.parsing.xml + /// reflection: // (single) Namespaces separated by "." to contain the name of reflectable types. In most of the cases this should be the same as namespace. e.g. vl.parsing.xml + /// parser:() // (multiple) Pair a function name to a rule name. ParserGen.exe will generate a function called "" to parse the input using rule named "". e.g. ParseDocument(XDocument) + /// ambiguity:(enabled|disabled) // (single) Set to "enabled" indicating that the grammar is by design to have ambiguity. + /// serialization:(enabled|disabled) // (single) Set to "enabled" to serialize the parsing table as binary in the generated C++ code, so that when the "LoadTable" function is called to load the table, it can deserialize from the binary data directly, instead of parsing the grammar again. But the grammar text will always be contained in the generated C++ code regardless of the value of "serialization", it can always be retrived using the "GetParserTextBuffer" function. + /// grammar: // (single) Configuration ends here. All content after "grammar:" will be treated as the grammar to define the input. + /// + /// Here is the brief description of the grammar. + /// The grammar is formed by 3 parts: types, token definitions and rule definitions. There is only one character escaping in strings: "", which means the " character. + /// + /// 1) Types: + /// You can write attributes like @AttributeName("argument1", "argument2", ...) in the middle of types. But attributes don't affect the parsing. All attribute definitions will be stored in the generated parsing table, and who uses the table defines how attributes work. Multiple attributes are separated by ",". + /// + /// a) Enum: + /// enum EnumName + /// { + /// Item1 , + /// Item2 , + /// ... // cannot skip the last "," + /// } + /// + /// b) Class: + /// class Name [ambiguous(AmbiguousType)] [: ParentType] + /// { + /// Type name [(UnescapingFunction)] ; + /// } + /// + /// UnescapingFunction is a callback, which will be called when the contained type is fully constructed. The generated C++ code will define forward declarations of all unescaping functions in the cpp file. You should implement them in other places, or you will get linking errors. + /// + /// If the grammar enables ambiguity, then the parsing result may contain ambiguous results for the same part of the input. For example, in C++: + /// A*B; + /// has two meaning (if we only consider context-free parsing): multiplication expression and pointer variable definition. + /// So if the grammar doesn't enable ambiguity, ParserGen.exe will refuce to generate C++ codes because the grammar is wrong. + /// If the grammar enables ambiguity, than the syntax tree should be defined like this: + /// + /// class Statement ambiguous(AmbiguousStatement) + /// { + /// } + /// + /// class AmbiguousStatement : Statement // due to the definition of "Statement" class, "AmbiguousStatement" should inherit from "Statement" + /// { + /// Statement[] items; // required by naming convention + /// } + /// + /// class ExpressionStatement : Statement + /// { + /// Expression expression; + /// } + /// + /// class VariableDefinitionStatement : Statement + /// { + /// Type type; + /// token name; + /// } + /// + /// So for the "A*B;" part in the whole input, it will becomes an AmbiguousStatement, in which the "items" field contains 2 instance of "ExpressionStatement" and "VariableDefinitionStatement". + /// And you can write C++ code to resolve the ambiguity in later passes. + /// + /// c) Type references: + /// Types can be defined globally or inside classes. Generic type is not supported. When you want to refer to a specific type, it could be: + /// token: Store a token, which will becomes [T:vl.parsing.ParsingToken]. + /// Type[]: Array, which will becomes [T:vl.collections.List`2] to the element type. Token cannot be the element of arrays. + /// ClassName: Instance of a specified type, which will becomes [T:vl.Ptr`1] to that type. + /// OuterClass.InnerClass: Refer to the "InnerClass" defined inside the "OuterClass". + /// + /// 2) Token definitions: + /// token TokenName = "regular expression" ; + /// discardtoken TokenName = "regular expression"; + /// + /// "discardtoken" means if such a token is identified, it will not appear in the lexical analyzing result. And you cannot refer to names of "discardtoken" in the grammar. + /// + /// 3) Rule definitions: + /// rule RuleType RuleName + /// = Grammar1 + /// = Grammar2 + /// ... + /// ; + /// + /// It means rule "RuleName" is defined by those grammars, and matching this rule will create an instance of "RuleType" or its whatever types that inheriting "RuleType". + /// + /// 4) Grammars: + /// RuleName: Defines an input that matches a rule. + /// TokenName: Defines an input that formed by the specified token. + /// "StringConstant": Defins an input that formed by exactly the string constant. This constant should define a token in the token list. + /// Grammar : FieldName: Defines an input that matches Grammar (should be either a rule name or a token name), and the result will be stored in field "FieldName" of a class, whose type will appear later. + /// !Grammar: Defines an input that matches Grammar, and the rule will return the result from this grammar. The input should still match other part of the rule, but result of other parts are ignored. + /// [Grammar]: Defines an input that, if match Grammar, will returns the result from that grammar; if not, the result is null. + /// {Grammar}: Defines an input that matches 0, 1 or more Grammar. + /// (Grammar): Defins an input that matches the the grammar. Brackets is only for changing operator associations. + /// Grammar1 Grammar2: Defines an input that should match Grammar1 right before Grammar2. + /// Grammar1 | Grammar2: Defines an input that match either Grammar1 or Grammar2. + /// Grammar as Type: Defines an input that matches the Grammar, and the whole branch of the rule creates an instance of type "Type" + /// Grammar with { FieldName = Value }: Defins an input that matches the Grammar, and will assign "Value", which should be an enum item, to the field "FieldName" of the created instance. + /// + /// 5) Example + /// Here is an example to parse expression containing +, -, *, /, () and numbers:\ + /// + /// include:"Vlpp.h" + /// classPrefix:Calc + /// guard:VCZH_CALCULATOR_PARSER + /// namespace:vl.calculator + /// reflection:vl.calculator + /// parser:ParseExpression(Expr) + /// ambiguity:disabled + /// serialization:enabled + /// grammar: + /// + /// class Expression + /// { + /// } + /// + /// enum BinaryOperator + /// { + /// Add, Sub, Mul, Div, + /// } + /// + /// class NumberExpression : Expression + /// { + /// token number; + /// } + /// + /// class BinaryExpression : Expression + /// { + /// BinaryOperator op; + /// Expression left; + /// Expression right; + /// } + /// + /// token ADD "\+" + /// token SUB "-" + /// token MUL "\*" + /// token DIV "\/" + /// token NUMBER "\d+(.\d+)?" + /// token OPEN "(" + /// token CLOSE ")" + /// + /// rule Expression Factor + /// = NUMBER : number as NumberExpression + /// = "(" !Expr ")" + /// ; + /// rule Expression Term + /// = !Factor + /// = Term : left "*" Factor : right as BinaryExpression with {op = "Mul"} + /// = Term : left "/" Factor : right as BinaryExpression with {op = "Div"} + /// ; + /// rule Expression Expr + /// = !Term + /// = Expr : left "+" Term : right as BinaryExpression with {op = "Add"} + /// = Expr : left "-" Term : right as BinaryExpression with {op = "Sub"} + /// ; + /// + /// After using ParserGen.exe to generate C++ codes, you can do this: + /// auto table = CalcLoadTable(); // this table can be used several times, don't load each type for each parsing, it will have a big performance overhead. + /// List> errors; + /// auto expression = CalcParseExpression(L"(1+2) * (3+4)", table, errors); // it should be a Ptr, will returns nullptr if the input is wrong, with all errors filled into the "errors" variable. + /// You don't need to define the "errors" if you don't actually care how the input is wrong. There will be a overloaded version of CalcParseExpression that doesn't need the error list. + /// + /// If you want to parse a wrong input and do automatic error recovering, which means if the input is not too wrong, you can still get a syntax tree, but some fields are null, with errors filled into the "error" variable. It will be a little complex: + /// auto table = CalcLoadTable(); // Load the table. + /// ParsingState state(L"(1+2) * (3+4)", table); // Initialize a state with the input and the table. + /// state.Reset(L"Expr"); // Set the rule to parse. + /// auto parser = CreateAutoRecoverParser(table); // Create an appropriate automatic error recoverable parser. + /// List> errors; // Define an error list. + /// auto node = parser->Parse(state, errors); // Parse to get an abstract syntax tree, which is a Ptr. + /// if (node) + /// { + /// auto expression = CalcConvertParsingTreeNode(node, state.GetTokens()).Cast(); + /// } + /// + /// After you get a strong typed syntax tree, you can use the generated visitor interface to do something, like evaluate the results of the expression: + /// class Evaluator : public Object, public virtual CalcExpression::IVisitor + /// { + /// private: + /// double result; + /// + /// double Call(CalcExpression* node) + /// { + /// node->Accept(this); + /// return result; + /// } + /// + /// public: + /// + /// static double Evaluate(CalcExpression* node) + /// { + /// return Evaluator().Call(node); + /// } + /// + /// void Visit(CalcNumberExpression* node)override + /// { + /// return wtof(node->number.value); + /// } + /// + /// void Visit(CalcBinaryExpression* node)override + /// { + /// auto left = Calc(node->left.Obj()); + /// auto right = Calc(node->right.Obj()); + /// switch (node->op) + /// { + /// case CalcBinaryOperator::Add: + /// result = left + right; + /// break; + /// case CalcBinaryOperator::Sub: + /// result = left 0 right; + /// break; + /// case CalcBinaryOperator::Mul: + /// result = left * right; + /// break; + /// case CalcBinaryOperator::Div: + /// result = left / right; + /// break; + /// } + /// } + /// }; + /// + /// Nullable EvaluateExpression(const WString& input) + /// { + /// static auto table = CalcLoadTable(); + /// auto expression = CalcParseExpression(input, table); + /// Nulllable result; + /// if (expression) + /// { + /// result = Evaluator::Evaulate(expression.Obj()); + /// } + /// return result; + /// } + /// + /// ]]> + class ParsingTable : public Object { - protected: - Ptr table; - public: - ParsingGeneralParser(Ptr _table); - ~ParsingGeneralParser(); - - /// Get the parser table that used to do the parsing. - /// The parser table that used to do the parsing. - Ptr GetTable(); - /// Initialization. It should be called before each time of parsing. - virtual void BeginParse(); - virtual ParsingState::TransitionResult ParseStep(ParsingState& state, collections::List>& errors)=0; - bool Parse(ParsingState& state, ParsingTransitionProcessor& processor, collections::List>& errors); - Ptr Parse(ParsingState& state, collections::List>& errors); - /// Parse an input and get an abstract syntax tree if no error happens or all errors are recovered. - /// The abstract syntax tree. - /// The input to parse. - /// The name of the rule that used to parse the input. - /// Returns all errors. - /// The code index to differentiate each input. This value will be stored in every tokens and abstract syntax nodes. - Ptr Parse(const WString& input, const WString& rule, collections::List>& errors, vint codeIndex = -1); - }; + static const vint TokenBegin=0; + static const vint TokenFinish=1; + static const vint NormalReduce=2; + static const vint LeftRecursiveReduce=3; + static const vint UserTokenStart=4; -/*********************************************************************** -语法分析器策略 -***********************************************************************/ - - /// A strict parse. It doesn't allow ambiguity and error recovery. - class ParsingStrictParser : public ParsingGeneralParser - { - protected: - - virtual bool OnTestErrorRecoverExists(); - virtual void OnClearErrorRecover(); - virtual ParsingState::TransitionResult OnErrorRecover(ParsingState& state, vint currentTokenIndex, collections::List>& errors); - public: - /// Create the parse using a parsing table. - /// The parsing table. - ParsingStrictParser(Ptr _table=0); - ~ParsingStrictParser(); - - ParsingState::TransitionResult ParseStep(ParsingState& state, collections::List>& errors)override; - }; - - /// A strict parse. It doesn't allow ambiguity but allows error recovery. - class ParsingAutoRecoverParser : public ParsingStrictParser - { - public: - struct RecoverFuture + class AttributeInfo : public Object { - ParsingState::Future* future; - vint insertedTokenCount; - vint index; - vint previousIndex; - vint nextIndex; + public: + WString name; + collections::List arguments; - RecoverFuture() - :future(0) - , insertedTokenCount(0) - , index(-1) - , previousIndex(-1) - , nextIndex(-1) + AttributeInfo(const WString& _name = L"") + :name(_name) + { + } + + AttributeInfo* Argument(const WString& argument) + { + arguments.Add(argument); + return this; + } + }; + + class AttributeInfoList : public Object + { + public: + collections::List> attributes; + + Ptr FindFirst(const WString& name); + }; + + class TreeTypeInfo + { + public: + WString type; + vint attributeIndex; + + TreeTypeInfo() + :attributeIndex(-1) + { + } + + TreeTypeInfo(const WString& _type, vint _attributeIndex) + :type(_type) + ,attributeIndex(_attributeIndex) { } }; + + class TreeFieldInfo + { + public: + WString type; + WString field; + vint attributeIndex; + + TreeFieldInfo() + :attributeIndex(-1) + { + } + + TreeFieldInfo(const WString& _type, const WString& _field, vint _attributeIndex) + :type(_type) + ,field(_field) + ,attributeIndex(_attributeIndex) + { + } + }; + + class TokenInfo + { + public: + WString name; + WString regex; + vint regexTokenIndex; + vint attributeIndex; + + TokenInfo() + :regexTokenIndex(-1) + ,attributeIndex(-1) + { + } + + TokenInfo(const WString& _name, const WString& _regex, vint _attributeIndex) + :name(_name) + ,regex(_regex) + ,regexTokenIndex(-1) + ,attributeIndex(_attributeIndex) + { + } + }; + + class StateInfo + { + public: + WString ruleName; + WString stateName; + WString stateExpression; + + WString ruleAmbiguousType; // filled in Initialize() + + StateInfo() + { + } + + StateInfo(const WString& _ruleName, const WString& _stateName, const WString& _stateExpression) + :ruleName(_ruleName) + ,stateName(_stateName) + ,stateExpression(_stateExpression) + { + } + }; + + class RuleInfo + { + public: + WString name; + WString type; + WString ambiguousType; + vint rootStartState; + vint attributeIndex; + + RuleInfo() + :rootStartState(-1) + ,attributeIndex(-1) + { + } + + RuleInfo(const WString& _name, const WString& _type, const WString& _ambiguousType, vint _rootStartState, vint _attributeIndex) + :name(_name) + ,type(_type) + ,ambiguousType(_ambiguousType) + ,rootStartState(_rootStartState) + ,attributeIndex(_attributeIndex) + { + } + }; + + class Instruction + { + public: + enum InstructionType + { + Create, + Assign, + Item, + Using, + Setter, + Shift, + Reduce, + LeftRecursiveReduce, + }; + + InstructionType instructionType; + vint stateParameter; + WString nameParameter; + WString value; + WString creatorRule; + + Instruction() + :instructionType(Create) + ,stateParameter(0) + { + } + + Instruction(InstructionType _instructionType, vint _stateParameter, const WString& _nameParameter, const WString& _value, const WString& _creatorRule) + :instructionType(_instructionType) + ,stateParameter(_stateParameter) + ,nameParameter(_nameParameter) + ,value(_value) + ,creatorRule(_creatorRule) + { + } + }; + + class LookAheadInfo + { + public: + collections::List tokens; + vint state; + + LookAheadInfo() + :state(-1) + { + } + + enum PrefixResult + { + Prefix, + Equal, + NotPrefix, + }; + + static PrefixResult TestPrefix(Ptr a, Ptr b); + static void WalkInternal(Ptr table, Ptr previous, vint state, collections::SortedList& walkedStates, collections::List>& newInfos); + static void Walk(Ptr table, Ptr previous, vint state, collections::List>& newInfos); + }; + + class TransitionItem + { + public: + vint token; + vint targetState; + collections::List> lookAheads; + collections::List stackPattern; + collections::List instructions; + + enum OrderResult + { + CorrectOrder, + WrongOrder, + SameOrder, + UnknownOrder, + }; + + TransitionItem(){} + + TransitionItem(vint _token, vint _targetState) + :token(_token) + ,targetState(_targetState) + { + } + + static OrderResult CheckOrder(Ptr t1, Ptr t2, bool forceGivingOrder); + static vint Compare(Ptr t1, Ptr t2); + }; + + class TransitionBag + { + public: + collections::List> transitionItems; + }; + protected: - vint maxInsertedTokenCount; - collections::List recoverFutures; - vint recoveringFutureIndex; - - RecoverFuture& GetRecoverFuture(vint index); - RecoverFuture& CreateRecoverFuture(vint index, vint previousIndex); - bool OnTestErrorRecoverExists()override; - void OnClearErrorRecover()override; - ParsingState::TransitionResult OnErrorRecover(ParsingState& state, vint currentTokenIndex, collections::List>& errors)override; + // metadata + bool ambiguity; + collections::Array> attributeInfos; + collections::Array treeTypeInfos; + collections::Array treeFieldInfos; + + // LALR table + vint tokenCount; // tokenInfos.Count() + discardTokenInfos.Count() + vint stateCount; // stateInfos.Count() + collections::Array tokenInfos; + collections::Array discardTokenInfos; + collections::Array stateInfos; + collections::Array ruleInfos; + collections::Array> transitionBags; + + // generated data + Ptr lexer; + collections::Dictionary ruleMap; + collections::Dictionary treeTypeInfoMap; + collections::Dictionary, vint> treeFieldInfoMap; + + template + void IO(TIO& io); + public: - /// Create the parse using a parsing table. - /// The parsing table. - /// The maximum number of tokens that allow to insert to recover an error. - ParsingAutoRecoverParser(Ptr _table = 0, vint _maxInsertedTokenCount = -1); - ~ParsingAutoRecoverParser(); + ParsingTable(vint _attributeInfoCount, vint _treeTypeInfoCount, vint _treeFieldInfoCount, vint _tokenCount, vint _discardTokenCount, vint _stateCount, vint _ruleCount); + /// Deserialize the parsing table from a stream. should be before using this table. + /// The stream. + ParsingTable(stream::IStream& input); + ~ParsingTable(); - void BeginParse()override; - }; - - /// A strict parse. It allows ambiguity but doesn't allow error recovery. - class ParsingAmbiguousParser : public ParsingGeneralParser - { - typedef collections::List DecisionList; - protected: + /// Serialize the parsing table to a stream. + /// The stream. + void Serialize(stream::IStream& output); - DecisionList decisions; - vint consumedDecisionCount; + bool GetAmbiguity(); + void SetAmbiguity(bool value); - virtual void OnErrorRecover(ParsingState& state, vint currentTokenIndex, collections::List& futures, vint& begin, vint& end, collections::List>& errors); - vint GetResolvableFutureLevels(collections::List& futures, vint begin, vint end); - vint SearchPathForOneStep(ParsingState& state, collections::List& futures, vint& begin, vint& end, collections::List>& errors); - vint GetConflictReduceCount(collections::List& futures); - void GetConflictReduceIndices(collections::List& futures, vint conflictReduceCount, collections::Array& conflictReduceIndices); - vint GetAffectedStackNodeCount(collections::List& futures, collections::Array& conflictReduceIndices); - void BuildSingleDecisionPath(ParsingState& state, ParsingState::Future* future, vint lastAvailableInstructionCount); - void BuildAmbiguousDecisions(ParsingState& state, collections::List& futures, vint begin, vint end, vint resolvableFutureLevels, collections::List>& errors); - void BuildDecisions(ParsingState& state, collections::List& futures, vint begin, vint end, vint resolvableFutureLevels, collections::List>& errors); - public: - /// Create the parse using a parsing table. - /// The parsing table. - ParsingAmbiguousParser(Ptr _table=0); - ~ParsingAmbiguousParser(); - - ParsingState::TransitionResult ParseStep(ParsingState& state, collections::List>& errors)override; - void BeginParse()override; - }; - - /// A strict parse. It allow both ambiguity and error recovery. - class ParsingAutoRecoverAmbiguousParser : public ParsingAmbiguousParser - { - protected: - vint maxInsertedTokenCount; + vint GetAttributeInfoCount(); + Ptr GetAttributeInfo(vint index); + void SetAttributeInfo(vint index, Ptr info); - void OnErrorRecover(ParsingState& state, vint currentTokenIndex, collections::List& futures, vint& begin, vint& end, collections::List>& errors)override; - public: - /// Create the parse using a parsing table. - /// The parsing table. - /// The maximum number of tokens that allow to insert to recover an error. - ParsingAutoRecoverAmbiguousParser(Ptr _table = 0, vint _maxInsertedTokenCount = -1); - ~ParsingAutoRecoverAmbiguousParser(); + vint GetTreeTypeInfoCount(); + const TreeTypeInfo& GetTreeTypeInfo(vint index); + const TreeTypeInfo& GetTreeTypeInfo(const WString& type); + void SetTreeTypeInfo(vint index, const TreeTypeInfo& info); + + vint GetTreeFieldInfoCount(); + const TreeFieldInfo& GetTreeFieldInfo(vint index); + const TreeFieldInfo& GetTreeFieldInfo(const WString& type, const WString& field); + void SetTreeFieldInfo(vint index, const TreeFieldInfo& info); + + vint GetTokenCount(); + const TokenInfo& GetTokenInfo(vint token); + void SetTokenInfo(vint token, const TokenInfo& info); + + vint GetDiscardTokenCount(); + const TokenInfo& GetDiscardTokenInfo(vint token); + void SetDiscardTokenInfo(vint token, const TokenInfo& info); + + vint GetStateCount(); + const StateInfo& GetStateInfo(vint state); + void SetStateInfo(vint state, const StateInfo& info); + + vint GetRuleCount(); + const RuleInfo& GetRuleInfo(const WString& ruleName); + const RuleInfo& GetRuleInfo(vint rule); + void SetRuleInfo(vint rule, const RuleInfo& info); + + const regex::RegexLexer& GetLexer(); + Ptr GetTransitionBag(vint state, vint token); + void SetTransitionBag(vint state, vint token, Ptr bag); + /// Initialize the parsing table. This function should be called after deserializing the table from a string. + void Initialize(); + bool IsInputToken(vint regexTokenIndex); + vint GetTableTokenIndex(vint regexTokenIndex); + vint GetTableDiscardTokenIndex(vint regexTokenIndex); }; /*********************************************************************** 辅助函数 ***********************************************************************/ - - /// Create the correct strict parser from a parsing table. - /// The created parse. - /// The table to create a parser. - extern Ptr CreateStrictParser(Ptr table); - /// Create the correct error recoverable parser from a parsing table. - /// The created parse. - /// The table to create a parser. - extern Ptr CreateAutoRecoverParser(Ptr table); - /// Create the correct strict parser to parse the grammar itself. - /// The created parse. - extern Ptr CreateBootstrapStrictParser(); - /// Create the correct error recoverable to parse the grammar itself. - /// The created parse. - extern Ptr CreateBootstrapAutoRecoverParser(); - } - } -} -/*********************************************************************** -反射 -***********************************************************************/ - -#ifndef VCZH_DEBUG_NO_REFLECTION - - -namespace vl -{ - namespace reflection - { - namespace description - { -#define PARSINGREFLECTION_TYPELIST(F)\ - F(parsing::ParsingTextPos)\ - F(parsing::ParsingTextRange)\ - F(parsing::ParsingTreeNode)\ - F(parsing::ParsingTreeToken)\ - F(parsing::ParsingTreeObject)\ - F(parsing::ParsingTreeArray)\ - F(parsing::ParsingTreeCustomBase)\ - F(parsing::ParsingToken)\ - F(parsing::ParsingError)\ - - PARSINGREFLECTION_TYPELIST(DECL_TYPE_INFO) - } - } -} - -#endif - -namespace vl -{ - namespace reflection - { - namespace description - { - extern bool LoadParsingTypes(); + extern void Log(Ptr table, stream::TextWriter& writer); } } } @@ -16572,7 +17516,7 @@ namespace vl #endif /*********************************************************************** -PARSING\PARSINGAUTOMATON.H +.\PARSING\PARSINGAUTOMATON.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -16798,7 +17742,558 @@ namespace vl #endif /*********************************************************************** -PARSING\JSON\PARSINGJSON_AST.H +.\PARSING\PARSINGSTATE.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Parsing::State + +Classes: +***********************************************************************/ + +#ifndef VCZH_PARSING_PARSINGSTATE +#define VCZH_PARSING_PARSINGSTATE + + +namespace vl +{ + namespace parsing + { + namespace tabling + { + +/*********************************************************************** +语法分析器 +***********************************************************************/ + + class ParsingTokenWalker : public Object + { + protected: + class LookAheadEnumerator : public Object, public collections::IEnumerator + { + protected: + const ParsingTokenWalker* walker; + vint firstToken; + vint currentToken; + vint currentValue; + vint index; + + public: + LookAheadEnumerator(const ParsingTokenWalker* _walker, vint _currentToken); + LookAheadEnumerator(const LookAheadEnumerator& _enumerator); + + collections::IEnumerator* Clone()const override; + const vint& Current()const override; + vint Index()const override; + bool Next()override; + void Reset()override; + }; + + class TokenLookAhead : public Object, public collections::IEnumerable + { + protected: + const ParsingTokenWalker* walker; + public: + TokenLookAhead(const ParsingTokenWalker* _talker); + + collections::IEnumerator* CreateEnumerator()const override; + }; + + class ReduceLookAhead : public Object, public collections::IEnumerable + { + protected: + const ParsingTokenWalker* walker; + public: + ReduceLookAhead(const ParsingTokenWalker* _walker); + + collections::IEnumerator* CreateEnumerator()const override; + }; + + protected: + collections::List& tokens; + Ptr table; + vint currentToken; + TokenLookAhead tokenLookAhead; + ReduceLookAhead reduceLookAhead; + + vint GetNextIndex(vint index)const; + vint GetTableTokenIndex(vint index)const; + public: + ParsingTokenWalker(collections::List& _tokens, Ptr _table); + ~ParsingTokenWalker(); + + const collections::IEnumerable& GetTokenLookahead()const; + const collections::IEnumerable& GetReduceLookahead()const; + void Reset(); + bool Move(); + vint GetTableTokenIndex()const; + regex::RegexToken* GetRegexToken()const; + vint GetTokenIndexInStream()const; + }; + + class ParsingState : public Object + { + public: + struct ShiftReduceRange + { + regex::RegexToken* shiftToken; + regex::RegexToken* reduceToken; + + ShiftReduceRange() + :shiftToken(0) + ,reduceToken(0) + { + } + }; + + struct TransitionResult + { + enum TransitionType + { + ExecuteInstructions, + AmbiguityBegin, + AmbiguityBranch, + AmbiguityEnd, + SkipToken, + }; + + TransitionType transitionType; + vint ambiguityAffectedStackNodeCount; + WString ambiguityNodeType; + + vint tableTokenIndex; + vint tableStateSource; + vint tableStateTarget; + vint tokenIndexInStream; + regex::RegexToken* token; + + ParsingTable::TransitionItem* transition; + vint instructionBegin; + vint instructionCount; + Ptr> shiftReduceRanges; + + TransitionResult(TransitionType _transitionType=ExecuteInstructions) + :transitionType(_transitionType) + ,ambiguityAffectedStackNodeCount(0) + ,tableTokenIndex(-1) + ,tableStateSource(-1) + ,tableStateTarget(-1) + ,tokenIndexInStream(-1) + ,token(0) + ,transition(0) + ,instructionBegin(-1) + ,instructionCount(-1) + { + } + + operator bool()const + { + return transitionType!=ExecuteInstructions || transition!=0; + } + + void AddShiftReduceRange(regex::RegexToken* shiftToken, regex::RegexToken* reduceToken) + { + ShiftReduceRange range; + range.shiftToken=shiftToken; + range.reduceToken=reduceToken; + if(!shiftReduceRanges) + { + shiftReduceRanges=new collections::List(); + } + shiftReduceRanges->Add(range); + } + }; + + struct Future + { + vint currentState; + vint reduceStateCount; + collections::List shiftStates; + regex::RegexToken* selectedRegexToken; + vint selectedToken; + ParsingTable::TransitionItem* selectedItem; + Future* previous; + Future* next; + + Future() + :currentState(-1) + ,reduceStateCount(0) + ,selectedRegexToken(0) + ,selectedToken(-1) + ,selectedItem(0) + ,previous(0) + ,next(0) + { + } + + Future* Clone() + { + Future* future = new Future; + future->currentState = currentState; + future->reduceStateCount = reduceStateCount; + CopyFrom(future->shiftStates, shiftStates); + future->selectedRegexToken = selectedRegexToken; + future->selectedToken = selectedToken; + future->selectedItem = selectedItem; + future->previous = previous; + return future; + } + }; + + struct StateGroup + { + collections::List stateStack; + vint currentState; + vint tokenSequenceIndex; + + collections::List shiftTokenStack; + regex::RegexToken* shiftToken; + regex::RegexToken* reduceToken; + + StateGroup(); + StateGroup(const ParsingTable::RuleInfo& info); + StateGroup(const StateGroup& group); + }; + private: + WString input; + Ptr table; + collections::List tokens; + Ptr walker; + + WString parsingRule; + vint parsingRuleStartState; + Ptr stateGroup; + public: + ParsingState(const WString& _input, Ptr _table, vint codeIndex=-1); + ~ParsingState(); + + const WString& GetInput(); + Ptr GetTable(); + const collections::List& GetTokens(); + regex::RegexToken* GetToken(vint index); + + vint Reset(const WString& rule); + WString GetParsingRule(); + vint GetParsingRuleStartState(); + vint GetCurrentToken(); + vint GetCurrentTableTokenIndex(); + const collections::List& GetStateStack(); + vint GetCurrentState(); + void SkipCurrentToken(); + + bool TestTransitionItemInFuture(vint tableTokenIndex, Future* future, ParsingTable::TransitionItem* item, const collections::IEnumerable* lookAheadTokens); + ParsingTable::TransitionItem* MatchTokenInFuture(vint tableTokenIndex, Future* future, const collections::IEnumerable* lookAheadTokens); + ParsingTable::TransitionItem* MatchToken(vint tableTokenIndex, const collections::IEnumerable* lookAheadTokens); + void RunTransitionInFuture(ParsingTable::TransitionItem* transition, Future* previous, Future* now); + ParsingState::TransitionResult RunTransition(ParsingTable::TransitionItem* transition, regex::RegexToken* regexToken, vint instructionBegin, vint instructionCount, bool lastPart); + ParsingState::TransitionResult RunTransition(ParsingTable::TransitionItem* transition, regex::RegexToken* regexToken); + + bool ReadTokenInFuture(vint tableTokenIndex, Future* previous, Future* now, const collections::IEnumerable* lookAheadTokens); + TransitionResult ReadToken(vint tableTokenIndex, regex::RegexToken* regexToken, const collections::IEnumerable* lookAheadTokens); + TransitionResult ReadToken(); + + bool TestExplore(vint tableTokenIndex, Future* previous); + bool Explore(vint tableTokenIndex, Future* previous, collections::List& possibilities); + bool ExploreStep(collections::List& previousFutures, vint start, vint count, collections::List& possibilities); + bool ExploreNormalReduce(collections::List& previousFutures, vint start, vint count, collections::List& possibilities); + bool ExploreLeftRecursiveReduce(collections::List& previousFutures, vint start, vint count, collections::List& possibilities); + Future* ExploreCreateRootFuture(); + + Ptr TakeSnapshot(); + void RestoreSnapshot(Ptr group); + }; + +/*********************************************************************** +语法树生成器 +***********************************************************************/ + + class ParsingTransitionProcessor : public Object + { + public: + virtual void Reset()=0; + virtual bool Run(const ParsingState::TransitionResult& result)=0; + virtual bool GetProcessingAmbiguityBranch()=0; + }; + + class ParsingTreeBuilder : public ParsingTransitionProcessor + { + protected: + Ptr createdObject; + Ptr operationTarget; + collections::List> nodeStack; + + bool processingAmbiguityBranch; + Ptr ambiguityBranchCreatedObject; + Ptr ambiguityBranchOperationTarget; + vint ambiguityBranchSharedNodeCount; + collections::List> ambiguityBranchNodeStack; + collections::List> ambiguityNodes; + public: + ParsingTreeBuilder(); + ~ParsingTreeBuilder(); + + void Reset()override; + bool Run(const ParsingState::TransitionResult& result)override; + bool GetProcessingAmbiguityBranch()override; + Ptr GetNode()const; + }; + + class ParsingTransitionCollector : public ParsingTransitionProcessor + { + typedef collections::List TransitionResultList; + protected: + vint ambiguityBegin; + TransitionResultList transitions; + + collections::Dictionary ambiguityBeginToEnds; + collections::Group ambiguityBeginToBranches; + collections::Dictionary ambiguityBranchToBegins; + public: + ParsingTransitionCollector(); + ~ParsingTransitionCollector(); + + void Reset()override; + bool Run(const ParsingState::TransitionResult& result)override; + bool GetProcessingAmbiguityBranch()override; + + const TransitionResultList& GetTransitions()const; + vint GetAmbiguityEndFromBegin(vint transitionIndex)const; + const collections::List& GetAmbiguityBranchesFromBegin(vint transitionIndex)const; + vint GetAmbiguityBeginFromBranch(vint transitionIndex)const; + }; + } + } +} + +#endif + +/*********************************************************************** +.\PARSING\PARSING.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Parsing::Parser + +Classes: +***********************************************************************/ + +#ifndef VCZH_PARSING_PARSING +#define VCZH_PARSING_PARSING + + +namespace vl +{ + namespace parsing + { + namespace tabling + { + +/*********************************************************************** +语法分析器通用策略 +***********************************************************************/ + + /// Base type of all parser strategy. + class ParsingGeneralParser : public Object + { + protected: + Ptr table; + + public: + ParsingGeneralParser(Ptr _table); + ~ParsingGeneralParser(); + + /// Get the parser table that used to do the parsing. + /// The parser table that used to do the parsing. + Ptr GetTable(); + /// Initialization. It should be called before each time of parsing. + virtual void BeginParse(); + virtual ParsingState::TransitionResult ParseStep(ParsingState& state, collections::List>& errors)=0; + bool Parse(ParsingState& state, ParsingTransitionProcessor& processor, collections::List>& errors); + Ptr Parse(ParsingState& state, collections::List>& errors); + /// Parse an input and get an abstract syntax tree if no error happens or all errors are recovered. + /// The abstract syntax tree. + /// The input to parse. + /// The name of the rule that used to parse the input. + /// Returns all errors. + /// The code index to differentiate each input. This value will be stored in every tokens and abstract syntax nodes. + Ptr Parse(const WString& input, const WString& rule, collections::List>& errors, vint codeIndex = -1); + }; + +/*********************************************************************** +语法分析器策略 +***********************************************************************/ + + /// A strict parse. It doesn't allow ambiguity and error recovery. + class ParsingStrictParser : public ParsingGeneralParser + { + protected: + + virtual bool OnTestErrorRecoverExists(); + virtual void OnClearErrorRecover(); + virtual ParsingState::TransitionResult OnErrorRecover(ParsingState& state, vint currentTokenIndex, collections::List>& errors); + public: + /// Create the parse using a parsing table. + /// The parsing table. + ParsingStrictParser(Ptr _table=0); + ~ParsingStrictParser(); + + ParsingState::TransitionResult ParseStep(ParsingState& state, collections::List>& errors)override; + }; + + /// A strict parse. It doesn't allow ambiguity but allows error recovery. + class ParsingAutoRecoverParser : public ParsingStrictParser + { + public: + struct RecoverFuture + { + ParsingState::Future* future; + vint insertedTokenCount; + vint index; + vint previousIndex; + vint nextIndex; + + RecoverFuture() + :future(0) + , insertedTokenCount(0) + , index(-1) + , previousIndex(-1) + , nextIndex(-1) + { + } + }; + protected: + vint maxInsertedTokenCount; + collections::List recoverFutures; + vint recoveringFutureIndex; + + RecoverFuture& GetRecoverFuture(vint index); + RecoverFuture& CreateRecoverFuture(vint index, vint previousIndex); + bool OnTestErrorRecoverExists()override; + void OnClearErrorRecover()override; + ParsingState::TransitionResult OnErrorRecover(ParsingState& state, vint currentTokenIndex, collections::List>& errors)override; + public: + /// Create the parse using a parsing table. + /// The parsing table. + /// The maximum number of tokens that allow to insert to recover an error. + ParsingAutoRecoverParser(Ptr _table = 0, vint _maxInsertedTokenCount = -1); + ~ParsingAutoRecoverParser(); + + void BeginParse()override; + }; + + /// A strict parse. It allows ambiguity but doesn't allow error recovery. + class ParsingAmbiguousParser : public ParsingGeneralParser + { + typedef collections::List DecisionList; + protected: + + DecisionList decisions; + vint consumedDecisionCount; + + virtual void OnErrorRecover(ParsingState& state, vint currentTokenIndex, collections::List& futures, vint& begin, vint& end, collections::List>& errors); + vint GetResolvableFutureLevels(collections::List& futures, vint begin, vint end); + vint SearchPathForOneStep(ParsingState& state, collections::List& futures, vint& begin, vint& end, collections::List>& errors); + vint GetConflictReduceCount(collections::List& futures); + void GetConflictReduceIndices(collections::List& futures, vint conflictReduceCount, collections::Array& conflictReduceIndices); + vint GetAffectedStackNodeCount(collections::List& futures, collections::Array& conflictReduceIndices); + void BuildSingleDecisionPath(ParsingState& state, ParsingState::Future* future, vint lastAvailableInstructionCount); + void BuildAmbiguousDecisions(ParsingState& state, collections::List& futures, vint begin, vint end, vint resolvableFutureLevels, collections::List>& errors); + void BuildDecisions(ParsingState& state, collections::List& futures, vint begin, vint end, vint resolvableFutureLevels, collections::List>& errors); + public: + /// Create the parse using a parsing table. + /// The parsing table. + ParsingAmbiguousParser(Ptr _table=0); + ~ParsingAmbiguousParser(); + + ParsingState::TransitionResult ParseStep(ParsingState& state, collections::List>& errors)override; + void BeginParse()override; + }; + + /// A strict parse. It allow both ambiguity and error recovery. + class ParsingAutoRecoverAmbiguousParser : public ParsingAmbiguousParser + { + protected: + vint maxInsertedTokenCount; + + void OnErrorRecover(ParsingState& state, vint currentTokenIndex, collections::List& futures, vint& begin, vint& end, collections::List>& errors)override; + public: + /// Create the parse using a parsing table. + /// The parsing table. + /// The maximum number of tokens that allow to insert to recover an error. + ParsingAutoRecoverAmbiguousParser(Ptr _table = 0, vint _maxInsertedTokenCount = -1); + ~ParsingAutoRecoverAmbiguousParser(); + }; + +/*********************************************************************** +辅助函数 +***********************************************************************/ + + /// Create the correct strict parser from a parsing table. + /// The created parse. + /// The table to create a parser. + extern Ptr CreateStrictParser(Ptr table); + /// Create the correct error recoverable parser from a parsing table. + /// The created parse. + /// The table to create a parser. + extern Ptr CreateAutoRecoverParser(Ptr table); + /// Create the correct strict parser to parse the grammar itself. + /// The created parse. + extern Ptr CreateBootstrapStrictParser(); + /// Create the correct error recoverable to parse the grammar itself. + /// The created parse. + extern Ptr CreateBootstrapAutoRecoverParser(); + } + } +} + +/*********************************************************************** +反射 +***********************************************************************/ + +#ifndef VCZH_DEBUG_NO_REFLECTION + + +namespace vl +{ + namespace reflection + { + namespace description + { +#define PARSINGREFLECTION_TYPELIST(F)\ + F(parsing::ParsingTextPos)\ + F(parsing::ParsingTextRange)\ + F(parsing::ParsingTreeNode)\ + F(parsing::ParsingTreeToken)\ + F(parsing::ParsingTreeObject)\ + F(parsing::ParsingTreeArray)\ + F(parsing::ParsingTreeCustomBase)\ + F(parsing::ParsingToken)\ + F(parsing::ParsingError)\ + + PARSINGREFLECTION_TYPELIST(DECL_TYPE_INFO) + } + } +} + +#endif + +namespace vl +{ + namespace reflection + { + namespace description + { + extern bool LoadParsingTypes(); + } + } +} + +#endif + +/*********************************************************************** +.\PARSING\JSON\PARSINGJSON_AST.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -16988,7 +18483,7 @@ namespace vl #endif /*********************************************************************** -PARSING\JSON\PARSINGJSON_PARSER.H +.\PARSING\JSON\PARSINGJSON_PARSER.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -17022,7 +18517,37 @@ namespace vl #endif /*********************************************************************** -PARSING\XML\PARSINGXML_AST.H +.\PARSING\JSON\PARSINGJSON.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Parser::ParsingJson_Parser + +***********************************************************************/ + +#ifndef VCZH_PARSING_JSON_PARSINGJSON +#define VCZH_PARSING_JSON_PARSINGJSON + + +namespace vl +{ + namespace parsing + { + namespace json + { + extern void JsonEscapeString(const WString& text, stream::TextWriter& writer); + extern void JsonUnescapeString(const WString& text, stream::TextWriter& writer); + extern void JsonPrint(Ptr node, stream::TextWriter& writer); + extern WString JsonToString(Ptr node); + } + } +} + +#endif + +/*********************************************************************** +.\PARSING\XML\PARSINGXML_AST.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -17228,7 +18753,7 @@ namespace vl #endif /*********************************************************************** -PARSING\XML\PARSINGXML_PARSER.H +.\PARSING\XML\PARSINGXML_PARSER.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -17267,840 +18792,102 @@ namespace vl #endif /*********************************************************************** -REGEX\REGEXDATA.H +.\PARSING\XML\PARSINGXML.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 Developer: Zihan Chen(vczh) -Regex::Basic Data Structure +Parser::ParsingXml -Classes: ***********************************************************************/ -#ifndef VCZH_REGEX_REGEXDATA -#define VCZH_REGEX_REGEXDATA +#ifndef VCZH_PARSING_XML_PARSINGXML +#define VCZH_PARSING_XML_PARSINGXML namespace vl { - namespace regex_internal + namespace parsing { - -/*********************************************************************** -基础数据结构 -***********************************************************************/ - - class CharRange + namespace xml { - public: - typedef collections::SortedList List; + extern WString XmlEscapeValue(const WString& value); + extern WString XmlUnescapeValue(const WString& value); + extern WString XmlEscapeCData(const WString& value); + extern WString XmlUnescapeCData(const WString& value); + extern WString XmlEscapeComment(const WString& value); + extern WString XmlUnescapeComment(const WString& value); + extern void XmlPrint(Ptr node, stream::TextWriter& writer); + extern void XmlPrintContent(Ptr element, stream::TextWriter& writer); + extern WString XmlToString(Ptr node); - wchar_t begin; - wchar_t end; + extern Ptr XmlGetAttribute(Ptr element, const WString& name); + extern Ptr XmlGetElement(Ptr element, const WString& name); + extern collections::LazyList> XmlGetElements(Ptr element); + extern collections::LazyList> XmlGetElements(Ptr element, const WString& name); + extern WString XmlGetValue(Ptr element); - CharRange(); - CharRange(wchar_t _begin, wchar_t _end); + extern Ptr XmlGetAttribute(XmlElement* element, const WString& name); + extern Ptr XmlGetElement(XmlElement* element, const WString& name); + extern collections::LazyList> XmlGetElements(XmlElement* element); + extern collections::LazyList> XmlGetElements(XmlElement* element, const WString& name); + extern WString XmlGetValue(XmlElement* element); - bool operator<(CharRange item)const; - bool operator<=(CharRange item)const; - bool operator>(CharRange item)const; - bool operator>=(CharRange item)const; - bool operator==(CharRange item)const; - bool operator!=(CharRange item)const; - - bool operator<(wchar_t item)const; - bool operator<=(wchar_t item)const; - bool operator>(wchar_t item)const; - bool operator>=(wchar_t item)const; - bool operator==(wchar_t item)const; - bool operator!=(wchar_t item)const; - }; - } - - template<> - struct POD - { - static const bool Result=true; - }; -} - -#endif - -/*********************************************************************** -REGEX\REGEXAUTOMATON.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Regex::RegexAutomaton - -Classes: - State :状态 - Transition :转换 - Automaton :状态机 - -Functions: - EpsilonNfaToNfa :去Epsilon - NfaToDfa :NFA转DFA -***********************************************************************/ - -#ifndef VCZH_REGEX_REGEXAUTOMATON -#define VCZH_REGEX_REGEXAUTOMATON - - -namespace vl -{ - namespace regex_internal - { - class State; - class Transition; - - class Transition - { - public: - enum Type + class XmlElementWriter : public Object { - Chars, //range为字符范围 - Epsilon, - BeginString, - EndString, - Nop, //无动作(不可消除epsilon,用来控制优先级) - Capture, //capture为捕获频道 - Match, //capture为捕获频道,index为匹配的位置,-1代表匹配频道下面的所有项目 - Positive, //正向匹配 - Negative, //反向匹配 - NegativeFail, //反向匹配失败 - End //Capture, Position, Negative + protected: + Ptr element; + const XmlElementWriter* previousWriter; + + public: + XmlElementWriter(Ptr _element, const XmlElementWriter* _previousWriter=0); + ~XmlElementWriter(); + + const XmlElementWriter& Attribute(const WString& name, const WString& value)const; + XmlElementWriter Element(const WString& name)const; + const XmlElementWriter& End()const; + const XmlElementWriter& Text(const WString& value)const; + const XmlElementWriter& CData(const WString& value)const; + const XmlElementWriter& Comment(const WString& value)const; }; - - State* source; - State* target; - CharRange range; - Type type; - vint capture; - vint index; - }; - - class State - { - public: - collections::List transitions; - collections::List inputs; - bool finalState; - void* userData; - }; - - class Automaton - { - public: - typedef Ptr Ref; - - collections::List> states; - collections::List> transitions; - collections::List captureNames; - State* startState; - - Automaton(); - - State* NewState(); - Transition* NewTransition(State* start, State* end); - Transition* NewChars(State* start, State* end, CharRange range); - Transition* NewEpsilon(State* start, State* end); - Transition* NewBeginString(State* start, State* end); - Transition* NewEndString(State* start, State* end); - Transition* NewNop(State* start, State* end); - Transition* NewCapture(State* start, State* end, vint capture); - Transition* NewMatch(State* start, State* end, vint capture, vint index=-1); - Transition* NewPositive(State* start, State* end); - Transition* NewNegative(State* start, State* end); - Transition* NewNegativeFail(State* start, State* end); - Transition* NewEnd(State* start, State* end); - }; - - extern bool PureEpsilonChecker(Transition* transition); - extern bool RichEpsilonChecker(Transition* transition); - extern bool AreEqual(Transition* transA, Transition* transB); - extern Automaton::Ref EpsilonNfaToNfa(Automaton::Ref source, bool(*epsilonChecker)(Transition*), collections::Dictionary& nfaStateMap); - extern Automaton::Ref NfaToDfa(Automaton::Ref source, collections::Group& dfaStateMap); + } } } #endif /*********************************************************************** -REGEX\REGEXEXPRESSION.H +.\STREAM\RECORDERSTREAM.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 Developer: Zihan Chen(vczh) -Regex::RegexExpression - -Classes: - Expression :表达式基类 | - CharSetExpression :字符集表达式 | a, [a-b], [^a-b0_9], \.rnt\/()+*?{}[]<>^$!=SsDdLlWw, [\rnt-[]\/^$] - LoopExpression :循环表达式 | a{3}, a{3,}, a{1,3}, a+, a*, a?, LOOP? - SequenceExpression :顺序表达式 | ab - AlternateExpression :选择表达式 | a|b - BeginExpression :【非纯】字符串起始表达式 | ^ - EndExpression :【非纯】字符串末尾表达式 | $ - CaptureExpression :【非纯】捕获表达式 | (expr), (?expr) - MatchExpression :【非纯】匹配表达式 | (<$name>), (<$name;i>), (<$i>) - PositiveExpression :【非纯】正向预查表达式 | (=expr) - NegativeExpression :【非纯】反向预查表达式 | (!expr) - UsingExpression :引用表达式 | (<#name1>expr)...(<&name1>)... - - RegexExpression :正则表达式 - -Functions: - ParseRegexExpression :将字符串分析为RegexExpression对象,如果语法有问题则抛异常 -***********************************************************************/ - -#ifndef VCZH_REGEX_REGEXEXPRESSION -#define VCZH_REGEX_REGEXEXPRESSION - - -namespace vl -{ - namespace regex_internal - { - class IRegexExpressionAlgorithm; - -/*********************************************************************** -正则表达式表达式树 -***********************************************************************/ - - class Expression : public Object, private NotCopyable - { - public: - typedef Ptr Ref; - typedef collections::Dictionary Map; - - virtual void Apply(IRegexExpressionAlgorithm& algorithm)=0; - bool IsEqual(Expression* expression); - bool HasNoExtension(); - bool CanTreatAsPure(); - void NormalizeCharSet(CharRange::List& subsets); - void CollectCharSet(CharRange::List& subsets); - void ApplyCharSet(CharRange::List& subsets); - Automaton::Ref GenerateEpsilonNfa(); - }; - - class CharSetExpression : public Expression - { - public: - CharRange::List ranges; - bool reverse; - - bool AddRangeWithConflict(CharRange range); - void Apply(IRegexExpressionAlgorithm& algorithm); - }; - - class LoopExpression : public Expression - { - public: - Expression::Ref expression; //被循环表达式 - vint min; //下限 - vint max; //上限,-1代表无限 - bool preferLong; //长匹配优先 - - void Apply(IRegexExpressionAlgorithm& algorithm); - }; - - class SequenceExpression : public Expression - { - public: - Expression::Ref left; //左表达式 - Expression::Ref right; //右表达式 - - void Apply(IRegexExpressionAlgorithm& algorithm); - }; - - class AlternateExpression : public Expression - { - public: - Expression::Ref left; //左表达式 - Expression::Ref right; //右表达式 - - void Apply(IRegexExpressionAlgorithm& algorithm); - }; - - class BeginExpression: public Expression - { - public: - - void Apply(IRegexExpressionAlgorithm& algorithm); - }; - - class EndExpression : public Expression - { - public: - - void Apply(IRegexExpressionAlgorithm& algorithm); - }; - - class CaptureExpression : public Expression - { - public: - WString name; //捕获名,空代表缺省捕获 - Expression::Ref expression; //被捕获表达式 - - void Apply(IRegexExpressionAlgorithm& algorithm); - }; - - class MatchExpression : public Expression - { - public: - WString name; //捕获名,空代表缺省捕获 - vint index; //捕获序号,-1代表非空捕获的所有项 - - void Apply(IRegexExpressionAlgorithm& algorithm); - }; - - class PositiveExpression : public Expression - { - public: - Expression::Ref expression; //正向匹配表达式 - - void Apply(IRegexExpressionAlgorithm& algorithm); - }; - - class NegativeExpression : public Expression - { - public: - Expression::Ref expression; //反向匹配表达式 - - void Apply(IRegexExpressionAlgorithm& algorithm); - }; - - class UsingExpression : public Expression - { - public: - WString name; //引用名 - - void Apply(IRegexExpressionAlgorithm& algorithm); - }; - - class RegexExpression : public Object, private NotCopyable - { - public: - typedef Ptr Ref; - - Expression::Map definitions; //命名子表达式 - Expression::Ref expression; //主表达式 - - Expression::Ref Merge(); - }; - -/*********************************************************************** -算法基类 -***********************************************************************/ - - class IRegexExpressionAlgorithm : public Interface - { - public: - virtual void Visit(CharSetExpression* expression)=0; - virtual void Visit(LoopExpression* expression)=0; - virtual void Visit(SequenceExpression* expression)=0; - virtual void Visit(AlternateExpression* expression)=0; - virtual void Visit(BeginExpression* expression)=0; - virtual void Visit(EndExpression* expression)=0; - virtual void Visit(CaptureExpression* expression)=0; - virtual void Visit(MatchExpression* expression)=0; - virtual void Visit(PositiveExpression* expression)=0; - virtual void Visit(NegativeExpression* expression)=0; - virtual void Visit(UsingExpression* expression)=0; - }; - - template - class RegexExpressionAlgorithm : public Object, public IRegexExpressionAlgorithm - { - private: - ReturnType returnValue; - ParameterType* parameterValue; - public: - - ReturnType Invoke(Expression* expression, ParameterType parameter) - { - parameterValue=¶meter; - expression->Apply(*this); - return returnValue; - } - - ReturnType Invoke(Expression::Ref expression, ParameterType parameter) - { - parameterValue=¶meter; - expression->Apply(*this); - return returnValue; - } - - virtual ReturnType Apply(CharSetExpression* expression, ParameterType parameter)=0; - virtual ReturnType Apply(LoopExpression* expression, ParameterType parameter)=0; - virtual ReturnType Apply(SequenceExpression* expression, ParameterType parameter)=0; - virtual ReturnType Apply(AlternateExpression* expression, ParameterType parameter)=0; - virtual ReturnType Apply(BeginExpression* expression, ParameterType parameter)=0; - virtual ReturnType Apply(EndExpression* expression, ParameterType parameter)=0; - virtual ReturnType Apply(CaptureExpression* expression, ParameterType parameter)=0; - virtual ReturnType Apply(MatchExpression* expression, ParameterType parameter)=0; - virtual ReturnType Apply(PositiveExpression* expression, ParameterType parameter)=0; - virtual ReturnType Apply(NegativeExpression* expression, ParameterType parameter)=0; - virtual ReturnType Apply(UsingExpression* expression, ParameterType parameter)=0; - public: - void Visit(CharSetExpression* expression) - { - returnValue=Apply(expression, *parameterValue); - } - - void Visit(LoopExpression* expression) - { - returnValue=Apply(expression, *parameterValue); - } - - void Visit(SequenceExpression* expression) - { - returnValue=Apply(expression, *parameterValue); - } - - void Visit(AlternateExpression* expression) - { - returnValue=Apply(expression, *parameterValue); - } - - void Visit(BeginExpression* expression) - { - returnValue=Apply(expression, *parameterValue); - } - - void Visit(EndExpression* expression) - { - returnValue=Apply(expression, *parameterValue); - } - - void Visit(CaptureExpression* expression) - { - returnValue=Apply(expression, *parameterValue); - } - - void Visit(MatchExpression* expression) - { - returnValue=Apply(expression, *parameterValue); - } - - void Visit(PositiveExpression* expression) - { - returnValue=Apply(expression, *parameterValue); - } - - void Visit(NegativeExpression* expression) - { - returnValue=Apply(expression, *parameterValue); - } - - void Visit(UsingExpression* expression) - { - returnValue=Apply(expression, *parameterValue); - } - }; - - template - class RegexExpressionAlgorithm : public Object, public IRegexExpressionAlgorithm - { - private: - ParameterType* parameterValue; - public: - - void Invoke(Expression* expression, ParameterType parameter) - { - parameterValue=¶meter; - expression->Apply(*this); - } - - void Invoke(Expression::Ref expression, ParameterType parameter) - { - parameterValue=¶meter; - expression->Apply(*this); - } - - virtual void Apply(CharSetExpression* expression, ParameterType parameter)=0; - virtual void Apply(LoopExpression* expression, ParameterType parameter)=0; - virtual void Apply(SequenceExpression* expression, ParameterType parameter)=0; - virtual void Apply(AlternateExpression* expression, ParameterType parameter)=0; - virtual void Apply(BeginExpression* expression, ParameterType parameter)=0; - virtual void Apply(EndExpression* expression, ParameterType parameter)=0; - virtual void Apply(CaptureExpression* expression, ParameterType parameter)=0; - virtual void Apply(MatchExpression* expression, ParameterType parameter)=0; - virtual void Apply(PositiveExpression* expression, ParameterType parameter)=0; - virtual void Apply(NegativeExpression* expression, ParameterType parameter)=0; - virtual void Apply(UsingExpression* expression, ParameterType parameter)=0; - public: - void Visit(CharSetExpression* expression) - { - Apply(expression, *parameterValue); - } - - void Visit(LoopExpression* expression) - { - Apply(expression, *parameterValue); - } - - void Visit(SequenceExpression* expression) - { - Apply(expression, *parameterValue); - } - - void Visit(AlternateExpression* expression) - { - Apply(expression, *parameterValue); - } - - void Visit(BeginExpression* expression) - { - Apply(expression, *parameterValue); - } - - void Visit(EndExpression* expression) - { - Apply(expression, *parameterValue); - } - - void Visit(CaptureExpression* expression) - { - Apply(expression, *parameterValue); - } - - void Visit(MatchExpression* expression) - { - Apply(expression, *parameterValue); - } - - void Visit(PositiveExpression* expression) - { - Apply(expression, *parameterValue); - } - - void Visit(NegativeExpression* expression) - { - Apply(expression, *parameterValue); - } - - void Visit(UsingExpression* expression) - { - Apply(expression, *parameterValue); - } - }; - -/*********************************************************************** -辅助函数 -***********************************************************************/ - - extern Ptr ParseLoop(const wchar_t*& input); - extern Ptr ParseCharSet(const wchar_t*& input); - extern Ptr ParseFunction(const wchar_t*& input); - extern Ptr ParseUnit(const wchar_t*& input); - extern Ptr ParseJoin(const wchar_t*& input); - extern Ptr ParseAlt(const wchar_t*& input); - extern Ptr ParseExpression(const wchar_t*& input); - extern RegexExpression::Ref ParseRegexExpression(const WString& code); - - extern WString EscapeTextForRegex(const WString& literalString); - extern WString UnescapeTextForRegex(const WString& escapedText); - extern WString NormalizeEscapedTextForRegex(const WString& escapedText); - extern bool IsRegexEscapedLiteralString(const WString& regex); - } -} - -#endif - -/*********************************************************************** -CONSOLE.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -UI::Console - -***********************************************************************/ - -#ifndef VCZH_CONSOLE -#define VCZH_CONSOLE - - -namespace vl -{ - namespace console - { - /// A Static class for command line window operations. - class Console abstract - { - public: - /// Write to the command line window. - /// Content to write. - /// Size of the content in wchar_t. The zero terminator is not included. - static void Write(const wchar_t* string, vint length); - - /// Write to the command line window. - /// Content to write. - static void Write(const wchar_t* string); - - /// Write to the command line window. - /// Content to write. - static void Write(const WString& string); - - /// Write to the command line window with a CRLF. - /// Content to write. - static void WriteLine(const WString& string); - - /// Read from the command line window. - /// The whole line read from the command line window. - static WString Read(); - - static void SetColor(bool red, bool green, bool blue, bool light); - static void SetTitle(const WString& string); - }; - } -} - -#endif - -/*********************************************************************** -FILESYSTEM.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Framework::FileSystem - -***********************************************************************/ - -#ifndef VCZH_FILESYSTEM -#define VCZH_FILESYSTEM - - -namespace vl -{ - namespace filesystem - { - /// A type representing a file path. - class FilePath : public Object - { - protected: - WString fullPath; - - void Initialize(); - - static void GetPathComponents(WString path, collections::List& components); - static WString ComponentsToPath(const collections::List& components); - public: -#if defined VCZH_MSVC - static const wchar_t Delimiter = L'\\'; -#elif defined VCZH_GCC - static const wchar_t Delimiter = L'/'; -#endif - - /// Create a root path. - FilePath(); - /// Create a file path. - /// Content of the file path. If it is a relative path, it will be converted to an absolute path. - FilePath(const WString& _filePath); - /// Create a file path. - /// Content of the file path. If it is a relative path, it will be converted to an absolute path. - FilePath(const wchar_t* _filePath); - /// Copy a file path. - /// The file path to copy. - FilePath(const FilePath& _filePath); - ~FilePath(); - - static vint Compare(const FilePath& a, const FilePath& b); - bool operator==(const FilePath& filePath){ return Compare(*this, filePath) == 0; } - bool operator!=(const FilePath& filePath){ return Compare(*this, filePath) != 0; } - bool operator< (const FilePath& filePath){ return Compare(*this, filePath) < 0; } - bool operator<=(const FilePath& filePath){ return Compare(*this, filePath) <= 0; } - bool operator> (const FilePath& filePath){ return Compare(*this, filePath) > 0; } - bool operator>=(const FilePath& filePath){ return Compare(*this, filePath) >= 0; } - - /// Concat an absolute path and a relative path. - /// The result absolute path. - /// The relative path to concat. - FilePath operator/(const WString& relativePath)const; - - /// Test if the file path is a file. - /// Returns true if the file path is a file. - bool IsFile()const; - /// Test if the file path is a folder. - /// Returns true if the file path is a folder. - bool IsFolder()const; - /// Test if the file path is a the root of all file system objects. - /// Returns true if the file path is the root of all file system objects. - bool IsRoot()const; - - /// Get the last piece of names in the file path. - /// The last piece of names in the file path. - WString GetName()const; - /// Get the containing folder of this file path. - /// The containing folder. - FilePath GetFolder()const; - /// Get the content of the file path. - /// The content of the file path. - WString GetFullPath()const; - /// Calculate the relative path using a referencing folder. - /// The relative path. - /// The referencing folder. - WString GetRelativePathFor(const FilePath& _filePath); - - }; - - /// Representing a file reference. - class File : public Object - { - private: - FilePath filePath; - - public: - /// Create an empty reference. - File(); - /// Create a reference to a specified file. - /// The specified file. - File(const FilePath& _filePath); - ~File(); - - /// Get the file path of the file. - /// The file path. - const FilePath& GetFilePath()const; - - /// Get the content of the file as text with encoding testing. - /// The content of the file. - /// Returns false if this operation succeeded. - /// The content of the file. - /// The encoding. - /// True if there is BOM. - bool ReadAllTextWithEncodingTesting(WString& text, stream::BomEncoder::Encoding& encoding, bool& containsBom); - /// Get the content of the file as text. - /// The content of the file. - WString ReadAllTextByBom()const; - /// Get the content of the file as text. - /// Returns false if this operation succeeded. - /// The content of the file. - bool ReadAllTextByBom(WString& text)const; - /// Get the content of the file as text. - /// Returns false if this operation succeeded. - /// The content of the file. - bool ReadAllLinesByBom(collections::List& lines)const; - - /// Write text to the file. - /// Returns false if this operation succeeded. - /// The text to write. - /// Set to true to add a corresponding BOM at the beginning of the file according to the encoding. - /// The text encoding. - bool WriteAllText(const WString& text, bool bom = true, stream::BomEncoder::Encoding encoding = stream::BomEncoder::Utf16); - /// Write text to the file. - /// Returns false if this operation succeeded. - /// The text to write. - /// Set to true to add a corresponding BOM at the beginning of the file according to the encoding. - /// The text encoding. - bool WriteAllLines(collections::List& lines, bool bom = true, stream::BomEncoder::Encoding encoding = stream::BomEncoder::Utf16); - - /// Test does the file exist or not. - /// Returns true if the file exists. - bool Exists()const; - /// Delete the file. - /// Returns true if this operation succeeded. - bool Delete()const; - /// Rename the file in the same folder. - /// Returns true if this operation succeeded. - /// The new file name. - bool Rename(const WString& newName)const; - }; - - /// Representing a folder reference. - class Folder : public Object - { - private: - FilePath filePath; - - public: - /// Create a root reference. - Folder(); - /// Create a reference to a specified folder. - /// The specified folder. - Folder(const FilePath& _filePath); - ~Folder(); - - /// Get the file path of the folder. - /// The file path. - const FilePath& GetFilePath()const; - /// Get all folders in this folder. - /// Returns true if this operation succeeded. - /// All folders. - bool GetFolders(collections::List& folders)const; - /// Get all files in this folder. - /// Returns true if this operation succeeded. - /// All files. - bool GetFiles(collections::List& files)const; - - /// Test does the folder exist or not. - /// Returns true if the folder exists. - bool Exists()const; - /// Create the folder. - /// Returns true if this operation succeeded. - /// Set to true to create all parent folders if necessary. - bool Create(bool recursively)const; - /// Delete the folder. - /// Returns true if this operation succeeded. - /// Set to true to delete everything in the folder. - bool Delete(bool recursively)const; - /// Rename the folder in the same folder. - /// Returns true if this operation succeeded. - /// The new folder name. - bool Rename(const WString& newName)const; - }; - } -} - -#endif - -/*********************************************************************** -STREAM\FILESTREAM.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Stream::FileStream +Stream::RecorderStream Interfaces: - FileStream :文件流 + RecorderStream :备份流 ***********************************************************************/ -#ifndef VCZH_STREAM_FILESTREAM -#define VCZH_STREAM_FILESTREAM +#ifndef VCZH_STREAM_RECORDERSTREAM +#define VCZH_STREAM_RECORDERSTREAM -#include namespace vl { namespace stream { - /// A file stream. It is readable when you use [F:vl.stream.FileStream.AccessRight.ReadOnly] or [F:vl.stream.FileStream.AccessRight.ReadWrite] to create the stream. It is writable when you use [F:vl.stream.FileStream.AccessRight.WriteOnly] or [F:vl.stream.FileStream.AccessRight.ReadWrite] to create the stream. - class FileStream : public Object, public virtual IStream + /// A readable stream that, read from an stream, and write everything that is read to another stream. + class RecorderStream : public Object, public virtual IStream { - public: - /// Access to the file. - enum AccessRight - { - /// The file is opened to read. - ReadOnly, - /// The file is opened to write. - WriteOnly, - /// The file is opened to both read and write. - ReadWrite - }; protected: - AccessRight accessRight; - FILE* file; + IStream* in; + IStream* out; public: /// Create a stream. - /// File to operate. - /// Operations want to perform on the file. - FileStream(const WString& fileName, AccessRight _accessRight); - ~FileStream(); + /// The stream to read. + /// The stream to write what is read from "_in". + RecorderStream(IStream& _in, IStream& _out); + ~RecorderStream(); bool CanRead()const; bool CanWrite()const; @@ -18124,193 +18911,7 @@ namespace vl #endif /*********************************************************************** -GLOBALSTORAGE.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Framework::Global Storage - -Classes: - GlobalStorage :全局对象 - -***********************************************************************/ - -#ifndef VCZH_GLOBALSTORAGE -#define VCZH_GLOBALSTORAGE - - -namespace vl -{ - /// ) - /// - /// INITIALIZE_GLOBAL_STORAGE_CLASS - /// - /// FINALIZE_GLOBAL_STORAGE_CLASS - /// - /// END_GLOBAL_STORAGE_CLASS - /// Then you have a global storage. You can only use this global storage in the current cpp file. [M:vl.InitializeGlobalStorage] should be called before using any global storage. [M:vl.FinalizeGlobalStorage] is encouraged to call if you think you will not use any global storages anymore. It will reduce noices when you want to detect memory leaks. - /// If the key of the global variable is called Key, and the variable you want to access is called Variable, then you can use GetKey()->Variable to access that variable. The GetKey function is created in the macro calls before. - /// ]]> - class GlobalStorage : public Object, private NotCopyable - { - private: - bool cleared; - public: - GlobalStorage(const wchar_t* key); - ~GlobalStorage(); - - bool Cleared(); - virtual void ClearResource()=0; - }; - - extern GlobalStorage* GetGlobalStorage(const wchar_t* key); - extern GlobalStorage* GetGlobalStorage(const WString& key); - - /// Initialize the global storage. - extern void InitializeGlobalStorage(); - /// Finalize the global storage. - extern void FinalizeGlobalStorage(); -} - -#define BEGIN_GLOBAL_STORAGE_CLASS(NAME)\ - class NAME : public vl::GlobalStorage\ - {\ - public:\ - NAME()\ - :vl::GlobalStorage(L ## #NAME)\ - {\ - InitializeClearResource();\ - }\ - ~NAME()\ - {\ - if(!Cleared())ClearResource();\ - }\ - -#define INITIALIZE_GLOBAL_STORAGE_CLASS\ - void InitializeClearResource()\ - {\ - -#define FINALIZE_GLOBAL_STORAGE_CLASS\ - }\ - void ClearResource()\ - {\ - -#define END_GLOBAL_STORAGE_CLASS(NAME)\ - }\ - };\ - NAME& Get##NAME()\ - {\ - static NAME __global_storage_##NAME;\ - return __global_storage_##NAME;\ - }\ - -#define EXTERN_GLOBAL_STORAGE_CLASS(NAME)\ - class NAME;\ - extern NAME& Get##NAME();\ - -#endif - -/*********************************************************************** -HTTPUTILITY.H -***********************************************************************/ -#ifndef VCZH_HTTPUTILITY -#define VCZH_HTTPUTILITY - - -#ifdef VCZH_MSVC - -namespace vl -{ - -/*********************************************************************** -HTTP Utility -***********************************************************************/ - - /// A type representing an http requiest. - class HttpRequest - { - typedef collections::Array BodyBuffer; - typedef collections::List StringList; - typedef collections::Dictionary HeaderMap; - public: - /// Name of the server, like "gaclib.net". - WString server; - /// Port of the server, like 80. - vint port; - /// Query of the request, like "/GettingStart.html". - WString query; - /// Set to true if the request uses SSL. - bool secure; - /// User name to authorize. Set to empty if you don't want to provide it. - WString username; - /// Password to authorize. Set to empty if you don't want to provide it. - WString password; - /// HTTP method, like "GET", "POST", "PUT", "DELETE", etc. - WString method; - /// Cookie. Set to empty if you don't want to provide it. - WString cookie; - /// Request body. This is a binary array using an array container to char. - BodyBuffer body; - /// Content type, like "text/xml". - WString contentType; - /// Accept type list, elements of it like "text/xml". - StringList acceptTypes; - /// A dictionary to contain extra headers. - HeaderMap extraHeaders; - - /// Create an empty request. - HttpRequest(); - - /// Set , , and fields for you using an URL. - /// Returns true if this operation succeeded. - /// The URL. - bool SetHost(const WString& inputQuery); - - /// Fill the body with a text using UTF-8 encoding. - /// The text to fill. - void SetBodyUtf8(const WString& bodyString); - }; - - /// A type representing an http response. - class HttpResponse - { - typedef collections::Array BodyBuffer; - public: - /// Status code, like 200. - vint statusCode; - /// Response body. This is a binary array using an array container to char. - BodyBuffer body; - /// Returned cookie from the server. - WString cookie; - - HttpResponse(); - - /// If you believe the server returns a text in UTF-8, use it to decode the body. - /// The response body as text. - WString GetBodyUtf8(); - }; - - /// Send an http request and receive a response. - /// Returns true if this operation succeeded. Even the server returns 404 will be treated as success, because you get the response. - /// The request. - /// The response. - extern bool HttpQuery(const HttpRequest& request, HttpResponse& response); - - /// Encode a text as part of the url. This function can be used to create arguments in an URL. - /// The encoded text. - /// The text to encode. - extern WString UrlEncodeQuery(const WString& query); -} - -#endif - -#endif - -/*********************************************************************** -THREADING.H +.\THREADING.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -19005,681 +19606,9 @@ RepeatingTaskExecutor } #endif -/*********************************************************************** -PARSING\JSON\PARSINGJSON.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Parser::ParsingJson_Parser - -***********************************************************************/ - -#ifndef VCZH_PARSING_JSON_PARSINGJSON -#define VCZH_PARSING_JSON_PARSINGJSON - - -namespace vl -{ - namespace parsing - { - namespace json - { - extern void JsonEscapeString(const WString& text, stream::TextWriter& writer); - extern void JsonUnescapeString(const WString& text, stream::TextWriter& writer); - extern void JsonPrint(Ptr node, stream::TextWriter& writer); - extern WString JsonToString(Ptr node); - } - } -} - -#endif /*********************************************************************** -PARSING\XML\PARSINGXML.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Parser::ParsingXml - -***********************************************************************/ - -#ifndef VCZH_PARSING_XML_PARSINGXML -#define VCZH_PARSING_XML_PARSINGXML - - -namespace vl -{ - namespace parsing - { - namespace xml - { - extern WString XmlEscapeValue(const WString& value); - extern WString XmlUnescapeValue(const WString& value); - extern WString XmlEscapeCData(const WString& value); - extern WString XmlUnescapeCData(const WString& value); - extern WString XmlEscapeComment(const WString& value); - extern WString XmlUnescapeComment(const WString& value); - extern void XmlPrint(Ptr node, stream::TextWriter& writer); - extern void XmlPrintContent(Ptr element, stream::TextWriter& writer); - extern WString XmlToString(Ptr node); - - extern Ptr XmlGetAttribute(Ptr element, const WString& name); - extern Ptr XmlGetElement(Ptr element, const WString& name); - extern collections::LazyList> XmlGetElements(Ptr element); - extern collections::LazyList> XmlGetElements(Ptr element, const WString& name); - extern WString XmlGetValue(Ptr element); - - extern Ptr XmlGetAttribute(XmlElement* element, const WString& name); - extern Ptr XmlGetElement(XmlElement* element, const WString& name); - extern collections::LazyList> XmlGetElements(XmlElement* element); - extern collections::LazyList> XmlGetElements(XmlElement* element, const WString& name); - extern WString XmlGetValue(XmlElement* element); - - class XmlElementWriter : public Object - { - protected: - Ptr element; - const XmlElementWriter* previousWriter; - - public: - XmlElementWriter(Ptr _element, const XmlElementWriter* _previousWriter=0); - ~XmlElementWriter(); - - const XmlElementWriter& Attribute(const WString& name, const WString& value)const; - XmlElementWriter Element(const WString& name)const; - const XmlElementWriter& End()const; - const XmlElementWriter& Text(const WString& value)const; - const XmlElementWriter& CData(const WString& value)const; - const XmlElementWriter& Comment(const WString& value)const; - }; - } - } -} - -#endif - -/*********************************************************************** -REGEX\REGEXPURE.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Regex::RegexInterpretor - -Classes: - PureInterpretor :正则表达式纯模拟器 -***********************************************************************/ - -#ifndef VCZH_REGEX_REGEXPURE -#define VCZH_REGEX_REGEXPURE - - -namespace vl -{ - namespace regex_internal - { - class PureResult - { - public: - vint start; - vint length; - vint finalState; - vint terminateState; - }; - - class PureInterpretor : public Object - { - protected: -#if defined VCZH_MSVC - static const vint SupportedCharCount = 0x10000; // UTF-16 -#elif defined VCZH_GCC - static const vint SupportedCharCount = 0x110000; // UTF-32 -#endif - - vint charMap[SupportedCharCount]; // char -> char set index - vint** transition; // (state * char set index) -> state* - bool* finalState; // state -> bool - vint* relatedFinalState; // sate -> (finalState or -1) - vint stateCount; - vint charSetCount; - vint startState; - public: - PureInterpretor(Automaton::Ref dfa, CharRange::List& subsets); - ~PureInterpretor(); - - bool MatchHead(const wchar_t* input, const wchar_t* start, PureResult& result); - bool Match(const wchar_t* input, const wchar_t* start, PureResult& result); - - vint GetStartState(); - vint Transit(wchar_t input, vint state); - bool IsFinalState(vint state); - bool IsDeadState(vint state); - - void PrepareForRelatedFinalStateTable(); - vint GetRelatedFinalState(vint state); - }; - } -} - -#endif - -/*********************************************************************** -REGEX\REGEXRICH.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Regex::RegexInterpretor - -Classes: - RichInterpretor :正则表达式完全模拟器 -***********************************************************************/ - -#ifndef VCZH_REGEX_REGEXRICH -#define VCZH_REGEX_REGEXRICH - - -namespace vl -{ - namespace regex_internal - { - class CaptureRecord - { - public: - vint capture; - vint start; - vint length; - - bool operator==(const CaptureRecord& record)const; - }; - } - - template<> - struct POD - { - static const bool Result=true; - }; - - namespace regex_internal - { - class RichResult - { - public: - vint start; - vint length; - collections::List captures; - }; - - class RichInterpretor : public Object - { - public: - protected: - class UserData - { - public: - bool NeedKeepState; - }; - - Automaton::Ref dfa; - UserData* datas; - public: - RichInterpretor(Automaton::Ref _dfa); - ~RichInterpretor(); - - bool MatchHead(const wchar_t* input, const wchar_t* start, RichResult& result); - bool Match(const wchar_t* input, const wchar_t* start, RichResult& result); - const collections::List& CaptureNames(); - }; - }; -} - -#endif - -/*********************************************************************** -REGEX\REGEXWRITER.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Regex::RegexWriter - -Classes: -***********************************************************************/ - -#ifndef VCZH_REGEX_REGEXWRITER -#define VCZH_REGEX_REGEXWRITER - - -namespace vl -{ - namespace regex - { - class RegexNode : public Object - { - public: - vl::regex_internal::Expression::Ref expression; - - RegexNode(vl::regex_internal::Expression::Ref _expression); - - RegexNode Some()const; - RegexNode Any()const; - RegexNode Opt()const; - RegexNode Loop(vint min, vint max)const; - RegexNode AtLeast(vint min)const; - RegexNode operator+(const RegexNode& node)const; - RegexNode operator|(const RegexNode& node)const; - RegexNode operator+()const; - RegexNode operator-()const; - RegexNode operator!()const; - RegexNode operator%(const RegexNode& node)const; - }; - - extern RegexNode rCapture(const WString& name, const RegexNode& node); - extern RegexNode rUsing(const WString& name); - extern RegexNode rMatch(const WString& name, vint index=-1); - extern RegexNode rMatch(vint index); - extern RegexNode rBegin(); - extern RegexNode rEnd(); - extern RegexNode rC(wchar_t a, wchar_t b=L'\0'); - extern RegexNode r_d(); - extern RegexNode r_l(); - extern RegexNode r_w(); - extern RegexNode rAnyChar(); - } -} - -#endif - -/*********************************************************************** -STREAM\BROADCASTSTREAM.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Stream::BroadcastStream - -Interfaces: - BroadcastStream :广播流 -***********************************************************************/ - -#ifndef VCZH_STREAM_BROADCASTSTREAM -#define VCZH_STREAM_BROADCASTSTREAM - - -namespace vl -{ - namespace stream - { - /// A writable stream that copy written content to multiple target streams. - class BroadcastStream : public Object, public virtual IStream - { - typedef collections::List StreamList; - protected: - bool closed; - pos_t position; - StreamList streams; - public: - /// Create a strema. - BroadcastStream(); - ~BroadcastStream(); - - /// Get the list of target streams. You can add streams to this list, or remove streams from this list. - /// The list of target streams. - StreamList& Targets(); - bool CanRead()const; - bool CanWrite()const; - bool CanSeek()const; - bool CanPeek()const; - bool IsLimited()const; - bool IsAvailable()const; - void Close(); - pos_t Position()const; - pos_t Size()const; - void Seek(pos_t _size); - void SeekFromBegin(pos_t _size); - void SeekFromEnd(pos_t _size); - vint Read(void* _buffer, vint _size); - vint Write(void* _buffer, vint _size); - vint Peek(void* _buffer, vint _size); - }; - } -} - -#endif - -/*********************************************************************** -STREAM\CACHESTREAM.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Stream::CacheStream - -Interfaces: - CacheStream :缓冲流 -***********************************************************************/ - -#ifndef VCZH_STREAM_CACHESTREAM -#define VCZH_STREAM_CACHESTREAM - - -namespace vl -{ - namespace stream - { - /// - /// A cache stream. Features (readable, writable, seekable, peekable) are enabled according to the target stream. - /// When you read from the cache strema, it will read a specified size of content from the target stream first and cache, reducing the numbers of operations on the target stream. - /// When you write to the cache strema, it will save them to a buffer, and write to the target stream until the buffer reaches a specified size, reducing the numbers of operations on the target stream. - /// - class CacheStream : public Object, public virtual IStream - { - protected: - IStream* target; - vint block; - pos_t start; - pos_t position; - - char* buffer; - vint dirtyStart; - vint dirtyLength; - vint availableLength; - pos_t operatedSize; - - void Flush(); - void Load(pos_t _position); - vint InternalRead(void* _buffer, vint _size); - vint InternalWrite(void* _buffer, vint _size); - public: - /// Create a cache stream using a target stream. - /// The target stream. - /// Size of the cache. - CacheStream(IStream& _target, vint _block=65536); - ~CacheStream(); - - bool CanRead()const; - bool CanWrite()const; - bool CanSeek()const; - bool CanPeek()const; - bool IsLimited()const; - bool IsAvailable()const; - void Close(); - pos_t Position()const; - pos_t Size()const; - void Seek(pos_t _size); - void SeekFromBegin(pos_t _size); - void SeekFromEnd(pos_t _size); - vint Read(void* _buffer, vint _size); - vint Write(void* _buffer, vint _size); - vint Peek(void* _buffer, vint _size); - }; - } -} - -#endif - -/*********************************************************************** -STREAM\RECORDERSTREAM.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Stream::RecorderStream - -Interfaces: - RecorderStream :备份流 -***********************************************************************/ - -#ifndef VCZH_STREAM_RECORDERSTREAM -#define VCZH_STREAM_RECORDERSTREAM - - -namespace vl -{ - namespace stream - { - /// A readable stream that, read from an stream, and write everything that is read to another stream. - class RecorderStream : public Object, public virtual IStream - { - protected: - IStream* in; - IStream* out; - public: - /// Create a stream. - /// The stream to read. - /// The stream to write what is read from "_in". - RecorderStream(IStream& _in, IStream& _out); - ~RecorderStream(); - - bool CanRead()const; - bool CanWrite()const; - bool CanSeek()const; - bool CanPeek()const; - bool IsLimited()const; - bool IsAvailable()const; - void Close(); - pos_t Position()const; - pos_t Size()const; - void Seek(pos_t _size); - void SeekFromBegin(pos_t _size); - void SeekFromEnd(pos_t _size); - vint Read(void* _buffer, vint _size); - vint Write(void* _buffer, vint _size); - vint Peek(void* _buffer, vint _size); - }; - } -} - -#endif - -/*********************************************************************** -UNITTEST\UNITTEST.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -UI::Console - -***********************************************************************/ - -#ifndef VCZH_UNITTEST -#define VCZH_UNITTEST - - -class UnitTestError -{ -}; - -namespace vl -{ - namespace unittest - { - /// ) - /// { - /// - /// - /// - /// - /// } - /// You should call [M:vl.unittest.UnitTest.RunAndDisposeTests] in your main function to run all test cases. - /// ]]> - class UnitTest abstract - { - public: - typedef void(*TestProc)(); - - /// Print a green message. - /// The content. - static void PrintMessage(const WString& string); - - /// Print a white information. - /// The content. - static void PrintInfo(const WString& string); - - /// Print a red error. - /// The content. - static void PrintError(const WString& string); - - static void PushTest(TestProc testProc); - - /// Run all test cases. - static void RunAndDisposeTests(); - }; - -#define TEST_CHECK_ERROR(CONDITION,DESCRIPTION) do{if(!(CONDITION))throw Error(DESCRIPTION);}while(0) -#define TEST_ASSERT(CONDITION) do{TEST_CHECK_ERROR(CONDITION,L"");}while(0) -#define TEST_ERROR(CONDITION) do{try{CONDITION;throw UnitTestError();}catch(const Error&){}catch(const UnitTestError&){TEST_CHECK_ERROR(false,L"");}}while(0) -#define TEST_CASE(NAME)\ - extern void TESTCASE_##NAME(); \ - namespace vl_unittest_executors \ - { \ - class TESTCASE_RUNNER_##NAME \ - { \ - public: \ - static void RunUnitTest() \ - { \ - vl::unittest::UnitTest::PrintMessage(L_(#NAME)); \ - TESTCASE_##NAME(); \ - } \ - TESTCASE_RUNNER_##NAME() \ - { \ - vl::unittest::UnitTest::PushTest(&TESTCASE_RUNNER_##NAME::RunUnitTest); \ - } \ - } TESTCASE_RUNNER_##NAME##_INSTANCE; \ - } \ - void TESTCASE_##NAME() -#define TEST_PRINT(x) vl::unittest::UnitTest::PrintInfo(x) -#define TEST_EXCEPTION(STATEMENT,EXCEPTION,ASSERT_FUNCTION) try{STATEMENT; TEST_ASSERT(false);}catch(const EXCEPTION& e){ASSERT_FUNCTION(e);} - } -} - -#endif - -/*********************************************************************** -LAZY.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Framework::Lazy Evaluation - -Classes: - Lazy :惰性对象 - -***********************************************************************/ - -#ifndef VCZH_LAZY -#define VCZH_LAZY - - -namespace vl -{ - /// A type representing a lazy evaluation. - /// The type of the evaluation result. - template - class Lazy : public Object - { - protected: - class Internal - { - public: - Func evaluator; - T value; - bool evaluated; - }; - - Ptr internalValue; - public: - /// Create an empty evaluation. - Lazy() - { - } - - /// Create an evaluation using a function. - /// The function. - Lazy(const Func& evaluator) - { - internalValue=new Internal; - internalValue->evaluated=false; - internalValue->evaluator=evaluator; - } - - /// Create an evaluation using the result directly. - /// The result that you have already known.0 - Lazy(const T& value) - { - internalValue=new Internal; - internalValue->evaluated=true; - internalValue->value=value; - } - - /// Copy an evaluation. - /// The evaluation to copy. - Lazy(const Lazy& lazy) - :internalValue(lazy.internalValue) - { - } - - Lazy& operator=(const Func& evaluator) - { - internalValue=new Internal; - internalValue->evaluated=false; - internalValue->evaluator=evaluator; - return *this; - } - - Lazy& operator=(const T& value) - { - internalValue=new Internal; - internalValue->evaluated=true; - internalValue->value=value; - return *this; - } - - Lazy& operator=(const Lazy& lazy) - { - internalValue=lazy.internalValue; - return *this; - } - - /// Get the evaluation result. If it has not been calculated yet, it will run the evaluation and cache the result. You will not need to calculate for the second time. - /// The evaluation result. - const T& Value()const - { - if(!internalValue->evaluated) - { - internalValue->evaluated=true; - internalValue->value=internalValue->evaluator(); - internalValue->evaluator=Func(); - } - return internalValue->value; - } - - /// Test if it has already been evaluated or not. - /// Returns true if it has already been evaluated. - const bool IsEvaluated()const - { - return internalValue->evaluated; - } - - /// Test if it is an empty evaluation or not. - /// Returns true if it is not empty. - const bool IsAvailable()const - { - return internalValue; - } - }; -} - -#endif - -/*********************************************************************** -TUPLE.H +.\TUPLE.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -19690,6 +19619,8 @@ This file is generated by: Vczh Functional Macro ***********************************************************************/ #ifndef VCZH_TUPLE #define VCZH_TUPLE + + namespace vl { class TupleNullItem @@ -20022,3 +19953,90 @@ vl::Tuple } #endif + +/*********************************************************************** +.\UNITTEST\UNITTEST.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +UI::Console + +***********************************************************************/ + +#ifndef VCZH_UNITTEST +#define VCZH_UNITTEST + + +class UnitTestError +{ +}; + +namespace vl +{ + namespace unittest + { + /// ) + /// { + /// + /// + /// + /// + /// } + /// You should call [M:vl.unittest.UnitTest.RunAndDisposeTests] in your main function to run all test cases. + /// ]]> + class UnitTest abstract + { + public: + typedef void(*TestProc)(); + + /// Print a green message. + /// The content. + static void PrintMessage(const WString& string); + + /// Print a white information. + /// The content. + static void PrintInfo(const WString& string); + + /// Print a red error. + /// The content. + static void PrintError(const WString& string); + + static void PushTest(TestProc testProc); + + /// Run all test cases. + static void RunAndDisposeTests(); + }; + +#define TEST_CHECK_ERROR(CONDITION,DESCRIPTION) do{if(!(CONDITION))throw Error(DESCRIPTION);}while(0) +#define TEST_ASSERT(CONDITION) do{TEST_CHECK_ERROR(CONDITION,L"");}while(0) +#define TEST_ERROR(CONDITION) do{try{CONDITION;throw UnitTestError();}catch(const Error&){}catch(const UnitTestError&){TEST_CHECK_ERROR(false,L"");}}while(0) +#define TEST_CASE(NAME)\ + extern void TESTCASE_##NAME(); \ + namespace vl_unittest_executors \ + { \ + class TESTCASE_RUNNER_##NAME \ + { \ + public: \ + static void RunUnitTest() \ + { \ + vl::unittest::UnitTest::PrintMessage(L_(#NAME)); \ + TESTCASE_##NAME(); \ + } \ + TESTCASE_RUNNER_##NAME() \ + { \ + vl::unittest::UnitTest::PushTest(&TESTCASE_RUNNER_##NAME::RunUnitTest); \ + } \ + } TESTCASE_RUNNER_##NAME##_INSTANCE; \ + } \ + void TESTCASE_##NAME() +#define TEST_PRINT(x) vl::unittest::UnitTest::PrintInfo(x) +#define TEST_EXCEPTION(STATEMENT,EXCEPTION,ASSERT_FUNCTION) try{STATEMENT; TEST_ASSERT(false);}catch(const EXCEPTION& e){ASSERT_FUNCTION(e);} + } +} + +#endif + diff --git a/Import/VlppWorkflow.cpp b/Import/VlppWorkflow.cpp index b815d8f4..4e511bd4 100644 --- a/Import/VlppWorkflow.cpp +++ b/Import/VlppWorkflow.cpp @@ -5,7 +5,7 @@ DEVELOPER: Zihan Chen(vczh) #include "VlppWorkflow.h" /*********************************************************************** -.CPP +.\WFRUNTIME.CPP ***********************************************************************/ namespace vl @@ -559,7 +559,7 @@ WfRuntimeThreadContext } /*********************************************************************** -ASSEMBLY.CPP +.\WFRUNTIMEASSEMBLY.CPP ***********************************************************************/ namespace vl @@ -2228,8 +2228,9 @@ WfAssembly } } + /*********************************************************************** -CONSTRUCTIONS.CPP +.\WFRUNTIMECONSTRUCTIONS.CPP ***********************************************************************/ namespace vl @@ -2313,7 +2314,7 @@ WfRuntimeInterfaceInstance } /*********************************************************************** -DEBUGGER.CPP +.\WFRUNTIMEDEBUGGER.CPP ***********************************************************************/ #include @@ -3073,7 +3074,7 @@ Helper Functions } /*********************************************************************** -EXECUTION.CPP +.\WFRUNTIMEEXECUTION.CPP ***********************************************************************/ namespace vl @@ -4319,7 +4320,7 @@ WfRuntimeThreadContext } /*********************************************************************** -INSTRUCTION.CPP +.\WFRUNTIMEINSTRUCTION.CPP ***********************************************************************/ namespace vl @@ -4510,8 +4511,9 @@ WfInstruction } } + /*********************************************************************** -TYPEDESCRIPTOR.CPP +.\WFRUNTIMETYPEDESCRIPTOR.CPP ***********************************************************************/ namespace vl diff --git a/Import/VlppWorkflow.h b/Import/VlppWorkflow.h index 4a59b8bd..a41ccf1d 100644 --- a/Import/VlppWorkflow.h +++ b/Import/VlppWorkflow.h @@ -5,7 +5,7 @@ DEVELOPER: Zihan Chen(vczh) #include "Vlpp.h" /*********************************************************************** -INSTRUCTION.H +.\WFRUNTIMEINSTRUCTION.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -267,8 +267,9 @@ Instruction #endif + /*********************************************************************** -TYPEDESCRIPTOR.H +.\WFRUNTIMETYPEDESCRIPTOR.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -800,8 +801,9 @@ Plugin #endif + /*********************************************************************** -ASSEMBLY.H +.\WFRUNTIMEASSEMBLY.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -895,8 +897,9 @@ Assembly #endif + /*********************************************************************** -CONSTRUCTIONS.H +.\WFRUNTIMECONSTRUCTIONS.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -1013,8 +1016,9 @@ InterfaceInstance #endif + /*********************************************************************** -DEBUGGER.H +.\WFRUNTIMEDEBUGGER.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -1373,8 +1377,9 @@ Debugger #endif + /*********************************************************************** -.H +.\WFRUNTIME.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -1664,3 +1669,4 @@ Helper Functions } #endif + diff --git a/Import/VlppWorkflowCompiler.cpp b/Import/VlppWorkflowCompiler.cpp index 8ec5ab64..eb21ddc0 100644 --- a/Import/VlppWorkflowCompiler.cpp +++ b/Import/VlppWorkflowCompiler.cpp @@ -5,23106 +5,7 @@ DEVELOPER: Zihan Chen(vczh) #include "VlppWorkflowCompiler.h" /*********************************************************************** -ANALYZER\WFANALYZER.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace analyzer - { - using namespace collections; - using namespace reflection::description; - -/*********************************************************************** -WfLexicalSymbol -***********************************************************************/ - - WfLexicalSymbol::WfLexicalSymbol(WfLexicalScope* _ownerScope) - :ownerScope(_ownerScope) - { - } - - WfLexicalSymbol::~WfLexicalSymbol() - { - } - - WString WfLexicalSymbol::GetFriendlyName() - { - return ownerScope->GetFriendlyName() + L"::" + name; - } - -/*********************************************************************** -WfLexicalScope -***********************************************************************/ - - WfLexicalScope::WfLexicalScope(WfLexicalScopeManager* _ownerManager) - :ownerManager(_ownerManager) - { - } - - WfLexicalScope::WfLexicalScope(Ptr _parentScope) - :ownerManager(0) - , parentScope(_parentScope) - { - } - - WfLexicalScope::~WfLexicalScope() - { - } - - WfLexicalScopeManager* WfLexicalScope::FindManager() - { - WfLexicalScope* scope = this; - while (scope) - { - if (scope->ownerManager) - { - return scope->ownerManager; - } - scope = scope->parentScope.Obj(); - } - return 0; - } - - Ptr WfLexicalScope::FindModule() - { - WfLexicalScope* scope = this; - while (scope) - { - if (auto module = scope->ownerNode.Cast()) - { - return module; - } - scope = scope->parentScope.Obj(); - } - return 0; - } - - WfLexicalScope* WfLexicalScope::FindFunctionScope() - { - auto scope = this; - while (scope) - { - if (scope->functionConfig) - { - return scope; - } - scope = scope->parentScope.Obj(); - } - return nullptr; - } - - WString WfLexicalScope::GetFriendlyName() - { - if (auto module = ownerNode.Cast()) - { - return L"<" + module->name.value + L">"; - } - else if (auto decl = ownerNode.Cast()) - { - auto name = decl->name.value; - if (name == L"") - { - name = L""; - } - return parentScope->GetFriendlyName() + L"::" + name; - } - else if (!parentScope) - { - return L""; - } - else - { - return parentScope->GetFriendlyName() + L"::<>"; - } - } - - Ptr WfLexicalScope::GetOwnerClassMember() - { - if (auto decl = ownerNode.Cast()) - { - return decl->classMember; - } - return nullptr; - } - -/*********************************************************************** -WfLexicalScopeName -***********************************************************************/ - - WfLexicalScopeName::WfLexicalScopeName(bool _imported) - :imported(_imported) - { - } - - WfLexicalScopeName::~WfLexicalScopeName() - { - } - - Ptr WfLexicalScopeName::AccessChild(const WString& name, bool imported) - { - vint index = children.Keys().IndexOf(name); - if (index == -1) - { - Ptr newName = new WfLexicalScopeName(imported); - newName->name = name; - newName->parent = this; - children.Add(name, newName); - return newName; - } - else - { - return children.Values()[index]; - } - } - - void WfLexicalScopeName::RemoveNonTypeDescriptorNames(WfLexicalScopeManager* manager) - { - FOREACH(Ptr, name, children.Values()) - { - name->RemoveNonTypeDescriptorNames(manager); - } - - for (vint i = children.Count() - 1; i >= 0; i--) - { - auto subScopeName = children.Values()[i]; - if (!subScopeName->imported) - { - children.Remove(children.Keys()[i]); - if (subScopeName->typeDescriptor) - { - manager->typeNames.Remove(subScopeName->typeDescriptor); - } - } - } - - declarations.Clear(); - } - - WString WfLexicalScopeName::GetFriendlyName() - { - if (parent) - { - WString parentName = parent->GetFriendlyName(); - if (parentName == L"") - { - return name; - } - else - { - return parentName + L"::" + name; - } - } - else - { - return L""; - } - } - -/*********************************************************************** -ResolveExpressionResult -***********************************************************************/ - - WString ResolveExpressionResult::GetFriendlyName(bool upperCase)const - { - WString typeName, result; - if (type) - { - typeName= + L" of type \"" + type->GetTypeFriendlyName() + L"\""; - } - - if (scopeName) - { - result = scopeName->GetFriendlyName(); - } - else if (symbol) - { - result = symbol->GetFriendlyName() + typeName; - } - else if (propertyInfo) - { - result = L"property \"" + propertyInfo->GetName() + L"\" in \"" + propertyInfo->GetOwnerTypeDescriptor()->GetTypeName() + L"\"" + typeName; - } - else if (methodInfo) - { - if (methodInfo->GetName() == L"") - { - result = L"constructor in \"" + methodInfo->GetOwnerTypeDescriptor()->GetTypeName() + L"\"" + typeName; - } - else - { - result = L"method \"" + methodInfo->GetName() + L"\" in \"" + methodInfo->GetOwnerTypeDescriptor()->GetTypeName() + L"\"" + typeName; - } - } - else if (eventInfo) - { - result = L"event \"" + eventInfo->GetName() + L"\" in \"" + eventInfo->GetOwnerTypeDescriptor()->GetTypeName() + L"\""; - } - else if (type) - { - result = L"expression" + typeName; - } - else - { - result = L""; - } - - if (result.Length() > 0 && upperCase) - { - result = INVLOC.ToUpper(result.Left(1)) + result.Right(result.Length() - 1); - } - return result; - } - - ResolveExpressionResult ResolveExpressionResult::ScopeName(Ptr _scopeName) - { - ResolveExpressionResult result; - result.scopeName = _scopeName; - return result; - } - - ResolveExpressionResult ResolveExpressionResult::ReadonlySymbol(Ptr _symbol) - { - ResolveExpressionResult result; - result.symbol = _symbol; - result.type = _symbol->typeInfo; - return result; - } - - ResolveExpressionResult ResolveExpressionResult::Symbol(Ptr _symbol) - { - ResolveExpressionResult result; - result.symbol = _symbol; - result.type = _symbol->typeInfo; - if (_symbol->creatorNode.Cast()) - { - result.writableType = _symbol->typeInfo; - } - return result; - } - - ResolveExpressionResult ResolveExpressionResult::ReadonlyType(Ptr _type) - { - ResolveExpressionResult result; - result.type = _type; - return result; - } - - ResolveExpressionResult ResolveExpressionResult::WritableType(Ptr _type) - { - ResolveExpressionResult result; - result.type = _type; - result.writableType = _type; - return result; - } - - ResolveExpressionResult ResolveExpressionResult::Property(reflection::description::IPropertyInfo* _propertyInfo) - { - Ptr getterType = CopyTypeInfo(_propertyInfo->GetReturn()); - Ptr setterType; - - if (getterType) - { - if (IMethodInfo* setter = _propertyInfo->GetSetter()) - { - setterType = getterType; - if (setter->GetParameterCount() == 1 && !IsSameType(getterType.Obj(), setter->GetParameter(0)->GetType())) - { - setterType = CopyTypeInfo(setter->GetParameter(0)->GetType()); - } - } - else if (_propertyInfo->IsWritable()) - { - auto td = _propertyInfo->GetOwnerTypeDescriptor(); - if ((td->GetTypeDescriptorFlags() & TypeDescriptorFlags::ReferenceType) != TypeDescriptorFlags::Undefined) - { - setterType = CopyTypeInfo(_propertyInfo->GetReturn()); - } - } - } - - ResolveExpressionResult result; - result.propertyInfo = _propertyInfo; - result.type = getterType; - result.writableType = setterType; - return result; - } - - ResolveExpressionResult ResolveExpressionResult::Method(reflection::description::IMethodInfo* _methodInfo) - { - ResolveExpressionResult result; - result.methodInfo = _methodInfo; - result.type = CreateTypeInfoFromMethodInfo(_methodInfo); - return result; - } - - ResolveExpressionResult ResolveExpressionResult::Constructor(reflection::description::IMethodInfo* _constructorInfo) - { - ResolveExpressionResult result; - result.constructorInfo = _constructorInfo; - result.type = CopyTypeInfo(_constructorInfo->GetReturn()); - return result; - } - - ResolveExpressionResult ResolveExpressionResult::Event(reflection::description::IEventInfo* _eventInfo) - { - ResolveExpressionResult result; - result.eventInfo = _eventInfo; - return result; - } - - bool IsSameTypeOrNull(ITypeInfo* fromType, ITypeInfo* toType) - { - if (fromType == toType) return true; - if ((fromType == nullptr) ^ (toType == nullptr)) return false; - return IsSameType(fromType, toType); - } - - bool ResolveExpressionResult::operator==(const ResolveExpressionResult& result) const - { - if (scopeName != result.scopeName) return false; - if (symbol != result.symbol) return false; - if (propertyInfo != result.propertyInfo) return false; - if (methodInfo != result.methodInfo) return false; - if (constructorInfo != result.constructorInfo) return false; - if (eventInfo != result.eventInfo) return false; - - if (!IsSameTypeOrNull(type.Obj(), result.type.Obj())) return false; - if (!IsSameTypeOrNull(writableType.Obj(), result.writableType.Obj())) return false; - if (!IsSameTypeOrNull(expectedType.Obj(), result.expectedType.Obj())) return false; - return true; - } - - bool ResolveExpressionResult::operator!=(const ResolveExpressionResult& result) const - { - return !(*this == result); - } - -/*********************************************************************** -WfLexicalScopeManager -***********************************************************************/ - - WfLexicalScopeManager::WfLexicalScopeManager(Ptr _parsingTable) - :parsingTable(_parsingTable) - { - attributes.Add({ L"cpp", L"File" }, TypeInfoRetriver::CreateTypeInfo()); - attributes.Add({ L"cpp", L"UserImpl" }, TypeInfoRetriver::CreateTypeInfo()); - attributes.Add({ L"cpp", L"Private" }, TypeInfoRetriver::CreateTypeInfo()); - attributes.Add({ L"cpp", L"Protected" }, TypeInfoRetriver::CreateTypeInfo()); - attributes.Add({ L"cpp", L"Friend" }, TypeInfoRetriver::CreateTypeInfo()); - } - - WfLexicalScopeManager::~WfLexicalScopeManager() - { - } - - vint WfLexicalScopeManager::AddModule(const WString& moduleCode) - { - if (auto module = WfParseModule(moduleCode, parsingTable, errors, usedCodeIndex)) - { - modules.Add(module); - moduleCodes.Add(moduleCode); - } - return usedCodeIndex++; - } - - vint WfLexicalScopeManager::AddModule(Ptr module) - { - module->codeRange.codeIndex = usedCodeIndex; - modules.Add(module); - moduleCodes.Add(L""); - return usedCodeIndex++; - } - - WfLexicalScopeManager::ModuleList& WfLexicalScopeManager::GetModules() - { - return modules; - } - - WfLexicalScopeManager::ModuleCodeList& WfLexicalScopeManager::GetModuleCodes() - { - return moduleCodes; - } - - void WfLexicalScopeManager::Clear(bool keepTypeDescriptorNames, bool deleteModules) - { - if (globalName) - { - if (keepTypeDescriptorNames) - { - globalName->RemoveNonTypeDescriptorNames(this); - } - else - { - globalName = 0; - typeNames.Clear(); - } - } - - if (deleteModules) - { - modules.Clear(); - moduleCodes.Clear(); - usedCodeIndex = 0; - usedTempVars = 0; - } - - errors.Clear(); - namespaceNames.Clear(); - - nodeScopes.Clear(); - expressionResolvings.Clear(); - lambdaCaptures.Clear(); - interfaceMethodImpls.Clear(); - declarationTypes.Clear(); - declarationMemberInfos.Clear(); - baseConstructorCallResolvings.Clear(); - } - -#define CALLBACK(EXPR) if (callback) callback->EXPR - - void WfLexicalScopeManager::Rebuild(bool keepTypeDescriptorNames, IWfCompilerCallback* callback) - { - CALLBACK(OnLoadEnvironment()); - Clear(keepTypeDescriptorNames, false); - if (!globalName) - { - globalName = new WfLexicalScopeName(true); - BuildGlobalNameFromTypeDescriptors(this); - } - - CALLBACK(OnInitialize(this)); - vint errorCount = errors.Count(); - -#define EXIT_IF_ERRORS_EXIST\ - do\ - {\ - if (errors.Count() != errorCount) return;\ - }while (0) - - EXIT_IF_ERRORS_EXIST; - FOREACH(Ptr, module, modules) - { - ContextFreeModuleDesugar(this, module); - ValidateModuleStructure(this, module); - } - - EXIT_IF_ERRORS_EXIST; - BuildGlobalNameFromModules(this); - FOREACH(Ptr, module, modules) - { - BuildScopeForModule(this, module); - } - ValidateScopeName(this, globalName); - CheckScopes_DuplicatedSymbol(this); - - EXIT_IF_ERRORS_EXIST; - FOREACH(Ptr, module, modules) - { - CompleteScopeForModule(this, module); - } - CheckScopes_BaseType(this); - CheckScopes_SymbolType(this); - - EXIT_IF_ERRORS_EXIST; - FOREACH(Ptr, module, modules) - { - CALLBACK(OnValidateModule(module)); - ValidateModuleSemantic(this, module); - } - -#undef EXIT_IF_ERRORS_EXIST - } - -#undef CALLBACK - - bool WfLexicalScopeManager::ResolveMember(ITypeDescriptor* typeDescriptor, const WString& name, bool preferStatic, collections::SortedList& searchedTypes, collections::List& results) - { - if (searchedTypes.Contains(typeDescriptor)) - { - return true; - } - searchedTypes.Add(typeDescriptor); - - bool found = false; - bool foundStaticMember = false; - - - if ((typeDescriptor->GetTypeDescriptorFlags() & TypeDescriptorFlags::EnumType) != TypeDescriptorFlags::Undefined) - { - if (preferStatic) - { - auto enumType = typeDescriptor->GetEnumType(); - vint index = enumType->IndexOfItem(name); - if (index != -1) - { - results.Add(ResolveExpressionResult::ReadonlyType(MakePtr(typeDescriptor, TypeInfoHint::Normal))); - return true; - } - } - return false; - } - - { - auto scopeName = typeNames[typeDescriptor]; - vint index = scopeName->children.Keys().IndexOf(name); - if (index != -1) - { - auto subScopeName = scopeName->children.Values()[index]; - found = true; - foundStaticMember = true; - results.Add(ResolveExpressionResult::ScopeName(subScopeName)); - } - } - - if (auto group = typeDescriptor->GetMethodGroupByName(name, false)) - { - for (vint i = 0; i < group->GetMethodCount(); i++) - { - auto info = group->GetMethod(i); - if (info->IsStatic()) - { - found = true; - foundStaticMember = true; - results.Add(ResolveExpressionResult::Method(info)); - } - } - } - - if (foundStaticMember && preferStatic) - { - return true; - } - - if (auto group = typeDescriptor->GetMethodGroupByName(name, false)) - { - for (vint i = 0; i < group->GetMethodCount(); i++) - { - auto info = group->GetMethod(i); - if (!info->IsStatic()) - { - found = true; - results.Add(ResolveExpressionResult::Method(info)); - } - } - } - if (auto info = typeDescriptor->GetPropertyByName(name, false)) - { - found = true; - results.Add(ResolveExpressionResult::Property(info)); - } - if (auto info = typeDescriptor->GetEventByName(name, false)) - { - found = true; - results.Add(ResolveExpressionResult::Event(info)); - } - - if (!found) - { - vint count = typeDescriptor->GetBaseTypeDescriptorCount(); - for (vint i = 0; i < count; i++) - { - if (ResolveMember(typeDescriptor->GetBaseTypeDescriptor(i), name, preferStatic, searchedTypes, results)) - { - found = true; - } - } - } - return found; - } - - class UsingPathToNameVisitor :public Object, public WfModuleUsingFragment::IVisitor - { - public: - WString name; - WString result; - - UsingPathToNameVisitor(const WString& _name) - :name(_name) - { - } - - void Visit(WfModuleUsingNameFragment* node) - { - result = node->name.value; - } - - void Visit(WfModuleUsingWildCardFragment* node) - { - result = name; - } - - static WString Execute(Ptr fragment, const WString& name) - { - UsingPathToNameVisitor visitor(name); - fragment->Accept(&visitor); - return visitor.result; - } - }; - - bool WfLexicalScopeManager::ResolveName(WfLexicalScope* scope, const WString& name, collections::List& results) - { - vint oldResultCount = results.Count(); - bool visibleToNonStatic = false; - WfLexicalScope* firstConfigScope = nullptr; - while (scope) - { - if (scope->ownerNode.Cast() || scope->ownerNode.Cast()) - { - break; - } - - if (scope->functionConfig) - { - visibleToNonStatic = scope->functionConfig->thisAccessable || scope->functionConfig->parentThisAccessable; - if (!firstConfigScope) - { - firstConfigScope = scope; - } - } - - vint index = scope->symbols.Keys().IndexOf(name); - if (index != -1) - { - if (scope->typeOfThisExpr) - { - if (scope->ownerNode.Cast()) - { - FOREACH(Ptr, symbol, scope->symbols.GetByIndex(index)) - { - if (symbol->creatorNode.Cast()) - { - auto result = ResolveExpressionResult::Symbol(symbol); - if (!results.Contains(result)) - { - results.Add(result); - } - } - else if (symbol->creatorNode.Cast()->classMember->kind == WfClassMemberKind::Normal) - { - if (firstConfigScope->parentScope == scope) - { - auto result = ResolveExpressionResult::Symbol(symbol); - if (!results.Contains(result)) - { - results.Add(result); - } - } - } - } - } - } - else - { - FOREACH(Ptr, symbol, scope->symbols.GetByIndex(index)) - { - auto result = ResolveExpressionResult::Symbol(symbol); - if (!results.Contains(result)) - { - results.Add(result); - } - } - } - } - - if (scope->typeOfThisExpr) - { - SortedList searchedTypes; - ResolveMember(scope->typeOfThisExpr, name, !visibleToNonStatic, searchedTypes, results); - } - - scope = scope->parentScope.Obj(); - } - - while (scope) - { - if (auto nsDecl = scope->ownerNode.Cast()) - { - auto scopeName = namespaceNames[nsDecl.Obj()]; - vint index = scopeName->children.Keys().IndexOf(name); - if (index != -1) - { - auto subScopeName = scopeName->children.Values()[index]; - auto result = ResolveExpressionResult::ScopeName(subScopeName); - if (!results.Contains(result)) - { - results.Add(result); - } - } - scope = scope->parentScope.Obj(); - } - else - { - break; - } - } - - vint index = globalName->children.Keys().IndexOf(name); - if (index != -1) - { - auto subScopeName = globalName->children.Values()[index]; - auto result = ResolveExpressionResult::ScopeName(subScopeName); - if (!results.Contains(result)) - { - results.Add(result); - } - } - - if (auto module = scope->ownerNode.Cast()) - { - FOREACH(Ptr, path, module->paths) - { - auto scopeName = globalName; - FOREACH(Ptr, item, path->items) - { - WString fragmentName; - FOREACH(Ptr, fragment, item->fragments) - { - fragmentName += UsingPathToNameVisitor::Execute(fragment, name); - } - vint index = scopeName->children.Keys().IndexOf(fragmentName); - if (index == -1) goto USING_PATH_MATCHING_FAILED; - scopeName = scopeName->children.Values()[index]; - } - - { - auto result = ResolveExpressionResult::ScopeName(scopeName); - if (!results.Contains(result)) - { - results.Add(result); - } - } - USING_PATH_MATCHING_FAILED:; - } - } - - return results.Count() > oldResultCount; - } - - Ptr WfLexicalScopeManager::GetDeclarationSymbol(WfLexicalScope* scope, WfDeclaration* node) - { - auto symbol = From(scope->parentScope->symbols[node->name.value]) - .Where([=](Ptr symbol) - { - return symbol->creatorNode == node; - }) - .First(); - return symbol; - } - - void WfLexicalScopeManager::CreateLambdaCapture(parsing::ParsingTreeCustomBase* node, Ptr capture) - { - if (!capture) - { - capture = MakePtr(); - } - lambdaCaptures.Add(node, capture); - } - } - } -} - -/*********************************************************************** -ANALYZER\WFANALYZER_BUILDGLOBALNAME.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace analyzer - { - using namespace collections; - using namespace reflection::description; - using namespace typeimpl; - -/*********************************************************************** -BuildGlobalNameFromTypeDescriptors -***********************************************************************/ - - void BuildGlobalNameFromTypeDescriptors(WfLexicalScopeManager* manager) - { - for (vint i = 0; i < GetGlobalTypeManager()->GetTypeDescriptorCount(); i++) - { - ITypeDescriptor* typeDescriptor = GetGlobalTypeManager()->GetTypeDescriptor(i); - WString name = typeDescriptor->GetTypeName(); - const wchar_t* reading = name.Buffer(); - Ptr currentName = manager->globalName; - - while (true) - { - WString fragment; - const wchar_t* delimiter = wcsstr(reading, L"::"); - if (delimiter) - { - fragment = WString(reading, vint(delimiter - reading)); - reading = delimiter + 2; - } - else - { - fragment = reading; - reading = 0; - } - - currentName = currentName->AccessChild(fragment, true); - if (!reading) - { - currentName->typeDescriptor = typeDescriptor; - manager->typeNames.Add(typeDescriptor, currentName); - break; - } - } - } - } - -/*********************************************************************** -BuildGlobalNameFromModules -***********************************************************************/ - - class BuildClassMemberVisitor : public Object, public WfDeclaration::IVisitor - { - public: - WfLexicalScopeManager* manager; - Ptr scopeName; - Ptr classDecl; - Ptr td; - - BuildClassMemberVisitor(WfLexicalScopeManager* _manager, Ptr _scopeName, Ptr _classDecl, Ptr _td) - :manager(_manager) - , scopeName(_scopeName) - , classDecl(_classDecl) - , td(_td) - { - } - - static WString GetTypeName(WfLexicalScopeManager* manager, Ptr scopeName) - { - WString typeName = scopeName->name; - { - WfLexicalScopeName* name = scopeName->parent; - while (name && name != manager->globalName.Obj()) - { - typeName = name->name + L"::" + typeName; - name = name->parent; - } - } - return typeName; - } - - static void AddCustomType(WfLexicalScopeManager* manager, Ptr scopeName, Ptr declaration, Ptr td) - { - manager->declarationTypes.Add(declaration, td); - - if (!scopeName->typeDescriptor) - { - scopeName->typeDescriptor = td.Obj(); - manager->typeNames.Add(td.Obj(), scopeName); - } - } - - static void BuildClass(WfLexicalScopeManager* manager, Ptr scopeName, Ptr declaration) - { - WString typeName = GetTypeName(manager, scopeName); - Ptr td; - switch (declaration->kind) - { - case WfClassKind::Class: - td = MakePtr(typeName); - break; - case WfClassKind::Interface: - td = MakePtr(typeName); - break; - } - AddCustomType(manager, scopeName, declaration, td); - - FOREACH(Ptr, memberDecl, declaration->declarations) - { - BuildClassMemberVisitor visitor(manager, scopeName, declaration, td); - memberDecl->Accept(&visitor); - } - } - - void Visit(WfNamespaceDeclaration* node)override - { - } - - void Visit(WfFunctionDeclaration* node)override - { - if (node->classMember->kind == WfClassMemberKind::Static) - { - auto info = MakePtr(); - td->AddMember(node->name.value, info); - manager->declarationMemberInfos.Add(node, info); - } - else - { - switch (classDecl->kind) - { - case WfClassKind::Class: - { - auto info = MakePtr(); - td->AddMember(node->name.value, info); - manager->declarationMemberInfos.Add(node, info); - } - break; - case WfClassKind::Interface: - { - auto info = MakePtr(); - td->AddMember(node->name.value, info); - manager->declarationMemberInfos.Add(node, info); - } - break; - } - } - } - - void Visit(WfVariableDeclaration* node)override - { - auto info = MakePtr(td.Obj(), node->name.value); - td->AddMember(info); - manager->declarationMemberInfos.Add(node, info); - } - - void Visit(WfEventDeclaration* node)override - { - auto info = MakePtr(td.Obj(), node->name.value); - td->AddMember(info); - manager->declarationMemberInfos.Add(node, info); - } - - void Visit(WfPropertyDeclaration* node)override - { - auto info = MakePtr(td.Obj(), node->name.value); - td->AddMember(info); - manager->declarationMemberInfos.Add(node, info); - } - - void Visit(WfConstructorDeclaration* node)override - { - Ptr typeInfo; - { - auto elementType = MakePtr(td.Obj(), TypeInfoHint::Normal); - if (node->constructorType == WfConstructorType::RawPtr) - { - typeInfo = MakePtr(elementType); - } - else - { - typeInfo = MakePtr(elementType); - } - } - - auto info = MakePtr(typeInfo); - td->AddMember(info); - manager->declarationMemberInfos.Add(node, info); - } - - void Visit(WfDestructorDeclaration* node)override - { - } - - void Visit(WfClassDeclaration* node)override - { - auto newScopeName = scopeName->AccessChild(node->name.value, false); - newScopeName->declarations.Add(node); - BuildClass(manager, newScopeName, node); - } - - void Visit(WfEnumDeclaration* node)override - { - BuildNameForDeclaration(manager, scopeName, node); - } - - void Visit(WfStructDeclaration* node)override - { - BuildNameForDeclaration(manager, scopeName, node); - } - - void Visit(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - }; - - class BuildNameDeclarationVisitor - : public empty_visitor::DeclarationVisitor - { - public: - WfLexicalScopeManager* manager; - Ptr scopeName; - - BuildNameDeclarationVisitor(WfLexicalScopeManager* _manager, Ptr _scopeName) - :manager(_manager) - , scopeName(_scopeName) - { - } - - void Dispatch(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - - void Visit(WfNamespaceDeclaration* node)override - { - manager->namespaceNames.Add(node, scopeName); - FOREACH(Ptr, subDecl, node->declarations) - { - BuildNameForDeclaration(manager, scopeName, subDecl.Obj()); - } - } - - void Visit(WfClassDeclaration* node)override - { - BuildClassMemberVisitor::BuildClass(manager, scopeName, node); - } - - void Visit(WfEnumDeclaration* node)override - { - auto td = MakePtr(node->kind == WfEnumKind::Flag, BuildClassMemberVisitor::GetTypeName(manager, scopeName)); - BuildClassMemberVisitor::AddCustomType(manager, scopeName, node, td); - } - - void Visit(WfStructDeclaration* node)override - { - auto td = MakePtr(BuildClassMemberVisitor::GetTypeName(manager, scopeName)); - BuildClassMemberVisitor::AddCustomType(manager, scopeName, node, td); - } - }; - - void BuildNameForDeclaration(WfLexicalScopeManager* manager, Ptr name, WfDeclaration* decl) - { - auto scopeName = name->AccessChild(decl->name.value, false); - scopeName->declarations.Add(decl); - - BuildNameDeclarationVisitor visitor(manager, scopeName); - decl->Accept(&visitor); - } - - void BuildGlobalNameFromModules(WfLexicalScopeManager* manager) - { - FOREACH(Ptr, module, manager->GetModules()) - { - FOREACH(Ptr, decl, module->declarations) - { - BuildNameForDeclaration(manager, manager->globalName, decl.Obj()); - } - } - } - -/*********************************************************************** -ValidateScopeName -***********************************************************************/ - - class ValidateScopeNameDeclarationVisitor - : public Object - , public WfDeclaration::IVisitor - { - public: - enum Category - { - None, - Type, - Variable, - Function, - Event, - Property, - Namespace, - }; - - WfLexicalScopeManager* manager; - Ptr name; - Category category; - - ValidateScopeNameDeclarationVisitor(WfLexicalScopeManager* _manager, Ptr _name) - :manager(_manager) - , name(_name) - , category(name->typeDescriptor && name->imported ? Type : None) - { - } - - void AddError(WfDeclaration* node) - { - WString categoryName; - switch (category) - { - case Type: - categoryName = L"type"; - break; - case Variable: - categoryName = L"variable"; - break; - case Function: - categoryName = L"function"; - break; - case Event: - categoryName = L"event"; - break; - case Property: - categoryName = L"property"; - break; - case Namespace: - categoryName = L"namespace"; - break; - default: - CHECK_FAIL(L"ValidateScopeNameDeclarationVisitor::AddError(WfDeclaration*)#Internal error."); - } - manager->errors.Add(WfErrors::DuplicatedDeclaration(node, categoryName)); - } - - void Visit(WfNamespaceDeclaration* node)override - { - if (category == None) - { - category = Namespace; - } - else if (category != Namespace) - { - AddError(node); - } - } - - void Visit(WfFunctionDeclaration* node)override - { - if (category == None) - { - category = Function; - } - else if (category != Function) - { - AddError(node); - } - } - - void Visit(WfVariableDeclaration* node)override - { - if (category == None) - { - category = Variable; - } - else - { - AddError(node); - } - } - - void Visit(WfEventDeclaration* node)override - { - if (category == None) - { - category = Event; - } - else - { - AddError(node); - } - } - - void Visit(WfPropertyDeclaration* node)override - { - if (category == None) - { - category = Property; - } - else - { - AddError(node); - } - } - - void Visit(WfConstructorDeclaration* node)override - { - } - - void Visit(WfDestructorDeclaration* node)override - { - } - - void Visit(WfClassDeclaration* node)override - { - if (category == None) - { - category = Type; - } - else - { - AddError(node); - } - } - - void Visit(WfEnumDeclaration* node)override - { - if (category == None) - { - category = Type; - } - else - { - AddError(node); - } - } - - void Visit(WfStructDeclaration* node)override - { - if (category == None) - { - category = Type; - } - else - { - AddError(node); - } - } - - void Visit(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - }; - - void ValidateScopeName(WfLexicalScopeManager* manager, Ptr name) - { - ValidateScopeNameDeclarationVisitor visitor(manager, name); - FOREACH(Ptr, declaration, name->declarations) - { - declaration->Accept(&visitor); - } - - FOREACH(Ptr, child, name->children.Values()) - { - ValidateScopeName(manager, child); - } - } - } - } -} - -/*********************************************************************** -ANALYZER\WFANALYZER_BUILDSCOPE.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace analyzer - { - using namespace collections; - using namespace parsing; - using namespace reflection; - using namespace reflection::description; - using namespace typeimpl; - -/*********************************************************************** -BuildScopeForDeclaration -***********************************************************************/ - - class BuildScopeForDeclarationVisitor : public Object, public WfDeclaration::IVisitor - { - public: - WfLexicalScopeManager* manager; - ParsingTreeCustomBase* source; - Ptr parentScope; - - Ptr resultScope; - - BuildScopeForDeclarationVisitor(WfLexicalScopeManager* _manager, Ptr _parentScope, ParsingTreeCustomBase* _source) - :manager(_manager) - , source(_source) - , parentScope(_parentScope) - { - } - - void Visit(Ptr scope, List>& attributes) - { - FOREACH(Ptr, attribute, attributes) - { - if (attribute->value) - { - BuildScopeForExpression(manager, scope, attribute->value); - } - } - } - - void Visit(WfNamespaceDeclaration* node)override - { - Ptr symbol = new WfLexicalSymbol(parentScope.Obj()); - symbol->name = node->name.value; - symbol->creatorNode = node; - parentScope->symbols.Add(symbol->name, symbol); - - resultScope = new WfLexicalScope(parentScope); - FOREACH(Ptr, declaration, node->declarations) - { - BuildScopeForDeclaration(manager, resultScope, declaration, node); - } - } - - void Visit(WfFunctionDeclaration* node)override - { - resultScope = new WfLexicalScope(parentScope); - auto config = MakePtr(); - resultScope->functionConfig = config; - resultScope->ownerNodeSource = source; - - if (source) - { - if (dynamic_cast(source)) - { - config->lambda = true; - config->thisAccessable = false; - config->parentThisAccessable = true; - } - else if (dynamic_cast(source)) - { - config->lambda = true; - config->thisAccessable = true; - config->parentThisAccessable = true; - } - else if (dynamic_cast(source)) - { - config->lambda = false; - config->thisAccessable = node->classMember->kind != WfClassMemberKind::Static; - config->parentThisAccessable = false; - } - } - - if (node->anonymity == WfFunctionAnonymity::Named) - { - Ptr functionNameScope = parentScope; - if (source && dynamic_cast(source)) - { - functionNameScope = resultScope; - } - - Ptr symbol = new WfLexicalSymbol(functionNameScope.Obj()); - symbol->name = node->name.value; - symbol->creatorNode = node; - { - Ptr type = new WfFunctionType; - type->result = node->returnType; - FOREACH(Ptr, argument, node->arguments) - { - type->arguments.Add(argument->type); - } - symbol->type = type; - } - functionNameScope->symbols.Add(symbol->name, symbol); - } - - if (node->statement) - { - FOREACH(Ptr, argument, node->arguments) - { - Ptr argumentSymbol = new WfLexicalSymbol(resultScope.Obj()); - argumentSymbol->name = argument->name.value; - argumentSymbol->type = argument->type; - argumentSymbol->creatorNode = argument; - resultScope->symbols.Add(argumentSymbol->name, argumentSymbol); - - Visit(parentScope, argument->attributes); - } - - BuildScopeForStatement(manager, resultScope, node->statement); - } - } - - void Visit(WfVariableDeclaration* node)override - { - Ptr symbol = new WfLexicalSymbol(parentScope.Obj()); - symbol->name = node->name.value; - symbol->creatorNode = node; - symbol->type = node->type; - parentScope->symbols.Add(symbol->name, symbol); - - BuildScopeForExpression(manager, parentScope, node->expression); - } - - void Visit(WfEventDeclaration* node)override - { - Ptr symbol = new WfLexicalSymbol(parentScope.Obj()); - symbol->name = node->name.value; - symbol->creatorNode = node; - parentScope->symbols.Add(symbol->name, symbol); - } - - void Visit(WfPropertyDeclaration* node)override - { - Ptr symbol = new WfLexicalSymbol(parentScope.Obj()); - symbol->name = node->name.value; - symbol->creatorNode = node; - symbol->type = node->type; - parentScope->symbols.Add(symbol->name, symbol); - } - - void Visit(WfConstructorDeclaration* node)override - { - resultScope = new WfLexicalScope(parentScope); - - FOREACH(Ptr, argument, node->arguments) - { - Ptr argumentSymbol = new WfLexicalSymbol(resultScope.Obj()); - argumentSymbol->name = argument->name.value; - argumentSymbol->type = argument->type; - argumentSymbol->creatorNode = argument; - resultScope->symbols.Add(argumentSymbol->name, argumentSymbol); - } - - FOREACH(Ptr, call, node->baseConstructorCalls) - { - FOREACH(Ptr, argument, call->arguments) - { - BuildScopeForExpression(manager, resultScope, argument); - } - } - - auto bodyScope = MakePtr(resultScope); - { - auto config = MakePtr(); - bodyScope->functionConfig = config; - - config->lambda = false; - config->thisAccessable = true; - config->parentThisAccessable = false; - } - BuildScopeForStatement(manager, bodyScope, node->statement); - } - - void Visit(WfDestructorDeclaration* node)override - { - resultScope = new WfLexicalScope(parentScope); - { - auto config = MakePtr(); - resultScope->functionConfig = config; - - config->lambda = false; - config->thisAccessable = true; - config->parentThisAccessable = false; - } - BuildScopeForStatement(manager, resultScope, node->statement); - } - - void Visit(WfClassDeclaration* node)override - { - Ptr symbol = new WfLexicalSymbol(parentScope.Obj()); - symbol->name = node->name.value; - symbol->creatorNode = node; - parentScope->symbols.Add(symbol->name, symbol); - - auto td = manager->declarationTypes[node]; - resultScope = new WfLexicalScope(parentScope); - resultScope->typeOfThisExpr = td.Obj(); - FOREACH(Ptr, memberDecl, node->declarations) - { - BuildScopeForDeclaration(manager, resultScope, memberDecl, node); - } - } - - void Visit(WfEnumDeclaration* node)override - { - Ptr symbol = new WfLexicalSymbol(parentScope.Obj()); - symbol->name = node->name.value; - symbol->creatorNode = node; - parentScope->symbols.Add(symbol->name, symbol); - - FOREACH(Ptr, item, node->items) - { - Visit(parentScope, item->attributes); - } - } - - void Visit(WfStructDeclaration* node)override - { - Ptr symbol = new WfLexicalSymbol(parentScope.Obj()); - symbol->name = node->name.value; - symbol->creatorNode = node; - parentScope->symbols.Add(symbol->name, symbol); - - FOREACH(Ptr, member, node->members) - { - Visit(parentScope, member->attributes); - } - } - - void Visit(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - Execute(manager, parentScope, source, decl); - } - } - - static Ptr Execute(WfLexicalScopeManager* manager, Ptr parentScope, ParsingTreeCustomBase* source, Ptr declaration) - { - BuildScopeForDeclarationVisitor visitor(manager, parentScope, source); - declaration->Accept(&visitor); - visitor.Visit(parentScope, declaration->attributes); - if (visitor.resultScope) - { - manager->nodeScopes.Add(declaration.Obj(), visitor.resultScope); - visitor.resultScope->ownerNode = declaration; - } - else - { - manager->nodeScopes.Add(declaration.Obj(), parentScope); - } - return visitor.resultScope; - } - }; - -/*********************************************************************** -BuildScopeForStatement -***********************************************************************/ - - class BuildScopeForStatementVisitor - : public Object - , public WfStatement::IVisitor - , public WfVirtualStatement::IVisitor - , public WfCoroutineStatement::IVisitor - { - public: - WfLexicalScopeManager* manager; - Ptr parentScope; - Ptr resultScope; - - BuildScopeForStatementVisitor(WfLexicalScopeManager* _manager, Ptr _parentScope) - :manager(_manager) - , parentScope(_parentScope) - { - } - - void Visit(WfBreakStatement* node)override - { - } - - void Visit(WfContinueStatement* node)override - { - } - - void Visit(WfReturnStatement* node)override - { - if (node->expression) - { - BuildScopeForExpression(manager, parentScope, node->expression); - } - } - - void Visit(WfDeleteStatement* node)override - { - BuildScopeForExpression(manager, parentScope, node->expression); - } - - void Visit(WfRaiseExceptionStatement* node)override - { - if (node->expression) - { - BuildScopeForExpression(manager, parentScope, node->expression); - } - } - - void Visit(WfIfStatement* node)override - { - resultScope = new WfLexicalScope(parentScope); - if (node->type) - { - Ptr symbol = new WfLexicalSymbol(resultScope.Obj()); - symbol->name = node->name.value; - symbol->type = node->type; - symbol->creatorNode = node; - resultScope->symbols.Add(symbol->name, symbol); - } - - BuildScopeForExpression(manager, resultScope, node->expression); - BuildScopeForStatement(manager, resultScope, node->trueBranch); - if (node->falseBranch) - { - BuildScopeForStatement(manager, resultScope, node->falseBranch); - } - } - - void Visit(WfWhileStatement* node)override - { - BuildScopeForExpression(manager, parentScope, node->condition); - BuildScopeForStatement(manager, parentScope, node->statement); - } - - void Visit(WfTryStatement* node)override - { - BuildScopeForStatement(manager, parentScope, node->protectedStatement); - if (node->catchStatement) - { - resultScope = new WfLexicalScope(parentScope); - - Ptr symbol = new WfLexicalSymbol(resultScope.Obj()); - symbol->name = node->name.value; - symbol->creatorNode = node; - { - auto system = MakePtr(); - system->name.value = L"system"; - - auto exception = MakePtr(); - exception->parent = system; - exception->name.value = L"Exception"; - - auto sharedPtr = MakePtr(); - sharedPtr->element = exception; - - symbol->type = sharedPtr; - } - resultScope->symbols.Add(symbol->name, symbol); - - BuildScopeForStatement(manager, resultScope, node->catchStatement); - } - if (node->finallyStatement) - { - BuildScopeForStatement(manager, parentScope, node->finallyStatement); - } - } - - void Visit(WfBlockStatement* node)override - { - resultScope = new WfLexicalScope(parentScope); - - FOREACH(Ptr, statement, node->statements) - { - BuildScopeForStatement(manager, resultScope, statement); - } - } - - void Visit(WfExpressionStatement* node)override - { - BuildScopeForExpression(manager, parentScope, node->expression); - } - - void Visit(WfVariableStatement* node)override - { - BuildScopeForDeclaration(manager, parentScope, node->variable, node); - } - - void Visit(WfVirtualStatement* node)override - { - node->Accept((WfVirtualStatement::IVisitor*)this); - if (node->expandedStatement) - { - BuildScopeForStatement(manager, parentScope, node->expandedStatement); - } - } - - void Visit(WfSwitchStatement* node)override - { - BuildScopeForExpression(manager, parentScope, node->expression); - FOREACH(Ptr, switchCase, node->caseBranches) - { - BuildScopeForExpression(manager, parentScope, switchCase->expression); - BuildScopeForStatement(manager, parentScope, switchCase->statement); - } - if (node->defaultBranch) - { - BuildScopeForStatement(manager, parentScope, node->defaultBranch); - } - } - - void Visit(WfForEachStatement* node)override - { - resultScope = new WfLexicalScope(parentScope); - - Ptr symbol = new WfLexicalSymbol(resultScope.Obj()); - symbol->name = node->name.value; - symbol->creatorNode = node; - resultScope->symbols.Add(symbol->name, symbol); - - BuildScopeForExpression(manager, parentScope, node->collection); - BuildScopeForStatement(manager, resultScope, node->statement); - } - - void Visit(WfCoProviderStatement* node)override - { - resultScope = new WfLexicalScope(parentScope); - { - Ptr symbol = new WfLexicalSymbol(resultScope.Obj()); - symbol->name = L"$PROVIDER"; - symbol->creatorNode = node; - resultScope->symbols.Add(symbol->name, symbol); - } - { - Ptr symbol = new WfLexicalSymbol(resultScope.Obj()); - symbol->name = L"$IMPL"; - symbol->creatorNode = node; - resultScope->symbols.Add(symbol->name, symbol); - } - BuildScopeForStatement(manager, resultScope, node->statement); - } - - void Visit(WfCoroutineStatement* node)override - { - node->Accept((WfCoroutineStatement::IVisitor*)this); - } - - void Visit(WfCoPauseStatement* node)override - { - if (node->statement) - { - BuildScopeForStatement(manager, parentScope, node->statement); - } - } - - void Visit(WfCoOperatorStatement* node)override - { - if (node->varName.value != L"") - { - Ptr symbol = new WfLexicalSymbol(parentScope.Obj()); - symbol->name = node->varName.value; - symbol->creatorNode = node; - parentScope->symbols.Add(symbol->name, symbol); - } - - FOREACH(Ptr, argument, node->arguments) - { - BuildScopeForExpression(manager, parentScope, argument); - } - } - - static Ptr Execute(WfLexicalScopeManager* manager, Ptr parentScope, Ptr statement) - { - BuildScopeForStatementVisitor visitor(manager, parentScope); - statement->Accept(&visitor); - if (visitor.resultScope) - { - manager->nodeScopes.Add(statement.Obj(), visitor.resultScope); - visitor.resultScope->ownerNode = statement; - } - else - { - manager->nodeScopes.Add(statement.Obj(), parentScope); - } - return visitor.resultScope; - } - }; - -/*********************************************************************** -BuildScopeForExpression -***********************************************************************/ - - class BuildScopeForExpressionVisitor - : public Object - , public WfExpression::IVisitor - , public WfVirtualExpression::IVisitor - { - public: - WfLexicalScopeManager* manager; - Ptr parentScope; - Ptr resultScope; - - BuildScopeForExpressionVisitor(WfLexicalScopeManager* _manager, Ptr _parentScope) - :manager(_manager) - , parentScope(_parentScope) - { - } - - void Visit(WfThisExpression* node)override - { - } - - void Visit(WfTopQualifiedExpression* node)override - { - } - - void Visit(WfReferenceExpression* node)override - { - } - - void Visit(WfOrderedNameExpression* node)override - { - } - - void Visit(WfOrderedLambdaExpression* node)override - { - manager->CreateLambdaCapture(node); - - SortedList names; - SearchOrderedName(parentScope.Obj(), node->body, names); - - resultScope = new WfLexicalScope(parentScope); - auto config = MakePtr(); - resultScope->functionConfig = config; - - config->lambda = true; - config->thisAccessable = false; - config->parentThisAccessable = true; - - FOREACH(vint, name, names) - { - Ptr symbol = new WfLexicalSymbol(resultScope.Obj()); - symbol->name = L"$" + itow(name); - symbol->creatorNode = node; - resultScope->symbols.Add(symbol->name, symbol); - } - - BuildScopeForExpression(manager, resultScope, node->body); - } - - void Visit(WfMemberExpression* node)override - { - BuildScopeForExpression(manager, parentScope, node->parent); - } - - void Visit(WfChildExpression* node)override - { - BuildScopeForExpression(manager, parentScope, node->parent); - } - - void Visit(WfLiteralExpression* node)override - { - } - - void Visit(WfFloatingExpression* node)override - { - } - - void Visit(WfIntegerExpression* node)override - { - } - - void Visit(WfStringExpression* node)override - { - } - - void Visit(WfUnaryExpression* node)override - { - BuildScopeForExpression(manager, parentScope, node->operand); - } - - void Visit(WfBinaryExpression* node)override - { - BuildScopeForExpression(manager, parentScope, node->first); - BuildScopeForExpression(manager, parentScope, node->second); - } - - void Visit(WfLetExpression* node)override - { - resultScope = new WfLexicalScope(parentScope); - FOREACH(Ptr, variable, node->variables) - { - Ptr symbol = new WfLexicalSymbol(resultScope.Obj()); - symbol->name = variable->name.value; - symbol->creatorNode = node; - resultScope->symbols.Add(symbol->name, symbol); - BuildScopeForExpression(manager, resultScope, variable->value); - } - - BuildScopeForExpression(manager, resultScope, node->expression); - } - - void Visit(WfIfExpression* node)override - { - BuildScopeForExpression(manager, parentScope, node->condition); - BuildScopeForExpression(manager, parentScope, node->trueBranch); - BuildScopeForExpression(manager, parentScope, node->falseBranch); - } - - void Visit(WfRangeExpression* node)override - { - BuildScopeForExpression(manager, parentScope, node->begin); - BuildScopeForExpression(manager, parentScope, node->end); - } - - void Visit(WfSetTestingExpression* node)override - { - BuildScopeForExpression(manager, parentScope, node->element); - BuildScopeForExpression(manager, parentScope, node->collection); - } - - void Visit(WfConstructorExpression* node)override - { - FOREACH(Ptr, argument, node->arguments) - { - BuildScopeForExpression(manager, parentScope, argument->key); - if (argument->value) - { - BuildScopeForExpression(manager, parentScope, argument->value); - } - } - } - - void Visit(WfInferExpression* node)override - { - BuildScopeForExpression(manager, parentScope, node->expression); - } - - void Visit(WfTypeCastingExpression* node)override - { - BuildScopeForExpression(manager, parentScope, node->expression); - } - - void Visit(WfTypeTestingExpression* node)override - { - if (node->expression) - { - BuildScopeForExpression(manager, parentScope, node->expression); - } - } - - void Visit(WfTypeOfTypeExpression* node)override - { - } - - void Visit(WfTypeOfExpressionExpression* node)override - { - BuildScopeForExpression(manager, parentScope, node->expression); - } - - void Visit(WfAttachEventExpression* node)override - { - BuildScopeForExpression(manager, parentScope, node->event); - BuildScopeForExpression(manager, parentScope, node->function); - } - - void Visit(WfDetachEventExpression* node)override - { - BuildScopeForExpression(manager, parentScope, node->event); - BuildScopeForExpression(manager, parentScope, node->handler); - } - - void Visit(WfObserveExpression* node)override - { - BuildScopeForExpression(manager, parentScope, node->parent); - if (node->observeType == WfObserveType::SimpleObserve) - { - BuildScopeForExpression(manager, parentScope, node->expression); - FOREACH(Ptr, event, node->events) - { - BuildScopeForExpression(manager, parentScope, event); - } - } - else - { - resultScope = new WfLexicalScope(parentScope); - { - Ptr symbol = new WfLexicalSymbol(resultScope.Obj()); - symbol->name = node->name.value; - symbol->creatorNode = node; - resultScope->symbols.Add(symbol->name, symbol); - } - - BuildScopeForExpression(manager, resultScope, node->expression); - FOREACH(Ptr, event, node->events) - { - BuildScopeForExpression(manager, resultScope, event); - } - } - } - - void Visit(WfCallExpression* node)override - { - BuildScopeForExpression(manager, parentScope, node->function); - FOREACH(Ptr, argument, node->arguments) - { - BuildScopeForExpression(manager, parentScope, argument); - } - } - - void Visit(WfFunctionExpression* node)override - { - manager->CreateLambdaCapture(node->function.Obj()); - BuildScopeForDeclaration(manager, parentScope, node->function, node); - } - - void Visit(WfNewClassExpression* node)override - { - FOREACH(Ptr, argument, node->arguments) - { - BuildScopeForExpression(manager, parentScope, argument); - } - } - - class CreateLambdaCaptureVisitor - : public empty_visitor::DeclarationVisitor - { - public: - WfLexicalScopeManager* manager; - Ptr capture; - - CreateLambdaCaptureVisitor(WfLexicalScopeManager* _manager, Ptr _capture) - :manager(_manager) - , capture(_capture) - { - } - - void Dispatch(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - - void Visit(WfFunctionDeclaration* node)override - { - manager->CreateLambdaCapture(node, capture); - } - }; - - void Visit(WfNewInterfaceExpression* node)override - { - resultScope = new WfLexicalScope(parentScope); - auto capture = MakePtr(); - manager->CreateLambdaCapture(node, capture); - - CreateLambdaCaptureVisitor visitor(manager, capture); - FOREACH(Ptr, memberDecl, node->declarations) - { - memberDecl->Accept(&visitor); - BuildScopeForDeclaration(manager, resultScope, memberDecl, node); - } - } - - void Visit(WfVirtualExpression* node)override - { - node->Accept((WfVirtualExpression::IVisitor*)this); - if (node->expandedExpression) - { - BuildScopeForExpression(manager, parentScope, node->expandedExpression); - } - } - - void Visit(WfBindExpression* node)override - { - BuildScopeForExpression(manager, parentScope, node->expression); - } - - void Visit(WfFormatExpression* node)override - { - } - - void Visit(WfNewCoroutineExpression* node)override - { - manager->CreateLambdaCapture(node); - - resultScope = new WfLexicalScope(parentScope); - auto config = MakePtr(); - resultScope->functionConfig = config; - - if (node->name.value != L"") - { - Ptr symbol = new WfLexicalSymbol(resultScope.Obj()); - symbol->name = node->name.value; - symbol->creatorNode = node; - symbol->typeInfo = TypeInfoRetriver>::CreateTypeInfo(); - symbol->type = GetTypeFromTypeInfo(symbol->typeInfo.Obj()); - resultScope->symbols.Add(symbol->name, symbol); - } - - config->lambda = true; - config->thisAccessable = false; - config->parentThisAccessable = true; - - BuildScopeForStatement(manager, resultScope, node->statement); - } - - void Visit(WfMixinCastExpression* node)override - { - BuildScopeForExpression(manager, parentScope, node->expression); - } - - void Visit(WfExpectedTypeCastExpression* node)override - { - BuildScopeForExpression(manager, parentScope, node->expression); - } - - static Ptr Execute(WfLexicalScopeManager* manager, Ptr parentScope, Ptr expression) - { - BuildScopeForExpressionVisitor visitor(manager, parentScope); - expression->Accept(&visitor); - if (visitor.resultScope) - { - manager->nodeScopes.Add(expression.Obj(), visitor.resultScope); - visitor.resultScope->ownerNode = expression; - } - else - { - manager->nodeScopes.Add(expression.Obj(), parentScope); - } - return visitor.resultScope; - } - }; - -/*********************************************************************** -BuildScope -***********************************************************************/ - - void BuildScopeForModule(WfLexicalScopeManager* manager, Ptr module) - { - Ptr scope = new WfLexicalScope(manager); - scope->ownerNode = module; - manager->nodeScopes.Add(module.Obj(), scope); - - FOREACH(Ptr, declaration, module->declarations) - { - BuildScopeForDeclaration(manager, scope, declaration, module.Obj()); - } - } - - void BuildScopeForDeclaration(WfLexicalScopeManager* manager, Ptr parentScope, Ptr declaration, parsing::ParsingTreeCustomBase* source) - { - BuildScopeForDeclarationVisitor::Execute(manager, parentScope, source, declaration); - } - - void BuildScopeForStatement(WfLexicalScopeManager* manager, Ptr parentScope, Ptr statement) - { - BuildScopeForStatementVisitor::Execute(manager, parentScope, statement); - } - - void BuildScopeForExpression(WfLexicalScopeManager* manager, Ptr parentScope, Ptr expression) - { - BuildScopeForExpressionVisitor::Execute(manager, parentScope, expression); - } - -/*********************************************************************** -CheckScopes_DuplicatedSymbol -***********************************************************************/ - - bool CheckScopes_DuplicatedSymbol(WfLexicalScopeManager* manager) - { - SortedList analyzedScopes; - vint errorCount = manager->errors.Count(); - FOREACH(Ptr, scope, manager->nodeScopes.Values()) - { - if (!analyzedScopes.Contains(scope.Obj())) - { - analyzedScopes.Add(scope.Obj()); - - for (vint i = 0; i < scope->symbols.Count(); i++) - { - const auto& symbols = scope->symbols.GetByIndex(i); - if (symbols.Count() > 1) - { - if (!scope->ownerNode.Cast() && !scope->ownerNode.Cast()) - { - if (symbols.Count() > 1) - { - FOREACH(Ptr, symbol, From(symbols)) - { - if (auto decl = symbol->creatorNode.Cast()) - { - if (!decl.Cast()) - { - manager->errors.Add(WfErrors::DuplicatedSymbol(decl.Obj(), symbol)); - } - } - else if (auto arg = symbol->creatorNode.Cast()) - { - manager->errors.Add(WfErrors::DuplicatedSymbol(arg.Obj(), symbol)); - } - else if (auto stat = symbol->creatorNode.Cast()) - { - manager->errors.Add(WfErrors::DuplicatedSymbol(stat.Obj(), symbol)); - } - else if (auto expr = symbol->creatorNode.Cast()) - { - manager->errors.Add(WfErrors::DuplicatedSymbol(expr.Obj(), symbol)); - } - } - } - } - } - } - } - } - return errorCount == manager->errors.Count(); - } - } - } -} - -/*********************************************************************** -ANALYZER\WFANALYZER_COMPLETESCOPE.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace analyzer - { - using namespace collections; - using namespace parsing; - using namespace reflection; - using namespace reflection::description; - using namespace typeimpl; - -/*********************************************************************** -CompleteScopeForClassMember -***********************************************************************/ - - class CompleteScopeForClassMemberVisitor : public Object, public WfDeclaration::IVisitor - { - public: - WfLexicalScopeManager* manager; - Ptr td; - Ptr classDecl; - - CompleteScopeForClassMemberVisitor(WfLexicalScopeManager* _manager, Ptr _td, Ptr _classDecl) - :manager(_manager) - , td(_td) - { - } - - void Visit(WfNamespaceDeclaration* node)override - { - } - - void Visit(WfFunctionDeclaration* node)override - { - auto scope = manager->nodeScopes[node]; - auto info = manager->declarationMemberInfos[node].Cast(); - - FOREACH(Ptr, argument, node->arguments) - { - if (auto typeInfo = CreateTypeInfoFromType(scope.Obj(), argument->type)) - { - auto paramInfo = MakePtr(info.Obj(), argument->name.value, typeInfo); - info->AddParameter(paramInfo); - } - } - - if (auto typeInfo = CreateTypeInfoFromType(scope.Obj(), node->returnType)) - { - info->SetReturn(typeInfo); - } - } - - void Visit(WfVariableDeclaration* node)override - { - auto scope = manager->nodeScopes[node]; - if (auto typeInfo = CreateTypeInfoFromType(scope.Obj(), node->type)) - { - auto info = manager->declarationMemberInfos[node].Cast(); - info->SetReturn(typeInfo); - } - } - - void Visit(WfEventDeclaration* node)override - { - auto scope = manager->nodeScopes[node]; - auto type = MakePtr(); - { - auto voidType = MakePtr(); - voidType->name = WfPredefinedTypeName::Void; - type->result = voidType; - } - FOREACH(Ptr, argument, node->arguments) - { - type->arguments.Add(argument); - } - - if (auto typeInfo = CreateTypeInfoFromType(scope.Obj(), type)) - { - auto info = manager->declarationMemberInfos[node].Cast(); - info->SetHandlerType(typeInfo); - } - } - - void Visit(WfPropertyDeclaration* node)override - { - auto scope = manager->nodeScopes[node]; - auto info = manager->declarationMemberInfos[node].Cast(); - - if (node->getter.value != L"") - { - info->SetGetter(dynamic_cast(td->GetMethodGroupByName(node->getter.value, false)->GetMethod(0))); - } - - if (node->setter.value != L"") - { - info->SetSetter(dynamic_cast(td->GetMethodGroupByName(node->setter.value, false)->GetMethod(0))); - } - - if (node->valueChangedEvent.value != L"") - { - info->SetValueChangedEvent(dynamic_cast(td->GetEventByName(node->valueChangedEvent.value, false))); - } - } - - void Visit(WfConstructorDeclaration* node)override - { - auto scope = manager->nodeScopes[node]; - auto info = manager->declarationMemberInfos[node].Cast(); - - FOREACH(Ptr, argument, node->arguments) - { - if (auto typeInfo = CreateTypeInfoFromType(scope.Obj(), argument->type)) - { - auto paramInfo = MakePtr(info.Obj(), argument->name.value, typeInfo); - info->AddParameter(paramInfo); - } - } - } - - void Visit(WfDestructorDeclaration* node)override - { - } - - void Visit(WfClassDeclaration* node)override - { - CompleteScopeForDeclaration(manager, node); - } - - void Visit(WfEnumDeclaration* node)override - { - CompleteScopeForDeclaration(manager, node); - } - - void Visit(WfStructDeclaration* node)override - { - CompleteScopeForDeclaration(manager, node); - } - - void Visit(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - - static void Execute(WfLexicalScopeManager* manager, Ptr td, Ptr classDecl, Ptr memberDecl) - { - CompleteScopeForClassMemberVisitor visitor(manager, td, classDecl); - memberDecl->Accept(&visitor); - } - }; - -/*********************************************************************** -CompleteScopeForDeclaration -***********************************************************************/ - - class CompleteScopeForDeclarationVisitor : public Object, public WfDeclaration::IVisitor - { - public: - WfLexicalScopeManager* manager; - Ptr declaration; - - CompleteScopeForDeclarationVisitor(WfLexicalScopeManager* _manager, Ptr _declaration) - :manager(_manager) - , declaration(_declaration) - { - } - - void Visit(WfNamespaceDeclaration* node)override - { - FOREACH(Ptr, decl, node->declarations) - { - CompleteScopeForDeclaration(manager, decl); - } - } - - void Visit(WfFunctionDeclaration* node)override - { - } - - void Visit(WfVariableDeclaration* node)override - { - } - - void Visit(WfEventDeclaration* node)override - { - } - - void Visit(WfPropertyDeclaration* node)override - { - } - - void Visit(WfConstructorDeclaration* node)override - { - } - - void Visit(WfDestructorDeclaration* node)override - { - } - - void Visit(WfClassDeclaration* node)override - { - auto scope = manager->nodeScopes[node]; - auto td = manager->declarationTypes[node].Cast(); - - if (node->baseTypes.Count() > 0) - { - FOREACH(Ptr, baseType, node->baseTypes) - { - if (auto scopeName = GetScopeNameFromReferenceType(scope->parentScope.Obj(), baseType)) - { - if (scopeName->typeDescriptor) - { - td->AddBaseType(scopeName->typeDescriptor); - } - } - } - } - else if (node->kind == WfClassKind::Class) - { - td->AddBaseType(description::GetTypeDescriptor()); - } - else if (node->kind == WfClassKind::Interface) - { - td->AddBaseType(description::GetTypeDescriptor()); - } - - if (node->kind == WfClassKind::Interface) - { - switch (node->constructorType) - { - case WfConstructorType::SharedPtr: - { - auto elementType = MakePtr(td.Obj(), TypeInfoHint::Normal); - auto pointerType = MakePtr(elementType); - - auto ctor = MakePtr(pointerType); - td->AddMember(ctor); - } - break; - case WfConstructorType::RawPtr: - { - auto elementType = MakePtr(td.Obj(), TypeInfoHint::Normal); - auto pointerType = MakePtr(elementType); - - auto ctor = MakePtr(pointerType); - td->AddMember(ctor); - } - break; - default:; - } - } - - FOREACH(Ptr, memberDecl, node->declarations) - { - CompleteScopeForClassMember(manager, td, node, memberDecl); - } - } - - void Visit(WfEnumDeclaration* node)override - { - auto td = manager->declarationTypes[node].Cast(); - Dictionary items; - FOREACH(Ptr, item, node->items) - { - vuint64_t value = 0; - switch (item->kind) - { - case WfEnumItemKind::Constant: - TypedValueSerializerProvider::Deserialize(item->number.value, value); - break; - case WfEnumItemKind::Intersection: - FOREACH(Ptr, itemInt, item->intersections) - { - value |= items[itemInt->name.value]; - } - break; - } - td->AddEnumItem(item->name.value, value); - items.Add(item->name.value, value); - } - } - - void Visit(WfStructDeclaration* node)override - { - auto scope = manager->nodeScopes[node]; - auto td = manager->declarationTypes[node].Cast(); - FOREACH(Ptr, member, node->members) - { - if (auto typeInfo = CreateTypeInfoFromType(scope.Obj(), member->type)) - { - auto field = MakePtr(td.Obj(), member->name.value); - field->SetReturn(typeInfo); - td->AddMember(field); - } - } - } - - void Visit(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - - static void Execute(WfLexicalScopeManager* manager, Ptr declaration) - { - CompleteScopeForDeclarationVisitor visitor(manager, declaration); - declaration->Accept(&visitor); - } - }; - -/*********************************************************************** -CheckBaseClass -***********************************************************************/ - - class CheckBaseClassDeclarationVisitor : public empty_visitor::DeclarationVisitor - { - public: - WfLexicalScopeManager* manager; - SortedList checkedInterfaces; - SortedList traversedInterfaces; - - CheckBaseClassDeclarationVisitor(WfLexicalScopeManager* _manager) - :manager(_manager) - { - } - - void Dispatch(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - - void Visit(WfNamespaceDeclaration* node)override - { - FOREACH(Ptr, decl, node->declarations) - { - decl->Accept(this); - } - } - - void CheckDuplicatedBaseClass(WfClassDeclaration* node, ITypeDescriptor* td) - { - List baseTypes; - SortedList duplicatedTypes; - baseTypes.Add(td); - - for (vint i = 0; i < baseTypes.Count(); i++) - { - auto currentTd = baseTypes[i]; - vint count = currentTd->GetBaseTypeDescriptorCount(); - for (vint j = 0; j < count; j++) - { - auto baseTd = currentTd->GetBaseTypeDescriptor(j); - if (baseTd->GetTypeDescriptorFlags() == TypeDescriptorFlags::Class && baseTd != description::GetTypeDescriptor()) - { - if (baseTypes.Contains(baseTd)) - { - if (!duplicatedTypes.Contains(baseTd)) - { - duplicatedTypes.Add(baseTd); - manager->errors.Add(WfErrors::DuplicatedBaseClass(node, baseTd)); - } - } - else - { - baseTypes.Add(baseTd); - } - } - } - } - } - - void CheckDuplicatedBaseInterface(WfClassDeclaration* node, ITypeDescriptor* td) - { - if (traversedInterfaces.Contains(td)) - { - manager->errors.Add(WfErrors::DuplicatedBaseInterface(node, td)); - } - else - { - if (checkedInterfaces.Contains(td)) - { - return; - } - checkedInterfaces.Add(td); - - vint index = traversedInterfaces.Add(td); - vint count = td->GetBaseTypeDescriptorCount(); - for (vint i = 0; i < count; i++) - { - CheckDuplicatedBaseInterface(node, td->GetBaseTypeDescriptor(i)); - } - traversedInterfaces.RemoveAt(index); - } - } - - void Visit(WfClassDeclaration* node)override - { - auto scope = manager->nodeScopes[node]; - auto td = manager->declarationTypes[node].Obj(); - - FOREACH(Ptr, baseType, node->baseTypes) - { - if (auto scopeName = GetScopeNameFromReferenceType(scope->parentScope.Obj(), baseType)) - { - if (auto baseTd = scopeName->typeDescriptor) - { - bool isClass = baseTd->GetTypeDescriptorFlags() == TypeDescriptorFlags::Class; - bool isInterface = baseTd->GetTypeDescriptorFlags() == TypeDescriptorFlags::Interface; - - switch (node->kind) - { - case WfClassKind::Class: - { - if (!isClass || !baseTd->IsAggregatable()) - { - if (!dynamic_cast(baseTd)) - { - manager->errors.Add(WfErrors::WrongBaseTypeOfClass(node, baseTd)); - } - } - } - break; - case WfClassKind::Interface: - { - if (!isInterface) - { - manager->errors.Add(WfErrors::WrongBaseTypeOfInterface(node, baseTd)); - } - } - break; - } - } - } - } - - if (node->kind == WfClassKind::Class) - { - CheckDuplicatedBaseClass(node, td); - } - else - { - CheckDuplicatedBaseInterface(node, td); - } - - FOREACH(Ptr, memberDecl, node->declarations) - { - memberDecl->Accept(this); - } - } - - void Visit(WfEnumDeclaration* node)override - { - } - - void Visit(WfStructDeclaration* node)override - { - } - - static void Execute(WfLexicalScopeManager* manager, Ptr declaration) - { - CompleteScopeForDeclarationVisitor visitor(manager, declaration); - declaration->Accept(&visitor); - } - }; - -/*********************************************************************** -CompleteScope -***********************************************************************/ - - void CompleteScopeForClassMember(WfLexicalScopeManager* manager, Ptr td, Ptr classDecl, Ptr memberDecl) - { - CompleteScopeForClassMemberVisitor::Execute(manager, td, classDecl, memberDecl); - } - - void CompleteScopeForDeclaration(WfLexicalScopeManager* manager, Ptr declaration) - { - CompleteScopeForDeclarationVisitor::Execute(manager, declaration); - } - - void CompleteScopeForModule(WfLexicalScopeManager* manager, Ptr module) - { - FOREACH(Ptr, declaration, module->declarations) - { - CompleteScopeForDeclaration(manager, declaration); - } - } - -/*********************************************************************** -CheckScopes_SymbolType -***********************************************************************/ - - bool CheckScopes_SymbolType(WfLexicalScopeManager* manager) - { - SortedList analyzedScopes; - vint errorCount = manager->errors.Count(); - FOREACH(Ptr, scope, manager->nodeScopes.Values()) - { - if (!analyzedScopes.Contains(scope.Obj())) - { - analyzedScopes.Add(scope.Obj()); - - for (vint i = 0; i < scope->symbols.Count(); i++) - { - FOREACH(Ptr, symbol, scope->symbols.GetByIndex(i)) - { - if (symbol->type) - { - vint currentErrorCount = manager->errors.Count(); - symbol->typeInfo = CreateTypeInfoFromType(scope.Obj(), symbol->type); - if (symbol->creatorNode) - { - for (vint i = currentErrorCount; i < manager->errors.Count(); i++) - { - manager->errors[i]->parsingTree = symbol->creatorNode.Obj(); - } - } - } - } - } - } - } - return errorCount == manager->errors.Count(); - } - -/*********************************************************************** -CheckScopes_BaseType -***********************************************************************/ - - bool CheckScopes_BaseType(WfLexicalScopeManager* manager) - { - vint errorCount = manager->errors.Count(); - CheckBaseClassDeclarationVisitor visitor(manager); - FOREACH(Ptr, module, manager->GetModules()) - { - FOREACH(Ptr, declaration, module->declarations) - { - declaration->Accept(&visitor); - } - } - return errorCount == manager->errors.Count(); - } - } - } -} - -/*********************************************************************** -ANALYZER\WFANALYZER_CONTEXTFREEDESUGAR.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace analyzer - { - using namespace collections; - using namespace parsing; - using namespace reflection::description; - -/*********************************************************************** -SetCodeRange -***********************************************************************/ - - class SetCodeRangeVisitor : public traverse_visitor::ModuleVisitor - { - public: - ParsingTextRange range; - - SetCodeRangeVisitor(ParsingTextRange _range) - :range(_range) - { - } - - void Traverse(ParsingTreeCustomBase* node)override - { - if (node->codeRange == ParsingTextRange()) - { - node->codeRange = range; - } - } - - void Traverse(ParsingToken& token)override - { - if (token.codeRange == ParsingTextRange()) - { - token.codeRange = range; - } - } - }; - - void SetCodeRange(Ptr node, parsing::ParsingTextRange codeRange) - { - SetCodeRangeVisitor(codeRange).VisitField(node.Obj()); - } - - void SetCodeRange(Ptr node, parsing::ParsingTextRange codeRange) - { - SetCodeRangeVisitor(codeRange).VisitField(node.Obj()); - } - - void SetCodeRange(Ptr node, parsing::ParsingTextRange codeRange) - { - SetCodeRangeVisitor(codeRange).VisitField(node.Obj()); - } - - void SetCodeRange(Ptr node, parsing::ParsingTextRange codeRange) - { - SetCodeRangeVisitor(codeRange).VisitField(node.Obj()); - } - - void SetCodeRange(Ptr node, parsing::ParsingTextRange codeRange) - { - SetCodeRangeVisitor(codeRange).VisitField(node.Obj()); - } - -/*********************************************************************** -ContextFreeModuleDesugar -***********************************************************************/ - - class ContextFreeDesugarVisitor : public traverse_visitor::ModuleVisitor - { - public: - WfLexicalScopeManager* manager; - WfClassDeclaration* surroundingClassDecl = nullptr; - WfNewInterfaceExpression* surroundingLambda = nullptr; - - ContextFreeDesugarVisitor(WfLexicalScopeManager* _manager) - :manager(_manager) - { - } - - void Traverse(WfFormatExpression* node)override - { - if (node->expandedExpression) - { - return; - } - - List> expressions; - const wchar_t* reading = node->value.value.Buffer(); - - while (*reading) - { - const wchar_t* begin = wcsstr(reading, L"$("); - if (begin) - { - Ptr expression = new WfStringExpression; - expression->codeRange = node->codeRange; - expression->value.value = WString(reading, vint(begin - reading)); - expressions.Add(expression); - } - else - { - break; - } - - const wchar_t* end = begin + 2; - vint counter = 1; - while (wchar_t c = *end++) - { - switch (c) - { - case L'(': - counter++; - break; - case L')': - counter--; - break; - } - if (counter == 0) - { - break; - } - } - - if (counter != 0) - { - auto error = WfErrors::WrongFormatStringSyntax(node); - error->errorMessage += L" (Does not find matched close bracket.)"; - manager->errors.Add(error); - return; - } - else - { - WString input(begin + 2, vint(end - begin - 3)); - List> errors; - if (auto expression = WfParseExpression(input, manager->parsingTable, errors)) - { - expressions.Add(expression); - } - FOREACH(Ptr, originalError, errors) - { - auto error = WfErrors::WrongFormatStringSyntax(node); - error->errorMessage += L" (" + originalError->errorMessage + L")"; - manager->errors.Add(error); - } - reading = end; - } - } - if (*reading || expressions.Count() == 0) - { - Ptr expression = new WfStringExpression; - expression->codeRange = node->codeRange; - expression->value.value = reading; - expressions.Add(expression); - } - - if (expressions.Count() > 0) - { - Ptr current = expressions[0]; - FOREACH(Ptr, expression, From(expressions).Skip(1)) - { - Ptr binary = new WfBinaryExpression; - binary->codeRange = node->codeRange; - binary->first = current; - binary->second = expression; - binary->op = WfBinaryOperator::Union; - current = binary; - } - - node->expandedExpression = current; - SetCodeRange(node->expandedExpression, node->codeRange); - } - } - - void Traverse(WfAutoPropertyDeclaration* node)override - { - if (node->expandedDeclarations.Count() > 0) - { - return; - } - - bool needVariable = false; - bool needVirtual = false; - bool needEvent = false; - bool needProperty = false; - - if (surroundingClassDecl) - { - switch (surroundingClassDecl->kind) - { - case WfClassKind::Class: - { - needVariable = true; - needVirtual = false; - needEvent = node->configObserve == WfAPObserve::Observable; - needProperty = true; - } - break; - case WfClassKind::Interface: - { - needVariable = false; - needVirtual = true; - needEvent = node->configObserve == WfAPObserve::Observable; - needProperty = true; - } - break; - } - } - else if (surroundingLambda) - { - needVariable = true; - needVirtual = false; - needEvent = false; - needProperty = false; - } - - auto varName = L"" + node->name.value; - auto getterName = L"Get" + node->name.value; - auto setterName = L"Set" + node->name.value; - auto eventName = node->name.value + L"Changed"; - - if (needVariable && node->expression) - { - auto decl = MakePtr(); - node->expandedDeclarations.Add(decl); - - decl->name.value = varName; - decl->type = CopyType(node->type); - decl->expression = CopyExpression(node->expression); - - auto att = MakePtr(); - att->category.value = L"cpp"; - att->name.value = L"Private"; - decl->attributes.Add(att); - } - - { - auto decl = MakePtr(); - node->expandedDeclarations.Add(decl); - - decl->anonymity = WfFunctionAnonymity::Named; - decl->name.value = getterName; - decl->returnType = CopyType(node->type); - - if (!needVirtual) - { - auto refExpr = MakePtr(); - refExpr->name.value = varName; - - auto returnStat = MakePtr(); - returnStat->expression = refExpr; - - auto block = MakePtr(); - block->statements.Add(returnStat); - decl->statement = block; - } - } - - if (!needVirtual || node->configConst == WfAPConst::Writable) - { - auto decl = MakePtr(); - node->expandedDeclarations.Add(decl); - - decl->anonymity = WfFunctionAnonymity::Named; - decl->name.value = setterName; - - if (node->configConst == WfAPConst::Readonly) - { - auto att = MakePtr(); - att->category.value = L"cpp"; - att->name.value = L"Protected"; - decl->attributes.Add(att); - } - - { - auto argument = MakePtr(); - argument->name.value = L""; - argument->type = CopyType(node->type); - decl->arguments.Add(argument); - } - { - auto voidType = MakePtr(); - voidType->name = WfPredefinedTypeName::Void; - decl->returnType = voidType; - } - - if (!needVirtual) - { - auto block = MakePtr(); - decl->statement = block; - - auto createBinaryExpr = [&](WfBinaryOperator op) - { - auto refArgument = MakePtr(); - refArgument->name.value = L""; - - auto refVar = MakePtr(); - refVar->name.value = varName; - - auto binaryExpr = MakePtr(); - binaryExpr->first = refVar; - binaryExpr->second = refArgument; - binaryExpr->op = op; - - return binaryExpr; - }; - - if (node->configObserve == WfAPObserve::Observable) - { - auto ifStat = MakePtr(); - ifStat->expression = createBinaryExpr(WfBinaryOperator::NE); - - auto trueBlock = MakePtr(); - ifStat->trueBranch = trueBlock; - - { - auto stat = MakePtr(); - stat->expression = createBinaryExpr(WfBinaryOperator::Assign); - trueBlock->statements.Add(stat); - } - { - auto refEvent = MakePtr(); - refEvent->name.value = eventName; - - auto callExpr = MakePtr(); - callExpr->function = refEvent; - - auto stat = MakePtr(); - stat->expression = callExpr; - trueBlock->statements.Add(stat); - } - - block->statements.Add(ifStat); - } - else - { - auto stat = MakePtr(); - stat->expression = createBinaryExpr(WfBinaryOperator::Assign); - - block->statements.Add(stat); - } - } - } - - if (needEvent) - { - auto decl = MakePtr(); - node->expandedDeclarations.Add(decl); - - decl->name.value = eventName; - } - - if (needProperty) - { - auto decl = MakePtr(); - node->expandedDeclarations.Add(decl); - - decl->type = CopyType(node->type); - decl->name.value = node->name.value; - decl->getter.value = getterName; - if (node->configConst == WfAPConst::Writable) - { - decl->setter.value = setterName; - } - if (node->configObserve == WfAPObserve::Observable) - { - decl->valueChangedEvent.value = eventName; - } - } - - FOREACH(Ptr, decl, node->expandedDeclarations) - { - auto classMember = MakePtr(); - decl->classMember = classMember; - - classMember->kind = WfClassMemberKind::Normal; - if (surroundingLambda) - { - if (decl->name.value == getterName) - { - classMember->kind = WfClassMemberKind::Override; - } - else if (decl->name.value == setterName) - { - if (node->configConst == WfAPConst::Writable) - { - classMember->kind = WfClassMemberKind::Override; - } - } - } - - SetCodeRange(decl, node->codeRange); - } - } - - void Traverse(WfCastResultInterfaceDeclaration* node)override - { - if (node->expandedDeclarations.Count() > 0) - { - return; - } - - auto decl = MakePtr(); - node->expandedDeclarations.Add(decl); - decl->kind = WfClassKind::Interface; - decl->constructorType = WfConstructorType::SharedPtr; - decl->name.value = node->name.value; - decl->baseTypes.Add(CopyType(node->baseType)); - - auto funcDecl = MakePtr(); - decl->declarations.Add(funcDecl); - { - funcDecl->classMember = MakePtr(); - funcDecl->classMember->kind = WfClassMemberKind::Static; - } - funcDecl->anonymity = WfFunctionAnonymity::Named; - funcDecl->name.value = L"CastResult"; - funcDecl->returnType = CopyType(node->elementType); - { - auto argument = MakePtr(); - funcDecl->arguments.Add(argument); - argument->name.value = L"value"; - argument->type = GetTypeFromTypeInfo(TypeInfoRetriver::CreateTypeInfo().Obj()); - } - { - auto block = MakePtr(); - funcDecl->statement = block; - - auto refValue = MakePtr(); - refValue->name.value = L"value"; - - auto castExpr = MakePtr(); - castExpr->strategy = WfTypeCastingStrategy::Strong; - castExpr->type = CopyType(node->elementType); - castExpr->expression = refValue; - - auto stat = MakePtr(); - stat->expression = castExpr; - - block->statements.Add(stat); - } - - SetCodeRange(Ptr(decl), node->codeRange); - } - -#define PUSH_SURROUNDING\ - auto o1 = surroundingClassDecl;\ - auto o2 = surroundingLambda;\ - surroundingClassDecl = nullptr;\ - surroundingLambda = nullptr;\ - -#define POP_SURROUNDING\ - surroundingClassDecl = o1;\ - surroundingLambda = o2;\ - - void Visit(WfClassDeclaration* node)override - { - PUSH_SURROUNDING - surroundingClassDecl = node; - traverse_visitor::DeclarationVisitor::Visit(node); - POP_SURROUNDING - } - - void Visit(WfNewInterfaceExpression* node)override - { - PUSH_SURROUNDING - surroundingLambda = node; - traverse_visitor::ExpressionVisitor::Visit(node); - POP_SURROUNDING - } - -#undef PUSH_SURROUNDING -#undef POP_SURROUNDING - }; - - void ContextFreeModuleDesugar(WfLexicalScopeManager* manager, Ptr module) - { - ContextFreeDesugarVisitor(manager).VisitField(module.Obj()); - } - - void ContextFreeDeclarationDesugar(WfLexicalScopeManager* manager, Ptr declaration) - { - ContextFreeDesugarVisitor(manager).VisitField(declaration.Obj()); - } - - void ContextFreeStatementDesugar(WfLexicalScopeManager* manager, Ptr statement) - { - ContextFreeDesugarVisitor(manager).VisitField(statement.Obj()); - } - - void ContextFreeExpressionDesugar(WfLexicalScopeManager* manager, Ptr expression) - { - ContextFreeDesugarVisitor(manager).VisitField(expression.Obj()); - } - } - } -} - -/*********************************************************************** -ANALYZER\WFANALYZER_ERRORS.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace analyzer - { - using namespace collections; - using namespace parsing; - using namespace reflection; - using namespace reflection::description; - -/*********************************************************************** -WfErrors -***********************************************************************/ - - Ptr WfErrors::WrongFormatStringSyntax(WfExpression* node) - { - return new ParsingError(node, L"A0: Wrong format string syntax."); - } - - Ptr WfErrors::WrongSimpleObserveExpression(WfExpression* node) - { - return new ParsingError(node, L"A1: Simple observe expression should observe a property under the observed object."); - } - - Ptr WfErrors::WrongSimpleObserveEvent(WfExpression* node) - { - return new ParsingError(node, L"A2: Simple observe expression should react to an event under the observed object."); - } - - Ptr WfErrors::EmptyObserveEvent(WfExpression* node) - { - return new ParsingError(node, L"A2: Observe expression should react to at least one event."); - } - - Ptr WfErrors::ObserveNotInBind(WfExpression* node) - { - return new ParsingError(node, L"A3: Observe expression should appear in a bind expression."); - } - - Ptr WfErrors::ObserveInObserveEvent(WfExpression* node) - { - return new ParsingError(node, L"A4: Observe expression should not appear in the event expression in another observe expression."); - } - - Ptr WfErrors::BindInBind(WfExpression* node) - { - return new ParsingError(node, L"A4: Bind expression should not appear in another bind expression."); - } - - Ptr WfErrors::AttachInBind(WfExpression* node) - { - return new ParsingError(node, L"A4: Attach expression should not appear in another bind expression."); - } - - Ptr WfErrors::DetachInBind(WfExpression* node) - { - return new ParsingError(node, L"A4: Detach expression should not appear in another bind expression."); - } - - Ptr WfErrors::ConstructorMixMapAndList(WfExpression* node) - { - return new ParsingError(node, L"A5: Key-value pairs are not allowed in list constructor expression."); - } - - Ptr WfErrors::ConstructorMixStructAndList(WfExpression* node) - { - return new ParsingError(node, L"A5: Field-value pairs are expected in struct constructor expression."); - } - - Ptr WfErrors::DuplicatedConstructorField(WfReferenceExpression* node) - { - return new ParsingError(node, L"A5: The same field cannot be assigned more than once in struct constructor expression."); - } - - Ptr WfErrors::ConstructorMixClassAndInterface(WfNewClassExpression* node) - { - return new ParsingError(node, L"A6: Arguments are not allowed in new interface expression."); - } - - Ptr WfErrors::ConstructorMixClassAndInterface(WfNewInterfaceExpression* node) - { - return new ParsingError(node, L"A6: Members are not allowed in new class expression."); - } - - Ptr WfErrors::ScopeNameIsNotExpression(WfExpression* node, Ptr scopeName) - { - return new ParsingError(node, L"A7: Symbol \"" + scopeName->GetFriendlyName() + L"\" cannot be used as an expression."); - } - - Ptr WfErrors::EventIsNotExpression(WfExpression* node, reflection::description::IEventInfo* eventInfo) - { - return new ParsingError(node, L"A7: Event \"" + eventInfo->GetName() + L"\" of type \"" + eventInfo->GetOwnerTypeDescriptor()->GetTypeName() + L"\" cannot be used as an expression."); - } - - Ptr WfErrors::ExpressionIsNotScopeName(WfExpression* node) - { - return new ParsingError(node, L"A8: Expression does not reference to a declaration."); - } - - Ptr WfErrors::ExpressionIsNotEvent(WfExpression* node) - { - return new ParsingError(node, L"A8: Expression does not reference to an event."); - } - - Ptr WfErrors::ExpressionCannotResolveType(WfExpression* node, Ptr symbol) - { - return new ParsingError(node, L"A9: Expression referencing to symbol \"" + symbol->name + L"\" failed to resolve its type."); - } - - Ptr WfErrors::NullCannotResolveType(WfExpression* node) - { - return new ParsingError(node, L"A9: Expression \"null\" failed to resolve its type."); - } - - Ptr WfErrors::ConstructorCannotResolveType(WfExpression* node) - { - return new ParsingError(node, L"A9: Expression \"{}\" failed to resolve its type."); - } - - Ptr WfErrors::OrderedLambdaCannotResolveType(WfExpression* node) - { - return new ParsingError(node, L"A9: Ordered lambda expression failed to resolve its type."); - } - - Ptr WfErrors::NullCannotImplicitlyConvertToType(WfExpression* node, reflection::description::ITypeInfo* toType) - { - return new ParsingError(node, L"A10: Expression \"null\" cannot implicitly convert to \"" + toType->GetTypeFriendlyName() + L"\"."); - } - - Ptr WfErrors::ConstructorCannotImplicitlyConvertToType(WfExpression* node, reflection::description::ITypeInfo* toType) - { - return new ParsingError(node, L"A10: Expression \"{}\" cannot implicitly convert to \"" + toType->GetTypeFriendlyName() + L"\"."); - } - - Ptr WfErrors::OrderedLambdaCannotImplicitlyConvertToType(WfExpression* node, reflection::description::ITypeInfo* toType) - { - return new ParsingError(node, L"A10: Ordered lambda expression cannot implicitly convert to \"" + toType->GetTypeFriendlyName() + L"\"."); - } - - Ptr WfErrors::ExpressionCannotImplicitlyConvertToType(WfExpression* node, reflection::description::ITypeInfo* fromType, reflection::description::ITypeInfo* toType) - { - return new ParsingError(node, L"A10: Expression of type \"" + fromType->GetTypeFriendlyName() + L"\" cannot implicitly convert to \"" + toType->GetTypeFriendlyName() + L"\"."); - } - - Ptr WfErrors::ExpressionCannotExplicitlyConvertToType(WfExpression* node, reflection::description::ITypeInfo* fromType, reflection::description::ITypeInfo* toType) - { - return new ParsingError(node, L"A11: Expression of type \"" + fromType->GetTypeFriendlyName() + L"\" cannot explicitly convert to \"" + toType->GetTypeFriendlyName() + L"\"."); - } - - Ptr WfErrors::CannotWeakCastToType(WfExpression* node, reflection::description::ITypeInfo* toType) - { - return new ParsingError(node, L"A12: Expression cannot weakly cast to \"" + toType->GetTypeFriendlyName() + L"\" because it cannot be \"null\"."); - } - - Ptr WfErrors::IntegerLiteralOutOfRange(WfIntegerExpression* node) - { - return new ParsingError(node, L"A13: Integer literal \"" + node->value.value + L"\" out of range."); - } - - Ptr WfErrors::FloatingLiteralOutOfRange(WfFloatingExpression* node) - { - return new ParsingError(node, L"A13: Floating literal \"" + node->value.value + L"\" out of range."); - } - - Ptr WfErrors::CannotMergeTwoType(WfExpression* node, reflection::description::ITypeInfo* firstType, reflection::description::ITypeInfo* secondType) - { - return new ParsingError(node, L"A14: Failed to merge type \"" + firstType->GetTypeFriendlyName() + L"\" with type \"" + secondType->GetTypeFriendlyName() + L"\" together to calculate the result type."); - } - - Ptr WfErrors::RangeShouldBeInteger(WfExpression* node, reflection::description::ITypeInfo* type) - { - return new ParsingError(node, L"A15: Elements in a range expression should be integer, not \"" + type->GetTypeFriendlyName() + L"\"."); - } - - Ptr WfErrors::UnaryOperatorOnWrongType(WfUnaryExpression* node, reflection::description::ITypeInfo* type) - { - return new ParsingError(node, L"A16: Unary operator cannot apply on expression of type \"" + type->GetTypeFriendlyName() + L"\"."); - } - - Ptr WfErrors::BinaryOperatorOnWrongType(WfBinaryExpression* node, reflection::description::ITypeInfo* type) - { - return new ParsingError(node, L"A16: Binary operator cannot apply on expression of type \"" + type->GetTypeFriendlyName() + L"\"."); - } - - Ptr WfErrors::IndexOperatorOnWrongType(WfBinaryExpression* node, reflection::description::ITypeInfo* containerType) - { - return new ParsingError(node, L"A17: Container of type \"" + containerType->GetTypeFriendlyName() + L"\" cannot be accessed using index."); - } - - Ptr WfErrors::ExpressionIsNotCollection(WfExpression* node, reflection::description::ITypeInfo* type) - { - return new ParsingError(node, L"A18: Expression of type \"" + type->GetTypeFriendlyName() + L"\" is not an enumerable type."); - } - - Ptr WfErrors::ExpressionIsNotFunction(WfExpression* node, reflection::description::ITypeInfo* type) - { - return new ParsingError(node, L"A19: Expression of type \"" + type->GetTypeFriendlyName() + L"\" is not an invokable function type."); - } - - Ptr WfErrors::FunctionArgumentCountMismatched(parsing::ParsingTreeCustomBase* node, vint expectedCount, const ResolveExpressionResult& function) - { - return new ParsingError(node, L"A20: Function " + function.GetFriendlyName() + L"\" is not allowed to call with " + itow(expectedCount) + L" arguments."); - } - - Ptr WfErrors::FunctionArgumentTypeMismatched(parsing::ParsingTreeCustomBase* node, const ResolveExpressionResult& function, vint index, reflection::description::ITypeInfo* fromType, reflection::description::ITypeInfo* toType) - { - return new ParsingError(node, L"A21: The " + itow(index) + L"-th argument of function " + function.GetFriendlyName() + L" cannot implicitly convert from \"" + fromType->GetTypeFriendlyName() + L"\" to \"" + toType->GetTypeFriendlyName() + L"\"."); - } - - Ptr WfErrors::CannotPickOverloadedFunctions(parsing::ParsingTreeCustomBase* node, collections::List& results) - { - WString description; - FOREACH_INDEXER(ResolveExpressionResult, result, index, results) - { - description += L"\r\n\t"; - description += result.GetFriendlyName(); - } - return new ParsingError(node, L"A22: Cannot decide which function to call in multiple targets: " + description + L"."); - } - - Ptr WfErrors::ClassContainsNoConstructor(WfExpression* node, reflection::description::ITypeInfo* type) - { - return new ParsingError(node, L"A23: Class \"" + type->GetTypeFriendlyName() + L"\" does not contain any constructor."); - } - - Ptr WfErrors::InterfaceContainsNoConstructor(WfExpression* node, reflection::description::ITypeInfo* type) - { - Ptr proxy = TypeInfoRetriver>::CreateTypeInfo(); - return new ParsingError(node, L"A23: Interface \"" + type->GetTypeFriendlyName() + L"\" does not contain any constructor receiving an \"" + proxy->GetTypeFriendlyName() + L"\"."); - } - - Ptr WfErrors::ConstructorReturnTypeMismatched(WfExpression* node, const ResolveExpressionResult& function, reflection::description::ITypeInfo* fromType, reflection::description::ITypeInfo* toType) - { - return new ParsingError(node, L"A24: The return type of " + function.GetFriendlyName() + L" cannot implicitly convert from \"" + fromType->GetTypeFriendlyName() + L"\" to \"" + toType->GetTypeFriendlyName() + L"\"."); - } - - Ptr WfErrors::ExpressionIsNotLeftValue(WfExpression* node, const ResolveExpressionResult& result) - { - return new ParsingError(node, L"A25: " + result.GetFriendlyName(true) + L" is not assignable."); - } - - Ptr WfErrors::CannotCallMemberOutsideOfClass(WfExpression* node, const ResolveExpressionResult& result) - { - return new ParsingError(node, L"A26: " + result.GetFriendlyName(true) + L" cannot be called as a static member."); - } - - Ptr WfErrors::CannotCallMemberInStaticFunction(WfExpression* node, const ResolveExpressionResult& result) - { - return new ParsingError(node, L"A27: " + result.GetFriendlyName(true) + L" cannot be called in static functions of its class or interface."); - } - - Ptr WfErrors::FieldCannotInitializeUsingEachOther(WfExpression* node, const ResolveExpressionResult& result) - { - return new ParsingError(node, L"A28: " + result.GetFriendlyName(true) + L" cannot be used to initialize other fields in the same type or new interface expression."); - } - - Ptr WfErrors::WrongThisExpression(WfExpression* node) - { - return new ParsingError(node, L"A29: The \"this\" expression can only be used in class methods or functions in new interface expressions"); - } - - Ptr WfErrors::IncorrectTypeForUnion(WfExpression* node, reflection::description::ITypeInfo* type) - { - return new ParsingError(node, L"A30: Expression of type \"" + type->GetTypeFriendlyName() + L"\" cannot be used in union (&) expression because it is not string or flag enum."); - } - - Ptr WfErrors::IncorrectTypeForIntersect(WfExpression* node, reflection::description::ITypeInfo* type) - { - return new ParsingError(node, L"A30: Expression of type \"" + type->GetTypeFriendlyName() + L"\" cannot be used in intersect (|) expression because it is not flag enum."); - } - - Ptr WfErrors::ExpressionIsNotConstant(WfExpression* node) - { - return new ParsingError(node, L"A31: Expression is not constant. A constant expression consists of:\r\n" - L"\tconstant primitive values\r\n" - L"\tenum items\r\n" - L"\tconstant unary (+, -, not) expressions\r\n" - L"\tconstant binary (|) expressions\r\n" - L"\tconstant range expressions\r\n" - L"\tconstant constructor expressions (to create values of structs, lists or dictionarys)\r\n" - L"\ttype() or typeof() expressions."); - } - - Ptr WfErrors::WrongMixinTargetType(WfExpression* node, reflection::description::ITypeInfo* fromType, reflection::description::ITypeInfo* toType) - { - return new ParsingError(node, L"A32: Mixin cast cannot implicitly convert from \"" + fromType->GetTypeFriendlyName() + L"\" to \"" + toType->GetTypeFriendlyName() + L"\". It is only for converting from an interface to a derived interface."); - } - - Ptr WfErrors::ExpectedTypeCastCannotResolveType(WfExpression* node) - { - return new ParsingError(node, L"A33: Cannot resolve type \"*\". This expression should only appear on a place which has an explicit type, including variables and arguments."); - } - - Ptr WfErrors::WrongVoidType(WfType* node) - { - return new ParsingError(node, L"B0: Void is not a type for a value."); - } - - Ptr WfErrors::WrongInterfaceType(WfType* node) - { - return new ParsingError(node, L"B1: Interface is not a type for a value."); - } - - Ptr WfErrors::RawPointerToNonReferenceType(WfType* node, reflection::description::ITypeInfo* typeInfo) - { - return new ParsingError(node, L"B2: A raw pointer" + (typeInfo ? L" \"" + typeInfo->GetTypeFriendlyName() + L"\"" : L"") + L" should point to a class or interface."); - } - - Ptr WfErrors::SharedPointerToNonReferenceType(WfType* node, reflection::description::ITypeInfo* typeInfo) - { - return new ParsingError(node, L"B3: A shared pointer" + (typeInfo ? L" \"" + typeInfo->GetTypeFriendlyName() + L"\"" : L"") + L" should point to a class or interface."); - } - - Ptr WfErrors::NullableToNonReferenceType(WfType* node, reflection::description::ITypeInfo* typeInfo) - { - return new ParsingError(node, L"B4: A nullable value" + (typeInfo ? L" \"" + typeInfo->GetTypeFriendlyName() + L"\"" : L"") + L" should point to a struct."); - } - - Ptr WfErrors::ChildOfNonReferenceType(WfType* node) - { - return new ParsingError(node, L"B5: Only a reference type have child types."); - } - - Ptr WfErrors::TypeNotExists(WfType* node, Ptr scopeName) - { - return new ParsingError(node, L"B6: \"" + scopeName->GetFriendlyName() + L"\" is not a type."); - } - - Ptr WfErrors::TypeNotExists(WfType* node, const ResolveExpressionResult& result) - { - return new ParsingError(node, L"B6: \"" + result.GetFriendlyName() + L"\" is not a type."); - } - - Ptr WfErrors::TypeNotForValue(WfType* node, reflection::description::ITypeInfo* typeInfo) - { - return new ParsingError(node, L"B7: Type \"" + typeInfo->GetTypeFriendlyName() + L"\" is not a type for a value."); - } - - Ptr WfErrors::BreakNotInLoop(WfStatement* node) - { - return new ParsingError(node, L"C0: Break statement should appear in a loop."); - } - - Ptr WfErrors::ContinueNotInLoop(WfStatement* node) - { - return new ParsingError(node, L"C1: Continue statement should appear in a loop."); - } - - Ptr WfErrors::RethrowNotInCatch(WfStatement* node) - { - return new ParsingError(node, L"C2: Re-raise exception statement should appear in catch."); - } - - Ptr WfErrors::TryMissCatchAndFinally(WfStatement* node) - { - return new ParsingError(node, L"C3: Try statement should not appear without both catch and finally."); - } - - Ptr WfErrors::ReturnMissExpression(WfStatement* node, reflection::description::ITypeInfo* type) - { - return new ParsingError(node, L"C4: Return statement requires an expression of type \"" + type->GetTypeFriendlyName() + L"\"."); - } - - Ptr WfErrors::DeleteNonRawPointer(WfStatement* node, reflection::description::ITypeInfo* type) - { - return new ParsingError(node, L"C5: Delete statement cannot apply on an expression of type \"" + type->GetTypeFriendlyName() + L"\", which is expected to be a raw pointer."); - } - - Ptr WfErrors::CannotReturnExpression(WfStatement* node) - { - return new ParsingError(node, L"C6: Return statement cannot have a value inside void functions, constructors, destructors or $coroutine expressions."); - } - - Ptr WfErrors::WrongCoPause(WfStatement* node) - { - return new ParsingError(node, L"C7: $pause statement should appear inside a $coroutine expression, and it cannot be nested."); - } - - Ptr WfErrors::WrongCoOperator(WfStatement* node) - { - return new ParsingError(node, L"C8: $Operator statement should appear inside a coroutine function (which has a functiona body like ${} or $Provider{})."); - } - - Ptr WfErrors::CoProviderNotExists(WfCoProviderStatement* node, collections::List& candidates) - { - WString description; - FOREACH(WString, candidate, candidates) - { - description += L"\r\n\t"; - description += candidate; - } - if (node->name.value == L"") - { - return new ParsingError(node, L"C9: Cannot find a coroutine provider based on the function return type, all of the following types do not exist: " + description + L"."); - } - else - { - return new ParsingError(node, L"C9: Cannot find a coroutine provider based on the provider name \"" + node->name.value.Right(node->name.value.Length() - 1) + L"\", all of the following types do not exist: " + description + L"."); - } - } - - Ptr WfErrors::CoOperatorNotExists(WfReturnStatement* node, reflection::description::ITypeInfo* type) - { - return new ParsingError(node, L"C10: Static function \"ReturnAndExit\" does not exist in coroutine provider \"" + type->GetTypeFriendlyName() + L"\"."); - } - - Ptr WfErrors::CoOperatorNotExists(WfCoOperatorStatement* node, reflection::description::ITypeInfo* type) - { - auto operatorName = node->opName.value.Right(node->opName.value.Length() - 1); - if (node->varName.value == L"") - { - return new ParsingError(node, L"C10: Static functions \"" + operatorName + L"AndPause\" and \"" + operatorName + L"AndRead\" do not exist in coroutine provider \"" + type->GetTypeFriendlyName() + L"\"."); - } - else - { - return new ParsingError(node, L"C10: Static function \"" + operatorName + L"AndRead\" does not exist in coroutine provider \"" + type->GetTypeFriendlyName() + L"\"."); - } - } - - Ptr WfErrors::CoOperatorCannotResolveResultType(WfCoOperatorStatement* node, collections::List& types) - { - auto operatorName = node->opName.value.Right(node->opName.value.Length() - 1); - if (node->arguments.Count() == 0) - { - return new ParsingError(node, L"C11: Failed to resolve the result type of coroutine operator \"" + operatorName + L"\", since there is no argument."); - } - else - { - WString description; - FOREACH(ITypeInfo*, type, types) - { - description += L"\r\n\t"; - description += type->GetTypeFriendlyName(); - } - return new ParsingError(node, L"C11: Failed to resolve the result type of coroutine operator \"" + operatorName + L"\", no appropriate static function \"CastResult\" is found in the following types. It requires exactly one argument of type \"object\" with a return type which is not \"void\": " + description + L"."); - } - } - - Ptr WfErrors::CoProviderCreateNotExists(WfCoProviderStatement* node, reflection::description::ITypeInfo* type) - { - return new ParsingError(node, L"C12: The required static function \"Create\" does not exist in coroutine provider \"" + type->GetTypeFriendlyName() + L"\". It is required to have exactly one argument of a function type, which consumes a pointer type and returns system::Coroutine^"); - } - - Ptr WfErrors::CoProviderCreateAndRunNotExists(WfCoProviderStatement* node, reflection::description::ITypeInfo* type) - { - return new ParsingError(node, L"C12: The required static function \"CreateAndRun\" does not exist in coroutine provider \"" + type->GetTypeFriendlyName() + L"\". It is required to have exactly one argument of a function type, which consumes a pointer type and returns system::Coroutine^"); - } - - Ptr WfErrors::FunctionShouldHaveName(WfDeclaration* node) - { - return new ParsingError(node, L"D0: Function should have a name."); - } - - Ptr WfErrors::FunctionShouldHaveImplementation(WfDeclaration* node) - { - return new ParsingError(node, L"D0: Function should be implemented."); - } - - Ptr WfErrors::InterfaceMethodShouldNotHaveImplementation(WfDeclaration* node) - { - return new ParsingError(node, L"D0: Interface method should not be implemented."); - } - - Ptr WfErrors::DuplicatedDeclaration(WfDeclaration* node, const WString& firstDeclarationCategory) - { - return new ParsingError(node, L"D1: Duplicated declaration \"" + node->name.value + L"\", it has already beed defined as a " + firstDeclarationCategory + L"."); - } - - Ptr WfErrors::DuplicatedSymbol(WfDeclaration* node, Ptr symbol) - { - return new ParsingError(node, L"D2: Duplicated symbol \"" + symbol->name + L"\"."); - } - - Ptr WfErrors::DuplicatedSymbol(WfFunctionArgument* node, Ptr symbol) - { - return new ParsingError(node, L"D2: Duplicated symbol \"" + symbol->name + L"\"."); - } - - Ptr WfErrors::DuplicatedSymbol(WfStatement* node, Ptr symbol) - { - return new ParsingError(node, L"D2: Duplicated symbol \"" + symbol->name + L"\"."); - } - - Ptr WfErrors::DuplicatedSymbol(WfExpression* node, Ptr symbol) - { - return new ParsingError(node, L"D2: Duplicated symbol \"" + symbol->name + L"\"."); - } - - Ptr WfErrors::InterfaceMethodNotImplemented(WfNewInterfaceExpression* node, reflection::description::IMethodInfo* method) - { - auto result = ResolveExpressionResult::Method(method); - return new ParsingError(node, L"D3: Interface method not implemented: " + result.GetFriendlyName() + L"."); - } - - Ptr WfErrors::InterfaceMethodNotFound(WfFunctionDeclaration* node, reflection::description::ITypeInfo* interfaceType, reflection::description::ITypeInfo* methodType) - { - return new ParsingError(node, L"D4: Interface \"" + interfaceType->GetTypeFriendlyName() + L"\" does not contain method \"" + node->name.value + L"\" which is in type \"" + methodType->GetTypeFriendlyName() + L"\"."); - } - - Ptr WfErrors::CannotPickOverloadedInterfaceMethods(WfExpression* node, collections::List& results) - { - WString description; - FOREACH_INDEXER(ResolveExpressionResult, result, index, results) - { - description += L"\r\n\t"; - description += result.GetFriendlyName(); - } - return new ParsingError(node, L"D5: Cannot decide which function to implement in multiple targets: " + description + L"."); - } - - Ptr WfErrors::CannotPickOverloadedImplementMethods(WfFunctionDeclaration* node, reflection::description::ITypeInfo* type) - { - return new ParsingError(node, L"D6: There are some other methods named \"" + node->name.value + L"\" whose types are also \"" + type->GetTypeFriendlyName() + L"\"."); - } - - Ptr WfErrors::WrongDeclaration(WfEventDeclaration* node) - { - return new ParsingError(node, L"D7: Event \"" + node->name.value + L"\" cannot be defined outside of classes or interfaces."); - } - - Ptr WfErrors::WrongDeclaration(WfPropertyDeclaration* node) - { - return new ParsingError(node, L"D7: Property \"" + node->name.value + L"\" cannot be defined outside of classes or interfaces."); - } - - Ptr WfErrors::WrongDeclaration(WfConstructorDeclaration* node) - { - return new ParsingError(node, L"D7: Constructor cannot be defined outside of classes."); - } - - Ptr WfErrors::WrongDeclaration(WfDestructorDeclaration* node) - { - return new ParsingError(node, L"D7: Destructor cannot be defined outside of classes."); - } - - Ptr WfErrors::WrongDeclaration(WfAutoPropertyDeclaration* node) - { - return new ParsingError(node, L"D7: Auto-property cannot be defined outside of classes."); - } - - Ptr WfErrors::WrongDeclarationInInterfaceConstructor(WfDeclaration* node) - { - return new ParsingError(node, L"D8: \"" + node->name.value + L"\" cannot be defined in an new interface expression, only functions, variables and auto-properties are allowed."); - } - - Ptr WfErrors::EnumValuesNotConsecutiveFromZero(WfEnumDeclaration* node) - { - return new ParsingError(node, L"D9: Item values in enum \"" + node->name.value + L"\" should be consecutive and starts from zero, like 0, 1, 2, 3, 4, ..."); - } - - Ptr WfErrors::FlagValuesNotConsecutiveFromZero(WfEnumDeclaration* node) - { - return new ParsingError(node, L"D9: Item values in flag enum \"" + node->name.value + L"\" should be consecutive powers of 2 and starts from zero, like 0, 1, 2, 4, 8, ..."); - } - - Ptr WfErrors::FlagValueNotExists(WfEnumItemIntersection* node, WfEnumDeclaration* owner) - { - return new ParsingError(node, L"D10: Item \"" + node->name.value + L" does not exists in the current flag enum \"" + owner->name.value + L"\"."); - } - - Ptr WfErrors::DuplicatedEnumValue(WfEnumItem* node, WfEnumDeclaration* owner) - { - return new ParsingError(node, L"D11: Item \"" + node->name.value + L" already exists in the current enum \"" + owner->name.value + L"\"."); - } - - Ptr WfErrors::StructContainsNonValueType(WfStructMember* node, WfStructDeclaration* owner) - { - return new ParsingError(node, L"D12: Type of member \"" + node->name.value + L"\" of struct \"" + owner->name.value + L"\" is not value type."); - } - - Ptr WfErrors::StructRecursivelyIncludeItself(WfStructDeclaration* node, const WString& path) - { - return new ParsingError(node, L"D13: Struct \"" + node->name.value + L"\" recursively include itself via \"" + path + L"\"."); - } - - Ptr WfErrors::DuplicatedStructMember(WfStructMember* node, WfStructDeclaration* owner) - { - return new ParsingError(node, L"D14: Member \"" + node->name.value + L"\" already exists in struct \"" + owner->name.value + L"\"."); - } - - Ptr WfErrors::AttributeNotExists(WfAttribute* node) - { - return new ParsingError(node, L"D15: Attribute \"" + node->category.value + L":" + node->name.value + L"\" does not exist."); - } - - Ptr WfErrors::AttributeMissValue(WfAttribute* node) - { - return new ParsingError(node, L"D15: Value of attribute \"" + node->category.value + L":" + node->name.value + L"\" is missing."); - } - - Ptr WfErrors::WrongUsingPathWildCard(WfModuleUsingPath* node) - { - return new ParsingError(node, L"E0: Wild card \"*\" should only appear in the last item of the using path and should appear once."); - } - - Ptr WfErrors::TopQualifiedSymbolNotExists(parsing::ParsingTreeCustomBase* node, const WString& name) - { - return new ParsingError(node, L"F0: Top qualified symbol \"" + name + L"\" does not exist."); - } - - Ptr WfErrors::ChildSymbolNotExists(parsing::ParsingTreeCustomBase* node, Ptr scopeName, const WString& name) - { - return new ParsingError(node, L"F1: Symbol \"" + name + L"\" does not exist in \"" + scopeName->GetFriendlyName() + L"\"."); - } - - Ptr WfErrors::MemberNotExists(parsing::ParsingTreeCustomBase* node, reflection::description::ITypeDescriptor* typeDescriptor, const WString& name) - { - return new ParsingError(node, L"F1: Member \"" + name + L"\" does not exist in \"" + typeDescriptor->GetTypeName() + L"\"."); - } - - Ptr WfErrors::ReferenceNotExists(parsing::ParsingTreeCustomBase* node, const WString& name) - { - return new ParsingError(node, L"F2: Symbol \"" + name + L"\" does not exist in the current scope."); - } - - Ptr WfErrors::TooManyTargets(parsing::ParsingTreeCustomBase* node, collections::List& results, const WString& name) - { - WString description; - FOREACH_INDEXER(ResolveExpressionResult, result, index, results) - { - description += L"\r\n\t"; - description += result.GetFriendlyName(); - } - return new ParsingError(node, L"F3: Symbol \"" + name + L"\" references to too many targets: " + description + L"."); - } - - Ptr WfErrors::EnumItemNotExists(parsing::ParsingTreeCustomBase* node, reflection::description::ITypeDescriptor* typeDescriptor, const WString& name) - { - return new ParsingError(node, L"F2: Enum item \"" + name + L"\" does not exist in enum type \"" + typeDescriptor->GetTypeName() + L"\"."); - } - - Ptr WfErrors::WrongClassMemberConfig(WfDeclaration* node) - { - return new ParsingError(node, L"G1: Class member \"" + node->name.value + L"\" cannot be static or override because it is not a function or a auto-property."); - } - - Ptr WfErrors::FunctionInNewTypeExpressionCannotBeStatic(WfDeclaration* node) - { - return new ParsingError(node, L"G1: Class member \"" + node->name.value + L"\" cannot be static because it is in a new interface expression."); - } - - Ptr WfErrors::AutoPropertyCannotBeNormalOutsideOfClass(WfDeclaration* node) - { - return new ParsingError(node, L"G1: Auto property \"" + node->name.value + L"\" cannot be normal outside of classes or interfaces."); - } - - Ptr WfErrors::AutoPropertyCannotBeStatic(WfDeclaration* node) - { - return new ParsingError(node, L"G1: Auto property \"" + node->name.value + L"\" cannot be static ."); - } - - Ptr WfErrors::WrongClassMember(WfNamespaceDeclaration* node) - { - return new ParsingError(node, L"G2: Namespace \"" + node->name.value + L"\" cannot be a class member."); - } - - Ptr WfErrors::PropertyGetterNotFound(WfPropertyDeclaration* node, WfClassDeclaration* classDecl) - { - return new ParsingError(node, L"G3: Cannot find the getter \"" + node->getter.value + L"\" of property \"" + node->name.value + L"\" in type \"" + classDecl->name.value + L"\". A property getter should be a non-static method in the same type."); - } - - Ptr WfErrors::PropertySetterNotFound(WfPropertyDeclaration* node, WfClassDeclaration* classDecl) - { - return new ParsingError(node, L"G3: Cannot find the setter \"" + node->setter.value + L"\" of property \"" + node->name.value + L"\" in type \"" + classDecl->name.value + L"\". A property setter should be a non-static method in the same type."); - } - - Ptr WfErrors::PropertyEventNotFound(WfPropertyDeclaration* node, WfClassDeclaration* classDecl) - { - return new ParsingError(node, L"G3: Cannot find the event \"" + node->valueChangedEvent.value + L"\" of property \"" + node->name.value + L"\" in type \"" + classDecl->name.value + L"\"."); - } - - Ptr WfErrors::TooManyPropertyGetter(WfPropertyDeclaration* node, WfClassDeclaration* classDecl) - { - return new ParsingError(node, L"G4: Too many symbols found for the getter \"" + node->getter.value + L"\" of property \"" + node->name.value + L"\" in type \"" + classDecl->name.value + L"\"."); - } - - Ptr WfErrors::TooManyPropertySetter(WfPropertyDeclaration* node, WfClassDeclaration* classDecl) - { - return new ParsingError(node, L"G4: Too many symbols found for the setter \"" + node->setter.value + L"\" of property \"" + node->name.value + L"\" in type \"" + classDecl->name.value + L"\"."); - } - - Ptr WfErrors::TooManyPropertyEvent(WfPropertyDeclaration* node, WfClassDeclaration* classDecl) - { - return new ParsingError(node, L"G4: Too many symbols found for the event \"" + node->valueChangedEvent.value + L"\" of property \"" + node->name.value + L"\" in type \"" + classDecl->name.value + L"\"."); - } - - Ptr WfErrors::PropertyGetterTypeMismatched(WfPropertyDeclaration* node, WfClassDeclaration* classDecl) - { - return new ParsingError(node, L"G5: Cannot match the getter \"" + node->getter.value + L"\" of property \"" + node->name.value + L"\" in type \"" + classDecl->name.value + L"\". A property getter should have no argument, and its return type should be identical to the property type."); - } - - Ptr WfErrors::PropertySetterTypeMismatched(WfPropertyDeclaration* node, WfClassDeclaration* classDecl) - { - return new ParsingError(node, L"G5: Cannot match the setter \"" + node->getter.value + L"\" of property \"" + node->name.value + L"\" in type \"" + classDecl->name.value + L"\". A property setter should have no return value and have only one argument, and the argument type should be identical to the property type."); - } - - Ptr WfErrors::WrongBaseType(WfClassDeclaration* node, WfType* type) - { - return new ParsingError(node, L"G6: A base type of the type \"" + node->name.value + L"\" should be another custom type, it cannot be any predefined type, pointer type, shared pointer type, nullable type, collection type, or function type"); - } - - Ptr WfErrors::WrongBaseTypeOfClass(WfClassDeclaration* node, reflection::description::ITypeDescriptor* type) - { - return new ParsingError(node, L"G6: Base type \"" + type->GetTypeName() + L"\" of class \"" + node->name.value + L"\" is not a class, or it is a class but it is not aggregatable."); - } - - Ptr WfErrors::WrongBaseTypeOfInterface(WfClassDeclaration* node, reflection::description::ITypeDescriptor* type) - { - return new ParsingError(node, L"G6: Base type \"" + type->GetTypeName() + L"\" of interface \"" + node->name.value + L"\" is not an interface."); - } - - Ptr WfErrors::WrongInterfaceBaseType(WfClassDeclaration* node, reflection::description::ITypeDescriptor* type) - { - Ptr proxy = TypeInfoRetriver>::CreateTypeInfo(); - return new ParsingError(node, L"G6: Interface \"" + type->GetTypeName() + L"\" should contain a constructor receiving an \"" + proxy->GetTypeFriendlyName() + L"\" to be the base type of \"" + node->name.value + L"\"."); - } - - Ptr WfErrors::ClassWithInterfaceConstructor(WfClassDeclaration* node) - { - return new ParsingError(node, L"G7: Cannot use interface constructor type on class \"" + node->name.value + L"\"."); - } - - Ptr WfErrors::OverrideShouldImplementInterfaceMethod(WfFunctionDeclaration* node) - { - return new ParsingError(node, L"G8: Function \"" + node->name.value + L"\" cannot be override because it doesn't implement any interface methods."); - } - - Ptr WfErrors::OverrideShouldImplementInterfaceMethod(WfAutoPropertyDeclaration* node) - { - return new ParsingError(node, L"G8: Auto-property \"" + node->name.value + L"\" cannot be override because it doesn't implement any interface methods."); - } - - Ptr WfErrors::MissingFieldType(WfVariableDeclaration* node) - { - return new ParsingError(node, L"G9: Type of field \"" + node->name.value + L"\" is missing."); - } - - Ptr WfErrors::DuplicatedBaseClass(WfClassDeclaration* node, reflection::description::ITypeDescriptor* type) - { - return new ParsingError(node, L"G10: Class \"" + node->name.value + L"\" inherits from another class \"" + type->GetTypeName() + L"\" for multiple times."); - } - - Ptr WfErrors::DuplicatedBaseInterface(WfClassDeclaration* node, reflection::description::ITypeDescriptor* type) - { - return new ParsingError(node, L"G10: Interface \"" + type->GetTypeName() + L"\" directly or indirectly inherits from itself."); - } - - Ptr WfErrors::WrongBaseConstructorCall(WfBaseConstructorCall* node, reflection::description::ITypeDescriptor* type) - { - return new ParsingError(node, L"G11: Type \"" + type->GetTypeName() + L"\" is not a base type of this class."); - } - - Ptr WfErrors::DuplicatedBaseConstructorCall(WfBaseConstructorCall* node, reflection::description::ITypeDescriptor* type) - { - return new ParsingError(node, L"G12: Base type \"" + type->GetTypeName() + L"\" has already been initialized."); - } - - Ptr WfErrors::TooManyDestructor(WfDestructorDeclaration* node, WfClassDeclaration* classDecl) - { - return new ParsingError(node, L"G13: Class \"" + classDecl->name.value + L"\" has too many destructors."); - } - - Ptr WfErrors::AutoPropertyShouldBeInitialized(WfAutoPropertyDeclaration* node) - { - return new ParsingError(node, L"G13: Auto property \"" + node->name.value + L"\" should be initialized."); - } - - Ptr WfErrors::AutoPropertyCannotBeInitializedInInterface(WfAutoPropertyDeclaration* node, WfClassDeclaration* classDecl) - { - return new ParsingError(node, L"G13: Auto property \"" + node->name.value + L"\" cannot be initialized in interface \"" + classDecl->name.value + L"\"."); - } - } - } -} - -/*********************************************************************** -ANALYZER\WFANALYZER_EXPANDBINDEXPRESSION.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace analyzer - { - using namespace collections; - using namespace reflection; - using namespace reflection::description; - -/*********************************************************************** -observing expressions: - WfObserveExpression - WfMemberExpression that detects the event -***********************************************************************/ - - class BindContext : public Object - { - typedef collections::List ExprList; - typedef collections::Dictionary ExprMap; - typedef collections::Group ExprGroup; - typedef collections::Group ExprEventGroup; - public: - ExprMap observeParents; - ExprEventGroup observeEvents; - ExprList orderedObserves; - ExprList cachedExprs; // expression that need to cache its value - ExprMap renames; // expression -> the expression being renamed - - ExprGroup exprAffects; // observe expression -> all expressions that it can cause to change - ExprGroup exprCauses; // expression -> observe expressions that cause it to change - ExprGroup observeAffects; // observe expression -> all observe expressions that it can cause to change - ExprGroup observeCauses; // observe expression -> observe expressions that cause it to change - - WString GetCacheVariableName(vint index) - { - return L"" + itow(index); - } - - vint GetCachedExpressionIndex(WfExpression* expression, bool ensureExists) - { - vint index = cachedExprs.IndexOf(expression); - if (ensureExists) - { - CHECK_ERROR(index != -1, L"BindContext::GetCachedExpressionIndex(WfExpression*, bool)#Cached expression not exists."); - } - return index; - } - - vint GetCachedExpressionIndexRecursively(WfExpression* expression, bool ensureExists) - { - WfExpression* cache = expression; - while (true) - { - vint index = renames.Keys().IndexOf(cache); - if (index == -1) - { - return GetCachedExpressionIndex(cache, ensureExists); - } - else - { - cache = renames.Values()[index]; - } - } - } - }; - - struct CallbackInfo - { - WfExpression* observe; - IEventInfo* eventInfo; - vint eventIndex; - WString handlerName; - WString callbackName; - }; - - struct BindCallbackInfo - { - Dictionary> handlerVariables; - Dictionary> callbackFunctions; - Group observeCallbackInfos; - }; - -/*********************************************************************** -CreateBindContext -***********************************************************************/ - - class CreateBindContextVisitor : public Object, public WfExpression::IVisitor - { - public: - WfLexicalScopeManager* manager; - BindContext& context; - - CreateBindContextVisitor(WfLexicalScopeManager* _manager, BindContext& _context) - :manager(_manager) - , context(_context) - { - } - - void Call(WfExpression* node) - { - node->Accept(this); - } - - void ObservableDepend(WfExpression* expr, WfExpression* parent) - { - context.orderedObserves.Add(expr); - context.observeParents.Add(expr, parent); - DirectDepend(expr, parent, false); - { - auto cache = parent; - while (true) - { - vint index = context.renames.Keys().IndexOf(cache); - if (index == -1) - { - index = context.cachedExprs.IndexOf(cache); - if (index == -1) - { - context.cachedExprs.Add(cache); - } - break; - } - else - { - cache = context.renames.Values()[index]; - } - } - } - - vint index = context.exprCauses.Keys().IndexOf(parent); - if (index != -1) - { - FOREACH(WfExpression*, observe, context.exprCauses.GetByIndex(index)) - { - context.observeAffects.Add(observe, expr); - context.observeCauses.Add(expr, observe); - } - } - - context.exprAffects.Add(expr, expr); - context.exprCauses.Add(expr, expr); - } - - void DirectDepend(WfExpression* expr, WfExpression* depended, bool processDepended = true) - { - if (processDepended) - { - Call(depended); - } - - vint index = context.exprCauses.Keys().IndexOf(depended); - if (index != -1) - { - FOREACH(WfExpression*, observe, context.exprCauses.GetByIndex(index)) - { - context.exprCauses.Add(expr, observe); - context.exprAffects.Add(observe, expr); - } - } - } - - void Visit(WfThisExpression* node)override - { - // root expression, nothing to do - } - - void Visit(WfTopQualifiedExpression* node)override - { - // root expression, nothing to do - } - - void Visit(WfReferenceExpression* node)override - { - auto result = manager->expressionResolvings[node]; - if (result.symbol) - { - auto scope = result.symbol->ownerScope; - if (auto letExpr = dynamic_cast(scope->ownerNode.Obj())) - { - auto letVar = From(letExpr->variables) - .Where([=](const Ptr& letVar) - { - return letVar->name.value == node->name.value; - }) - .First(); - context.renames.Add(node, letVar->value.Obj()); - DirectDepend(node, letVar->value.Obj(), false); - } - else if (auto observeExpr = dynamic_cast(scope->ownerNode.Obj())) - { - context.renames.Add(node, observeExpr->parent.Obj()); - DirectDepend(node, observeExpr->parent.Obj()); - } - } - } - - void Visit(WfOrderedNameExpression* node)override - { - // root expression, nothing to do - } - - void Visit(WfOrderedLambdaExpression* node)override - { - // root expression, nothing to do - } - - void Visit(WfMemberExpression* node)override - { - Call(node->parent.Obj()); - - auto scope = manager->nodeScopes[node].Obj(); - while (scope) - { - if (scope->ownerNode.Cast()) - { - break; - } - scope = scope->parentScope.Obj(); - } - - if (!scope) - { - auto memberResult = manager->expressionResolvings[node]; - if (memberResult.propertyInfo) - { - auto td = memberResult.propertyInfo->GetOwnerTypeDescriptor(); - auto ev = memberResult.propertyInfo->GetValueChangedEvent(); - if (!ev) - { - ev = td->GetEventByName(memberResult.propertyInfo->GetName() + L"Changed", true); - } - if (ev) - { - ObservableDepend(node, node->parent.Obj()); - context.observeEvents.Add(node, ev); - return; - } - } - } - - DirectDepend(node, node->parent.Obj(), false); - } - - void Visit(WfChildExpression* node)override - { - DirectDepend(node, node->parent.Obj()); - } - - void Visit(WfLiteralExpression* node)override - { - // root expression, nothing to do - } - - void Visit(WfFloatingExpression* node)override - { - // root expression, nothing to do - } - - void Visit(WfIntegerExpression* node)override - { - // root expression, nothing to do - } - - void Visit(WfStringExpression* node)override - { - // root expression, nothing to do - } - - void Visit(WfUnaryExpression* node)override - { - DirectDepend(node, node->operand.Obj()); - } - - void Visit(WfBinaryExpression* node)override - { - DirectDepend(node, node->first.Obj()); - DirectDepend(node, node->second.Obj()); - } - - void Visit(WfLetExpression* node)override - { - FOREACH(Ptr, var, node->variables) - { - DirectDepend(node, var->value.Obj()); - } - DirectDepend(node, node->expression.Obj()); - } - - void Visit(WfIfExpression* node)override - { - DirectDepend(node, node->condition.Obj()); - DirectDepend(node, node->trueBranch.Obj()); - DirectDepend(node, node->falseBranch.Obj()); - } - - void Visit(WfRangeExpression* node)override - { - DirectDepend(node, node->begin.Obj()); - DirectDepend(node, node->end.Obj()); - } - - void Visit(WfSetTestingExpression* node)override - { - DirectDepend(node, node->collection.Obj()); - DirectDepend(node, node->element.Obj()); - } - - void Visit(WfConstructorExpression* node)override - { - auto result = manager->expressionResolvings[node]; - bool isStruct = (result.type->GetTypeDescriptor()->GetTypeDescriptorFlags() == TypeDescriptorFlags::Struct); - - FOREACH(Ptr, argument, node->arguments) - { - if (!isStruct) - { - DirectDepend(node, argument->key.Obj()); - } - DirectDepend(node, argument->value.Obj()); - } - } - - void Visit(WfInferExpression* node)override - { - DirectDepend(node, node->expression.Obj()); - } - - void Visit(WfTypeCastingExpression* node)override - { - DirectDepend(node, node->expression.Obj()); - } - - void Visit(WfTypeTestingExpression* node)override - { - DirectDepend(node, node->expression.Obj()); - } - - void Visit(WfTypeOfTypeExpression* node)override - { - // root expression, nothing to do - } - - void Visit(WfTypeOfExpressionExpression* node)override - { - // root expression, nothing to do - } - - void Visit(WfAttachEventExpression* node)override - { - DirectDepend(node, node->event.Obj()); - DirectDepend(node, node->function.Obj()); - } - - void Visit(WfDetachEventExpression* node)override - { - DirectDepend(node, node->event.Obj()); - DirectDepend(node, node->handler.Obj()); - } - - void Visit(WfObserveExpression* node)override - { - Call(node->parent.Obj()); - ObservableDepend(node, node->parent.Obj()); - Call(node->expression.Obj()); - FOREACH(Ptr, eventExpr, node->events) - { - auto result = manager->expressionResolvings[eventExpr.Obj()]; - context.observeEvents.Add(node, result.eventInfo); - Call(eventExpr.Obj()); - } - } - - void Visit(WfCallExpression* node)override - { - DirectDepend(node, node->function.Obj()); - FOREACH(Ptr, argument, node->arguments) - { - DirectDepend(node, argument.Obj()); - } - } - - void Visit(WfFunctionExpression* node)override - { - // root expression, nothing to do - } - - void Visit(WfNewClassExpression* node)override - { - FOREACH(Ptr, argument, node->arguments) - { - DirectDepend(node, argument.Obj()); - } - } - - void Visit(WfNewInterfaceExpression* node)override - { - // root expression, nothing to do - } - - void Visit(WfVirtualExpression* node)override - { - DirectDepend(node, node->expandedExpression.Obj()); - } - }; - -/*********************************************************************** -Copy(Type|Expression|Statement|Declaration) -***********************************************************************/ - - Ptr CopyType(Ptr type) - { - return copy_visitor::ModuleVisitor().CreateField(type); - } - - Ptr CopyExpression(Ptr expression) - { - return copy_visitor::ModuleVisitor().CreateField(expression); - } - - Ptr CopyStatement(Ptr statement) - { - return copy_visitor::ModuleVisitor().CreateField(statement); - } - - Ptr CopyDeclaration(Ptr declaration) - { - return copy_visitor::ModuleVisitor().CreateField(declaration); - } - -/*********************************************************************** -ExpandObserveExpression -***********************************************************************/ - - Ptr CreateReference(const WString& name) - { - auto ref = MakePtr(); - ref->name.value = name; - return ref; - } - - class ExpandObserveExpressionVisitor - : public copy_visitor::ExpressionVisitor - , public copy_visitor::VirtualExpressionVisitor - { - public: - BindContext& context; - - ExpandObserveExpressionVisitor(BindContext& _context) - :context(_context) - { - } - - static Ptr Execute(WfExpression* expression, BindContext& context, bool expandImmediately = true) - { - if (!expression) - { - return nullptr; - } - - { - vint index = context.GetCachedExpressionIndexRecursively(expression, false); - if (index != -1) - { - if (expandImmediately) - { - return CreateReference(context.GetCacheVariableName(index)); - } - else - { - expression = context.cachedExprs[index]; - } - } - } - - ExpandObserveExpressionVisitor visitor(context); - expression->Accept(&visitor); - return visitor.result.Cast(); - } - - vl::Ptr CreateField(vl::Ptr from)override - { - return Execute(from.Obj(), context); - } - - vl::Ptr CreateField(vl::Ptr from)override - { - return CopyType(from); - } - - vl::Ptr CreateField(vl::Ptr from)override - { - return CopyStatement(from); - } - - vl::Ptr CreateField(vl::Ptr from)override - { - return CopyDeclaration(from); - } - - vl::Ptr Dispatch(WfVirtualExpression* node)override - { - node->Accept((WfVirtualExpression::IVisitor*)this); - return result; - } - - void Visit(WfLetExpression* node)override - { - auto letExpr = MakePtr(); - FOREACH(Ptr, var, node->variables) - { - if (context.GetCachedExpressionIndexRecursively(var->value.Obj(), false) == -1) - { - auto letVar = MakePtr(); - letVar->name.value = var->name.value; - letVar->value = Execute(var->value.Obj(), context); - letExpr->variables.Add(letVar); - } - } - - if (letExpr->variables.Count() == 0) - { - result = Execute(node->expression.Obj(), context); - } - else - { - letExpr->expression = Execute(node->expression.Obj(), context); - result = letExpr; - } - } - - void Visit(WfObserveExpression* node)override - { - if (node->observeType == WfObserveType::SimpleObserve) - { - auto expr = MakePtr(); - expr->parent = CreateField(node->parent); - expr->name.value = node->expression.Cast()->name.value; - result = expr; - } - else - { - result = CreateField(node->expression); - } - } - }; - -/*********************************************************************** -CreateDefaultValue -***********************************************************************/ - - Ptr CreateDefaultValue(ITypeInfo* elementType) - { - auto valueType = elementType->GetTypeDescriptor()->GetValueType(); - if (elementType->GetDecorator()==ITypeInfo::TypeDescriptor && valueType != nullptr) - { - auto value = valueType->CreateDefault(); - switch (GetTypeFlag(elementType)) - { - case TypeFlag::Enum: - { - auto intExpr = MakePtr(); - intExpr->value.value = u64tow(elementType->GetTypeDescriptor()->GetEnumType()->FromEnum(value)); - - auto inferExpr = MakePtr(); - inferExpr->strategy = WfTypeCastingStrategy::Strong; - inferExpr->expression = intExpr; - inferExpr->type = GetTypeFromTypeInfo(CreateTypeInfoFromTypeFlag(TypeFlag::U8).Obj()); - - auto castExpr = MakePtr(); - castExpr->strategy = WfTypeCastingStrategy::Strong; - castExpr->expression = inferExpr; - castExpr->type = GetTypeFromTypeInfo(elementType); - - return castExpr; - } - case TypeFlag::String: - { - auto stringExpr = MakePtr(); - elementType->GetTypeDescriptor()->GetSerializableType()->Serialize(value, stringExpr->value.value); - return stringExpr; - } - break; - case TypeFlag::Struct: - if (elementType->GetTypeDescriptor()->GetSerializableType() == nullptr) - { - auto ctorExpr = MakePtr(); - - auto castExpr = MakePtr(); - castExpr->strategy = WfTypeCastingStrategy::Strong; - castExpr->expression = ctorExpr; - castExpr->type = GetTypeFromTypeInfo(elementType); - - return castExpr; - } - default: - { - auto td = elementType->GetTypeDescriptor(); - if (td == description::GetTypeDescriptor()) - { - auto expr = MakePtr(); - expr->value = WfLiteralValue::False; - return expr; - } - else if (td == description::GetTypeDescriptor() - || td == description::GetTypeDescriptor()) - { - auto valueExpr = MakePtr(); - valueExpr->value.value = L"0"; - - auto inferExpr = MakePtr(); - inferExpr->expression = valueExpr; - inferExpr->type = GetTypeFromTypeInfo(elementType); - - return inferExpr; - } - else if (td == description::GetTypeDescriptor() - || td == description::GetTypeDescriptor() - || td == description::GetTypeDescriptor() - || td == description::GetTypeDescriptor() - || td == description::GetTypeDescriptor() - || td == description::GetTypeDescriptor() - || td == description::GetTypeDescriptor() - || td == description::GetTypeDescriptor()) - { - auto valueExpr = MakePtr(); - valueExpr->value.value = L"0"; - - auto inferExpr = MakePtr(); - inferExpr->expression = valueExpr; - inferExpr->type = GetTypeFromTypeInfo(elementType); - - return inferExpr; - } - else - { - auto stringExpr = MakePtr(); - elementType->GetTypeDescriptor()->GetSerializableType()->Serialize(value, stringExpr->value.value); - - auto castExpr = MakePtr(); - castExpr->strategy = WfTypeCastingStrategy::Strong; - castExpr->expression = stringExpr; - castExpr->type = GetTypeFromTypeInfo(elementType); - - return castExpr; - } - } - } - } - else - { - auto nullExpr = MakePtr(); - nullExpr->value = WfLiteralValue::Null; - - auto inferExpr = MakePtr(); - inferExpr->expression = nullExpr; - inferExpr->type = GetTypeFromTypeInfo(elementType); - - return inferExpr; - } - } - -/*********************************************************************** -CreateBindWritableVariable -***********************************************************************/ - - Ptr CreateWritableVariable(const WString& name, ITypeInfo* type, Ptr value = nullptr) - { - auto decl = MakePtr(); - decl->name.value = name; - decl->type = GetTypeFromTypeInfo(type); - decl->expression = value ? value : CreateDefaultValue(type); - return decl; - } - - Ptr CreateWritableVariableStatement(const WString& name, ITypeInfo* type, Ptr value = nullptr) - { - auto stat = MakePtr(); - stat->variable = CreateWritableVariable(name, type, value); - return stat; - } - -/*********************************************************************** -IValueSubscription::Subscribe -***********************************************************************/ - - Ptr AssignNormalMember(Ptr decl) - { - decl->classMember = MakePtr(); - decl->classMember->kind = WfClassMemberKind::Normal; - return decl; - } - - Ptr AssignOverrideMember(Ptr decl) - { - decl->classMember = MakePtr(); - decl->classMember->kind = WfClassMemberKind::Override; - return decl; - } - -/*********************************************************************** -ExpandObserveEvent -***********************************************************************/ - - Ptr ExpandObserveEvent(WfLexicalScopeManager* manager, WfExpression* observe, vint eventIndex, BindContext& context) - { - auto cacheName = context.GetCacheVariableName(context.GetCachedExpressionIndexRecursively(context.observeParents[observe], true)); - if (auto observeExpr = dynamic_cast(observe)) - { - if (observeExpr->observeType == WfObserveType::SimpleObserve) - { - auto expr = MakePtr(); - expr->parent = CreateReference(cacheName); - expr->name.value = observeExpr->events[eventIndex].Cast()->name.value; - return expr; - } - else - { - return ExpandObserveExpressionVisitor::Execute(observeExpr->events[eventIndex].Obj(), context); - } - } - else - { - auto eventName = context.observeEvents[observe][0]->GetName(); - - auto expr = MakePtr(); - expr->parent = CreateReference(cacheName); - expr->name.value = eventName; - - return expr; - } - } - -/*********************************************************************** -CreateBindAttachStatement -***********************************************************************/ - - void CreateBindAttachStatement(Ptr block, WfLexicalScopeManager* manager, WfExpression* observe, BindContext& context, BindCallbackInfo& info) - { - FOREACH(CallbackInfo, callbackInfo, info.observeCallbackInfos[observe]) - { - auto attach = MakePtr(); - attach->event = ExpandObserveEvent(manager, observe, callbackInfo.eventIndex, context); - attach->function = CreateReference(callbackInfo.callbackName); - - auto assign = MakePtr(); - assign->op = WfBinaryOperator::Assign; - assign->first = CreateReference(callbackInfo.handlerName); - assign->second = attach; - - auto stat = MakePtr(); - stat->expression = assign; - block->statements.Add(stat); - } - } - -/*********************************************************************** -CreateBindDetachStatement -***********************************************************************/ - - void CreateBindDetachStatement(Ptr block, WfLexicalScopeManager* manager, WfExpression* observe, BindContext& context, BindCallbackInfo& info) - { - FOREACH(CallbackInfo, callbackInfo, info.observeCallbackInfos[observe]) - { - auto detach = MakePtr(); - detach->event = ExpandObserveEvent(manager, observe, callbackInfo.eventIndex, context); - detach->handler = CreateReference(callbackInfo.handlerName); - - auto stat = MakePtr(); - stat->expression = detach; - block->statements.Add(stat); - } - } - -/*********************************************************************** -CreateBindCacheAssignStatement -***********************************************************************/ - - void CreateBindCacheAssignStatement(Ptr block, WfExpression* observe, BindContext& context) - { - auto parent = context.observeParents[observe]; - auto cacheName = context.GetCacheVariableName(context.GetCachedExpressionIndexRecursively(parent, true)); - - auto assign = MakePtr(); - assign->op = WfBinaryOperator::Assign; - assign->first = CreateReference(cacheName); - assign->second = ExpandObserveExpressionVisitor::Execute(parent, context, false); - - auto stat = MakePtr(); - stat->expression = assign; - block->statements.Add(stat); - } - -/*********************************************************************** -IValueSubscription::Open -***********************************************************************/ - - Ptr CreateBindOpenFunction(WfLexicalScopeManager* manager, BindContext& context, BindCallbackInfo& info) - { - auto func = MakePtr(); - func->name.value = L"Open"; - func->anonymity = WfFunctionAnonymity::Named; - { - auto typeInfo = TypeInfoRetriver::CreateTypeInfo(); - func->returnType = GetTypeFromTypeInfo(typeInfo.Obj()); - } - - auto block = MakePtr(); - func->statement = block; - { - auto ifStat = MakePtr(); - block->statements.Add(ifStat); - { - auto notExpr = MakePtr(); - notExpr->op = WfUnaryOperator::Not; - notExpr->operand = CreateReference(L""); - ifStat->expression = notExpr; - } - - auto ifBlock = MakePtr(); - ifStat->trueBranch = ifBlock; - { - auto literal = MakePtr(); - literal->value = WfLiteralValue::True; - - auto assign = MakePtr(); - assign->op = WfBinaryOperator::Assign; - assign->first = CreateReference(L""); - assign->second = literal; - - auto stat = MakePtr(); - stat->expression = assign; - ifBlock->statements.Add(stat); - } - { - SortedList assignedParents; - SortedList observes; - CopyFrom(observes, context.observeParents.Keys()); - - SortedList freeObserves; - while (observes.Count() > 0) - { - CopyFrom( - freeObserves, - From(observes) - .Where([&](WfExpression* observe) - { - return !context.observeCauses.Keys().Contains(observe) || - From(context.observeCauses[observe]) - .All([&](WfExpression* depended) - { - return !observes.Contains(depended); - }); - }) - ); - - FOREACH(WfExpression*, observe, context.orderedObserves) - { - if (freeObserves.Contains(observe)) - { - auto parent = context.GetCachedExpressionIndexRecursively(context.observeParents[observe], true); - if (!assignedParents.Contains(parent)) - { - assignedParents.Add(parent); - CreateBindCacheAssignStatement(ifBlock, observe, context); - } - } - } - - FOREACH(WfExpression*, observe, freeObserves) - { - observes.Remove(observe); - } - freeObserves.Clear(); - } - } - { - FOREACH(WfExpression*, observe, context.orderedObserves) - { - CreateBindAttachStatement(ifBlock, manager, observe, context, info); - } - } - { - auto literal = MakePtr(); - literal->value = WfLiteralValue::True; - - auto returnStat = MakePtr(); - returnStat->expression = literal; - ifBlock->statements.Add(returnStat); - } - } - { - auto literal = MakePtr(); - literal->value = WfLiteralValue::False; - - auto returnStat = MakePtr(); - returnStat->expression = literal; - block->statements.Add(returnStat); - } - - return func; - } - -/*********************************************************************** -IValueSubscription::Update -***********************************************************************/ - - Ptr CreateBindUpdateFunction(BindCallbackInfo& info) - { - auto func = MakePtr(); - func->name.value = L"Update"; - func->anonymity = WfFunctionAnonymity::Named; - { - auto typeInfo = TypeInfoRetriver::CreateTypeInfo(); - func->returnType = GetTypeFromTypeInfo(typeInfo.Obj()); - } - - auto block = MakePtr(); - func->statement = block; - { - auto ifStat = MakePtr(); - block->statements.Add(ifStat); - { - auto notExpr = MakePtr(); - notExpr->op = WfUnaryOperator::Not; - notExpr->operand = CreateReference(L""); - - auto andExpr = MakePtr(); - andExpr->op = WfBinaryOperator::And; - andExpr->first = CreateReference(L""); - andExpr->second = notExpr; - - ifStat->expression = andExpr; - } - - auto ifBlock = MakePtr(); - ifStat->trueBranch = ifBlock; - { - auto ref = CreateReference(L""); - - auto call = MakePtr(); - call->function = ref; - - auto stat = MakePtr(); - stat->expression = call; - ifBlock->statements.Add(stat); - } - { - auto literal = MakePtr(); - literal->value = WfLiteralValue::True; - - auto returnStat = MakePtr(); - returnStat->expression = literal; - ifBlock->statements.Add(returnStat); - } - } - { - auto literal = MakePtr(); - literal->value = WfLiteralValue::False; - - auto returnStat = MakePtr(); - returnStat->expression = literal; - block->statements.Add(returnStat); - } - - return func; - } - -/*********************************************************************** -IValueSubscription::Close -***********************************************************************/ - - Ptr CreateBindCloseFunction(WfLexicalScopeManager* manager, BindContext& context, BindCallbackInfo& info) - { - auto func = MakePtr(); - func->name.value = L"Close"; - func->anonymity = WfFunctionAnonymity::Named; - { - auto typeInfo = TypeInfoRetriver::CreateTypeInfo(); - func->returnType = GetTypeFromTypeInfo(typeInfo.Obj()); - } - - auto block = MakePtr(); - func->statement = block; - { - auto ifStat = MakePtr(); - block->statements.Add(ifStat); - { - auto notExpr = MakePtr(); - notExpr->op = WfUnaryOperator::Not; - notExpr->operand = CreateReference(L""); - ifStat->expression = notExpr; - } - - auto ifBlock = MakePtr(); - ifStat->trueBranch = ifBlock; - { - auto literal = MakePtr(); - literal->value = WfLiteralValue::True; - - auto assign = MakePtr(); - assign->op = WfBinaryOperator::Assign; - assign->first = CreateReference(L""); - assign->second = literal; - - auto stat = MakePtr(); - stat->expression = assign; - ifBlock->statements.Add(stat); - } - FOREACH(WfExpression*, observe, context.orderedObserves) - { - CreateBindDetachStatement(ifBlock, manager, observe, context, info); - } - - for (vint i = 0; i < context.cachedExprs.Count(); i++) - { - auto cacheName = context.GetCacheVariableName(i); - auto type = manager->expressionResolvings[context.cachedExprs[i]].type; - - auto assign = MakePtr(); - assign->op = WfBinaryOperator::Assign; - assign->first = CreateReference(cacheName); - assign->second = CreateDefaultValue(type.Obj()); - - auto stat = MakePtr(); - stat->expression = assign; - ifBlock->statements.Add(stat); - } - for (vint i = 0; i < info.handlerVariables.Count(); i++) - { - auto cacheName = info.handlerVariables.Keys()[i]; - auto result = info.handlerVariables.Values()[i]; - - auto assign = MakePtr(); - assign->op = WfBinaryOperator::Assign; - assign->first = CreateReference(cacheName); - assign->second = CreateDefaultValue(result.Obj()); - - auto stat = MakePtr(); - stat->expression = assign; - ifBlock->statements.Add(stat); - } - - { - auto literal = MakePtr(); - literal->value = WfLiteralValue::True; - - auto returnStat = MakePtr(); - returnStat->expression = literal; - ifBlock->statements.Add(returnStat); - } - } - { - auto literal = MakePtr(); - literal->value = WfLiteralValue::False; - - auto returnStat = MakePtr(); - returnStat->expression = literal; - block->statements.Add(returnStat); - } - - return func; - } - -/*********************************************************************** -ExpandBindExpression -***********************************************************************/ - - void ExpandBindExpression(WfLexicalScopeManager* manager, WfBindExpression* node) - { - BindContext context; - CreateBindContextVisitor(manager, context).Call(node->expression.Obj()); - BindCallbackInfo bcInfo; - - auto newSubscription = MakePtr(); - node->expandedExpression = newSubscription; - { - auto typeInfo = TypeInfoRetriver>::CreateTypeInfo(); - newSubscription->type = GetTypeFromTypeInfo(typeInfo.Obj()); - } - { - // stable symbol order by sorting them by code - List orderedObserves; - - auto printExpression = [](WfExpression* observe) - { - stream::MemoryStream stream; - { - stream::StreamWriter writer(stream); - WfPrint(observe, WString::Empty, writer); - } - stream.SeekFromBegin(0); - { - stream::StreamReader reader(stream); - return reader.ReadToEnd(); - } - }; - - FOREACH_INDEXER(WfExpression*, parent, index, context.cachedExprs) - { - WString cacheName = context.GetCacheVariableName(index); - { - auto elementType = manager->expressionResolvings[parent].type; - newSubscription->declarations.Add(AssignNormalMember(CreateWritableVariable(cacheName, elementType.Obj()))); - } - } - - FOREACH_INDEXER(WfExpression*, observe, observeIndex, context.orderedObserves) - { - const auto& events = context.observeEvents[observe]; - FOREACH_INDEXER(IEventInfo*, ev, eventIndex, events) - { - WString handlerName = L"" + itow(observeIndex) + L"_" + itow(eventIndex); - { - auto elementType = TypeInfoRetriver>::CreateTypeInfo(); - bcInfo.handlerVariables.Add(handlerName, elementType); - newSubscription->declarations.Add(AssignNormalMember(CreateWritableVariable(handlerName, elementType.Obj()))); - } - - WString callbackName = L"" + itow(observeIndex) + L"_" + itow(eventIndex); - { - auto elementType = CopyTypeInfo(ev->GetHandlerType()); - bcInfo.callbackFunctions.Add(callbackName, elementType); - } - - CallbackInfo callbackInfo; - callbackInfo.observe = observe; - callbackInfo.eventInfo = ev; - callbackInfo.eventIndex = eventIndex; - callbackInfo.callbackName = callbackName; - callbackInfo.handlerName = handlerName; - bcInfo.observeCallbackInfos.Add(observe, callbackInfo); - } - } - newSubscription->declarations.Add(AssignNormalMember(CreateWritableVariable(L"", TypeInfoRetriver::CreateTypeInfo().Obj()))); - newSubscription->declarations.Add(AssignNormalMember(CreateWritableVariable(L"", TypeInfoRetriver::CreateTypeInfo().Obj()))); - { - auto func = MakePtr(); - func->name.value = L""; - func->anonymity = WfFunctionAnonymity::Named; - func->returnType = GetTypeFromTypeInfo(TypeInfoRetriver::CreateTypeInfo().Obj()); - - auto block = MakePtr(); - func->statement = block; - { - auto var = MakePtr(); - var->name.value = L""; - var->expression = ExpandObserveExpressionVisitor::Execute(node->expression.Obj(), context); - - auto varStat = MakePtr(); - varStat->variable = var; - block->statements.Add(varStat); - } - { - auto call = MakePtr(); - call->function = CreateReference(L"ValueChanged"); - call->arguments.Add(CreateReference(L"")); - - auto stat = MakePtr(); - stat->expression = call; - block->statements.Add(stat); - } - - newSubscription->declarations.Add(AssignNormalMember(func)); - } - FOREACH(WfExpression*, observe, context.orderedObserves) - { - FOREACH(CallbackInfo, callbackInfo, bcInfo.observeCallbackInfos[observe]) - { - auto func = MakePtr(); - func->name.value = callbackInfo.callbackName; - func->anonymity = WfFunctionAnonymity::Named; - { - auto genericType = bcInfo.callbackFunctions[callbackInfo.callbackName]->GetElementType(); - func->returnType = GetTypeFromTypeInfo(genericType->GetGenericArgument(0)); - vint count = genericType->GetGenericArgumentCount(); - for (vint i = 1; i < count; i++) - { - auto arg = MakePtr(); - arg->name.value = L"" + itow(i - 1); - arg->type = GetTypeFromTypeInfo(genericType->GetGenericArgument(i)); - func->arguments.Add(arg); - } - } - auto block = MakePtr(); - func->statement = block; - { - List affected; - affected.Add(observe); - for (vint i = 0; i < affected.Count(); i++) - { - auto current = affected[i]; - vint dependencyIndex = context.observeAffects.Keys().IndexOf(current); - if (dependencyIndex != -1) - { - FOREACH(WfExpression*, affectedObserve, context.observeAffects.GetByIndex(dependencyIndex)) - { - if (affectedObserve && !affected.Contains(affectedObserve)) - { - affected.Add(affectedObserve); - } - } - } - } - affected.Remove(observe); - - FOREACH(WfExpression*, affectedObserve, From(affected).Reverse()) - { - CreateBindDetachStatement(block, manager, affectedObserve, context, bcInfo); - } - { - SortedList assignedParents; - FOREACH(WfExpression*, affectedObserve, affected) - { - auto parent = context.GetCachedExpressionIndexRecursively(context.observeParents[affectedObserve], true); - if (!assignedParents.Contains(parent)) - { - assignedParents.Add(parent); - CreateBindCacheAssignStatement(block, affectedObserve, context); - } - } - } - FOREACH(WfExpression*, affectedObserve, affected) - { - CreateBindAttachStatement(block, manager, affectedObserve, context, bcInfo); - } - } - { - auto ref = CreateReference(L""); - - auto call = MakePtr(); - call->function = ref; - - auto stat = MakePtr(); - stat->expression = call; - block->statements.Add(stat); - } - - newSubscription->declarations.Add(AssignNormalMember(func)); - } - } - } - newSubscription->declarations.Add(AssignOverrideMember(CreateBindOpenFunction(manager, context, bcInfo))); - newSubscription->declarations.Add(AssignOverrideMember(CreateBindUpdateFunction(bcInfo))); - newSubscription->declarations.Add(AssignOverrideMember(CreateBindCloseFunction(manager, context, bcInfo))); - } - } - } -} - -/*********************************************************************** -ANALYZER\WFANALYZER_EXPANDMIXINCASTEXPRESSION.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace analyzer - { - using namespace collections; - using namespace reflection; - using namespace reflection::description; - -/*********************************************************************** -ExpandNewCoroutineExpression -***********************************************************************/ - - void ExpandMixinCastExpression(WfLexicalScopeManager* manager, WfMixinCastExpression* node) - { - auto sourceType = manager->expressionResolvings[node->expression.Obj()].type; - - auto newExpr = MakePtr(); - node->expandedExpression = newExpr; - - newExpr->type = CopyType(node->type); - { - auto varDecl = MakePtr(); - newExpr->declarations.Add(varDecl); - { - varDecl->classMember = MakePtr(); - varDecl->classMember->kind = WfClassMemberKind::Normal; - } - varDecl->name.value = L""; - varDecl->expression = CopyExpression(node->expression); - - if (sourceType->GetDecorator() == ITypeInfo::RawPtr) - { - auto tdType = MakePtr(sourceType->GetTypeDescriptor(), TypeInfoHint::Normal); - auto pointerType = MakePtr(tdType); - - auto castExpr = MakePtr(); - castExpr->strategy = WfTypeCastingStrategy::Strong; - castExpr->expression = varDecl->expression; - castExpr->type = GetTypeFromTypeInfo(pointerType.Obj()); - - varDecl->expression = castExpr; - } - } - List unprocessed; - unprocessed.Add(sourceType->GetTypeDescriptor()); - for (vint i = 0; i < unprocessed.Count(); i++) - { - auto td = unprocessed[i]; - vint groupCount = td->GetMethodGroupCount(); - for (vint j = 0; j < groupCount; j++) - { - auto group = td->GetMethodGroup(j); - vint methodCount = group->GetMethodCount(); - for (vint k = 0; k < methodCount; k++) - { - auto method = group->GetMethod(k); - if (!method->IsStatic()) - { - auto funcDecl = MakePtr(); - newExpr->declarations.Add(funcDecl); - { - funcDecl->classMember = MakePtr(); - funcDecl->classMember->kind = WfClassMemberKind::Override; - } - funcDecl->anonymity = WfFunctionAnonymity::Named; - funcDecl->name.value = method->GetName(); - funcDecl->returnType = GetTypeFromTypeInfo(method->GetReturn()); - vint parameterCount = method->GetParameterCount(); - for (vint l = 0; l < parameterCount; l++) - { - auto parameter = method->GetParameter(l); - auto argument = MakePtr(); - argument->name.value = parameter->GetName(); - argument->type = GetTypeFromTypeInfo(parameter->GetType()); - funcDecl->arguments.Add(argument); - } - - auto implBlock = MakePtr(); - funcDecl->statement = implBlock; - { - auto refSource = MakePtr(); - refSource->name.value = L""; - - auto memberExpr = MakePtr(); - if (sourceType->GetTypeDescriptor() == method->GetOwnerTypeDescriptor()) - { - memberExpr->parent = refSource; - } - else if (sourceType->GetTypeDescriptor()->GetMethodGroupByName(method->GetName(), true) == method->GetOwnerMethodGroup()) - { - memberExpr->parent = refSource; - } - else - { - auto castExpr = MakePtr(); - castExpr->strategy = WfTypeCastingStrategy::Strong; - castExpr->expression = refSource; - { - auto tdType = MakePtr(sourceType->GetTypeDescriptor(), TypeInfoHint::Normal); - auto pointerType = MakePtr(tdType); - castExpr->type = GetTypeFromTypeInfo(pointerType.Obj()); - } - - auto inferExpr = MakePtr(); - inferExpr->expression = castExpr; - { - auto tdType = MakePtr(method->GetOwnerTypeDescriptor(), TypeInfoHint::Normal); - auto pointerType = MakePtr(tdType); - inferExpr->type = GetTypeFromTypeInfo(pointerType.Obj()); - } - - memberExpr->parent = inferExpr; - } - memberExpr->name.value = method->GetName(); - - auto callExpr = MakePtr(); - callExpr->function = memberExpr; - - for (vint l = 0; l < parameterCount; l++) - { - auto parameter = method->GetParameter(l); - - auto argumentExpr = MakePtr(); - argumentExpr->name.value = parameter->GetName(); - callExpr->arguments.Add(argumentExpr); - } - - if (method->GetReturn()->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - auto stat = MakePtr(); - stat->expression = callExpr; - implBlock->statements.Add(stat); - } - else - { - auto stat = MakePtr(); - stat->expression = callExpr; - implBlock->statements.Add(stat); - } - } - } - } - } - - vint count = td->GetBaseTypeDescriptorCount(); - for (vint j = 0; j < count; j++) - { - auto baseTd = td->GetBaseTypeDescriptor(j); - if (!unprocessed.Contains(baseTd)) - { - unprocessed.Add(baseTd); - } - } - } - } - } - } -} - -/*********************************************************************** -ANALYZER\WFANALYZER_EXPANDNEWCOROUTINEEXPRESSION.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace analyzer - { - using namespace collections; - using namespace reflection; - using namespace reflection::description; - -/*********************************************************************** -FindCoroutineAwaredStatements -***********************************************************************/ - - class FindCoroutineAwaredStatementVisitor : public empty_visitor::StatementVisitor - { - public: - List& awaredStatements; - bool awared = false; - - FindCoroutineAwaredStatementVisitor(List& _awaredStatements) - :awaredStatements(_awaredStatements) - { - } - - bool Call(Ptr node) - { - if (!node) return false; - - awared = false; - node->Accept(this); - if (awared) - { - awaredStatements.Add(node.Obj()); - } - return awared; - } - - void Dispatch(WfVirtualStatement* node)override - { - awared = Call(node->expandedStatement); - } - - void Dispatch(WfCoroutineStatement* node)override - { - awared = true; - } - - void Visit(WfReturnStatement* node)override - { - awared = true; - } - - void Visit(WfIfStatement* node)override - { - bool a = Call(node->trueBranch); - bool b = Call(node->falseBranch); - awared = a || b; - } - - void Visit(WfWhileStatement* node)override - { - awared = Call(node->statement); - } - - void Visit(WfTryStatement* node)override - { - bool a = Call(node->protectedStatement); - bool b = Call(node->catchStatement); - bool c = Call(node->finallyStatement); - awared = a || b || c; - } - - void Visit(WfBlockStatement* node)override - { - bool result = false; - FOREACH(Ptr, stat, node->statements) - { - bool a = Call(stat); - result |= a; - } - awared = result; - } - }; - - void FindCoroutineAwaredStatements(Ptr node, List& awaredStatements) - { - FindCoroutineAwaredStatementVisitor(awaredStatements).Call(node); - } - -/*********************************************************************** -FindCoroutineAwaredVariables -***********************************************************************/ - - class FindCoroutineAwaredVariableVisitor : public empty_visitor::StatementVisitor - { - public: - List& awaredVariables; - - FindCoroutineAwaredVariableVisitor(List& _awaredVariables) - :awaredVariables(_awaredVariables) - { - } - - void Dispatch(WfVirtualStatement* node)override - { - node->expandedStatement->Accept(this); - } - - void Dispatch(WfCoroutineStatement* node)override - { - } - - void Visit(WfVariableStatement* node)override - { - awaredVariables.Add(node); - } - }; - - class FindCoroutineAwaredBlockVisitor : public empty_visitor::StatementVisitor - { - public: - List& awaredVariables; - - FindCoroutineAwaredBlockVisitor(List& _awaredVariables) - :awaredVariables(_awaredVariables) - { - } - - void Dispatch(WfVirtualStatement* node)override - { - // If an virtual node is coroutine awared - // than its expandedStatement is also in the list - // no need to find variables again - } - - void Dispatch(WfCoroutineStatement* node)override - { - } - - void Visit(WfBlockStatement* node)override - { - FindCoroutineAwaredVariableVisitor visitor(awaredVariables); - FOREACH(Ptr, stat, node->statements) - { - stat->Accept(&visitor); - } - } - }; - - void FindCoroutineAwaredVariables(WfStatement* node, List& awaredVariables) - { - FindCoroutineAwaredBlockVisitor visitor(awaredVariables); - node->Accept(&visitor); - } - -/*********************************************************************** -FindCoroutineReferenceRenaming -***********************************************************************/ - - void FindCoroutineReferenceRenaming(WfLexicalScopeManager* manager, List& awaredStatements, List& awaredVariables, Dictionary& referenceRenaming) - { - vint renameCounter = 0; - auto rename = [&](const WString& name) - { - if (name.Length() > 0 && name[0] == L'<') - { - vint index = INVLOC.FindFirst(name, L">", Locale::None).key; - auto category = name.Sub(1, index - 1); - auto local = name.Sub(index + 1, name.Length() - index - 1); - return L"" + local; - } - else - { - return L"" + name; - } - }; - - FOREACH(WfVariableStatement*, stat, awaredVariables) - { - auto scope = manager->nodeScopes[stat]; - auto symbol = scope->symbols[stat->variable->name.value][0]; - auto name = rename(stat->variable->name.value); - referenceRenaming.Add(symbol.Obj(), name); - } - - FOREACH(WfStatement*, stat, awaredStatements) - { - if (auto tryStat = dynamic_cast(stat)) - { - if (tryStat->catchStatement) - { - auto scope = manager->nodeScopes[tryStat->catchStatement.Obj()]->parentScope.Obj(); - auto symbol = scope->symbols[tryStat->name.value][0]; - auto name = rename(tryStat->name.value); - referenceRenaming.Add(symbol.Obj(), name); - } - } - else if (auto ifStat = dynamic_cast(stat)) - { - if (ifStat->name.value != L"") - { - auto scope = manager->nodeScopes[ifStat->trueBranch.Obj()]->parentScope.Obj(); - auto symbol = scope->symbols[ifStat->name.value][0]; - auto name = rename(ifStat->name.value); - referenceRenaming.Add(symbol.Obj(), name); - } - } - } - } - -/*********************************************************************** -FlowChart -***********************************************************************/ - - class FlowChartNode; - - class FlowChartBranch : public Object - { - public: - Ptr condition; - FlowChartNode* destination = nullptr; - }; - - enum class FlowChartNodeAction - { - None, - SetPause, - }; - - class FlowChartNode : public Object - { - public: - FlowChartNodeAction action = FlowChartNodeAction::None; - bool embedInBranch = false; - List> statements; - List> branches; - FlowChartNode* destination = nullptr; - FlowChartNode* exceptionDestination = nullptr; - FlowChartNode* pauseDestination = nullptr; - WfLexicalSymbol* exceptionVariable = nullptr; - }; - - class FlowChart : public Object - { - typedef Dictionary> TempExVarMap; - public: - List> nodes; - FlowChartNode* headNode = nullptr; - FlowChartNode* lastNode = nullptr; - TempExVarMap tempExVars; - - FlowChartNode* CreateNode(FlowChartNode* catchNode) - { - auto node = MakePtr(); - node->exceptionDestination = catchNode; - nodes.Add(node); - return node.Obj(); - } - - FlowChartNode* AppendNode(FlowChartNode* head, FlowChartNode* catchNode, FlowChartNodeAction action = FlowChartNodeAction::None) - { - auto node = CreateNode(catchNode); - node->action = action; - if (head) - { - CHECK_ERROR(head->destination == nullptr, L"FlowChart::AppendNode(FlowChartNode*, FlowChartNode*, FlowChartNodeAction)#Cannot append a new node to a flow chart node that already has a default destination."); - head->destination = node; - } - return node; - } - - FlowChartNode* EnsureAppendStatement(FlowChartNode* head, FlowChartNode* catchNode) - { - if (head == nullptr) - { - return CreateNode(catchNode); - } - else if(head->branches.Count() > 0 || head->exceptionDestination != catchNode) - { - CHECK_ERROR(head->destination == nullptr, L"FlowChart::EnsureAppendStatement(FlowChartNode*, FlowChartNode*)#Cannot append a statement to a flow chart node that already has a default destination."); - auto node = CreateNode(catchNode); - head->destination = node; - return node; - } - else - { - return head; - } - } - }; - -/*********************************************************************** -GenerateFlowChart -***********************************************************************/ - - class GenerateFlowChartModuleVisitor : public copy_visitor::ModuleVisitor - { - public: - WfLexicalScopeManager* manager; - Dictionary& referenceRenaming; - - GenerateFlowChartModuleVisitor(WfLexicalScopeManager* _manager, Dictionary& _referenceRenaming) - :manager(_manager) - , referenceRenaming(_referenceRenaming) - { - } - - void Visit(WfReferenceExpression* node)override - { - copy_visitor::ExpressionVisitor::Visit(node); - vint index = manager->expressionResolvings.Keys().IndexOf(node); - if (index != -1) - { - auto resolvingResult = manager->expressionResolvings.Values()[index]; - vint index = referenceRenaming.Keys().IndexOf(resolvingResult.symbol.Obj()); - if (index != -1) - { - result.Cast()->name.value = referenceRenaming.Values()[index]; - } - } - } - }; - - class GenerateFlowChartStatementVisitor - : public Object - , public WfStatement::IVisitor - , public WfCoroutineStatement::IVisitor - { - public: - enum class ScopeType - { - Function, - Loop, - TryCatch, - }; - - struct ScopeContext - { - ScopeContext* parent = nullptr; - ScopeType type = ScopeType::Function; - FlowChartNode* enterNode = nullptr; - FlowChartNode* leaveNode = nullptr; - ScopeContext* exitStatementScope = nullptr; - Ptr exitStatement; - }; - - public: - WfLexicalScopeManager* manager; - SortedList& awaredStatements; - Dictionary& referenceRenaming; - Ptr flowChart; - FlowChartNode* headNode; - FlowChartNode* catchNode; - ScopeContext* scopeContext; - FlowChartNode* resultHead = nullptr; - FlowChartNode* resultLast = nullptr; - - GenerateFlowChartStatementVisitor(WfLexicalScopeManager* _manager, SortedList& _awaredStatements, Dictionary& _referenceRenaming, Ptr _flowChart, FlowChartNode* _headNode, FlowChartNode* _catchNode, ScopeContext* _scopeContext) - :manager(_manager) - , awaredStatements(_awaredStatements) - , referenceRenaming(_referenceRenaming) - , flowChart(_flowChart) - , headNode(_headNode) - , catchNode(_catchNode) - , scopeContext(_scopeContext) - { - } - -#define COPY_AST(STATEMENT) GenerateFlowChartModuleVisitor(manager, referenceRenaming).CreateField(STATEMENT) - - void AppendAwaredStatement(FlowChartNode* catchNode, ScopeContext* scopeContext, Ptr statement) - { - if (!resultHead) - { - resultHead = flowChart->EnsureAppendStatement(headNode, catchNode); - resultLast = resultHead; - } - resultLast = Execute(resultHead, catchNode, scopeContext, statement).value; - } - - void AppendUnawaredCopiedStatement(FlowChartNode* catchNode, ScopeContext* scopeContext, Ptr statement) - { - if (!resultHead) - { - resultHead = flowChart->EnsureAppendStatement(headNode, catchNode); - resultLast = resultHead; - } - resultHead->statements.Add(statement); - } - - ScopeContext* InlineScopeExitCode(ScopeType untilScopeType, bool exclusive) - { - auto current = scopeContext; - while (current) - { - if (exclusive && current->type == untilScopeType) break; - if (current->exitStatement) - { - AppendAwaredStatement(catchNode, current->exitStatementScope, current->exitStatement); - } - if (!exclusive && current->type == untilScopeType) break; - current = current->parent; - } - return current; - } - - static Pair Execute(WfLexicalScopeManager* manager, SortedList& awaredStatements, Dictionary& referenceRenaming, Ptr flowChart, FlowChartNode* headNode, FlowChartNode* catchNode, ScopeContext* scopeContext, Ptr statement) - { - GenerateFlowChartStatementVisitor visitor(manager, awaredStatements, referenceRenaming, flowChart, headNode, catchNode, scopeContext); - if (awaredStatements.Contains(statement.Obj())) - { - statement->Accept(&visitor); - } - else - { - visitor.AppendUnawaredCopiedStatement(catchNode, scopeContext, COPY_AST(statement)); - } - return{ visitor.resultHead,visitor.resultLast }; - } - - Pair Execute(FlowChartNode* headNode, FlowChartNode* catchNode, ScopeContext* scopeContext, Ptr statement) - { - return Execute(manager, awaredStatements, referenceRenaming, flowChart, headNode, catchNode, scopeContext, statement); - } - - void Visit(WfBreakStatement* node)override - { - auto targetContext = InlineScopeExitCode(ScopeType::Loop, false); - resultLast->destination = targetContext->leaveNode; - } - - void Visit(WfContinueStatement* node)override - { - auto targetContext = InlineScopeExitCode(ScopeType::Loop, true); - resultLast->destination = targetContext->enterNode; - } - - void Visit(WfReturnStatement* node)override - { - auto targetContext = InlineScopeExitCode(ScopeType::Function, false); - AppendUnawaredCopiedStatement(catchNode, scopeContext, COPY_AST(node)); - resultLast->destination = targetContext->leaveNode; - } - - void Visit(WfDeleteStatement* node)override - { - AppendUnawaredCopiedStatement(catchNode, scopeContext, COPY_AST(node)); - } - - void Visit(WfRaiseExceptionStatement* node)override - { - AppendUnawaredCopiedStatement(catchNode, scopeContext, COPY_AST(node)); - } - - void GenerateIfWithVar(WfIfStatement* node) - { - resultHead = flowChart->EnsureAppendStatement(headNode, catchNode); - { - auto branch = MakePtr(); - resultHead->branches.Add(branch); - - auto scope = manager->nodeScopes[node]; - auto symbol = scope->symbols[node->name.value][0].Obj(); - { - auto refExpr = MakePtr(); - refExpr->name.value = referenceRenaming[symbol]; - - auto assignExpr = MakePtr(); - assignExpr->op = WfBinaryOperator::Assign; - assignExpr->first = refExpr; - assignExpr->second = COPY_AST(node->expression); - - auto stat = MakePtr(); - stat->expression = assignExpr; - - SetCodeRange((Ptr)stat, node->expression->codeRange); - resultHead->statements.Add(stat); - } - { - auto refExpr = MakePtr(); - refExpr->name.value = referenceRenaming[symbol]; - - auto testExpr = MakePtr(); - testExpr->test = WfTypeTesting::IsNotNull; - testExpr->expression = refExpr; - - SetCodeRange((Ptr)testExpr, node->expression->codeRange); - branch->condition = testExpr; - } - } - resultLast = flowChart->CreateNode(catchNode); - - { - auto pair = Execute(nullptr, catchNode, scopeContext, node->trueBranch); - pair.value->destination = resultLast; - resultHead->branches[0]->destination = pair.key; - } - - if (node->falseBranch) - { - auto pair = Execute(nullptr, catchNode, scopeContext, node->falseBranch); - pair.value->destination = resultLast; - resultHead->destination = pair.key; - } - else - { - resultHead->destination = resultLast; - } - } - - void GenerateIfWithoutVar(WfIfStatement* node) - { - resultHead = flowChart->EnsureAppendStatement(headNode, catchNode); - resultLast = flowChart->CreateNode(catchNode); - - while (true) - { - auto branch = MakePtr(); - resultHead->branches.Add(branch); - branch->condition = COPY_AST(node->expression); - - auto pair = Execute(nullptr, catchNode, scopeContext, node->trueBranch); - pair.value->destination = resultLast; - branch->destination = pair.key; - - auto next = dynamic_cast(node->falseBranch.Obj()); - if (next && next->name.value == L"") - { - node = next; - } - else - { - break; - } - } - - if (node->falseBranch) - { - auto pair = Execute(nullptr, catchNode, scopeContext, node->falseBranch); - pair.value->destination = resultLast; - resultHead->destination = pair.key; - } - else - { - resultHead->destination = resultLast; - } - } - - void Visit(WfIfStatement* node)override - { - if (node->name.value == L"") - { - GenerateIfWithoutVar(node); - } - else - { - GenerateIfWithVar(node); - } - } - - void Visit(WfWhileStatement* node)override - { - resultHead = flowChart->EnsureAppendStatement(headNode, catchNode); - { - auto branch = MakePtr(); - resultHead->branches.Add(branch); - branch->condition = COPY_AST(node->condition); - } - auto loopEnd = flowChart->CreateNode(catchNode); - { - auto branch = MakePtr(); - loopEnd->branches.Add(branch); - branch->condition = COPY_AST(node->condition); - } - resultLast = flowChart->CreateNode(catchNode); - - ScopeContext loopContext; - loopContext.parent = scopeContext; - loopContext.type = ScopeType::Loop; - loopContext.enterNode = loopEnd; - loopContext.leaveNode = resultLast; - auto pair = Execute(nullptr, catchNode, &loopContext, node->statement); - pair.value->destination = loopEnd; - - resultHead->branches[0]->destination = pair.key; - loopEnd->branches[0]->destination = pair.key; - resultHead->destination = resultLast; - loopEnd->destination = resultLast; - } - - WfLexicalSymbol* GetExceptionVariableSymbol(WfTryStatement* node) - { - if (node->catchStatement) - { - auto scope = manager->nodeScopes[node->catchStatement.Obj()]->parentScope.Obj(); - auto symbol = scope->symbols[node->name.value][0]; - return symbol.Obj(); - } - else - { - vint index = flowChart->tempExVars.Keys().IndexOf(node); - if (index == -1) - { - auto symbol = MakePtr(nullptr); - symbol->name = L"ex"; - symbol->typeInfo = TypeInfoRetriver>::CreateTypeInfo(); - flowChart->tempExVars.Add(node, symbol); - - referenceRenaming.Add(symbol.Obj(), L"tempExVars.Count() - 1) + L">ex"); - return symbol.Obj(); - } - return flowChart->tempExVars.Values()[index].Obj(); - } - } - - Pair GenerateCatch(WfTryStatement* node, FlowChartNode* catchNode) - { - auto pair = Execute(nullptr, catchNode, scopeContext, node->catchStatement); - pair.key->exceptionVariable = GetExceptionVariableSymbol(node); - return pair; - } - - Pair GenerateFinally(WfTryStatement* node, FlowChartNode* catchNode) - { - return Execute(nullptr, catchNode, scopeContext, node->finallyStatement); - } - - Pair GenerateFinallyAndRaise(WfTryStatement* node, FlowChartNode* catchNode) - { - auto pair = Execute(nullptr, catchNode, scopeContext, node->finallyStatement); - auto raiseNode = flowChart->CreateNode(catchNode); - { - pair.key->exceptionVariable = GetExceptionVariableSymbol(node); - - auto refExpr = MakePtr(); - refExpr->name.value = referenceRenaming[pair.key->exceptionVariable]; - - auto memberExpr = MakePtr(); - memberExpr->parent = refExpr; - memberExpr->name.value = L"Message"; - - auto raiseStat = MakePtr(); - raiseStat->expression = memberExpr; - - SetCodeRange((Ptr)raiseStat, node->finallyStatement->codeRange); - raiseNode->statements.Add(raiseStat); - } - pair.value->destination = raiseNode; - return { pair.key,raiseNode }; - } - - void Visit(WfTryStatement* node)override - { - ScopeContext tryContext; - tryContext.parent = scopeContext; - tryContext.type = ScopeType::TryCatch; - if (node->finallyStatement) - { - tryContext.exitStatementScope = scopeContext; - tryContext.exitStatement = node->finallyStatement; - } - - if (node->catchStatement && !node->finallyStatement) - { - auto pairCatch = GenerateCatch(node, catchNode); - AppendAwaredStatement(pairCatch.key, &tryContext, node->protectedStatement); - - auto endNode = flowChart->CreateNode(catchNode); - pairCatch.value->destination = endNode; - resultLast->destination = endNode; - resultLast = endNode; - } - else if (!node->catchStatement && node->finallyStatement) - { - auto pairFinallyAndRaise = GenerateFinallyAndRaise(node, catchNode); - AppendAwaredStatement(pairFinallyAndRaise.key, &tryContext, node->protectedStatement); - auto pairFinally = GenerateFinally(node, catchNode); - - auto endNode = flowChart->CreateNode(catchNode); - resultLast->destination = pairFinally.key; - pairFinally.value->destination = endNode; - pairFinallyAndRaise.value->destination = endNode; - resultLast = endNode; - } - else - { - auto pairFinallyAndRaise = GenerateFinallyAndRaise(node, catchNode); - auto pairCatch = GenerateCatch(node, pairFinallyAndRaise.key); - AppendAwaredStatement(pairCatch.key, &tryContext, node->protectedStatement); - auto pairFinally = GenerateFinally(node, catchNode); - - auto endNode = flowChart->CreateNode(catchNode); - resultLast->destination = pairFinally.key; - pairCatch.value->destination = pairFinally.key; - pairFinally.value->destination = endNode; - pairFinallyAndRaise.value->destination = endNode; - resultLast = endNode; - } - } - - void Visit(WfBlockStatement* node)override - { - resultHead = flowChart->EnsureAppendStatement(headNode, catchNode); - resultLast = resultHead; - - FOREACH_INDEXER(Ptr, stat, index, node->statements) - { - auto pair = Execute(resultLast, catchNode, scopeContext, stat); - resultLast = pair.value; - } - } - - void Visit(WfVariableStatement* node)override - { - resultHead = flowChart->EnsureAppendStatement(headNode, catchNode); - resultLast = resultHead; - - auto scope = manager->nodeScopes[node]; - auto symbol = scope->symbols[node->variable->name.value][0].Obj(); - - auto refExpr = MakePtr(); - refExpr->name.value = referenceRenaming[symbol]; - - auto assignExpr = MakePtr(); - assignExpr->op = WfBinaryOperator::Assign; - assignExpr->first = refExpr; - assignExpr->second = COPY_AST(node->variable->expression); - - auto stat = MakePtr(); - stat->expression = assignExpr; - - SetCodeRange((Ptr)stat, node->codeRange); - AppendUnawaredCopiedStatement(catchNode, scopeContext, stat); - } - - void Visit(WfExpressionStatement* node)override - { - AppendUnawaredCopiedStatement(catchNode, scopeContext, COPY_AST(node)); - } - - void Visit(WfVirtualStatement* node)override - { - node->expandedStatement->Accept(this); - } - - void Visit(WfCoroutineStatement* node)override - { - node->Accept(static_cast(this)); - } - - void Visit(WfCoPauseStatement* node)override - { - resultHead = flowChart->AppendNode(headNode, catchNode, FlowChartNodeAction::SetPause); - resultLast = resultHead; - if (node->statement) - { - AppendUnawaredCopiedStatement(catchNode, scopeContext, COPY_AST(node->statement)); - } - - resultLast = flowChart->AppendNode(resultLast, catchNode); - { - auto pauseStat = MakePtr(); - SetCodeRange((Ptr)pauseStat, node->codeRange); - resultLast->statements.Add(pauseStat); - } - resultLast = flowChart->AppendNode(resultLast, catchNode); - resultHead->pauseDestination = resultLast; - } - - void Visit(WfCoOperatorStatement* node)override - { - CHECK_FAIL(L"GenerateFlowChartStatementVisitor::Visit(WfCoOperatorStatement*)#Internal error, co-operator statement is not allowed in $coroutine expression."); - } - -#undef COPY_STATEMENT - }; - - Ptr GenerateFlowChart(WfLexicalScopeManager* manager, List& awaredStatements, List& awaredVariables, Dictionary& referenceRenaming, Ptr statement) - { - auto flowChart = MakePtr(); - SortedList sortedAwaredStatements; - CopyFrom(sortedAwaredStatements, awaredStatements, true); - CopyFrom(sortedAwaredStatements, awaredVariables, true); - - auto endNode = flowChart->CreateNode(nullptr); - GenerateFlowChartStatementVisitor::ScopeContext context; - context.leaveNode = endNode; - - auto pair = GenerateFlowChartStatementVisitor::Execute(manager, sortedAwaredStatements, referenceRenaming, flowChart, nullptr, nullptr, &context, statement); - pair.value->destination = endNode; - - flowChart->headNode = pair.key; - flowChart->lastNode = endNode; - return flowChart; - } - -/*********************************************************************** -RemoveUnnecessaryNodes -***********************************************************************/ - - void CalculateEnterCounts(Ptr flowChart, Dictionary& enterCounts) - { - const auto& keys = enterCounts.Keys(); - auto& values = const_cast::ValueContainer&>(enterCounts.Values()); - - FOREACH(Ptr, node, flowChart->nodes) - { - enterCounts.Add(node.Obj(), 0); - } - enterCounts.Set(flowChart->headNode, 1); - - auto Inc = [&](FlowChartNode* node) - { - if (node) - { - vint index = keys.IndexOf(node); - values[index]++; - } - }; - - FOREACH(Ptr, node, flowChart->nodes) - { - Inc(node->destination); - Inc(node->exceptionDestination); - Inc(node->pauseDestination); - FOREACH(Ptr, branch, node->branches) - { - Inc(branch->destination); - } - } - } - - void RemoveUnnecessaryNodesPass(Ptr flowChart) - { - Dictionary enterCounts; - CalculateEnterCounts(flowChart, enterCounts); - - SortedList mergableNodes; - List> keepingNodes; - FOREACH(Ptr, node, flowChart->nodes) - { - bool mergable = false; - - if (node->branches.Count() == 0 && node->destination) - { - if (node->statements.Count() == 0 && node->action == FlowChartNodeAction::None && !node->exceptionVariable) - { - mergable = true; - } - else if (node->destination->action == FlowChartNodeAction::None && !node->destination->exceptionVariable && enterCounts[node->destination] == 1) - { - mergable = true; - } - } - - if (mergable) - { - mergableNodes.Add(node.Obj()); - } - else - { - keepingNodes.Add(node); - } - } - - Dictionary merging; - FOREACH(FlowChartNode*, node, mergableNodes) - { - auto current = node; - while (mergableNodes.Contains(current)) - { - auto target = current->destination; - - if (current->action == FlowChartNodeAction::SetPause) - { - target->action = current->action; - target->pauseDestination = current->pauseDestination; - } - if (current->exceptionVariable) - { - target->exceptionVariable = current->exceptionVariable; - } - if (current->statements.Count() > 0) - { - CopyFrom(current->statements, target->statements, true); - CopyFrom(target->statements, current->statements); - current->statements.Clear(); - } - - current = target; - } - merging.Add(node, current); - } - -#define MERGE_FLOW_CHART_NODE(DESTINATION)\ - {\ - vint index = merging.Keys().IndexOf(DESTINATION);\ - if (index != -1) DESTINATION = merging.Values()[index];\ - }\ - - FOREACH(Ptr, node, flowChart->nodes) - { - if (!mergableNodes.Contains(node.Obj())) - { - MERGE_FLOW_CHART_NODE(node->destination); - MERGE_FLOW_CHART_NODE(node->exceptionDestination); - MERGE_FLOW_CHART_NODE(node->pauseDestination); - FOREACH(Ptr, branch, node->branches) - { - MERGE_FLOW_CHART_NODE(branch->destination); - } - } - } - MERGE_FLOW_CHART_NODE(flowChart->headNode); - MERGE_FLOW_CHART_NODE(flowChart->lastNode); - -#undef MERGE_FLOW_CHART_NODE - - vint headNodeIndex = keepingNodes.IndexOf(flowChart->headNode); - if (headNodeIndex != 0) - { - auto headNode = keepingNodes[headNodeIndex]; - keepingNodes.RemoveAt(headNodeIndex); - keepingNodes.Insert(0, headNode); - } - CopyFrom(flowChart->nodes, keepingNodes); - } - - void RemoveUnnecessaryNodes(Ptr flowChart) - { - RemoveUnnecessaryNodesPass(flowChart); - - FOREACH(Ptr, node, flowChart->nodes) - { - if (node->pauseDestination && node->statements.Count() > 0 && node->statements[node->statements.Count() - 1].Cast()) - { - node->destination = nullptr; - } - } - - Dictionary enterCounts; - CalculateEnterCounts(flowChart, enterCounts); - FOREACH(Ptr, node, flowChart->nodes) - { - FOREACH(Ptr, branch, node->branches) - { - if (enterCounts[branch->destination] == 1) - { - branch->destination->embedInBranch = true; - } - } - } - } - -/*********************************************************************** -GenerateSetStatus -***********************************************************************/ - - Ptr GenerateSetStatus(const WString& status) - { - auto refExpr = MakePtr(); - refExpr->name.value = status; - - auto funcExpr = MakePtr(); - funcExpr->name.value = L"SetStatus"; - - auto callExpr = MakePtr(); - callExpr->function = funcExpr; - callExpr->arguments.Add(refExpr); - - auto stat = MakePtr(); - stat->expression = callExpr; - - return stat; - }; - -/*********************************************************************** -GenerateSetCoState -***********************************************************************/ - - Ptr GenerateSetCoState(List& nodeOrders, FlowChartNode* node) - { - auto refState = MakePtr(); - refState->name.value = L""; - - auto intState = MakePtr(); - intState->value.value = itow(nodeOrders.IndexOf(node)); - - auto assignExpr = MakePtr(); - assignExpr->op = WfBinaryOperator::Assign; - assignExpr->first = refState; - assignExpr->second = intState; - - auto stat = MakePtr(); - stat->expression = assignExpr; - - return stat; - }; - -/*********************************************************************** -ExpandExceptionDestination -***********************************************************************/ - - Ptr ExpandExceptionDestination(FlowChartNode* catchNode, Dictionary& referenceRenaming, List& nodeOrders, Ptr stateBlock) - { - ///////////////////////////////////////////////////////////////////////////// - // try { ... } - ///////////////////////////////////////////////////////////////////////////// - - auto nodeTryStat = MakePtr(); - auto nodeBlock = MakePtr(); - nodeTryStat->protectedStatement = nodeBlock; - - ///////////////////////////////////////////////////////////////////////////// - // catch() - // { - // THE_EXCEPTION_VARIABLE = ; - // = THE_EXCEPTION_STATE; - // continue; - // } - ///////////////////////////////////////////////////////////////////////////// - - nodeTryStat->name.value = L""; - auto catchBlock = MakePtr(); - nodeTryStat->catchStatement = catchBlock; - { - auto refTarget = MakePtr(); - refTarget->name.value = referenceRenaming[catchNode->exceptionVariable]; - - auto refEx = MakePtr(); - refEx->name.value = L""; - - auto assignExpr = MakePtr(); - assignExpr->op = WfBinaryOperator::Assign; - assignExpr->first = refTarget; - assignExpr->second = refEx; - - auto stat = MakePtr(); - stat->expression = assignExpr; - catchBlock->statements.Add(stat); - } - catchBlock->statements.Add(GenerateSetCoState(nodeOrders, catchNode)); - catchBlock->statements.Add(MakePtr()); - - stateBlock->statements.Add(nodeTryStat); - return nodeBlock; - } - -/*********************************************************************** -ExpandFlowChartNode -***********************************************************************/ - - void ExpandFlowChartNode(Ptr flowChart, FlowChartNode* flowChartNode, Dictionary& referenceRenaming, List& nodeOrders, FlowChartNode* parentCatchNode, Ptr stateBlock) - { - if (flowChartNode->action == FlowChartNodeAction::SetPause) - { - ///////////////////////////////////////////////////////////////////////////// - // = THE_NEXT_STATE; - // SetStatus(Waiting); - ///////////////////////////////////////////////////////////////////////////// - stateBlock->statements.Add(GenerateSetStatus(L"Waiting")); - stateBlock->statements.Add(GenerateSetCoState(nodeOrders, flowChartNode->pauseDestination)); - } - - auto nodeBlock = stateBlock; - if (flowChartNode->exceptionDestination && parentCatchNode != flowChartNode->exceptionDestination) - { - nodeBlock = ExpandExceptionDestination(flowChartNode->exceptionDestination, referenceRenaming, nodeOrders, stateBlock); - } - - bool exited = false; - FOREACH(Ptr, stat, flowChartNode->statements) - { - if (stat.Cast()) - { - exited = true; - ///////////////////////////////////////////////////////////////////////////// - // return; - ///////////////////////////////////////////////////////////////////////////// - nodeBlock->statements.Add(MakePtr()); - } - else if (stat.Cast()) - { - exited = true; - ///////////////////////////////////////////////////////////////////////////// - // SetStatus(Stopped); - // return; - ///////////////////////////////////////////////////////////////////////////// - stateBlock->statements.Add(GenerateSetStatus(L"Stopped")); - { - auto returnStat = MakePtr(); - stateBlock->statements.Add(returnStat); - } - } - else - { - if (stat.Cast()) - { - exited = true; - } - nodeBlock->statements.Add(stat); - } - } - - FOREACH(Ptr, branch, flowChartNode->branches) - { - auto ifStat = MakePtr(); - ifStat->expression = branch->condition; - - auto trueBlock = MakePtr(); - ifStat->trueBranch = trueBlock; - - if (branch->destination->embedInBranch) - { - ExpandFlowChartNode(flowChart, branch->destination, referenceRenaming, nodeOrders, flowChartNode->exceptionDestination, trueBlock); - } - else - { - trueBlock->statements.Add(GenerateSetCoState(nodeOrders, branch->destination)); - trueBlock->statements.Add(MakePtr()); - } - - nodeBlock->statements.Add(ifStat); - } - - if (!exited) - { - if (flowChartNode == flowChart->lastNode) - { - ///////////////////////////////////////////////////////////////////////////// - // SetStatus(Stopped); - // return; - ///////////////////////////////////////////////////////////////////////////// - stateBlock->statements.Add(GenerateSetStatus(L"Stopped")); - { - auto returnStat = MakePtr(); - stateBlock->statements.Add(returnStat); - } - } - else - { - ///////////////////////////////////////////////////////////////////////////// - // = THE_NEXT_STATE; - // continue; - ///////////////////////////////////////////////////////////////////////////// - stateBlock->statements.Add(GenerateSetCoState(nodeOrders, flowChartNode->destination)); - stateBlock->statements.Add(MakePtr()); - } - } - } - -/*********************************************************************** -ExpandNewCoroutineExpression -***********************************************************************/ - - void ExpandNewCoroutineExpression(WfLexicalScopeManager* manager, WfNewCoroutineExpression* node) - { - List awaredStatements; - List awaredVariables; - Dictionary referenceRenaming; - - FindCoroutineAwaredStatements(node->statement, awaredStatements); - FOREACH(WfStatement*, stat, awaredStatements) - { - FindCoroutineAwaredVariables(stat, awaredVariables); - } - FindCoroutineReferenceRenaming(manager, awaredStatements, awaredVariables, referenceRenaming); - auto flowChart = GenerateFlowChart(manager, awaredStatements, awaredVariables, referenceRenaming, node->statement); - RemoveUnnecessaryNodes(flowChart); - - List nodeOrders; - CopyFrom( - nodeOrders, - From(flowChart->nodes) - .Select([](Ptr node) - { - return node.Obj(); - }) - .Where([](FlowChartNode* node) - { - return !node->embedInBranch; - }) - ); - - auto newExpr = MakePtr(); - node->expandedExpression = newExpr; - newExpr->type = GetTypeFromTypeInfo(TypeInfoRetriver>::CreateTypeInfo().Obj()); - - ///////////////////////////////////////////////////////////////////////////// - // Coroutine Awared Variables - ///////////////////////////////////////////////////////////////////////////// - - FOREACH(WfLexicalSymbol*, symbol, - From(referenceRenaming.Keys()) - .OrderBy([&](WfLexicalSymbol* a, WfLexicalSymbol* b) - { - return WString::Compare(referenceRenaming[a], referenceRenaming[b]); - })) - { - auto varDecl = MakePtr(); - newExpr->declarations.Add(varDecl); - { - auto member = MakePtr(); - member->kind = WfClassMemberKind::Normal; - varDecl->classMember = member; - } - - varDecl->name.value = referenceRenaming[symbol]; - varDecl->type = GetTypeFromTypeInfo(symbol->typeInfo.Obj()); - varDecl->expression = CreateDefaultValue(symbol->typeInfo.Obj()); - } - - ///////////////////////////////////////////////////////////////////////////// - // - ///////////////////////////////////////////////////////////////////////////// - - { - auto varDecl = MakePtr(); - newExpr->declarations.Add(varDecl); - { - auto member = MakePtr(); - member->kind = WfClassMemberKind::Normal; - varDecl->classMember = member; - } - - varDecl->name.value = L""; - varDecl->type = GetTypeFromTypeInfo(TypeInfoRetriver::CreateTypeInfo().Obj()); - - auto stateExpr = MakePtr(); - stateExpr->value.value = L"0"; - varDecl->expression = stateExpr; - } - - ///////////////////////////////////////////////////////////////////////////// - // prop Failure : Exception^ {const, not observe} - ///////////////////////////////////////////////////////////////////////////// - - { - auto propDecl = MakePtr(); - newExpr->declarations.Add(propDecl); - { - auto member = MakePtr(); - member->kind = WfClassMemberKind::Override; - propDecl->classMember = member; - } - - propDecl->name.value = L"Failure"; - propDecl->type = GetTypeFromTypeInfo(TypeInfoRetriver>::CreateTypeInfo().Obj()); - propDecl->configConst = WfAPConst::Readonly; - propDecl->configObserve = WfAPObserve::NotObservable; - - auto nullExpr = MakePtr(); - nullExpr->value = WfLiteralValue::Null; - propDecl->expression = nullExpr; - } - - ///////////////////////////////////////////////////////////////////////////// - // prop Status : CoroutineStatus^ {const, not observe} - ///////////////////////////////////////////////////////////////////////////// - - { - auto propDecl = MakePtr(); - newExpr->declarations.Add(propDecl); - { - auto member = MakePtr(); - member->kind = WfClassMemberKind::Override; - propDecl->classMember = member; - } - - propDecl->name.value = L"Status"; - propDecl->type = GetTypeFromTypeInfo(TypeInfoRetriver::CreateTypeInfo().Obj()); - propDecl->configConst = WfAPConst::Readonly; - propDecl->configObserve = WfAPObserve::NotObservable; - - auto refExpr = MakePtr(); - refExpr->name.value = L"Waiting"; - - propDecl->expression = refExpr; - } - - ///////////////////////////////////////////////////////////////////////////// - // func Resume( : bool, : CoroutineResult^) : void - ///////////////////////////////////////////////////////////////////////////// - - { - auto funcDecl = MakePtr(); - newExpr->declarations.Add(funcDecl); - { - auto member = MakePtr(); - member->kind = WfClassMemberKind::Override; - funcDecl->classMember = member; - } - - funcDecl->name.value = L"Resume"; - funcDecl->returnType = GetTypeFromTypeInfo(TypeInfoRetriver::CreateTypeInfo().Obj()); - { - auto argument = MakePtr(); - funcDecl->arguments.Add(argument); - argument->name.value = L""; - argument->type = GetTypeFromTypeInfo(TypeInfoRetriver::CreateTypeInfo().Obj()); - } - { - auto argument = MakePtr(); - funcDecl->arguments.Add(argument); - if (node->name.value == L"") - { - argument->name.value = L""; - } - else - { - argument->name.value = node->name.value; - } - argument->type = GetTypeFromTypeInfo(TypeInfoRetriver>::CreateTypeInfo().Obj()); - } - - auto block = MakePtr(); - funcDecl->statement = block; - - ///////////////////////////////////////////////////////////////////////////// - // if (Status != Waiting) raise "..."; - ///////////////////////////////////////////////////////////////////////////// - - { - auto ifStat = MakePtr(); - { - auto refStatus = MakePtr(); - refStatus->name.value = L"Status"; - - auto waitingStatus = MakePtr(); - waitingStatus->parent = GetExpressionFromTypeDescriptor(description::GetTypeDescriptor()); - waitingStatus->name.value = L"Waiting"; - - auto compExpr = MakePtr(); - compExpr->op = WfBinaryOperator::NE; - compExpr->first = refStatus; - compExpr->second = waitingStatus; - - ifStat->expression = compExpr; - } - - auto trueBlock = MakePtr(); - ifStat->trueBranch = trueBlock; - { - auto exExpr = MakePtr(); - exExpr->value.value = L"Resume should be called only when the coroutine is in the waiting status."; - - auto raiseStat = MakePtr(); - raiseStat->expression = exExpr; - trueBlock->statements.Add(raiseStat); - } - block->statements.Add(ifStat); - } - - ///////////////////////////////////////////////////////////////////////////// - // SetStatus(Executing); - ///////////////////////////////////////////////////////////////////////////// - - block->statements.Add(GenerateSetStatus(L"Executing")); - { - ///////////////////////////////////////////////////////////////////////////// - // try { ... } - ///////////////////////////////////////////////////////////////////////////// - - auto tryStat = MakePtr(); - auto tryBlock = MakePtr(); - tryStat->protectedStatement = tryBlock; - { - ///////////////////////////////////////////////////////////////////////////// - // while (true) { ... } - ///////////////////////////////////////////////////////////////////////////// - - auto whileStat = MakePtr(); - { - auto trueExpr = MakePtr(); - trueExpr->value = WfLiteralValue::True; - whileStat->condition = trueExpr; - } - - auto whileBlock = MakePtr(); - whileStat->statement = whileBlock; - - using GroupPair = Pair>; - auto nodeByCatches = From(nodeOrders) - .GroupBy([](FlowChartNode* node) - { - return node->exceptionDestination; - }) - .OrderBy([&](const GroupPair& p1, const GroupPair& p2) - { - return nodeOrders.IndexOf(p1.key) - nodeOrders.IndexOf(p2.key); - }); - - FOREACH(GroupPair, group, nodeByCatches) - { - auto catchNode = group.key; - auto groupBlock = whileBlock; - if (catchNode) - { - groupBlock = ExpandExceptionDestination(catchNode, referenceRenaming, nodeOrders, whileBlock); - } - - FOREACH(FlowChartNode*, flowChartNode, group.value) - { - ///////////////////////////////////////////////////////////////////////////// - // if ( == THE_CURRENT_STATE) { ... } - ///////////////////////////////////////////////////////////////////////////// - - auto ifStat = MakePtr(); - groupBlock->statements.Add(ifStat); - { - auto refState = MakePtr(); - refState->name.value = L""; - - auto intState = MakePtr(); - intState->value.value = itow(nodeOrders.IndexOf(flowChartNode)); - - auto compExpr = MakePtr(); - compExpr->op = WfBinaryOperator::EQ; - compExpr->first = refState; - compExpr->second = intState; - - ifStat->expression = compExpr; - } - - auto stateBlock = MakePtr(); - ifStat->trueBranch = stateBlock; - { - ExpandFlowChartNode(flowChart, flowChartNode, referenceRenaming, nodeOrders, catchNode, stateBlock); - } - } - } - tryBlock->statements.Add(whileStat); - } - - ///////////////////////////////////////////////////////////////////////////// - // catch() - // { - // SetFailure(); - // SetStatus(Stopped); - // if () raise ; - // } - ///////////////////////////////////////////////////////////////////////////// - - tryStat->name.value = L""; - auto catchBlock = MakePtr(); - tryStat->catchStatement = catchBlock; - { - auto refExpr = MakePtr(); - refExpr->name.value = L""; - - auto funcExpr = MakePtr(); - funcExpr->name.value = L"SetFailure"; - - auto callExpr = MakePtr(); - callExpr->function = funcExpr; - callExpr->arguments.Add(refExpr); - - auto stat = MakePtr(); - stat->expression = callExpr; - catchBlock->statements.Add(stat); - } - catchBlock->statements.Add(GenerateSetStatus(L"Stopped")); - { - auto refExpr = MakePtr(); - refExpr->name.value = L""; - - auto ifStat = MakePtr(); - ifStat->expression = refExpr; - - auto trueBlock = MakePtr(); - ifStat->trueBranch = trueBlock; - { - auto raiseStat = MakePtr(); - trueBlock->statements.Add(raiseStat); - } - catchBlock->statements.Add(ifStat); - } - - block->statements.Add(tryStat); - } - } - } - } - } -} - -/*********************************************************************** -ANALYZER\WFANALYZER_EXPANDSTATEMENT.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace analyzer - { - using namespace collections; - using namespace parsing; - using namespace reflection; - using namespace reflection::description; - -/*********************************************************************** -ExpandSwitchStatement -***********************************************************************/ - - void ExpandSwitchStatement(WfLexicalScopeManager* manager, WfSwitchStatement* node) - { - auto block = MakePtr(); - node->expandedStatement = block; - auto varName = L"" + itow(manager->usedTempVars++); - - { - auto result = manager->expressionResolvings[node->expression.Obj()]; - auto decl = MakePtr(); - decl->name.value = varName; - decl->type = GetTypeFromTypeInfo(result.type.Obj()); - decl->expression = CopyExpression(node->expression); - - auto stat = MakePtr(); - stat->variable = decl; - block->statements.Add(stat); - } - - Ptr rootIfStat; - auto tailIfStat = &rootIfStat; - - FOREACH(Ptr, switchCase, node->caseBranches) - { - auto ifStat = MakePtr(); - *tailIfStat = ifStat; - tailIfStat = &ifStat->falseBranch; - - { - auto refExpr = MakePtr(); - refExpr->name.value = varName; - - auto inferExpr = MakePtr(); - inferExpr->expression= CopyExpression(switchCase->expression); - { - auto result = manager->expressionResolvings[switchCase->expression.Obj()]; - inferExpr->type = GetTypeFromTypeInfo(result.type.Obj()); - } - - auto compare = MakePtr(); - compare->first = refExpr; - compare->second = inferExpr; - compare->op = WfBinaryOperator::EQ; - - ifStat->expression = compare; - } - ifStat->trueBranch = CopyStatement(switchCase->statement); - } - - if (node->defaultBranch) - { - *tailIfStat = CopyStatement(node->defaultBranch); - } - - if (rootIfStat) - { - block->statements.Add(rootIfStat); - } - } - -/*********************************************************************** -ExpandForEachStatement -***********************************************************************/ - - Ptr GenerateForEachStepStatement(WfForEachStatement* node) - { - auto refVar1 = MakePtr(); - refVar1->name.value = node->name.value; - - auto refVar2 = MakePtr(); - refVar2->name.value = node->name.value; - - auto one = MakePtr(); - one->value.value = L"1"; - - auto stepExpr = MakePtr(); - stepExpr->first = refVar2; - stepExpr->second = one; - stepExpr->op = node->direction == WfForEachDirection::Normal ? WfBinaryOperator::Add : WfBinaryOperator::Sub; - - auto assignExpr = MakePtr(); - assignExpr->first = refVar1; - assignExpr->second = stepExpr; - assignExpr->op = WfBinaryOperator::Assign; - - auto stat = MakePtr(); - stat->expression = assignExpr; - return stat; - } - - class CopyForEachRangeBodyVisitor - : public copy_visitor::ModuleVisitor - { - public: - WfLexicalScopeManager* manager; - WfForEachStatement* forEach; - - CopyForEachRangeBodyVisitor(WfLexicalScopeManager* _manager, WfForEachStatement* _forEach) - :manager(_manager) - , forEach(_forEach) - { - } - - void Visit(WfContinueStatement* node) - { - auto scope = manager->nodeScopes[node]; - while (scope) - { - if (scope->ownerNode.Cast()) - { - break; - } - else if (scope->ownerNode.Cast()) - { - if (scope->ownerNode != forEach) - { - break; - } - else - { - auto block = MakePtr(); - block->statements.Add(GenerateForEachStepStatement(forEach)); - block->statements.Add(MakePtr()); - SetCodeRange((Ptr)block, node->codeRange); - result = block; - return; - } - } - scope = scope->parentScope; - } - copy_visitor::StatementVisitor::Visit(node); - } - }; - - void ExpandForEachStatement(WfLexicalScopeManager* manager, WfForEachStatement* node) - { - auto block = MakePtr(); - node->expandedStatement = block; - - if (auto range = node->collection.Cast()) - { - auto varBegin = L"" + node->name.value; - auto varEnd = L"" + node->name.value; - { - auto result = manager->expressionResolvings[range->begin.Obj()]; - auto decl = MakePtr(); - decl->name.value = varBegin; - decl->type = GetTypeFromTypeInfo(result.type.Obj()); - decl->expression = CopyExpression(range->begin); - if (range->beginBoundary == WfRangeBoundary::Exclusive) - { - auto one = MakePtr(); - one->value.value = L"1"; - - auto addExpr = MakePtr(); - addExpr->first = decl->expression; - addExpr->second = one; - addExpr->op = WfBinaryOperator::Add; - - decl->expression = addExpr; - } - - auto stat = MakePtr(); - stat->variable = decl; - block->statements.Add(stat); - } - { - auto result = manager->expressionResolvings[range->end.Obj()]; - auto decl = MakePtr(); - decl->name.value = varEnd; - decl->type = GetTypeFromTypeInfo(result.type.Obj()); - decl->expression = CopyExpression(range->end); - if (range->endBoundary == WfRangeBoundary::Exclusive) - { - auto one = MakePtr(); - one->value.value = L"1"; - - auto subExpr = MakePtr(); - subExpr->first = decl->expression; - subExpr->second = one; - subExpr->op = WfBinaryOperator::Sub; - - decl->expression = subExpr; - } - - auto stat = MakePtr(); - stat->variable = decl; - block->statements.Add(stat); - } - { - auto refBegin = MakePtr(); - refBegin->name.value = node->direction == WfForEachDirection::Normal ? varBegin : varEnd; - - auto decl = MakePtr(); - decl->name.value = node->name.value; - decl->expression = refBegin; - - auto stat = MakePtr(); - stat->variable = decl; - block->statements.Add(stat); - } - { - auto whileStat = MakePtr(); - { - auto refVar = MakePtr(); - refVar->name.value = node->name.value; - - auto refBegin = MakePtr(); - refBegin->name.value = node->direction == WfForEachDirection::Normal ? varEnd : varBegin; - - auto compare = MakePtr(); - compare->first = refVar; - compare->second = refBegin; - compare->op = node->direction == WfForEachDirection::Normal ? WfBinaryOperator::LE : WfBinaryOperator::GE; - - whileStat->condition = compare; - } - { - auto whileBlock = MakePtr(); - whileStat->statement = whileBlock; - - { - CopyForEachRangeBodyVisitor visitor(manager, node); - node->statement->Accept(&visitor); - whileBlock->statements.Add(visitor.result.Cast()); - } - whileBlock->statements.Add(GenerateForEachStepStatement(node)); - } - block->statements.Add(whileStat); - } - } - else - { - auto varEnum = L"" + node->name.value; - auto varIter = L"" + node->name.value; - { - auto decl = MakePtr(); - decl->name.value = varEnum; - if (node->direction == WfForEachDirection::Normal) - { - auto inferExpr = MakePtr(); - inferExpr->expression = CopyExpression(node->collection); - inferExpr->type = GetTypeFromTypeInfo(TypeInfoRetriver>::CreateTypeInfo().Obj()); - - decl->expression = inferExpr; - } - else - { - auto refSystem = MakePtr(); - refSystem->name.value = L"system"; - - auto refSys = MakePtr(); - refSys->parent = refSystem; - refSys->name.value = L"Sys"; - - auto refMethod = MakePtr(); - refMethod->parent = refSys; - refMethod->name.value = L"ReverseEnumerable"; - - auto refCall = MakePtr(); - refCall->function = refMethod; - refCall->arguments.Add(CopyExpression(node->collection)); - - decl->expression = refCall; - } - - auto stat = MakePtr(); - stat->variable = decl; - block->statements.Add(stat); - } - { - auto refEnum = MakePtr(); - refEnum->name.value = varEnum; - - auto refMethod = MakePtr(); - refMethod->parent = refEnum; - refMethod->name.value = L"CreateEnumerator"; - - auto callExpr = MakePtr(); - callExpr->function = refMethod; - - auto decl = MakePtr(); - decl->name.value = varIter; - decl->expression = callExpr; - - auto stat = MakePtr(); - stat->variable = decl; - block->statements.Add(stat); - } - { - auto whileStat = MakePtr(); - { - auto refIter = MakePtr(); - refIter->name.value = varIter; - - auto refMethod = MakePtr(); - refMethod->parent = refIter; - refMethod->name.value = L"Next"; - - auto callExpr = MakePtr(); - callExpr->function = refMethod; - - whileStat->condition = callExpr; - } - { - auto whileBlock = MakePtr(); - whileStat->statement = whileBlock; - - { - auto refIter = MakePtr(); - refIter->name.value = varIter; - - auto refMethod = MakePtr(); - refMethod->parent = refIter; - refMethod->name.value = L"GetCurrent"; - - auto callExpr = MakePtr(); - callExpr->function = refMethod; - - auto castExpr = MakePtr(); - castExpr->expression = callExpr; - castExpr->strategy = WfTypeCastingStrategy::Strong; - { - auto parentScope = manager->nodeScopes[node]; - auto symbol = parentScope->symbols[node->name.value][0]; - castExpr->type = GetTypeFromTypeInfo(symbol->typeInfo.Obj()); - } - - auto decl = MakePtr(); - decl->name.value = node->name.value; - decl->expression = castExpr; - - auto stat = MakePtr(); - stat->variable = decl; - whileBlock->statements.Add(stat); - } - whileBlock->statements.Add(CopyStatement(node->statement)); - } - block->statements.Add(whileStat); - } - } - } - -/*********************************************************************** -ExpandCoProviderStatement -***********************************************************************/ - - class ExpandCoProviderStatementVisitor - : public copy_visitor::StatementVisitor - , public copy_visitor::CoroutineStatementVisitor - { - public: - WfLexicalScopeManager* manager; - - ExpandCoProviderStatementVisitor(WfLexicalScopeManager* _manager) - :manager(_manager) - { - } - - Ptr CreateField(Ptr from)override - { - if (!from) return nullptr; - return CopyExpression(from); - } - - Ptr CreateField(Ptr from)override - { - if (!from) return nullptr; - return CopyType(from); - } - - Ptr CreateField(Ptr from)override - { - if (!from) return nullptr; - from->Accept(this); - return result.Cast(); - } - - void Visit(WfReturnStatement* node)override - { - auto opInfo = manager->coOperatorResolvings[node].methodInfo; - auto block = MakePtr(); - - { - auto refImpl = MakePtr(); - refImpl->name.value = L""; - - auto funcExpr = MakePtr(); - funcExpr->parent = GetExpressionFromTypeDescriptor(opInfo->GetOwnerTypeDescriptor()); - funcExpr->name.value = opInfo->GetName(); - - auto callExpr = MakePtr(); - callExpr->function = funcExpr; - callExpr->arguments.Add(refImpl); - if (node->expression) - { - callExpr->arguments.Add(CreateField(node->expression)); - } - - auto stat = MakePtr(); - stat->expression = callExpr; - block->statements.Add(stat); - } - block->statements.Add(MakePtr()); - - SetCodeRange(Ptr(block), node->codeRange); - result = block; - } - - void Visit(WfCoOperatorStatement* node)override - { - auto opInfo = manager->coOperatorResolvings[node].methodInfo; - auto block = MakePtr(); - - { - auto refImpl = MakePtr(); - refImpl->name.value = L""; - - auto funcExpr = MakePtr(); - funcExpr->parent = GetExpressionFromTypeDescriptor(opInfo->GetOwnerTypeDescriptor()); - funcExpr->name.value = opInfo->GetName(); - - auto callExpr = MakePtr(); - callExpr->function = funcExpr; - callExpr->arguments.Add(refImpl); - FOREACH(Ptr, argument, node->arguments) - { - callExpr->arguments.Add(CreateField(argument)); - } - - auto stat = MakePtr(); - stat->expression = callExpr; - - auto pauseBlock = MakePtr(); - pauseBlock->statements.Add(stat); - - auto pauseStat = MakePtr(); - pauseStat->statement = pauseBlock; - - block->statements.Add(pauseStat); - } - { - Ptr ifHasResultStat; - - if (node->varName.value == L"") - { - ifHasResultStat = MakePtr(); - { - auto refCoResult = MakePtr(); - refCoResult->name.value = L""; - - auto testExpr = MakePtr(); - testExpr->expression = refCoResult; - testExpr->test = WfTypeTesting::IsNotNull; - - ifHasResultStat->expression = testExpr; - } - } - - auto ifStat = MakePtr(); - { - auto refCoResult = MakePtr(); - refCoResult->name.value = L""; - - auto refFailure = MakePtr(); - refFailure->parent = refCoResult; - refFailure->name.value = L"Failure"; - - auto testExpr = MakePtr(); - testExpr->expression = refFailure; - testExpr->test = WfTypeTesting::IsNotNull; - - ifStat->expression = testExpr; - } - { - auto refCoResult = MakePtr(); - refCoResult->name.value = L""; - - auto refFailure = MakePtr(); - refFailure->parent = refCoResult; - refFailure->name.value = L"Failure"; - - auto raiseStat = MakePtr(); - raiseStat->expression = refFailure; - - auto ifBlock = MakePtr(); - ifBlock->statements.Add(raiseStat); - ifStat->trueBranch = ifBlock; - } - - if (ifHasResultStat) - { - auto ifBlock = MakePtr(); - ifHasResultStat->trueBranch = ifBlock; - ifBlock->statements.Add(ifStat); - block->statements.Add(ifHasResultStat); - } - else - { - block->statements.Add(ifStat); - } - } - if (node->varName.value != L"") - { - auto refCoResult = MakePtr(); - refCoResult->name.value = L""; - - auto refResult = MakePtr(); - refResult->parent = refCoResult; - refResult->name.value = L"Result"; - - auto castResultInfo = manager->coCastResultResolvings[node].methodInfo; - auto refCastResult = MakePtr(); - refCastResult->parent = GetExpressionFromTypeDescriptor(castResultInfo->GetOwnerTypeDescriptor()); - refCastResult->name.value = L"CastResult"; - - auto callExpr = MakePtr(); - callExpr->function = refCastResult; - callExpr->arguments.Add(refResult); - - auto varDecl = MakePtr(); - varDecl->name.value = node->varName.value; - varDecl->expression = callExpr; - - auto stat = MakePtr(); - stat->variable = varDecl; - block->statements.Add(stat); - } - - SetCodeRange(Ptr(block), node->codeRange); - result = block; - } - - void Visit(WfBlockStatement* node)override - { - auto block = MakePtr(); - - FOREACH(Ptr, statement, node->statements) - { - while (auto virtualStat = statement.Cast()) - { - statement = virtualStat->expandedStatement; - } - if (auto coOperatorStat = statement.Cast()) - { - coOperatorStat->Accept(this); - CopyFrom(block->statements, result.Cast()->statements, true); - } - else - { - block->statements.Add(CreateField(statement)); - } - } - - SetCodeRange(Ptr(block), node->codeRange); - result = block; - } - - Ptr Dispatch(WfVirtualStatement* node)override - { - node->expandedStatement->Accept(this); - return result; - } - - Ptr Dispatch(WfCoroutineStatement* node)override - { - node->Accept((WfCoroutineStatement::IVisitor*)this); - return result; - } - }; - - void ExpandCoProviderStatement(WfLexicalScopeManager* manager, WfCoProviderStatement* node) - { - auto scope = manager->nodeScopes[node].Obj(); - auto functionScope = scope->FindFunctionScope(); - auto funcDecl = functionScope->ownerNode.Cast(); - auto providerScope = manager->nodeScopes[funcDecl->statement.Obj()]; - auto providerType = providerScope->symbols[L"$PROVIDER"][0]->typeInfo; - auto implType = providerScope->symbols[L"$IMPL"][0]->typeInfo; - - auto coroutineExpr = MakePtr(); - { - coroutineExpr->name.value = L""; - coroutineExpr->statement = ExpandCoProviderStatementVisitor(manager).CreateField(node->statement); - } - - auto creatorExpr = MakePtr(); - { - auto creatorDecl = MakePtr(); - creatorExpr->function = creatorDecl; - creatorDecl->anonymity = WfFunctionAnonymity::Anonymous; - creatorDecl->returnType = GetTypeFromTypeInfo(TypeInfoRetriver>::CreateTypeInfo().Obj()); - { - auto argument = MakePtr(); - creatorDecl->arguments.Add(argument); - argument->name.value = L""; - argument->type = GetTypeFromTypeInfo(implType.Obj()); - } - - auto block = MakePtr(); - creatorDecl->statement = block; - - auto returnStat = MakePtr(); - returnStat->expression = coroutineExpr; - block->statements.Add(returnStat); - } - - auto providerBlock = MakePtr(); - { - auto funcReturnType = CreateTypeInfoFromType(functionScope, funcDecl->returnType); - auto creatorInfo = manager->coProviderResolvings[node].methodInfo; - - auto funcExpr = MakePtr(); - funcExpr->parent = GetExpressionFromTypeDescriptor(creatorInfo->GetOwnerTypeDescriptor()); - funcExpr->name.value = creatorInfo->GetName(); - - auto callExpr = MakePtr(); - callExpr->function = funcExpr; - callExpr->arguments.Add(creatorExpr); - - if (funcReturnType->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - auto stat = MakePtr(); - stat->expression = callExpr; - providerBlock->statements.Add(stat); - } - else - { - if (IsSameType(funcReturnType.Obj(), creatorInfo->GetReturn())) - { - auto stat = MakePtr(); - stat->expression = callExpr; - providerBlock->statements.Add(stat); - } - else if (funcReturnType->GetTypeDescriptor() == creatorInfo->GetReturn()->GetTypeDescriptor()) - { - auto castExpr = MakePtr(); - castExpr->strategy = WfTypeCastingStrategy::Strong; - castExpr->type = GetTypeFromTypeInfo(funcReturnType.Obj()); - castExpr->expression = callExpr; - - auto stat = MakePtr(); - stat->expression = castExpr; - providerBlock->statements.Add(stat); - } - else - { - { - auto varDecl = MakePtr(); - varDecl->name.value = L""; - varDecl->expression = callExpr; - - auto stat = MakePtr(); - stat->variable = varDecl; - providerBlock->statements.Add(stat); - } - { - auto refExpr = MakePtr(); - refExpr->name.value = L""; - - auto castExpr = MakePtr(); - castExpr->type = GetTypeFromTypeInfo(funcReturnType.Obj()); - castExpr->expression = refExpr; - - auto stat = MakePtr(); - stat->expression = castExpr; - providerBlock->statements.Add(stat); - } - } - } - } - - node->expandedStatement = providerBlock; - } - } - } -} - -/*********************************************************************** -ANALYZER\WFANALYZER_MISC.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace analyzer - { - using namespace collections; - using namespace reflection; - using namespace reflection::description; - -/*********************************************************************** -IsExpressionDependOnExpectedType(Expression) -***********************************************************************/ - - class IsExpressionDependOnExpectedTypeVisitor - : public empty_visitor::ExpressionVisitor - , public empty_visitor::VirtualExpressionVisitor - { - public: - WfLexicalScopeManager* manager; - bool result; - - IsExpressionDependOnExpectedTypeVisitor(WfLexicalScopeManager* _manager) - :manager(_manager) - , result(false) - { - } - - void Dispatch(WfVirtualExpression* node)override - { - node->Accept(static_cast(this)); - } - - bool Execute(Ptr expression) - { - result = false; - expression->Accept(this); - return result; - } - - void Visit(WfReferenceExpression* node)override - { - auto scope = manager->nodeScopes[node].Obj(); - List testResults; - manager->ResolveName(scope, node->name.value, testResults); - if (testResults.Count() == 0) - { - result = true; - } - } - - void Visit(WfOrderedLambdaExpression* node)override - { - auto scope = manager->nodeScopes[node].Obj(); - result = scope->symbols.Count() > 0; - } - - void Visit(WfLiteralExpression* node)override - { - if (node->value == WfLiteralValue::Null) - { - result = true; - } - } - - void Visit(WfIfExpression* node)override - { - result = Execute(node->trueBranch) && Execute(node->falseBranch); - } - - void Visit(WfConstructorExpression* node)override - { - if (node->arguments.Count() == 0) - { - result = true; - } - else - { - vint possibleFieldCount = 0; - bool unresolvableField = false; - auto scope = manager->nodeScopes[node].Obj(); - - FOREACH(Ptr, argument, node->arguments) - { - if (argument->value) - { - if (auto refExpr = argument->key.Cast()) - { - possibleFieldCount++; - List testResults; - manager->ResolveName(scope, refExpr->name.value, testResults); - if (testResults.Count() == 0) - { - unresolvableField = true; - } - } - } - } - - result = unresolvableField&&possibleFieldCount == node->arguments.Count(); - } - } - - void Visit(WfExpectedTypeCastExpression* node)override - { - result = true; - } - }; - - bool IsExpressionDependOnExpectedType(WfLexicalScopeManager* manager, Ptr expression) - { - IsExpressionDependOnExpectedTypeVisitor visitor(manager); - expression->Accept(&visitor); - return visitor.result; - } - -/*********************************************************************** -GetExpressionName(Expression) -***********************************************************************/ - - class GetExpressionNameVisitor - : public empty_visitor::ExpressionVisitor - , public empty_visitor::VirtualExpressionVisitor - { - public: - WString result; - - void Dispatch(WfVirtualExpression* node)override - { - node->Accept(static_cast(this)); - } - - void Visit(WfTopQualifiedExpression* node)override - { - result = node->name.value; - } - - void Visit(WfReferenceExpression* node)override - { - result = node->name.value; - } - - void Visit(WfOrderedNameExpression* node)override - { - result = node->name.value; - } - - void Visit(WfMemberExpression* node)override - { - result = node->name.value; - } - - void Visit(WfChildExpression* node)override - { - result = node->name.value; - } - }; - - WString GetExpressionName(Ptr expression) - { - GetExpressionNameVisitor visitor; - expression->Accept(&visitor); - return visitor.result; - } - } - } -} - -/*********************************************************************** -ANALYZER\WFANALYZER_SEARCHORDEREDNAME.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace analyzer - { - using namespace collections; - -/*********************************************************************** -SearchOrderedName -***********************************************************************/ - - class SearchOrderedNameVisitor : public traverse_visitor::ModuleVisitor - { - public: - WfLexicalScope* scope; - SortedList& names; - - SearchOrderedNameVisitor(WfLexicalScope* _scope, SortedList& _names) - :scope(_scope) - , names(_names) - { - } - - void Traverse(WfOrderedNameExpression* node)override - { - vint name = wtoi(node->name.value.Sub(1, node->name.value.Length() - 1)); - if (!names.Contains(name)) - { - WfLexicalScope* currentScope = scope; - while (currentScope) - { - if (currentScope->symbols.Keys().Contains(node->name.value)) - { - return; - } - currentScope = currentScope->parentScope.Obj(); - } - names.Add(name); - } - } - - void Visit(WfOrderedLambdaExpression* node)override - { - // names in nested ordered lambda expression is not counted - } - - static void Execute(WfLexicalScope* scope, Ptr expression, SortedList& names) - { - SearchOrderedNameVisitor visitor(scope, names); - expression->Accept(&visitor); - } - }; - - void SearchOrderedName(WfLexicalScope* scope, Ptr expression, collections::SortedList& names) - { - SearchOrderedNameVisitor::Execute(scope, expression, names); - } - } - } -} - -/*********************************************************************** -ANALYZER\WFANALYZER_TYPEINFO.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace analyzer - { - using namespace collections; - using namespace reflection; - using namespace reflection::description; - -/*********************************************************************** -GetTypeFlag -***********************************************************************/ - - TypeFlag GetTypeFlag(reflection::description::ITypeDescriptor* typeDescriptor) - { - if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::Bool; - if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::I1; - if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::I2; - if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::I4; - if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::I8; - if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::U1; - if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::U2; - if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::U4; - if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::U8; - if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::F4; - if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::F8; - if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::String; - switch (typeDescriptor->GetTypeDescriptorFlags()) - { - case TypeDescriptorFlags::FlagEnum: - case TypeDescriptorFlags::NormalEnum: - return TypeFlag::Enum; - case TypeDescriptorFlags::Struct: - return TypeFlag::Struct; - default: - return TypeFlag::Others; - } - } - - TypeFlag GetTypeFlag(reflection::description::ITypeInfo* typeInfo) - { - ITypeDescriptor* td = typeInfo->GetTypeDescriptor(); - return GetTypeFlag(td); - } - -/*********************************************************************** -CreateTypeInfoFromTypeFlag -***********************************************************************/ - - Ptr CreateTypeInfoFromTypeFlag(TypeFlag flag) - { - switch (flag) - { - case TypeFlag::Bool: return TypeInfoRetriver::CreateTypeInfo(); - case TypeFlag::I1: return TypeInfoRetriver::CreateTypeInfo(); - case TypeFlag::I2: return TypeInfoRetriver::CreateTypeInfo(); - case TypeFlag::I4: return TypeInfoRetriver::CreateTypeInfo(); - case TypeFlag::I8: return TypeInfoRetriver::CreateTypeInfo(); - case TypeFlag::U1: return TypeInfoRetriver::CreateTypeInfo(); - case TypeFlag::U2: return TypeInfoRetriver::CreateTypeInfo(); - case TypeFlag::U4: return TypeInfoRetriver::CreateTypeInfo(); - case TypeFlag::U8: return TypeInfoRetriver::CreateTypeInfo(); - case TypeFlag::F4: return TypeInfoRetriver::CreateTypeInfo(); - case TypeFlag::F8: return TypeInfoRetriver::CreateTypeInfo(); - case TypeFlag::String: return TypeInfoRetriver::CreateTypeInfo(); - default: return nullptr; - } - } - -/*********************************************************************** -GetTypeFragments -***********************************************************************/ - - void GetTypeFragments(reflection::description::ITypeDescriptor* typeDescriptor, collections::List& fragments) - { - WString name = typeDescriptor->GetTypeName(); - const wchar_t* reading = name.Buffer(); - while (reading) - { - const wchar_t* delimiter = wcsstr(reading, L"::"); - if (delimiter) - { - fragments.Add(WString(reading, vint(delimiter - reading))); - reading = delimiter + 2; - } - else - { - fragments.Add(reading); - break; - } - } - } - -/*********************************************************************** -GetExpressionFromTypeDescriptor -***********************************************************************/ - - Ptr GetExpressionFromTypeDescriptor(reflection::description::ITypeDescriptor* typeDescriptor) - { - List fragments; - GetTypeFragments(typeDescriptor, fragments); - - Ptr parentExpr; - FOREACH(WString, fragment, fragments) - { - if (!parentExpr) - { - auto expr = MakePtr(); - expr->name.value = fragment; - parentExpr = expr; - } - else - { - auto expr = MakePtr(); - expr->parent = parentExpr; - expr->name.value = fragment; - parentExpr = expr; - } - } - return parentExpr; - } - -/*********************************************************************** -GetTypeFromTypeInfo -***********************************************************************/ - - Ptr GetTypeFromTypeInfo(reflection::description::ITypeInfo* typeInfo) - { - switch (typeInfo->GetDecorator()) - { - case ITypeInfo::RawPtr: - { - Ptr element = GetTypeFromTypeInfo(typeInfo->GetElementType()); - if (element) - { - Ptr type = new WfRawPointerType; - type->element = element; - return type; - } - return 0; - } - case ITypeInfo::SharedPtr: - { - if (typeInfo->GetElementType()->GetDecorator() == ITypeInfo::Generic) - { - return GetTypeFromTypeInfo(typeInfo->GetElementType()); - } - else - { - Ptr element = GetTypeFromTypeInfo(typeInfo->GetElementType()); - if (element) - { - Ptr type = new WfSharedPointerType; - type->element = element; - return type; - } - return 0; - } - } - case ITypeInfo::Nullable: - { - Ptr element = GetTypeFromTypeInfo(typeInfo->GetElementType()); - if (element) - { - Ptr type = new WfNullableType; - type->element = element; - return type; - } - return 0; - } - case ITypeInfo::TypeDescriptor: - { - List fragments; - GetTypeFragments(typeInfo->GetTypeDescriptor(), fragments); - - Ptr parentType; - FOREACH(WString, fragment, fragments) - { - if (!parentType) - { - auto type = MakePtr(); - type->name.value = fragment; - parentType = type; - } - else - { - auto type = MakePtr(); - type->parent = parentType; - type->name.value = fragment; - parentType = type; - } - } - return parentType; - } - case ITypeInfo::Generic: - { - if (typeInfo->GetElementType()->GetDecorator() == ITypeInfo::TypeDescriptor) - { - if (typeInfo->GetTypeDescriptor() == GetTypeDescriptor()) - { - if (typeInfo->GetGenericArgumentCount() == 1) - { - if (Ptr elementType = GetTypeFromTypeInfo(typeInfo->GetGenericArgument(0))) - { - Ptr type = new WfEnumerableType; - type->element = elementType; - return type; - } - } - } - else if (typeInfo->GetTypeDescriptor() == GetTypeDescriptor()) - { - if (typeInfo->GetGenericArgumentCount() == 1) - { - if (Ptr valueType = GetTypeFromTypeInfo(typeInfo->GetGenericArgument(0))) - { - Ptr type = new WfMapType; - type->writability = WfMapWritability::Readonly; - type->value = valueType; - return type; - } - } - } - else if (typeInfo->GetTypeDescriptor() == GetTypeDescriptor()) - { - if (typeInfo->GetGenericArgumentCount() == 1) - { - if (Ptr valueType = GetTypeFromTypeInfo(typeInfo->GetGenericArgument(0))) - { - Ptr type = new WfMapType; - type->writability = WfMapWritability::Writable; - type->value = valueType; - return type; - } - } - } - else if (typeInfo->GetTypeDescriptor() == GetTypeDescriptor()) - { - if (typeInfo->GetGenericArgumentCount() == 1) - { - if (Ptr elementType = GetTypeFromTypeInfo(typeInfo->GetGenericArgument(0))) - { - Ptr type = new WfObservableListType; - type->element = elementType; - return type; - } - } - } - else if (typeInfo->GetTypeDescriptor() == GetTypeDescriptor()) - { - if (typeInfo->GetGenericArgumentCount() == 2) - { - if (Ptr keyType = GetTypeFromTypeInfo(typeInfo->GetGenericArgument(0))) - if (Ptr valueType = GetTypeFromTypeInfo(typeInfo->GetGenericArgument(1))) - { - Ptr type = new WfMapType; - type->writability = WfMapWritability::Readonly; - type->key = keyType; - type->value = valueType; - return type; - } - } - } - else if (typeInfo->GetTypeDescriptor() == GetTypeDescriptor()) - { - if (typeInfo->GetGenericArgumentCount() == 2) - { - if (Ptr keyType = GetTypeFromTypeInfo(typeInfo->GetGenericArgument(0))) - if (Ptr valueType = GetTypeFromTypeInfo(typeInfo->GetGenericArgument(1))) - { - Ptr type = new WfMapType; - type->writability = WfMapWritability::Writable; - type->key = keyType; - type->value = valueType; - return type; - } - } - } - else if (typeInfo->GetTypeDescriptor() == GetTypeDescriptor()) - { - if (typeInfo->GetGenericArgumentCount() >= 1) - { - if (Ptr returnType = GetTypeFromTypeInfo(typeInfo->GetGenericArgument(0))) - { - Ptr type = new WfFunctionType; - type->result = GetTypeFromTypeInfo(typeInfo->GetGenericArgument(0)); - for (vint i = 1; i < typeInfo->GetGenericArgumentCount(); i++) - { - if (Ptr argumentType = GetTypeFromTypeInfo(typeInfo->GetGenericArgument(i))) - { - type->arguments.Add(argumentType); - } - else - { - return 0; - } - } - return type; - } - } - } - } - return 0; - } - default: - return 0; - } - } - -/*********************************************************************** -GetScopeNameFromReferenceType -***********************************************************************/ - - class GetScopeNameFromReferenceTypeVisitor : public Object, public WfType::IVisitor - { - public: - WfLexicalScope* scope; - Ptr result; - - GetScopeNameFromReferenceTypeVisitor(WfLexicalScope* _scope) - :scope(_scope) - { - } - - Ptr Call(WfType* node) - { - node->Accept(this); - Ptr scopeName = result; - result = 0; - return scopeName; - } - - void Visit(WfPredefinedType* node)override - { - WString name; - switch (node->name) - { - case WfPredefinedTypeName::Void: - name = L"Void"; - break; - case WfPredefinedTypeName::Object: - name = L"Object"; - break; - case WfPredefinedTypeName::Interface: - name = L"Interface"; - break; - case WfPredefinedTypeName::Int: -#if defined VCZH_64 - name = L"Int64"; -#else - name = L"Int32"; -#endif - break; - case WfPredefinedTypeName::UInt: -#if defined VCZH_64 - name = L"UInt64"; -#else - name = L"UInt32"; -#endif - break; - case WfPredefinedTypeName::Float: - name = L"Single"; - break; - case WfPredefinedTypeName::Double: - name = L"Double"; - break; - case WfPredefinedTypeName::String: - name = L"String"; - break; - case WfPredefinedTypeName::Char: - name = L"Char"; - break; - case WfPredefinedTypeName::Bool: - name = L"Boolean"; - break; - default: - CHECK_FAIL(L"GetScopeNameFromReferenceTypeVisitor::Visit(WfPredefinedType*)#Internal error, ValidateTypeStructure function should check correctly."); - } - - Ptr ns = new WfTopQualifiedType; - ns->name.value = L"system"; - - Ptr type = new WfChildType; - type->parent = ns; - type->name.value = name; - - type->Accept(this); - } - - void Visit(WfTopQualifiedType* node)override - { - auto manager = scope->FindManager(); - if (manager->globalName) - { - vint index = manager->globalName->children.Keys().IndexOf(node->name.value); - if (index != -1) - { - result = manager->globalName->children.Values()[index]; - return; - } - } - manager->errors.Add(WfErrors::TopQualifiedSymbolNotExists(node, node->name.value)); - } - - void Visit(WfReferenceType* node)override - { - auto manager = scope->FindManager(); - List results; - manager->ResolveName(scope, node->name.value, results); - - if (results.Count() > 1) - { - manager->errors.Add(WfErrors::TooManyTargets(node, results, node->name.value)); - } - else if (results.Count() == 1) - { - if (auto scopeName = results[0].scopeName) - { - result = scopeName; - } - else - { - manager->errors.Add(WfErrors::TypeNotExists(node, results[0])); - } - } - else - { - manager->errors.Add(WfErrors::ReferenceNotExists(node, node->name.value)); - } - } - - void Visit(WfRawPointerType* node)override - { - CHECK_FAIL(L"GetScopeNameFromReferenceTypeVisitor::Visit(WfRawPointerType*)#Internal error, ValidateTypeStructure function should check correctly."); - } - - void Visit(WfSharedPointerType* node)override - { - CHECK_FAIL(L"GetScopeNameFromReferenceTypeVisitor::Visit(WfSharedPointerType*)#Internal error, ValidateTypeStructure function should check correctly."); - } - - void Visit(WfNullableType* node)override - { - CHECK_FAIL(L"GetScopeNameFromReferenceTypeVisitor::Visit(WfNullableType*)#Internal error, ValidateTypeStructure function should check correctly."); - } - - void Visit(WfEnumerableType* node)override - { - CHECK_FAIL(L"GetScopeNameFromReferenceTypeVisitor::Visit(WfEnumerableType*)#Internal error, ValidateTypeStructure function should check correctly."); - } - - void Visit(WfMapType* node)override - { - CHECK_FAIL(L"GetScopeNameFromReferenceTypeVisitor::Visit(WfMapType*)#Internal error, ValidateTypeStructure function should check correctly."); - } - - void Visit(WfObservableListType* node)override - { - CHECK_FAIL(L"GetScopeNameFromReferenceTypeVisitor::Visit(WfObservableListType*)#Internal error, ValidateTypeStructure function should check correctly."); - } - - void Visit(WfFunctionType* node)override - { - CHECK_FAIL(L"GetScopeNameFromReferenceTypeVisitor::Visit(WfFunctionType*)#Internal error, ValidateTypeStructure function should check correctly."); - } - - void Visit(WfChildType* node)override - { - if (Ptr scopeName = Call(node->parent.Obj())) - { - vint index = scopeName->children.Keys().IndexOf(node->name.value); - if (index != -1) - { - result = scopeName->children.Values()[index]; - return; - } - scope->FindManager()->errors.Add(WfErrors::ChildSymbolNotExists(node, scopeName, node->name.value)); - } - } - - static Ptr Execute(WfLexicalScope* scope, WfType* type) - { - return GetScopeNameFromReferenceTypeVisitor(scope).Call(type); - } - }; - - Ptr GetScopeNameFromReferenceType(WfLexicalScope* scope, Ptr type) - { - return GetScopeNameFromReferenceTypeVisitor::Execute(scope, type.Obj()); - } - -/*********************************************************************** -CreateTypeInfoFromType -***********************************************************************/ - - class CreateTypeInfoFromTypeVisitor : public Object, public WfType::IVisitor - { - public: - WfLexicalScope* scope; - Ptr result; - - CreateTypeInfoFromTypeVisitor(WfLexicalScope* _scope) - :scope(_scope) - { - } - - Ptr Call(WfType* node, bool checkTypeForValue) - { - node->Accept(this); - Ptr typeInfo = result; - result = 0; - if (typeInfo) - { - auto manager = scope->FindManager(); - switch (typeInfo->GetDecorator()) - { - case ITypeInfo::RawPtr: - case ITypeInfo::SharedPtr: - switch (typeInfo->GetTypeDescriptor()->GetTypeDescriptorFlags()) - { - case TypeDescriptorFlags::IDescriptable: - case TypeDescriptorFlags::Class: - case TypeDescriptorFlags::Interface: - break; - default: - if (typeInfo->GetDecorator() == ITypeInfo::RawPtr) - { - manager->errors.Add(WfErrors::RawPointerToNonReferenceType(node, typeInfo.Obj())); - } - else - { - manager->errors.Add(WfErrors::SharedPointerToNonReferenceType(node, typeInfo.Obj())); - } - } - break; - case ITypeInfo::Nullable: - switch (typeInfo->GetTypeDescriptor()->GetTypeDescriptorFlags()) - { - case TypeDescriptorFlags::Primitive: - case TypeDescriptorFlags::Struct: - case TypeDescriptorFlags::FlagEnum: - case TypeDescriptorFlags::NormalEnum: - break; - default: - manager->errors.Add(WfErrors::NullableToNonReferenceType(node, typeInfo.Obj())); - } - break; - case ITypeInfo::TypeDescriptor: - if (checkTypeForValue) - { - switch (typeInfo->GetTypeDescriptor()->GetTypeDescriptorFlags()) - { - case TypeDescriptorFlags::Object: - case TypeDescriptorFlags::Primitive: - case TypeDescriptorFlags::Struct: - case TypeDescriptorFlags::FlagEnum: - case TypeDescriptorFlags::NormalEnum: - break; - default: - manager->errors.Add(WfErrors::TypeNotForValue(node, typeInfo.Obj())); - } - } - break; - case ITypeInfo::Generic: - if (checkTypeForValue) - { - manager->errors.Add(WfErrors::TypeNotForValue(node, typeInfo.Obj())); - } - break; - } - } - return typeInfo; - } - - void VisitReferenceType(WfType* node) - { - if (auto scopeName = GetScopeNameFromReferenceTypeVisitor::Execute(scope, node)) - { - if (scopeName->typeDescriptor) - { - result = MakePtr(scopeName->typeDescriptor, TypeInfoHint::Normal); - } - else - { - scope->FindManager()->errors.Add(WfErrors::TypeNotExists(node, scopeName)); - } - } - } - - void Visit(WfPredefinedType* node)override - { - ITypeDescriptor* typeDescriptor = 0; - switch (node->name) - { - case WfPredefinedTypeName::Void: - typeDescriptor = description::GetTypeDescriptor(); - break; - case WfPredefinedTypeName::Object: - typeDescriptor = description::GetTypeDescriptor(); - break; - case WfPredefinedTypeName::Interface: - typeDescriptor = description::GetTypeDescriptor(); - break; - case WfPredefinedTypeName::Int: - typeDescriptor = description::GetTypeDescriptor(); - break; - case WfPredefinedTypeName::UInt: - typeDescriptor = description::GetTypeDescriptor(); - break; - case WfPredefinedTypeName::Float: - typeDescriptor = description::GetTypeDescriptor(); - break; - case WfPredefinedTypeName::Double: - typeDescriptor = description::GetTypeDescriptor(); - break; - case WfPredefinedTypeName::String: - typeDescriptor = description::GetTypeDescriptor(); - break; - case WfPredefinedTypeName::Char: - typeDescriptor = description::GetTypeDescriptor(); - break; - case WfPredefinedTypeName::Bool: - typeDescriptor = description::GetTypeDescriptor(); - break; - default: - CHECK_FAIL(L"CreateTypeInfoFromTypeVisitor::Visit(WfPredefinedType*)#Internal error, ValidateTypeStructure function should check correctly."); - } - if (typeDescriptor) - { - result = MakePtr(typeDescriptor, TypeInfoHint::Normal); - } - } - - void Visit(WfTopQualifiedType* node)override - { - VisitReferenceType(node); - } - - void Visit(WfReferenceType* node)override - { - VisitReferenceType(node); - } - - void Visit(WfRawPointerType* node)override - { - if (Ptr element = Call(node->element.Obj(), false)) - { - result = MakePtr(element); - } - } - - void Visit(WfSharedPointerType* node)override - { - if (Ptr element = Call(node->element.Obj(), false)) - { - result = MakePtr(element); - } - } - - void Visit(WfNullableType* node)override - { - if (Ptr element = Call(node->element.Obj(), false)) - { - result = MakePtr(element); - } - } - - void Visit(WfEnumerableType* node)override - { - if (Ptr element = Call(node->element.Obj(), true)) - { - auto enumerableTypeInfo = MakePtr(description::GetTypeDescriptor(), TypeInfoHint::Normal); - auto genericTypeInfo = MakePtr(enumerableTypeInfo); - genericTypeInfo->AddGenericArgument(element); - result = MakePtr(genericTypeInfo); - } - } - - void Visit(WfMapType* node)override - { - Ptr key, value; - if (!(value = Call(node->value.Obj(), true))) return; - if (node->key) - { - if (!(key = Call(node->key.Obj(), true))) return; - } - - ITypeDescriptor* typeDescriptor = nullptr; - if (node->writability == WfMapWritability::Writable) - { - if (node->key) - { - typeDescriptor = description::GetTypeDescriptor(); - } - else - { - typeDescriptor = description::GetTypeDescriptor(); - } - } - else - { - if (node->key) - { - typeDescriptor = description::GetTypeDescriptor(); - } - else - { - typeDescriptor = description::GetTypeDescriptor(); - } - } - - auto mapTypeInfo = MakePtr(typeDescriptor, TypeInfoHint::Normal); - auto genericTypeInfo = MakePtr(mapTypeInfo); - if (key) genericTypeInfo->AddGenericArgument(key); - genericTypeInfo->AddGenericArgument(value); - result = MakePtr(genericTypeInfo); - } - - void Visit(WfObservableListType* node)override - { - Ptr element; - if (!(element = Call(node->element.Obj(), true))) return; - - auto typeDescriptor = description::GetTypeDescriptor(); - auto mapTypeInfo = MakePtr(typeDescriptor, TypeInfoHint::Normal); - auto genericTypeInfo = MakePtr(mapTypeInfo); - genericTypeInfo->AddGenericArgument(element); - result = MakePtr(genericTypeInfo); - } - - void Visit(WfFunctionType* node)override - { - if (Ptr returnType = Call(node->result.Obj(), true)) - { - auto enumerableTypeInfo = MakePtr(description::GetTypeDescriptor(), TypeInfoHint::Normal); - auto genericTypeInfo = MakePtr(enumerableTypeInfo); - genericTypeInfo->AddGenericArgument(returnType); - FOREACH(Ptr, argument, node->arguments) - { - if (Ptr argumentType = Call(argument.Obj(), true)) - { - genericTypeInfo->AddGenericArgument(argumentType); - } - else - { - return; - } - } - result = MakePtr(genericTypeInfo); - } - } - - void Visit(WfChildType* node)override - { - VisitReferenceType(node); - } - - static Ptr Execute(WfLexicalScope* scope, WfType* type) - { - return CreateTypeInfoFromTypeVisitor(scope).Call(type, true); - } - }; - - Ptr CreateTypeInfoFromType(WfLexicalScope* scope, Ptr type) - { - return CreateTypeInfoFromTypeVisitor::Execute(scope, type.Obj()); - } - -/*********************************************************************** -CreateTypeInfoFromType -***********************************************************************/ - - Ptr CopyTypeInfoInternal(reflection::description::ITypeInfo* typeInfo) - { - switch (typeInfo->GetDecorator()) - { - case ITypeInfo::RawPtr: - return MakePtr(CopyTypeInfo(typeInfo->GetElementType())); - case ITypeInfo::SharedPtr: - return MakePtr(CopyTypeInfo(typeInfo->GetElementType())); - case ITypeInfo::Nullable: - return MakePtr(CopyTypeInfo(typeInfo->GetElementType())); - case ITypeInfo::TypeDescriptor: - return MakePtr(typeInfo->GetTypeDescriptor(), typeInfo->GetHint()); - case ITypeInfo::Generic: - { - auto impl = MakePtr(typeInfo->GetElementType()); - vint count = typeInfo->GetGenericArgumentCount(); - for (vint i = 0; i < count; i++) - { - impl->AddGenericArgument(CopyTypeInfo(typeInfo->GetGenericArgument(i))); - } - return impl; - } - default:; - return nullptr; - } - } - - Ptr CopyTypeInfo(reflection::description::ITypeInfo* typeInfo) - { - if (!typeInfo) return nullptr; - return CopyTypeInfoInternal(typeInfo); - } - -/*********************************************************************** -CanConvertToType -***********************************************************************/ - - bool CanConvertToType(reflection::description::ITypeInfo* fromType, reflection::description::ITypeInfo* toType, bool explicitly) - { - ITypeDescriptor* objectType = GetTypeDescriptor(); - bool fromObject = fromType->GetDecorator() == ITypeInfo::TypeDescriptor && fromType->GetTypeDescriptor() == objectType; - bool toObject = toType->GetDecorator() == ITypeInfo::TypeDescriptor && toType->GetTypeDescriptor() == objectType; - - if (fromObject && toObject) - { - return true; - } - else if (fromObject) - { - return explicitly; - } - else if (toObject) - { - return true; - } - - switch (fromType->GetDecorator()) - { - case ITypeInfo::RawPtr: - switch (toType->GetDecorator()) - { - case ITypeInfo::RawPtr: - return CanConvertToType(fromType->GetElementType(), toType->GetElementType(), explicitly); - case ITypeInfo::SharedPtr: - return explicitly && CanConvertToType(fromType->GetElementType(), toType->GetElementType(), explicitly); - case ITypeInfo::Nullable: - case ITypeInfo::TypeDescriptor: - case ITypeInfo::Generic: - return false; - } - break; - case ITypeInfo::SharedPtr: - switch (toType->GetDecorator()) - { - case ITypeInfo::RawPtr: - return explicitly && CanConvertToType(fromType->GetElementType(), toType->GetElementType(), explicitly); - case ITypeInfo::SharedPtr: - return CanConvertToType(fromType->GetElementType(), toType->GetElementType(), explicitly); - case ITypeInfo::Nullable: - case ITypeInfo::TypeDescriptor: - case ITypeInfo::Generic: - return false; - } - break; - case ITypeInfo::Nullable: - switch (toType->GetDecorator()) - { - case ITypeInfo::RawPtr: - case ITypeInfo::SharedPtr: - return false; - case ITypeInfo::Nullable: - return CanConvertToType(fromType->GetElementType(), toType->GetElementType(), explicitly); - case ITypeInfo::TypeDescriptor: - return explicitly && CanConvertToType(fromType->GetElementType(), toType, explicitly); - case ITypeInfo::Generic: - return false; - } - break; - case ITypeInfo::TypeDescriptor: - switch (toType->GetDecorator()) - { - case ITypeInfo::RawPtr: - case ITypeInfo::SharedPtr: - return false; - case ITypeInfo::Nullable: - return CanConvertToType(fromType, toType->GetElementType(), explicitly); - case ITypeInfo::TypeDescriptor: - { - ITypeDescriptor* fromTd = fromType->GetTypeDescriptor(); - ITypeDescriptor* toTd = toType->GetTypeDescriptor(); - bool fromValue = (fromTd->GetTypeDescriptorFlags() & TypeDescriptorFlags::ReferenceType) == TypeDescriptorFlags::Undefined; - bool toValue = (toTd->GetTypeDescriptorFlags() & TypeDescriptorFlags::ReferenceType) == TypeDescriptorFlags::Undefined; - if (fromValue != toValue) - { - return false; - } - - if (fromValue) - { - if (fromTd == toTd) - { - return true; - } - else if (fromTd == GetTypeDescriptor()) - { - return explicitly && toTd->GetSerializableType() != nullptr; - } - else if (toTd == GetTypeDescriptor()) - { - return fromTd->GetSerializableType() != nullptr; - } - - TypeFlag fromFlag = GetTypeFlag(fromTd); - TypeFlag toFlag = GetTypeFlag(toTd); - static vint conversionTable[(vint)TypeFlag::Count][(vint)TypeFlag::Count] = { - /*Bool */{1, /**/ 0, 0, 0, 0, /**/ 0, 0, 0, 0, /**/ 0, 0, /**/ 1, 0, 0, 0}, - //------------------------------------------------------------------------------- - /*I1 */{0, /**/ 1, 1, 1, 1, /**/ 2, 2, 2, 2, /**/ 1, 1, /**/ 1, 0, 0, 0}, - /*I2 */{0, /**/ 2, 1, 1, 1, /**/ 2, 2, 2, 2, /**/ 1, 1, /**/ 1, 0, 0, 0}, - /*I4 */{0, /**/ 2, 2, 1, 1, /**/ 2, 2, 2, 2, /**/ 2, 1, /**/ 1, 0, 0, 0}, - /*I8 */{0, /**/ 2, 2, 2, 1, /**/ 2, 2, 2, 2, /**/ 2, 1, /**/ 1, 0, 0, 0}, - //------------------------------------------------------------------------------- - /*U1 */{0, /**/ 2, 2, 2, 2, /**/ 1, 1, 1, 1, /**/ 1, 1, /**/ 1, 0, 0, 0}, - /*U2 */{0, /**/ 2, 2, 2, 2, /**/ 2, 1, 1, 1, /**/ 1, 1, /**/ 1, 0, 0, 0}, - /*U4 */{0, /**/ 2, 2, 2, 2, /**/ 2, 2, 1, 1, /**/ 2, 1, /**/ 1, 0, 0, 0}, - /*U8 */{0, /**/ 2, 2, 2, 2, /**/ 2, 2, 2, 1, /**/ 2, 1, /**/ 1, 2, 0, 0}, - //------------------------------------------------------------------------------- - /*F4 */{0, /**/ 2, 2, 2, 2, /**/ 2, 2, 2, 2, /**/ 1, 1, /**/ 1, 0, 0, 0}, - /*F8 */{0, /**/ 2, 2, 2, 2, /**/ 2, 2, 2, 2, /**/ 2, 1, /**/ 1, 0, 0, 0}, - //------------------------------------------------------------------------------- - /*String */{2, /**/ 2, 2, 2, 2, /**/ 2, 2, 2, 2, /**/ 2, 2, /**/ 1, 0, 0, 0}, - /*Enum */{0, /**/ 0, 0, 0, 0, /**/ 0, 0, 0, 2, /**/ 0, 0, /**/ 0, 0, 0, 0}, - /*Struct */{0, /**/ 0, 0, 0, 0, /**/ 0, 0, 0, 0, /**/ 0, 0, /**/ 0, 0, 0, 0}, - /*Others */{0, /**/ 0, 0, 0, 0, /**/ 0, 0, 0, 0, /**/ 0, 0, /**/ 0, 0, 0, 0}, - }; - vint conversion = conversionTable[(vint)fromFlag][(vint)toFlag]; - return conversion == 1 || (explicitly && conversion == 2); - } - else - { - if (fromTd->CanConvertTo(toTd)) - { - return true; - } - if (explicitly && toTd->CanConvertTo(fromTd)) - { - return true; - } - } - } - break; - case ITypeInfo::Generic: - return explicitly && CanConvertToType(fromType, toType->GetElementType(), explicitly); - } - break; - case ITypeInfo::Generic: - switch (toType->GetDecorator()) - { - case ITypeInfo::RawPtr: - case ITypeInfo::SharedPtr: - case ITypeInfo::Nullable: - return false; - case ITypeInfo::TypeDescriptor: - return CanConvertToType(fromType->GetElementType(), toType, explicitly); - case ITypeInfo::Generic: - if (explicitly) return true; - if (fromType->GetGenericArgumentCount() != toType->GetGenericArgumentCount()) - { - return false; - } - if (!CanConvertToType(fromType->GetElementType(), toType->GetElementType(), explicitly)) return false; - for (vint i = 0; i < fromType->GetGenericArgumentCount(); i++) - { - if (!IsSameType(fromType->GetGenericArgument(i), toType->GetGenericArgument(i))) - { - return false; - } - } - return true; - } - break; - } - return false; - } - -/*********************************************************************** -IsSameType -***********************************************************************/ - - bool IsSameType(reflection::description::ITypeInfo* fromType, reflection::description::ITypeInfo* toType) - { - if (fromType->GetDecorator() != toType->GetDecorator()) - { - return false; - } - switch (fromType->GetDecorator()) - { - case ITypeInfo::RawPtr: - case ITypeInfo::SharedPtr: - case ITypeInfo::Nullable: - return IsSameType(fromType->GetElementType(), toType->GetElementType()); - case ITypeInfo::TypeDescriptor: - return fromType->GetTypeDescriptor() == toType->GetTypeDescriptor(); - case ITypeInfo::Generic: - if (fromType->GetGenericArgumentCount() != toType->GetGenericArgumentCount()) - { - return false; - } - if (!IsSameType(fromType->GetElementType(), toType->GetElementType())) return false; - for (vint i = 0; i < fromType->GetGenericArgumentCount(); i++) - { - if (!IsSameType(fromType->GetGenericArgument(i), toType->GetGenericArgument(i))) - { - return false; - } - } - return true; - } - return false; - } - -/*********************************************************************** -GetMergedType -***********************************************************************/ - - Ptr GetMergedType(Ptr firstType, Ptr secondType) - { - if (CanConvertToType(secondType.Obj(), firstType.Obj(), false)) - { - return firstType; - } - else if (CanConvertToType(firstType.Obj(), secondType.Obj(), false)) - { - return secondType; - } - else - { - return 0; - } - } - -/*********************************************************************** -IsNullAcceptableType -***********************************************************************/ - - bool IsNullAcceptableType(reflection::description::ITypeInfo* type) - { - switch (type->GetDecorator()) - { - case ITypeInfo::RawPtr: - case ITypeInfo::SharedPtr: - case ITypeInfo::Nullable: - return true; - case ITypeInfo::TypeDescriptor: - return type->GetTypeDescriptor() == description::GetTypeDescriptor(); - case ITypeInfo::Generic: - return false; - } - return false; - } - -/*********************************************************************** -CreateTypeInfoFromMethodInfo -***********************************************************************/ - - Ptr CreateTypeInfoFromMethodInfo(reflection::description::IMethodInfo* info) - { - auto elementType = MakePtr(description::GetTypeDescriptor(), TypeInfoHint::Normal); - auto genericType = MakePtr(elementType); - genericType->AddGenericArgument(CopyTypeInfo(info->GetReturn())); - vint parameterCount = info->GetParameterCount(); - for (vint j = 0; j < parameterCount; j++) - { - genericType->AddGenericArgument(CopyTypeInfo(info->GetParameter(j)->GetType())); - } - return MakePtr(genericType); - } - } - } -} - -/*********************************************************************** -ANALYZER\WFANALYZER_VALIDATESEMANTIC.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace analyzer - { - using namespace collections; - using namespace reflection; - using namespace reflection::description; - using namespace typeimpl; - -/*********************************************************************** -Helper Functions -***********************************************************************/ - - IMethodInfo* FindInterfaceConstructor(ITypeDescriptor* type) - { - if (auto ctors = type->GetConstructorGroup()) - { - auto proxyTd = description::GetTypeDescriptor(); - for (vint i = 0; i < ctors->GetMethodCount(); i++) - { - IMethodInfo* info = ctors->GetMethod(i); - if (info->GetParameterCount() == 1) - { - ITypeInfo* parameterType = info->GetParameter(0)->GetType(); - if (parameterType->GetDecorator() == ITypeInfo::SharedPtr) - { - parameterType = parameterType->GetElementType(); - if (parameterType->GetDecorator() == ITypeInfo::TypeDescriptor && parameterType->GetTypeDescriptor() == proxyTd) - { - return info; - } - } - } - } - } - return nullptr; - } - - ITypeInfo* GetFunctionType(const ResolveExpressionResult& result) - { - if (result.eventInfo) - { - return result.eventInfo->GetHandlerType(); - } - else if (result.type) - { - return result.type.Obj(); - } - else - { - return nullptr; - } - } - - Ptr SelectFunction(WfLexicalScopeManager* manager, parsing::ParsingTreeCustomBase* node, Ptr functionExpression, List& functions, List>& arguments, vint& selectedFunctionIndex) - { - selectedFunctionIndex = -1; - - List resolvables; - List> types; - FOREACH(Ptr, argument, arguments) - { - if (!argument || IsExpressionDependOnExpectedType(manager, argument)) - { - resolvables.Add(false); - types.Add(nullptr); - } - else - { - resolvables.Add(true); - types.Add(GetExpressionType(manager, argument, 0)); - } - } - - List> functionErrors, nonFunctionErrors; - List selectedFunctionIndices; - ITypeDescriptor* functionFd = description::GetTypeDescriptor(); - for (vint i = 0; i < functions.Count(); i++) - { - bool failed = false; - auto result = functions[i]; - ITypeInfo* expressionType = GetFunctionType(result); - - if (expressionType->GetDecorator() == ITypeInfo::SharedPtr) - { - ITypeInfo* genericType = expressionType->GetElementType(); - if (genericType->GetDecorator() != ITypeInfo::Generic) goto FUNCTION_TYPE_FAILED; - ITypeInfo* functionType = genericType->GetElementType(); - if (functionType->GetDecorator() != ITypeInfo::TypeDescriptor || functionType->GetTypeDescriptor() != functionFd) goto FUNCTION_TYPE_FAILED; - - if (genericType->GetGenericArgumentCount() != types.Count() + 1) - { - functionErrors.Add(WfErrors::FunctionArgumentCountMismatched(node, arguments.Count(), result)); - failed = true; - } - else - { - for (vint j = 0; j < types.Count(); j++) - { - if (resolvables[j] && types[j]) - { - ITypeInfo* argumentType = genericType->GetGenericArgument(j + 1); - if (!CanConvertToType(types[j].Obj(), argumentType, false)) - { - functionErrors.Add(WfErrors::FunctionArgumentTypeMismatched(node, result, j + 1, types[j].Obj(), argumentType)); - failed = true; - } - } - } - } - } - else - { - goto FUNCTION_TYPE_FAILED; - } - - goto FUNCTION_TYPE_FINISHED; - FUNCTION_TYPE_FAILED: - nonFunctionErrors.Add(WfErrors::ExpressionIsNotFunction(functionExpression.Obj(), result.type.Obj())); - failed = true; - FUNCTION_TYPE_FINISHED: - if (!failed) - { - selectedFunctionIndices.Add(i); - } - } - - if (selectedFunctionIndices.Count() == 1) - { - selectedFunctionIndex = selectedFunctionIndices[0]; - ITypeInfo* genericType = GetFunctionType(functions[selectedFunctionIndex])->GetElementType(); - for (vint i = 0; i < types.Count(); i++) - { - if (!resolvables[i]) - { - ITypeInfo* argumentType = genericType->GetGenericArgument(i + 1); - if (arguments[i]) - { - GetExpressionType(manager, arguments[i], CopyTypeInfo(argumentType)); - } - } - } - return CopyTypeInfo(genericType->GetGenericArgument(0)); - } - else - { - if (selectedFunctionIndices.Count() > 1) - { - List overloadedFunctions; - CopyFrom( - overloadedFunctions, - From(selectedFunctionIndices) - .Select([&functions](vint index) - { - return functions[index]; - })); - manager->errors.Add(WfErrors::CannotPickOverloadedFunctions(node, overloadedFunctions)); - } - - if (functionErrors.Count() > 0) - { - CopyFrom(manager->errors, functionErrors, true); - } - else - { - CopyFrom(manager->errors, nonFunctionErrors, true); - } - return nullptr; - } - } - -/*********************************************************************** -ValidateSemantic(ClassMember) -***********************************************************************/ - - class ValidateSemanticClassMemberVisitor : public Object, public WfDeclaration::IVisitor - { - public: - WfLexicalScopeManager* manager; - Ptr td; - Ptr classDecl; - - ValidateSemanticClassMemberVisitor(Ptr _td, Ptr _classDecl, WfLexicalScopeManager* _manager) - :td(_td) - , classDecl(_classDecl) - , manager(_manager) - { - } - - void Visit(WfNamespaceDeclaration* node)override - { - } - - void Visit(WfFunctionDeclaration* node)override - { - ValidateDeclarationSemantic(manager, node); - } - - void Visit(WfVariableDeclaration* node)override - { - ValidateDeclarationSemantic(manager, node); - } - - void Visit(WfEventDeclaration* node)override - { - ValidateDeclarationSemantic(manager, node); - } - - void Visit(WfPropertyDeclaration* node)override - { - ValidateDeclarationSemantic(manager, node); - - auto scope = manager->nodeScopes[node]; - if (auto typeInfo = CreateTypeInfoFromType(scope.Obj(), node->type)) - { - if (node->getter.value != L"") - { - auto getter = td->GetMethodGroupByName(node->getter.value, false)->GetMethod(0); - if (!IsSameType(typeInfo.Obj(), getter->GetReturn()) || getter->GetParameterCount() != 0) - { - manager->errors.Add(WfErrors::PropertyGetterTypeMismatched(node, classDecl.Obj())); - } - } - - if (node->setter.value != L"") - { - auto setter = td->GetMethodGroupByName(node->setter.value, false)->GetMethod(0); - if (setter->GetReturn()->GetTypeDescriptor() != description::GetTypeDescriptor() || setter->GetParameterCount() != 1 || !IsSameType(typeInfo.Obj(), setter->GetParameter(0)->GetType())) - { - manager->errors.Add(WfErrors::PropertySetterTypeMismatched(node, classDecl.Obj())); - } - } - } - } - - static void SelectConstructor(WfLexicalScopeManager* manager, WfConstructorDeclaration* ctorDecl, parsing::ParsingTreeCustomBase* node, ITypeDescriptor* td, List>& arguments) - { - List functions; - if (auto ctors = td->GetConstructorGroup()) - { - vint count = ctors->GetMethodCount(); - for (vint i = 0; i < count; i++) - { - auto ctor = ctors->GetMethod(i); - functions.Add(ResolveExpressionResult::Method(ctor)); - } - } - - vint selectedFunctionIndex = -1; - SelectFunction(manager, node, nullptr, functions, arguments, selectedFunctionIndex); - if (selectedFunctionIndex != -1) - { - auto ctor = functions[selectedFunctionIndex].methodInfo; - auto call = dynamic_cast(node); - manager->baseConstructorCallResolvings.Add({ctorDecl, td}, {call, ctor}); - } - } - - void Visit(WfConstructorDeclaration* node)override - { - ValidateDeclarationSemantic(manager, node); - - auto scope = manager->nodeScopes[node].Obj(); - auto classScope = scope->parentScope.Obj(); - SortedList baseTypes, initTypes; - { - auto td = classScope->typeOfThisExpr; - vint count = td->GetBaseTypeDescriptorCount(); - for (vint i = 0; i < count; i++) - { - auto baseTd = td->GetBaseTypeDescriptor(i); - if (!baseTypes.Contains(baseTd)) - { - baseTypes.Add(baseTd); - } - } - } - - FOREACH(Ptr, call, node->baseConstructorCalls) - { - if (auto scopeName = GetScopeNameFromReferenceType(classScope, call->type)) - { - if (auto td = scopeName->typeDescriptor) - { - if (initTypes.Contains(td)) - { - manager->errors.Add(WfErrors::DuplicatedBaseConstructorCall(call.Obj(), td)); - } - else if (baseTypes.Contains(td)) - { - initTypes.Add(td); - SelectConstructor(manager, node, call.Obj(), td, call->arguments); - } - else - { - manager->errors.Add(WfErrors::WrongBaseConstructorCall(call.Obj(), td)); - } - } - } - } - - { - vint index = -1; - for (vint i = 0; i < initTypes.Count(); i++) - { - while (baseTypes[++index] != initTypes[i]) - { - auto td = baseTypes[index]; - List> arguments; - SelectConstructor(manager, node, node, td, arguments); - } - } - while (++index < baseTypes.Count()) - { - auto td = baseTypes[index]; - List> arguments; - SelectConstructor(manager, node, node, td, arguments); - } - } - - ValidateStatementSemantic(manager, node->statement); - } - - void Visit(WfDestructorDeclaration* node)override - { - ValidateDeclarationSemantic(manager, node); - ValidateStatementSemantic(manager, node->statement); - } - - void Visit(WfClassDeclaration* node)override - { - ValidateDeclarationSemantic(manager, node); - } - - void Visit(WfEnumDeclaration* node)override - { - ValidateDeclarationSemantic(manager, node); - } - - void Visit(WfStructDeclaration* node)override - { - ValidateDeclarationSemantic(manager, node); - } - - void Visit(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - - static void Execute(Ptr td, Ptr classDecl, Ptr memberDecl, WfLexicalScopeManager* manager) - { - ValidateSemanticClassMemberVisitor visitor(td, classDecl, manager); - memberDecl->Accept(&visitor); - } - }; - -/*********************************************************************** -ValidateSemantic(Declaration) -***********************************************************************/ - - class ValidateSemanticDeclarationVisitor : public Object, public WfDeclaration::IVisitor - { - public: - WfLexicalScopeManager* manager; - - ValidateSemanticDeclarationVisitor(WfLexicalScopeManager* _manager) - :manager(_manager) - { - } - - void Visit(List>& attributes) - { - FOREACH(Ptr, attribute, attributes) - { - auto key = Pair(attribute->category.value, attribute->name.value); - vint index = manager->attributes.Keys().IndexOf(key); - if (index == -1) - { - manager->errors.Add(WfErrors::AttributeNotExists(attribute.Obj())); - } - else - { - auto expectedType = manager->attributes.Values()[index]; - if (attribute->value) - { - ValidateConstantExpression(manager, attribute->value, expectedType); - } - else if (expectedType->GetTypeDescriptor() != description::GetTypeDescriptor()) - { - manager->errors.Add(WfErrors::AttributeMissValue(attribute.Obj())); - } - } - } - } - - void Visit(WfNamespaceDeclaration* node)override - { - FOREACH(Ptr, declaration, node->declarations) - { - ValidateDeclarationSemantic(manager, declaration); - } - } - - void Visit(WfFunctionDeclaration* node)override - { - if (node->statement) - { - ValidateStatementSemantic(manager, node->statement); - } - FOREACH(Ptr, argument, node->arguments) - { - Visit(argument->attributes); - } - } - - void Visit(WfVariableDeclaration* node)override - { - auto scope = manager->nodeScopes[node]; - auto symbol = scope->symbols[node->name.value][0]; - symbol->typeInfo = GetExpressionType(manager, node->expression, symbol->typeInfo); - if (symbol->typeInfo && !symbol->type) - { - symbol->type = GetTypeFromTypeInfo(symbol->typeInfo.Obj()); - } - } - - void Visit(WfEventDeclaration* node)override - { - } - - void Visit(WfPropertyDeclaration* node)override - { - } - - void Visit(WfConstructorDeclaration* node)override - { - } - - void Visit(WfDestructorDeclaration* node)override - { - } - - void Visit(WfClassDeclaration* node)override - { - auto scope = manager->nodeScopes[node]; - auto td = manager->declarationTypes[node].Cast(); - - if (node->kind == WfClassKind::Interface) - { - FOREACH(Ptr, baseType, node->baseTypes) - { - auto scopeName = GetScopeNameFromReferenceType(scope->parentScope.Obj(), baseType); - auto baseTd = scopeName->typeDescriptor; - auto ctor = FindInterfaceConstructor(baseTd); - if (ctor == nullptr) - { - manager->errors.Add(WfErrors::WrongInterfaceBaseType(node, baseTd)); - } - } - } - - FOREACH(Ptr, memberDecl, node->declarations) - { - ValidateClassMemberSemantic(manager, td, node, memberDecl); - } - } - - void Visit(WfEnumDeclaration* node)override - { - FOREACH(Ptr, item, node->items) - { - Visit(item->attributes); - } - } - - void SearchForItself(WfStructDeclaration* node, ITypeDescriptor* target, ITypeDescriptor* current, List& path) - { - if (target == current) - { - manager->errors.Add(WfErrors::StructRecursivelyIncludeItself( - node, - From(path).Aggregate([](const WString& a, const WString& b) {return a + L"::" + b; }) - )); - return; - } - - if (current == nullptr) - { - current = target; - } - - vint count = current->GetPropertyCount(); - for (vint i = 0; i < count; i++) - { - auto prop = current->GetProperty(i); - auto propType = prop->GetReturn(); - auto propTd = prop->GetReturn()->GetTypeDescriptor(); - if (propType->GetDecorator()==ITypeInfo::TypeDescriptor && propTd->GetTypeDescriptorFlags() == TypeDescriptorFlags::Struct) - { - vint index = path.Add(prop->GetName()); - SearchForItself(node, target, propTd, path); - path.RemoveAt(index); - } - } - } - - void Visit(WfStructDeclaration* node)override - { - auto scope = manager->nodeScopes[node]; - auto td = manager->declarationTypes[node].Cast(); - FOREACH(Ptr, member, node->members) - { - auto memberTd = td->GetPropertyByName(member->name.value, false)->GetReturn()->GetTypeDescriptor(); - if ((memberTd->GetTypeDescriptorFlags() & TypeDescriptorFlags::ReferenceType) != TypeDescriptorFlags::Undefined) - { - manager->errors.Add(WfErrors::StructContainsNonValueType(member.Obj(), node)); - } - } - List path; - path.Add(td->GetTypeName()); - SearchForItself(node, td.Obj(), nullptr, path); - - FOREACH(Ptr, member, node->members) - { - Visit(member->attributes); - } - } - - void Visit(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - - static void Execute(Ptr declaration, WfLexicalScopeManager* manager) - { - ValidateSemanticDeclarationVisitor visitor(manager); - declaration->Accept(&visitor); - visitor.Visit(declaration->attributes); - } - }; - -/*********************************************************************** -ValidateSemantic(Statement) -***********************************************************************/ - - class ExpandVirtualStatementVisitor : public Object, public WfVirtualStatement::IVisitor - { - public: - WfLexicalScopeManager* manager; - - ExpandVirtualStatementVisitor(WfLexicalScopeManager* _manager) - :manager(_manager) - { - } - - void Visit(WfSwitchStatement* node)override - { - ExpandSwitchStatement(manager, node); - } - - void Visit(WfForEachStatement* node)override - { - ExpandForEachStatement(manager, node); - } - - void Visit(WfCoProviderStatement* node)override - { - ExpandCoProviderStatement(manager, node); - } - }; - - class ValidateSemanticStatementVisitor - : public Object - , public WfStatement::IVisitor - , public WfVirtualStatement::IVisitor - , public WfCoroutineStatement::IVisitor - { - public: - WfLexicalScopeManager* manager; - - ValidateSemanticStatementVisitor(WfLexicalScopeManager* _manager) - :manager(_manager) - { - } - - void Visit(WfBreakStatement* node)override - { - } - - void Visit(WfContinueStatement* node)override - { - } - - void Visit(WfReturnStatement* node)override - { - auto scope = manager->nodeScopes[node].Obj(); - auto functionScope = scope->FindFunctionScope(); - if (auto funcDecl = functionScope->ownerNode.Cast()) - { - auto providerStat = funcDecl->statement.Cast(); - if (providerStat && !providerStat->expandedStatement) - { - auto providerScope = manager->nodeScopes[funcDecl->statement.Obj()]; - auto providerSymbol = providerScope->symbols[L"$PROVIDER"][0]; - auto implSymbol = providerScope->symbols[L"$IMPL"][0]; - if (providerSymbol->typeInfo && implSymbol->typeInfo) - { - if (auto group = providerSymbol->typeInfo->GetTypeDescriptor()->GetMethodGroupByName(L"ReturnAndExit", true)) - { - List functions; - vint count = group->GetMethodCount(); - for (vint i = 0; i < count; i++) - { - auto method = group->GetMethod(i); - if (method->IsStatic()) - { - if (method->GetParameterCount() > 0 && IsSameType(implSymbol->typeInfo.Obj(), method->GetParameter(0)->GetType())) - { - functions.Add(ResolveExpressionResult::Method(method)); - } - } - } - - vint selectedFunctionIndex = -1; - List> arguments; - arguments.Add(nullptr); - if (node->expression) - { - arguments.Add(node->expression); - } - SelectFunction(manager, node, nullptr, functions, arguments, selectedFunctionIndex); - if (selectedFunctionIndex != -1) - { - manager->coOperatorResolvings.Add(node, functions[selectedFunctionIndex]); - } - } - else - { - manager->errors.Add(WfErrors::CoOperatorNotExists(node, providerSymbol->typeInfo.Obj())); - } - } - } - else - { - auto returnType = CreateTypeInfoFromType(scope, funcDecl->returnType); - if (node->expression) - { - if (returnType->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - manager->errors.Add(WfErrors::CannotReturnExpression(node)); - } - else - { - GetExpressionType(manager, node->expression, returnType); - } - } - else if (returnType->GetDecorator() != ITypeInfo::TypeDescriptor || returnType->GetTypeDescriptor() != description::GetTypeDescriptor()) - { - manager->errors.Add(WfErrors::ReturnMissExpression(node, returnType.Obj())); - } - } - } - else - { - if (node->expression) - { - manager->errors.Add(WfErrors::CannotReturnExpression(node)); - } - } - } - - void Visit(WfDeleteStatement* node)override - { - Ptr type = GetExpressionType(manager, node->expression, 0); - if (type) - { - if (type->GetDecorator() != ITypeInfo::RawPtr) - { - manager->errors.Add(WfErrors::DeleteNonRawPointer(node, type.Obj())); - } - } - } - - void Visit(WfRaiseExceptionStatement* node)override - { - if (node->expression) - { - if (auto type = GetExpressionType(manager, node->expression, nullptr)) - { - auto stringType = TypeInfoRetriver::CreateTypeInfo(); - auto exceptionType = TypeInfoRetriver>::CreateTypeInfo(); - if (!CanConvertToType(type.Obj(), stringType.Obj(), false) && !CanConvertToType(type.Obj(), exceptionType.Obj(), false)) - { - manager->errors.Add(WfErrors::ExpressionCannotImplicitlyConvertToType(node->expression.Obj(), type.Obj(), stringType.Obj())); - } - } - } - } - - void Visit(WfIfStatement* node)override - { - if (node->type) - { - auto scope = manager->nodeScopes[node].Obj(); - auto symbol = scope->symbols[node->name.value][0]; - if (!IsNullAcceptableType(symbol->typeInfo.Obj())) - { - manager->errors.Add(WfErrors::NullCannotImplicitlyConvertToType(node->expression.Obj(), symbol->typeInfo.Obj())); - } - GetExpressionType(manager, node->expression, nullptr); - } - else - { - Ptr boolType = TypeInfoRetriver::CreateTypeInfo(); - GetExpressionType(manager, node->expression, boolType); - } - ValidateStatementSemantic(manager, node->trueBranch); - if (node->falseBranch) - { - ValidateStatementSemantic(manager, node->falseBranch); - } - } - - void Visit(WfWhileStatement* node)override - { - Ptr boolType = TypeInfoRetriver::CreateTypeInfo(); - GetExpressionType(manager, node->condition, boolType); - ValidateStatementSemantic(manager, node->statement); - } - - void Visit(WfTryStatement* node)override - { - ValidateStatementSemantic(manager, node->protectedStatement); - if (node->catchStatement) - { - ValidateStatementSemantic(manager, node->catchStatement); - } - if (node->finallyStatement) - { - ValidateStatementSemantic(manager, node->finallyStatement); - } - } - - void Visit(WfBlockStatement* node)override - { - FOREACH(Ptr, statement, node->statements) - { - ValidateStatementSemantic(manager, statement); - } - } - - void Visit(WfExpressionStatement* node)override - { - GetExpressionType(manager, node->expression, 0); - } - - void Visit(WfVariableStatement* node)override - { - ValidateDeclarationSemantic(manager, node->variable); - } - - void Visit(WfVirtualStatement* node)override - { - bool expanded = node->expandedStatement; - vint errorCount = manager->errors.Count(); - node->Accept((WfVirtualStatement::IVisitor*)this); - - if (!expanded && manager->errors.Count() == errorCount) - { - ExpandVirtualStatementVisitor visitor(manager); - node->Accept(&visitor); - SetCodeRange(node->expandedStatement, node->codeRange); - - auto parentScope = manager->nodeScopes[node]; - if (parentScope->ownerNode == node) - { - parentScope = parentScope->parentScope; - } - - ContextFreeStatementDesugar(manager, node->expandedStatement); - BuildScopeForStatement(manager, parentScope, node->expandedStatement); - if (!CheckScopes_DuplicatedSymbol(manager) || !CheckScopes_SymbolType(manager)) - { - return; - } - } - - if (node->expandedStatement) - { - ValidateStatementSemantic(manager, node->expandedStatement); - } - } - - void Visit(WfSwitchStatement* node)override - { - Ptr type = GetExpressionType(manager, node->expression, 0); - FOREACH(Ptr, switchCase, node->caseBranches) - { - Ptr caseType; - if (IsExpressionDependOnExpectedType(manager, switchCase->expression)) - { - caseType = GetExpressionType(manager, switchCase->expression, type); - } - else - { - caseType = GetExpressionType(manager, switchCase->expression, 0); - } - - if (type && caseType) - { - if (!GetMergedType(type, caseType)) - { - manager->errors.Add(WfErrors::CannotMergeTwoType(switchCase->expression.Obj(), type.Obj(), caseType.Obj())); - } - } - ValidateStatementSemantic(manager, switchCase->statement); - } - if (node->defaultBranch) - { - ValidateStatementSemantic(manager, node->defaultBranch); - } - } - - void Visit(WfForEachStatement* node)override - { - Ptr elementType = GetEnumerableExpressionItemType(manager, node->collection, 0); - if (elementType) - { - auto scope = manager->nodeScopes[node].Obj(); - auto symbol = scope->symbols[node->name.value][0]; - symbol->typeInfo = elementType; - symbol->type = GetTypeFromTypeInfo(elementType.Obj()); - } - ValidateStatementSemantic(manager, node->statement); - } - - void Visit(WfCoProviderStatement* node)override - { - auto scope = manager->nodeScopes[node].Obj(); - auto providerSymbol = scope->symbols[L"$PROVIDER"][0]; - auto implSymbol = scope->symbols[L"$IMPL"][0]; - Ptr funcReturnType; - { - auto decl = scope->parentScope->ownerNode.Cast(); - funcReturnType = CreateTypeInfoFromType(scope->parentScope.Obj(), decl->returnType); - } - ITypeDescriptor* selectedProviderTd = nullptr; - List candidates; - - if (node->name.value == L"") - { - if (funcReturnType) - { - List unprocessed; - unprocessed.Add(funcReturnType->GetTypeDescriptor()); - - for (vint i = 0; i < unprocessed.Count(); i++) - { - auto td = unprocessed[i]; - auto candidate = td->GetTypeName() + L"Coroutine"; - if ((selectedProviderTd = description::GetTypeDescriptor(candidate))) - { - break; - } - else - { - candidates.Add(candidate); - } - - vint count = td->GetBaseTypeDescriptorCount(); - for (vint i = 0; i < count; i++) - { - auto baseTd = td->GetBaseTypeDescriptor(i); - if (!unprocessed.Contains(baseTd)) - { - unprocessed.Add(baseTd); - } - } - } - } - } - else - { - List results, resolveResults; - auto providerName = node->name.value.Right(node->name.value.Length() - 1); - - if (manager->ResolveName(scope, providerName, resolveResults)) - { - CopyFrom(results, resolveResults); - - for (vint i = results.Count() - 1; i >= 0; i--) - { - auto& result = results[i]; - ITypeDescriptor* providerTd = nullptr; - - if (result.scopeName && result.scopeName->typeDescriptor) - { - auto candidate = result.scopeName->typeDescriptor->GetTypeName() + L"Coroutine"; - providerTd = description::GetTypeDescriptor(candidate); - if (providerTd) - { - selectedProviderTd = providerTd; - } - else - { - candidates.Add(candidate); - } - } - - if (!providerTd) - { - results.RemoveAt(i); - } - } - - if (results.Count() == 1) - { - goto FINISH_SEARCHING; - } - else if (results.Count() > 1) - { - manager->errors.Add(WfErrors::TooManyTargets(node, resolveResults, providerName)); - goto SKIP_SEARCHING; - } - } - - resolveResults.Clear(); - if (manager->ResolveName(scope, providerName + L"Coroutine", resolveResults)) - { - CopyFrom(results, resolveResults); - - for (vint i = results.Count() - 1; i >= 0; i--) - { - auto& result = results[i]; - - if (result.scopeName && result.scopeName->typeDescriptor) - { - selectedProviderTd = result.scopeName->typeDescriptor; - } - else - { - results.RemoveAt(i); - } - } - - if (results.Count() == 1) - { - goto FINISH_SEARCHING; - } - else if (results.Count() > 1) - { - manager->errors.Add(WfErrors::TooManyTargets(node, resolveResults, providerName)); - goto SKIP_SEARCHING; - } - } - - candidates.Add(providerName); - candidates.Add(providerName + L"Coroutine"); - } - - FINISH_SEARCHING: - if (selectedProviderTd) - { - providerSymbol->typeInfo = MakePtr(selectedProviderTd, TypeInfoHint::Normal); - - if (funcReturnType) - { - WString creatorName; - if (funcReturnType->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - creatorName = L"CreateAndRun"; - } - else - { - creatorName = L"Create"; - } - - if (auto group = selectedProviderTd->GetMethodGroupByName(creatorName, true)) - { - List results; - ITypeInfo* selectedImplType = nullptr; - IMethodInfo* selectedCreator = nullptr; - vint count = group->GetMethodCount(); - - for (vint i = 0; i < count; i++) - { - auto method = group->GetMethod(i); - if (method->IsStatic()) - { - if (method->GetParameterCount() == 1) - { - auto creatorType = method->GetParameter(0)->GetType(); - if (creatorType->GetDecorator() == ITypeInfo::SharedPtr) - { - auto functionType = creatorType->GetElementType(); - if (functionType->GetDecorator() == ITypeInfo::Generic && - functionType->GetGenericArgumentCount() == 2 && - functionType->GetTypeDescriptor() == description::GetTypeDescriptor() - ) - { - auto returnType = functionType->GetGenericArgument(0); - if (returnType->GetDecorator() == ITypeInfo::SharedPtr &&returnType->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - selectedImplType = functionType->GetGenericArgument(1); - selectedCreator = method; - results.Add(ResolveExpressionResult::Method(method)); - } - } - } - } - } - } - - if (results.Count() == 1) - { - implSymbol->typeInfo = CopyTypeInfo(selectedImplType); - manager->coProviderResolvings.Add(node, ResolveExpressionResult::Method(selectedCreator)); - } - else if (results.Count() > 1) - { - manager->errors.Add(WfErrors::TooManyTargets(node, results, creatorName)); - } - } - - if (!implSymbol->typeInfo) - { - if (funcReturnType->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - manager->errors.Add(WfErrors::CoProviderCreateAndRunNotExists(node, providerSymbol->typeInfo.Obj())); - } - else - { - manager->errors.Add(WfErrors::CoProviderCreateNotExists(node, providerSymbol->typeInfo.Obj())); - } - } - } - } - else - { - manager->errors.Add(WfErrors::CoProviderNotExists(node, candidates)); - } - SKIP_SEARCHING: - ValidateStatementSemantic(manager, node->statement); - } - - void Visit(WfCoroutineStatement* node)override - { - node->Accept((WfCoroutineStatement::IVisitor*)this); - } - - void Visit(WfCoPauseStatement* node)override - { - if (node->statement) - { - ValidateStatementSemantic(manager, node->statement); - } - } - - void Visit(WfCoOperatorStatement* node)override - { - auto scope = manager->nodeScopes[node].Obj(); - auto functionScope = scope->FindFunctionScope(); - if (auto funcDecl = functionScope->ownerNode.Cast()) - { - if (funcDecl->statement.Cast()) - { - auto providerScope = manager->nodeScopes[funcDecl->statement.Obj()]; - auto providerSymbol = providerScope->symbols[L"$PROVIDER"][0]; - auto implSymbol = providerScope->symbols[L"$IMPL"][0]; - if (providerSymbol->typeInfo && implSymbol->typeInfo) - { - List groups; - auto operatorName = node->opName.value.Right(node->opName.value.Length() - 1); - if (auto group = providerSymbol->typeInfo->GetTypeDescriptor()->GetMethodGroupByName(operatorName + L"AndRead", true)) - { - groups.Add(group); - } - if (node->varName.value == L"") - { - if (auto group = providerSymbol->typeInfo->GetTypeDescriptor()->GetMethodGroupByName(operatorName + L"AndPause", true)) - { - groups.Add(group); - } - } - - if (groups.Count() == 0) - { - manager->errors.Add(WfErrors::CoOperatorNotExists(node, providerSymbol->typeInfo.Obj())); - } - else - { - List functions; - FOREACH(IMethodGroupInfo*, group, groups) - { - vint count = group->GetMethodCount(); - for (vint i = 0; i < count; i++) - { - auto method = group->GetMethod(i); - if (method->IsStatic()) - { - if (method->GetParameterCount() > 0 && IsSameType(implSymbol->typeInfo.Obj(), method->GetParameter(0)->GetType())) - { - functions.Add(ResolveExpressionResult::Method(method)); - } - } - } - } - - vint selectedFunctionIndex = -1; - vint oldErrorCount = manager->errors.Count(); - List> arguments; - arguments.Add(nullptr); - CopyFrom(arguments, node->arguments, true); - SelectFunction(manager, node, nullptr, functions, arguments, selectedFunctionIndex); - if (selectedFunctionIndex != -1) - { - manager->coOperatorResolvings.Add(node, functions[selectedFunctionIndex]); - if (node->varName.value != L"" && manager->errors.Count() == oldErrorCount) - { - auto symbol = scope->symbols[node->varName.value][0]; - List types; - - FOREACH(Ptr, argument, node->arguments) - { - vint index = manager->expressionResolvings.Keys().IndexOf(argument.Obj()); - if (index != -1) - { - auto type = manager->expressionResolvings.Values()[index].type; - if (!types.Contains(type.Obj())) - { - types.Add(type.Obj()); - if (auto group = type->GetTypeDescriptor()->GetMethodGroupByName(L"CastResult", true)) - { - vint count = group->GetMethodCount(); - for (vint i = 0; i < count; i++) - { - auto method = group->GetMethod(i); - if (method->IsStatic()) - { - if (method->GetParameterCount() == 1 && - method->GetParameter(0)->GetType()->GetTypeDescriptor() == description::GetTypeDescriptor() && - method->GetReturn()->GetTypeDescriptor() != description::GetTypeDescriptor() - ) - { - manager->coCastResultResolvings.Add(node, ResolveExpressionResult::Method(method)); - symbol->typeInfo = CopyTypeInfo(method->GetReturn()); - break; - } - } - } - } - } - } - } - - if (!symbol->typeInfo) - { - manager->errors.Add(WfErrors::CoOperatorCannotResolveResultType(node, types)); - } - } - } - } - } - } - } - } - - static void Execute(Ptr statement, WfLexicalScopeManager* manager) - { - ValidateSemanticStatementVisitor visitor(manager); - statement->Accept(&visitor); - } - }; - -/*********************************************************************** -ValidateSemantic(Expression) -***********************************************************************/ - - class ExpandVirtualExpressionVisitor : public Object, public WfVirtualExpression::IVisitor - { - public: - WfLexicalScopeManager* manager; - Ptr expectedType; - - ExpandVirtualExpressionVisitor(WfLexicalScopeManager* _manager, Ptr _expectedType) - :manager(_manager) - , expectedType(_expectedType) - { - } - - void Visit(WfBindExpression* node)override - { - ExpandBindExpression(manager, node); - } - - void Visit(WfFormatExpression* node)override - { - } - - void Visit(WfNewCoroutineExpression* node)override - { - ExpandNewCoroutineExpression(manager, node); - } - - void Visit(WfMixinCastExpression* node)override - { - ExpandMixinCastExpression(manager, node); - } - - void Visit(WfExpectedTypeCastExpression* node)override - { - auto castExpr = MakePtr(); - castExpr->strategy = node->strategy; - castExpr->expression = CopyExpression(node->expression); - castExpr->type = GetTypeFromTypeInfo(expectedType.Obj()); - node->expandedExpression = castExpr; - } - }; - - class ValidateSemanticExpressionVisitor - : public Object - , public WfExpression::IVisitor - , public WfVirtualExpression::IVisitor - { - public: - WfLexicalScopeManager* manager; - Ptr expectedType; - List& results; - - ValidateSemanticExpressionVisitor(WfLexicalScopeManager* _manager, Ptr _expectedType, List& _results) - :manager(_manager) - , expectedType(_expectedType) - , results(_results) - { - } - - void Visit(WfThisExpression* node)override - { - auto scope = manager->nodeScopes[node].Obj(); - Ptr lastConfig; - while (scope) - { - if (auto config = scope->functionConfig) - { - lastConfig = config; - if (!lastConfig->thisAccessable) - { - break; - } - } - - if (scope->typeOfThisExpr) - { - if (!lastConfig) - { - break; - } - - if (lastConfig->thisAccessable) - { - auto elementType = MakePtr(scope->typeOfThisExpr, TypeInfoHint::Normal); - auto pointerType = MakePtr(elementType); - - results.Add(ResolveExpressionResult::ReadonlyType(pointerType)); - return; - } - } - scope = scope->parentScope.Obj(); - } - manager->errors.Add(WfErrors::WrongThisExpression(node)); - } - - void Visit(WfTopQualifiedExpression* node)override - { - if (manager->globalName) - { - vint index = manager->globalName->children.Keys().IndexOf(node->name.value); - if (index != -1) - { - results.Add(ResolveExpressionResult::ScopeName(manager->globalName->children.Values()[index])); - return; - } - } - manager->errors.Add(WfErrors::TopQualifiedSymbolNotExists(node, node->name.value)); - } - - void ResolveName(WfExpression* node, const WString& name) - { - auto scope = manager->nodeScopes[node].Obj(); - List nameResults; - manager->ResolveName(scope, name, nameResults); - - for (vint i = 0; i < nameResults.Count(); i++) - { - auto& result = nameResults[i]; - if (result.symbol) - { - if (!result.type) - { - manager->errors.Add(WfErrors::ExpressionCannotResolveType(node, result.symbol)); - } - else if (!result.symbol->creatorNode.Cast() || result.symbol->creatorNode.Cast()) - { - bool readonlyCaptured = false; - if (!result.symbol->ownerScope->ownerNode.Cast() && !result.symbol->ownerScope->ownerNode.Cast()) - { - auto currentScope = scope; - WfLexicalScope* firstConfigScope = nullptr; - WfLexicalScope* lastConfigScope = nullptr; - while (currentScope) - { - if (currentScope->functionConfig) - { - if (!firstConfigScope) - { - firstConfigScope = currentScope; - } - lastConfigScope = currentScope; - } - - if (result.symbol->ownerScope == currentScope) - { - if (firstConfigScope && firstConfigScope->functionConfig->lambda) - { - readonlyCaptured = true; - } - - if (currentScope->ownerNode.Cast()) - { - if (firstConfigScope) - { - readonlyCaptured = firstConfigScope != lastConfigScope; - - if (!lastConfigScope->GetOwnerClassMember()) - { - manager->errors.Add(WfErrors::FieldCannotInitializeUsingEachOther(node, result)); - } - } - else - { - manager->errors.Add(WfErrors::FieldCannotInitializeUsingEachOther(node, result)); - } - } - break; - } - - if (currentScope->ownerNode.Cast()) - { - auto capture = manager->lambdaCaptures[currentScope->ownerNode.Obj()]; - if (!capture->ctorArgumentSymbols.Contains(result.symbol.Obj())) - { - if (lastConfigScope == nullptr) - { - capture->ctorArgumentSymbols.Add(result.symbol); - } - else - { - auto functionCapture = manager->lambdaCaptures[lastConfigScope->ownerNode.Obj()]; - if (capture != functionCapture) - { - capture->ctorArgumentSymbols.Add(result.symbol); - } - } - } - } - - if (currentScope->functionConfig) - { - if (currentScope->functionConfig->lambda) - { - auto capture = manager->lambdaCaptures[currentScope->ownerNode.Obj()]; - if (!capture->symbols.Contains(result.symbol.Obj())) - { - capture->symbols.Add(result.symbol); - } - } - } - currentScope = currentScope->parentScope.Obj(); - } - } - - if (readonlyCaptured) - { - results.Add(ResolveExpressionResult::ReadonlySymbol(result.symbol)); - } - else - { - results.Add(ResolveExpressionResult::Symbol(result.symbol)); - } - } - else - { - results.Add(result); - } - } - else - { - if (result.propertyInfo && dynamic_cast(node)) - { - auto currentScope = scope; - WfLexicalScope* firstConfigScope = nullptr; - WfLexicalScope* lastConfigScope = nullptr; - while (currentScope) - { - if (currentScope->functionConfig) - { - if (!firstConfigScope) - { - firstConfigScope = currentScope; - } - lastConfigScope = currentScope; - } - - if (currentScope->ownerNode.Cast() && currentScope->typeOfThisExpr == result.propertyInfo->GetOwnerTypeDescriptor()) - { - if (firstConfigScope) - { - bool inMethodBody = lastConfigScope->GetOwnerClassMember() && lastConfigScope->ownerNode.Cast(); - bool inDtorBody = lastConfigScope->GetOwnerClassMember() && lastConfigScope->ownerNode.Cast(); - bool inCtorBody = lastConfigScope->parentScope->GetOwnerClassMember() && lastConfigScope->parentScope->ownerNode.Cast(); - - if (!inMethodBody && !inDtorBody && !inCtorBody) - { - manager->errors.Add(WfErrors::FieldCannotInitializeUsingEachOther(node, result)); - } - } - else if (!scope->ownerNode.Cast()) - { - manager->errors.Add(WfErrors::FieldCannotInitializeUsingEachOther(node, result)); - } - } - currentScope = currentScope->parentScope.Obj(); - } - } - results.Add(result); - } - } - - if (results.Count() == 0) - { - if (nameResults.Count() > 0) - { - FOREACH(ResolveExpressionResult, result, nameResults) - { - manager->errors.Add(WfErrors::ExpressionCannotResolveType(node, result.symbol)); - } - } - else - { - manager->errors.Add(WfErrors::ReferenceNotExists(node, name)); - } - } - } - - void Visit(WfReferenceExpression* node)override - { - if (expectedType && (expectedType->GetTypeDescriptor()->GetTypeDescriptorFlags() & TypeDescriptorFlags::EnumType) != TypeDescriptorFlags::Undefined) - { - auto scope = manager->nodeScopes[node].Obj(); - List testResults; - manager->ResolveName(scope, node->name.value, testResults); - - if (testResults.Count() == 0) - { - auto enumType = expectedType->GetTypeDescriptor()->GetEnumType(); - if (enumType->IndexOfItem(node->name.value) == -1) - { - manager->errors.Add(WfErrors::EnumItemNotExists(node, expectedType->GetTypeDescriptor(), node->name.value)); - } - else - { - results.Add(ResolveExpressionResult::ReadonlyType(expectedType)); - } - return; - } - } - - ResolveName(node, node->name.value); - FOREACH(ResolveExpressionResult, result, results) - { - ITypeDescriptor* td = nullptr; - if (result.methodInfo) - { - td = result.methodInfo->GetOwnerTypeDescriptor(); - } - else if (result.propertyInfo) - { - td = result.propertyInfo->GetOwnerTypeDescriptor(); - } - else if (result.eventInfo) - { - td = result.eventInfo->GetOwnerTypeDescriptor(); - } - - if (td) - { - auto scope = manager->nodeScopes[node].Obj(); - bool visibleToNonStatic = false; - while (scope) - { - if (scope->functionConfig) - { - visibleToNonStatic = scope->functionConfig->thisAccessable || scope->functionConfig->parentThisAccessable; - } - - if (scope->typeOfThisExpr && scope->typeOfThisExpr->CanConvertTo(td)) - { - if (!visibleToNonStatic) - { - if (result.methodInfo) - { - if (!result.methodInfo->IsStatic()) - { - manager->errors.Add(WfErrors::CannotCallMemberInStaticFunction(node, result)); - } - } - else if (result.propertyInfo) - { - manager->errors.Add(WfErrors::CannotCallMemberInStaticFunction(node, result)); - } - else if (result.eventInfo) - { - manager->errors.Add(WfErrors::CannotCallMemberInStaticFunction(node, result)); - } - break; - } - } - scope = scope->parentScope.Obj(); - } - } - } - } - - void Visit(WfOrderedNameExpression* node)override - { - ResolveName(node, node->name.value); - } - - void Visit(WfOrderedLambdaExpression* node)override - { - auto scope = manager->nodeScopes[node].Obj(); - List> parameterSymbols; - CopyFrom( - parameterSymbols, - Range(0, scope->symbols.Count()) - .Select([scope](vint index)->Ptr{return scope->symbols.GetByIndex(index)[0];}) - .OrderBy([](Ptr a, Ptr b) - { - vint aId = wtoi(a->name.Sub(1, a->name.Length() - 1)); - vint bId = wtoi(b->name.Sub(1, a->name.Length() - 1)); - return aId - bId; - }) - ); - Ptr resultType = expectedType; - - if (!expectedType && parameterSymbols.Count() > 0) - { - manager->errors.Add(WfErrors::OrderedLambdaCannotResolveType(node)); - return; - } - else if (expectedType) - { - ITypeInfo* type = expectedType.Obj(); - if (type->GetDecorator() != ITypeInfo::SharedPtr) - { - goto ORDERED_FAILED; - } - type = type->GetElementType(); - if (type->GetDecorator() != ITypeInfo::Generic) - { - goto ORDERED_FAILED; - } - { - ITypeInfo* functionType = type->GetElementType(); - if (functionType->GetDecorator() != ITypeInfo::TypeDescriptor) - { - goto ORDERED_FAILED; - } - if (functionType->GetTypeDescriptor() != description::GetTypeDescriptor()) - { - goto ORDERED_FAILED; - } - } - - if (type->GetGenericArgumentCount() != parameterSymbols.Count() + 1) - { - goto ORDERED_FAILED; - } - - Ptr resultType = type->GetGenericArgument(0); - FOREACH_INDEXER(Ptr, symbol, index, parameterSymbols) - { - symbol->typeInfo = type->GetGenericArgument(index + 1); - symbol->type = GetTypeFromTypeInfo(symbol->typeInfo.Obj()); - } - GetExpressionType(manager, node->body, resultType); - } - else - { - auto bodyType = GetExpressionType(manager, node->body, 0); - if (bodyType) - { - auto funcType = MakePtr(description::GetTypeDescriptor(), TypeInfoHint::Normal); - auto genericType = MakePtr(funcType); - genericType->AddGenericArgument(bodyType); - - resultType = MakePtr(genericType); - } - } - - goto ORDERED_FINISHED; - ORDERED_FAILED: - manager->errors.Add(WfErrors::OrderedLambdaCannotImplicitlyConvertToType(node, expectedType.Obj())); - ORDERED_FINISHED: - if (resultType) - { - results.Add(ResolveExpressionResult::ReadonlyType(resultType)); - } - } - - void Visit(WfMemberExpression* node)override - { - Ptr type = GetExpressionType(manager, node->parent, 0); - if (type) - { - SortedList searchedTypes; - manager->ResolveMember(type->GetTypeDescriptor(), node->name.value, false, searchedTypes, results); - - if (results.Count() == 0) - { - manager->errors.Add(WfErrors::MemberNotExists(node, type->GetTypeDescriptor(), node->name.value)); - } - } - } - - void Visit(WfChildExpression* node)override - { - if (Ptr scopeName = GetExpressionScopeName(manager, node->parent)) - { - vint index = scopeName->children.Keys().IndexOf(node->name.value); - if (index != -1) - { - results.Add(ResolveExpressionResult::ScopeName(scopeName->children.Values()[index])); - return; - } - - if (scopeName->typeDescriptor) - { - SortedList searchedTypes; - manager->ResolveMember(scopeName->typeDescriptor, node->name.value, true, searchedTypes, results); - - if (results.Count() > 0) - { - FOREACH(ResolveExpressionResult, result, results) - { - if (result.methodInfo) - { - if (!result.methodInfo->IsStatic()) - { - manager->errors.Add(WfErrors::CannotCallMemberOutsideOfClass(node, result)); - } - } - else if (result.propertyInfo) - { - manager->errors.Add(WfErrors::CannotCallMemberOutsideOfClass(node, result)); - } - else if (result.eventInfo) - { - manager->errors.Add(WfErrors::CannotCallMemberOutsideOfClass(node, result)); - } - } - return; - } - } - - if (scopeName->typeDescriptor != nullptr && (scopeName->typeDescriptor->GetTypeDescriptorFlags() & TypeDescriptorFlags::EnumType) != TypeDescriptorFlags::Undefined) - { - manager->errors.Add(WfErrors::EnumItemNotExists(node, scopeName->typeDescriptor, node->name.value)); - } - else - { - manager->errors.Add(WfErrors::ChildSymbolNotExists(node, scopeName, node->name.value)); - } - } - } - - void Visit(WfLiteralExpression* node)override - { - if (node->value == WfLiteralValue::Null) - { - if (!expectedType) - { - manager->errors.Add(WfErrors::NullCannotResolveType(node)); - } - else if (!IsNullAcceptableType(expectedType.Obj())) - { - manager->errors.Add(WfErrors::NullCannotImplicitlyConvertToType(node, expectedType.Obj())); - } - - results.Add(ResolveExpressionResult::ReadonlyType(expectedType)); - } - else - { - results.Add(ResolveExpressionResult::ReadonlyType(TypeInfoRetriver::CreateTypeInfo())); - } - } - - void Visit(WfFloatingExpression* node)override - { - auto typeDescriptor = expectedType ? expectedType->GetTypeDescriptor() : nullptr; - if (!typeDescriptor || typeDescriptor->GetTypeDescriptorFlags() == TypeDescriptorFlags::Object || typeDescriptor == description::GetTypeDescriptor()) - { - typeDescriptor = description::GetTypeDescriptor(); - } - - if (auto serializableType = typeDescriptor->GetSerializableType()) - { - Value output; - if (serializableType->Deserialize(node->value.value, output)) - { - results.Add(ResolveExpressionResult::ReadonlyType(MakePtr(typeDescriptor, TypeInfoHint::Normal))); - return; - } - } - manager->errors.Add(WfErrors::FloatingLiteralOutOfRange(node)); - } - - void Visit(WfIntegerExpression* node)override - { - auto typeDescriptor = expectedType ? expectedType->GetTypeDescriptor() : nullptr; - if (!typeDescriptor || typeDescriptor->GetTypeDescriptorFlags() == TypeDescriptorFlags::Object || typeDescriptor==description::GetTypeDescriptor()) - { -#ifdef VCZH_64 - typeDescriptor = description::GetTypeDescriptor(); -#else - typeDescriptor = description::GetTypeDescriptor(); -#endif - } - - if (auto serializableType = typeDescriptor->GetSerializableType()) - { - Value output; - if (serializableType->Deserialize(node->value.value, output)) - { - results.Add(ResolveExpressionResult::ReadonlyType(MakePtr(typeDescriptor, TypeInfoHint::Normal))); - return; - } - } - manager->errors.Add(WfErrors::IntegerLiteralOutOfRange(node)); - } - - void Visit(WfStringExpression* node)override - { - results.Add(ResolveExpressionResult::ReadonlyType(TypeInfoRetriver::CreateTypeInfo())); - } - - void Visit(WfUnaryExpression* node)override - { - Ptr typeInfo = GetExpressionType(manager, node->operand, 0); - if (typeInfo) - { - TypeFlag flag = GetTypeFlag(typeInfo.Obj()); - switch (node->op) - { - case WfUnaryOperator::Not: - switch (flag) - { - case TypeFlag::F4: - case TypeFlag::F8: - case TypeFlag::String: - case TypeFlag::Enum: - case TypeFlag::Struct: - case TypeFlag::Others: - manager->errors.Add(WfErrors::UnaryOperatorOnWrongType(node, typeInfo.Obj())); - break; - default:; - } - break; - case WfUnaryOperator::Positive: - switch (flag) - { - case TypeFlag::Bool: - case TypeFlag::String: - case TypeFlag::Enum: - case TypeFlag::Struct: - case TypeFlag::Others: - manager->errors.Add(WfErrors::UnaryOperatorOnWrongType(node, typeInfo.Obj())); - break; - default:; - } - break; - case WfUnaryOperator::Negative: - switch (flag) - { - case TypeFlag::Bool: - case TypeFlag::U1: - case TypeFlag::U2: - case TypeFlag::U4: - case TypeFlag::U8: - case TypeFlag::String: - case TypeFlag::Enum: - case TypeFlag::Struct: - case TypeFlag::Others: - manager->errors.Add(WfErrors::UnaryOperatorOnWrongType(node, typeInfo.Obj())); - break; - default:; - } - break; - } - - results.Add(ResolveExpressionResult::ReadonlyType(typeInfo)); - } - } - - void Visit(WfBinaryExpression* node)override - { - if (node->op == WfBinaryOperator::Assign) - { - Ptr variableType = GetLeftValueExpressionType(manager, node->first); - GetExpressionType(manager, node->second, variableType); - if (variableType) - { - results.Add(ResolveExpressionResult::ReadonlyType(variableType)); - } - } - else if (node->op == WfBinaryOperator::Index) - { - Ptr containerType = GetExpressionType(manager, node->first, 0); - if (containerType) - { - if (containerType->GetDecorator() == ITypeInfo::SharedPtr) - { - ITypeInfo* genericType = containerType->GetElementType(); - Ptr indexType; - Ptr resultType; - bool leftValue = false; - - if (genericType->GetDecorator() == ITypeInfo::Generic) - { - ITypeInfo* classType = genericType->GetElementType(); - if (classType->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - indexType = TypeInfoRetriver::CreateTypeInfo(); - resultType = CopyTypeInfo(genericType->GetGenericArgument(0)); - } - else if (classType->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - indexType = TypeInfoRetriver::CreateTypeInfo(); - resultType = CopyTypeInfo(genericType->GetGenericArgument(0)); - leftValue = true; - } - else if (classType->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - indexType = TypeInfoRetriver::CreateTypeInfo(); - resultType = CopyTypeInfo(genericType->GetGenericArgument(0)); - leftValue = true; - } - else if (classType->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - indexType = CopyTypeInfo(genericType->GetGenericArgument(0)); - resultType = CopyTypeInfo(genericType->GetGenericArgument(1)); - } - else if (classType->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - indexType = CopyTypeInfo(genericType->GetGenericArgument(0)); - resultType = CopyTypeInfo(genericType->GetGenericArgument(1)); - leftValue = true; - } - else - { - manager->errors.Add(WfErrors::IndexOperatorOnWrongType(node, containerType.Obj())); - } - } - else - { - if (genericType->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - indexType = TypeInfoRetriver::CreateTypeInfo(); - resultType = TypeInfoRetriver::CreateTypeInfo(); - } - else if (genericType->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - indexType = TypeInfoRetriver::CreateTypeInfo(); - resultType = TypeInfoRetriver::CreateTypeInfo(); - leftValue = true; - } - else if (genericType->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - indexType = TypeInfoRetriver::CreateTypeInfo(); - resultType = TypeInfoRetriver::CreateTypeInfo(); - leftValue = true; - } - else if (genericType->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - indexType = TypeInfoRetriver::CreateTypeInfo(); - resultType = TypeInfoRetriver::CreateTypeInfo(); - } - else if (genericType->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - indexType = TypeInfoRetriver::CreateTypeInfo(); - resultType = TypeInfoRetriver::CreateTypeInfo(); - leftValue = true; - } - else - { - manager->errors.Add(WfErrors::IndexOperatorOnWrongType(node, containerType.Obj())); - } - } - - GetExpressionType(manager, node->second, indexType); - if (resultType) - { - if (leftValue) - { - results.Add(ResolveExpressionResult::WritableType(resultType)); - } - else - { - results.Add(ResolveExpressionResult::ReadonlyType(resultType)); - } - } - } - else - { - manager->errors.Add(WfErrors::IndexOperatorOnWrongType(node, containerType.Obj())); - } - } - } - else if (node->op == WfBinaryOperator::Union) - { - auto typeA = GetExpressionType(manager, node->first, expectedType); - auto typeB = GetExpressionType(manager, node->second, expectedType); - - if (typeA && typeB) - { - if (typeA->GetDecorator() == ITypeInfo::TypeDescriptor && typeB->GetDecorator() == ITypeInfo::TypeDescriptor) - { - auto stringType = TypeInfoRetriver::CreateTypeInfo(); - if (CanConvertToType(typeA.Obj(), stringType.Obj(), false) && CanConvertToType(typeB.Obj(), stringType.Obj(), false)) - { - results.Add(ResolveExpressionResult::ReadonlyType(stringType)); - return; - } - else if (auto type = GetMergedType(typeA, typeB)) - { - if (type->GetTypeDescriptor()->GetTypeDescriptorFlags() != TypeDescriptorFlags::FlagEnum) - { - manager->errors.Add(WfErrors::IncorrectTypeForUnion(node->first.Obj(), type.Obj())); - } - results.Add(ResolveExpressionResult::ReadonlyType(type)); - return; - } - } - manager->errors.Add(WfErrors::CannotMergeTwoType(node, typeA.Obj(), typeB.Obj())); - } - } - else if (node->op == WfBinaryOperator::Intersect) - { - auto typeA = GetExpressionType(manager, node->first, expectedType); - auto typeB = GetExpressionType(manager, node->second, expectedType); - - if (typeA && typeB) - { - if (typeA->GetDecorator() == ITypeInfo::TypeDescriptor && typeB->GetDecorator() == ITypeInfo::TypeDescriptor) - { - if (auto type = GetMergedType(typeA, typeB)) - { - if (type->GetTypeDescriptor()->GetTypeDescriptorFlags() != TypeDescriptorFlags::FlagEnum) - { - manager->errors.Add(WfErrors::IncorrectTypeForIntersect(node->first.Obj(), type.Obj())); - } - results.Add(ResolveExpressionResult::ReadonlyType(type)); - return; - } - } - manager->errors.Add(WfErrors::CannotMergeTwoType(node, typeA.Obj(), typeB.Obj())); - } - } - else if (node->op == WfBinaryOperator::FailedThen) - { - Ptr firstType = GetExpressionType(manager, node->first, 0); - bool depend = IsExpressionDependOnExpectedType(manager, node->second); - Ptr secondType = GetExpressionType(manager, node->second, (depend ? firstType : nullptr)); - - if (firstType && secondType) - { - auto mergedType = GetMergedType(firstType, secondType); - results.Add(ResolveExpressionResult::ReadonlyType(mergedType ? mergedType : firstType)); - } - } - else - { - Ptr firstType = GetExpressionType(manager, node->first, 0); - Ptr secondType = GetExpressionType(manager, node->second, 0); - Ptr elementType; - if (firstType && secondType) - { - if (!(elementType = GetMergedType(firstType, secondType))) - { - manager->errors.Add(WfErrors::CannotMergeTwoType(node, firstType.Obj(), secondType.Obj())); - } - } - - if (elementType) - { - TypeFlag flag = GetTypeFlag(elementType.Obj()); - TypeFlag* selectedTable = 0; - switch (node->op) - { - case WfBinaryOperator::Exp: - { - static TypeFlag conversionTable[(vint)TypeFlag::Count] = { - /*Bool */TypeFlag::Unknown, - /*I1 */TypeFlag::F4, - /*I2 */TypeFlag::F4, - /*I4 */TypeFlag::F8, - /*I8 */TypeFlag::F8, - /*U1 */TypeFlag::F4, - /*U2 */TypeFlag::F4, - /*U4 */TypeFlag::F8, - /*U8 */TypeFlag::F8, - /*F4 */TypeFlag::F4, - /*F8 */TypeFlag::F8, - /*String */TypeFlag::Unknown, - /*Enum */TypeFlag::Unknown, - /*Struct */TypeFlag::Unknown, - /*Others */TypeFlag::Unknown, - }; - selectedTable = conversionTable; - } - break; - case WfBinaryOperator::Add: - case WfBinaryOperator::Sub: - case WfBinaryOperator::Mul: - case WfBinaryOperator::Div: - { - static TypeFlag conversionTable[(vint)TypeFlag::Count] = { - /*Bool */TypeFlag::Unknown, - /*I1 */TypeFlag::I4, - /*I2 */TypeFlag::I4, - /*I4 */TypeFlag::I4, - /*I8 */TypeFlag::I8, - /*U1 */TypeFlag::U4, - /*U2 */TypeFlag::U4, - /*U4 */TypeFlag::U4, - /*U8 */TypeFlag::U8, - /*F4 */TypeFlag::F4, - /*F8 */TypeFlag::F8, - /*String */TypeFlag::Unknown, - /*Enum */TypeFlag::Unknown, - /*Struct */TypeFlag::Unknown, - /*Others */TypeFlag::Unknown, - }; - selectedTable = conversionTable; - } - break; - case WfBinaryOperator::Mod: - case WfBinaryOperator::Shl: - case WfBinaryOperator::Shr: - { - static TypeFlag conversionTable[(vint)TypeFlag::Count] = { - /*Bool */TypeFlag::Unknown, - /*I1 */TypeFlag::I4, - /*I2 */TypeFlag::I4, - /*I4 */TypeFlag::I4, - /*I8 */TypeFlag::I8, - /*U1 */TypeFlag::U4, - /*U2 */TypeFlag::U4, - /*U4 */TypeFlag::U4, - /*U8 */TypeFlag::U8, - /*F4 */TypeFlag::Unknown, - /*F8 */TypeFlag::Unknown, - /*String */TypeFlag::Unknown, - /*Enum */TypeFlag::Unknown, - /*Struct */TypeFlag::Unknown, - /*Others */TypeFlag::Unknown, - }; - selectedTable = conversionTable; - } - break; - case WfBinaryOperator::LT: - case WfBinaryOperator::GT: - case WfBinaryOperator::LE: - case WfBinaryOperator::GE: - { - static TypeFlag conversionTable[(vint)TypeFlag::Count] = { - /*Bool */TypeFlag::Unknown, - /*I1 */TypeFlag::Bool, - /*I2 */TypeFlag::Bool, - /*I4 */TypeFlag::Bool, - /*I8 */TypeFlag::Bool, - /*U1 */TypeFlag::Bool, - /*U2 */TypeFlag::Bool, - /*U4 */TypeFlag::Bool, - /*U8 */TypeFlag::Bool, - /*F4 */TypeFlag::Bool, - /*F8 */TypeFlag::Bool, - /*String */TypeFlag::Bool, - /*Enum */TypeFlag::Unknown, - /*Struct */TypeFlag::Unknown, - /*Others */TypeFlag::Unknown, - }; - selectedTable = conversionTable; - } - break; - case WfBinaryOperator::EQ: - case WfBinaryOperator::NE: - { - results.Add(ResolveExpressionResult::ReadonlyType(TypeInfoRetriver::CreateTypeInfo())); - return; - } - break; - case WfBinaryOperator::Xor: - case WfBinaryOperator::And: - case WfBinaryOperator::Or: - { - static TypeFlag conversionTable[(vint)TypeFlag::Count] = { - /*Bool */TypeFlag::Bool, - /*I1 */TypeFlag::I1, - /*I2 */TypeFlag::I2, - /*I4 */TypeFlag::I4, - /*I8 */TypeFlag::I8, - /*U1 */TypeFlag::U1, - /*U2 */TypeFlag::U2, - /*U4 */TypeFlag::U4, - /*U8 */TypeFlag::U8, - /*F4 */TypeFlag::Unknown, - /*F8 */TypeFlag::Unknown, - /*String */TypeFlag::Unknown, - /*Enum */TypeFlag::Unknown, - /*Struct */TypeFlag::Unknown, - /*Others */TypeFlag::Unknown, - }; - selectedTable = conversionTable; - } - break; - default:; - } - - TypeFlag resultFlag = selectedTable[(vint)flag]; - if (resultFlag == TypeFlag::Unknown) - { - manager->errors.Add(WfErrors::BinaryOperatorOnWrongType(node, elementType.Obj())); - } - else - { - results.Add(ResolveExpressionResult::ReadonlyType(CreateTypeInfoFromTypeFlag(resultFlag))); - } - } - } - } - - void Visit(WfLetExpression* node)override - { - auto scope = manager->nodeScopes[node].Obj(); - - FOREACH(Ptr, variable, node->variables) - { - auto symbol = scope->symbols[variable->name.value][0]; - symbol->typeInfo = GetExpressionType(manager, variable->value, 0); - if (symbol->typeInfo) - { - symbol->type = GetTypeFromTypeInfo(symbol->typeInfo.Obj()); - } - } - Ptr type = GetExpressionType(manager, node->expression, expectedType); - if (type) - { - results.Add(ResolveExpressionResult::ReadonlyType(type)); - } - } - - void Visit(WfIfExpression* node)override - { - Ptr boolType = TypeInfoRetriver::CreateTypeInfo(); - GetExpressionType(manager, node->condition, boolType); - - Ptr firstType, secondType; - - if (expectedType) - { - firstType = GetExpressionType(manager, node->trueBranch, expectedType); - secondType = GetExpressionType(manager, node->falseBranch, expectedType); - } - else - { - bool resolveFirst = !IsExpressionDependOnExpectedType(manager, node->trueBranch); - bool resolveSecond = !IsExpressionDependOnExpectedType(manager, node->falseBranch); - - if (resolveFirst == resolveSecond) - { - firstType = GetExpressionType(manager, node->trueBranch, 0); - secondType = GetExpressionType(manager, node->falseBranch, 0); - } - else if (resolveFirst) - { - firstType = GetExpressionType(manager, node->trueBranch, 0); - secondType = GetExpressionType(manager, node->falseBranch, firstType); - } - else if (resolveSecond) - { - secondType = GetExpressionType(manager, node->falseBranch, 0); - firstType = GetExpressionType(manager, node->trueBranch, secondType); - } - } - - if (firstType && !secondType) - { - results.Add(ResolveExpressionResult::ReadonlyType(firstType)); - } - else if (!firstType && secondType) - { - results.Add(ResolveExpressionResult::ReadonlyType(secondType)); - } - else if (firstType && secondType) - { - if (auto mergedType = GetMergedType(firstType, secondType)) - { - results.Add(ResolveExpressionResult::ReadonlyType(mergedType)); - } - else - { - manager->errors.Add(WfErrors::CannotMergeTwoType(node, firstType.Obj(), secondType.Obj())); - } - } - } - - void Visit(WfRangeExpression* node)override - { - Ptr firstType = GetExpressionType(manager, node->begin, 0); - Ptr secondType = GetExpressionType(manager, node->end, 0); - Ptr elementType; - - if (firstType && !secondType) - { - elementType = firstType; - } - else if (!firstType && secondType) - { - elementType = secondType; - } - else if (firstType && secondType) - { - if (!(elementType = GetMergedType(firstType, secondType))) - { - manager->errors.Add(WfErrors::CannotMergeTwoType(node, firstType.Obj(), secondType.Obj())); - } - } - - if (elementType) - { - TypeFlag flag = GetTypeFlag(elementType.Obj()); - switch (flag) - { - case TypeFlag::I1: - case TypeFlag::I2: - case TypeFlag::I4: - case TypeFlag::I8: - case TypeFlag::U1: - case TypeFlag::U2: - case TypeFlag::U4: - case TypeFlag::U8: - break; - default: - manager->errors.Add(WfErrors::RangeShouldBeInteger(node, elementType.Obj())); - } - - auto enumerableType = MakePtr(description::GetTypeDescriptor(), TypeInfoHint::Normal); - auto genericType = MakePtr(enumerableType); - genericType->AddGenericArgument(elementType); - - auto pointerType = MakePtr(genericType); - results.Add(ResolveExpressionResult::ReadonlyType(pointerType)); - } - } - - void Visit(WfSetTestingExpression* node)override - { - Ptr elementType = GetExpressionType(manager, node->element, 0); - - if (auto range = node->collection.Cast()) - { - Ptr beginType = GetExpressionType(manager, range->begin, 0); - Ptr endType = GetExpressionType(manager, range->end, 0); - - if (elementType && beginType) - { - if (!GetMergedType(elementType, beginType)) - { - manager->errors.Add(WfErrors::CannotMergeTwoType(node, elementType.Obj(), beginType.Obj())); - } - } - if (elementType && endType) - { - if (!GetMergedType(elementType, endType)) - { - manager->errors.Add(WfErrors::CannotMergeTwoType(node, elementType.Obj(), endType.Obj())); - } - } - } - else - { - Ptr itemType = GetEnumerableExpressionItemType(manager, node->collection, 0); - if (elementType && itemType) - { - if (!GetMergedType(elementType, itemType)) - { - manager->errors.Add(WfErrors::CannotMergeTwoType(node, elementType.Obj(), itemType.Obj())); - } - } - } - - results.Add(ResolveExpressionResult::ReadonlyType(TypeInfoRetriver::CreateTypeInfo())); - } - - void Visit(WfConstructorExpression* node)override - { - if (expectedType && expectedType->GetTypeDescriptor()->GetTypeDescriptorFlags() == TypeDescriptorFlags::Struct) - { - SortedList fields; - FOREACH(Ptr, argument, node->arguments) - { - if (!argument->value) - { - manager->errors.Add(WfErrors::ConstructorMixStructAndList(node)); - return; - } - else if (auto field = argument->key.Cast()) - { - if (auto prop = expectedType->GetTypeDescriptor()->GetPropertyByName(field->name.value, true)) - { - if (fields.Contains(field->name.value)) - { - manager->errors.Add(WfErrors::DuplicatedConstructorField(field.Obj())); - } - else - { - fields.Add(field->name.value); - } - GetExpressionType(manager, argument->value, CopyTypeInfo(prop->GetReturn())); - } - else - { - manager->errors.Add(WfErrors::MemberNotExists(field.Obj(), expectedType->GetTypeDescriptor(), field->name.value)); - } - } - else - { - manager->errors.Add(WfErrors::ConstructorMixStructAndList(argument->value.Obj())); - } - } - results.Add(ResolveExpressionResult::ReadonlyType(expectedType)); - } - else if (node->arguments.Count() == 0) - { - if (expectedType) - { - ITypeDescriptor* td = expectedType->GetTypeDescriptor(); - if (!td->CanConvertTo(description::GetTypeDescriptor()) && !td->CanConvertTo(description::GetTypeDescriptor())) - { - manager->errors.Add(WfErrors::ConstructorCannotImplicitlyConvertToType(node, expectedType.Obj())); - } - results.Add(ResolveExpressionResult::ReadonlyType(expectedType)); - } - else - { - manager->errors.Add(WfErrors::ConstructorCannotResolveType(node)); - } - } - else - { - ITypeInfo* expectedKeyType = nullptr; - ITypeInfo* expectedValueType = nullptr; - if (expectedType) - { - if (expectedType->GetDecorator() == ITypeInfo::SharedPtr) - { - auto genericType = expectedType->GetElementType(); - if (genericType->GetDecorator() == ITypeInfo::Generic) - { - if (genericType->GetTypeDescriptor() == description::GetTypeDescriptor() - || genericType->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - if (genericType->GetGenericArgumentCount() == 2) - { - expectedKeyType = genericType->GetGenericArgument(0); - expectedValueType = genericType->GetGenericArgument(1); - } - } - else if (genericType->GetTypeDescriptor() == description::GetTypeDescriptor() - || genericType->GetTypeDescriptor() == description::GetTypeDescriptor() - || genericType->GetTypeDescriptor() == description::GetTypeDescriptor() - || genericType->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - if (genericType->GetGenericArgumentCount() == 1) - { - expectedKeyType = genericType->GetGenericArgument(0); - } - } - } - } - } - - bool map = node->arguments[0]->value; - Ptr keyType, valueType; - FOREACH(Ptr, argument, node->arguments) - { - { - Ptr newKeyType = GetExpressionType(manager, argument->key, expectedKeyType); - if (!keyType) - { - keyType = newKeyType; - } - else if (auto mergedType = GetMergedType(keyType, newKeyType)) - { - keyType = mergedType; - } - else - { - manager->errors.Add(WfErrors::CannotMergeTwoType(node, keyType.Obj(), newKeyType.Obj())); - } - } - if (map) - { - Ptr newValueType = GetExpressionType(manager, argument->value, expectedValueType); - if (!valueType) - { - valueType = newValueType; - } - else if (auto mergedType = GetMergedType(valueType, newValueType)) - { - valueType = mergedType; - } - else - { - manager->errors.Add(WfErrors::CannotMergeTwoType(node, valueType.Obj(), newValueType.Obj())); - } - } - } - - if (map) - { - if (keyType && valueType) - { - auto classType = MakePtr(description::GetTypeDescriptor(), TypeInfoHint::Normal); - auto genericType = MakePtr(classType); - genericType->AddGenericArgument(keyType); - genericType->AddGenericArgument(valueType); - - auto pointerType = MakePtr(genericType); - results.Add(ResolveExpressionResult::ReadonlyType(pointerType)); - } - } - else - { - if (keyType) - { - Ptr classType; - if (expectedType && expectedType->GetTypeDescriptor()==description::GetTypeDescriptor()) - { - classType = MakePtr(description::GetTypeDescriptor(), TypeInfoHint::Normal); - } - else - { - classType = MakePtr(description::GetTypeDescriptor(), TypeInfoHint::Normal); - } - auto genericType = MakePtr(classType); - genericType->AddGenericArgument(keyType); - - auto pointerType = MakePtr(genericType); - results.Add(ResolveExpressionResult::ReadonlyType(pointerType)); - } - } - } - } - - void Visit(WfInferExpression* node)override - { - auto scope = manager->nodeScopes[node].Obj(); - Ptr type = CreateTypeInfoFromType(scope, node->type); - Ptr expressionType = GetExpressionType(manager, node->expression, type); - if (expressionType) - { - results.Add(ResolveExpressionResult::ReadonlyType(type)); - } - } - - void Visit(WfTypeCastingExpression* node)override - { - auto scope = manager->nodeScopes[node].Obj(); - if (auto type = CreateTypeInfoFromType(scope, node->type)) - { - if (auto expressionType = GetExpressionType(manager, node->expression, 0)) - { - if (!CanConvertToType(expressionType.Obj(), type.Obj(), true)) - { - manager->errors.Add(WfErrors::ExpressionCannotExplicitlyConvertToType(node->expression.Obj(), expressionType.Obj(), type.Obj())); - } - } - if (node->strategy == WfTypeCastingStrategy::Weak) - { - switch (type->GetDecorator()) - { - case ITypeInfo::RawPtr: - case ITypeInfo::SharedPtr: - case ITypeInfo::Nullable: - break; - default: - manager->errors.Add(WfErrors::CannotWeakCastToType(node->expression.Obj(), type.Obj())); - } - } - results.Add(ResolveExpressionResult::ReadonlyType(type)); - } - } - - void Visit(WfTypeTestingExpression* node)override - { - Ptr type = GetExpressionType(manager, node->expression, 0); - if (type) - { - switch (node->test) - { - case WfTypeTesting::IsNull: - case WfTypeTesting::IsNotNull: - if (!IsNullAcceptableType(type.Obj())) - { - manager->errors.Add(WfErrors::NullCannotImplicitlyConvertToType(node->expression.Obj(), type.Obj())); - } - break; - default:; - } - } - results.Add(ResolveExpressionResult::ReadonlyType(TypeInfoRetriver::CreateTypeInfo())); - } - - void Visit(WfTypeOfTypeExpression* node)override - { - results.Add(ResolveExpressionResult::ReadonlyType(TypeInfoRetriver::CreateTypeInfo())); - } - - void Visit(WfTypeOfExpressionExpression* node)override - { - GetExpressionType(manager, node->expression, 0); - results.Add(ResolveExpressionResult::ReadonlyType(TypeInfoRetriver::CreateTypeInfo())); - } - - void Visit(WfAttachEventExpression* node)override - { - IEventInfo* eventInfo = GetExpressionEventInfo(manager, node->event); - Ptr functionType; - if (eventInfo) - { - functionType = CopyTypeInfo(eventInfo->GetHandlerType()); - } - GetExpressionType(manager, node->function, functionType); - results.Add(ResolveExpressionResult::ReadonlyType(TypeInfoRetriver>::CreateTypeInfo())); - } - - void Visit(WfDetachEventExpression* node)override - { - GetExpressionEventInfo(manager, node->event); - Ptr pointerType = TypeInfoRetriver>::CreateTypeInfo(); - GetExpressionType(manager, node->handler, pointerType); - results.Add(ResolveExpressionResult::ReadonlyType(TypeInfoRetriver::CreateTypeInfo())); - } - - void Visit(WfObserveExpression* node)override - { - Ptr parentType = GetExpressionType(manager, node->parent, 0); - Ptr observeeType; - if (parentType) - { - if (node->observeType == WfObserveType::SimpleObserve) - { - ITypeDescriptor* td = parentType->GetTypeDescriptor(); - IPropertyInfo* propertyInfo = 0; - { - auto ref = node->expression.Cast(); - propertyInfo = td->GetPropertyByName(ref->name.value, true); - if (propertyInfo) - { - observeeType = CopyTypeInfo(propertyInfo->GetReturn()); - } - else - { - manager->errors.Add(WfErrors::MemberNotExists(ref.Obj(), td, ref->name.value)); - } - } - - if (node->events.Count() == 0) - { - if (propertyInfo) - { - IEventInfo* eventInfo = propertyInfo->GetValueChangedEvent(); - if (!eventInfo) - { - eventInfo = td->GetEventByName(propertyInfo->GetName() + L"Changed", true); - } - if (!eventInfo) - { - manager->errors.Add(WfErrors::MemberNotExists(node->expression.Obj(), td, propertyInfo->GetName() + L"Changed")); - } - } - } - else - { - FOREACH(Ptr, eventExpr, node->events) - { - auto ref = eventExpr.Cast(); - IEventInfo* info = td->GetEventByName(ref->name.value, true); - if (!info) - { - manager->errors.Add(WfErrors::MemberNotExists(ref.Obj(), td, ref->name.value)); - } - } - } - } - else - { - auto scope = manager->nodeScopes[node].Obj(); - auto symbol = scope->symbols[node->name.value][0]; - symbol->typeInfo = parentType; - symbol->type = GetTypeFromTypeInfo(parentType.Obj()); - - observeeType = GetExpressionType(manager, node->expression, 0); - FOREACH(Ptr, eventExpr, node->events) - { - GetExpressionEventInfo(manager, eventExpr); - } - } - } - - if (observeeType) - { - results.Add(ResolveExpressionResult::ReadonlyType(observeeType)); - } - } - - void Visit(WfCallExpression* node)override - { - List functions; - GetExpressionTypes(manager, node->function, nullptr, true, functions); - - vint selectedFunctionIndex = -1; - Ptr resultType = SelectFunction(manager, node, node->function, functions, node->arguments, selectedFunctionIndex); - if (resultType) - { - manager->expressionResolvings.Add(node->function, functions[selectedFunctionIndex]); - results.Add(ResolveExpressionResult::ReadonlyType(resultType)); - } - } - - void Visit(WfFunctionExpression* node)override - { - ValidateDeclarationSemantic(manager, node->function); - auto scope = manager->nodeScopes[node->function.Obj()].Obj(); - - auto classType = MakePtr(description::GetTypeDescriptor(), TypeInfoHint::Normal); - auto genericType = MakePtr(classType); - genericType->AddGenericArgument(CreateTypeInfoFromType(scope, node->function->returnType)); - FOREACH(Ptr, argument, node->function->arguments) - { - genericType->AddGenericArgument(scope->symbols[argument->name.value][0]->typeInfo); - } - - auto pointerType = MakePtr(genericType); - results.Add(ResolveExpressionResult::ReadonlyType(pointerType)); - } - - Ptr GetFunctionDeclarationType(WfLexicalScope* scope, Ptr decl) - { - Ptr symbol = From(manager->nodeScopes[decl.Obj()]->parentScope->symbols[decl->name.value]) - .Where([decl](Ptr symbol) - { - return symbol->creatorNode == decl; - }) - .First(); - return symbol->typeInfo; - } - - class NewInterfaceExpressionVisitor : public empty_visitor::DeclarationVisitor - { - public: - WfLexicalScopeManager* manager; - List> overrideFunctions; - List> variableSymbols; - WfFunctionDeclaration* lastFunction = nullptr; - - NewInterfaceExpressionVisitor(WfLexicalScopeManager* _manager) - :manager(_manager) - { - } - - void Dispatch(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - - void Visit(WfFunctionDeclaration* node)override - { - lastFunction = node; - if (node->classMember->kind == WfClassMemberKind::Override) - { - overrideFunctions.Add(node); - } - } - - void Visit(WfVariableDeclaration* node)override - { - variableSymbols.Add( - From(manager->nodeScopes[node]->symbols[node->name.value]) - .Where([=](Ptr symbol) - { - return symbol->creatorNode == node; - }) - .First() - ); - } - - void Execute(WfNewInterfaceExpression* node) - { - FOREACH(Ptr, memberDecl, node->declarations) - { - memberDecl->Accept(this); - ValidateDeclarationSemantic(manager, memberDecl); - } - } - }; - - void Visit(WfNewClassExpression* node)override - { - auto scope = manager->nodeScopes[node].Obj(); - Ptr type = CreateTypeInfoFromType(scope, node->type); - if (type) - { - ITypeDescriptor* td = type->GetTypeDescriptor(); - IMethodGroupInfo* ctors = td->GetConstructorGroup(); - Ptr selectedType; - IMethodInfo* selectedConstructor = nullptr; - - if (!ctors || ctors->GetMethodCount() == 0) - { - manager->errors.Add(WfErrors::ClassContainsNoConstructor(node, type.Obj())); - } - else - { - if ((td->GetTypeDescriptorFlags() & TypeDescriptorFlags::ClassType) != TypeDescriptorFlags::Undefined) - { - List functions; - for (vint i = 0; i < ctors->GetMethodCount(); i++) - { - IMethodInfo* info = ctors->GetMethod(i); - functions.Add(ResolveExpressionResult::Method(info)); - } - - vint selectedFunctionIndex = -1; - selectedType = SelectFunction(manager, node, nullptr, functions, node->arguments, selectedFunctionIndex); - if (selectedType) - { - selectedConstructor = functions[selectedFunctionIndex].methodInfo; - } - } - else if ((td->GetTypeDescriptorFlags() & TypeDescriptorFlags::InterfaceType) != TypeDescriptorFlags::Undefined) - { - manager->errors.Add(WfErrors::ConstructorMixClassAndInterface(node)); - } - else - { - manager->errors.Add(WfErrors::ClassContainsNoConstructor(node, type.Obj())); - } - } - - if (selectedType) - { - auto result = ResolveExpressionResult::Constructor(selectedConstructor); - if (!IsSameType(selectedType.Obj(), type.Obj())) - { - manager->errors.Add(WfErrors::ConstructorReturnTypeMismatched(node, result, selectedType.Obj(), type.Obj())); - } - results.Add(result); - } - } - } - - void Visit(WfNewInterfaceExpression* node)override - { - auto scope = manager->nodeScopes[node].Obj(); - Ptr type = CreateTypeInfoFromType(scope, node->type); - if (type) - { - ITypeDescriptor* td = type->GetTypeDescriptor(); - IMethodGroupInfo* ctors = td->GetConstructorGroup(); - Ptr selectedType; - IMethodInfo* selectedConstructor = nullptr; - - scope->typeOfThisExpr = td; - - if (!ctors || ctors->GetMethodCount() == 0) - { - manager->errors.Add(WfErrors::ClassContainsNoConstructor(node, type.Obj())); - } - else - { - if ((td->GetTypeDescriptorFlags() & TypeDescriptorFlags::ClassType) != TypeDescriptorFlags::Undefined) - { - manager->errors.Add(WfErrors::ConstructorMixClassAndInterface(node)); - } - else if ((td->GetTypeDescriptorFlags() & TypeDescriptorFlags::InterfaceType) != TypeDescriptorFlags::Undefined) - { - if (auto info = FindInterfaceConstructor(td)) - { - selectedType = CopyTypeInfo(info->GetReturn()); - selectedConstructor = info; - } - else - { - manager->errors.Add(WfErrors::InterfaceContainsNoConstructor(node, type.Obj())); - } - - Group interfaceMethods; - Group> implementMethods; - - { - NewInterfaceExpressionVisitor declVisitor(manager); - declVisitor.Execute(node); - - if (declVisitor.lastFunction) - { - FOREACH(Ptr, func, declVisitor.overrideFunctions) - { - implementMethods.Add(func->name.value, func); - } - - auto capture = manager->lambdaCaptures[declVisitor.lastFunction]; - List> readonlySymbols; - CopyFrom(readonlySymbols, From(capture->symbols).Except(declVisitor.variableSymbols)); - CopyFrom(capture->symbols, declVisitor.variableSymbols); - CopyFrom(capture->symbols, readonlySymbols, true); - } - } - { - SortedList searchedTypes; - List types; - types.Add(td); - vint begin = 0; - - while (begin < types.Count()) - { - ITypeDescriptor* currentType = types[begin++]; - if (searchedTypes.Contains(currentType)) - { - continue; - } - searchedTypes.Add(currentType); - - vint count = currentType->GetBaseTypeDescriptorCount(); - for (vint i = 0; i < count; i++) - { - types.Add(currentType->GetBaseTypeDescriptor(i)); - } - - count = currentType->GetMethodGroupCount(); - for (vint i = 0; i < count; i++) - { - IMethodGroupInfo* group = currentType->GetMethodGroup(i); - vint methodCount = group->GetMethodCount(); - for (vint j = 0; j < methodCount; j++) - { - auto method = group->GetMethod(j); - if (!method->IsStatic()) - { - interfaceMethods.Add(group->GetName(), method); - } - } - } - } - } - - auto discardFirst = [=](const WString& key, const List& methods) - { - FOREACH(IMethodInfo*, method, methods) - { - manager->errors.Add(WfErrors::InterfaceMethodNotImplemented(node, method)); - } - }; - auto discardSecond = [=](const WString& key, const List>& methods) - { - FOREACH(Ptr, decl, methods) - { - Ptr declType = GetFunctionDeclarationType(scope, decl); - manager->errors.Add(WfErrors::InterfaceMethodNotFound(decl.Obj(), type.Obj(), declType.Obj())); - } - }; - - GroupInnerJoin( - interfaceMethods, - implementMethods, - discardFirst, - discardSecond, - [=](const WString& key, const List& interfaces, const List>& implements) - { - Group typedInterfaceMethods; - Group> typedImplementMethods; - - FOREACH(IMethodInfo*, method, interfaces) - { - Ptr methodType = CreateTypeInfoFromMethodInfo(method); - typedInterfaceMethods.Add(methodType->GetTypeFriendlyName(), method); - } - - FOREACH(Ptr, decl, implements) - { - Ptr methodType = GetFunctionDeclarationType(scope, decl); - typedImplementMethods.Add(methodType->GetTypeFriendlyName(), decl); - } - - GroupInnerJoin( - typedInterfaceMethods, - typedImplementMethods, - discardFirst, - discardSecond, - [=](const WString& key, const List& interfaces, const List>& implements) - { - if (interfaces.Count() > 1) - { - List functions; - FOREACH(IMethodInfo*, method, interfaces) - { - functions.Add(ResolveExpressionResult::Constructor(method)); - manager->errors.Add(WfErrors::CannotPickOverloadedInterfaceMethods(node, functions)); - } - } - if (implements.Count() > 1) - { - auto decl = implements[0]; - Ptr methodType = GetFunctionDeclarationType(scope, decl); - manager->errors.Add(WfErrors::CannotPickOverloadedImplementMethods(decl.Obj(), methodType.Obj())); - } - - if (interfaces.Count() == 1 && implements.Count() == 1) - { - manager->interfaceMethodImpls.Add(implements[0].Obj(), interfaces[0]); - } - }); - }); - } - else - { - manager->errors.Add(WfErrors::ClassContainsNoConstructor(node, type.Obj())); - } - } - - if (selectedType) - { - auto result = ResolveExpressionResult::Constructor(selectedConstructor); - if (!IsSameType(selectedType.Obj(), type.Obj())) - { - manager->errors.Add(WfErrors::ConstructorReturnTypeMismatched(node, result, selectedType.Obj(), type.Obj())); - } - results.Add(result); - } - } - } - - void Visit(WfVirtualExpression* node)override - { - bool expanded = node->expandedExpression; - vint errorCount = manager->errors.Count(); - node->Accept((WfVirtualExpression::IVisitor*)this); - - if (!expanded && manager->errors.Count() == errorCount) - { - ExpandVirtualExpressionVisitor visitor(manager, expectedType); - node->Accept(&visitor); - SetCodeRange(node->expandedExpression, node->codeRange); - - auto parentScope = manager->nodeScopes[node]; - if (parentScope->ownerNode == node) - { - parentScope = parentScope->parentScope; - } - - ContextFreeExpressionDesugar(manager, node->expandedExpression); - BuildScopeForExpression(manager, parentScope, node->expandedExpression); - if (!CheckScopes_DuplicatedSymbol(manager) || !CheckScopes_SymbolType(manager)) - { - return; - } - } - - if (node->expandedExpression) - { - if (results.Count() == 1) - { - GetExpressionType(manager, node->expandedExpression, results[0].type); - } - else - { - GetExpressionType(manager, node->expandedExpression, nullptr); - } - } - } - - void Visit(WfBindExpression* node)override - { - GetExpressionType(manager, node->expression, 0); - results.Add(ResolveExpressionResult::ReadonlyType(TypeInfoRetriver>::CreateTypeInfo())); - } - - void Visit(WfFormatExpression* node)override - { - Ptr typeInfo = TypeInfoRetriver::CreateTypeInfo(); - results.Add(ResolveExpressionResult::ReadonlyType(typeInfo)); - } - - void Visit(WfNewCoroutineExpression* node)override - { - Ptr typeInfo = TypeInfoRetriver>::CreateTypeInfo(); - results.Add(ResolveExpressionResult::ReadonlyType(typeInfo)); - ValidateStatementSemantic(manager, node->statement); - } - - void Visit(WfMixinCastExpression* node)override - { - auto scope = manager->nodeScopes[node].Obj(); - auto type = CreateTypeInfoFromType(scope, node->type); - auto expressionType = GetExpressionType(manager, node->expression, 0); - if (type && expressionType) - { - results.Add(ResolveExpressionResult::ReadonlyType(type)); - if (expressionType) - { - auto fromTd = expressionType->GetTypeDescriptor(); - auto toTd = type->GetTypeDescriptor(); - if ((fromTd->GetTypeDescriptorFlags() & TypeDescriptorFlags::InterfaceType) != TypeDescriptorFlags::Undefined) - { - if ((toTd->GetTypeDescriptorFlags() & TypeDescriptorFlags::InterfaceType) != TypeDescriptorFlags::Undefined) - { - if (fromTd != toTd && toTd->CanConvertTo(fromTd)) - { - goto PASS_VALIDATION; - } - } - } - manager->errors.Add(WfErrors::WrongMixinTargetType(node, expressionType.Obj(), type.Obj())); - PASS_VALIDATION:; - } - } - } - - void Visit(WfExpectedTypeCastExpression* node)override - { - GetExpressionType(manager, node->expression, nullptr); - if (expectedType) - { - results.Add(ResolveExpressionResult::ReadonlyType(expectedType)); - } - else - { - manager->errors.Add(WfErrors::ExpectedTypeCastCannotResolveType(node)); - } - } - - static void Execute(Ptr expression, WfLexicalScopeManager* manager, Ptr expectedType, List& results) - { - ValidateSemanticExpressionVisitor visitor(manager, expectedType, results); - expression->Accept(&visitor); - } - }; - -/*********************************************************************** -IsConstantExpression -***********************************************************************/ - - class ValidateConstantExpressionVisitor - : public Object - , public WfExpression::IVisitor - { - public: - WfLexicalScopeManager* manager; - bool isConstant = false; - - ValidateConstantExpressionVisitor(WfLexicalScopeManager* _manager) - :manager(_manager) - { - } - - bool Call(Ptr node) - { - bool cache = isConstant; - isConstant = false; - node->Accept(this); - bool result = isConstant; - isConstant = cache; - return result; - } - - void VisitReferenceExpression(WfExpression* node, const WString& name) - { - auto result = manager->expressionResolvings[node]; - if (auto enumType = result.type->GetTypeDescriptor()->GetEnumType()) - { - vint index = enumType->IndexOfItem(name); - if (index != -1) - { - isConstant = true; - } - } - } - - void Visit(WfThisExpression* node)override - { - } - - void Visit(WfTopQualifiedExpression* node)override - { - } - - void Visit(WfReferenceExpression* node)override - { - VisitReferenceExpression(node, node->name.value); - } - - void Visit(WfOrderedNameExpression* node)override - { - } - - void Visit(WfOrderedLambdaExpression* node)override - { - } - - void Visit(WfMemberExpression* node)override - { - } - - void Visit(WfChildExpression* node)override - { - VisitReferenceExpression(node, node->name.value); - } - - void Visit(WfLiteralExpression* node)override - { - isConstant = true; - } - - void Visit(WfFloatingExpression* node)override - { - isConstant = true; - } - - void Visit(WfIntegerExpression* node)override - { - isConstant = true; - } - - void Visit(WfStringExpression* node)override - { - isConstant = true; - } - - void Visit(WfUnaryExpression* node)override - { - isConstant = Call(node->operand); - } - - void Visit(WfBinaryExpression* node)override - { - if (node->op == WfBinaryOperator::Intersect) - { - isConstant = Call(node->first) && Call(node->second); - } - } - - void Visit(WfLetExpression* node)override - { - } - - void Visit(WfIfExpression* node)override - { - } - - void Visit(WfRangeExpression* node)override - { - isConstant = Call(node->begin) && Call(node->end); - } - - void Visit(WfSetTestingExpression* node)override - { - } - - void Visit(WfConstructorExpression* node)override - { - auto result = manager->expressionResolvings[node]; - bool isStruct = (result.type->GetTypeDescriptor()->GetTypeDescriptorFlags() == TypeDescriptorFlags::Struct); - - FOREACH(Ptr, argument, node->arguments) - { - if (argument->key && !isStruct) - { - if (!Call(argument->key)) return; - } - if (argument->value) - { - if (!Call(argument->value)) return; - } - } - isConstant = true; - } - - void Visit(WfInferExpression* node)override - { - } - - void Visit(WfTypeCastingExpression* node)override - { - } - - void Visit(WfTypeTestingExpression* node)override - { - } - - void Visit(WfTypeOfTypeExpression* node)override - { - isConstant = true; - } - - void Visit(WfTypeOfExpressionExpression* node)override - { - isConstant = true; - } - - void Visit(WfAttachEventExpression* node)override - { - } - - void Visit(WfDetachEventExpression* node)override - { - } - - void Visit(WfObserveExpression* node)override - { - } - - void Visit(WfCallExpression* node)override - { - } - - void Visit(WfFunctionExpression* node)override - { - } - - void Visit(WfNewClassExpression* node)override - { - } - - void Visit(WfNewInterfaceExpression* node)override - { - } - - void Visit(WfVirtualExpression* node)override - { - if (node->expandedExpression) - { - isConstant = Call(node->expandedExpression); - } - } - - static void Execute(Ptr expression, WfLexicalScopeManager* manager, Ptr expectedType) - { - if (GetExpressionType(manager, expression, expectedType)) - { - ValidateConstantExpressionVisitor visitor(manager); - expression->Accept(&visitor); - if (!visitor.isConstant) - { - manager->errors.Add(WfErrors::ExpressionIsNotConstant(expression.Obj())); - } - } - } - }; - -/*********************************************************************** -ValidateSemantic -***********************************************************************/ - - void ValidateModuleSemantic(WfLexicalScopeManager* manager, Ptr module) - { - FOREACH(Ptr, declaration, module->declarations) - { - ValidateDeclarationSemantic(manager, declaration); - } - } - - void ValidateClassMemberSemantic(WfLexicalScopeManager* manager, Ptr td, Ptr classDecl, Ptr memberDecl) - { - return ValidateSemanticClassMemberVisitor::Execute(td, classDecl, memberDecl, manager); - } - - void ValidateDeclarationSemantic(WfLexicalScopeManager* manager, Ptr declaration) - { - return ValidateSemanticDeclarationVisitor::Execute(declaration, manager); - } - - void ValidateStatementSemantic(WfLexicalScopeManager* manager, Ptr statement) - { - return ValidateSemanticStatementVisitor::Execute(statement, manager); - } - - void ValidateExpressionSemantic(WfLexicalScopeManager* manager, Ptr expression, Ptr expectedType, collections::List& results) - { - ValidateSemanticExpressionVisitor::Execute(expression, manager, expectedType, results); - for (vint i = results.Count() - 1; i >= 0; i--) - { - auto result = results[i]; - if (result.scopeName && result.scopeName->declarations.Count() > 0) - { - List replaces; - FOREACH(Ptr, decl, result.scopeName->declarations) - { - vint index = manager->nodeScopes.Keys().IndexOf(decl.Obj()); - if (index == -1) continue; - auto scope = manager->nodeScopes.Values()[index]; - if (scope->ownerNode == decl) - { - scope = scope->parentScope; - } - - index = scope->symbols.Keys().IndexOf(decl->name.value); - if (index == -1) continue; - FOREACH(Ptr, symbol, scope->symbols.GetByIndex(index)) - { - if (symbol->creatorNode == decl && symbol->typeInfo) - { - replaces.Add(ResolveExpressionResult::Symbol(symbol)); - } - } - } - - if (replaces.Count() > 0) - { - results.RemoveAt(i); - FOREACH_INDEXER(ResolveExpressionResult, replaceResult, index, replaces) - { - results.Insert(i + index, replaceResult); - } - } - } - } - } - - void ValidateConstantExpression(WfLexicalScopeManager* manager, Ptr expression, Ptr expectedType) - { - ValidateConstantExpressionVisitor::Execute(expression, manager, expectedType); - } - -/*********************************************************************** -GetExpressionScopeName -***********************************************************************/ - - Ptr GetExpressionScopeName(WfLexicalScopeManager* manager, Ptr expression) - { - List results; - ValidateExpressionSemantic(manager, expression, 0, results); - if (results.Count() == 0) return 0; - - for (vint i = results.Count() - 1; i >= 0; i--) - { - auto& result = results[i]; - if (!result.scopeName) - { - results.RemoveAt(i); - } - } - if (results.Count() == 0) - { - manager->errors.Add(WfErrors::ExpressionIsNotScopeName(expression.Obj())); - return 0; - } - else if (results.Count() > 1) - { - manager->errors.Add(WfErrors::TooManyTargets(expression.Obj(), results, GetExpressionName(expression))); - return 0; - } - - auto result = results[0]; - manager->expressionResolvings.Add(expression, result); - return result.scopeName; - } - -/*********************************************************************** -GetExpressionEventInfo -***********************************************************************/ - - reflection::description::IEventInfo* GetExpressionEventInfo(WfLexicalScopeManager* manager, Ptr expression) - { - List results; - ValidateExpressionSemantic(manager, expression, 0, results); - if (results.Count() == 0) return 0; - - for (vint i = results.Count() - 1; i >= 0; i--) - { - auto& result = results[i]; - if (!result.eventInfo) - { - results.RemoveAt(i); - } - } - if (results.Count() == 0) - { - manager->errors.Add(WfErrors::ExpressionIsNotEvent(expression.Obj())); - return 0; - } - else if (results.Count() > 1) - { - manager->errors.Add(WfErrors::TooManyTargets(expression.Obj(), results, GetExpressionName(expression))); - return 0; - } - - auto result = results[0]; - manager->expressionResolvings.Add(expression, result); - return result.eventInfo; - } - -/*********************************************************************** -GetExpressionTypes/GetExpressionType/GetLeftValueExpressionType -***********************************************************************/ - - void GetExpressionTypes(WfLexicalScopeManager* manager, Ptr expression, Ptr expectedType, bool allowEvent, collections::List& results) - { - ValidateExpressionSemantic(manager, expression, expectedType, results); - if (results.Count() == 0) return; - - Ptr scopeName; - IEventInfo* eventInfo = 0; - for (vint i = results.Count() - 1; i >= 0; i--) - { - auto& result = results[i]; - if (result.scopeName && !scopeName) - { - scopeName = result.scopeName; - } - if (result.eventInfo && !eventInfo) - { - eventInfo = result.eventInfo; - } - if (!result.type && !(allowEvent && eventInfo)) - { - results.RemoveAt(i); - } - } - if (results.Count() == 0) - { - if (scopeName) - { - manager->errors.Add(WfErrors::ScopeNameIsNotExpression(expression.Obj(), scopeName)); - } - if (eventInfo) - { - manager->errors.Add(WfErrors::EventIsNotExpression(expression.Obj(), eventInfo)); - } - } - - if (expectedType) - { - List> failedTypes; - for (vint i = results.Count() - 1; i >= 0; i--) - { - auto& result = results[i]; - if (!CanConvertToType(result.type.Obj(), expectedType.Obj(), false)) - { - failedTypes.Add(result.type); - results.RemoveAt(i); - } - } - - if (results.Count() == 0) - { - FOREACH(Ptr, type, failedTypes) - { - manager->errors.Add(WfErrors::ExpressionCannotImplicitlyConvertToType(expression.Obj(), type.Obj(), expectedType.Obj())); - } - } - } - } - - Ptr GetExpressionType(WfLexicalScopeManager* manager, Ptr expression, Ptr expectedType) - { - List results; - GetExpressionTypes(manager, expression, expectedType, false, results); - - if (results.Count() > 1) - { - manager->errors.Add(WfErrors::TooManyTargets(expression.Obj(), results, GetExpressionName(expression))); - return expectedType; - } - else if (results.Count() == 1) - { - auto result = results[0]; - result.expectedType = expectedType; - manager->expressionResolvings.Add(expression, result); - return expectedType ? expectedType : result.type; - } - else - { - return expectedType; - } - } - - Ptr GetLeftValueExpressionType(WfLexicalScopeManager* manager, Ptr expression) - { - List results; - GetExpressionTypes(manager, expression, nullptr, false, results); - - if (results.Count() > 1) - { - manager->errors.Add(WfErrors::TooManyTargets(expression.Obj(), results, GetExpressionName(expression))); - } - else if (results.Count() == 1) - { - if (results[0].writableType) - { - auto result = results[0]; - manager->expressionResolvings.Add(expression, result); - return result.writableType; - } - else - { - manager->errors.Add(WfErrors::ExpressionIsNotLeftValue(expression.Obj(), results[0])); - } - } - return 0; - } - -/*********************************************************************** -GetEnumerableExpressionItemType -***********************************************************************/ - - Ptr GetEnumerableExpressionItemType(WfLexicalScopeManager* manager, Ptr expression, Ptr expectedType) - { - Ptr collectionType = GetExpressionType(manager, expression, expectedType); - if (collectionType) - { - if (collectionType->GetTypeDescriptor()->CanConvertTo(description::GetTypeDescriptor())) - { - if (collectionType->GetDecorator() == ITypeInfo::SharedPtr) - { - ITypeInfo* genericType = collectionType->GetElementType(); - if (genericType->GetDecorator() == ITypeInfo::Generic && genericType->GetGenericArgumentCount() == 1) - { - return CopyTypeInfo(genericType->GetGenericArgument(0)); - } - } - return TypeInfoRetriver::CreateTypeInfo(); - } - - manager->errors.Add(WfErrors::ExpressionIsNotCollection(expression.Obj(), collectionType.Obj())); - } - return 0; - } - } - } -} - -/*********************************************************************** -ANALYZER\WFANALYZER_VALIDATESTRUCTURE.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace analyzer - { - using namespace collections; - using namespace parsing; - using namespace reflection::description; - -/*********************************************************************** -ValidateStructureContext -***********************************************************************/ - - ValidateStructureContext::ValidateStructureContext() - :currentBindExpression(0) - , currentObserveExpression(0) - , currentLoopStatement(0) - , currentCatchStatement(0) - { - } - -/*********************************************************************** -ValidateStructure(Type) -***********************************************************************/ - - class ValidateReferenceTypeVisitor : public Object, public WfType::IVisitor - { - public: - WfLexicalScopeManager* manager; - bool result; - - ValidateReferenceTypeVisitor(WfLexicalScopeManager* _manager) - :manager(_manager) - , result(true) - { - } - - void Visit(WfPredefinedType* node)override - { - } - - void Visit(WfTopQualifiedType* node)override - { - } - - void Visit(WfReferenceType* node)override - { - } - - void Visit(WfRawPointerType* node)override - { - result = false; - } - - void Visit(WfSharedPointerType* node)override - { - result = false; - } - - void Visit(WfNullableType* node)override - { - result = false; - } - - void Visit(WfEnumerableType* node)override - { - result = false; - } - - void Visit(WfMapType* node)override - { - result = false; - } - - void Visit(WfObservableListType* node)override - { - result = false; - } - - void Visit(WfFunctionType* node)override - { - result = false; - } - - void Visit(WfChildType* node)override - { - node->parent->Accept(this); - } - - static bool Execute(Ptr type, WfLexicalScopeManager* manager) - { - ValidateReferenceTypeVisitor visitor(manager); - type->Accept(&visitor); - return visitor.result; - } - }; - - class ValidateStructureTypeVisitor : public Object, public WfType::IVisitor - { - public: - WfLexicalScopeManager* manager; - ValidateTypeStragety strategy; - WfClassDeclaration* classDecl; - - ValidateStructureTypeVisitor(WfLexicalScopeManager* _manager, ValidateTypeStragety _strategy, WfClassDeclaration* _classDecl) - :manager(_manager) - , strategy(_strategy) - , classDecl(_classDecl) - { - } - - void Visit(WfPredefinedType* node)override - { - switch (node->name) - { - case WfPredefinedTypeName::Void: - switch (strategy) - { - case ValidateTypeStragety::Value: - manager->errors.Add(WfErrors::WrongVoidType(node)); - break; - case ValidateTypeStragety::BaseType: - manager->errors.Add(WfErrors::WrongBaseType(classDecl, node)); - default:; - } - break; - case WfPredefinedTypeName::Interface: - switch (strategy) - { - case ValidateTypeStragety::ReturnType: - case ValidateTypeStragety::Value: - manager->errors.Add(WfErrors::WrongInterfaceType(node)); - break; - default:; - } - default:; - } - } - - void Visit(WfTopQualifiedType* node)override - { - } - - void Visit(WfReferenceType* node)override - { - } - - void Visit(WfRawPointerType* node)override - { - if (strategy == ValidateTypeStragety::BaseType) - { - manager->errors.Add(WfErrors::WrongBaseType(classDecl, node)); - } - - if (!ValidateReferenceTypeVisitor::Execute(node->element, manager)) - { - manager->errors.Add(WfErrors::RawPointerToNonReferenceType(node)); - } - else if (auto predefinedType = node->element.Cast()) - { - if (predefinedType->name != WfPredefinedTypeName::Interface) - { - manager->errors.Add(WfErrors::RawPointerToNonReferenceType(node)); - } - } - } - - void Visit(WfSharedPointerType* node)override - { - if (strategy == ValidateTypeStragety::BaseType) - { - manager->errors.Add(WfErrors::WrongBaseType(classDecl, node)); - } - - if (!ValidateReferenceTypeVisitor::Execute(node->element, manager)) - { - manager->errors.Add(WfErrors::SharedPointerToNonReferenceType(node)); - } - else if (auto predefinedType = node->element.Cast()) - { - if (predefinedType->name != WfPredefinedTypeName::Interface) - { - manager->errors.Add(WfErrors::SharedPointerToNonReferenceType(node)); - } - } - } - - void Visit(WfNullableType* node)override - { - if (strategy == ValidateTypeStragety::BaseType) - { - manager->errors.Add(WfErrors::WrongBaseType(classDecl, node)); - } - - if (!ValidateReferenceTypeVisitor::Execute(node->element, manager)) - { - manager->errors.Add(WfErrors::NullableToNonReferenceType(node)); - } - else if (auto predefinedType = node->element.Cast()) - { - switch (predefinedType->name) - { - case WfPredefinedTypeName::Void: - case WfPredefinedTypeName::Object: - case WfPredefinedTypeName::Interface: - manager->errors.Add(WfErrors::NullableToNonReferenceType(node)); - break; - default:; - } - } - } - - void Visit(WfEnumerableType* node)override - { - if (strategy == ValidateTypeStragety::BaseType) - { - manager->errors.Add(WfErrors::WrongBaseType(classDecl, node)); - } - - ValidateTypeStructure(manager, node->element); - } - - void Visit(WfMapType* node)override - { - if (strategy == ValidateTypeStragety::BaseType) - { - manager->errors.Add(WfErrors::WrongBaseType(classDecl, node)); - } - - if (node->key) - { - ValidateTypeStructure(manager, node->key); - } - ValidateTypeStructure(manager, node->value); - } - - void Visit(WfObservableListType* node)override - { - if (strategy == ValidateTypeStragety::BaseType) - { - manager->errors.Add(WfErrors::WrongBaseType(classDecl, node)); - } - - ValidateTypeStructure(manager, node->element); - } - - void Visit(WfFunctionType* node)override - { - if (strategy == ValidateTypeStragety::BaseType) - { - manager->errors.Add(WfErrors::WrongBaseType(classDecl, node)); - } - - ValidateTypeStructure(manager, node->result, ValidateTypeStragety::ReturnType); - FOREACH(Ptr, argument, node->arguments) - { - ValidateTypeStructure(manager, argument); - } - } - - void Visit(WfChildType* node)override - { - if (!ValidateReferenceTypeVisitor::Execute(node->parent, manager)) - { - manager->errors.Add(WfErrors::ChildOfNonReferenceType(node)); - } - } - - static void Execute(Ptr type, WfLexicalScopeManager* manager, ValidateTypeStragety strategy, WfClassDeclaration* classDecl) - { - ValidateStructureTypeVisitor visitor(manager, strategy, classDecl); - type->Accept(&visitor); - } - }; - -/*********************************************************************** -ValidateStructure(Declaration) -***********************************************************************/ - - class ValidateStructureDeclarationVisitor - : public Object - , public WfDeclaration::IVisitor - , public WfVirtualDeclaration::IVisitor - { - public: - WfLexicalScopeManager* manager; - WfClassDeclaration* classDecl; - WfExpression* surroundingLambda; - - ValidateStructureDeclarationVisitor(WfLexicalScopeManager* _manager, WfClassDeclaration* _classDecl, WfExpression* _surroundingLambda) - :manager(_manager) - , classDecl(_classDecl) - , surroundingLambda(_surroundingLambda) - { - } - - void Visit(WfNamespaceDeclaration* node)override - { - if (dynamic_cast(surroundingLambda)) - { - manager->errors.Add(WfErrors::WrongDeclarationInInterfaceConstructor(node)); - } - if (node->classMember) - { - manager->errors.Add(WfErrors::WrongClassMember(node)); - } - - for (vint i = 0; i < node->declarations.Count(); i++) - { - ValidateDeclarationStructure(manager, node->declarations[i]); - } - } - - void Visit(WfFunctionDeclaration* node)override - { - if (classDecl && node->classMember) - { - switch (classDecl->kind) - { - case WfClassKind::Class: - { - switch (node->classMember->kind) - { - case WfClassMemberKind::Normal: - case WfClassMemberKind::Static: - if (!node->statement) - { - manager->errors.Add(WfErrors::FunctionShouldHaveImplementation(node)); - } - break; - case WfClassMemberKind::Override: - manager->errors.Add(WfErrors::OverrideShouldImplementInterfaceMethod(node)); - break; - } - } - break; - case WfClassKind::Interface: - { - switch (node->classMember->kind) - { - case WfClassMemberKind::Normal: - if (node->statement) - { - manager->errors.Add(WfErrors::InterfaceMethodShouldNotHaveImplementation(node)); - } - break; - case WfClassMemberKind::Static: - if (!node->statement) - { - manager->errors.Add(WfErrors::FunctionShouldHaveImplementation(node)); - } - break; - case WfClassMemberKind::Override: - manager->errors.Add(WfErrors::OverrideShouldImplementInterfaceMethod(node)); - break; - } - } - break; - } - } - else - { - if (dynamic_cast(surroundingLambda)) - { - switch (node->classMember->kind) - { - case WfClassMemberKind::Normal: - break; - case WfClassMemberKind::Static: - manager->errors.Add(WfErrors::FunctionInNewTypeExpressionCannotBeStatic(node)); - break; - case WfClassMemberKind::Override: - break; - } - } - if (!node->statement) - { - manager->errors.Add(WfErrors::FunctionShouldHaveImplementation(node)); - } - } - - if (node->anonymity == WfFunctionAnonymity::Anonymous) - { - if (!dynamic_cast(surroundingLambda)) - { - manager->errors.Add(WfErrors::FunctionShouldHaveName(node)); - } - } - - - ValidateTypeStructure(manager, node->returnType, ValidateTypeStragety::ReturnType); - FOREACH(Ptr, argument, node->arguments) - { - ValidateTypeStructure(manager, argument->type); - } - - if (node->statement) - { - ValidateStructureContext context; - ValidateStatementStructure(manager, &context, node->statement); - } - } - - void Visit(WfVariableDeclaration* node)override - { - if (classDecl && node->classMember) - { - switch (node->classMember->kind) - { - case WfClassMemberKind::Normal: - break; - case WfClassMemberKind::Static: - case WfClassMemberKind::Override: - manager->errors.Add(WfErrors::WrongClassMemberConfig(node)); - break; - } - } - - if (node->type) - { - ValidateTypeStructure(manager, node->type); - } - else if (classDecl) - { - manager->errors.Add(WfErrors::MissingFieldType(node)); - } - ValidateStructureContext context; - ValidateExpressionStructure(manager, &context, node->expression); - } - - void Visit(WfEventDeclaration* node)override - { - if (classDecl && node->classMember) - { - switch (node->classMember->kind) - { - case WfClassMemberKind::Normal: - break; - case WfClassMemberKind::Static: - case WfClassMemberKind::Override: - manager->errors.Add(WfErrors::WrongClassMemberConfig(node)); - break; - } - - FOREACH(Ptr, argument, node->arguments) - { - ValidateTypeStructure(manager, argument); - } - } - else if (dynamic_cast(surroundingLambda)) - { - manager->errors.Add(WfErrors::WrongDeclarationInInterfaceConstructor(node)); - } - else - { - manager->errors.Add(WfErrors::WrongDeclaration(node)); - } - } - - class FindPropertyRelatedDeclVisitor - : public empty_visitor::DeclarationVisitor - { - public: - WfLexicalScopeManager* manager; - WfClassDeclaration* classDecl; - WfPropertyDeclaration* propDecl; - Ptr getter; - Ptr setter; - Ptr valueChangedEvent; - bool duplicateGetter = false; - bool duplicateSetter = false; - bool duplicateEvent = false; - - FindPropertyRelatedDeclVisitor(WfLexicalScopeManager* _manager, WfClassDeclaration* _classDecl, WfPropertyDeclaration* _propDecl) - :manager(_manager) - , classDecl(_classDecl) - , propDecl(_propDecl) - { - } - - void Dispatch(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - Execute(decl); - } - } - - void Execute(Ptr memberDecl) - { - memberDecl->Accept(this); - if (!duplicateGetter && memberDecl->name.value == propDecl->getter.value) - { - if (getter) - { - duplicateGetter = true; - manager->errors.Add(WfErrors::TooManyPropertyGetter(propDecl, classDecl)); - } - else - { - getter = memberDecl; - } - } - - if (!duplicateSetter && propDecl->setter.value != L"" && memberDecl->name.value == propDecl->setter.value) - { - if (setter) - { - duplicateSetter = true; - manager->errors.Add(WfErrors::TooManyPropertySetter(propDecl, classDecl)); - } - else - { - setter = memberDecl; - } - } - - if (!duplicateEvent && propDecl->valueChangedEvent.value != L"" && memberDecl->name.value == propDecl->valueChangedEvent.value) - { - if (valueChangedEvent) - { - duplicateEvent = true; - manager->errors.Add(WfErrors::TooManyPropertyEvent(propDecl, classDecl)); - } - else - { - valueChangedEvent = memberDecl; - } - } - } - }; - - void Visit(WfPropertyDeclaration* node)override - { - if (classDecl && node->classMember) - { - switch (node->classMember->kind) - { - case WfClassMemberKind::Normal: - break; - case WfClassMemberKind::Static: - case WfClassMemberKind::Override: - manager->errors.Add(WfErrors::WrongClassMemberConfig(node)); - break; - } - - ValidateTypeStructure(manager, node->type); - FindPropertyRelatedDeclVisitor visitor(manager, classDecl, node); - - FOREACH(Ptr, memberDecl, classDecl->declarations) - { - visitor.Execute(memberDecl); - } - - if (!visitor.getter || visitor.getter->classMember->kind == WfClassMemberKind::Static || !visitor.getter.Cast()) - { - manager->errors.Add(WfErrors::PropertyGetterNotFound(node, classDecl)); - } - - if (node->setter.value != L"" && (!visitor.setter || visitor.setter->classMember->kind == WfClassMemberKind::Static || !visitor.setter.Cast())) - { - manager->errors.Add(WfErrors::PropertySetterNotFound(node, classDecl)); - } - - if (node->valueChangedEvent.value != L"" && (!visitor.valueChangedEvent || visitor.valueChangedEvent->classMember->kind == WfClassMemberKind::Static || !visitor.valueChangedEvent.Cast())) - { - manager->errors.Add(WfErrors::PropertyEventNotFound(node, classDecl)); - } - } - else if (dynamic_cast(surroundingLambda)) - { - manager->errors.Add(WfErrors::WrongDeclarationInInterfaceConstructor(node)); - } - else - { - manager->errors.Add(WfErrors::WrongDeclaration(node)); - } - } - - void Visit(WfConstructorDeclaration* node)override - { - if (classDecl && node->classMember) - { - switch (node->classMember->kind) - { - case WfClassMemberKind::Normal: - break; - case WfClassMemberKind::Static: - case WfClassMemberKind::Override: - manager->errors.Add(WfErrors::WrongClassMemberConfig(node)); - break; - } - - if (classDecl->kind != WfClassKind::Class) - { - manager->errors.Add(WfErrors::WrongDeclaration(node)); - } - - FOREACH(Ptr, call, node->baseConstructorCalls) - { - ValidateTypeStructure(manager, call->type, ValidateTypeStragety::BaseType, classDecl); - FOREACH(Ptr, argument, call->arguments) - { - ValidateStructureContext context; - ValidateExpressionStructure(manager, &context, argument); - } - } - { - ValidateStructureContext context; - ValidateStatementStructure(manager, &context, node->statement); - } - } - else - { - manager->errors.Add(WfErrors::WrongDeclaration(node)); - } - } - - void Visit(WfDestructorDeclaration* node)override - { - if (classDecl && node->classMember) - { - switch (node->classMember->kind) - { - case WfClassMemberKind::Normal: - break; - case WfClassMemberKind::Static: - case WfClassMemberKind::Override: - manager->errors.Add(WfErrors::WrongClassMemberConfig(node)); - break; - } - - if (classDecl->kind != WfClassKind::Class) - { - manager->errors.Add(WfErrors::WrongDeclaration(node)); - } - - ValidateStructureContext context; - ValidateStatementStructure(manager, &context, node->statement); - } - else - { - manager->errors.Add(WfErrors::WrongDeclaration(node)); - } - } - - class FindCtorVisitor - : public empty_visitor::DeclarationVisitor - { - public: - WfConstructorDeclaration* ctor = nullptr; - - void Dispatch(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - - void Visit(WfConstructorDeclaration* node)override - { - ctor = node; - } - }; - - class TooManyDtorVisitor - : public empty_visitor::DeclarationVisitor - { - public: - WfLexicalScopeManager* manager; - WfClassDeclaration* classDecl; - WfDestructorDeclaration* dtor = nullptr; - - TooManyDtorVisitor(WfLexicalScopeManager* _manager, WfClassDeclaration* _classDecl) - :manager(_manager) - , classDecl(_classDecl) - { - } - - void Dispatch(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - - void Visit(WfDestructorDeclaration* node)override - { - if (!dtor) - { - dtor = node; - } - else - { - manager->errors.Add(WfErrors::TooManyDestructor(node, classDecl)); - } - } - }; - - void Visit(WfClassDeclaration* node)override - { - if (classDecl && node->classMember) - { - switch (node->classMember->kind) - { - case WfClassMemberKind::Normal: - break; - case WfClassMemberKind::Static: - case WfClassMemberKind::Override: - manager->errors.Add(WfErrors::WrongClassMemberConfig(node)); - break; - } - } - else if (dynamic_cast(surroundingLambda)) - { - manager->errors.Add(WfErrors::WrongDeclarationInInterfaceConstructor(node)); - } - - switch (node->kind) - { - case WfClassKind::Class: - { - if (node->constructorType != WfConstructorType::Undefined) - { - manager->errors.Add(WfErrors::ClassWithInterfaceConstructor(node)); - } - { - FindCtorVisitor visitor; - FOREACH(Ptr, memberDecl, node->declarations) - { - memberDecl->Accept(&visitor); - } - - if (!visitor.ctor) - { - auto ctor = MakePtr(); - node->declarations.Add(ctor); - ctor->codeRange = node->codeRange; - ctor->classMember = MakePtr(); - ctor->classMember->codeRange = node->codeRange; - ctor->classMember->kind = WfClassMemberKind::Normal; - - auto stat = MakePtr(); - ctor->statement = stat; - stat->codeRange = node->codeRange; - } - } - } - break; - case WfClassKind::Interface: - break; - } - - FOREACH(Ptr, type, node->baseTypes) - { - ValidateTypeStructure(manager, type, ValidateTypeStragety::BaseType, node); - } - - { - TooManyDtorVisitor visitor(manager, node); - FOREACH(Ptr, memberDecl, node->declarations) - { - ValidateDeclarationStructure(manager, memberDecl, node); - memberDecl->Accept(&visitor); - } - } - } - - void Visit(WfEnumDeclaration* node)override - { - if (classDecl && node->classMember) - { - switch (node->classMember->kind) - { - case WfClassMemberKind::Normal: - break; - case WfClassMemberKind::Static: - case WfClassMemberKind::Override: - manager->errors.Add(WfErrors::WrongClassMemberConfig(node)); - break; - } - } - else if (dynamic_cast(surroundingLambda)) - { - manager->errors.Add(WfErrors::WrongDeclarationInInterfaceConstructor(node)); - } - - vuint64_t current = 0; - bool reportedNotConsecutive = false; - SortedList discoveredItems; - FOREACH(Ptr, item, node->items) - { - switch (item->kind) - { - case WfEnumItemKind::Constant: - { - vuint64_t value = -1; - TypedValueSerializerProvider::Deserialize(item->number.value, value); - if (!reportedNotConsecutive && value != current) - { - reportedNotConsecutive = true; - switch (node->kind) - { - case WfEnumKind::Normal: - manager->errors.Add(WfErrors::EnumValuesNotConsecutiveFromZero(node)); - break; - case WfEnumKind::Flag: - manager->errors.Add(WfErrors::FlagValuesNotConsecutiveFromZero(node)); - break; - } - } - switch (node->kind) - { - case WfEnumKind::Normal: - current++; - break; - case WfEnumKind::Flag: - current = current == 0 ? 1 : current * 2; - break; - } - } - break; - case WfEnumItemKind::Intersection: - FOREACH(Ptr, enumInt, item->intersections) - { - if (!discoveredItems.Contains(enumInt->name.value)) - { - manager->errors.Add(WfErrors::FlagValueNotExists(enumInt.Obj(), node)); - } - } - break; - } - - if (discoveredItems.Contains(item->name.value)) - { - manager->errors.Add(WfErrors::DuplicatedEnumValue(item.Obj(), node)); - } - else - { - discoveredItems.Add(item->name.value); - } - } - } - - void Visit(WfStructDeclaration* node)override - { - if (classDecl && node->classMember) - { - switch (node->classMember->kind) - { - case WfClassMemberKind::Normal: - break; - case WfClassMemberKind::Static: - case WfClassMemberKind::Override: - manager->errors.Add(WfErrors::WrongClassMemberConfig(node)); - break; - } - } - else if (dynamic_cast(surroundingLambda)) - { - manager->errors.Add(WfErrors::WrongDeclarationInInterfaceConstructor(node)); - } - - SortedList discoveredItems; - FOREACH(Ptr, member, node->members) - { - if (discoveredItems.Contains(member->name.value)) - { - manager->errors.Add(WfErrors::DuplicatedStructMember(member.Obj(), node)); - } - else - { - discoveredItems.Add(member->name.value); - } - } - } - - void Visit(WfVirtualDeclaration* node)override - { - node->Accept(static_cast(this)); - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - - void Visit(WfAutoPropertyDeclaration* node)override - { - switch (node->classMember->kind) - { - case WfClassMemberKind::Normal: - if (dynamic_cast(surroundingLambda)) - { - manager->errors.Add(WfErrors::AutoPropertyCannotBeNormalOutsideOfClass(node)); - } - break; - case WfClassMemberKind::Static: - manager->errors.Add(WfErrors::AutoPropertyCannotBeStatic(node)); - break; - case WfClassMemberKind::Override: - if (!dynamic_cast(surroundingLambda)) - { - manager->errors.Add(WfErrors::OverrideShouldImplementInterfaceMethod(node)); - } - break; - } - - if (classDecl) - { - switch (classDecl->kind) - { - case WfClassKind::Class: - if (!node->expression) - { - manager->errors.Add(WfErrors::AutoPropertyShouldBeInitialized(node)); - } - break; - case WfClassKind::Interface: - if (node->expression) - { - manager->errors.Add(WfErrors::AutoPropertyCannotBeInitializedInInterface(node, classDecl)); - } - break; - } - } - else if (dynamic_cast(surroundingLambda)) - { - if (!node->expression) - { - manager->errors.Add(WfErrors::AutoPropertyShouldBeInitialized(node)); - } - } - else - { - manager->errors.Add(WfErrors::WrongDeclaration(node)); - } - - ValidateTypeStructure(manager, node->type); - if (node->expression) - { - ValidateStructureContext context; - ValidateExpressionStructure(manager, &context, node->expression); - } - } - - void Visit(WfCastResultInterfaceDeclaration* node)override - { - } - - static void Execute(Ptr declaration, WfLexicalScopeManager* manager, WfClassDeclaration* classDecl, WfExpression* surroundingLambda) - { - ValidateStructureDeclarationVisitor visitor(manager, classDecl, surroundingLambda); - declaration->Accept(&visitor); - } - }; - -/*********************************************************************** -ValidateStructure(Statement) -***********************************************************************/ - - class ValidateStructureStatementVisitor - : public Object - , public WfStatement::IVisitor - , public WfVirtualStatement::IVisitor - , public WfCoroutineStatement::IVisitor - { - public: - WfLexicalScopeManager* manager; - ValidateStructureContext* context; - Ptr result; - - ValidateStructureStatementVisitor(WfLexicalScopeManager* _manager, ValidateStructureContext* _context) - :manager(_manager) - , context(_context) - { - } - - void Visit(WfBreakStatement* node)override - { - if (!context->currentLoopStatement) - { - manager->errors.Add(WfErrors::BreakNotInLoop(node)); - } - } - - void Visit(WfContinueStatement* node)override - { - if (!context->currentLoopStatement) - { - manager->errors.Add(WfErrors::ContinueNotInLoop(node)); - } - } - - void Visit(WfReturnStatement* node)override - { - if (node->expression) - { - ValidateExpressionStructure(manager, context, node->expression); - } - } - - void Visit(WfDeleteStatement* node)override - { - ValidateExpressionStructure(manager, context, node->expression); - } - - void Visit(WfRaiseExceptionStatement* node)override - { - if (node->expression) - { - ValidateExpressionStructure(manager, context, node->expression); - } - else if (!context->currentCatchStatement) - { - manager->errors.Add(WfErrors::RethrowNotInCatch(node)); - } - } - - void Visit(WfIfStatement* node)override - { - if (node->type) - { - ValidateTypeStructure(manager, node->type); - } - ValidateExpressionStructure(manager, context, node->expression); - ValidateStatementStructure(manager, context, node->trueBranch); - if (node->falseBranch) - { - ValidateStatementStructure(manager, context, node->falseBranch); - } - } - - void Visit(WfWhileStatement* node)override - { - auto oldLoop = context->currentLoopStatement; - context->currentLoopStatement = node; - ValidateExpressionStructure(manager, context, node->condition); - ValidateStatementStructure(manager, context, node->statement); - context->currentLoopStatement = oldLoop; - } - - void Visit(WfTryStatement* node)override - { - ValidateStatementStructure(manager, context, node->protectedStatement); - if (node->catchStatement) - { - auto oldCatch = context->currentCatchStatement; - context->currentCatchStatement = node->catchStatement.Obj(); - ValidateStatementStructure(manager, context, node->catchStatement); - context->currentCatchStatement = oldCatch; - } - if (node->finallyStatement) - { - ValidateStatementStructure(manager, context, node->finallyStatement); - } - if (!node->catchStatement && !node->finallyStatement) - { - manager->errors.Add(WfErrors::TryMissCatchAndFinally(node)); - } - } - - void Visit(WfBlockStatement* node)override - { - for (vint i = 0; i < node->statements.Count(); i++) - { - ValidateStatementStructure(manager, context, node->statements[i]); - } - } - - void Visit(WfExpressionStatement* node)override - { - ValidateExpressionStructure(manager, context, node->expression); - } - - void Visit(WfVariableStatement* node)override - { - ValidateDeclarationStructure(manager, node->variable); - } - - void Visit(WfVirtualStatement* node)override - { - node->Accept((WfVirtualStatement::IVisitor*)this); - if (node->expandedStatement) - { - ValidateStatementStructure(manager, context, node->expandedStatement); - } - } - - void Visit(WfSwitchStatement* node)override - { - ValidateExpressionStructure(manager, context, node->expression); - FOREACH(Ptr, switchCase, node->caseBranches) - { - ValidateExpressionStructure(manager, context, switchCase->expression); - ValidateStatementStructure(manager, context, switchCase->statement); - } - if (node->defaultBranch) - { - ValidateStatementStructure(manager, context, node->defaultBranch); - } - } - - void Visit(WfForEachStatement* node)override - { - auto oldLoop = context->currentLoopStatement; - context->currentLoopStatement = node; - ValidateExpressionStructure(manager, context, node->collection); - ValidateStatementStructure(manager, context, node->statement); - context->currentLoopStatement = oldLoop; - } - - void Visit(WfCoProviderStatement* node)override - { - auto oldProvider = context->currentCoProviderStatement; - context->currentCoProviderStatement = node; - ValidateStatementStructure(manager, context, node->statement); - context->currentCoProviderStatement = oldProvider; - } - - void Visit(WfCoroutineStatement* node)override - { - node->Accept((WfCoroutineStatement::IVisitor*)this); - } - - void Visit(WfCoPauseStatement* node)override - { - if (!context->currentNewCoroutineExpression || context->currentCoPauseStatement) - { - manager->errors.Add(WfErrors::WrongCoPause(node)); - } - if (node->statement) - { - auto oldCpPause = context->currentCoPauseStatement; - context->currentCoPauseStatement = node; - ValidateStatementStructure(manager, context, node->statement); - context->currentCoPauseStatement = oldCpPause; - } - } - - void Visit(WfCoOperatorStatement* node)override - { - if (!context->currentCoProviderStatement) - { - manager->errors.Add(WfErrors::WrongCoOperator(node)); - } - } - - static void Execute(Ptr& statement, WfLexicalScopeManager* manager, ValidateStructureContext* context) - { - ValidateStructureStatementVisitor visitor(manager, context); - statement->Accept(&visitor); - if (visitor.result) - { - statement = visitor.result; - } - } - }; - -/*********************************************************************** -ValidateStructure(Expression) -***********************************************************************/ - - class ValidateStructureExpressionVisitor - : public Object - , public WfExpression::IVisitor - , public WfVirtualExpression::IVisitor - { - public: - WfLexicalScopeManager* manager; - ValidateStructureContext* context; - Ptr result; - - ValidateStructureExpressionVisitor(WfLexicalScopeManager* _manager, ValidateStructureContext* _context) - :manager(_manager) - , context(_context) - { - } - - void Visit(WfThisExpression* node)override - { - if (context->currentBindExpression) - { - manager->errors.Add(WfErrors::WrongThisExpression(node)); - } - } - - void Visit(WfTopQualifiedExpression* node)override - { - } - - void Visit(WfReferenceExpression* node)override - { - } - - void Visit(WfOrderedNameExpression* node)override - { - } - - void Visit(WfOrderedLambdaExpression* node)override - { - auto oldBind = context->currentBindExpression; - context->currentBindExpression = 0; - ValidateExpressionStructure(manager, context, node->body); - context->currentBindExpression = oldBind; - } - - void Visit(WfMemberExpression* node)override - { - ValidateExpressionStructure(manager, context, node->parent); - } - - void Visit(WfChildExpression* node)override - { - ValidateExpressionStructure(manager, context, node->parent); - } - - void Visit(WfLiteralExpression* node)override - { - } - - void Visit(WfFloatingExpression* node)override - { - } - - void Visit(WfIntegerExpression* node)override - { - } - - void Visit(WfStringExpression* node)override - { - } - - void Visit(WfUnaryExpression* node)override - { - ValidateExpressionStructure(manager, context, node->operand); - } - - void Visit(WfBinaryExpression* node)override - { - ValidateExpressionStructure(manager, context, node->first); - ValidateExpressionStructure(manager, context, node->second); - } - - void Visit(WfLetExpression* node)override - { - FOREACH(Ptr, variable, node->variables) - { - ValidateExpressionStructure(manager, context, variable->value); - } - ValidateExpressionStructure(manager, context, node->expression); - } - - void Visit(WfIfExpression* node)override - { - ValidateExpressionStructure(manager, context, node->condition); - ValidateExpressionStructure(manager, context, node->trueBranch); - ValidateExpressionStructure(manager, context, node->falseBranch); - } - - void Visit(WfRangeExpression* node)override - { - ValidateExpressionStructure(manager, context, node->begin); - ValidateExpressionStructure(manager, context, node->end); - } - - void Visit(WfSetTestingExpression* node)override - { - ValidateExpressionStructure(manager, context, node->element); - ValidateExpressionStructure(manager, context, node->collection); - } - - void Visit(WfConstructorExpression* node)override - { - vint listElementCount = 0; - vint mapElementCount = 0; - FOREACH(Ptr, argument, node->arguments) - { - ValidateExpressionStructure(manager, context, argument->key); - if (argument->value) - { - ValidateExpressionStructure(manager, context, argument->value); - mapElementCount++; - } - else - { - listElementCount++; - } - } - - if (listElementCount*mapElementCount != 0) - { - manager->errors.Add(WfErrors::ConstructorMixMapAndList(node)); - } - } - - void Visit(WfInferExpression* node)override - { - ValidateTypeStructure(manager, node->type); - ValidateExpressionStructure(manager, context, node->expression); - } - - void Visit(WfTypeCastingExpression* node)override - { - ValidateTypeStructure(manager, node->type); - ValidateExpressionStructure(manager, context, node->expression); - } - - void Visit(WfTypeTestingExpression* node)override - { - if (node->type) - { - ValidateTypeStructure(manager, node->type); - } - ValidateExpressionStructure(manager, context, node->expression); - } - - void Visit(WfTypeOfTypeExpression* node)override - { - ValidateTypeStructure(manager, node->type); - } - - void Visit(WfTypeOfExpressionExpression* node)override - { - ValidateExpressionStructure(manager, context, node->expression); - } - - void Visit(WfAttachEventExpression* node)override - { - if (context->currentBindExpression) - { - manager->errors.Add(WfErrors::AttachInBind(node)); - } - ValidateExpressionStructure(manager, context, node->event); - ValidateExpressionStructure(manager, context, node->function); - } - - void Visit(WfDetachEventExpression* node)override - { - if (context->currentBindExpression) - { - manager->errors.Add(WfErrors::DetachInBind(node)); - } - ValidateExpressionStructure(manager, context, node->event); - ValidateExpressionStructure(manager, context, node->handler); - } - - void Visit(WfObserveExpression* node)override - { - if (!context->currentBindExpression) - { - manager->errors.Add(WfErrors::ObserveNotInBind(node)); - } - if (context->currentObserveExpression) - { - manager->errors.Add(WfErrors::ObserveInObserveEvent(node)); - } - - if (node->observeType == WfObserveType::SimpleObserve) - { - if (!node->expression.Cast()) - { - manager->errors.Add(WfErrors::WrongSimpleObserveExpression(node->expression.Obj())); - } - FOREACH(Ptr, event, node->events) - { - if (!event.Cast()) - { - manager->errors.Add(WfErrors::WrongSimpleObserveEvent(event.Obj())); - } - } - } - if (node->events.Count() == 0) - { - manager->errors.Add(WfErrors::EmptyObserveEvent(node)); - } - - ValidateExpressionStructure(manager, context, node->parent); - ValidateExpressionStructure(manager, context, node->expression); - context->currentObserveExpression = node; - for (vint i = 0; i < node->events.Count(); i++) - { - ValidateExpressionStructure(manager, context, node->events[i]); - } - context->currentObserveExpression = 0; - } - - void Visit(WfCallExpression* node)override - { - ValidateExpressionStructure(manager, context, node->function); - for (vint i = 0; i < node->arguments.Count(); i++) - { - ValidateExpressionStructure(manager, context, node->arguments[i]); - } - } - - void Visit(WfFunctionExpression* node)override - { - ValidateDeclarationStructure(manager, node->function, nullptr, node); - } - - void Visit(WfNewClassExpression* node)override - { - ValidateTypeStructure(manager, node->type); - for (vint i = 0; i < node->arguments.Count(); i++) - { - ValidateExpressionStructure(manager, context, node->arguments[i]); - } - } - - void Visit(WfNewInterfaceExpression* node)override - { - ValidateTypeStructure(manager, node->type); - FOREACH(Ptr, memberDecl, node->declarations) - { - ValidateDeclarationStructure(manager, memberDecl, nullptr, node); - } - } - - void Visit(WfVirtualExpression* node)override - { - node->Accept((WfVirtualExpression::IVisitor*)this); - if (node->expandedExpression) - { - ValidateExpressionStructure(manager, context, node->expandedExpression); - } - } - - void Visit(WfBindExpression* node)override - { - if (context->currentBindExpression) - { - manager->errors.Add(WfErrors::BindInBind(node)); - } - - auto bind = context->currentBindExpression; - context->currentBindExpression = node; - ValidateExpressionStructure(manager, context, node->expression); - context->currentBindExpression = bind; - } - - void Visit(WfFormatExpression* node)override - { - } - - void Visit(WfNewCoroutineExpression* node)override - { - ValidateStructureContext context; - context.currentNewCoroutineExpression = node; - ValidateStatementStructure(manager, &context, node->statement); - } - - void Visit(WfMixinCastExpression* node)override - { - ValidateTypeStructure(manager, node->type); - ValidateExpressionStructure(manager, context, node->expression); - } - - void Visit(WfExpectedTypeCastExpression* node)override - { - ValidateExpressionStructure(manager, context, node->expression); - } - - static void Execute(Ptr& expression, WfLexicalScopeManager* manager, ValidateStructureContext* context) - { - ValidateStructureExpressionVisitor visitor(manager, context); - expression->Accept(&visitor); - if (visitor.result) - { - expression = visitor.result; - } - } - }; - -/*********************************************************************** -ValidateStructure -***********************************************************************/ - - void ValidateTypeStructure(WfLexicalScopeManager* manager, Ptr type, ValidateTypeStragety strategy, WfClassDeclaration* classDecl) - { - ValidateStructureTypeVisitor::Execute(type, manager, strategy, classDecl); - } - - void ValidateModuleStructure(WfLexicalScopeManager* manager, Ptr module) - { - FOREACH(Ptr, path, module->paths) - { - FOREACH_INDEXER(Ptr, item, index, path->items) - { - vint counter = 0; - FOREACH(Ptr, fragment, item->fragments) - { - if (fragment.Cast()) - { - if (index == path->items.Count() - 1) - { - counter++; - } - else - { - goto USING_PATH_INCORRECT; - } - } - } - - if (index == path->items.Count() - 1 && counter != 1) - { - goto USING_PATH_INCORRECT; - } - } - continue; - USING_PATH_INCORRECT: - manager->errors.Add(WfErrors::WrongUsingPathWildCard(path.Obj())); - } - for (vint i = 0; i < module->declarations.Count(); i++) - { - ValidateDeclarationStructure(manager, module->declarations[i]); - } - } - - void ValidateDeclarationStructure(WfLexicalScopeManager* manager, Ptr declaration, WfClassDeclaration* classDecl, WfExpression* surroundingLambda) - { - ValidateStructureDeclarationVisitor::Execute(declaration, manager, classDecl, surroundingLambda); - } - - void ValidateStatementStructure(WfLexicalScopeManager* manager, ValidateStructureContext* context, Ptr& statement) - { - ValidateStructureStatementVisitor::Execute(statement, manager, context); - } - - void ValidateExpressionStructure(WfLexicalScopeManager* manager, ValidateStructureContext* context, Ptr& expression) - { - ValidateStructureExpressionVisitor::Execute(expression, manager, context); - } - } - } -} - -/*********************************************************************** -CPP\WFCPP.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace cppcodegen - { - using namespace collections; - using namespace regex; - using namespace reflection; - using namespace reflection::description; - using namespace stream; - using namespace emitter; - -/*********************************************************************** -WfCppConfig -***********************************************************************/ - - void WfCppConfig::Collect() - { - FOREACH(Ptr, module, manager->GetModules()) - { - CollectModule(this, module); - } - - FOREACH(Ptr, lambda, lambdaExprs.Keys()) - { - auto closureInfo = CollectClosureInfo(lambda); - closureInfo->lambdaClassName = lambdaExprs[lambda.Obj()]; - closureInfos.Add(lambda, closureInfo); - } - - FOREACH(Ptr, classExpr, classExprs.Keys()) - { - auto closureInfo = CollectClosureInfo(classExpr); - closureInfo->lambdaClassName = classExprs[classExpr.Obj()]; - closureInfos.Add(classExpr, closureInfo); - } - } - - void WfCppConfig::Sort(collections::List>& structDecls) - { - List tds; - FOREACH_INDEXER(Ptr, decl, index, structDecls) - { - tds.Add(manager->declarationTypes[decl.Obj()].Obj()); - } - - for (vint i = 0; i < tds.Count(); i++) - { - for (vint j = i; i < tds.Count(); j++) - { - auto td = tds[j]; - vint count = td->GetPropertyCount(); - bool found = false; - for (vint k = 0; k < count && !found; k++) - { - auto prop = td->GetProperty(k); - auto propTd = prop->GetReturn()->GetTypeDescriptor(); - for (vint l = k + 1; l < tds.Count() && !found; l++) - { - found = tds[l] == propTd; - } - } - - if (!found) - { - if (j != i) - { - auto t = tds[j]; - tds.RemoveAt(j); - tds.Insert(i, t); - - auto decl = structDecls[j]; - structDecls.RemoveAt(j); - structDecls.Insert(i, decl); - } - - break; - } - } - } - } - - WfCppConfig::WfCppConfig(analyzer::WfLexicalScopeManager* _manager, const WString& _assemblyName, const WString& _assemblyNamespace) - :manager(_manager) - , regexSplitName(L"::") - , regexSpecialName(L"/<(/w+)(-(/w+))*/>(/w*)") - , regexTemplate(L", /$Arguments|/$Arguments, |/$/l+") - , assemblyName(_assemblyName) - , assemblyNamespace(_assemblyNamespace) - { - attributeEvaluator = MakePtr(manager); - Collect(); - for (vint i = 0; i < structDecls.Count(); i++) - { - const auto& values = structDecls.GetByIndex(i); - Sort(const_cast>&>(values)); - } - } - - WfCppConfig::~WfCppConfig() - { - } - - void WfCppConfig::WriteFunctionBody(stream::StreamWriter& writer, Ptr expr, const WString& prefix, ITypeInfo* expectedType) - { - writer.WriteString(prefix); - writer.WriteString(L"return "); - GenerateExpression(this, writer, expr, expectedType); - writer.WriteLine(L";"); - } - - void WfCppConfig::WriteFunctionBody(stream::StreamWriter& writer, Ptr stat, const WString& prefix, ITypeInfo* expectedType) - { - GenerateStatement(this, MakePtr(), writer, stat, prefix, WString(L"\t", false), expectedType); - } - - WString WfCppConfig::ConvertName(const WString& name) - { - if (name.Length() > 0 && name[0] == L'$') - { - return L"__vwsno_" + name.Sub(1, name.Length() - 1); - } - - auto match = regexSpecialName.Match(name); - if (match) - { - return L"__vwsn_" - + From(match->Groups()[L"category"]) - .Select([](const RegexString& rs) - { - return rs.Value(); - }) - .Aggregate([](const WString& a, const WString& b) - { - return a + L"_" + b; - }) - + L"_" + match->Groups()[L"name"][0].Value(); - } - else - { - return name; - } - } - - WString WfCppConfig::ConvertFullName(const WString& fullName, WString delimiter) - { - List> matches; - regexSplitName.Split(fullName, false, matches); - return (fullName[0] == L':' ? delimiter : WString::Empty) + From(matches) - .Select([this](Ptr match) - { - return ConvertName(match->Result().Value()); - }) - .Aggregate([&](const WString& a, const WString& b) - { - return a + delimiter + b; - }); - } - - WString WfCppConfig::ConvertFunctionType(IMethodInfo* methodInfo, WString name) - { - WString type = ConvertType(methodInfo->GetReturn()) + name + L"("; - vint count = methodInfo->GetParameterCount(); - for (vint i = 0; i < count; i++) - { - if (i > 0) - { - type += L", "; - } - type += ConvertArgumentType(methodInfo->GetParameter(i)->GetType()); - } - type += L")"; - return type; - } - - WString WfCppConfig::ConvertFunctionType(ITypeInfo* typeInfo) - { - if (typeInfo->GetDecorator() == ITypeInfo::SharedPtr) - { - return ConvertFunctionType(typeInfo->GetElementType()); - } - CHECK_ERROR(typeInfo->GetDecorator() == ITypeInfo::Generic, L"WfCppConfig::ConvertFunctionType(ITypeInfo*)#Wrong function type."); - CHECK_ERROR(typeInfo->GetTypeDescriptor() == description::GetTypeDescriptor(), L"WfCppConfig::ConvertFunctionType(ITypeInfo*)#Wrong function type."); - - WString type = ConvertType(typeInfo->GetGenericArgument(0)) + L"("; - vint count = typeInfo->GetGenericArgumentCount(); - for (vint i = 1; i < count; i++) - { - if (i > 1) type += L", "; - type += ConvertArgumentType(typeInfo->GetGenericArgument(i)); - } - type += L")"; - return type; - } - - bool WfCppConfig::IsSpecialGenericType(ITypeInfo* typeInfo) - { - switch (typeInfo->GetDecorator()) - { - case ITypeInfo::SharedPtr: - if (typeInfo->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - return true; - } - else if (typeInfo->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - return true; - } - else - { - return false; - } - default: - return false; - } - } - - WString WfCppConfig::ConvertType(ITypeDescriptor* typeInfo, WString delimiter) - { - return ConvertFullName(CppGetFullName(typeInfo), delimiter); - } - - WString WfCppConfig::ConvertType(ITypeInfo* typeInfo) - { - switch (typeInfo->GetDecorator()) - { - case ITypeInfo::RawPtr: - return ConvertType(typeInfo->GetElementType()) + L"*"; - case ITypeInfo::SharedPtr: - if (typeInfo->GetElementType()->GetDecorator() == ITypeInfo::Generic) - { - if (typeInfo->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - return ConvertType(typeInfo->GetElementType()); - } - else if (typeInfo->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - return ConvertType(typeInfo->GetElementType()); - } - } - return L"::vl::Ptr<" + ConvertType(typeInfo->GetElementType()) + L">"; - case ITypeInfo::Nullable: - return L"::vl::Nullable<" + ConvertType(typeInfo->GetElementType()) + L">"; - case ITypeInfo::Generic: - if (typeInfo->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - return L"::vl::Func<" + ConvertFunctionType(typeInfo) + L">"; - } - else if(typeInfo->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - return L"::vl::collections::LazyList<" + ConvertType(typeInfo->GetGenericArgument(0)) + L">"; - } - else - { - return ConvertType(typeInfo->GetElementType()); - } - default:; - } - return ConvertType(typeInfo->GetTypeDescriptor()); - } - - WString WfCppConfig::ConvertArgumentType(ITypeInfo* typeInfo) - { - auto td = typeInfo->GetTypeDescriptor(); - bool constRef = - td == description::GetTypeDescriptor() || - td == description::GetTypeDescriptor() || - ( - typeInfo->GetDecorator() == ITypeInfo::SharedPtr && typeInfo->GetElementType()->GetDecorator() == ITypeInfo::Generic && - ( - td == description::GetTypeDescriptor() || - td == description::GetTypeDescriptor() - ) - ); - - if (constRef) - { - return L"const " + ConvertType(typeInfo) + L"&"; - } - else - { - return ConvertType(typeInfo); - } - } - - WString WfCppConfig::DefaultValue(ITypeInfo* typeInfo) - { - switch (typeInfo->GetDecorator()) - { - case ITypeInfo::RawPtr: - return L"nullptr"; - case ITypeInfo::SharedPtr: - return L""; - case ITypeInfo::Nullable: - return L""; - case ITypeInfo::Generic: - return L""; - default:; - } - auto td = typeInfo->GetTypeDescriptor(); - if ((td->GetTypeDescriptorFlags()&TypeDescriptorFlags::EnumType) != TypeDescriptorFlags::Undefined) - { - return L"static_cast<" + ConvertType(typeInfo) + L">(0)"; - } - if (td == description::GetTypeDescriptor()) return L"0"; - if (td == description::GetTypeDescriptor()) return L"0"; - if (td == description::GetTypeDescriptor()) return L"0"; - if (td == description::GetTypeDescriptor()) return L"0"; - if (td == description::GetTypeDescriptor()) return L"0"; - if (td == description::GetTypeDescriptor()) return L"0"; - if (td == description::GetTypeDescriptor()) return L"0"; - if (td == description::GetTypeDescriptor()) return L"0"; - if (td == description::GetTypeDescriptor()) return L"false"; - if (td == description::GetTypeDescriptor()) return L"0.0f"; - if (td == description::GetTypeDescriptor()) return L"0.0"; - return L""; - } - - vint WfCppConfig::CountClassNamespace(Ptr decl) - { - vint result = 0; - auto scope = manager->nodeScopes[decl.Obj()].Obj(); - while (scope) - { - if (scope->ownerNode.Cast()) - { - result++; - } - scope = scope->parentScope.Obj(); - } - return result; - } - - void WfCppConfig::GetClassNamespace(Ptr decl, collections::List& nss) - { - auto td = manager->declarationTypes[decl.Obj()].Obj(); - auto name = ConvertType(td); - vint count = CountClassNamespace(decl); - - List> matches; - regexSplitName.Split(name, false, matches); - - CopyFrom( - nss, - From(matches) - .Take(count) - .Select([this](Ptr match) - { - return ConvertName(match->Result().Value()); - }) - ); - } - - WString WfCppConfig::GetClassBaseName(Ptr decl) - { - auto td = manager->declarationTypes[decl.Obj()].Obj(); - auto name = ConvertType(td); - vint count = CountClassNamespace(decl); - - List> matches; - regexSplitName.Split(name, false, matches); - - return From(matches) - .Skip(count) - .Select([this](Ptr match) - { - return ConvertName(match->Result().Value()); - }) - .Aggregate([](const WString& a, const WString& b) - { - return a + L"::" + b; - }); - } - - WString WfCppConfig::WriteNamespace(stream::StreamWriter& writer, collections::List& nss, collections::List& nss2) - { - vint commonPrefix = 0; - for (vint i = 0; i < nss.Count() && i < nss2.Count(); i++) - { - if (nss[i] == nss2[i]) - { - commonPrefix++; - } - else - { - break; - } - } - - while (nss.Count() > commonPrefix) - { - for (vint i = 1; i < nss.Count(); i++) - { - writer.WriteChar(L'\t'); - } - writer.WriteLine(L"}"); - nss.RemoveAt(nss.Count() - 1); - } - - WString prefix; - for (vint i = 0; i < nss.Count(); i++) - { - prefix += L'\t'; - } - - for (vint i = commonPrefix; i < nss2.Count(); i++) - { - writer.WriteString(prefix); - writer.WriteString(L"namespace "); - writer.WriteLine(nss2[i]); - - writer.WriteString(prefix); - writer.WriteLine(L"{"); - - nss.Add(nss2[i]); - prefix += L'\t'; - } - - return prefix; - } - - WString WfCppConfig::WriteNamespace(stream::StreamWriter& writer, const WString& fullName, collections::List& nss, WString& name) - { - List> matches; - regexSplitName.Split(fullName, false, matches); - - List nss2; - CopyFrom( - nss2, - From(matches) - .Select([this](Ptr match) - { - return ConvertName(match->Result().Value()); - }) - ); - - name = nss2[nss2.Count() - 1]; - nss2.RemoveAt(nss2.Count() - 1); - return WriteNamespace(writer, nss, nss2); - } - - void WfCppConfig::WriteNamespaceEnd(stream::StreamWriter& writer, collections::List& nss) - { - while (nss.Count() > 0) - { - for (vint i = 1; i < nss.Count(); i++) - { - writer.WriteChar(L'\t'); - } - writer.WriteLine(L"}"); - nss.RemoveAt(0); - } - } - } - } -} - -/*********************************************************************** -CPP\WFCPP_CLASS.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace cppcodegen - { - using namespace collections; - using namespace reflection; - using namespace reflection::description; - using namespace analyzer; - - bool IsVirtual(WfCppConfig* config, WfFunctionDeclaration* node) - { - vint index = config->manager->declarationMemberInfos.Keys().IndexOf(node); - if (index != -1) - { - auto methodInfo = dynamic_cast(config->manager->declarationMemberInfos.Values()[index].Obj()); - if (methodInfo->IsStatic()) - { - return false; - } - auto td = methodInfo->GetOwnerTypeDescriptor(); - return td->GetTypeDescriptorFlags() == TypeDescriptorFlags::Interface; - } - return false; - } - -/*********************************************************************** -WfGenerateClassMemberDeclVisitor -***********************************************************************/ - - class WfGenerateClassMemberDeclVisitor : public Object, public WfDeclaration::IVisitor - { - public: - WfCppConfig* config; - stream::StreamWriter& writer; - WString className; - WString prefix; - bool forClassExpr; - - WfGenerateClassMemberDeclVisitor(WfCppConfig* _config, stream::StreamWriter& _writer, const WString& _className, const WString& _prefix, bool _forClassExpr) - :config(_config) - , writer(_writer) - , className(_className) - , prefix(_prefix) - , forClassExpr(_forClassExpr) - { - } - - void Visit(WfNamespaceDeclaration* node)override - { - } - - void Visit(WfFunctionDeclaration* node)override - { - bool isVirtual = IsVirtual(config, node); - - writer.WriteString(prefix); - if (isVirtual) - { - writer.WriteString(L"virtual "); - } - else if (node->classMember->kind == WfClassMemberKind::Static) - { - writer.WriteString(L"static "); - } - config->WriteFunctionHeader(writer, node, config->ConvertName(node->name.value), true); - if (isVirtual) - { - writer.WriteString(L" = 0"); - } - else if (node->classMember->kind == WfClassMemberKind::Override) - { - writer.WriteString(L" override"); - } - writer.WriteLine(L";"); - } - - void Visit(WfVariableDeclaration* node)override - { - auto scope = config->manager->nodeScopes[node].Obj(); - auto symbol = scope->symbols[node->name.value][0]; - auto typeInfo = symbol->typeInfo; - writer.WriteString(prefix + config->ConvertType(typeInfo.Obj()) + L" " + config->ConvertName(node->name.value)); - if (!forClassExpr && node->expression) - { - writer.WriteString(L" = "); - GenerateExpression(config, writer, node->expression, typeInfo.Obj()); - } - else - { - auto defaultValue = config->DefaultValue(typeInfo.Obj()); - if (defaultValue != L"") - { - writer.WriteString(L" = "); - writer.WriteString(defaultValue); - } - } - writer.WriteLine(L";"); - } - - void Visit(WfEventDeclaration* node)override - { - auto eventInfo = dynamic_cast(config->manager->declarationMemberInfos[node].Obj()); - auto typeInfo = eventInfo->GetHandlerType(); - writer.WriteString(prefix); - - writer.WriteString(L"::vl::EventGetGenericArgumentCount(); - for (vint i = 1; i < count; i++) - { - if (i > 1) writer.WriteString(L", "); - writer.WriteString(config->ConvertType(typeInfo->GetGenericArgument(i))); - } - writer.WriteLine(L")> " + config->ConvertName(node->name.value) + L";"); - } - - void Visit(WfPropertyDeclaration* node)override - { - } - - void Visit(WfConstructorDeclaration* node)override - { - auto methodInfo = dynamic_cast(config->manager->declarationMemberInfos[node].Obj()); - writer.WriteString(prefix); - config->WriteFunctionHeader(writer, methodInfo, className, false); - writer.WriteLine(L";"); - } - - void Visit(WfDestructorDeclaration* node)override - { - writer.WriteLine(prefix + L"~" + className + L"();"); - } - - void Visit(WfClassDeclaration* node)override - { - } - - void Visit(WfEnumDeclaration* node)override - { - } - - void Visit(WfStructDeclaration* node)override - { - } - - void Visit(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - }; - - void GenerateClassMemberDecl(WfCppConfig* config, stream::StreamWriter& writer, const WString& className, Ptr memberDecl, const WString& prefix, bool forClassExpr) - { - WfGenerateClassMemberDeclVisitor visitor(config, writer, className, prefix, forClassExpr); - memberDecl->Accept(&visitor); - } - -/*********************************************************************** -WfGenerateClassMemberImplVisitor -***********************************************************************/ - - class WfGenerateClassMemberImplVisitor : public Object, public WfDeclaration::IVisitor - { - public: - WfCppConfig* config; - stream::StreamWriter& writer; - WString classBaseName; - WString className; - WString classFullName; - WString prefix; - bool printableMember = false; - - WfGenerateClassMemberImplVisitor(WfCppConfig* _config, stream::StreamWriter& _writer, const WString& _classBaseName, const WString& _className, const WString& _classFullName, const WString& _prefix) - :config(_config) - , writer(_writer) - , classBaseName(_classBaseName) - , className(_className) - , classFullName(_classFullName) - , prefix(_prefix) - { - } - - void WriteNotImplemented() - { - writer.WriteString(prefix); - writer.WriteLine(L"{"); - writer.WriteString(prefix); - writer.WriteLine(L"\tthrow ::vl::Exception(L\"You should implement this function.\");"); - writer.WriteString(prefix); - writer.WriteLine(L"}"); - } - - void Visit(WfNamespaceDeclaration* node)override - { - } - - void Visit(WfFunctionDeclaration* node)override - { - if (!IsVirtual(config, node)) - { - printableMember = true; - - bool userImpl = config->attributeEvaluator->GetAttribute(node->attributes, L"cpp", L"UserImpl"); - if (userImpl) - { - writer.WriteString(prefix); - writer.WriteString(L"USERIMPL(/* "); - writer.WriteString(classFullName); - writer.WriteLine(L" */)"); - } - - writer.WriteString(prefix); - auto returnType = config->WriteFunctionHeader(writer, node, classBaseName + L"::" + config->ConvertName(node->name.value), true); - writer.WriteLine(L""); - - if (userImpl) - { - WriteNotImplemented(); - } - else - { - config->WriteFunctionBody(writer, node->statement, prefix, returnType); - } - } - } - - void Visit(WfVariableDeclaration* node)override - { - } - - void Visit(WfEventDeclaration* node)override - { - } - - void Visit(WfPropertyDeclaration* node)override - { - } - - void Visit(WfConstructorDeclaration* node)override - { - auto scope = config->manager->nodeScopes[node].Obj(); - printableMember = true; - auto methodInfo = dynamic_cast(config->manager->declarationMemberInfos[node].Obj()); - - List arguments; - FOREACH(Ptr, argument, node->arguments) - { - arguments.Add(config->ConvertName(argument->name.value)); - } - - bool userImpl = config->attributeEvaluator->GetAttribute(node->attributes, L"cpp", L"UserImpl"); - if (userImpl) - { - writer.WriteString(prefix); - writer.WriteString(L"USERIMPL(/* "); - writer.WriteString(classFullName); - writer.WriteLine(L" */)"); - } - - writer.WriteString(prefix); - config->WriteFunctionHeader(writer, methodInfo, arguments, classBaseName + L"::" + className, false); - writer.WriteLine(L""); - FOREACH_INDEXER(Ptr, call, callIndex, node->baseConstructorCalls) - { - auto callType = CreateTypeInfoFromType(scope, call->type); - auto callCtor = config->manager->baseConstructorCallResolvings[{node, callType->GetTypeDescriptor()}].value; - - writer.WriteString(prefix); - if (callIndex == 0) - { - writer.WriteString(L"\t: "); - } - else - { - writer.WriteString(L"\t, "); - } - - writer.WriteString(config->ConvertType(callType->GetTypeDescriptor())); - writer.WriteString(L"("); - FOREACH_INDEXER(Ptr, argument, argumentIndex, call->arguments) - { - if (argumentIndex) writer.WriteString(L", "); - GenerateExpression(config, writer, argument, callCtor->GetParameter(argumentIndex)->GetType()); - } - writer.WriteLine(L")"); - } - - if (userImpl) - { - WriteNotImplemented(); - } - else - { - config->WriteFunctionBody(writer, node->statement, prefix, nullptr); - } - } - - void Visit(WfDestructorDeclaration* node)override - { - printableMember = true; - - bool userImpl = config->attributeEvaluator->GetAttribute(node->attributes, L"cpp", L"UserImpl"); - if (userImpl) - { - writer.WriteString(prefix); - writer.WriteString(L"USERIMPL(/* "); - writer.WriteString(classFullName); - writer.WriteLine(L" */)"); - } - - writer.WriteLine(prefix + classBaseName + L"::~" + className + L"()"); - - if (userImpl) - { - WriteNotImplemented(); - } - else - { - config->WriteFunctionBody(writer, node->statement, prefix, nullptr); - } - } - - void Visit(WfClassDeclaration* node)override - { - } - - void Visit(WfEnumDeclaration* node)override - { - } - - void Visit(WfStructDeclaration* node)override - { - } - - void Visit(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - }; - - bool GenerateClassMemberImpl(WfCppConfig* config, stream::StreamWriter& writer, const WString& classBaseName, const WString& className, const WString& classFullName, Ptr memberDecl, const WString& prefix) - { - WfGenerateClassMemberImplVisitor visitor(config, writer, classBaseName, className, classFullName, prefix); - memberDecl->Accept(&visitor); - return visitor.printableMember; - } - } - } -} - -/*********************************************************************** -CPP\WFCPP_COLLECT.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace cppcodegen - { - using namespace collections; - using namespace regex; - using namespace reflection::description; - using namespace analyzer; - -/*********************************************************************** -CollectModule -***********************************************************************/ - - class WfCollectModuleVisitor : public traverse_visitor::ModuleVisitor - { - public: - WfCppConfig* config; - WfClassDeclaration* surroundingClassDecl = nullptr; - WfFunctionDeclaration* funcDeclToSkip = nullptr; - WfVariableDeclaration* varDeclToSkip = nullptr; - - WfCollectModuleVisitor(WfCppConfig* _config) - :config(_config) - { - } - - WString GetScopePostfix(WfLexicalScope* scope) - { - WString name; - while (scope) - { - if (auto decl = scope->ownerNode.Cast()) - { - name = config->ConvertName(decl->name.value) + L"_" + name; - } - scope = scope->parentScope.Obj(); - } - return name; - } - - void Traverse(WfOrderedLambdaExpression* node)override - { - WString prefix = L"__vwsno" + itow(config->lambdaExprs.Count() + 1) + L"_" + config->assemblyName + L"_"; - WString postfix = GetScopePostfix(config->manager->nodeScopes[node].Obj()); - WString name = prefix + postfix; - - config->lambdaExprs.Add(node, name); - config->classClosures.Add(surroundingClassDecl, node); - } - - void Traverse(WfFunctionExpression* node)override - { - WString prefix = L"__vwsnf" + itow(config->lambdaExprs.Count() + 1) + L"_" + config->assemblyName + L"_"; - WString postfix = GetScopePostfix(config->manager->nodeScopes[node].Obj()); - WString name = prefix + postfix; - - config->lambdaExprs.Add(node, name); - config->classClosures.Add(surroundingClassDecl, node); - } - - void Traverse(WfNewInterfaceExpression* node)override - { - WString prefix = L"__vwsnc" + itow(config->classExprs.Count() + 1) + L"_" + config->assemblyName + L"_"; - WString postfix = GetScopePostfix(config->manager->nodeScopes[node].Obj()); - - auto result = config->manager->expressionResolvings[node]; - auto td = result.constructorInfo->GetOwnerTypeDescriptor(); - WString name = prefix + postfix + config->ConvertType(td, L"_"); - - config->classExprs.Add(node, name); - config->classClosures.Add(surroundingClassDecl, node); - } - - void Traverse(WfFunctionDeclaration* node)override - { - if (node != funcDeclToSkip && !node->classMember) - { - config->funcDecls.Add(node); - } - } - - void Traverse(WfVariableDeclaration* node)override - { - if (node != varDeclToSkip && !node->classMember) - { - config->varDecls.Add(node); - } - } - - void AddDeclFile(WfDeclaration* node) - { - if (surroundingClassDecl) - { - auto fileName = config->declFiles[surroundingClassDecl]; - config->declFiles.Add(node, fileName); - } - else - { - config->declFiles.Add(node, L""); - } - } - - void Visit(WfClassDeclaration* node)override - { - config->classDecls.Add(surroundingClassDecl, node); - - if (surroundingClassDecl) - { - AddDeclFile(node); - } - else - { - WString file; - if (auto att = config->attributeEvaluator->GetAttribute(node->attributes, L"cpp", L"File")) - { - file = UnboxValue(config->attributeEvaluator->GetAttributeValue(att)); - } - config->topLevelClassDeclsForFiles.Add(file, node); - config->declFiles.Add(node, file); - } - - auto td = config->manager->declarationTypes[node].Obj(); - vint count = td->GetBaseTypeDescriptorCount(); - for (vint i = 0; i < count; i++) - { - auto baseTd = td->GetBaseTypeDescriptor(i); - auto scopeName = config->manager->typeNames[baseTd]; - if (scopeName->declarations.Count() > 0) - { - config->declDependencies.Add(node, scopeName->declarations[0]); - } - } - - auto oldSurroundingClassDecl = surroundingClassDecl; - surroundingClassDecl = node; - traverse_visitor::DeclarationVisitor::Visit(node); - surroundingClassDecl = oldSurroundingClassDecl; - } - - void Traverse(WfEnumDeclaration* node)override - { - config->enumDecls.Add(surroundingClassDecl, node); - AddDeclFile(node); - } - - void Traverse(WfStructDeclaration* node)override - { - config->structDecls.Add(surroundingClassDecl, node); - AddDeclFile(node); - - auto td = config->manager->declarationTypes[node].Obj(); - vint count = td->GetPropertyCount(); - for (vint i = 0; i < count; i++) - { - auto propTd = td->GetProperty(i)->GetReturn()->GetTypeDescriptor(); - auto scopeName = config->manager->typeNames[propTd]; - if (scopeName->declarations.Count() > 0) - { - config->declDependencies.Add(node, scopeName->declarations[0]); - } - } - } - - void Visit(WfFunctionExpression* node)override - { - auto old = funcDeclToSkip; - funcDeclToSkip = node->function.Obj(); - traverse_visitor::ExpressionVisitor::Visit(node); - funcDeclToSkip = old; - } - - void Visit(WfVariableStatement* node)override - { - auto old = varDeclToSkip; - varDeclToSkip = node->variable.Obj(); - traverse_visitor::StatementVisitor::Visit(node); - varDeclToSkip = old; - } - }; - - void CollectModule(WfCppConfig* config, Ptr module) - { - WfCollectModuleVisitor(config).VisitField(module.Obj()); - } - } - } -} - -/*********************************************************************** -CPP\WFCPP_EXPRESSION.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace cppcodegen - { - using namespace collections; - using namespace regex; - using namespace reflection; - using namespace reflection::description; - using namespace analyzer; - -/*********************************************************************** -Expression Helpers -***********************************************************************/ - - template - void WriteBoxValue(WfCppConfig* config, stream::StreamWriter& writer, ITypeInfo* type, const T& writeExpression) - { - writer.WriteString(L"::vl::__vwsn::Box("); - writeExpression(); - writer.WriteString(L")"); - } - - template - void WriteUnboxValue(WfCppConfig* config, stream::StreamWriter& writer, ITypeInfo* type, const T& writeExpression) - { - writer.WriteString(L"::vl::__vwsn::Unbox<"); - writer.WriteString(config->ConvertType(type)); - writer.WriteString(L">("); - writeExpression(); - writer.WriteString(L")"); - } - - template - void WriteUnboxWeakValue(WfCppConfig* config, stream::StreamWriter& writer, ITypeInfo* type, const T& writeExpression) - { - writer.WriteString(L"::vl::__vwsn::UnboxWeak<"); - writer.WriteString(config->ConvertType(type)); - writer.WriteString(L">("); - writeExpression(); - writer.WriteString(L")"); - } - - template - void ConvertValueType(WfCppConfig* config, stream::StreamWriter& writer, ITypeDescriptor* fromTd, ITypeDescriptor* toTd, const T& writeExpression) - { - if (fromTd == toTd) - { - writeExpression(); - } - else if (fromTd == description::GetTypeDescriptor()) - { - writer.WriteString(L"::vl::__vwsn::Parse<"); - writer.WriteString(config->ConvertType(toTd)); - writer.WriteString(L">("); - writeExpression(); - writer.WriteString(L")"); - } - else if (toTd == description::GetTypeDescriptor()) - { - writer.WriteString(L"::vl::__vwsn::ToString("); - writeExpression(); - writer.WriteString(L")"); - } - else - { - writer.WriteString(L"static_cast<"); - writer.WriteString(config->ConvertType(toTd)); - writer.WriteString(L">("); - writeExpression(); - writer.WriteString(L")"); - } - } - - void ConvertType(WfCppConfig* config, stream::StreamWriter& writer, ITypeInfo* fromType, ITypeInfo* toType, const Func& writeExpression, bool strongCast) - { - if (fromType->GetTypeDescriptor()->GetTypeDescriptorFlags() == TypeDescriptorFlags::Object) - { - if (strongCast) - { - WriteUnboxValue(config, writer, toType, writeExpression); - } - else - { - WriteUnboxWeakValue(config, writer, toType, writeExpression); - } - return; - } - else if (toType->GetTypeDescriptor()->GetTypeDescriptorFlags() == TypeDescriptorFlags::Object) - { - WriteBoxValue(config, writer, fromType, writeExpression); - return; - } - else - { - auto tdVe = description::GetTypeDescriptor(); - if (toType->GetTypeDescriptor() == tdVe) - { - if (toType->GetElementType()->GetDecorator() == ITypeInfo::Generic) - { - if ((fromType->GetTypeDescriptor() == tdVe && fromType->GetElementType()->GetDecorator() != ITypeInfo::Generic) - || fromType->GetTypeDescriptor()->CanConvertTo(description::GetTypeDescriptor()) - || fromType->GetTypeDescriptor()->CanConvertTo(description::GetTypeDescriptor()) - ) - { - writer.WriteString(L"::vl::reflection::description::GetLazyList<"); - writer.WriteString(config->ConvertType(toType->GetElementType()->GetGenericArgument(0))); - writer.WriteString(L">("); - writeExpression(); - writer.WriteString(L")"); - return; - } - } - else - { - if ((fromType->GetTypeDescriptor() == tdVe && fromType->GetElementType()->GetDecorator() == ITypeInfo::Generic) - || fromType->GetHint() == TypeInfoHint::NativeCollectionReference - ) - { - writer.WriteString(L"::vl::__vwsn::UnboxCollection<"); - writer.WriteString(config->ConvertType(tdVe)); - writer.WriteString(L">("); - writeExpression(); - writer.WriteString(L")"); - return; - } - } - } - - switch (fromType->GetDecorator()) - { - case ITypeInfo::RawPtr: - { - switch (toType->GetDecorator()) - { - case ITypeInfo::RawPtr: - if (strongCast) writer.WriteString(L"::vl::__vwsn::Ensure("); - if (fromType->GetTypeDescriptor()->CanConvertTo(toType->GetTypeDescriptor())) - { - writer.WriteString(L"static_cast<"); - writer.WriteString(config->ConvertType(toType->GetTypeDescriptor())); - writer.WriteString(L"*>("); - writeExpression(); - writer.WriteString(L")"); - } - else - { - writer.WriteString(L"::vl::__vwsn::RawPtrCast<"); - writer.WriteString(config->ConvertType(toType->GetTypeDescriptor())); - writer.WriteString(L">("); - writeExpression(); - writer.WriteString(L")"); - } - if (strongCast) writer.WriteString(L")"); - return; - case ITypeInfo::SharedPtr: - if (strongCast) writer.WriteString(L"::vl::__vwsn::Ensure("); - if (fromType->GetTypeDescriptor()->CanConvertTo(toType->GetTypeDescriptor())) - { - writer.WriteString(L"::vl::Ptr<"); - writer.WriteString(config->ConvertType(toType->GetTypeDescriptor())); - writer.WriteString(L">("); - writeExpression(); - writer.WriteString(L")"); - } - else - { - writer.WriteString(L"::vl::__vwsn::SharedPtrCast<"); - writer.WriteString(config->ConvertType(toType->GetTypeDescriptor())); - writer.WriteString(L">("); - writeExpression(); - writer.WriteString(L")"); - } - if (strongCast) writer.WriteString(L")"); - return; - default:; - } - } - break; - case ITypeInfo::SharedPtr: - { - switch (toType->GetDecorator()) - { - case ITypeInfo::RawPtr: - if (strongCast) writer.WriteString(L"::vl::__vwsn::Ensure("); - if (fromType->GetTypeDescriptor()->CanConvertTo(toType->GetTypeDescriptor())) - { - writer.WriteString(L"static_cast<"); - writer.WriteString(config->ConvertType(toType->GetTypeDescriptor())); - writer.WriteString(L"*>("); - writeExpression(); - writer.WriteString(L".Obj())"); - } - else - { - writer.WriteString(L"::vl::__vwsn::RawPtrCast<"); - writer.WriteString(config->ConvertType(toType->GetTypeDescriptor())); - writer.WriteString(L">("); - writeExpression(); - writer.WriteString(L".Obj())"); - } - if (strongCast) writer.WriteString(L")"); - return; - case ITypeInfo::SharedPtr: - if (strongCast) writer.WriteString(L"::vl::__vwsn::Ensure("); - if (fromType->GetTypeDescriptor()->CanConvertTo(toType->GetTypeDescriptor())) - { - writer.WriteString(L"::vl::Ptr<"); - writer.WriteString(config->ConvertType(toType->GetTypeDescriptor())); - writer.WriteString(L">("); - writeExpression(); - writer.WriteString(L")"); - } - else - { - writer.WriteString(L"::vl::__vwsn::SharedPtrCast<"); - writer.WriteString(config->ConvertType(toType->GetTypeDescriptor())); - writer.WriteString(L">("); - writeExpression(); - writer.WriteString(L".Obj())"); - } - if (strongCast) writer.WriteString(L")"); - return; - default:; - } - } - break; - case ITypeInfo::Nullable: - { - switch (toType->GetDecorator()) - { - case ITypeInfo::Nullable: - if (strongCast) writer.WriteString(L"::vl::__vwsn::Ensure("); - writer.WriteString(L"::vl::__vwsn::NullableCast<"); - writer.WriteString(config->ConvertType(toType->GetTypeDescriptor())); - writer.WriteString(L">("); - writeExpression(); - writer.WriteString(L")"); - if (strongCast) writer.WriteString(L")"); - return; - case ITypeInfo::TypeDescriptor: - ConvertValueType(config, writer, fromType->GetTypeDescriptor(), toType->GetTypeDescriptor(), [&]() - { - writeExpression(); - writer.WriteString(L".Value()"); - }); - return; - default:; - } - } - break; - case ITypeInfo::TypeDescriptor: - { - switch (toType->GetDecorator()) - { - case ITypeInfo::Nullable: - writer.WriteString(config->ConvertType(toType)); - writer.WriteString(L"("); - ConvertValueType(config, writer, fromType->GetTypeDescriptor(), toType->GetTypeDescriptor(), writeExpression); - writer.WriteString(L")"); - return; - case ITypeInfo::TypeDescriptor: - ConvertValueType(config, writer, fromType->GetTypeDescriptor(), toType->GetTypeDescriptor(), writeExpression); - return; - default:; - } - } - break; - default:; - } - } - writer.WriteString(L"/* NOT EXISTS: convert ("); - writer.WriteString(config->ConvertType(fromType)); - writer.WriteString(L") to ("); - writer.WriteString(config->ConvertType(toType)); - writer.WriteString(L") */ __vwsn_not_exists__("); - writeExpression(); - writer.WriteString(L")"); - } - -/*********************************************************************** -WfGenerateExpressionVisitor -***********************************************************************/ - - class WfGenerateExpressionVisitor - : public Object - , public WfExpression::IVisitor - { - public: - WfCppConfig* config; - stream::StreamWriter& writer; - bool useReturnValue; - - WfGenerateExpressionVisitor(WfCppConfig* _config, stream::StreamWriter& _writer, bool _useReturnValue) - :config(_config) - , writer(_writer) - , useReturnValue(_useReturnValue) - { - } - - bool NeedConvertType(ITypeInfo* fromType, ITypeInfo*& toType) - { - if (toType == nullptr) - { - toType = fromType; - return false; - } - if (IsSameType(fromType, toType)) - { - return false; - } - else - { - return true; - } - } - - template - void WriteBoxValue(ITypeInfo* type, const T& writeExpression) - { - cppcodegen::WriteBoxValue(config, writer, type, writeExpression); - } - - template - void WriteUnboxValue(ITypeInfo* type, const T& writeExpression) - { - cppcodegen::WriteUnboxValue(config, writer, type, writeExpression); - } - - template - void WriteUnboxWeakValue(ITypeInfo* type, const T& writeExpression) - { - cppcodegen::WriteUnboxWeakValue(config, writer, type, writeExpression); - } - - void ConvertMultipleTypes(ITypeInfo** types, vint typesLength, Func writeExpression) - { - if (typesLength == 1) - { - writeExpression(); - } - else if (NeedConvertType(types[0], types[1])) - { - ConvertMultipleTypes(types + 1, typesLength - 1, [&]() - { - auto fromType = types[0]; - auto toType = types[1]; - ConvertType(config, writer, fromType, toType, writeExpression, false); - }); - } - else - { - return ConvertMultipleTypes(types + 1, typesLength - 1, writeExpression); - } - } - - void Call(Ptr node, ITypeInfo* expectedType = nullptr, bool useReturnValue = true) - { - GenerateExpression(config, writer, node, expectedType, useReturnValue); - } - - Ptr GetClosureInfo(WfExpression* node, Ptr testCtorArgumentSymbol = nullptr) - { - Ptr closureInfo; - auto scope = config->manager->nodeScopes[node].Obj(); - - if (dynamic_cast(node)) - { - scope = scope->parentScope.Obj(); - } - - while (scope) - { - if (scope->functionConfig && scope->functionConfig->lambda) - { - auto source = scope->ownerNodeSource ? scope->ownerNodeSource : scope->ownerNode.Obj(); - if (auto ordered = dynamic_cast(source)) - { - closureInfo = config->closureInfos[ordered]; - break; - } - else if (auto funcExpr = dynamic_cast(source)) - { - closureInfo = config->closureInfos[funcExpr]; - break; - } - else if (auto classExpr = dynamic_cast(source)) - { - closureInfo = config->closureInfos[classExpr]; - break; - } - } - else if (auto classExpr = scope->ownerNode.Cast()) - { - auto info = config->closureInfos[classExpr.Obj()]; - if (info->ctorArgumentSymbols.Values().Contains(testCtorArgumentSymbol.Obj())) - { - closureInfo = info; - break; - } - } - scope = scope->parentScope.Obj(); - } - - return closureInfo; - } - - void WriteNotExists(ITypeDescriptor* typeDescriptor) - { - writer.WriteString(L"/* NOT EXISTS: type("); - writer.WriteString(typeDescriptor->GetTypeName()); - writer.WriteString(L") */ __vwsn_not_exists__"); - } - - void WriteNotExists(IMethodInfo* methodInfo) - { - writer.WriteString(L"/* NOT EXISTS: method("); - writer.WriteString(methodInfo->GetName()); - writer.WriteString(L") of type ("); - writer.WriteString(methodInfo->GetOwnerTypeDescriptor()->GetTypeName()); - writer.WriteString(L") */ __vwsn_not_exists__"); - } - - void WriteNotExists(IPropertyInfo* propertyInfo) - { - writer.WriteString(L"/* NOT EXISTS: property("); - writer.WriteString(propertyInfo->GetName()); - writer.WriteString(L") of type ("); - writer.WriteString(propertyInfo->GetOwnerTypeDescriptor()->GetTypeName()); - writer.WriteString(L") */ __vwsn_not_exists__"); - } - - void WriteNotExists(IEventInfo* eventInfo) - { - writer.WriteString(L"/* NOT EXISTS: event("); - writer.WriteString(eventInfo->GetName()); - writer.WriteString(L") of type ("); - writer.WriteString(eventInfo->GetOwnerTypeDescriptor()->GetTypeName()); - writer.WriteString(L") */ __vwsn_not_exists__"); - } - - template - void WriteTemplate(const WString& templateValue, const T& callback) - { - List> matches; - config->regexTemplate.Cut(templateValue, false, matches); - FOREACH(Ptr, match, matches) - { - WString item = match->Result().Value(); - if (match->Success()) - { - if (!callback(item)) - { - writer.WriteString(L"/* NOT EXISTS: "); - writer.WriteString(item); - writer.WriteString(L" */ __vwsn_not_exists__"); - } - } - else - { - writer.WriteString(item); - } - } - } - - void VisitThisExpression(WfExpression* node, ITypeDescriptor* td) - { - if (auto closureInfo = GetClosureInfo(node)) - { - FOREACH_INDEXER(ITypeDescriptor*, thisType, index, closureInfo->thisTypes) - { - if (thisType->CanConvertTo(td)) - { - writer.WriteString(L"__vwsnthis_"); - writer.WriteString(itow(index)); - return; - } - } - } - writer.WriteString(L"this"); - } - - void VisitSymbol(WfExpression* node, Ptr symbol, bool forLambdaArgument) - { - if (auto varDecl = symbol->creatorNode.Cast()) - { - auto ownerNode = symbol->ownerScope->ownerNode; - if (ownerNode.Cast() || ownerNode.Cast()) - { - writer.WriteString(L"GLOBAL_NAME "); - writer.WriteString(config->ConvertName(symbol->name)); - return; - } - else if(auto closureInfo = GetClosureInfo(node, (forLambdaArgument ? nullptr : symbol))) - { - if (closureInfo->symbols.Values().Contains(symbol.Obj())) - { - writer.WriteString(L"this->"); - writer.WriteString(config->ConvertName(symbol->name)); - return; - } - else if (closureInfo->ctorArgumentSymbols.Values().Contains(symbol.Obj())) - { - writer.WriteString(L"__vwsnctor_"); - writer.WriteString(config->ConvertName(symbol->name)); - return; - } - } - writer.WriteString(config->ConvertName(symbol->name)); - return; - } - else if (auto funcDecl = symbol->creatorNode.Cast()) - { - auto ownerNode = symbol->ownerScope->ownerNode; - if (ownerNode.Cast() || ownerNode.Cast()) - { - writer.WriteString(config->ConvertType(symbol->typeInfo.Obj())); - writer.WriteString(L"(GLOBAL_OBJ, &GLOBAL_SYMBOL "); - writer.WriteString(config->ConvertName(symbol->name)); - writer.WriteString(L")"); - return; - } - else if (auto classExpr = ownerNode.Cast()) - { - writer.WriteString(config->ConvertType(symbol->typeInfo.Obj())); - writer.WriteString(L"(this, &"); - writer.WriteString(config->classExprs[classExpr.Obj()]); - writer.WriteString(L"::"); - writer.WriteString(config->ConvertName(symbol->name)); - writer.WriteString(L")"); - return; - } - else if (symbol->ownerScope->functionConfig && symbol->ownerScope->functionConfig->lambda && symbol->name == funcDecl->name.value) - { - auto scope = config->manager->nodeScopes[funcDecl.Obj()]; - auto closureInfo = config->closureInfos[dynamic_cast(scope->ownerNodeSource)]; - - writer.WriteString(L"LAMBDA(::"); - writer.WriteString(config->assemblyNamespace); - writer.WriteString(L"::"); - writer.WriteString(closureInfo->lambdaClassName); - writer.WriteString(L"("); - - FOREACH_INDEXER(WString, symbolName, index, closureInfo->symbols.Keys()) - { - if (index > 0) - { - writer.WriteString(L", "); - } - writer.WriteString(config->ConvertName(symbol->name)); - } - - FOREACH_INDEXER(ITypeDescriptor*, thisType, index, closureInfo->thisTypes) - { - if (index > 0 || closureInfo->symbols.Count() > 0) - { - writer.WriteString(L", "); - } - writer.WriteString(L" __vwsnctorthis_" + itow(index)); - } - - writer.WriteString(L"))"); - return; - } - } - writer.WriteString(config->ConvertName(symbol->name)); - } - - enum class CommaPosition - { - Left, - Right, - No, - }; - - bool IsCppRefGenericType(ITypeInfo* type) - { - switch (type->GetHint()) - { - case TypeInfoHint::Array: - case TypeInfoHint::List: - case TypeInfoHint::SortedList: - case TypeInfoHint::ObservableList: - case TypeInfoHint::Dictionary: - return true; - default: - return false; - } - } - - template - void WriteReturnValue(ITypeInfo* type, const TReturnValue& returnValueCallback, bool castReturnValue) - { - if (castReturnValue) - { - if (IsCppRefGenericType(type) || type->GetHint() == TypeInfoHint::NativeCollectionReference) - { - writer.WriteString(L"::vl::__vwsn::UnboxCollection<"); - writer.WriteString(config->ConvertType(type->GetTypeDescriptor())); - writer.WriteString(L">("); - returnValueCallback(); - writer.WriteString(L")"); - return; - } - } - returnValueCallback(); - } - - template - void WriteInvokeTemplate(vint count, ITypeInfo* returnType, const TType& typeCallback, const TInvoke& invokeCallback, const TArgument& argumentCallback, TInfo* info, bool castReturnValue) - { - if (Range(0, count).Any([&](vint index) {return IsCppRefGenericType(typeCallback(index)); })) - { - writer.WriteString(L"[&]()->decltype(auto){"); - for (vint i = 0; i < count; i++) - { - auto type = typeCallback(i); - if (IsCppRefGenericType(type)) - { - writer.WriteString(L" auto __vwsn_temp_x"); - writer.WriteString(itow(i)); - writer.WriteString(L" = ::vl::__vwsn::Box("); - argumentCallback(info, i); - writer.WriteString(L"); "); - - switch (type->GetHint()) - { - case TypeInfoHint::Array: - writer.WriteString(L"::vl::collections::Array<"); - break; - case TypeInfoHint::List: - writer.WriteString(L"::vl::collections::List<"); - break; - case TypeInfoHint::SortedList: - writer.WriteString(L"::vl::collections::SortedList<"); - break; - case TypeInfoHint::ObservableList: - writer.WriteString(L"::vl::collections::ObservableList<"); - break; - case TypeInfoHint::Dictionary: - writer.WriteString(L"::vl::collections::Dictionary<"); - break; - default:; - } - - vint count = type->GetElementType()->GetGenericArgumentCount(); - for (vint i = 0; i < count; i++) - { - if (i > 0) writer.WriteString(L", "); - writer.WriteString(config->ConvertType(type->GetElementType()->GetGenericArgument(i))); - } - writer.WriteString(L"> __vwsn_temp_"); - writer.WriteString(itow(i)); - writer.WriteString(L"; ::vl::reflection::description::UnboxParameter(__vwsn_temp_x"); - writer.WriteString(itow(i)); - writer.WriteString(L", __vwsn_temp_"); - writer.WriteString(itow(i)); - writer.WriteString(L");"); - } - else - { - writer.WriteString(L" auto __vwsn_temp_"); - writer.WriteString(itow(i)); - writer.WriteString(L" = "); - argumentCallback(info, i); - writer.WriteString(L";"); - } - } - writer.WriteString(L" return "); - WriteReturnValue(returnType, [&]() { invokeCallback(true); }, castReturnValue); - writer.WriteString(L"; }()"); - } - else - { - WriteReturnValue(returnType, [&]() { invokeCallback(false); }, castReturnValue); - } - } - - template - void WriteMethodTemplate(const WString& templateValue, IMethodInfo* methodInfo, const TThis& thisCallback, const TArgument& argumentCallback, bool castReturnValue) - { - WriteInvokeTemplate(methodInfo->GetParameterCount(), methodInfo->GetReturn(), [&](vint index) { return methodInfo->GetParameter(index)->GetType(); }, - [&](bool useTemporaryArgument) - { - WriteTemplate(templateValue, [&](const WString& item) - { - auto cp = CommaPosition::No; - vint count = methodInfo->GetParameterCount(); - - if (item == L"$Type") - { - writer.WriteString(config->ConvertType(methodInfo->GetOwnerTypeDescriptor())); - return true; - } - else if (item == L"$Func") - { - writer.WriteString(config->ConvertFunctionType(methodInfo)); - return true; - } - else if (item == L"$Name") - { - writer.WriteString(config->ConvertName(methodInfo->GetName())); - return true; - } - else if (item == L"$This") - { - if (!methodInfo->IsStatic()) - { - return thisCallback(methodInfo); - } - } - else if (item == L"$Arguments") - { - if (count == 0) - { - return true; - } - } - else if (item == L", $Arguments") - { - if (count == 0) - { - return true; - } - cp = CommaPosition::Left; - } - else if (item == L"$Arguments, ") - { - if (count == 0) - { - return true; - } - cp = CommaPosition::Right; - } - else - { - return false; - } - - if (count > 0) - { - if (cp == CommaPosition::Left) writer.WriteString(L", "); - for (vint i = 0; i < count; i++) - { - if (i > 0) writer.WriteString(L", "); - if (useTemporaryArgument) - { - writer.WriteString(L"__vwsn_temp_"); - writer.WriteString(itow(i)); - } - else - { - argumentCallback(methodInfo, i); - } - } - if (cp == CommaPosition::Right) writer.WriteString(L", "); - } - return true; - }); - }, argumentCallback, methodInfo, castReturnValue); - } - - template - void WritePropertyTemplate(const WString& templateValue, IPropertyInfo* propertyInfo, const TThis& thisCallback, bool castReturnValue) - { - WriteReturnValue(propertyInfo->GetReturn(), - [&]() - { - WriteTemplate(templateValue, [&](const WString& item) - { - if (item == L"$Type") - { - writer.WriteString(config->ConvertType(propertyInfo->GetOwnerTypeDescriptor())); - return true; - } - else if (item == L"$Name") - { - writer.WriteString(config->ConvertName(propertyInfo->GetName())); - return true; - } - else if (item == L"$This") - { - return thisCallback(propertyInfo); - } - return false; - }); - }, castReturnValue); - } - - template - void WriteEventTemplate(const WString& templateValue, IEventInfo* eventInfo, const TThis& thisCallback, const THandler& handlerCallback, const TArgument& argumentCallback) - { - auto handlerType = eventInfo->GetHandlerType()->GetElementType(); - WriteInvokeTemplate(handlerType->GetGenericArgumentCount() - 1, handlerType->GetGenericArgument(0), [&](vint index) { return handlerType->GetGenericArgument(index + 1); }, - [&](bool useTemporaryArgument) - { - WriteTemplate(templateValue, [&](const WString& item) - { - auto cp = CommaPosition::No; - vint count = eventInfo->GetHandlerType()->GetElementType()->GetGenericArgumentCount() - 1; - - if (item == L"$Name") - { - writer.WriteString(config->ConvertName(eventInfo->GetName())); - return true; - } - else if (item == L"$This") - { - return thisCallback(eventInfo); - } - else if (item == L"$Handler") - { - return handlerCallback(eventInfo); - } - else if (item == L"$Arguments") - { - if (count == 0) - { - return true; - } - } - else if (item == L", $Arguments") - { - if (count == 0) - { - return true; - } - cp = CommaPosition::Left; - } - else if (item == L"$Arguments, ") - { - if (count == 0) - { - return true; - } - cp = CommaPosition::Right; - } - else - { - return false; - } - - if (count > 0) - { - if (cp == CommaPosition::Left) writer.WriteString(L", "); - for (vint i = 0; i < count; i++) - { - if (i > 0) writer.WriteString(L", "); - if (useTemporaryArgument) - { - writer.WriteString(L"__vwsn_temp_"); - writer.WriteString(itow(i)); - } - else - { - argumentCallback(eventInfo, i); - } - } - if (cp == CommaPosition::Right) writer.WriteString(L", "); - } - return true; - }); - }, argumentCallback, eventInfo, false); - } - - template - bool WriteReferenceTemplate(ResolveExpressionResult& result, const TMethodThis& methodThis, const TPropertyThis& propertyThis, bool castReturnValue) - { - if (result.methodInfo) - { - if (CppExists(result.methodInfo)) - { - auto methodInfo = result.methodInfo; - WriteMethodTemplate(CppGetClosureTemplate(methodInfo), methodInfo, methodThis, [&](IMethodInfo*, vint){}, castReturnValue); - } - else - { - WriteNotExists(result.methodInfo); - } - return true; - } - else if (result.propertyInfo) - { - if (CppExists(result.propertyInfo)) - { - if (result.propertyInfo->GetCpp() == nullptr && result.propertyInfo->GetGetter() != nullptr) - { - auto methodInfo = result.propertyInfo->GetGetter(); - WriteMethodTemplate(CppGetInvokeTemplate(methodInfo), methodInfo, methodThis, [&](IMethodInfo*, vint){}, castReturnValue); - } - else - { - auto templateValue = CppGetReferenceTemplate(result.propertyInfo); - auto propertyInfo = result.propertyInfo; - WritePropertyTemplate(CppGetReferenceTemplate(propertyInfo), propertyInfo, propertyThis, castReturnValue); - } - } - else - { - WriteNotExists(result.propertyInfo); - } - return true; - } - else - { - return false; - } - } - - void VisitReferenceExpression(WfExpression* node, const WString& name) - { - auto result = config->manager->expressionResolvings[node]; - bool success = WriteReferenceTemplate(result, - [&](IMethodInfo* methodInfo) - { - VisitThisExpression(node, methodInfo->GetOwnerTypeDescriptor()); - return true; - }, - [&](IPropertyInfo* propertyInfo) - { - auto isRef = (propertyInfo->GetOwnerTypeDescriptor()->GetTypeDescriptorFlags() & TypeDescriptorFlags::ReferenceType) != TypeDescriptorFlags::Undefined; - VisitThisExpression(node, propertyInfo->GetOwnerTypeDescriptor()); - return true; - }, useReturnValue); - - if (!success) - { - if (result.symbol) - { - VisitSymbol(node, result.symbol, false); - } - else - { - if ((result.type->GetTypeDescriptor()->GetTypeDescriptorFlags() & TypeDescriptorFlags::EnumType) != TypeDescriptorFlags::Undefined) - { - auto enumType = result.type->GetTypeDescriptor()->GetEnumType(); - Ptr enumValueType; - if (result.type->GetDecorator() == ITypeInfo::TypeDescriptor) - { - enumValueType = result.type; - } - else - { - enumValueType = MakePtr(result.type->GetTypeDescriptor(), TypeInfoHint::Normal); - } - vint index = enumType->IndexOfItem(name); - if (index != -1) - { - ITypeInfo* types[] = { enumValueType.Obj(),result.type.Obj() }; - ConvertMultipleTypes(types, (sizeof(types) / sizeof(*types)), [=]() - { - writer.WriteString(config->ConvertType(result.type->GetTypeDescriptor())); - writer.WriteString(L"::"); - writer.WriteString(name); - }); - return; - } - } - CHECK_FAIL(L"WfGenerateExpressionVisitor::VisitReferenceExpression(WfExpression*, const WString&)#Internal error, cannot find any record of this expression."); - } - } - } - - void WriteClosureArguments(Ptr closureInfo, WfExpression* node) - { - vint index = 0; - - FOREACH(Ptr, symbol, From(closureInfo->symbols.Values()).Union(closureInfo->ctorArgumentSymbols.Values())) - { - if (index++ > 0) - { - writer.WriteString(L", "); - } - VisitSymbol(node, symbol, true); - } - - FOREACH(ITypeDescriptor*, thisType, closureInfo->thisTypes) - { - if (index++ > 0) - { - writer.WriteString(L", "); - } - VisitThisExpression(node, thisType); - } - } - - void Visit(WfThisExpression* node)override - { - auto result = config->manager->expressionResolvings[node]; - VisitThisExpression(node, result.type->GetTypeDescriptor()); - } - - void Visit(WfTopQualifiedExpression* node)override - { - VisitReferenceExpression(node, node->name.value); - } - - void Visit(WfReferenceExpression* node)override - { - VisitReferenceExpression(node, node->name.value); - } - - void Visit(WfOrderedNameExpression* node)override - { - VisitReferenceExpression(node, node->name.value); - } - - void Visit(WfOrderedLambdaExpression* node)override - { - writer.WriteString(L"LAMBDA(::"); - writer.WriteString(config->assemblyNamespace); - writer.WriteString(L"::"); - writer.WriteString(config->lambdaExprs[node]); - writer.WriteString(L"("); - - auto closureInfo = config->closureInfos[node]; - WriteClosureArguments(closureInfo, node); - - writer.WriteString(L"))"); - } - - void Visit(WfMemberExpression* node)override - { - auto result = config->manager->expressionResolvings[node]; - auto parentResult = config->manager->expressionResolvings[node->parent.Obj()]; - WriteReferenceTemplate(result, - [&](IMethodInfo* methodInfo) - { - writer.WriteString(L"::vl::__vwsn::This("); - Call(node->parent); - if (parentResult.type->GetDecorator() == ITypeInfo::SharedPtr) - { - writer.WriteString(L".Obj()"); - } - writer.WriteString(L")"); - return true; - }, - [&](IPropertyInfo* propertyInfo) - { - auto isRef = (propertyInfo->GetOwnerTypeDescriptor()->GetTypeDescriptorFlags() & TypeDescriptorFlags::ReferenceType) != TypeDescriptorFlags::Undefined; - if (isRef) writer.WriteString(L"::vl::__vwsn::This("); - Call(node->parent); - if (parentResult.type->GetDecorator() == ITypeInfo::SharedPtr) - { - writer.WriteString(L".Obj()"); - } - else if (parentResult.type->GetDecorator() == ITypeInfo::Nullable) - { - writer.WriteString(L".Value()"); - } - if (isRef) writer.WriteString(L")"); - return true; - }, useReturnValue); - } - - void Visit(WfChildExpression* node)override - { - VisitReferenceExpression(node, node->name.value); - } - - void Visit(WfLiteralExpression* node)override - { - switch (node->value) - { - case WfLiteralValue::Null: - { - auto result = config->manager->expressionResolvings[node]; - switch (result.type->GetDecorator()) - { - case ITypeInfo::Nullable: - case ITypeInfo::SharedPtr: - writer.WriteString(config->ConvertType(result.type.Obj())); - writer.WriteString(L"()"); - break; - case ITypeInfo::TypeDescriptor: - writer.WriteString(L"::vl::reflection::description::Value()"); - break; - default: - writer.WriteString(L"static_cast<"); - writer.WriteString(config->ConvertType(result.type.Obj())); - writer.WriteString(L">(nullptr)"); - } - } - break; - case WfLiteralValue::True: - writer.WriteString(L"true"); - break; - case WfLiteralValue::False: - writer.WriteString(L"false"); - break; - } - } - - void Visit(WfFloatingExpression* node)override - { - auto result = config->manager->expressionResolvings[node]; - auto td = result.type->GetTypeDescriptor(); - - writer.WriteString(L"static_cast<"); - writer.WriteString(config->ConvertType(td)); - writer.WriteString(L">("); - if (td == description::GetTypeDescriptor()) - { - writer.WriteString(node->value.value + L"f"); - } - else - { - writer.WriteString(node->value.value); - } - writer.WriteString(L")"); - } - - void Visit(WfIntegerExpression* node)override - { - auto result = config->manager->expressionResolvings[node]; - auto td = result.type->GetTypeDescriptor(); - - writer.WriteString(L"static_cast<"); - writer.WriteString(config->ConvertType(td)); - writer.WriteString(L">("); - if (td == description::GetTypeDescriptor()) - { - writer.WriteString(node->value.value + L"U"); - } - else if (td == description::GetTypeDescriptor()) - { - writer.WriteString(node->value.value + L"L"); - } - else if (td == description::GetTypeDescriptor()) - { - writer.WriteString(node->value.value + L"UL"); - } - else - { - writer.WriteString(node->value.value); - } - writer.WriteString(L")"); - } - - void Visit(WfStringExpression* node)override - { - writer.WriteString(L"::vl::WString(L\""); - for (vint i = 0; i < node->value.value.Length(); i++) - { - auto c = node->value.value[i]; - switch (c) - { - case L'\'': writer.WriteString(L"\\\'"); break; - case L'\"': writer.WriteString(L"\\\""); break; - case L'\r': writer.WriteString(L"\\r"); break; - case L'\n': writer.WriteString(L"\\n"); break; - case L'\t': writer.WriteString(L"\\t"); break; - default: writer.WriteChar(c); - } - } - writer.WriteString(L"\", false)"); - } - - void Visit(WfUnaryExpression* node)override - { - auto result = config->manager->expressionResolvings[node]; - switch (node->op) - { - case WfUnaryOperator::Positive: - writer.WriteString(L"(+ "); - Call(node->operand, result.type.Obj()); - writer.WriteString(L")"); - break; - case WfUnaryOperator::Negative: - writer.WriteString(L"(- "); - Call(node->operand, result.type.Obj()); - writer.WriteString(L")"); - break; - case WfUnaryOperator::Not: - { - if (result.type->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - writer.WriteString(L"(! "); - } - else - { - if (BinaryNeedConvert(result.type->GetTypeDescriptor())) - { - writer.WriteString(L"static_cast<"); - writer.WriteString(config->ConvertType(result.type->GetTypeDescriptor())); - writer.WriteString(L">"); - } - writer.WriteString(L"(~ "); - } - Call(node->operand, result.type.Obj()); - writer.WriteString(L")"); - } - break; - } - } - - void VisitBinaryExpression(WfBinaryExpression* node, const wchar_t* op, ITypeDescriptor* resultType, ITypeInfo* operandType) - { - if (resultType) - { - writer.WriteString(L"static_cast<"); - writer.WriteString(config->ConvertType(resultType)); - writer.WriteString(L">"); - } - writer.WriteString(L"("); - Call(node->first, operandType); - writer.WriteString(L" "); - writer.WriteString(op); - writer.WriteString(L" "); - Call(node->second, operandType); - writer.WriteString(L")"); - } - - bool BinaryNeedConvert(ITypeDescriptor* type) - { - return type == description::GetTypeDescriptor() - || type == description::GetTypeDescriptor() - || type == description::GetTypeDescriptor() - || type == description::GetTypeDescriptor() - ; - } - - void Visit(WfBinaryExpression* node)override - { - if (node->op == WfBinaryOperator::Assign) - { - auto result = config->manager->expressionResolvings[node->first.Obj()]; - if (result.propertyInfo) - { - auto propInfo = result.propertyInfo; - auto member = node->first.Cast(); - - if (CppExists(propInfo)) - { - if (propInfo->GetCpp() == nullptr && propInfo->GetSetter() != nullptr) - { - WriteMethodTemplate(CppGetInvokeTemplate(propInfo->GetSetter()), propInfo->GetSetter(), - [&](IMethodInfo*) - { - if (member) - { - writer.WriteString(L"::vl::__vwsn::This("); - Call(member->parent); - auto parentResult = config->manager->expressionResolvings[member->parent.Obj()]; - if (parentResult.type->GetDecorator() == ITypeInfo::SharedPtr) - { - writer.WriteString(L".Obj()"); - } - writer.WriteString(L")"); - } - else - { - VisitThisExpression(node->first.Obj(), propInfo->GetOwnerTypeDescriptor()); - } - return true; - }, - [&](IMethodInfo*, vint index) - { - Call(node->second); - }, useReturnValue); - } - else - { - writer.WriteString(L"("); - WritePropertyTemplate(CppGetReferenceTemplate(propInfo), propInfo, - [&](IPropertyInfo*) - { - if (member) - { - writer.WriteString(L"::vl::__vwsn::This("); - Call(member->parent); - auto parentResult = config->manager->expressionResolvings[member->parent.Obj()]; - if (parentResult.type->GetDecorator() == ITypeInfo::SharedPtr) - { - writer.WriteString(L".Obj()"); - } - writer.WriteString(L")"); - } - else - { - VisitThisExpression(node->first.Obj(), propInfo->GetOwnerTypeDescriptor()); - } - return true; - }, true); - writer.WriteString(L" = "); - Call(node->second, propInfo->GetReturn()); - writer.WriteString(L")"); - } - } - else - { - WriteNotExists(propInfo); - } - } - else if (auto binary = node->first.Cast()) - { - auto containerType = config->manager->expressionResolvings[binary->first.Obj()].type.Obj(); - if (IsCppRefGenericType(containerType)) - { - Call(binary->first, nullptr, false); - writer.WriteString(L".Set("); - Call(binary->second); - writer.WriteString(L", "); - Call(node->second); - writer.WriteString(L")"); - } - else - { - auto keyType = config->manager->expressionResolvings[binary->second.Obj()].type.Obj(); - auto valueType = config->manager->expressionResolvings[node->second.Obj()].type.Obj(); - writer.WriteString(L"::vl::__vwsn::This("); - Call(binary->first); - writer.WriteString(L".Obj())->Set("); - if (containerType->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - WriteBoxValue(keyType, [&]() {Call(binary->second); }); - } - else - { - Call(binary->second); - } - writer.WriteString(L", "); - WriteBoxValue(valueType, [&]() {Call(node->second); }); - writer.WriteString(L")"); - } - } - else - { - VisitBinaryExpression(node, L"=", nullptr, nullptr); - } - } - else if (node->op == WfBinaryOperator::Index) - { - auto containerType = config->manager->expressionResolvings[node->first.Obj()].type.Obj(); - if (IsCppRefGenericType(containerType)) - { - Call(node->first, nullptr, false); - writer.WriteString(L"["); - Call(node->second); - writer.WriteString(L"]"); - } - else - { - auto keyType = config->manager->expressionResolvings[node->second.Obj()].type.Obj(); - auto valueType = config->manager->expressionResolvings[node].type.Obj(); - WriteUnboxValue(valueType, [&]() - { - writer.WriteString(L"::vl::__vwsn::This("); - Call(node->first); - writer.WriteString(L".Obj())->Get("); - if (containerType->GetTypeDescriptor()->CanConvertTo(description::GetTypeDescriptor())) - { - WriteBoxValue(keyType, [&]() {Call(node->second); }); - } - else - { - Call(node->second); - } - writer.WriteString(L")"); - }); - } - } - else if (node->op == WfBinaryOperator::Union) - { - auto type = config->manager->expressionResolvings[node].type; - if (type->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - VisitBinaryExpression(node, L"+", nullptr, type.Obj()); - } - else - { - VisitBinaryExpression(node, L"&", nullptr, nullptr); - } - } - else if (node->op == WfBinaryOperator::Intersect) - { - VisitBinaryExpression(node, L"|", nullptr, nullptr); - } - else if (node->op == WfBinaryOperator::FailedThen) - { - auto firstResult = config->manager->expressionResolvings[node->first.Obj()]; - auto secondResult = config->manager->expressionResolvings[node->second.Obj()]; - auto mergedType = GetMergedType(firstResult.type, secondResult.type); - - writer.WriteString(L"[&](){ try{ return "); - Call(node->first, mergedType.Obj()); - writer.WriteString(L"; } catch(...){ return "); - Call(node->second, mergedType.Obj()); - writer.WriteString(L"; } }()"); - } - else - { - auto result = config->manager->expressionResolvings[node]; - auto firstResult = config->manager->expressionResolvings[node->first.Obj()]; - auto secondResult = config->manager->expressionResolvings[node->second.Obj()]; - auto mergedType = GetMergedType(firstResult.type, secondResult.type); - - switch (node->op) - { - case WfBinaryOperator::Exp: - writer.WriteString(L"static_cast<"); - writer.WriteString(config->ConvertType(result.type->GetTypeDescriptor())); - writer.WriteString(L">(pow(static_cast("); - Call(node->first); - writer.WriteString(L"), static_cast("); - Call(node->second); - writer.WriteString(L")))"); - return; - case WfBinaryOperator::Add: - case WfBinaryOperator::Sub: - case WfBinaryOperator::Mul: - case WfBinaryOperator::Div: - case WfBinaryOperator::Mod: - case WfBinaryOperator::Shl: - case WfBinaryOperator::Shr: - { - const wchar_t* op = nullptr; - switch (node->op) - { - case WfBinaryOperator::Add: op = L"+"; break; - case WfBinaryOperator::Sub: op = L"-"; break; - case WfBinaryOperator::Mul: op = L"*"; break; - case WfBinaryOperator::Div: op = L"/"; break; - case WfBinaryOperator::Mod: op = L"%"; break; - case WfBinaryOperator::Shl: op = L"<<"; break; - case WfBinaryOperator::Shr: op = L">>"; break; - default:; - } - VisitBinaryExpression(node, op, (BinaryNeedConvert(result.type->GetTypeDescriptor()) ? result.type->GetTypeDescriptor() : nullptr), result.type.Obj()); - } - return; - case WfBinaryOperator::EQ: - case WfBinaryOperator::NE: - { - if (firstResult.type->GetDecorator() == ITypeInfo::RawPtr || firstResult.type->GetDecorator() == ITypeInfo::SharedPtr) - { - auto td = mergedType->GetTypeDescriptor(); - auto tdFirst = firstResult.type->GetTypeDescriptor(); - auto tdSecond = secondResult.type->GetTypeDescriptor(); - auto dFirst = firstResult.type->GetDecorator(); - auto dSecond = secondResult.type->GetDecorator(); - - writer.WriteString(L"("); - - if (td != tdFirst) - { - writer.WriteString(L"static_cast<"); - writer.WriteString(config->ConvertType(tdFirst)); - writer.WriteString(L"*>("); - } - Call(node->first); - if (dFirst == ITypeInfo::SharedPtr) - { - writer.WriteString(L".Obj()"); - } - if (td != tdFirst) - { - writer.WriteString(L")"); - } - - if (node->op == WfBinaryOperator::EQ) - { - writer.WriteString(L" == "); - } - else - { - writer.WriteString(L" != "); - } - - if (td != tdSecond) - { - writer.WriteString(L"static_cast<"); - writer.WriteString(config->ConvertType(tdSecond)); - writer.WriteString(L"*>("); - } - Call(node->second); - if (dSecond == ITypeInfo::SharedPtr) - { - writer.WriteString(L".Obj()"); - } - if (td != tdSecond) - { - writer.WriteString(L")"); - } - - writer.WriteString(L")"); - return; - } - } - case WfBinaryOperator::LT: - case WfBinaryOperator::GT: - case WfBinaryOperator::LE: - case WfBinaryOperator::GE: - { - const wchar_t* op = nullptr; - switch (node->op) - { - case WfBinaryOperator::LT: op = L"<"; break; - case WfBinaryOperator::GT: op = L">"; break; - case WfBinaryOperator::LE: op = L"<="; break; - case WfBinaryOperator::GE: op = L">="; break; - case WfBinaryOperator::EQ: op = L"=="; break; - case WfBinaryOperator::NE: op = L"!="; break; - default:; - } - VisitBinaryExpression(node, op, nullptr, mergedType.Obj()); - } - return; - case WfBinaryOperator::Xor: - case WfBinaryOperator::And: - case WfBinaryOperator::Or: - { - auto td = result.type->GetTypeDescriptor(); - const wchar_t* op = nullptr; - if (td == description::GetTypeDescriptor()) - { - switch (node->op) - { - case WfBinaryOperator::Xor: op = L"^"; break; - case WfBinaryOperator::And: op = L"&&"; break; - case WfBinaryOperator::Or: op = L"||"; break; - default:; - } - if (node->op != WfBinaryOperator::Xor) - { - td = nullptr; - } - } - else - { - switch (node->op) - { - case WfBinaryOperator::Xor: op = L"^"; break; - case WfBinaryOperator::And: op = L"&"; break; - case WfBinaryOperator::Or: op = L"|"; break; - default:; - } - if (!BinaryNeedConvert(td)) - { - td = nullptr; - } - } - VisitBinaryExpression(node, op, td, result.type.Obj()); - } - return; - default:; - } - } - } - - void Visit(WfLetExpression* node)override - { - auto scope = config->manager->nodeScopes[node]; - writer.WriteString(L"[&]("); - FOREACH_INDEXER(Ptr, letVar, index, node->variables) - { - if (index > 0) - { - writer.WriteString(L", "); - } - writer.WriteString(L"auto "); - writer.WriteString(config->ConvertName(letVar->name.value)); - } - writer.WriteString(L"){ return "); - Call(node->expression); - writer.WriteString(L"; }("); - FOREACH_INDEXER(Ptr, letVar, index, node->variables) - { - if (index > 0) - { - writer.WriteString(L", "); - } - auto symbol = scope->symbols[letVar->name.value][0]; - Call(letVar->value, symbol->typeInfo.Obj()); - } - writer.WriteString(L")"); - } - - void Visit(WfIfExpression* node)override - { - auto firstResult = config->manager->expressionResolvings[node->trueBranch.Obj()]; - auto secondResult = config->manager->expressionResolvings[node->falseBranch.Obj()]; - auto mergedType = GetMergedType(firstResult.type, secondResult.type); - - writer.WriteString(L"("); - Call(node->condition); - writer.WriteString(L" ? "); - Call(node->trueBranch, mergedType.Obj()); - writer.WriteString(L" : "); - Call(node->falseBranch, mergedType.Obj()); - writer.WriteString(L")"); - } - - void Visit(WfRangeExpression* node)override - { - auto result = config->manager->expressionResolvings[node]; - auto elementType = result.type->GetElementType()->GetGenericArgument(0); - - writer.WriteString(L"::vl::__vwsn::Range("); - Call(node->begin, elementType); - if (node->beginBoundary == WfRangeBoundary::Exclusive) - { - writer.WriteString(L" + 1"); - } - writer.WriteString(L", "); - Call(node->end, elementType); - if (node->endBoundary == WfRangeBoundary::Inclusive) - { - writer.WriteString(L" + 1"); - } - writer.WriteString(L")"); - } - - void Visit(WfSetTestingExpression* node)override - { - if (auto range = node->collection.Cast()) - { - auto resultElement = config->manager->expressionResolvings[node->element.Obj()]; - auto resultBegin = config->manager->expressionResolvings[range->begin.Obj()]; - auto resultEnd = config->manager->expressionResolvings[range->end.Obj()]; - - writer.WriteString(L"[&](auto __vwsn_1){ return "); - if (node->test == WfSetTesting::NotIn) - { - writer.WriteString(L"!"); - } - writer.WriteString(L"("); - - Call(range->begin); - writer.WriteString(range->beginBoundary == WfRangeBoundary::Inclusive ? L" <= " : L" < "); - writer.WriteString(L" __vwsn_1 && __vwsn_1"); - writer.WriteString(range->endBoundary == WfRangeBoundary::Inclusive ? L" <= " : L" < "); - Call(range->end); - - writer.WriteString(L"); }("); - Call(node->element, resultElement.type.Obj()); - writer.WriteString(L")"); - } - else - { - auto result = config->manager->expressionResolvings[node->collection.Obj()]; - auto elementType = result.type->GetElementType()->GetGenericArgument(0); - - if (node->test == WfSetTesting::NotIn) - { - writer.WriteString(L"(! "); - } - - writer.WriteString(L"::vl::__vwsn::InSet("); - Call(node->element, elementType); - writer.WriteString(L", "); - Call(node->collection); - writer.WriteString(L")"); - - if (node->test == WfSetTesting::NotIn) - { - writer.WriteString(L")"); - } - } - } - - void Visit(WfConstructorExpression* node)override - { - auto result = config->manager->expressionResolvings[node]; - auto td = result.type->GetTypeDescriptor(); - if (node->arguments.Count() == 0) - { - if ((td->GetTypeDescriptorFlags() & TypeDescriptorFlags::StructType) != TypeDescriptorFlags::Undefined) - { - writer.WriteString(config->ConvertType(result.type.Obj()) + L"{}"); - } - else - { - writer.WriteString(config->ConvertType(td) + L"::Create()"); - } - } - else - { - if (result.type->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - auto elementType = result.type->GetElementType()->GetGenericArgument(0); - writer.WriteString(L"(::vl::__vwsn::CreateList()"); - - FOREACH(Ptr, argument, node->arguments) - { - writer.WriteString(L".Add("); - Call(argument->key); - writer.WriteString(L")"); - } - - writer.WriteString(L").list"); - } - else if (result.type->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - auto elementType = result.type->GetElementType()->GetGenericArgument(0); - writer.WriteString(L"(::vl::__vwsn::CreateObservableList()"); - - FOREACH(Ptr, argument, node->arguments) - { - writer.WriteString(L".Add("); - Call(argument->key); - writer.WriteString(L")"); - } - - writer.WriteString(L").list"); - } - else if (result.type->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - auto keyType = result.type->GetElementType()->GetGenericArgument(0); - auto valueType = result.type->GetElementType()->GetGenericArgument(1); - writer.WriteString(L"(::vl::__vwsn::CreateDictionary()"); - - FOREACH(Ptr, argument, node->arguments) - { - writer.WriteString(L".Add("); - Call(argument->key); - writer.WriteString(L", "); - Call(argument->value); - writer.WriteString(L")"); - } - - writer.WriteString(L").dictionary"); - } - else - { - writer.WriteString(L"[&](){ "); - writer.WriteString(config->ConvertType(td)); - writer.WriteString(L" __vwsn_temp__;"); - - FOREACH(Ptr, argument, node->arguments) - { - writer.WriteString(L" __vwsn_temp__."); - writer.WriteString(argument->key.Cast()->name.value); - writer.WriteString(L" = "); - Call(argument->value); - writer.WriteString(L";"); - } - - writer.WriteString(L" return __vwsn_temp__; }()"); - } - } - } - - void Visit(WfInferExpression* node)override - { - Call(node->expression); - } - - void Visit(WfTypeCastingExpression* node)override - { - auto scope = config->manager->nodeScopes[node].Obj(); - auto typeInfo = CreateTypeInfoFromType(scope, node->type); - bool strongCast = node->strategy == WfTypeCastingStrategy::Strong; - auto result = config->manager->expressionResolvings[node->expression.Obj()]; - ConvertType(config, writer, result.type.Obj(), typeInfo.Obj(), [&]() {Call(node->expression); }, strongCast); - } - - void Visit(WfTypeTestingExpression* node)override - { - auto result = config->manager->expressionResolvings[node->expression.Obj()]; - Ptr type; - if (node->type) - { - auto scope = config->manager->nodeScopes[node].Obj(); - type = CreateTypeInfoFromType(scope, node->type); - } - - switch (result.type->GetDecorator()) - { - case ITypeInfo::RawPtr: - { - switch (node->test) - { - case WfTypeTesting::IsNull: - writer.WriteString(L"("); - Call(node->expression); - writer.WriteString(L" == nullptr)"); - break; - case WfTypeTesting::IsNotNull: - writer.WriteString(L"("); - Call(node->expression); - writer.WriteString(L" != nullptr)"); - break; - case WfTypeTesting::IsType: - case WfTypeTesting::IsNotType: - if (type->GetDecorator() != ITypeInfo::RawPtr) - { - writer.WriteString(node->test == WfTypeTesting::IsType ? L"false" : L"true"); - } - else - { - writer.WriteString(L"(::vl::__vwsn::RawPtrCast<"); - writer.WriteString(config->ConvertType(type->GetTypeDescriptor())); - writer.WriteString(L">("); - Call(node->expression); - writer.WriteString(L") "); - writer.WriteString(node->test == WfTypeTesting::IsType ? L"!=" : L"=="); - writer.WriteString(L" nullptr)"); - } - break; - } - } - break; - case ITypeInfo::SharedPtr: - { - if (result.type->GetElementType()->GetDecorator() == ITypeInfo::Generic) - { - auto toCode = [&]() - { - stream::MemoryStream stream; - { - stream::StreamWriter writer(stream); - WfPrint(node, WString::Empty, writer); - } - stream.SeekFromBegin(0); - { - stream::StreamReader reader(stream); - return reader.ReadToEnd(); - } - }; - - if (config->IsSpecialGenericType(result.type.Obj())) - { - writer.WriteString(L"/* NOT SUPPORTS: testing against non-reference generic type: "); - writer.WriteString(toCode()); - writer.WriteString(L" */ __vwsn_not_exists__"); - return; - } - } - switch (node->test) - { - case WfTypeTesting::IsNull: - writer.WriteString(L"(! static_cast("); - Call(node->expression); - writer.WriteString(L"))"); - break; - case WfTypeTesting::IsNotNull: - writer.WriteString(L"static_cast("); - Call(node->expression); - writer.WriteString(L")"); - break; - case WfTypeTesting::IsType: - case WfTypeTesting::IsNotType: - if (type->GetDecorator() != ITypeInfo::SharedPtr) - { - writer.WriteString(node->test == WfTypeTesting::IsType ? L"false" : L"true"); - } - else - { - writer.WriteString(L"(::vl::__vwsn::RawPtrCast<"); - writer.WriteString(config->ConvertType(type->GetTypeDescriptor())); - writer.WriteString(L">("); - Call(node->expression); - writer.WriteString(L".Obj()) "); - writer.WriteString(node->test == WfTypeTesting::IsType ? L"!=" : L"=="); - writer.WriteString(L" nullptr)"); - } - break; - } - } - break; - case ITypeInfo::Nullable: - { - switch (node->test) - { - case WfTypeTesting::IsNull: - writer.WriteString(L"(! static_cast("); - Call(node->expression); - writer.WriteString(L"))"); - break; - case WfTypeTesting::IsNotNull: - writer.WriteString(L"static_cast("); - Call(node->expression); - writer.WriteString(L")"); - break; - case WfTypeTesting::IsType: - if (type->GetTypeDescriptor() == result.type->GetTypeDescriptor()) - { - writer.WriteString(L"static_cast("); - Call(node->expression); - writer.WriteString(L")"); - } - else - { - writer.WriteString(L"false"); - } - break; - case WfTypeTesting::IsNotType: - if (type->GetTypeDescriptor() == result.type->GetTypeDescriptor()) - { - writer.WriteString(L"false"); - } - else - { - writer.WriteString(L"true"); - } - break; - } - } - break; - case ITypeInfo::TypeDescriptor: - { - if (result.type->GetTypeDescriptor()->GetTypeDescriptorFlags() == TypeDescriptorFlags::Object) - { - switch (node->test) - { - case WfTypeTesting::IsNull: - Call(node->expression); - writer.WriteString(L".IsNull()"); - break; - case WfTypeTesting::IsNotNull: - writer.WriteString(L"(! "); - Call(node->expression); - writer.WriteString(L".IsNull())"); - break; - case WfTypeTesting::IsType: - case WfTypeTesting::IsNotType: - if ((type->GetTypeDescriptor()->GetTypeDescriptorFlags() & TypeDescriptorFlags::ReferenceType) != TypeDescriptorFlags::Undefined) - { - writer.WriteString(L"[&](){ auto __vwsn_temp__ = "); - Call(node->expression); - writer.WriteString(L"; return "); - if ((type->GetDecorator() == ITypeInfo::RawPtr) == (node->test == WfTypeTesting::IsType)) - { - writer.WriteString(L"!"); - } - writer.WriteString(L"__vwsn_temp__.GetSharedPtr() "); - writer.WriteString(node->test == WfTypeTesting::IsType ? L"&&" : L"||"); - writer.WriteString(L" ::vl::__vwsn::RawPtrCast<"); - writer.WriteString(config->ConvertType(type->GetTypeDescriptor())); - writer.WriteString(L">(__vwsn_temp__.GetRawPtr()) "); - writer.WriteString(node->test == WfTypeTesting::IsType ? L"!=" : L"=="); - writer.WriteString(L" nullptr; }()"); - } - else - { - writer.WriteString(L"(dynamic_cast<::vl::reflection::description::IValueType::TypedBox<"); - writer.WriteString(config->ConvertType(type->GetTypeDescriptor())); - writer.WriteString(L">*>("); - Call(node->expression); - writer.WriteString(L".GetBoxedValue().Obj()) "); - writer.WriteString(node->test == WfTypeTesting::IsType ? L"!=" : L"=="); - writer.WriteString(L" nullptr)"); - } - break; - } - } - else if ((type->GetTypeDescriptor() == result.type->GetTypeDescriptor()) == (node->test == WfTypeTesting::IsType)) - { - writer.WriteString(L"true"); - } - else - { - writer.WriteString(L"false"); - } - } - break; - default:; - } - } - - void Visit(WfTypeOfTypeExpression* node)override - { - writer.WriteString(L"/* NOT SUPPORTS: typeof() */ __vwsn_not_exists__"); - } - - void Visit(WfTypeOfExpressionExpression* node)override - { - writer.WriteString(L"/* NOT SUPPORTS: type() */ __vwsn_not_exists__"); - } - - void Visit(WfAttachEventExpression* node)override - { - auto result = config->manager->expressionResolvings[node->event.Obj()]; - if (CppExists(result.eventInfo)) - { - WriteEventTemplate(CppGetAttachTemplate(result.eventInfo), result.eventInfo, - [&](IEventInfo*) - { - writer.WriteString(L"::vl::__vwsn::This("); - if (auto member = node->event.Cast()) - { - Call(member->parent); - auto parentResult = config->manager->expressionResolvings[member->parent.Obj()]; - if (parentResult.type->GetDecorator() == ITypeInfo::SharedPtr) - { - writer.WriteString(L".Obj()"); - } - } - else - { - VisitThisExpression(node, result.eventInfo->GetOwnerTypeDescriptor()); - } - writer.WriteString(L")"); - return true; - }, - [&](IEventInfo*) - { - Call(node->function); - return true; - }, - [&](IEventInfo*, vint) {}); - } - else - { - WriteNotExists(result.eventInfo); - } - } - - void Visit(WfDetachEventExpression* node)override - { - auto result = config->manager->expressionResolvings[node->event.Obj()]; - if (CppExists(result.eventInfo)) - { - WriteEventTemplate(CppGetDetachTemplate(result.eventInfo), result.eventInfo, - [&](IEventInfo* eventInfo) - { - writer.WriteString(L"::vl::__vwsn::This("); - if (auto member = node->event.Cast()) - { - Call(member->parent); - auto parentResult = config->manager->expressionResolvings[member->parent.Obj()]; - if (parentResult.type->GetDecorator() == ITypeInfo::SharedPtr) - { - writer.WriteString(L".Obj()"); - } - } - else - { - VisitThisExpression(node, eventInfo->GetOwnerTypeDescriptor()); - } - writer.WriteString(L")"); - return true; - }, - [&](IEventInfo*) - { - Call(node->handler); - return true; - }, - [&](IEventInfo*, vint) {}); - } - else - { - WriteNotExists(result.eventInfo); - } - } - - void Visit(WfObserveExpression* node)override - { - } - - void Visit(WfCallExpression* node)override - { - auto thisCallback = [&](ITypeDescriptor* td) - { - if (auto member = node->function.Cast()) - { - writer.WriteString(L"::vl::__vwsn::This("); - Call(member->parent); - auto parentResult = config->manager->expressionResolvings[member->parent.Obj()]; - if (parentResult.type->GetDecorator() == ITypeInfo::SharedPtr) - { - writer.WriteString(L".Obj()"); - } - writer.WriteString(L")"); - } - else - { - VisitThisExpression(node, td); - } - return true; - }; - - auto argumentCallback = [&](IMethodInfo* methodInfo, ITypeInfo* typeInfo, vint index) - { - auto type = methodInfo - ? methodInfo->GetParameter(index)->GetType() - : typeInfo->GetElementType()->GetGenericArgument(index + 1) - ; - Call(node->arguments[index], type); - }; - - auto result = config->manager->expressionResolvings[node->function.Obj()]; - if (result.methodInfo) - { - WriteMethodTemplate(CppGetInvokeTemplate(result.methodInfo), result.methodInfo, - [&](IMethodInfo* methodInfo) { return thisCallback(methodInfo->GetOwnerTypeDescriptor()); }, - [&](IMethodInfo* methodInfo, vint index) { return argumentCallback(methodInfo, nullptr, index); }, - useReturnValue); - return; - } - else if (result.eventInfo) - { - WriteEventTemplate(CppGetInvokeTemplate(result.eventInfo), result.eventInfo, - [&](IEventInfo* eventInfo) { return thisCallback(eventInfo->GetOwnerTypeDescriptor()); }, - [&](IEventInfo*) { return false; }, - [&](IEventInfo* eventInfo, vint index) { return argumentCallback(nullptr, eventInfo->GetHandlerType(), index); } - ); - return; - } - else if (result.symbol) - { - if (auto funcDecl = result.symbol->creatorNode.Cast()) - { - if (result.symbol->ownerScope->ownerNode.Cast()) - { - writer.WriteString(L"this->"); - writer.WriteString(config->ConvertName(result.symbol->name)); - } - else if (result.symbol->ownerScope->functionConfig && result.symbol->ownerScope->functionConfig->lambda && result.symbol->name == funcDecl->name.value) - { - writer.WriteString(L"(*this)"); - } - else - { - writer.WriteString(L"GLOBAL_NAME "); - writer.WriteString(config->ConvertName(result.symbol->name)); - } - writer.WriteString(L"("); - for (vint i = 0; i < node->arguments.Count(); i++) - { - if (i > 0) writer.WriteString(L", "); - argumentCallback(nullptr, result.symbol->typeInfo.Obj(), i); - } - writer.WriteString(L")"); - return; - } - } - Call(node->function); - writer.WriteString(L"("); - for (vint i = 0; i < node->arguments.Count(); i++) - { - if (i > 0) writer.WriteString(L", "); - argumentCallback(nullptr, result.type.Obj(), i); - } - writer.WriteString(L")"); - } - - void Visit(WfFunctionExpression* node)override - { - writer.WriteString(L"LAMBDA(::"); - writer.WriteString(config->assemblyNamespace); - writer.WriteString(L"::"); - writer.WriteString(config->lambdaExprs[node]); - writer.WriteString(L"("); - - auto closureInfo = config->closureInfos[node]; - WriteClosureArguments(closureInfo, node); - - writer.WriteString(L"))"); - } - - void Visit(WfNewClassExpression* node)override - { - auto result = config->manager->expressionResolvings[node]; - auto ctor = result.constructorInfo; - - if (ctor->GetReturn()->GetDecorator() == ITypeInfo::SharedPtr) - { - writer.WriteString(L"::vl::Ptr<"); - writer.WriteString(config->ConvertType(ctor->GetReturn()->GetTypeDescriptor())); - writer.WriteString(L">("); - } - - WriteMethodTemplate(CppGetInvokeTemplate(ctor), ctor, [&](IMethodInfo*) { return false; }, - [&](IMethodInfo*, vint index) - { - Call(node->arguments[index]); - }, useReturnValue); - - if (ctor->GetReturn()->GetDecorator() == ITypeInfo::SharedPtr) - { - writer.WriteString(L")"); - } - } - - void Visit(WfNewInterfaceExpression* node)override - { - auto result = config->manager->expressionResolvings[node]; - auto ctor = result.constructorInfo; - - if (ctor->GetReturn()->GetDecorator() == ITypeInfo::SharedPtr) - { - writer.WriteString(L"::vl::Ptr<"); - writer.WriteString(config->ConvertType(ctor->GetReturn()->GetTypeDescriptor())); - writer.WriteString(L">("); - } - else - { - writer.WriteString(L"static_cast<"); - writer.WriteString(config->ConvertType(ctor->GetReturn()->GetTypeDescriptor())); - writer.WriteString(L"*>("); - } - - writer.WriteString(L"new ::"); - writer.WriteString(config->assemblyNamespace); - writer.WriteString(L"::"); - writer.WriteString(config->classExprs[node]); - writer.WriteString(L"("); - - auto closureInfo = config->closureInfos[node]; - WriteClosureArguments(closureInfo, node); - - writer.WriteString(L"))"); - } - - void Visit(WfVirtualExpression* node)override - { - Call(node->expandedExpression); - } - }; - - void GenerateExpression(WfCppConfig* config, stream::StreamWriter& writer, Ptr node, reflection::description::ITypeInfo* expectedType, bool useReturnValue) - { - WfGenerateExpressionVisitor visitor(config, writer, useReturnValue); - if (useReturnValue) - { - auto result = config->manager->expressionResolvings[node.Obj()]; - ITypeInfo* types[] = { result.type.Obj(), result.expectedType.Obj(), expectedType }; - visitor.ConvertMultipleTypes(types, sizeof(types) / sizeof(*types), [&]() - { - node->Accept(&visitor); - }); - } - else - { - node->Accept(&visitor); - } - } - } - } -} - -/*********************************************************************** -CPP\WFCPP_FILE.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace cppcodegen - { - using namespace collections; - - void WfCppConfig::WritePushCompileOptions(stream::StreamWriter& writer) - { - writer.WriteLine(L"#if defined( _MSC_VER)"); - writer.WriteLine(L"#pragma warning(push)"); - writer.WriteLine(L"#pragma warning(disable:4250)"); - writer.WriteLine(L"#elif defined(__GNUC__)"); - writer.WriteLine(L"#pragma GCC diagnostic push"); - writer.WriteLine(L"#pragma GCC diagnostic ignored \"-Wparentheses-equality\""); - writer.WriteLine(L"#elif defined(__clang__)"); - writer.WriteLine(L"#pragma clang diagnostic push"); - writer.WriteLine(L"#pragma clang diagnostic ignored \"-Wparentheses-equality\""); - writer.WriteLine(L"#endif"); - } - - void WfCppConfig::WritePopCompileOptions(stream::StreamWriter& writer) - { - writer.WriteLine(L"#if defined( _MSC_VER)"); - writer.WriteLine(L"#pragma warning(pop)"); - writer.WriteLine(L"#elif defined(__GNUC__)"); - writer.WriteLine(L"#pragma GCC diagnostic pop"); - writer.WriteLine(L"#elif defined(__clang__)"); - writer.WriteLine(L"#pragma clang diagnostic pop"); - writer.WriteLine(L"#endif"); - } - - void WfCppConfig::WriteCpp_PushMacros(stream::StreamWriter& writer) - { - writer.WriteString(L"#define GLOBAL_SYMBOL "); - writer.WriteString(L"::"); - writer.WriteString(assemblyNamespace); - writer.WriteString(L"::"); - writer.WriteString(assemblyName); - writer.WriteLine(L"::"); - - writer.WriteString(L"#define GLOBAL_NAME "); - writer.WriteString(L"::"); - writer.WriteString(assemblyNamespace); - writer.WriteString(L"::"); - writer.WriteString(assemblyName); - writer.WriteLine(L"::Instance()."); - - writer.WriteString(L"#define GLOBAL_OBJ "); - writer.WriteString(L"&::"); - writer.WriteString(assemblyNamespace); - writer.WriteString(L"::"); - writer.WriteString(assemblyName); - writer.WriteLine(L"::Instance()"); - - writer.WriteLine(L"#define USERIMPL(...)"); - } - - void WfCppConfig::WriteCpp_PopMacros(stream::StreamWriter& writer) - { - writer.WriteLine(L"#undef GLOBAL_SYMBOL"); - writer.WriteLine(L"#undef GLOBAL_NAME"); - writer.WriteLine(L"#undef GLOBAL_OBJ"); - writer.WriteLine(L"#undef USERIMPL"); - } - - void WfCppConfig::WriteHeader(stream::StreamWriter& writer, bool multiFile) - { - WritePushCompileOptions(writer); - writer.WriteLine(L""); - - { - Dictionary> reversedLambdaExprs; - Dictionary> reversedClassExprs; - SortClosure(reversedLambdaExprs, reversedClassExprs); - - if (reversedLambdaExprs.Count() + reversedClassExprs.Count() > 0) - { - writer.WriteString(L"namespace "); - writer.WriteLine(assemblyNamespace); - writer.WriteLine(L"{"); - - FOREACH(Ptr, expr, reversedLambdaExprs.Values()) - { - WriteHeader_ClosurePreDecl(writer, expr); - } - - FOREACH(Ptr, expr, reversedClassExprs.Values()) - { - WriteHeader_ClosurePreDecl(writer, expr); - } - - writer.WriteLine(L"}"); - writer.WriteLine(L""); - } - } - - List nss; - - if (enumDecls.Keys().Contains(nullptr)) - { - FOREACH(Ptr, decl, enumDecls[nullptr]) - { - WriteHeader_Enum(writer, decl, nss); - writer.WriteLine(L""); - } - } - - if (structDecls.Keys().Contains(nullptr)) - { - FOREACH(Ptr, decl, structDecls[nullptr]) - { - WriteHeader_Struct(writer, decl, nss); - writer.WriteLine(L""); - } - } - - if (classDecls.Keys().Contains(nullptr)) - { - FOREACH(Ptr, decl, classDecls[nullptr]) - { - WriteHeader_ClassPreDecl(writer, decl, nss); - } - writer.WriteLine(L""); - if (multiFile) - { - vint index = topLevelClassDeclsForFiles.Keys().IndexOf(L""); - if (index != -1) - { - FOREACH(Ptr, decl, topLevelClassDeclsForFiles.GetByIndex(index)) - { - WriteHeader_TopLevelClass(writer, decl, nss); - writer.WriteLine(L""); - } - } - } - else - { - FOREACH(Ptr, decl, classDecls[nullptr]) - { - WriteHeader_TopLevelClass(writer, decl, nss); - writer.WriteLine(L""); - } - } - } - WriteNamespaceEnd(writer, nss); - - WriteHeader_Global(writer); - - if (!multiFile) - { - if (manager->declarationTypes.Count() > 0) - { - writer.WriteLine(L""); - WriteHeader_Reflection(writer); - } - } - - writer.WriteLine(L""); - WritePopCompileOptions(writer); - } - - void WfCppConfig::WriteCpp(stream::StreamWriter& writer, bool multiFile) - { - WritePushCompileOptions(writer); - writer.WriteLine(L""); - WriteCpp_PushMacros(writer); - - writer.WriteLine(L""); - WriteCpp_Global(writer); - writer.WriteLine(L""); - - if (classDecls.Keys().Contains(nullptr)) - { - List nss; - - if (multiFile) - { - vint index = topLevelClassDeclsForFiles.Keys().IndexOf(L""); - if (index != -1) - { - FOREACH(Ptr, decl, topLevelClassDeclsForFiles.GetByIndex(index)) - { - WriteCpp_Class(writer, decl, nss); - } - } - } - else - { - FOREACH(Ptr, decl, classDecls[nullptr]) - { - WriteCpp_Class(writer, decl, nss); - } - } - - WriteNamespaceEnd(writer, nss); - } - - WriteCpp_PopMacros(writer); - - if (manager->declarationTypes.Count() > 0) - { - writer.WriteLine(L""); - WriteCpp_Reflection(writer); - } - - writer.WriteLine(L""); - WritePopCompileOptions(writer); - } - - void WfCppConfig::WriteSubHeader(stream::StreamWriter& writer, const WString& fileName) - { - WritePushCompileOptions(writer); - writer.WriteLine(L""); - List nss; - - FOREACH(Ptr, decl, topLevelClassDeclsForFiles.Get(fileName)) - { - WriteHeader_TopLevelClass(writer, decl, nss); - writer.WriteLine(L""); - } - - WriteNamespaceEnd(writer, nss); - WritePopCompileOptions(writer); - } - - void WfCppConfig::WriteSubCpp(stream::StreamWriter& writer, const WString& fileName) - { - WritePushCompileOptions(writer); - writer.WriteLine(L""); - WriteCpp_PushMacros(writer); - writer.WriteLine(L""); - List nss; - - FOREACH(Ptr, decl, topLevelClassDeclsForFiles.Get(fileName)) - { - WriteCpp_Class(writer, decl, nss); - } - - WriteNamespaceEnd(writer, nss); - WriteCpp_PopMacros(writer); - writer.WriteLine(L""); - WritePopCompileOptions(writer); - } - } - } -} - -/*********************************************************************** -CPP\WFCPP_GENERATECPPFILES.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace cppcodegen - { - using namespace collections; - using namespace stream; - using namespace filesystem; - -/*********************************************************************** -WfCppInput -***********************************************************************/ - - WfCppInput::WfCppInput(const WString& _assemblyName) - { - headerGuardPrefix = L"VCZH_WORKFLOW_COMPILER_GENERATED_"; - assemblyName = _assemblyName; - assemblyNamespace = L"vl_workflow_global"; - includeFileName = _assemblyName + L"Includes"; - defaultFileName = _assemblyName; - } - -/*********************************************************************** -GenerateCppFiles -***********************************************************************/ - - template - WString GenerateToStream(const TCallback& callback) - { - MemoryStream stream; - { - StreamWriter writer(stream); - callback(writer); - } - stream.SeekFromBegin(0); - { - StreamReader reader(stream); - return reader.ReadToEnd(); - } - } - - void GenerateCppComment(StreamWriter& writer, const WString& comment) - { - writer.WriteLine(L"/***********************************************************************"); - writer.WriteLine(L"!!!!!! DO NOT MODIFY !!!!!!"); - writer.WriteLine(L""); - writer.WriteLine(comment); - writer.WriteLine(L""); - writer.WriteLine(L"This file is generated by Workflow compiler"); - writer.WriteLine(L"https://github.com/vczh-libraries"); - writer.WriteLine(L"***********************************************************************/"); - } - - Ptr GenerateCppFiles(Ptr input, analyzer::WfLexicalScopeManager* manager) - { - WfCppConfig config(manager, input->assemblyName, input->assemblyNamespace); - auto output = MakePtr(); - if (config.manager->declarationTypes.Count() > 0) - { - output->containsReflectionInfo = true; - } - - bool multiFile = false; - switch (input->multiFile) - { - case WfCppMultiFile::Enabled: - multiFile = true; - break; - case WfCppMultiFile::Disabled: - multiFile = false; - break; - default: - multiFile = config.topLevelClassDeclsForFiles.Count() > 1; - } - - output->multiFile = multiFile; - if (multiFile) - { - output->entryFileName = input->includeFileName; - } - else - { - output->entryFileName = input->defaultFileName; - } - - output->cppFiles.Add(input->defaultFileName + L".h", GenerateToStream([&](StreamWriter& writer) - { - GenerateCppComment(writer, input->comment); - writer.WriteLine(L""); - writer.WriteLine(L"#ifndef " + input->headerGuardPrefix + wupper(input->defaultFileName)); - writer.WriteLine(L"#define " + input->headerGuardPrefix + wupper(input->defaultFileName)); - writer.WriteLine(L""); - FOREACH(WString, include, input->normalIncludes) - { - writer.WriteLine(L"#include \"" + include + L"\""); - } - if (input->reflectionIncludes.Count() > 0) - { - writer.WriteLine(L"#ifndef VCZH_DEBUG_NO_REFLECTION"); - FOREACH(WString, include, input->reflectionIncludes) - { - writer.WriteLine(L"#include \"" + include + L"\""); - } - writer.WriteLine(L"#endif"); - } - writer.WriteLine(L""); - config.WriteHeader(writer, multiFile); - writer.WriteLine(L""); - writer.WriteLine(L"#endif"); - })); - - output->cppFiles.Add(input->defaultFileName + L".cpp", GenerateToStream([&](StreamWriter& writer) - { - GenerateCppComment(writer, input->comment); - writer.WriteLine(L""); - writer.WriteLine(L"#include \"" + output->entryFileName + L".h\""); - writer.WriteLine(L""); - config.WriteCpp(writer, multiFile); - })); - - if (multiFile) - { - output->cppFiles.Add(input->includeFileName + L".h", GenerateToStream([&](StreamWriter& writer) - { - GenerateCppComment(writer, input->comment); - writer.WriteLine(L""); - writer.WriteLine(L"#ifndef " + input->headerGuardPrefix + wupper(input->includeFileName)); - writer.WriteLine(L"#define " + input->headerGuardPrefix + wupper(input->includeFileName)); - writer.WriteLine(L""); - - writer.WriteLine(L"#include \"" + input->defaultFileName + L".h\""); - FOREACH(WString, fileName, config.topLevelClassDeclsForFiles.Keys()) - { - if (fileName != L"") - { - writer.WriteLine(L"#include \"" + fileName + L".h\""); - } - } - - if (config.manager->declarationTypes.Count() > 0) - { - writer.WriteLine(L""); - config.WriteHeader_Reflection(writer); - } - - writer.WriteLine(L""); - writer.WriteLine(L"#endif"); - })); - - FOREACH(WString, fileName, config.topLevelClassDeclsForFiles.Keys()) - { - if (fileName != L"") - { - output->cppFiles.Add(fileName + L".h", GenerateToStream([&](StreamWriter& writer) - { - GenerateCppComment(writer, input->comment); - writer.WriteLine(L""); - writer.WriteLine(L"#ifndef " + input->headerGuardPrefix + wupper(fileName)); - writer.WriteLine(L"#define " + input->headerGuardPrefix + wupper(fileName)); - writer.WriteLine(L""); - writer.WriteLine(L"#include \"" + input->defaultFileName + L".h\""); - { - List> decls; - CopyFrom(decls, config.topLevelClassDeclsForFiles[fileName]); - for (vint i = 0; i < decls.Count(); i++) - { - if (auto classDecl = decls[i].Cast()) - { - { - vint index = config.enumDecls.Keys().IndexOf(classDecl.Obj()); - if (index != -1) - { - CopyFrom(decls, config.enumDecls.GetByIndex(index), true); - } - } - { - vint index = config.structDecls.Keys().IndexOf(classDecl.Obj()); - if (index != -1) - { - CopyFrom(decls, config.structDecls.GetByIndex(index), true); - } - } - { - vint index = config.classDecls.Keys().IndexOf(classDecl.Obj()); - if (index != -1) - { - CopyFrom(decls, config.classDecls.GetByIndex(index), true); - } - } - } - } - - SortedList fileNames; - FOREACH(Ptr, decl, decls) - { - vint index = config.declDependencies.Keys().IndexOf(decl.Obj()); - if (index != -1) - { - FOREACH(Ptr, declDep, config.declDependencies.GetByIndex(index)) - { - WString fileName = config.declFiles[declDep.Obj()]; - if (fileName != L"" && !fileNames.Contains(fileName)) - { - fileNames.Add(fileName); - } - } - } - } - - FOREACH(WString, fileName, fileNames) - { - writer.WriteLine(L"#include \"" + fileName + L".h\""); - } - } - writer.WriteLine(L""); - config.WriteSubHeader(writer, fileName); - writer.WriteLine(L""); - writer.WriteLine(L"#endif"); - })); - - output->cppFiles.Add(fileName + L".cpp", GenerateToStream([&](StreamWriter& writer) - { - GenerateCppComment(writer, input->comment); - writer.WriteLine(L""); - writer.WriteLine(L"#include \"" + input->includeFileName + L".h\""); - writer.WriteLine(L""); - config.WriteSubCpp(writer, fileName); - })); - } - } - } - - return output; - } - -/*********************************************************************** -MergeCppFile -***********************************************************************/ - - WString RemoveSpacePrefix(const WString& s) - { - for (vint i = 0; i < s.Length(); i++) - { - if (s[i] != L' '&&s[i] != L'\t') - { - return s.Sub(i, s.Length() - i); - } - } - return WString::Empty; - } - - const vint NORMAL = 0; - const vint WAIT_HEADER = 1; - const vint WAIT_OPEN = 2; - const vint WAIT_CLOSE = 3; - const vint UNUSED_USER_CONTENT = 4; - - template - void ProcessCppContent(const WString& code, const TCallback& callback) - { - vint state = NORMAL; - vint counter = 0; - - StringReader reader(code); - while (!reader.IsEnd()) - { - auto line = reader.ReadLine(); - if (reader.IsEnd() && line == L"") - { - break; - } - - if (line == L"// UNUSED_USER_CONTENT:") - { - state = UNUSED_USER_CONTENT; - } - - if (state == UNUSED_USER_CONTENT) - { - callback(state, state, line, line); - } - else - { - auto content = RemoveSpacePrefix(line); - auto previousState = state; - switch (state) - { - case NORMAL: - if (content.Length() > 9 && content.Sub(0, 9) == L"USERIMPL(") - { - state = WAIT_HEADER; - } - break; - case WAIT_HEADER: - state = WAIT_OPEN; - break; - case WAIT_OPEN: - if (content == L"{") - { - state = WAIT_CLOSE; - } - break; - case WAIT_CLOSE: - if (content == L"{") - { - counter++; - } - else if (content == L"}") - { - if (counter == 0) - { - state = NORMAL; - } - else - { - counter--; - } - } - break; - } - callback(previousState, state, line, content); - } - } - } - - template - void SplitCppContent(const WString& code, Dictionary& userContents, Dictionary& userContentsFull, const TCallback& callback) - { - WString name; - WString userImpl; - WString userImplFull; - ProcessCppContent(code, [&](vint previousState, vint state, const WString& line, const WString& content) - { - if (state == UNUSED_USER_CONTENT) - { - callback(line); - } - else - { - if (previousState == NORMAL && state == WAIT_HEADER) - { - name = content; - userImpl = L""; - userImplFull = L""; - } - else if (previousState == WAIT_HEADER) - { - name += content; - } - else if (previousState == WAIT_CLOSE && state == WAIT_CLOSE) - { - userImpl += line + L"\r\n"; - } - else if (previousState == WAIT_CLOSE && state == NORMAL) - { - userImplFull += L"//" + line + L"\r\n"; - userContents.Add(name, userImpl); - userContentsFull.Add(name, userImplFull); - name = L""; - } - - if (name != L"") - { - userImplFull += L"//" + line + L"\r\n"; - } - } - }); - } - - WString MergeCppMultiPlatform(const WString& code32, const WString& code64) - { - return GenerateToStream([&](StreamWriter& writer) - { - const wchar_t* reading32 = code32.Buffer(); - const wchar_t* reading64 = code64.Buffer(); - const wchar_t* start32 = reading32; - while (true) - { - vint length = 0; - while (reading32[length] && reading64[length]) - { - if (reading32[length] == reading64[length]) - { - length++; - } - else - { - break; - } - } - - writer.WriteString(reading32, length); - reading32 += length; - reading64 += length; - - if (*reading32 == 0 && *reading64 == 0) - { - break; - } - -#define IS_DIGIT(C) (L'0' <= C && C <= L'9') - - if (reading32[0] == L'3' && reading32[1] == L'2' && reading64[0] == L'6' && reading64[1] == L'4') - { - if (length >= 4) - { - if (wcsncmp(reading32 - 4, L"vint32_t", 8) == 0 && wcsncmp(reading64 - 4, L"vint64_t", 8) == 0) - { - reading32 += 4; - reading64 += 4; - goto NEXT_ROUND; - } - } - } - else if (reading64[0] == L'L') - { - if (reading32[0] == reading64[1] && length >= 1) - { - if (IS_DIGIT(reading32[-1]) && !IS_DIGIT(reading32[0])) - { - if (IS_DIGIT(reading64[-1]) && !IS_DIGIT(reading64[1])) - { - reading64 += 1; - goto NEXT_ROUND; - } - } - } - } - else if (reading64[0] == L'U' && reading64[1] == L'L') - { - if (reading32[0] == reading64[2] && length >= 1) - { - if (IS_DIGIT(reading32[-1]) && !IS_DIGIT(reading32[0])) - { - if (IS_DIGIT(reading64[-1]) && !IS_DIGIT(reading64[2])) - { - reading64 += 2; - goto NEXT_ROUND; - } - } - } - } - throw Exception(L"The difference at " + itow((vint)(reading32 - start32)) + L"-th character between Input C++ source files are not " - L"\"vint32_t\" and \"vint64_t\", " - L"\"\" and \"L\", " - L"\"\" and \"UL\"." - ); - NEXT_ROUND:; - -#undef IS_DIGIT - } - }); - } - - WString MergeCppFileContent(const WString& dst, const WString& src) - { - Dictionary userContents, userContentsFull; - WString unusedUserContent = GenerateToStream([&](StreamWriter& writer) - { - SplitCppContent(dst, userContents, userContentsFull, [&](const WString& line) - { - writer.WriteLine(line); - }); - }); - - WString processedUnusedUserContent = GenerateToStream([&](StreamWriter& writer) - { - StringReader reader(unusedUserContent); - while (!reader.IsEnd()) - { - auto line = reader.ReadLine(); - if (line != L"// UNUSED_USER_CONTENT:") - { - if (INVLOC.StartsWith(line, L"//", Locale::None)) - { - line = line.Right(line.Length() - 2); - } - writer.WriteLine(line); - } - } - }); - - SplitCppContent(processedUnusedUserContent, userContents, userContentsFull, [&](const WString& line) {}); - - return GenerateToStream([&](StreamWriter& writer) - { - WString name; - WString userImpl; - ProcessCppContent(src, [&](vint previousState, vint state, const WString& line, const WString& content) - { - if (previousState == NORMAL && state == WAIT_HEADER) - { - name = content; - userImpl = L""; - } - else if (previousState == WAIT_HEADER) - { - name += content; - } - else if (previousState == WAIT_CLOSE && state == WAIT_CLOSE) - { - userImpl += line + L"\r\n"; - return; - } - else if (previousState == WAIT_CLOSE && state == NORMAL) - { - vint index = userContents.Keys().IndexOf(name); - if (index == -1) - { - writer.WriteString(userImpl); - } - else - { - writer.WriteString(userContents.Values()[index]); - userContentsFull.Remove(name); - } - } - writer.WriteLine(line); - }); - - if (userContentsFull.Count() > 0) - { - writer.WriteLine(L"// UNUSED_USER_CONTENT:"); - FOREACH(WString, content, userContentsFull.Values()) - { - writer.WriteString(content); - } - } - }); - } - } - } -} - -/*********************************************************************** -CPP\WFCPP_STATEMENT.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace cppcodegen - { - using namespace collections; - using namespace reflection; - using namespace reflection::description; - using namespace analyzer; - - class WfGenerateStatementVisitor : public Object, public WfStatement::IVisitor - { - public: - WfCppConfig* config; - Ptr functionRecord; - stream::StreamWriter& writer; - WString prefixBlock; - WString prefix; - ITypeInfo* returnType; - - WfGenerateStatementVisitor(WfCppConfig* _config, Ptr _functionRecord, stream::StreamWriter& _writer, const WString& _prefixBlock, const WString& _prefix, ITypeInfo* _returnType) - :config(_config) - , functionRecord(_functionRecord) - , writer(_writer) - , prefixBlock(_prefixBlock) - , prefix(_prefix) - , returnType(_returnType) - { - } - - void Call(Ptr node, WString prefixDelta = WString(L"\t", false)) - { - GenerateStatement(config, functionRecord, writer, node, prefix, prefixDelta, returnType); - } - - void Visit(WfBreakStatement* node)override - { - writer.WriteString(prefix); - writer.WriteLine(L"break;"); - } - - void Visit(WfContinueStatement* node)override - { - writer.WriteString(prefix); - writer.WriteLine(L"continue;"); - } - - void Visit(WfReturnStatement* node)override - { - writer.WriteString(prefix); - if (node->expression) - { - writer.WriteString(L"return "); - GenerateExpression(config, writer, node->expression, returnType); - writer.WriteLine(L";"); - } - else - { - writer.WriteLine(L"return;"); - } - } - - void Visit(WfDeleteStatement* node)override - { - writer.WriteString(prefix); - writer.WriteString(L"::vl::__vwsn::This("); - GenerateExpression(config, writer, node->expression, nullptr); - writer.WriteLine(L")->Dispose(true);"); - } - - void Visit(WfRaiseExceptionStatement* node)override - { - if (node->expression) - { - writer.WriteString(prefix); - writer.WriteString(L"throw ::vl::Exception("); - - auto result = config->manager->expressionResolvings[node->expression.Obj()]; - bool throwString = result.type->GetTypeDescriptor() == description::GetTypeDescriptor(); - if (!throwString) - { - writer.WriteString(L"::vl::__vwsn::This("); - } - GenerateExpression(config, writer, node->expression, result.type.Obj()); - if (!throwString) - { - writer.WriteString(L".Obj())->GetMessage()"); - } - - writer.WriteLine(L");"); - } - else - { - writer.WriteString(prefix); - writer.WriteLine(L"throw;"); - } - } - - void Visit(WfIfStatement* node)override - { - writer.WriteString(prefix); - while (node) - { - writer.WriteString(L"if ("); - if (node->type) - { - auto result = config->manager->expressionResolvings[node->expression.Obj()]; - auto scope = config->manager->nodeScopes[node].Obj(); - auto typeInfo = CreateTypeInfoFromType(scope, node->type); - writer.WriteString(L"auto "); - writer.WriteString(config->ConvertName(node->name.value)); - writer.WriteString(L" = "); - ConvertType(config, writer, result.type.Obj(), typeInfo.Obj(), [&]() {GenerateExpression(config, writer, node->expression, nullptr); }, false); - } - else - { - GenerateExpression(config, writer, node->expression, TypeInfoRetriver::CreateTypeInfo().Obj()); - } - writer.WriteLine(L")"); - Call(node->trueBranch); - if (node->falseBranch) - { - writer.WriteString(prefix); - if (auto ifStat = node->falseBranch.Cast()) - { - writer.WriteString(L"else "); - node = ifStat.Obj(); - continue; - } - else - { - writer.WriteLine(L"else"); - Call(node->falseBranch); - } - } - break; - } - } - - void Visit(WfWhileStatement* node)override - { - writer.WriteString(prefix); - writer.WriteString(L"while ("); - GenerateExpression(config, writer, node->condition, TypeInfoRetriver::CreateTypeInfo().Obj()); - writer.WriteLine(L")"); - Call(node->statement); - } - - void Visit(WfTryStatement* node)override - { - auto exName = L"__vwsne_" + itow(functionRecord->exprCounter++); - - WString tryPrefix = prefix; - if (node->finallyStatement) - { - auto blockName = L"__vwsnb_" + itow(functionRecord->blockCounter++); - tryPrefix += L"\t"; - - writer.WriteString(prefix); - writer.WriteLine(L"{"); - - writer.WriteString(tryPrefix); - writer.WriteString(L"auto "); - writer.WriteString(blockName); - writer.WriteLine(L" = [&]()"); - GenerateStatement(config, functionRecord, writer, node->finallyStatement, tryPrefix, WString(L"\t", false), returnType); - writer.WriteString(tryPrefix); - writer.WriteLine(L";"); - - writer.WriteString(tryPrefix); - writer.WriteString(L"::vl::__vwsn::RunOnExit<::vl::RemoveCVR::Type> "); - writer.WriteString(blockName); - writer.WriteString(L"_dtor(&"); - writer.WriteString(blockName); - writer.WriteLine(L");"); - } - WString bodyPrefix = tryPrefix + L"\t"; - - writer.WriteString(tryPrefix); - writer.WriteLine(L"try"); - writer.WriteString(tryPrefix); - writer.WriteLine(L"{"); - GenerateStatement(config, functionRecord, writer, node->protectedStatement, bodyPrefix, WString(L"\t", false), returnType); - writer.WriteString(tryPrefix); - writer.WriteLine(L"}"); - - writer.WriteString(tryPrefix); - writer.WriteString(L"catch(const ::vl::Exception&"); - if (node->catchStatement) - { - writer.WriteString(L" "); - writer.WriteString(exName); - } - writer.WriteLine(L")"); - writer.WriteString(tryPrefix); - writer.WriteLine(L"{"); - if (node->catchStatement) - { - writer.WriteString(bodyPrefix); - writer.WriteString(L"auto "); - writer.WriteString(config->ConvertName(node->name.value)); - writer.WriteString(L" = ::vl::reflection::description::IValueException::Create("); - writer.WriteString(exName); - writer.WriteLine(L".Message());"); - GenerateStatement(config, functionRecord, writer, node->catchStatement, bodyPrefix, WString(L"\t", false), returnType); - } - writer.WriteString(tryPrefix); - writer.WriteLine(L"}"); - - if (node->finallyStatement) - { - writer.WriteString(prefix); - writer.WriteLine(L"}"); - } - } - - void Visit(WfBlockStatement* node)override - { - writer.WriteString(prefixBlock); - writer.WriteLine(L"{"); - FOREACH(Ptr, statement, node->statements) - { - while (auto virtualStat = statement.Cast()) - { - statement = virtualStat->expandedStatement; - } - - if (statement.Cast()) - { - Call(statement); - } - else - { - Call(statement, WString::Empty); - } - } - writer.WriteString(prefixBlock); - writer.WriteLine(L"}"); - } - - void Visit(WfExpressionStatement* node)override - { - writer.WriteString(prefix); - GenerateExpression(config, writer, node->expression, nullptr, false); - writer.WriteLine(L";"); - } - - void Visit(WfVariableStatement* node)override - { - auto scope = config->manager->nodeScopes[node->variable.Obj()]; - auto symbol = scope->symbols[node->variable->name.value][0].Obj(); - - writer.WriteString(prefix); - if (node->variable->expression) - { - writer.WriteString(L"auto"); - } - else - { - writer.WriteString(config->ConvertType(symbol->typeInfo.Obj())); - } - writer.WriteString(L" "); - writer.WriteString(config->ConvertName(node->variable->name.value)); - - if (node->variable->expression) - { - writer.WriteString(L" = "); - GenerateExpression(config, writer, node->variable->expression, symbol->typeInfo.Obj()); - } - writer.WriteLine(L";"); - } - - void Visit(WfVirtualStatement* node)override - { - node->expandedStatement->Accept(this); - } - - void Visit(WfCoroutineStatement* node)override - { - CHECK_FAIL(L"WfGenerateStatementVisitor::Visit(WfCoroutineStatement*)#Internal error, All coroutine statements do not generate C++ code."); - } - }; - - void GenerateStatement(WfCppConfig* config, Ptr functionRecord, stream::StreamWriter& writer, Ptr node, const WString& prefix, const WString& prefixDelta, reflection::description::ITypeInfo* returnType) - { - WfGenerateStatementVisitor visitor(config, functionRecord, writer, prefix, prefix + prefixDelta, returnType); - node->Accept(&visitor); - } - } - } -} - -/*********************************************************************** -CPP\WFCPP_WRITECLASS.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace cppcodegen - { - using namespace collections; - using namespace reflection; - using namespace reflection::description; - - void WfCppConfig::WriteHeader_ClassPreDecl(stream::StreamWriter& writer, Ptr decl, const WString& name, const WString& prefix) - { - writer.WriteLine(prefix + L"class " + name + L";"); - } - - void WfCppConfig::WriteHeader_ClassPreDecl(stream::StreamWriter& writer, Ptr decl, collections::List& nss) - { - auto td = manager->declarationTypes[decl.Obj()].Obj(); - WString name; - auto prefix = WriteNamespace(writer, CppGetFullName(td), nss, name); - WriteHeader_ClassPreDecl(writer, decl, name, prefix); - } - - class WriteHeader_Class_FindClassDeclVisitor - : public empty_visitor::DeclarationVisitor - { - public: - List>& unprocessed; - - WriteHeader_Class_FindClassDeclVisitor(List>& _unprocessed) - :unprocessed(_unprocessed) - { - } - - void Dispatch(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - - void Visit(WfClassDeclaration* node)override - { - unprocessed.Add(node); - } - }; - - void WfCppConfig::WriteHeader_Class(stream::StreamWriter& writer, Ptr decl, const WString& name, const WString& prefix) - { - auto td = manager->declarationTypes[decl.Obj()].Obj(); - - writer.WriteString(prefix + L"class " + name + L" : "); - switch (decl->kind) - { - case WfClassKind::Class: - { - vint count = td->GetBaseTypeDescriptorCount(); - bool hasClassBase = Range(0, count) - .Any([=](vint index) - { - auto baseTd = td->GetBaseTypeDescriptor(index); - return baseTd->GetTypeDescriptorFlags() == TypeDescriptorFlags::Class - && baseTd != description::GetTypeDescriptor(); - }); - - if (!hasClassBase) - { - writer.WriteString(L"public ::vl::Object, "); - } - for (vint i = 0; i < count; i++) - { - auto baseTd = td->GetBaseTypeDescriptor(i); - switch (baseTd->GetTypeDescriptorFlags()) - { - case TypeDescriptorFlags::Class: - if (baseTd != description::GetTypeDescriptor()) - { - writer.WriteString(L"public " + ConvertType(baseTd) + L", "); - } - break; - case TypeDescriptorFlags::Interface: - writer.WriteString(L"public virtual " + ConvertType(baseTd) + L", "); - break; - default:; - } - } - } - break; - case WfClassKind::Interface: - { - vint count = td->GetBaseTypeDescriptorCount(); - for (vint i = 0; i < count; i++) - { - writer.WriteString(L"public virtual " + ConvertType(td->GetBaseTypeDescriptor(i)) + L", "); - } - } - break; - } - writer.WriteLine(L"public ::vl::reflection::Description<" + name + L">"); - writer.WriteLine(prefix + L"{"); - - List> unprocessed; - unprocessed.Add(decl); - - FOREACH(Ptr, attribute, attributeEvaluator->GetAttributes(decl->attributes, L"cpp", L"Friend")) - { - auto td = UnboxValue(attributeEvaluator->GetAttributeValue(attribute)); - - auto scopeName = manager->typeNames[td]; - if (scopeName->declarations.Count() == 0) - { - writer.WriteLine(prefix + L"\tfriend class " + ConvertType(td) + L";"); - } - else - { - auto friendDecl = scopeName->declarations[0].Cast(); - unprocessed.Add(friendDecl); - } - } - - auto declTypeName = ConvertType(manager->declarationTypes[decl.Obj()].Obj()); - for (vint i = 0; i < unprocessed.Count(); i++) - { - auto current = unprocessed[i]; - if (current != decl) - { - auto currentTypeName = ConvertType(manager->declarationTypes[current.Obj()].Obj()); - - bool isInternalClass = false; - if (currentTypeName.Length() > declTypeName.Length() + 2) - { - if (currentTypeName.Left(declTypeName.Length() + 2) == declTypeName + L"::") - { - isInternalClass = true; - } - } - if (!isInternalClass) - { - writer.WriteLine(prefix + L"\tfriend class " + currentTypeName + L";"); - } - } - - vint index = classClosures.Keys().IndexOf(current.Obj()); - if (index != -1) - { - SortedList closureNames; - CopyFrom( - closureNames, - From(classClosures.GetByIndex(index)) - .Select([&](Ptr closure) - { - return (closure.Cast() ? L"class ::" : L"struct ::") + - assemblyNamespace + - L"::" + - closureInfos[closure.Obj()]->lambdaClassName; - }) - ); - FOREACH(WString, closureName, closureNames) - { - writer.WriteLine(prefix + L"\tfriend " + closureName + L";"); - } - } - - WriteHeader_Class_FindClassDeclVisitor visitor(unprocessed); - FOREACH(Ptr, memberDecl, current->declarations) - { - memberDecl->Accept(&visitor); - } - } - writer.WriteLine(L"#ifndef VCZH_DEBUG_NO_REFLECTION"); - writer.WriteLine(prefix + L"\tfriend struct ::vl::reflection::description::CustomTypeDescriptorSelector<" + name + L">;"); - writer.WriteLine(L"#endif"); - - const vint PRIVATE = 0; - const vint PROTECTED = 1; - const vint PUBLIC = 2; - vint accessor = -1; - - { - vint index = enumDecls.Keys().IndexOf(decl.Obj()); - if (index != -1) - { - if (accessor != PUBLIC) - { - accessor = PUBLIC; - writer.WriteLine(prefix + L"public:"); - } - FOREACH(Ptr, decl, enumDecls.GetByIndex(index)) - { - WriteHeader_Enum(writer, decl, ConvertName(decl->name.value), prefix + L"\t"); - writer.WriteLine(L""); - } - } - } - - { - vint index = structDecls.Keys().IndexOf(decl.Obj()); - if (index != -1) - { - if (accessor != PUBLIC) - { - accessor = PUBLIC; - writer.WriteLine(prefix + L"public:"); - } - FOREACH(Ptr, decl, structDecls.GetByIndex(index)) - { - WriteHeader_Struct(writer, decl, ConvertName(decl->name.value), prefix + L"\t"); - writer.WriteLine(L""); - } - } - } - - { - vint index = classDecls.Keys().IndexOf(decl.Obj()); - if (index != -1) - { - if (accessor != PUBLIC) - { - accessor = PUBLIC; - writer.WriteLine(prefix + L"public:"); - } - FOREACH(Ptr, decl, classDecls.GetByIndex(index)) - { - WriteHeader_ClassPreDecl(writer, decl, ConvertName(decl->name.value), prefix + L"\t"); - } - writer.WriteLine(L""); - FOREACH(Ptr, decl, classDecls.GetByIndex(index)) - { - WriteHeader_Class(writer, decl, ConvertName(decl->name.value), prefix + L"\t"); - } - } - } - - FOREACH(Ptr, memberDecl, decl->declarations) - { - vint memberAccessor = PUBLIC; - if (attributeEvaluator->GetAttribute(memberDecl->attributes, L"cpp", L"Private")) - { - memberAccessor = PRIVATE; - } - else if (attributeEvaluator->GetAttribute(memberDecl->attributes, L"cpp", L"Protected")) - { - memberAccessor = PROTECTED; - } - - if (accessor != memberAccessor) - { - accessor = memberAccessor; - switch (accessor) - { - case PRIVATE: - writer.WriteLine(prefix + L"private:"); - break; - case PROTECTED: - writer.WriteLine(prefix + L"protected:"); - break; - case PUBLIC: - writer.WriteLine(prefix + L"public:"); - break; - } - } - GenerateClassMemberDecl(this, writer, ConvertName(decl->name.value), memberDecl, prefix + L"\t", false); - } - - writer.WriteLine(prefix + L"};"); - } - - WString WfCppConfig::WriteHeader_Class(stream::StreamWriter& writer, Ptr decl, collections::List& nss) - { - auto td = manager->declarationTypes[decl.Obj()].Obj(); - WString name; - auto prefix = WriteNamespace(writer, CppGetFullName(td), nss, name); - WriteHeader_Class(writer, decl, name, prefix); - return prefix; - } - - void WfCppConfig::WriteHeader_TopLevelClass(stream::StreamWriter& writer, Ptr decl, collections::List& nss) - { - auto prefix = WriteHeader_Class(writer, decl, nss); - List> classes; - classes.Add(decl); - vint processed = 0; - while (processed < classes.Count()) - { - auto current = classes[processed++]; - { - vint index = enumDecls.Keys().IndexOf(current.Obj()); - if (index != -1) - { - FOREACH(Ptr, enumDecl, enumDecls.GetByIndex(index)) - { - auto td = manager->declarationTypes[enumDecl.Obj()].Obj(); - WriteHeader_EnumOp(writer, enumDecl, ConvertType(td), prefix); - } - } - } - { - vint index = structDecls.Keys().IndexOf(current.Obj()); - if (index != -1) - { - FOREACH(Ptr, structDecl, structDecls.GetByIndex(index)) - { - auto td = manager->declarationTypes[structDecl.Obj()].Obj(); - WriteHeader_StructOp(writer, structDecl, ConvertType(td), prefix); - } - } - } - { - vint index = classDecls.Keys().IndexOf(current.Obj()); - if (index != -1) - { - CopyFrom(classes, classDecls.GetByIndex(index), true); - } - } - } - } - - bool WfCppConfig::WriteCpp_ClassMember(stream::StreamWriter& writer, Ptr decl, Ptr memberDecl, collections::List& nss) - { - List nss2; - GetClassNamespace(decl, nss2); - auto prefix = WriteNamespace(writer, nss, nss2); - - auto td = manager->declarationTypes[decl.Obj()].Obj(); - auto classFullName = CppGetFullName(td); - return GenerateClassMemberImpl(this, writer, GetClassBaseName(decl), ConvertName(decl->name.value), classFullName , memberDecl, prefix); - } - - void WfCppConfig::WriteCpp_Class(stream::StreamWriter& writer, Ptr decl, collections::List& nss) - { - List> classes; - classes.Add(decl); - vint processed = 0; - while (processed < classes.Count()) - { - auto current = classes[processed++]; - - writer.WriteLine(L"/***********************************************************************"); - writer.WriteLine(L"Class (" + CppGetFullName(manager->declarationTypes[current.Obj()].Obj()) + L")"); - writer.WriteLine(L"***********************************************************************/"); - writer.WriteLine(L""); - - FOREACH(Ptr, memberDecl, current->declarations) - { - if (WriteCpp_ClassMember(writer, current, memberDecl, nss)) - { - writer.WriteLine(L""); - } - } - - vint index = classDecls.Keys().IndexOf(current.Obj()); - if (index != -1) - { - CopyFrom(classes, classDecls.GetByIndex(index), true); - } - } - } - } - } -} - -/*********************************************************************** -CPP\WFCPP_WRITEENUM.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace cppcodegen - { - using namespace collections; - - void WfCppConfig::WriteHeader_Enum(stream::StreamWriter& writer, Ptr decl, const WString& name, const WString& prefix) - { - writer.WriteLine(prefix + L"enum class " + name + L" : vl::vuint64_t"); - writer.WriteLine(prefix + L"{"); - FOREACH(Ptr, item, decl->items) - { - switch (item->kind) - { - case WfEnumItemKind::Constant: - writer.WriteLine(prefix + L"\t" + ConvertName(item->name.value) + L" = " + item->number.value + L"UL,"); - break; - case WfEnumItemKind::Intersection: - writer.WriteString(prefix + L"\t" + ConvertName(item->name.value) + L" = "); - FOREACH_INDEXER(Ptr, enumInt, index, item->intersections) - { - if (index > 0) - { - writer.WriteString(L" | "); - } - writer.WriteString(ConvertName(enumInt->name.value)); - } - writer.WriteLine(L","); - break; - } - } - writer.WriteLine(prefix + L"};"); - } - - void WfCppConfig::WriteHeader_EnumOp(stream::StreamWriter& writer, Ptr decl, const WString& name, const WString& prefix) - { - const wchar_t* ops[] = { L"&", L"|" }; - for (auto op : ops) - { - writer.WriteString(prefix); - writer.WriteString(L"inline "); - writer.WriteString(name); - writer.WriteString(L" operator"); - writer.WriteString(op); - writer.WriteString(L" ("); - writer.WriteString(name); - writer.WriteString(L" a, "); - writer.WriteString(name); - writer.WriteString(L" b) { return static_cast<"); - writer.WriteString(name); - writer.WriteString(L">(static_cast<::vl::vuint64_t>(a) "); - writer.WriteString(op); - writer.WriteLine(L" static_cast<::vl::vuint64_t>(b)); }"); - } - } - - void WfCppConfig::WriteHeader_Enum(stream::StreamWriter& writer, Ptr decl, collections::List& nss) - { - auto td = manager->declarationTypes[decl.Obj()].Obj(); - WString name; - auto prefix = WriteNamespace(writer, CppGetFullName(td), nss, name); - WriteHeader_Enum(writer, decl, name, prefix); - WriteHeader_EnumOp(writer, decl, name, prefix); - } - } - } -} - -/*********************************************************************** -CPP\WFCPP_WRITEFUNCTIONHEADER.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace cppcodegen - { - using namespace collections; - using namespace reflection::description; - - ITypeInfo* WfCppConfig::WriteFunctionHeader(stream::StreamWriter& writer, ITypeInfo* typeInfo, collections::List& arguments, const WString& name, bool writeReturnType) - { - ITypeInfo* returnType = nullptr; - if (writeReturnType) - { - returnType = typeInfo->GetElementType()->GetGenericArgument(0); - writer.WriteString(ConvertType(returnType)); - writer.WriteChar(L' '); - } - - writer.WriteString(name); - writer.WriteString(L"("); - for (vint i = 0; i < arguments.Count(); i++) - { - if (i > 0) - { - writer.WriteString(L", "); - } - writer.WriteString(ConvertArgumentType(typeInfo->GetElementType()->GetGenericArgument(i + 1))); - writer.WriteChar(L' '); - writer.WriteString(ConvertName(arguments[i])); - } - writer.WriteString(L")"); - - return returnType; - } - - ITypeInfo* WfCppConfig::WriteFunctionHeader(stream::StreamWriter& writer, Ptr ordered, const WString& name, bool writeReturnType) - { - auto result = manager->expressionResolvings[ordered.Obj()]; - auto typeInfo = result.type.Obj(); - - auto scope = manager->nodeScopes[ordered.Obj()].Obj(); - List arguments; - CopyFrom( - arguments, - Range(0, scope->symbols.Count()) - .Select([scope](vint index) - { - return scope->symbols.GetByIndex(index)[0]->name; - }) - .OrderBy((vint(*)(const WString&, const WString&))&WString::Compare) - ); - - return WriteFunctionHeader(writer, typeInfo, arguments, name, writeReturnType); - } - - ITypeInfo* WfCppConfig::WriteFunctionHeader(stream::StreamWriter& writer, Ptr funcExpr, const WString& name, bool writeReturnType) - { - auto result = manager->expressionResolvings[funcExpr.Obj()]; - auto typeInfo = result.type.Obj(); - - List arguments; - CopyFrom( - arguments, - From(funcExpr->function->arguments) - .Select([](Ptr argument) - { - return argument->name.value; - }) - ); - return WriteFunctionHeader(writer, typeInfo, arguments, name, writeReturnType); - } - - ITypeInfo* WfCppConfig::WriteFunctionHeader(stream::StreamWriter& writer, Ptr decl, const WString& name, bool writeReturnType) - { - vint index1 = manager->declarationMemberInfos.Keys().IndexOf(decl.Obj()); - vint index2 = manager->interfaceMethodImpls.Keys().IndexOf(decl.Obj()); - auto methodInfo = - index1 != -1 ? dynamic_cast(manager->declarationMemberInfos.Values()[index1].Obj()) : - index2 != -1 ? manager->interfaceMethodImpls.Values()[index2] : - nullptr; - - List arguments; - CopyFrom( - arguments, - From(decl->arguments) - .Select([](Ptr argument) - { - return argument->name.value; - }) - ); - - if (methodInfo) - { - return WriteFunctionHeader(writer, methodInfo, arguments, name, writeReturnType); - } - else - { - auto scope = manager->nodeScopes[decl.Obj()].Obj(); - auto symbol = manager->GetDeclarationSymbol(scope, decl.Obj()); - auto typeInfo = symbol->typeInfo.Obj(); - - return WriteFunctionHeader(writer, typeInfo, arguments, name, writeReturnType); - } - } - - ITypeInfo* WfCppConfig::WriteFunctionHeader(stream::StreamWriter& writer, IMethodInfo* methodInfo, collections::List& arguments, const WString& name, bool writeReturnType) - { - ITypeInfo* returnType = nullptr; - if (writeReturnType) - { - returnType = methodInfo->GetReturn(); - writer.WriteString(ConvertType(returnType)); - writer.WriteChar(L' '); - } - writer.WriteString(name); - writer.WriteString(L"("); - vint count = methodInfo->GetParameterCount(); - for (vint i = 0; i < count; i++) - { - if (i > 0) - { - writer.WriteString(L", "); - } - writer.WriteString(ConvertArgumentType(methodInfo->GetParameter(i)->GetType())); - writer.WriteChar(L' '); - if (arguments.Count() == 0) - { - writer.WriteString(ConvertName(methodInfo->GetParameter(i)->GetName())); - } - else - { - writer.WriteString(ConvertName(arguments[i])); - } - } - writer.WriteString(L")"); - return returnType; - } - - ITypeInfo* WfCppConfig::WriteFunctionHeader(stream::StreamWriter& writer, IMethodInfo* methodInfo, const WString& name, bool writeReturnType) - { - List arguments; - return WriteFunctionHeader(writer, methodInfo, arguments, name, writeReturnType); - } - } - } -} - -/*********************************************************************** -CPP\WFCPP_WRITEGLOBAL.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace cppcodegen - { - using namespace collections; - using namespace reflection; - using namespace reflection::description; - - void WfCppConfig::SortClosure(Dictionary>& reversedLambdaExprs, Dictionary>& reversedClassExprs) - { - CopyFrom( - reversedLambdaExprs, - From(lambdaExprs) - .Select([](Pair, WString> pair) - { - return Pair>(pair.value, pair.key); - }) - ); - - CopyFrom( - reversedClassExprs, - From(classExprs) - .Select([](Pair, WString> pair) - { - return Pair>(pair.value, pair.key); - }) - ); - } - - void WfCppConfig::WriteHeader_Global(stream::StreamWriter& writer) - { - Dictionary> reversedLambdaExprs; - Dictionary> reversedClassExprs; - SortClosure(reversedLambdaExprs, reversedClassExprs); - - writer.WriteLine(L"/***********************************************************************"); - writer.WriteLine(L"Global Variables and Functions"); - writer.WriteLine(L"***********************************************************************/"); - writer.WriteLine(L""); - writer.WriteLine(L"namespace " + assemblyNamespace); - writer.WriteLine(L"{"); - writer.WriteLine(L"\tclass " + assemblyName); - writer.WriteLine(L"\t{"); - writer.WriteLine(L"\tpublic:"); - if (varDecls.Count() > 0) - { - writer.WriteLine(L""); - FOREACH(Ptr, decl, varDecls) - { - auto scope = manager->nodeScopes[decl.Obj()].Obj(); - auto symbol = scope->symbols[decl->name.value][0]; - auto typeInfo = symbol->typeInfo; - writer.WriteString(L"\t\t" + ConvertType(typeInfo.Obj()) + L" " + ConvertName(decl->name.value)); - auto defaultValue = DefaultValue(typeInfo.Obj()); - if (defaultValue != L"") - { - writer.WriteString(L" = "); - writer.WriteString(defaultValue); - } - writer.WriteLine(L";"); - } - } - if (funcDecls.Count() > 0) - { - writer.WriteLine(L""); - FOREACH(Ptr, decl, funcDecls) - { - writer.WriteString(L"\t\t"); - WriteFunctionHeader(writer, decl, ConvertName(decl->name.value), true); - writer.WriteLine(L";"); - } - } - writer.WriteLine(L""); - writer.WriteLine(L"\t\tstatic " + assemblyName + L"& Instance();"); - writer.WriteLine(L"\t};"); - - if (reversedLambdaExprs.Count() + reversedClassExprs.Count() > 0) - { - writer.WriteLine(L""); - writer.WriteLine(L"/***********************************************************************"); - writer.WriteLine(L"Closures"); - writer.WriteLine(L"***********************************************************************/"); - - FOREACH(Ptr, expr, reversedLambdaExprs.Values()) - { - writer.WriteLine(L""); - WriteHeader_LambdaExprDecl(writer, expr); - } - - FOREACH(Ptr, expr, reversedClassExprs.Values()) - { - writer.WriteLine(L""); - WriteHeader_ClassExprDecl(writer, expr); - } - } - - writer.WriteLine(L"}"); - } - - void WfCppConfig::WriteCpp_Global(stream::StreamWriter& writer) - { - Dictionary> reversedLambdaExprs; - Dictionary> reversedClassExprs; - SortClosure(reversedLambdaExprs, reversedClassExprs); - - writer.WriteLine(L"/***********************************************************************"); - writer.WriteLine(L"Global Variables"); - writer.WriteLine(L"***********************************************************************/"); - writer.WriteLine(L""); - - WString storageName = assemblyNamespace + L"_" + assemblyName; - writer.WriteLine(L"BEGIN_GLOBAL_STORAGE_CLASS(" + storageName + L")"); - writer.WriteLine(L"\t" + assemblyNamespace + L"::" + assemblyName + L" instance;"); - writer.WriteLine(L"\tINITIALIZE_GLOBAL_STORAGE_CLASS"); - if (varDecls.Count() > 0) - { - writer.WriteLine(L""); - FOREACH(Ptr, decl, varDecls) - { - auto scope = manager->nodeScopes[decl.Obj()].Obj(); - auto symbol = scope->symbols[decl->name.value][0]; - auto typeInfo = symbol->typeInfo; - if (decl->expression) - { - writer.WriteString(L"\t\tinstance." + ConvertName(decl->name.value) + L" = "); - GenerateExpression(this, writer, decl->expression, typeInfo.Obj()); - writer.WriteLine(L";"); - } - } - } - writer.WriteLine(L"\tFINALIZE_GLOBAL_STORAGE_CLASS"); - if (varDecls.Count() > 0) - { - writer.WriteLine(L""); - FOREACH(Ptr, decl, varDecls) - { - auto scope = manager->nodeScopes[decl.Obj()].Obj(); - auto symbol = scope->symbols[decl->name.value][0]; - auto typeInfo = symbol->typeInfo; - switch (typeInfo->GetDecorator()) - { - case ITypeInfo::RawPtr: - case ITypeInfo::SharedPtr: - writer.WriteLine(L"\t\tinstance." + ConvertName(decl->name.value) + L" = nullptr;"); - break; - case ITypeInfo::Nullable: - writer.WriteString(L"\t\tinstance." + ConvertName(decl->name.value) + L" = "); - ConvertType(typeInfo.Obj()); - writer.WriteLine(L"();"); - break; - default: - if (typeInfo->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - writer.WriteLine(L"\t\tinstance." + ConvertName(decl->name.value) + L" = ::vl::WString::Empty;"); - } - else if (typeInfo->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - writer.WriteLine(L"\t\tinstance." + ConvertName(decl->name.value) + L" = ::vl::reflection::description::Value();"); - } - } - } - } - writer.WriteLine(L"END_GLOBAL_STORAGE_CLASS(" + storageName + L")"); - writer.WriteLine(L""); - - writer.WriteString(L"namespace "); - writer.WriteLine(assemblyNamespace); - writer.WriteLine(L"{"); - - writer.WriteLine(L"/***********************************************************************"); - writer.WriteLine(L"Global Functions"); - writer.WriteLine(L"***********************************************************************/"); - - FOREACH(Ptr, decl, funcDecls) - { - writer.WriteLine(L""); - writer.WriteString(L"\t"); - auto returnType = WriteFunctionHeader(writer, decl, assemblyName + L"::" + ConvertName(decl->name.value), true); - writer.WriteLine(L""); - WriteFunctionBody(writer, decl->statement, L"\t", returnType); - } - - writer.WriteLine(L""); - writer.WriteLine(L"\t" + assemblyName + L"& " + assemblyName + L"::Instance()"); - writer.WriteLine(L"\t{"); - writer.WriteLine(L"\t\treturn Get" + storageName + L"().instance;"); - writer.WriteLine(L"\t}"); - - if (reversedLambdaExprs.Count() + reversedClassExprs.Count() > 0) - { - writer.WriteLine(L""); - writer.WriteLine(L"/***********************************************************************"); - writer.WriteLine(L"Closures"); - writer.WriteLine(L"***********************************************************************/"); - - FOREACH(Ptr, expr, reversedLambdaExprs.Values()) - { - writer.WriteLine(L""); - writer.WriteLine(L"\t//-------------------------------------------------------------------"); - writer.WriteLine(L""); - WriteCpp_LambdaExprImpl(writer, expr); - } - - if (reversedClassExprs.Count() > 0) - { - writer.WriteLine(L""); - FOREACH(Ptr, expr, reversedClassExprs.Values()) - { - writer.WriteLine(L"\t//-------------------------------------------------------------------"); - writer.WriteLine(L""); - WriteCpp_ClassExprImpl(writer, expr); - } - } - } - - writer.WriteLine(L"}"); - } - } - } -} - -/*********************************************************************** -CPP\WFCPP_WRITELAMBDA.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace cppcodegen - { - using namespace collections; - using namespace parsing; - using namespace analyzer; - using namespace reflection; - using namespace reflection::description; - -/*********************************************************************** -WfCppConfig::CollectClosureInfo -***********************************************************************/ - - class WfCppCollectClassExprInfoVisitor : public empty_visitor::DeclarationVisitor - { - public: - WfCppConfig* config; - vint variableCount = 0; - Ptr capture; - - WfCppCollectClassExprInfoVisitor(WfCppConfig* _config) - :config(_config) - { - } - - void Visit(WfVariableDeclaration* node)override - { - variableCount++; - } - - void Dispatch(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - - void Execute(WfNewInterfaceExpression* node) - { - capture = config->manager->lambdaCaptures[node]; - FOREACH(Ptr, memberDecl, node->declarations) - { - memberDecl->Accept(this); - } - } - }; - - Ptr WfCppConfig::CollectClosureInfo(Ptr closure) - { - using SymbolPair = Pair>; - - auto info = MakePtr(); - WfLexicalScope* scope = nullptr; - - if (auto ordered = closure.Cast()) - { - // stable symbol order by sorting them by name - CopyFrom( - info->symbols, - From(manager->lambdaCaptures[ordered.Obj()]->symbols) - .Select([](Ptr symbol) - { - return SymbolPair(symbol->name, symbol); - }) - ); - scope = manager->nodeScopes[ordered.Obj()].Obj(); - } - else if (auto funcExpr = closure.Cast()) - { - // stable symbol order by sorting them by name - CopyFrom( - info->symbols, - From(manager->lambdaCaptures[funcExpr->function.Obj()]->symbols) - .Select([](Ptr symbol) - { - return SymbolPair(symbol->name, symbol); - }) - ); - scope = manager->nodeScopes[funcExpr->function.Obj()].Obj(); - } - else if (auto classExpr = closure.Cast()) - { - WfCppCollectClassExprInfoVisitor visitor(this); - visitor.Execute(classExpr.Obj()); - - if (visitor.capture) - { - // stable symbol order by sorting them by name - CopyFrom( - info->symbols, - From(visitor.capture->symbols) - .Skip(visitor.variableCount) - .Select([](Ptr symbol) - { - return SymbolPair(symbol->name, symbol); - }) - ); - - CopyFrom( - info->ctorArgumentSymbols, - From(visitor.capture->ctorArgumentSymbols) - .Select([](Ptr symbol) - { - return SymbolPair(symbol->name, symbol); - }) - ); - } - - scope = manager->nodeScopes[classExpr.Obj()].Obj(); - } - - Ptr methodConfig; - while (scope) - { - if (scope->typeOfThisExpr) - { - if (methodConfig) - { - info->thisTypes.Add(scope->typeOfThisExpr); - if (!methodConfig->parentThisAccessable) - { - break; - } - methodConfig = nullptr; - } - } - - if (scope->functionConfig) - { - if (scope->functionConfig->thisAccessable) - { - methodConfig = scope->functionConfig; - } - } - scope = scope->parentScope.Obj(); - } - - return info; - } - -/*********************************************************************** -WfCppConfig::WriteCpp -***********************************************************************/ - - void WfCppConfig::WriteHeader_ClosurePreDecl(stream::StreamWriter& writer, Ptr closure) - { - auto info = closureInfos[closure.Obj()]; - writer.WriteString(L"\t"); - if (closure.Cast()) - { - writer.WriteString(L"class "); - } - else - { - writer.WriteString(L"struct "); - } - writer.WriteString(info->lambdaClassName); - writer.WriteLine(L";"); - } - - void WfCppConfig::WriteHeader_LambdaExprDecl(stream::StreamWriter& writer, Ptr lambda) - { - if (auto ordered = lambda.Cast()) - { - auto name = lambdaExprs[lambda.Obj()]; - writer.WriteLine(L"\tstruct " + name); - writer.WriteLine(L"\t{"); - - if (WriteCpp_ClosureMembers(writer, lambda)) - { - writer.WriteLine(L""); - } - writer.WriteString(L"\t\t"); - WriteCpp_ClosureCtor(writer, lambda, name); - writer.WriteLine(L";"); - writer.WriteLine(L""); - - writer.WriteString(L"\t\t"); - WriteFunctionHeader(writer, ordered, L"operator()", true); - writer.WriteLine(L" const;"); - writer.WriteLine(L"\t};"); - } - else if (auto funcExpr = lambda.Cast()) - { - auto name = lambdaExprs[lambda.Obj()]; - writer.WriteLine(L"\tstruct " + name); - writer.WriteLine(L"\t{"); - - if (WriteCpp_ClosureMembers(writer, lambda)) - { - writer.WriteLine(L""); - } - writer.WriteString(L"\t\t"); - WriteCpp_ClosureCtor(writer, lambda, name); - writer.WriteLine(L";"); - writer.WriteLine(L""); - - writer.WriteString(L"\t\t"); - WriteFunctionHeader(writer, funcExpr, L"operator()", true); - writer.WriteLine(L" const;"); - writer.WriteLine(L"\t};"); - } - } - - void WfCppConfig::WriteHeader_ClassExprDecl(stream::StreamWriter& writer, Ptr lambda) - { - auto result = manager->expressionResolvings[lambda.Obj()]; - auto td = result.constructorInfo->GetOwnerTypeDescriptor(); - auto name = classExprs[lambda.Obj()]; - writer.WriteLine(L"\tclass " + name + L" : public ::vl::Object, public virtual " + ConvertType(td)); - writer.WriteLine(L"\t{"); - writer.WriteLine(L"\tpublic:"); - - if (WriteCpp_ClosureMembers(writer, lambda)) - { - writer.WriteLine(L""); - } - writer.WriteString(L"\t\t"); - WriteCpp_ClosureCtor(writer, lambda, name); - writer.WriteLine(L";"); - writer.WriteLine(L""); - - FOREACH(Ptr, memberDecl, lambda->declarations) - { - GenerateClassMemberDecl(this, writer, name, memberDecl, L"\t\t", true); - } - writer.WriteLine(L"\t};"); - } - - bool WfCppConfig::WriteCpp_ClosureMembers(stream::StreamWriter& writer, Ptr closure) - { - auto info = closureInfos[closure.Obj()]; - - FOREACH(Ptr, symbol, info->symbols.Values()) - { - writer.WriteString(L"\t\t"); - writer.WriteString(ConvertType(symbol->typeInfo.Obj())); - writer.WriteString(L" "); - writer.WriteString(ConvertName(symbol->name)); - writer.WriteLine(L";"); - } - - FOREACH_INDEXER(ITypeDescriptor*, thisType, index, info->thisTypes) - { - auto typeInfo = MakePtr(MakePtr(thisType, TypeInfoHint::Normal)); - - writer.WriteString(L"\t\t"); - writer.WriteString(ConvertType(typeInfo.Obj())); - writer.WriteString(L" "); - writer.WriteString(L"__vwsnthis_" + itow(index)); - writer.WriteLine(L";"); - } - - return info->symbols.Count() + info->thisTypes.Count() > 0; - } - - void WfCppConfig::WriteCpp_ClosureCtor(stream::StreamWriter& writer, Ptr closure, const WString& name) - { - auto info = closureInfos[closure.Obj()]; - - writer.WriteString(name); - writer.WriteString(L"("); - - vint argumentIndex = 0; - - FOREACH_INDEXER(Ptr, symbol, index, From(info->symbols.Values()).Concat(info->ctorArgumentSymbols.Values())) - { - if (argumentIndex++ > 0) - { - writer.WriteString(L", "); - } - writer.WriteString(ConvertType(symbol->typeInfo.Obj())); - writer.WriteString(L" __vwsnctor_"); - writer.WriteString(ConvertName(symbol->name)); - } - - FOREACH_INDEXER(ITypeDescriptor*, thisType, index, info->thisTypes) - { - auto typeInfo = MakePtr(MakePtr(thisType, TypeInfoHint::Normal)); - - if (argumentIndex++ > 0) - { - writer.WriteString(L", "); - } - writer.WriteString(ConvertType(typeInfo.Obj())); - writer.WriteString(L" __vwsnctorthis_" + itow(index)); - } - - writer.WriteString(L")"); - } - - void WfCppConfig::WriteCpp_ClosureCtorInitList(stream::StreamWriter& writer, Ptr closure) - { - auto info = closureInfos[closure.Obj()]; - - FOREACH_INDEXER(Ptr, symbol, index, info->symbols.Values()) - { - if (index > 0) - { - writer.WriteString(L"\t\t, "); - } - else - { - writer.WriteString(L"\t\t:"); - } - writer.WriteString(ConvertName(symbol->name)); - writer.WriteString(L"(__vwsnctor_"); - writer.WriteString(ConvertName(symbol->name)); - writer.WriteLine(L")"); - } - - FOREACH_INDEXER(ITypeDescriptor*, thisType, index, info->thisTypes) - { - if (index > 0 || info->symbols.Count() > 0) - { - writer.WriteString(L"\t\t, "); - } - else - { - writer.WriteString(L"\t\t:"); - } - writer.WriteString(L"__vwsnthis_" + itow(index)); - writer.WriteString(L"(::vl::__vwsn::This(__vwsnctorthis_" + itow(index)); - writer.WriteLine(L"))"); - } - } - - void WfCppConfig::WriteCpp_LambdaExprImpl(stream::StreamWriter& writer, Ptr lambda) - { - if (auto ordered = lambda.Cast()) - { - auto name = lambdaExprs[lambda.Obj()]; - - writer.WriteString(L"\t"); - WriteCpp_ClosureCtor(writer, lambda, name + L"::" + name); - writer.WriteLine(L""); - WriteCpp_ClosureCtorInitList(writer, lambda); - writer.WriteLine(L"\t{"); - writer.WriteLine(L"\t}"); - writer.WriteLine(L""); - - writer.WriteString(L"\t"); - auto returnType = WriteFunctionHeader(writer, ordered, name + L"::operator()", true); - writer.WriteLine(L" const"); - writer.WriteLine(L"\t{"); - WriteFunctionBody(writer, ordered->body, L"\t\t", returnType); - writer.WriteLine(L"\t}"); - } - else if (auto funcExpr = lambda.Cast()) - { - auto name = lambdaExprs[lambda.Obj()]; - - writer.WriteString(L"\t"); - WriteCpp_ClosureCtor(writer, lambda, name + L"::" + name); - writer.WriteLine(L""); - WriteCpp_ClosureCtorInitList(writer, lambda); - writer.WriteLine(L"\t{"); - writer.WriteLine(L"\t}"); - writer.WriteLine(L""); - - writer.WriteString(L"\t"); - auto returnType = WriteFunctionHeader(writer, funcExpr, name + L"::operator()", true); - writer.WriteLine(L" const"); - WriteFunctionBody(writer, funcExpr->function->statement, L"\t", returnType); - } - } - - class WriteCpp_ClassExprImpl_InitFieldVisitor - : public empty_visitor::DeclarationVisitor - { - public: - WfCppConfig* config; - stream::StreamWriter& writer; - - WriteCpp_ClassExprImpl_InitFieldVisitor(WfCppConfig* _config, stream::StreamWriter& _writer) - :config(_config) - , writer(_writer) - { - } - - void Dispatch(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - - void Visit(WfVariableDeclaration* node)override - { - if (node->expression) - { - auto scope = config->manager->nodeScopes[node].Obj(); - auto symbol = scope->symbols[node->name.value][0]; - auto typeInfo = symbol->typeInfo; - writer.WriteString(L"\t\tthis->"); - writer.WriteString(config->ConvertName(node->name.value)); - writer.WriteString(L" = "); - GenerateExpression(config, writer, node->expression, typeInfo.Obj()); - writer.WriteLine(L";"); - } - } - }; - - void WfCppConfig::WriteCpp_ClassExprImpl(stream::StreamWriter& writer, Ptr lambda) - { - auto name = classExprs[lambda.Obj()]; - - writer.WriteString(L"\t"); - WriteCpp_ClosureCtor(writer, lambda, name + L"::" + name); - writer.WriteLine(L""); - WriteCpp_ClosureCtorInitList(writer, lambda); - writer.WriteLine(L"\t{"); - - { - WriteCpp_ClassExprImpl_InitFieldVisitor visitor(this, writer); - FOREACH(Ptr, memberDecl, lambda->declarations) - { - memberDecl->Accept(&visitor); - } - } - - writer.WriteLine(L"\t}"); - writer.WriteLine(L""); - - WString classFullName = L"::" + assemblyNamespace + L"::" + name; - FOREACH(Ptr, memberDecl, lambda->declarations) - { - if (GenerateClassMemberImpl(this, writer, name, name, classFullName, memberDecl, L"\t")) - { - writer.WriteLine(L""); - } - } - } - } - } -} - -/*********************************************************************** -CPP\WFCPP_WRITEREFLECTION.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace cppcodegen - { - using namespace collections; - using namespace reflection; - using namespace reflection::description; - - void LoadTypes(WfCppConfig* config, List& tds) - { - CopyFrom( - tds, - From(config->manager->declarationTypes.Values()) - .OrderBy([](Ptr a, Ptr b) - { - return WString::Compare(a->GetTypeName(), b->GetTypeName()); - }) - .Select([](Ptr td) - { - return td.Obj(); - }) - ); - } - - void WfCppConfig::WriteHeader_Reflection(stream::StreamWriter& writer) - { - writer.WriteLine(L"/***********************************************************************"); - writer.WriteLine(L"Reflection"); - writer.WriteLine(L"***********************************************************************/"); - writer.WriteLine(L""); - List tds; - LoadTypes(this, tds); - - writer.WriteLine(L"namespace vl"); - writer.WriteLine(L"{"); - writer.WriteLine(L"\tnamespace reflection"); - writer.WriteLine(L"\t{"); - writer.WriteLine(L"\t\tnamespace description"); - writer.WriteLine(L"\t\t{"); - writer.WriteLine(L"#ifndef VCZH_DEBUG_NO_REFLECTION"); - - FOREACH(ITypeDescriptor*, td, tds) - { - writer.WriteString(L"\t\t\tDECL_TYPE_INFO("); - writer.WriteString(ConvertType(td)); - writer.WriteLine(L")"); - } - - List tdInterfaces; - CopyFrom( - tdInterfaces, - From(tds) - .Where([](ITypeDescriptor* td) - { - return td->GetTypeDescriptorFlags() == TypeDescriptorFlags::Interface; - }) - ); - { - vint processed = 0; - while (processed < tdInterfaces.Count()) - { - vint count = tdInterfaces.Count(); - for (vint i = processed; i < count; i++) - { - auto td = tdInterfaces[i]; - if (Range(0, td->GetBaseTypeDescriptorCount()) - .All([&](vint baseIndex) - { - return tdInterfaces.IndexOf(td->GetBaseTypeDescriptor(baseIndex)) < processed; - })) - { - tdInterfaces.RemoveAt(i); - tdInterfaces.Insert(processed++, td); - } - } - } - } - - if (tdInterfaces.Count() > 0) - { - FOREACH(ITypeDescriptor*, td, tdInterfaces) - { - List baseTds; - CopyFrom( - baseTds, - Range(0, td->GetBaseTypeDescriptorCount()) - .Select([&](vint index) - { - return td->GetBaseTypeDescriptor(index); - }) - .Where([&](ITypeDescriptor* baseTd) - { - return baseTd->GetTypeDescriptorFlags() != TypeDescriptorFlags::IDescriptable; - }) - ); - - writer.WriteLine(L""); - if (baseTds.Count() > 0) - { - writer.WriteString(L"\t\t\tBEGIN_INTERFACE_PROXY_SHAREDPTR("); - writer.WriteString(ConvertType(td)); - FOREACH(ITypeDescriptor*, baseTd, baseTds) - { - writer.WriteString(L", "); - writer.WriteString(ConvertType(baseTd)); - } - writer.WriteLine(L")"); - } - else - { - writer.WriteString(L"\t\t\tBEGIN_INTERFACE_PROXY_NOPARENT_SHAREDPTR("); - writer.WriteString(ConvertType(td)); - writer.WriteLine(L")"); - } - - vint methodGroupCount = td->GetMethodGroupCount(); - for (vint i = 0; i < methodGroupCount; i++) - { - auto methodGroup = td->GetMethodGroup(i); - vint methodCount = methodGroup->GetMethodCount(); - for (vint j = 0; j < methodCount; j++) - { - auto methodInfo = methodGroup->GetMethod(j); - if (!methodInfo->IsStatic()) - { - writer.WriteString(L"\t\t\t\t"); - WriteFunctionHeader(writer, methodInfo, ConvertName(methodInfo->GetName()), true); - writer.WriteLine(L" override"); - writer.WriteLine(L"\t\t\t\t{"); - - if (methodInfo->GetReturn()->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - writer.WriteString(L"\t\t\t\t\tINVOKE_INTERFACE_PROXY"); - } - else - { - writer.WriteString(L"\t\t\t\t\tINVOKEGET_INTERFACE_PROXY"); - } - - if (methodInfo->GetParameterCount() > 0) - { - writer.WriteString(L"("); - writer.WriteString(ConvertName(methodInfo->GetName())); - vint parameterCount = methodInfo->GetParameterCount(); - for (vint k = 0; k < parameterCount; k++) - { - writer.WriteString(L", "); - writer.WriteString(ConvertName(methodInfo->GetParameter(k)->GetName())); - } - writer.WriteLine(L");"); - } - else - { - writer.WriteString(L"_NOPARAMS("); - writer.WriteString(ConvertName(methodInfo->GetName())); - writer.WriteLine(L");"); - } - - writer.WriteLine(L"\t\t\t\t}"); - } - } - } - - writer.WriteString(L"\t\t\tEND_INTERFACE_PROXY("); - writer.WriteString(ConvertType(td)); - writer.WriteLine(L")"); - } - } - - writer.WriteLine(L"#endif"); - writer.WriteLine(L""); - - writer.WriteString(L"\t\t\textern bool Load"); - writer.WriteString(assemblyName); - writer.WriteLine(L"Types();"); - writer.WriteLine(L"\t\t}"); - writer.WriteLine(L"\t}"); - writer.WriteLine(L"}"); - } - - void WfCppConfig::WriteCpp_Reflection(stream::StreamWriter& writer) - { - writer.WriteLine(L"/***********************************************************************"); - writer.WriteLine(L"Reflection"); - writer.WriteLine(L"***********************************************************************/"); - writer.WriteLine(L""); - List tds; - LoadTypes(this, tds); - - writer.WriteLine(L"namespace vl"); - writer.WriteLine(L"{"); - writer.WriteLine(L"\tnamespace reflection"); - writer.WriteLine(L"\t{"); - writer.WriteLine(L"\t\tnamespace description"); - writer.WriteLine(L"\t\t{"); - writer.WriteLine(L"#ifndef VCZH_DEBUG_NO_REFLECTION"); - - FOREACH(ITypeDescriptor*, td, tds) - { - writer.WriteString(L"\t\t\tIMPL_CPP_TYPE_INFO("); - WString type = ConvertType(td); - if (type.Length() > 2 && type.Sub(0, 2) == L"::") - { - type = type.Sub(2, type.Length() - 2); - } - writer.WriteString(type); - writer.WriteLine(L")"); - } - writer.WriteLine(L""); - - writer.WriteLine(L"#define _ ,"); - FOREACH(ITypeDescriptor*, td, tds) - { - switch (td->GetTypeDescriptorFlags()) - { - case TypeDescriptorFlags::NormalEnum: - case TypeDescriptorFlags::FlagEnum: - { - writer.WriteString(L"\t\t\tBEGIN_ENUM_ITEM"); - if (td->GetTypeDescriptorFlags() == TypeDescriptorFlags::FlagEnum) - { - writer.WriteString(L"_MERGABLE"); - } - writer.WriteString(L"("); - writer.WriteString(ConvertType(td)); - writer.WriteLine(L")"); - - auto enumType = td->GetEnumType(); - vint count = enumType->GetItemCount(); - for (vint i = 0; i < count; i++) - { - writer.WriteString(L"\t\t\t\tENUM_CLASS_ITEM("); - writer.WriteString(ConvertName(enumType->GetItemName(i))); - writer.WriteLine(L")"); - } - - writer.WriteString(L"\t\t\tEND_ENUM_ITEM("); - writer.WriteString(ConvertType(td)); - writer.WriteLine(L")"); - } - break; - case TypeDescriptorFlags::Struct: - { - writer.WriteString(L"\t\t\tBEGIN_STRUCT_MEMBER("); - writer.WriteString(ConvertType(td)); - writer.WriteLine(L")"); - - vint count = td->GetPropertyCount(); - for (vint i = 0; i < count; i++) - { - writer.WriteString(L"\t\t\t\tSTRUCT_MEMBER("); - writer.WriteString(ConvertName(td->GetProperty(i)->GetName())); - writer.WriteLine(L")"); - } - - writer.WriteString(L"\t\t\tEND_STRUCT_MEMBER("); - writer.WriteString(ConvertType(td)); - writer.WriteLine(L")"); - } - break; - case TypeDescriptorFlags::Interface: - case TypeDescriptorFlags::Class: - { - if (td->GetTypeDescriptorFlags() == TypeDescriptorFlags::Interface) - { - writer.WriteString(L"\t\t\tBEGIN_INTERFACE_MEMBER("); - } - else - { - writer.WriteString(L"\t\t\tBEGIN_CLASS_MEMBER("); - } - writer.WriteString(ConvertType(td)); - writer.WriteLine(L")"); - - if (td->GetTypeDescriptorFlags() == TypeDescriptorFlags::Class) - { - auto methodGroup = td->GetConstructorGroup(); - vint methodCount = methodGroup->GetMethodCount(); - for (vint j = 0; j < methodCount; j++) - { - auto methodInfo = methodGroup->GetMethod(j); - vint parameterCount = methodInfo->GetParameterCount(); - - writer.WriteString(L"\t\t\t\tCLASS_MEMBER_CONSTRUCTOR("); - writer.WriteString(ConvertType(methodInfo->GetReturn())); - writer.WriteString(L"("); - for (vint k = 0; k < parameterCount; k++) - { - if (k > 0) - { - writer.WriteString(L", "); - } - writer.WriteString(ConvertArgumentType(methodInfo->GetParameter(k)->GetType())); - } - writer.WriteString(L")"); - - if (parameterCount > 0) - { - writer.WriteString(L", {"); - for (vint k = 0; k < parameterCount; k++) - { - if (k > 0) - { - writer.WriteString(L" _"); - } - writer.WriteString(L" L\""); - writer.WriteString(ConvertName(methodInfo->GetParameter(k)->GetName())); - writer.WriteString(L"\""); - } - writer.WriteLine(L" })"); - } - else - { - writer.WriteLine(L", NO_PARAMETER)"); - } - } - } - - vint methodGroupCount = td->GetMethodGroupCount(); - for (vint i = 0; i < methodGroupCount; i++) - { - auto methodGroup = td->GetMethodGroup(i); - vint methodCount = methodGroup->GetMethodCount(); - for (vint j = 0; j < methodCount; j++) - { - auto methodInfo = methodGroup->GetMethod(j); - if (methodInfo->IsStatic()) - { - writer.WriteString(L"\t\t\t\tCLASS_MEMBER_STATIC_METHOD"); - } - else - { - writer.WriteString(L"\t\t\t\tCLASS_MEMBER_METHOD"); - } - if (methodCount > 1) - { - writer.WriteString(L"_OVERLOAD"); - } - writer.WriteString(L"("); - writer.WriteString(ConvertName(methodInfo->GetName())); - - vint parameterCount = methodInfo->GetParameterCount(); - if (parameterCount > 0) - { - writer.WriteString(L", {"); - for (vint k = 0; k < parameterCount; k++) - { - if (k > 0) - { - writer.WriteString(L" _"); - } - writer.WriteString(L" L\""); - writer.WriteString(ConvertName(methodInfo->GetParameter(k)->GetName())); - writer.WriteString(L"\""); - } - writer.WriteString(L" }"); - } - else - { - writer.WriteString(L", NO_PARAMETER"); - } - if (methodCount > 1) - { - writer.WriteString(L", "); - auto typeDecorator = methodInfo->IsStatic() ? WString(L"(*)", false) : L"(" + ConvertType(td) + L"::*)"; - writer.WriteString(ConvertFunctionType(methodInfo, typeDecorator)); - } - writer.WriteLine(L")"); - } - } - - vint eventCount = td->GetEventCount(); - for (vint i = 0; i < eventCount; i++) - { - auto eventInfo = td->GetEvent(i); - writer.WriteString(L"\t\t\t\tCLASS_MEMBER_EVENT("); - writer.WriteString(ConvertName(eventInfo->GetName())); - writer.WriteLine(L")"); - } - - vint propertyCount = td->GetPropertyCount(); - for (vint i = 0; i < propertyCount; i++) - { - auto propertyInfo = td->GetProperty(i); - if (auto getter = propertyInfo->GetGetter()) - { - if (auto eventInfo = propertyInfo->GetValueChangedEvent()) - { - if (auto setter = propertyInfo->GetSetter()) - { - writer.WriteString(L"\t\t\t\tCLASS_MEMBER_PROPERTY_EVENT("); - writer.WriteString(ConvertName(propertyInfo->GetName())); - writer.WriteString(L", "); - writer.WriteString(ConvertName(getter->GetName())); - writer.WriteString(L", "); - writer.WriteString(ConvertName(setter->GetName())); - writer.WriteString(L", "); - writer.WriteString(ConvertName(eventInfo->GetName())); - writer.WriteLine(L")"); - } - else - { - writer.WriteString(L"\t\t\t\tCLASS_MEMBER_PROPERTY_EVENT_READONLY("); - writer.WriteString(ConvertName(propertyInfo->GetName())); - writer.WriteString(L", "); - writer.WriteString(ConvertName(getter->GetName())); - writer.WriteString(L", "); - writer.WriteString(ConvertName(eventInfo->GetName())); - writer.WriteLine(L")"); - } - } - else - { - if (auto setter = propertyInfo->GetSetter()) - { - writer.WriteString(L"\t\t\t\tCLASS_MEMBER_PROPERTY("); - writer.WriteString(ConvertName(propertyInfo->GetName())); - writer.WriteString(L", "); - writer.WriteString(ConvertName(getter->GetName())); - writer.WriteString(L", "); - writer.WriteString(ConvertName(setter->GetName())); - writer.WriteLine(L")"); - } - else - { - writer.WriteString(L"\t\t\t\tCLASS_MEMBER_PROPERTY_READONLY("); - writer.WriteString(ConvertName(propertyInfo->GetName())); - writer.WriteString(L", "); - writer.WriteString(ConvertName(getter->GetName())); - writer.WriteLine(L")"); - } - } - } - else - { - writer.WriteString(L"\t\t\t\tCLASS_MEMBER_FIELD("); - writer.WriteString(ConvertName(propertyInfo->GetName())); - writer.WriteLine(L")"); - } - } - - if (td->GetTypeDescriptorFlags() == TypeDescriptorFlags::Interface) - { - writer.WriteString(L"\t\t\tEND_INTERFACE_MEMBER("); - } - else - { - writer.WriteString(L"\t\t\tEND_CLASS_MEMBER("); - } - writer.WriteString(ConvertType(td)); - writer.WriteLine(L")"); - } - break; - default:; - } - writer.WriteLine(L""); - } - writer.WriteLine(L"#undef _"); - - writer.WriteString(L"\t\t\tclass "); - writer.WriteString(assemblyName); - writer.WriteLine(L"TypeLoader : public Object, public ITypeLoader"); - writer.WriteLine(L"\t\t\t{"); - writer.WriteLine(L"\t\t\tpublic:"); - writer.WriteLine(L"\t\t\t\tvoid Load(ITypeManager* manager)"); - writer.WriteLine(L"\t\t\t\t{"); - - FOREACH(ITypeDescriptor*, td, tds) - { - writer.WriteString(L"\t\t\t\t\tADD_TYPE_INFO("); - writer.WriteString(ConvertType(td)); - writer.WriteLine(L")"); - } - writer.WriteLine(L"\t\t\t\t}"); - writer.WriteLine(L""); - writer.WriteLine(L"\t\t\t\tvoid Unload(ITypeManager* manager)"); - writer.WriteLine(L"\t\t\t\t{"); - writer.WriteLine(L"\t\t\t\t}"); - writer.WriteLine(L"\t\t\t};"); - - writer.WriteLine(L"#endif"); - writer.WriteLine(L""); - - writer.WriteString(L"\t\t\tbool Load"); - writer.WriteString(assemblyName); - writer.WriteLine(L"Types()"); - writer.WriteLine(L"\t\t\t{"); - writer.WriteLine(L"#ifndef VCZH_DEBUG_NO_REFLECTION"); - writer.WriteLine(L"\t\t\t\tif (auto manager = GetGlobalTypeManager())"); - writer.WriteLine(L"\t\t\t\t{"); - writer.WriteString(L"\t\t\t\t\treturn manager->AddTypeLoader(MakePtr<"); - writer.WriteString(assemblyName); - writer.WriteLine(L"TypeLoader>());"); - writer.WriteLine(L"\t\t\t\t}"); - writer.WriteLine(L"#endif"); - writer.WriteLine(L"\t\t\t\treturn false;"); - writer.WriteLine(L"\t\t\t}"); - - writer.WriteLine(L"\t\t}"); - writer.WriteLine(L"\t}"); - writer.WriteLine(L"}"); - } - } - } -} - -/*********************************************************************** -CPP\WFCPP_WRITESTRUCT.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace cppcodegen - { - using namespace collections; - - void WfCppConfig::WriteHeader_Struct(stream::StreamWriter& writer, Ptr decl, const WString& name, const WString& prefix) - { - auto td = manager->declarationTypes[decl.Obj()].Obj(); - writer.WriteLine(prefix + L"struct " + name); - writer.WriteLine(prefix + L"{"); - FOREACH(Ptr, member, decl->members) - { - auto prop = td->GetPropertyByName(member->name.value, false); - auto defaultValue = DefaultValue(prop->GetReturn()); - if (defaultValue != L"") - { - defaultValue = L" = " + defaultValue; - } - writer.WriteLine(prefix + L"\t" + ConvertType(prop->GetReturn()) + L" " + ConvertName(member->name.value) + defaultValue + L";"); - } - writer.WriteLine(prefix + L"};"); - } - - void WfCppConfig::WriteHeader_StructOp(stream::StreamWriter& writer, Ptr decl, const WString& name, const WString& prefix) - { - using opt = Tuple; - opt ops[] = { - opt(L"==", L"false", L"true"), - opt(L"!=", L"true", L"false") - }; - for (auto op : ops) - { - writer.WriteString(prefix); - writer.WriteString(L"inline bool operator"); - writer.WriteString(op.f0); - writer.WriteString(L" (const "); - writer.WriteString(name); - writer.WriteString(L"& a, const "); - writer.WriteString(name); - writer.WriteLine(L"& b)"); - - writer.WriteString(prefix); - writer.WriteLine(L"{"); - - FOREACH(Ptr, member, decl->members) - { - writer.WriteString(prefix); - writer.WriteString(L"\tif (a."); - writer.WriteString(ConvertName(member->name.value)); - writer.WriteString(L" != b."); - writer.WriteString(ConvertName(member->name.value)); - writer.WriteString(L") return "); - writer.WriteString(op.f1); - writer.WriteLine(L";"); - } - writer.WriteString(prefix); - writer.WriteString(L"\treturn "); - writer.WriteString(op.f2); - writer.WriteLine(L";"); - - writer.WriteString(prefix); - writer.WriteLine(L"}"); - } - } - - void WfCppConfig::WriteHeader_Struct(stream::StreamWriter& writer, Ptr decl, collections::List& nss) - { - auto td = manager->declarationTypes[decl.Obj()].Obj(); - WString name; - auto prefix = WriteNamespace(writer, CppGetFullName(td), nss, name); - WriteHeader_Struct(writer, decl, name, prefix); - WriteHeader_StructOp(writer, decl, name, prefix); - } - } - } -} - -/*********************************************************************** -EMITTER\WFEMITTER.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace emitter - { - using namespace parsing; - using namespace reflection::description; - using namespace analyzer; - using namespace runtime; - -/*********************************************************************** -WfAttributeEvaluator -***********************************************************************/ - - WfAttributeEvaluator::WfAttributeEvaluator(analyzer::WfLexicalScopeManager* _manager) - :manager(_manager) - { - } - - Ptr WfAttributeEvaluator::GetAttribute(collections::List>& atts, const WString& category, const WString& name) - { - return From(GetAttributes(atts, category, name)).First(nullptr); - } - - collections::LazyList> WfAttributeEvaluator::GetAttributes(collections::List>& atts, const WString& category, const WString& name) - { - return From(atts) - .Where([=](Ptr att) - { - return att->category.value == category && att->name.value == name; - }); - } - - Value WfAttributeEvaluator::GetAttributeValue(Ptr att) - { - if (!att->value) - { - return Value(); - } - - { - vint index = attributeValues.Keys().IndexOf(att.Obj()); - if (index != -1) - { - return attributeValues.Values()[index]; - } - } - - if (!attributeAssembly) - { - attributeAssembly = MakePtr(); - - auto func = MakePtr(); - func->name = L""; - func->firstInstruction = 0; - - vint index = attributeAssembly->functions.Add(func); - attributeAssembly->functionByName.Add(func->name, index); - } - - attributeAssembly->insBeforeCodegen = MakePtr(); - attributeAssembly->insAfterCodegen = MakePtr(); - attributeAssembly->instructions.Clear(); - - WfCodegenContext context(attributeAssembly, manager); - { - auto recorderBefore = new ParsingGeneratedLocationRecorder(context.nodePositionsBeforeCodegen); - auto recorderAfter = new ParsingGeneratedLocationRecorder(context.nodePositionsAfterCodegen); - auto recorderOriginal = new ParsingOriginalLocationRecorder(recorderBefore); - auto recorderMultiple = new ParsingMultiplePrintNodeRecorder; - recorderMultiple->AddRecorder(recorderOriginal); - recorderMultiple->AddRecorder(recorderAfter); - - stream::MemoryStream memoryStream; - { - stream::StreamWriter streamWriter(memoryStream); - ParsingWriter parsingWriter(streamWriter, recorderMultiple); - WfPrint(att->value, L"", parsingWriter); - } - } - auto typeInfo = manager->attributes[{att->category.value, att->name.value}]; - GenerateExpressionInstructions(context, att->value, typeInfo); - attributeAssembly->instructions.Add(WfInstruction::Return()); - - if (!attributeGlobalContext) - { - attributeGlobalContext = MakePtr(attributeAssembly); - } - auto func = LoadFunction(attributeGlobalContext, L""); - auto value = func(); - attributeValues.Add(att, value); - return func(); - } - -/*********************************************************************** -WfCodegenFunctionContext -***********************************************************************/ - - WfCodegenFunctionContext::WfCodegenFunctionContext() - { - scopeContextStack.Add(new WfCodegenScopeContext); - } - - Ptr WfCodegenFunctionContext::GetCurrentScopeContext() - { - return scopeContextStack[scopeContextStack.Count() - 1]; - } - - Ptr WfCodegenFunctionContext::GetCurrentScopeContext(WfCodegenScopeType type) - { - for (vint i = scopeContextStack.Count() - 1; i >= 0; i--) - { - auto context = scopeContextStack[i]; - if (context->type == type) - { - return context; - } - } - return 0; - } - - Ptr WfCodegenFunctionContext::PushScopeContext(WfCodegenScopeType type) - { - auto context = MakePtr(); - context->type = type; - scopeContextStack.Add(context); - return context; - } - - void WfCodegenFunctionContext::PopScopeContext() - { - scopeContextStack.RemoveAt(scopeContextStack.Count() - 1); - } - -/*********************************************************************** -WfCodegenContext -***********************************************************************/ - - WfCodegenContext::WfCodegenContext(Ptr _assembly, analyzer::WfLexicalScopeManager* _manager) - :assembly(_assembly) - , manager(_manager) - { - } - - vint WfCodegenContext::AddInstruction(parsing::ParsingTreeCustomBase* node, const runtime::WfInstruction& ins) - { - auto index = assembly->instructions.Add(ins); - if (node) - { - assembly->insBeforeCodegen->instructionCodeMapping.Add(nodePositionsBeforeCodegen[node]); - assembly->insAfterCodegen->instructionCodeMapping.Add(nodePositionsAfterCodegen[node]); - } - else - { - parsing::ParsingTextRange range; - assembly->insBeforeCodegen->instructionCodeMapping.Add(range); - assembly->insAfterCodegen->instructionCodeMapping.Add(range); - } - return index; - } - - void WfCodegenContext::AddExitInstruction(parsing::ParsingTreeCustomBase* node, const runtime::WfInstruction& ins) - { - auto context = functionContext->GetCurrentScopeContext(); - context->exitInstructions.Add(ins); - context->instructionCodeMappingBeforeCodegen.Add(nodePositionsBeforeCodegen[node]); - context->instructionCodeMappingAfterCodegen.Add(nodePositionsAfterCodegen[node]); - } - - void WfCodegenContext::ApplyExitInstructions(Ptr scopeContext) - { - if (scopeContext->exitInstructions.Count() > 0) - { - CopyFrom(assembly->instructions, scopeContext->exitInstructions, true); - CopyFrom(assembly->insBeforeCodegen->instructionCodeMapping, scopeContext->instructionCodeMappingBeforeCodegen, true); - CopyFrom(assembly->insAfterCodegen->instructionCodeMapping, scopeContext->instructionCodeMappingAfterCodegen, true); - } - } - - vint WfCodegenContext::GetThisStackCount(analyzer::WfLexicalScope* scope) - { - vint count = 0; - Ptr firstConfig, methodConfig; - while (scope) - { - if (scope->typeOfThisExpr) - { - if (methodConfig) - { - count++; - if (!methodConfig->parentThisAccessable) - { - break; - } - methodConfig = nullptr; - } - } - - if (scope->functionConfig) - { - if (!firstConfig) - { - vint index = thisStackCounts.Keys().IndexOf(scope->functionConfig.Obj()); - if (index == -1) - { - firstConfig = scope->functionConfig; - } - else - { - return thisStackCounts.Values()[index]; - } - } - if (scope->functionConfig->thisAccessable) - { - methodConfig = scope->functionConfig; - } - } - scope = scope->parentScope.Obj(); - } - - if (firstConfig) - { - thisStackCounts.Add(firstConfig, count); - } - return count; - } - } - } -} - -/*********************************************************************** -EMITTER\WFEMITTER_ASSEMBLY.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace emitter - { - using namespace parsing; - using namespace reflection::description; - using namespace analyzer; - using namespace runtime; - using namespace typeimpl; - - typedef WfInstruction Ins; - -#define INSTRUCTION(X) context.AddInstruction(node, X) - -/*********************************************************************** -GenerateTypeCastInstructions -***********************************************************************/ - - void GenerateTypeCastInstructions(WfCodegenContext& context, Ptr expectedType, bool strongCast, WfExpression* node) - { - if (expectedType->GetTypeDescriptor() != GetTypeDescriptor()) - { - if (strongCast) - { - switch (expectedType->GetDecorator()) - { - case ITypeInfo::RawPtr: - INSTRUCTION(Ins::ConvertToType(Value::RawPtr, expectedType->GetTypeDescriptor())); - break; - case ITypeInfo::SharedPtr: - INSTRUCTION(Ins::ConvertToType(Value::SharedPtr, expectedType->GetTypeDescriptor())); - break; - case ITypeInfo::Nullable: - case ITypeInfo::TypeDescriptor: - case ITypeInfo::Generic: - INSTRUCTION(Ins::ConvertToType(Value::BoxedValue, expectedType->GetTypeDescriptor())); - break; - } - } - else - { - switch (expectedType->GetDecorator()) - { - case ITypeInfo::RawPtr: - INSTRUCTION(Ins::TryConvertToType(Value::RawPtr, expectedType->GetTypeDescriptor())); - break; - case ITypeInfo::SharedPtr: - INSTRUCTION(Ins::TryConvertToType(Value::SharedPtr, expectedType->GetTypeDescriptor())); - break; - case ITypeInfo::Nullable: - case ITypeInfo::TypeDescriptor: - case ITypeInfo::Generic: - INSTRUCTION(Ins::TryConvertToType(Value::BoxedValue, expectedType->GetTypeDescriptor())); - break; - } - } - } - } - -/*********************************************************************** -GetInstructionTypeArgument -***********************************************************************/ - - void GenerateTypeTestingInstructions(WfCodegenContext& context, Ptr expectedType, WfExpression* node) - { - if (expectedType->GetTypeDescriptor() != GetTypeDescriptor()) - { - switch (expectedType->GetDecorator()) - { - case ITypeInfo::RawPtr: - INSTRUCTION(Ins::TestType(Value::RawPtr, expectedType->GetTypeDescriptor())); - break; - case ITypeInfo::SharedPtr: - INSTRUCTION(Ins::TestType(Value::SharedPtr, expectedType->GetTypeDescriptor())); - break; - case ITypeInfo::Nullable: - case ITypeInfo::TypeDescriptor: - case ITypeInfo::Generic: - INSTRUCTION(Ins::TestType(Value::BoxedValue, expectedType->GetTypeDescriptor())); - break; - } - } - else - { - INSTRUCTION(Ins::Pop()); - INSTRUCTION(Ins::LoadValue(BoxValue(true))); - } - } - -/*********************************************************************** -GenerateTypeCastInstructions -***********************************************************************/ - - runtime::WfInsType GetInstructionTypeArgument(Ptr expectedType) - { - auto td = expectedType->GetTypeDescriptor(); - if (td == GetTypeDescriptor()) return WfInsType::Bool; - if (td == GetTypeDescriptor()) return WfInsType::I1; - if (td == GetTypeDescriptor()) return WfInsType::I2; - if (td == GetTypeDescriptor()) return WfInsType::I4; - if (td == GetTypeDescriptor()) return WfInsType::I8; - if (td == GetTypeDescriptor()) return WfInsType::U1; - if (td == GetTypeDescriptor()) return WfInsType::U2; - if (td == GetTypeDescriptor()) return WfInsType::U4; - if (td == GetTypeDescriptor()) return WfInsType::U8; - if (td == GetTypeDescriptor()) return WfInsType::F4; - if (td == GetTypeDescriptor()) return WfInsType::F8; - if (td == GetTypeDescriptor()) return WfInsType::String; - return WfInsType::Unknown; - } - -/*********************************************************************** -GenerateAssembly -***********************************************************************/ - -#define CALLBACK(EXPR) if (callback) callback->EXPR - - Ptr GenerateAssembly(analyzer::WfLexicalScopeManager* manager, IWfCompilerCallback* callback) - { - CALLBACK(OnGenerateMetadata()); - auto assembly = MakePtr(); - assembly->insBeforeCodegen = new WfInstructionDebugInfo; - assembly->insAfterCodegen = new WfInstructionDebugInfo; - - WfCodegenContext context(assembly, manager); - FOREACH_INDEXER(Ptr, module, index, manager->GetModules()) - { - auto codeBeforeCodegen = manager->GetModuleCodes()[index]; - - auto recorderBefore = new ParsingGeneratedLocationRecorder(context.nodePositionsBeforeCodegen); - auto recorderAfter = new ParsingGeneratedLocationRecorder(context.nodePositionsAfterCodegen); - auto recorderOriginal = new ParsingOriginalLocationRecorder(recorderBefore); - auto recorderMultiple = new ParsingMultiplePrintNodeRecorder; - recorderMultiple->AddRecorder(recorderOriginal); - recorderMultiple->AddRecorder(recorderAfter); - - stream::MemoryStream memoryStream; - { - stream::StreamWriter streamWriter(memoryStream); - ParsingWriter parsingWriter(streamWriter, recorderMultiple, index); - WfPrint(module, L"", parsingWriter); - } - - memoryStream.SeekFromBegin(0); - auto codeAfterCodegen = stream::StreamReader(memoryStream).ReadToEnd(); - - assembly->insBeforeCodegen->moduleCodes.Add(codeBeforeCodegen); - assembly->insAfterCodegen->moduleCodes.Add(codeAfterCodegen); - } - - if (manager->declarationTypes.Count() > 0) - { - assembly->typeImpl = new WfTypeImpl; - FOREACH(Ptr, td, manager->declarationTypes.Values()) - { - if (auto tdClass = td.Cast()) - { - assembly->typeImpl->classes.Add(tdClass); - } - else if (auto tdInterface = td.Cast()) - { - assembly->typeImpl->interfaces.Add(tdInterface); - } - else if (auto tdStruct = td.Cast()) - { - assembly->typeImpl->structs.Add(tdStruct); - } - else if (auto tdEnum = td.Cast()) - { - assembly->typeImpl->enums.Add(tdEnum); - } - } - } - - FOREACH(Ptr, module, manager->GetModules()) - { - FOREACH(Ptr, decl, module->declarations) - { - GenerateGlobalDeclarationMetadata(context, decl); - } - } - - { - auto meta = MakePtr(); - meta->name = L""; - vint functionIndex = assembly->functions.Add(meta); - assembly->functionByName.Add(meta->name, functionIndex); - - auto functionContext = MakePtr(); - functionContext->function = meta; - context.functionContext = functionContext; - - meta->firstInstruction = assembly->instructions.Count(); - FOREACH(Ptr, module, manager->GetModules()) - { - FOREACH(Ptr, decl, module->declarations) - { - GenerateInitializeInstructions(context, decl); - } - } - - // define node for INSTRUCTION - parsing::ParsingTreeCustomBase* node = nullptr; - INSTRUCTION(Ins::LoadValue(Value())); - INSTRUCTION(Ins::Return()); - - meta->lastInstruction = assembly->instructions.Count() - 1; - - context.functionContext = 0; - GenerateClosureInstructions(context, functionContext); - } - - FOREACH(Ptr, module, manager->GetModules()) - { - CALLBACK(OnGenerateCode(module)); - FOREACH(Ptr, decl, module->declarations) - { - GenerateDeclarationInstructions(context, decl); - } - } - - CALLBACK(OnGenerateDebugInfo()); - assembly->Initialize(); - return assembly; - } - -#undef CALLBACK -#undef INSTRUCTION - -/*********************************************************************** -Compile -***********************************************************************/ - - Ptr Compile(Ptr table, analyzer::WfLexicalScopeManager* manager, collections::List& moduleCodes, collections::List>& errors) - { - manager->Clear(true, true); - FOREACH(WString, code, moduleCodes) - { - manager->AddModule(code); - } - - if (manager->errors.Count() > 0) - { - CopyFrom(errors, manager->errors); - return 0; - } - - manager->Rebuild(true); - if (manager->errors.Count() > 0) - { - CopyFrom(errors, manager->errors); - return 0; - } - - return GenerateAssembly(manager); - } - - Ptr Compile(Ptr table, collections::List& moduleCodes, collections::List>& errors) - { - WfLexicalScopeManager manager(table); - return Compile(table, &manager, moduleCodes, errors); - } - } - } -} - -/*********************************************************************** -EMITTER\WFEMITTER_DECLARATION.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace emitter - { - using namespace collections; - using namespace parsing; - using namespace reflection::description; - using namespace analyzer; - using namespace runtime; - using namespace typeimpl; - - typedef WfInstruction Ins; - -#define INSTRUCTION(X) context.AddInstruction(node, X) - -/*********************************************************************** -GenerateInstructions(Initialize) -***********************************************************************/ - - class GenerateInitializeInstructionsVisitor : public Object, public WfDeclaration::IVisitor - { - public: - WfCodegenContext& context; - - GenerateInitializeInstructionsVisitor(WfCodegenContext& _context) - :context(_context) - { - } - - void Visit(WfNamespaceDeclaration* node)override - { - FOREACH(Ptr, decl, node->declarations) - { - GenerateInitializeInstructions(context, decl); - } - } - - void Visit(WfFunctionDeclaration* node)override - { - } - - void Visit(WfVariableDeclaration* node)override - { - auto scope = context.manager->nodeScopes[node].Obj(); - auto symbol = scope->symbols[node->name.value][0]; - vint variableIndex = context.globalVariables[symbol.Obj()]; - GenerateExpressionInstructions(context, node->expression); - INSTRUCTION(Ins::StoreGlobalVar(variableIndex)); - } - - void Visit(WfEventDeclaration* node)override - { - } - - void Visit(WfPropertyDeclaration* node)override - { - } - - void Visit(WfConstructorDeclaration* node)override - { - } - - void Visit(WfDestructorDeclaration* node)override - { - } - - void Visit(WfClassDeclaration* node)override - { - } - - void Visit(WfEnumDeclaration* node)override - { - } - - void Visit(WfStructDeclaration* node)override - { - } - - void Visit(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - }; - - void GenerateInitializeInstructions(WfCodegenContext& context, Ptr declaration) - { - GenerateInitializeInstructionsVisitor visitor(context); - declaration->Accept(&visitor); - } - -/*********************************************************************** -GenerateInstructions(Declaration) -***********************************************************************/ - - Ptr GenerateFunctionInstructions_Prolog(WfCodegenContext& context, WfLexicalScope* scope, Ptr meta, Ptr returnType, Ptr recursiveLambdaSymbol, const List>& argumentSymbols, const List>& capturedSymbols, ParsingTreeCustomBase* node) - { - auto functionContext = MakePtr(); - functionContext->function = meta; - context.functionContext = functionContext; - { - FOREACH_INDEXER(Ptr, argumentSymbol, index, argumentSymbols) - { - functionContext->arguments.Add(argumentSymbol.Obj(), index); - } - FOREACH_INDEXER(Ptr, capturedSymbol, index, capturedSymbols) - { - functionContext->capturedVariables.Add(capturedSymbol.Obj(), index); - } - } - if (recursiveLambdaSymbol) - { - vint variableIndex = meta->argumentNames.Count() + meta->localVariableNames.Add(L"" + recursiveLambdaSymbol->name); - functionContext->localVariables.Add(recursiveLambdaSymbol.Obj(), variableIndex); - } - - meta->firstInstruction = context.assembly->instructions.Count(); - if (recursiveLambdaSymbol) - { - INSTRUCTION(Ins::LoadClosureContext()); - INSTRUCTION(Ins::LoadFunction(context.assembly->functions.IndexOf(meta.Obj()))); - INSTRUCTION(Ins::CreateClosure()); - INSTRUCTION(Ins::StoreLocalVar(functionContext->localVariables[recursiveLambdaSymbol.Obj()])); - } - return functionContext; - } - - void GenerateFunctionInstructions_Epilog(WfCodegenContext& context, WfLexicalScope* scope, Ptr meta, Ptr returnType, Ptr recursiveLambdaSymbol, const List>& argumentSymbols, const List>& capturedSymbols, Ptr functionContext, ParsingTreeCustomBase* node) - { - Value result; - if (returnType->GetDecorator() == ITypeInfo::TypeDescriptor) - { - if (auto vt = returnType->GetTypeDescriptor()->GetValueType()) - { - result = vt->CreateDefault(); - } - } - INSTRUCTION(Ins::LoadValue(Value())); - INSTRUCTION(Ins::Return()); - meta->lastInstruction = context.assembly->instructions.Count() - 1; - context.functionContext = 0; - - GenerateClosureInstructions(context, functionContext); - } - - void GenerateFunctionInstructions(WfCodegenContext& context, WfLexicalScope* scope, Ptr meta, Ptr returnType, Ptr recursiveLambdaSymbol, const List>& argumentSymbols, const List>& capturedSymbols, Ptr statementBody, ParsingTreeCustomBase* node) - { - auto functionContext = GenerateFunctionInstructions_Prolog(context, scope, meta, returnType, recursiveLambdaSymbol, argumentSymbols, capturedSymbols, node); - GenerateStatementInstructions(context, statementBody); - GenerateFunctionInstructions_Epilog(context, scope, meta, returnType, recursiveLambdaSymbol, argumentSymbols, capturedSymbols, functionContext, node); - } - - void GenerateFunctionInstructions(WfCodegenContext& context, WfLexicalScope* scope, Ptr meta, Ptr returnType, Ptr recursiveLambdaSymbol, const List>& argumentSymbols, const List>& capturedSymbols, Ptr expressionBody, ParsingTreeCustomBase* node) - { - auto functionContext = GenerateFunctionInstructions_Prolog(context, scope, meta, returnType, recursiveLambdaSymbol, argumentSymbols, capturedSymbols, node); - GenerateExpressionInstructions(context, expressionBody); - INSTRUCTION(Ins::Return()); - GenerateFunctionInstructions_Epilog(context, scope, meta, returnType, recursiveLambdaSymbol, argumentSymbols, capturedSymbols, functionContext, node); - } - - void GenerateFunctionDeclarationInstructions(WfCodegenContext& context, WfFunctionDeclaration* node, WfLexicalScope* scope, Ptr meta, Ptr recursiveLambdaSymbol) - { - List> argumentSymbols, capturedSymbols; - { - FOREACH(Ptr, argument, node->arguments) - { - auto symbol = scope->symbols[argument->name.value][0]; - argumentSymbols.Add(symbol); - } - - vint index = context.manager->lambdaCaptures.Keys().IndexOf(node); - if (index != -1) - { - auto capture = context.manager->lambdaCaptures.Values()[index]; - FOREACH(Ptr, symbol, capture->symbols) - { - capturedSymbols.Add(symbol); - } - } - } - - auto returnType = CreateTypeInfoFromType(scope, node->returnType); - GenerateFunctionInstructions(context, scope, meta, returnType, recursiveLambdaSymbol, argumentSymbols, capturedSymbols, node->statement, node); - } - - class GenerateClassMemberInstructionsVisitor : public Object, public WfDeclaration::IVisitor - { - public: - WfCodegenContext& context; - Ptr classDecl; - - GenerateClassMemberInstructionsVisitor(WfCodegenContext& _context, Ptr _classDecl) - :context(_context) - , classDecl(_classDecl) - { - } - - void Visit(WfNamespaceDeclaration* node)override - { - } - - void Visit(WfFunctionDeclaration* node)override - { - if (node->classMember->kind == WfClassMemberKind::Static) - { - GenerateDeclarationInstructions(context, node); - } - else if (classDecl->kind == WfClassKind::Class) - { - GenerateDeclarationInstructions(context, node); - } - } - - void Visit(WfVariableDeclaration* node)override - { - } - - void Visit(WfEventDeclaration* node)override - { - } - - void Visit(WfPropertyDeclaration* node)override - { - } - - class InitializeFieldVisitor - : public empty_visitor::DeclarationVisitor - { - public: - WfCodegenContext& context; - - InitializeFieldVisitor(WfCodegenContext& _context) - :context(_context) - { - } - - void Dispatch(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - - void Visit(WfVariableDeclaration* node)override - { - auto info = context.manager->declarationMemberInfos[node].Cast().Obj(); - GenerateExpressionInstructions(context, node->expression); - INSTRUCTION(Ins::LoadCapturedVar(0)); - INSTRUCTION(Ins::SetProperty(info)); - } - }; - - void Visit(WfConstructorDeclaration* node)override - { - auto meta = context.assembly->functions[context.constructors[node]]; - auto functionContext = MakePtr(); - functionContext->function = meta; - context.functionContext = functionContext; - meta->firstInstruction = context.assembly->instructions.Count(); - - auto scope = context.manager->nodeScopes[node].Obj(); - { - FOREACH_INDEXER(Ptr, argument, index, node->arguments) - { - auto symbol = scope->symbols[argument->name.value][0]; - functionContext->arguments.Add(symbol.Obj(), index); - } - } - - if (classDecl->baseTypes.Count() > 0) - { - auto td = scope->parentScope->typeOfThisExpr; - vint count = td->GetBaseTypeDescriptorCount(); - for (vint i = 0; i < count; i++) - { - auto baseTd = td->GetBaseTypeDescriptor(i); - auto ctor = context.manager->baseConstructorCallResolvings[{node, baseTd}]; - if (ctor.key) - { - FOREACH(Ptr, argument, ctor.key->arguments) - { - GenerateExpressionInstructions(context, argument); - } - INSTRUCTION(Ins::LoadCapturedVar(0)); - INSTRUCTION(Ins::InvokeBaseCtor(ctor.value, ctor.key->arguments.Count())); - } - else - { - INSTRUCTION(Ins::LoadCapturedVar(0)); - INSTRUCTION(Ins::InvokeBaseCtor(ctor.value, 0)); - } - INSTRUCTION(Ins::Pop()); - } - } - - { - InitializeFieldVisitor visitor(context); - FOREACH(Ptr, memberDecl, classDecl->declarations) - { - memberDecl->Accept(&visitor); - } - } - GenerateStatementInstructions(context, node->statement); - - INSTRUCTION(Ins::LoadValue(Value())); - INSTRUCTION(Ins::Return()); - meta->lastInstruction = context.assembly->instructions.Count() - 1; - context.functionContext = 0; - GenerateClosureInstructions(context, functionContext); - } - - void Visit(WfDestructorDeclaration* node)override - { - auto meta = context.assembly->functions[context.destructors[node]]; - auto functionContext = MakePtr(); - functionContext->function = meta; - context.functionContext = functionContext; - meta->firstInstruction = context.assembly->instructions.Count(); - - auto scope = context.manager->nodeScopes[node].Obj(); - GenerateStatementInstructions(context, node->statement); - - INSTRUCTION(Ins::LoadValue(Value())); - INSTRUCTION(Ins::Return()); - meta->lastInstruction = context.assembly->instructions.Count() - 1; - context.functionContext = 0; - GenerateClosureInstructions(context, functionContext); - } - - void Visit(WfClassDeclaration* node)override - { - GenerateDeclarationInstructions(context, node); - } - - void Visit(WfEnumDeclaration* node)override - { - } - - void Visit(WfStructDeclaration* node)override - { - } - - void Visit(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - }; - - class GenerateDeclarationInstructionsVisitor : public Object, public WfDeclaration::IVisitor - { - public: - WfCodegenContext& context; - - GenerateDeclarationInstructionsVisitor(WfCodegenContext& _context) - :context(_context) - { - } - - void Visit(WfNamespaceDeclaration* node)override - { - FOREACH(Ptr, decl, node->declarations) - { - GenerateDeclarationInstructions(context, decl); - } - } - - void Visit(WfFunctionDeclaration* node)override - { - auto scope = context.manager->nodeScopes[node].Obj(); - auto symbol = context.manager->GetDeclarationSymbol(scope, node); - auto meta = context.assembly->functions[context.globalFunctions[symbol.Obj()]]; - GenerateFunctionDeclarationInstructions(context, node, scope, meta, 0); - } - - void Visit(WfVariableDeclaration* node)override - { - } - - void Visit(WfEventDeclaration* node)override - { - } - - void Visit(WfPropertyDeclaration* node)override - { - } - - void Visit(WfConstructorDeclaration* node)override - { - } - - void Visit(WfDestructorDeclaration* node)override - { - } - - void Visit(WfClassDeclaration* node)override - { - FOREACH(Ptr, memberDecl, node->declarations) - { - GenerateClassMemberInstructionsVisitor visitor(context, node); - memberDecl->Accept(&visitor); - } - } - - void Visit(WfEnumDeclaration* node)override - { - } - - void Visit(WfStructDeclaration* node)override - { - } - - void Visit(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - }; - - void GenerateDeclarationInstructions(WfCodegenContext& context, Ptr declaration) - { - GenerateDeclarationInstructionsVisitor visitor(context); - declaration->Accept(&visitor); - } - -/*********************************************************************** -GenerateInstructions(Closure) -***********************************************************************/ - - void GenerateClosureInstructions_Function(WfCodegenContext& context, vint functionIndex, WfFunctionDeclaration* node, bool createInterface) - { - auto scope = context.manager->nodeScopes[node].Obj(); - auto meta = context.assembly->functions[functionIndex]; - GenerateFunctionDeclarationMetadata(context, node, meta); - Ptr recursiveLambdaSymbol; - if (!createInterface && node->name.value != L"") - { - recursiveLambdaSymbol = scope->symbols[node->name.value][0]; - } - GenerateFunctionDeclarationInstructions(context, node, scope, meta, recursiveLambdaSymbol); - } - - void GenerateClosureInstructions_Ordered(WfCodegenContext& context, vint functionIndex, WfOrderedLambdaExpression* node) - { - auto scope = context.manager->nodeScopes[node].Obj(); - List> argumentSymbols, capturedSymbols; - CopyFrom( - argumentSymbols, - Range(0, scope->symbols.Count()) - .Select([scope](vint index)->Ptr{return scope->symbols.GetByIndex(index)[0];}) - .OrderBy([](Ptr a, Ptr b) - { - vint aId = wtoi(a->name.Sub(1, a->name.Length() - 1)); - vint bId = wtoi(b->name.Sub(1, a->name.Length() - 1)); - return aId - bId; - }) - ); - - auto meta = context.assembly->functions[functionIndex]; - FOREACH(Ptr, symbol, argumentSymbols) - { - meta->argumentNames.Add(symbol->name); - } - { - auto capture = context.manager->lambdaCaptures.Get(node); - FOREACH(Ptr, symbol, capture->symbols) - { - meta->capturedVariableNames.Add(L"" + symbol->name); - capturedSymbols.Add(symbol); - } - - vint count = context.GetThisStackCount(scope); - for (vint i = 0; i < count; i++) - { - meta->capturedVariableNames.Add(L"" + itow(i)); - } - } - - auto result = context.manager->expressionResolvings[node]; - auto returnType = CopyTypeInfo(result.type->GetElementType()->GetGenericArgument(0)); - GenerateFunctionInstructions(context, scope, meta, returnType, 0, argumentSymbols, capturedSymbols, node->body, node); - } - - void GenerateClosureInstructions(WfCodegenContext& context, Ptr functionContext) - { - for (vint i = 0; i < functionContext->closuresToCodegen.Count(); i++) - { - vint functionIndex = functionContext->closuresToCodegen.Keys()[i]; - auto closure = functionContext->closuresToCodegen.Values()[i]; - - if (closure.functionExpression) - { - GenerateClosureInstructions_Function(context, functionIndex, closure.functionExpression->function.Obj(), false); - } - else if (closure.orderedLambdaExpression) - { - GenerateClosureInstructions_Ordered(context, functionIndex, closure.orderedLambdaExpression); - } - else if (closure.functionDeclaration) - { - GenerateClosureInstructions_Function(context, functionIndex, closure.functionDeclaration, true); - } - } - } - -#undef INSTRUCTION - } - } -} - -/*********************************************************************** -EMITTER\WFEMITTER_EXPRESSION.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace emitter - { - using namespace collections; - using namespace parsing; - using namespace reflection; - using namespace reflection::description; - using namespace analyzer; - using namespace runtime; - - typedef WfInstruction Ins; - -#define INSTRUCTION(X) context.AddInstruction(node, X) - -/*********************************************************************** -GenerateInstructions(Expression) -***********************************************************************/ - - class GenerateExpressionInstructionsVisitor - : public Object - , public WfExpression::IVisitor - { - public: - WfCodegenContext& context; - - GenerateExpressionInstructionsVisitor(WfCodegenContext& _context) - :context(_context) - { - } - - static void GenerateLoadSymbolInstructions(WfCodegenContext& context, WfLexicalSymbol* symbol, parsing::ParsingTreeCustomBase* node) - { - vint index = -1; - if ((index = context.globalFunctions.Keys().IndexOf(symbol)) != -1) - { - vint functionIndex = context.globalFunctions.Values()[index]; - INSTRUCTION(Ins::CreateClosureContext(0)); - INSTRUCTION(Ins::LoadFunction(functionIndex)); - INSTRUCTION(Ins::CreateClosure()); - } - else if ((index = context.globalVariables.Keys().IndexOf(symbol)) != -1) - { - vint variableIndex = context.globalVariables.Values()[index]; - INSTRUCTION(Ins::LoadGlobalVar(variableIndex)); - } - else if ((index = context.functionContext->capturedVariables.Keys().IndexOf(symbol)) != -1) - { - vint variableIndex = context.functionContext->capturedVariables.Values()[index]; - INSTRUCTION(Ins::LoadCapturedVar(variableIndex)); - } - else if ((index = context.functionContext->localVariables.Keys().IndexOf(symbol)) != -1) - { - vint variableIndex = context.functionContext->localVariables.Values()[index]; - INSTRUCTION(Ins::LoadLocalVar(variableIndex)); - } - else if ((index = context.functionContext->arguments.Keys().IndexOf(symbol)) != -1) - { - vint variableIndex = context.functionContext->arguments.Values()[index]; - INSTRUCTION(Ins::LoadLocalVar(variableIndex)); - } - else if ((index = context.closureFunctions.Keys().IndexOf(symbol)) != -1) - { - vint functionIndex = context.closureFunctions.Values()[index]; - INSTRUCTION(Ins::LoadClosureContext()); - INSTRUCTION(Ins::LoadFunction(functionIndex)); - INSTRUCTION(Ins::CreateClosure()); - } - else - { - CHECK_FAIL(L"GenerateExpressionInstructionsVisitor::GenerateLoadSymbolInstructions(WfCodegenContext&, WfLexicalSymbol*, ParsingTreeCustomBase*)#Internal error, cannot find any record of this symbol."); - } - } - - static vint PushCapturedThisValues(WfCodegenContext& context, WfLexicalScope* lambdaScopeParent, ParsingTreeCustomBase* node) - { - auto scope = lambdaScopeParent; - while (scope) - { - if (scope->functionConfig) - { - vint parentThisCount = context.GetThisStackCount(scope); - if (scope->functionConfig->lambda) - { - auto capture = context.manager->lambdaCaptures[scope->ownerNode.Obj()]; - vint captureCount = capture->symbols.Count(); - for (vint i = 0; i < parentThisCount; i++) - { - INSTRUCTION(Ins::LoadCapturedVar(captureCount + i)); - } - } - else if (parentThisCount > 0) - { - CHECK_ERROR(parentThisCount == 1, L"GenerateExpressionInstructionsVisitor::PushCapturedThisValues(WfCodegenContext&, WfLexicalScope*, ParsingTreeCustomBase*)#Internal error, wrong parentThisCount value."); - INSTRUCTION(Ins::LoadCapturedVar(0)); - } - return parentThisCount; - } - scope = scope->parentScope.Obj(); - } - return 0; - } - - static vint AddClosure(WfCodegenContext& context, WfCodegenLambdaContext lc, const Func& getName) - { - auto meta = MakePtr(); - vint functionIndex = context.assembly->functions.Add(meta); - meta->name = getName(functionIndex); - context.assembly->functionByName.Add(meta->name, functionIndex); - context.functionContext->closuresToCodegen.Add(functionIndex, lc); - return functionIndex; - } - - void VisitReferenceExpression(WfExpression* node, const WString& name) - { - auto result = context.manager->expressionResolvings[node]; - if (result.symbol) - { - GenerateLoadSymbolInstructions(context, result.symbol.Obj(), node); - } - else if (result.methodInfo) - { - if (result.methodInfo->IsStatic()) - { - INSTRUCTION(Ins::LoadValue(Value())); - } - else - { - VisitThisExpression(node, result.methodInfo->GetOwnerTypeDescriptor()); - } - INSTRUCTION(Ins::LoadMethodClosure(result.methodInfo)); - } - else if (result.propertyInfo) - { - if (auto getter = result.propertyInfo->GetGetter()) - { - VisitThisExpression(node, getter->GetOwnerTypeDescriptor()); - INSTRUCTION(Ins::InvokeMethod(getter, 0)); - } - else - { - VisitThisExpression(node, result.propertyInfo->GetOwnerTypeDescriptor()); - INSTRUCTION(Ins::GetProperty(result.propertyInfo)); - } - } - else - { - if ((result.type->GetTypeDescriptor()->GetTypeDescriptorFlags() & TypeDescriptorFlags::EnumType) != TypeDescriptorFlags::Undefined) - { - auto enumType = result.type->GetTypeDescriptor()->GetEnumType(); - vint index = enumType->IndexOfItem(name); - if (index != -1) - { - auto intValue = enumType->GetItemValue(index); - INSTRUCTION(Ins::LoadValue(enumType->ToEnum(intValue))); - return; - } - } - CHECK_FAIL(L"GenerateExpressionInstructionsVisitor::VisitReferenceExpression(WfExpression*, const WString&)#Internal error, cannot find any record of this expression."); - } - } - - void VisitThisExpression(WfExpression* node, ITypeDescriptor* td) - { - auto scope = context.manager->nodeScopes[node].Obj(); - vint count = context.GetThisStackCount(scope); - vint offset = 0; - - Ptr capture; - Ptr lastConfig; - while (scope) - { - if (scope->typeOfThisExpr) - { - if (scope->typeOfThisExpr->CanConvertTo(td)) - { - if (capture) - { - INSTRUCTION(Ins::LoadCapturedVar(capture->symbols.Count() + count - offset - 1)); - } - else - { - INSTRUCTION(Ins::LoadCapturedVar(0)); - } - return; - } - else - { - offset++; - } - - if (lastConfig) - { - if (!lastConfig->parentThisAccessable) - { - break; - } - } - } - - if (scope->functionConfig) - { - lastConfig = scope->functionConfig; - if (!capture) - { - vint index = context.manager->lambdaCaptures.Keys().IndexOf(scope->ownerNode.Obj()); - if (index != -1) - { - capture = context.manager->lambdaCaptures.Values()[index]; - } - } - } - - scope = scope->parentScope.Obj(); - } - CHECK_FAIL(L"GenerateExpressionInstructionsVisitor::VisitThisExpression(WfExpression*, ITypeDescriptor*)#Internal error, cannot find any record of the this value."); - } - - void Visit(WfThisExpression* node)override - { - auto scope = context.manager->nodeScopes[node].Obj(); - while (scope) - { - if (scope->functionConfig) - { - if (scope->functionConfig->thisAccessable) - { - if (scope->functionConfig->lambda) - { - auto capture = context.manager->lambdaCaptures[scope->ownerNode.Obj()]; - auto count = context.GetThisStackCount(scope); - INSTRUCTION(Ins::LoadCapturedVar(capture->symbols.Count() + count - 1)); - } - else - { - INSTRUCTION(Ins::LoadCapturedVar(0)); - } - return; - } - CHECK_FAIL(L"GenerateExpressionInstructionsVisitor::Visit(WfThisExpression*)#Internal error, this expression is illegal here."); - } - scope = scope->parentScope.Obj(); - } - CHECK_FAIL(L"GenerateExpressionInstructionsVisitor::Visit(WfThisExpression*)#Internal error, this expression is illegal here."); - } - - void Visit(WfTopQualifiedExpression* node)override - { - VisitReferenceExpression(node, node->name.value); - } - - void Visit(WfReferenceExpression* node)override - { - VisitReferenceExpression(node, node->name.value); - } - - void Visit(WfOrderedNameExpression* node)override - { - VisitReferenceExpression(node, node->name.value); - } - - void Visit(WfOrderedLambdaExpression* node)override - { - auto scope = context.manager->nodeScopes[node].Obj(); - - WfCodegenLambdaContext lc; - lc.orderedLambdaExpression = node; - auto functionIndex = AddClosure(context, lc, [=](vint index) - { - return L" in " + context.functionContext->function->name; - }); - - auto capture = context.manager->lambdaCaptures.Get(node); - FOREACH(Ptr, symbol, capture->symbols) - { - GenerateLoadSymbolInstructions(context, symbol.Obj(), node); - } - vint thisCount = PushCapturedThisValues(context, scope->parentScope.Obj(), node); - INSTRUCTION(Ins::CreateClosureContext(capture->symbols.Count() + thisCount)); - INSTRUCTION(Ins::LoadFunction(functionIndex)); - INSTRUCTION(Ins::CreateClosure()); - } - - void Visit(WfMemberExpression* node)override - { - auto result = context.manager->expressionResolvings[node]; - if (result.propertyInfo) - { - GenerateExpressionInstructions(context, node->parent); - if (result.propertyInfo->GetGetter()) - { - INSTRUCTION(Ins::InvokeMethod(result.propertyInfo->GetGetter(), 0)); - } - else - { - INSTRUCTION(Ins::GetProperty(result.propertyInfo)); - } - } - else - { - GenerateExpressionInstructions(context, node->parent); - INSTRUCTION(Ins::LoadMethodClosure(result.methodInfo)); - } - } - - void Visit(WfChildExpression* node)override - { - VisitReferenceExpression(node, node->name.value); - } - - void Visit(WfLiteralExpression* node)override - { - switch (node->value) - { - case WfLiteralValue::Null: - INSTRUCTION(Ins::LoadValue(Value())); - break; - case WfLiteralValue::True: - INSTRUCTION(Ins::LoadValue(BoxValue(true))); - break; - case WfLiteralValue::False: - INSTRUCTION(Ins::LoadValue(BoxValue(false))); - break; - } - } - - void Visit(WfFloatingExpression* node)override - { - auto result = context.manager->expressionResolvings[node]; - auto td = result.type->GetTypeDescriptor(); - Value output; - td->GetSerializableType()->Deserialize(node->value.value, output); - INSTRUCTION(Ins::LoadValue(output)); - } - - void Visit(WfIntegerExpression* node)override - { - auto result = context.manager->expressionResolvings[node]; - auto td = result.type->GetTypeDescriptor(); - Value output; - td->GetSerializableType()->Deserialize(node->value.value, output); - INSTRUCTION(Ins::LoadValue(output)); - } - - void Visit(WfStringExpression* node)override - { - INSTRUCTION(Ins::LoadValue(BoxValue(node->value.value))); - } - - void Visit(WfUnaryExpression* node)override - { - auto type = GenerateExpressionInstructions(context, node->operand); - switch (node->op) - { - case WfUnaryOperator::Not: - INSTRUCTION(Ins::OpNot(GetInstructionTypeArgument(type))); - break; - case WfUnaryOperator::Positive: - INSTRUCTION(Ins::OpPositive(GetInstructionTypeArgument(type))); - break; - case WfUnaryOperator::Negative: - INSTRUCTION(Ins::OpNegative(GetInstructionTypeArgument(type))); - break; - } - } - - void Visit(WfBinaryExpression* node)override - { - if (node->op == WfBinaryOperator::Assign) - { - if (auto binary = node->first.Cast()) - { - auto result = context.manager->expressionResolvings[binary->first.Obj()]; - auto containerType = result.expectedType ? result.expectedType : result.type; - auto methodInfo = containerType->GetTypeDescriptor()->GetMethodGroupByName(L"Set", true)->GetMethod(0); - GenerateExpressionInstructions(context, binary->second); - INSTRUCTION(Ins::Duplicate(0)); - GenerateExpressionInstructions(context, node->second); - GenerateExpressionInstructions(context, binary->first); - INSTRUCTION(Ins::InvokeMethod(methodInfo, 2)); - INSTRUCTION(Ins::Pop()); - } - else if (auto member = node->first.Cast()) - { - auto result = context.manager->expressionResolvings[member.Obj()]; - if (auto methodInfo = result.propertyInfo->GetSetter()) - { - GenerateExpressionInstructions(context, node->second); - INSTRUCTION(Ins::Duplicate(0)); - GenerateExpressionInstructions(context, member->parent); - INSTRUCTION(Ins::InvokeMethod(methodInfo, 1)); - INSTRUCTION(Ins::Pop()); - } - else - { - GenerateExpressionInstructions(context, node->second); - INSTRUCTION(Ins::Duplicate(0)); - GenerateExpressionInstructions(context, member->parent); - INSTRUCTION(Ins::SetProperty(result.propertyInfo)); - } - } - else - { - GenerateExpressionInstructions(context, node->second); - INSTRUCTION(Ins::Duplicate(0)); - auto result = context.manager->expressionResolvings[node->first.Obj()]; - vint index = -1; - if ((index = context.globalVariables.Keys().IndexOf(result.symbol.Obj())) != -1) - { - vint variableIndex = context.globalVariables.Values()[index]; - INSTRUCTION(Ins::StoreGlobalVar(variableIndex)); - } - else if ((index = context.functionContext->localVariables.Keys().IndexOf(result.symbol.Obj())) != -1) - { - vint variableIndex = context.functionContext->localVariables.Values()[index]; - INSTRUCTION(Ins::StoreLocalVar(variableIndex)); - } - else if ((index = context.functionContext->capturedVariables.Keys().IndexOf(result.symbol.Obj())) != -1) - { - vint variableIndex = context.functionContext->capturedVariables.Values()[index]; - INSTRUCTION(Ins::StoreCapturedVar(variableIndex)); - } - else if (result.propertyInfo) - { - if (auto setter = result.propertyInfo->GetSetter()) - { - VisitThisExpression(node, setter->GetOwnerTypeDescriptor()); - INSTRUCTION(Ins::InvokeMethod(setter, 1)); - INSTRUCTION(Ins::Pop()); - } - else - { - VisitThisExpression(node, result.propertyInfo->GetOwnerTypeDescriptor()); - INSTRUCTION(Ins::SetProperty(result.propertyInfo)); - } - } - else - { - CHECK_FAIL(L"GenerateExpressionInstructionsVisitor::Visit(WfBinaryExpression*)#Internal error, cannot find any record of this assignable symbol."); - } - } - } - else if (node->op == WfBinaryOperator::Index) - { - auto result = context.manager->expressionResolvings[node->first.Obj()]; - auto containerType = result.expectedType ? result.expectedType : result.type; - auto methodInfo = containerType->GetTypeDescriptor()->GetMethodGroupByName(L"Get", true)->GetMethod(0); - GenerateExpressionInstructions(context, node->second); - GenerateExpressionInstructions(context, node->first); - INSTRUCTION(Ins::InvokeMethod(methodInfo, 1)); - } - else if (node->op == WfBinaryOperator::Union) - { - auto type = context.manager->expressionResolvings[node].type; - if (type->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - GenerateExpressionInstructions(context, node->first, type); - GenerateExpressionInstructions(context, node->second, type); - INSTRUCTION(Ins::OpConcat()); - } - else - { - GenerateExpressionInstructions(context, node->first, type); - INSTRUCTION(Ins::ConvertToType(Value::BoxedValue, description::GetTypeDescriptor())); - GenerateExpressionInstructions(context, node->second, type); - INSTRUCTION(Ins::ConvertToType(Value::BoxedValue, description::GetTypeDescriptor())); - INSTRUCTION(Ins::OpAnd(WfInsType::U8)); - INSTRUCTION(Ins::ConvertToType(Value::BoxedValue, type->GetTypeDescriptor())); - } - } - else if (node->op == WfBinaryOperator::Intersect) - { - auto type = context.manager->expressionResolvings[node].type; - GenerateExpressionInstructions(context, node->first, type); - INSTRUCTION(Ins::ConvertToType(Value::BoxedValue, description::GetTypeDescriptor())); - GenerateExpressionInstructions(context, node->second, type); - INSTRUCTION(Ins::ConvertToType(Value::BoxedValue, description::GetTypeDescriptor())); - INSTRUCTION(Ins::OpOr(WfInsType::U8)); - INSTRUCTION(Ins::ConvertToType(Value::BoxedValue, type->GetTypeDescriptor())); - } - else if (node->op == WfBinaryOperator::FailedThen) - { - auto result = context.manager->expressionResolvings[node]; - vint trapInstruction = INSTRUCTION(Ins::InstallTry(-1)); - GenerateExpressionInstructions(context, node->first, result.type); - INSTRUCTION(Ins::UninstallTry(1)); - vint finishInstruction = INSTRUCTION(Ins::Jump(-1)); - - context.assembly->instructions[trapInstruction].indexParameter = context.assembly->instructions.Count(); - GenerateExpressionInstructions(context, node->second, result.type); - - context.assembly->instructions[finishInstruction].indexParameter = context.assembly->instructions.Count(); - } - else - { - Ptr mergedType; - switch (node->op) - { - case WfBinaryOperator::Exp: - case WfBinaryOperator::Add: - case WfBinaryOperator::Sub: - case WfBinaryOperator::Mul: - case WfBinaryOperator::Div: - case WfBinaryOperator::Mod: - case WfBinaryOperator::Shl: - case WfBinaryOperator::Shr: - { - auto result = context.manager->expressionResolvings[node]; - mergedType = result.type; - } - break; - default: - { - auto firstResult = context.manager->expressionResolvings[node->first.Obj()]; - auto secondResult = context.manager->expressionResolvings[node->second.Obj()]; - auto firstType = firstResult.expectedType ? firstResult.expectedType : firstResult.type; - auto secondType = secondResult.expectedType ? secondResult.expectedType : secondResult.type; - if (node->op == WfBinaryOperator::EQ || node->op == WfBinaryOperator::NE) - { - if (firstType->GetDecorator() == ITypeInfo::RawPtr || firstType->GetDecorator() == ITypeInfo::SharedPtr) - { - GenerateExpressionInstructions(context, node->first); - GenerateExpressionInstructions(context, node->second); - INSTRUCTION(Ins::CompareReference()); - if (node->op == WfBinaryOperator::NE) - { - INSTRUCTION(Ins::OpNot(WfInsType::Bool)); - } - return; - } - } - - mergedType = GetMergedType(firstType, secondType); - if (node->op == WfBinaryOperator::EQ || node->op == WfBinaryOperator::NE) - { - GenerateExpressionInstructions(context, node->first); - GenerateExpressionInstructions(context, node->second); - INSTRUCTION(Ins::CompareValue()); - if (node->op == WfBinaryOperator::NE) - { - INSTRUCTION(Ins::OpNot(WfInsType::Bool)); - } - return; - } - } - } - - GenerateExpressionInstructions(context, node->first, mergedType); - GenerateExpressionInstructions(context, node->second, mergedType); - - switch (node->op) - { - case WfBinaryOperator::Exp: - INSTRUCTION(Ins::OpExp(GetInstructionTypeArgument(mergedType))); - break; - case WfBinaryOperator::Add: - INSTRUCTION(Ins::OpAdd(GetInstructionTypeArgument(mergedType))); - break; - case WfBinaryOperator::Sub: - INSTRUCTION(Ins::OpSub(GetInstructionTypeArgument(mergedType))); - break; - case WfBinaryOperator::Mul: - INSTRUCTION(Ins::OpMul(GetInstructionTypeArgument(mergedType))); - break; - case WfBinaryOperator::Div: - INSTRUCTION(Ins::OpDiv(GetInstructionTypeArgument(mergedType))); - break; - case WfBinaryOperator::Mod: - INSTRUCTION(Ins::OpMod(GetInstructionTypeArgument(mergedType))); - break; - case WfBinaryOperator::Shl: - INSTRUCTION(Ins::OpShl(GetInstructionTypeArgument(mergedType))); - break; - case WfBinaryOperator::Shr: - INSTRUCTION(Ins::OpShr(GetInstructionTypeArgument(mergedType))); - break; - case WfBinaryOperator::LT: - INSTRUCTION(Ins::CompareLiteral(GetInstructionTypeArgument(mergedType))); - INSTRUCTION(Ins::OpLT()); - break; - case WfBinaryOperator::GT: - INSTRUCTION(Ins::CompareLiteral(GetInstructionTypeArgument(mergedType))); - INSTRUCTION(Ins::OpGT()); - break; - case WfBinaryOperator::LE: - INSTRUCTION(Ins::CompareLiteral(GetInstructionTypeArgument(mergedType))); - INSTRUCTION(Ins::OpLE()); - break; - case WfBinaryOperator::GE: - INSTRUCTION(Ins::CompareLiteral(GetInstructionTypeArgument(mergedType))); - INSTRUCTION(Ins::OpGE()); - break; - case WfBinaryOperator::EQ: - INSTRUCTION(Ins::CompareLiteral(GetInstructionTypeArgument(mergedType))); - INSTRUCTION(Ins::OpEQ()); - break; - case WfBinaryOperator::NE: - INSTRUCTION(Ins::CompareLiteral(GetInstructionTypeArgument(mergedType))); - INSTRUCTION(Ins::OpNE()); - break; - case WfBinaryOperator::Xor: - INSTRUCTION(Ins::OpXor(GetInstructionTypeArgument(mergedType))); - break; - case WfBinaryOperator::And: - INSTRUCTION(Ins::OpAnd(GetInstructionTypeArgument(mergedType))); - break; - case WfBinaryOperator::Or: - INSTRUCTION(Ins::OpOr(GetInstructionTypeArgument(mergedType))); - break; - default:; - } - } - } - - void Visit(WfLetExpression* node)override - { - auto scope = context.manager->nodeScopes[node].Obj(); - Array variableIndices(node->variables.Count()); - auto function = context.functionContext->function; - FOREACH_INDEXER(Ptr, var, index, node->variables) - { - auto symbol = scope->symbols[var->name.value][0]; - vint variableIndex = function->argumentNames.Count() + function->localVariableNames.Add(L"" + var->name.value); - context.functionContext->localVariables.Add(symbol.Obj(), variableIndex); - variableIndices[index] = variableIndex; - - GenerateExpressionInstructions(context, var->value); - INSTRUCTION(Ins::StoreLocalVar(variableIndex)); - } - GenerateExpressionInstructions(context, node->expression); - FOREACH_INDEXER(Ptr, var, index, node->variables) - { - INSTRUCTION(Ins::LoadValue(Value())); - INSTRUCTION(Ins::StoreLocalVar(variableIndices[index])); - } - } - - void Visit(WfIfExpression* node)override - { - auto result = context.manager->expressionResolvings[node]; - GenerateExpressionInstructions(context, node->condition); - vint fillTrueIndex = INSTRUCTION(Ins::JumpIf(-1)); - GenerateExpressionInstructions(context, node->falseBranch, result.type); - vint fillEndIndex = INSTRUCTION(Ins::Jump(-1)); - context.assembly->instructions[fillTrueIndex].indexParameter = context.assembly->instructions.Count(); - GenerateExpressionInstructions(context, node->trueBranch, result.type); - context.assembly->instructions[fillEndIndex].indexParameter = context.assembly->instructions.Count(); - } - - void Visit(WfRangeExpression* node)override - { - auto result = context.manager->expressionResolvings[node]; - auto elementType = result.type->GetElementType()->GetGenericArgument(0); - auto type = GetInstructionTypeArgument(elementType); - - GenerateExpressionInstructions(context, node->begin, elementType); - if (node->beginBoundary == WfRangeBoundary::Exclusive) - { - INSTRUCTION(Ins::LoadValue(BoxValue(1))); - INSTRUCTION(Ins::OpAdd(type)); - } - - GenerateExpressionInstructions(context, node->end, elementType); - if (node->endBoundary == WfRangeBoundary::Exclusive) - { - INSTRUCTION(Ins::LoadValue(BoxValue(1))); - INSTRUCTION(Ins::OpSub(type)); - } - - INSTRUCTION(Ins::CreateRange(type)); - } - - void Visit(WfSetTestingExpression* node)override - { - if (auto range = node->collection.Cast()) - { - auto resultElement = context.manager->expressionResolvings[node->element.Obj()]; - auto resultBegin = context.manager->expressionResolvings[range->begin.Obj()]; - auto resultEnd = context.manager->expressionResolvings[range->end.Obj()]; - auto typeElement = resultElement.expectedType ? resultElement.expectedType : resultElement.type; - auto typeBegin = resultBegin.expectedType ? resultBegin.expectedType : resultBegin.type; - auto typeEnd = resultEnd.expectedType ? resultEnd.expectedType : resultEnd.type; - auto typeLeft = GetMergedType(typeElement, typeBegin); - auto typeRight = GetMergedType(typeElement, typeEnd); - - auto function = context.functionContext->function; - vint index = function->argumentNames.Count() + function->localVariableNames.Add(L""); - GenerateExpressionInstructions(context, node->element); - INSTRUCTION(Ins::StoreLocalVar(index)); - - INSTRUCTION(Ins::LoadLocalVar(index)); - if (!IsSameType(typeElement.Obj(), typeLeft.Obj())) - { - GenerateTypeCastInstructions(context, typeLeft, true, node); - } - GenerateExpressionInstructions(context, range->begin, typeLeft); - INSTRUCTION(Ins::CompareLiteral(GetInstructionTypeArgument(typeLeft))); - if (range->beginBoundary == WfRangeBoundary::Exclusive) - { - INSTRUCTION(Ins::OpGT()); - } - else - { - INSTRUCTION(Ins::OpGE()); - } - - INSTRUCTION(Ins::LoadLocalVar(index)); - if (!IsSameType(typeElement.Obj(), typeRight.Obj())) - { - GenerateTypeCastInstructions(context, typeRight, true, node); - } - GenerateExpressionInstructions(context, range->end, typeRight); - INSTRUCTION(Ins::CompareLiteral(GetInstructionTypeArgument(typeRight))); - if (range->endBoundary == WfRangeBoundary::Exclusive) - { - INSTRUCTION(Ins::OpLT()); - } - else - { - INSTRUCTION(Ins::OpLE()); - } - - INSTRUCTION(Ins::OpAnd(WfInsType::Bool)); - if (node->test == WfSetTesting::NotIn) - { - INSTRUCTION(Ins::OpNot(WfInsType::Bool)); - } - INSTRUCTION(Ins::LoadValue(Value())); - INSTRUCTION(Ins::StoreLocalVar(index)); - } - else - { - auto result = context.manager->expressionResolvings[node->collection.Obj()]; - auto type = result.expectedType ? result.expectedType : result.type; - - GenerateExpressionInstructions(context, node->element); - GenerateExpressionInstructions(context, node->collection); - - auto tdList = description::GetTypeDescriptor(); - if (result.type->GetTypeDescriptor()->CanConvertTo(tdList)) - { - auto method = tdList->GetMethodGroupByName(L"Contains", true)->GetMethod(0); - INSTRUCTION(Ins::InvokeMethod(method, 1)); - } - else - { - INSTRUCTION(Ins::TestElementInSet()); - } - - if (node->test == WfSetTesting::NotIn) - { - INSTRUCTION(Ins::OpNot(WfInsType::Bool)); - } - } - } - - void Visit(WfConstructorExpression* node)override - { - auto result = context.manager->expressionResolvings[node]; - - if (result.type->GetTypeDescriptor()->GetTypeDescriptorFlags() == TypeDescriptorFlags::Struct) - { - auto td = result.type->GetTypeDescriptor(); - INSTRUCTION(Ins::CreateStruct(Value::BoxedValue, td)); - - FOREACH(Ptr, argument, node->arguments) - { - auto prop = td->GetPropertyByName(argument->key.Cast()->name.value, true); - GenerateExpressionInstructions(context, argument->value, CopyTypeInfo(prop->GetReturn())); - INSTRUCTION(Ins::UpdateProperty(prop)); - } - } - else if (result.type->GetTypeDescriptor() == description::GetTypeDescriptor() - || result.type->GetTypeDescriptor() == description::GetTypeDescriptor() - || result.type->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - Ptr keyType = CopyTypeInfo(result.type->GetElementType()->GetGenericArgument(0)); - FOREACH(Ptr, argument, From(node->arguments).Reverse()) - { - GenerateExpressionInstructions(context, argument->key, keyType); - } - INSTRUCTION(Ins::CreateArray(node->arguments.Count())); - } - else if (result.type->GetTypeDescriptor() == description::GetTypeDescriptor()) - { - Ptr keyType = CopyTypeInfo(result.type->GetElementType()->GetGenericArgument(0)); - FOREACH(Ptr, argument, From(node->arguments).Reverse()) - { - GenerateExpressionInstructions(context, argument->key, keyType); - } - INSTRUCTION(Ins::CreateObservableList(node->arguments.Count())); - } - else - { - Ptr keyType = CopyTypeInfo(result.type->GetElementType()->GetGenericArgument(0)); - Ptr valueType = CopyTypeInfo(result.type->GetElementType()->GetGenericArgument(1)); - FOREACH(Ptr, argument, From(node->arguments).Reverse()) - { - GenerateExpressionInstructions(context, argument->key, keyType); - GenerateExpressionInstructions(context, argument->value, valueType); - } - INSTRUCTION(Ins::CreateMap(node->arguments.Count() * 2)); - } - } - - void Visit(WfInferExpression* node)override - { - GenerateExpressionInstructions(context, node->expression); - } - - void Visit(WfTypeCastingExpression* node)override - { - if (node->strategy == WfTypeCastingStrategy::Strong) - { - auto result = context.manager->expressionResolvings[node]; - GenerateExpressionInstructions(context, node->expression, result.type); - } - else - { - auto scope = context.manager->nodeScopes[node].Obj(); - auto type = CreateTypeInfoFromType(scope, node->type); - GenerateExpressionInstructions(context, node->expression); - GenerateTypeCastInstructions(context, type, false, node); - } - } - - void Visit(WfTypeTestingExpression* node)override - { - switch (node->test) - { - case WfTypeTesting::IsNull: - GenerateExpressionInstructions(context, node->expression); - INSTRUCTION(Ins::LoadValue(Value())); - INSTRUCTION(Ins::CompareReference()); - break; - case WfTypeTesting::IsNotNull: - GenerateExpressionInstructions(context, node->expression); - INSTRUCTION(Ins::LoadValue(Value())); - INSTRUCTION(Ins::CompareReference()); - INSTRUCTION(Ins::OpNot(WfInsType::Bool)); - break; - case WfTypeTesting::IsType: - { - auto scope = context.manager->nodeScopes[node].Obj(); - auto type = CreateTypeInfoFromType(scope, node->type); - GenerateExpressionInstructions(context, node->expression); - GenerateTypeTestingInstructions(context, type, node); - } - break; - case WfTypeTesting::IsNotType: - { - auto scope = context.manager->nodeScopes[node].Obj(); - auto type = CreateTypeInfoFromType(scope, node->type); - GenerateExpressionInstructions(context, node->expression); - GenerateTypeTestingInstructions(context, type, node); - INSTRUCTION(Ins::OpNot(WfInsType::Bool)); - } - break; - } - } - - void Visit(WfTypeOfTypeExpression* node)override - { - auto scope = context.manager->nodeScopes[node].Obj(); - auto type = CreateTypeInfoFromType(scope, node->type); - auto value = Value::From(type->GetTypeDescriptor()); - INSTRUCTION(Ins::LoadValue(value)); - } - - void Visit(WfTypeOfExpressionExpression* node)override - { - GenerateExpressionInstructions(context, node->expression); - INSTRUCTION(Ins::GetType()); - } - - void Visit(WfAttachEventExpression* node)override - { - auto result = context.manager->expressionResolvings[node->event.Obj()]; - if (auto member = node->event.Cast()) - { - GenerateExpressionInstructions(context, member->parent); - } - else - { - VisitThisExpression(node, result.eventInfo->GetOwnerTypeDescriptor()); - } - GenerateExpressionInstructions(context, node->function); - INSTRUCTION(Ins::AttachEvent(result.eventInfo)); - } - - void Visit(WfDetachEventExpression* node)override - { - auto result = context.manager->expressionResolvings[node->event.Obj()]; - if (auto member = node->event.Cast()) - { - GenerateExpressionInstructions(context, member->parent); - } - else - { - VisitThisExpression(node, result.eventInfo->GetOwnerTypeDescriptor()); - } - GenerateExpressionInstructions(context, node->handler); - INSTRUCTION(Ins::DetachEvent(result.eventInfo)); - } - - void Visit(WfObserveExpression* node)override - { - } - - void Visit(WfCallExpression* node)override - { - FOREACH(Ptr, argument, node->arguments) - { - GenerateExpressionInstructions(context, argument); - } - - auto result = context.manager->expressionResolvings[node->function.Obj()]; - if (result.methodInfo) - { - if (result.methodInfo->IsStatic()) - { - INSTRUCTION(Ins::LoadValue(Value())); - } - else if (auto member = node->function.Cast()) - { - GenerateExpressionInstructions(context, member->parent); - } - else - { - VisitThisExpression(node, result.methodInfo->GetOwnerTypeDescriptor()); - } - - INSTRUCTION(Ins::InvokeMethod(result.methodInfo, node->arguments.Count())); - return; - } - else if (result.eventInfo) - { - if(auto member = node->function.Cast()) - { - GenerateExpressionInstructions(context, member->parent); - } - else - { - VisitThisExpression(node, result.eventInfo->GetOwnerTypeDescriptor()); - } - INSTRUCTION(Ins::InvokeEvent(result.eventInfo, node->arguments.Count())); - return; - } - else if (result.symbol) - { - if (result.symbol->creatorNode.Cast()) - { - if (result.symbol->ownerScope->ownerNode.Cast()) - { - vint functionIndex = context.closureFunctions[result.symbol.Obj()]; - INSTRUCTION(Ins::InvokeWithContext(functionIndex, node->arguments.Count())); - return; - } - else - { - vint index = context.globalFunctions.Keys().IndexOf(result.symbol.Obj()); - if (index != -1) - { - vint functionIndex = context.globalFunctions.Values()[index]; - INSTRUCTION(Ins::Invoke(functionIndex, node->arguments.Count())); - return; - } - } - } - } - - GenerateExpressionInstructions(context, node->function); - INSTRUCTION(Ins::InvokeProxy(node->arguments.Count())); - } - - static void VisitFunction(WfCodegenContext& context, WfFunctionDeclaration* node, WfCodegenLambdaContext lc, const Func& getName) - { - auto scope = context.manager->nodeScopes[node].Obj(); - bool inNewInterfaceExpr = scope->parentScope && scope->parentScope->ownerNode.Cast(); - auto functionIndex = AddClosure(context, lc, getName); - - if (inNewInterfaceExpr) - { - INSTRUCTION(Ins::LoadFunction(functionIndex)); - } - else - { - auto capture = context.manager->lambdaCaptures.Get(node); - FOREACH(Ptr, symbol, capture->symbols) - { - GenerateLoadSymbolInstructions(context, symbol.Obj(), node); - } - vint thisCount = PushCapturedThisValues(context, scope->parentScope.Obj(), node); - INSTRUCTION(Ins::CreateClosureContext(capture->symbols.Count() + thisCount)); - INSTRUCTION(Ins::LoadFunction(functionIndex)); - INSTRUCTION(Ins::CreateClosure()); - } - } - - void Visit(WfFunctionExpression* node)override - { - WfCodegenLambdaContext lc; - lc.functionExpression = node; - VisitFunction(context, node->function.Obj(), lc, [=](vint index) - { - return L"function->name.value + L"(" + itow(index) + L")> in " + context.functionContext->function->name; - }); - } - - class NewInterfaceExpressionVisitor : public empty_visitor::DeclarationVisitor - { - public: - WfCodegenContext& context; - vint variableCount = 0; - List> variableSymbols; - List> closureFunctions; - List> overrideFunctions; - WfFunctionDeclaration* firstFunction = nullptr; - - NewInterfaceExpressionVisitor(WfCodegenContext& _context) - :context(_context) - { - } - - void Dispatch(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - - void Visit(WfFunctionDeclaration* node)override - { - if (!firstFunction) - { - firstFunction = node; - } - - if (node->classMember->kind == WfClassMemberKind::Normal) - { - closureFunctions.Add(node); - } - else - { - overrideFunctions.Add(node); - } - } - - void Visit(WfVariableDeclaration* node)override - { - variableCount++; - } - - void Execute(WfNewInterfaceExpression* node) - { - FOREACH(Ptr, memberDecl, node->declarations) - { - memberDecl->Accept(this); - } - - if (firstFunction != nullptr && variableCount > 0) - { - auto capture = context.manager->lambdaCaptures.Get(firstFunction); - CopyFrom(variableSymbols, From(capture->symbols).Take(variableCount)); - } - } - }; - - void Visit(WfNewClassExpression* node)override - { - auto result = context.manager->expressionResolvings[node]; - FOREACH(Ptr, argument, node->arguments) - { - GenerateExpressionInstructions(context, argument); - } - INSTRUCTION(Ins::LoadValue(Value())); - INSTRUCTION(Ins::InvokeMethod(result.constructorInfo, node->arguments.Count())); - } - - void Visit(WfNewInterfaceExpression* node)override - { - auto result = context.manager->expressionResolvings[node]; - NewInterfaceExpressionVisitor declVisitor(context); - declVisitor.Execute(node); - - if (declVisitor.firstFunction != nullptr) - { - for (vint i = 0; i < declVisitor.variableCount; i++) - { - auto var = declVisitor.variableSymbols[i]->creatorNode.Cast(); - GenerateExpressionInstructions(context, var->expression); - } - - auto capture = context.manager->lambdaCaptures.Get(declVisitor.firstFunction); - for (vint i = declVisitor.variableCount; i < capture->symbols.Count(); i++) - { - GenerateLoadSymbolInstructions(context, capture->symbols[i].Obj(), node); - } - auto scope = context.manager->nodeScopes[node].Obj(); - vint thisCount = PushCapturedThisValues(context, scope, node); - INSTRUCTION(Ins::LoadValue(Value())); - INSTRUCTION(Ins::CreateClosureContext(capture->symbols.Count() + thisCount + 1)); - - FOREACH(Ptr, func, declVisitor.closureFunctions) - { - WfCodegenLambdaContext lc; - lc.functionDeclaration = func.Obj(); - auto functionIndex = AddClosure(context, lc, [=](vint index) - { - return L"name.value + L"<" + result.type->GetTypeDescriptor()->GetTypeName() + L">(" + itow(index) + L")> in " + context.functionContext->function->name; - }); - - auto scope = context.manager->nodeScopes[func.Obj()].Obj(); - auto symbol = context.manager->GetDeclarationSymbol(scope, func.Obj()); - context.closureFunctions.Add(symbol.Obj(), functionIndex); - } - - FOREACH(Ptr, func, declVisitor.overrideFunctions) - { - auto methodInfo = context.manager->interfaceMethodImpls[func.Obj()]; - INSTRUCTION(Ins::LoadMethodInfo(methodInfo)); - WfCodegenLambdaContext lc; - lc.functionDeclaration = func.Obj(); - VisitFunction(context, func.Obj(), lc, [=, &declVisitor](vint index) - { - return L"name.value + L"<" + result.type->GetTypeDescriptor()->GetTypeName() + L">(" + itow(index + declVisitor.closureFunctions.Count()) + L")> in " + context.functionContext->function->name; - }); - } - } - - INSTRUCTION(Ins::CreateInterface(result.constructorInfo, declVisitor.overrideFunctions.Count() * 2)); - } - - void Visit(WfVirtualExpression* node)override - { - GenerateExpressionInstructions(context, node->expandedExpression); - } - }; - -#undef INSTRUCTION - - Ptr GenerateExpressionInstructions(WfCodegenContext& context, Ptr expression, Ptr expectedType) - { - GenerateExpressionInstructionsVisitor visitor(context); - expression->Accept(&visitor); - - auto result = context.manager->expressionResolvings[expression.Obj()]; - auto type = result.type; - - if (result.expectedType && !IsSameType(type.Obj(), result.expectedType.Obj())) - { - type = result.expectedType; - GenerateTypeCastInstructions(context, type, true, expression.Obj()); - } - - if (expectedType && !IsSameType(type.Obj(), expectedType.Obj())) - { - type = expectedType; - GenerateTypeCastInstructions(context, type, true, expression.Obj()); - } - - return type; - } - } - } -} - -/*********************************************************************** -EMITTER\WFEMITTER_METADATA.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace emitter - { - using namespace collections; - using namespace reflection::description; - using namespace analyzer; - using namespace runtime; - using namespace typeimpl; - -/*********************************************************************** -GenerateGlobalDeclarationMetadata -***********************************************************************/ - - void GenerateFunctionDeclarationMetadata(WfCodegenContext& context, WfFunctionDeclaration* node, Ptr meta) - { - FOREACH(Ptr, argument, node->arguments) - { - meta->argumentNames.Add(argument->name.value); - } - { - vint index = context.manager->lambdaCaptures.Keys().IndexOf(node); - if (index != -1) - { - auto capture = context.manager->lambdaCaptures.Values()[index]; - FOREACH(Ptr, symbol, capture->symbols) - { - meta->capturedVariableNames.Add(L"" + symbol->name); - } - } - - auto scope = context.manager->nodeScopes[node]; - vint count = context.GetThisStackCount(scope.Obj()); - for (vint i = 0; i < count; i++) - { - meta->capturedVariableNames.Add(L"" + itow(i)); - } - } - } - - class GenerateGlobalClassMemberMetadataVisitor : public Object, public WfDeclaration::IVisitor - { - public: - WfCodegenContext& context; - WString namePrefix; - Ptr classDecl; - - GenerateGlobalClassMemberMetadataVisitor(WfCodegenContext& _context, const WString& _namePrefix, Ptr _classDecl) - :context(_context) - , namePrefix(_namePrefix) - , classDecl(_classDecl) - { - } - - void Visit(WfNamespaceDeclaration* node)override - { - } - - void Visit(WfFunctionDeclaration* node)override - { - if (node->classMember->kind == WfClassMemberKind::Static) - { - GenerateGlobalDeclarationMetadata(context, node, namePrefix); - auto scope = context.manager->nodeScopes[node].Obj(); - auto symbol = context.manager->GetDeclarationSymbol(scope, node); - auto index = context.globalFunctions[symbol.Obj()]; - auto info = context.manager->declarationMemberInfos[node].Cast(); - info->functionIndex = index; - } - else if (classDecl->kind == WfClassKind::Class) - { - GenerateGlobalDeclarationMetadata(context, node, namePrefix); - auto scope = context.manager->nodeScopes[node].Obj(); - auto symbol = context.manager->GetDeclarationSymbol(scope, node); - auto index = context.globalFunctions[symbol.Obj()]; - auto info = context.manager->declarationMemberInfos[node].Cast(); - info->functionIndex = index; - } - } - - void Visit(WfVariableDeclaration* node)override - { - } - - void Visit(WfEventDeclaration* node)override - { - } - - void Visit(WfPropertyDeclaration* node)override - { - } - - void Visit(WfConstructorDeclaration* node)override - { - auto meta = MakePtr(); - meta->name = namePrefix + L"#ctor"; - FOREACH(Ptr, argument, node->arguments) - { - meta->argumentNames.Add(argument->name.value); - } - meta->capturedVariableNames.Add(L"0"); - - vint index = context.assembly->functions.Add(meta); - context.assembly->functionByName.Add(meta->name, index); - context.constructors.Add(node, index); - - auto info = context.manager->declarationMemberInfos[node].Cast(); - info->functionIndex = index; - } - - void Visit(WfDestructorDeclaration* node)override - { - auto meta = MakePtr(); - meta->name = namePrefix + L"#dtor"; - meta->capturedVariableNames.Add(L"0"); - - vint index = context.assembly->functions.Add(meta); - context.assembly->functionByName.Add(meta->name, index); - context.destructors.Add(node, index); - - auto info = context.manager->declarationTypes[classDecl.Obj()].Cast(); - info->destructorFunctionIndex = index; - } - - void Visit(WfClassDeclaration* node)override - { - GenerateGlobalDeclarationMetadata(context, node, namePrefix); - } - - void Visit(WfEnumDeclaration* node)override - { - } - - void Visit(WfStructDeclaration* node)override - { - } - - void Visit(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - }; - - class GenerateGlobalDeclarationMetadataVisitor : public Object, public WfDeclaration::IVisitor - { - public: - WfCodegenContext& context; - WString namePrefix; - - GenerateGlobalDeclarationMetadataVisitor(WfCodegenContext& _context, const WString& _namePrefix) - :context(_context) - , namePrefix(_namePrefix) - { - } - - void Visit(WfNamespaceDeclaration* node)override - { - FOREACH(Ptr, decl, node->declarations) - { - GenerateGlobalDeclarationMetadata(context, decl, namePrefix + node->name.value + L"::"); - } - } - - void Visit(WfFunctionDeclaration* node)override - { - auto meta = MakePtr(); - meta->name = namePrefix + node->name.value; - GenerateFunctionDeclarationMetadata(context, node, meta); - - vint index = context.assembly->functions.Add(meta); - context.assembly->functionByName.Add(meta->name, index); - - auto scope = context.manager->nodeScopes[node].Obj(); - auto symbol = context.manager->GetDeclarationSymbol(scope, node); - context.globalFunctions.Add(symbol.Obj(), index); - } - - void Visit(WfVariableDeclaration* node)override - { - vint index = context.assembly->variableNames.Add(namePrefix + node->name.value); - - auto scope = context.manager->nodeScopes[node].Obj(); - auto symbol = scope->symbols[node->name.value][0]; - context.globalVariables.Add(symbol.Obj(), index); - } - - void Visit(WfEventDeclaration* node)override - { - } - - void Visit(WfPropertyDeclaration* node)override - { - } - - void Visit(WfConstructorDeclaration* node)override - { - } - - void Visit(WfDestructorDeclaration* node)override - { - } - - void Visit(WfClassDeclaration* node)override - { - FOREACH(Ptr, memberDecl, node->declarations) - { - GenerateGlobalClassMemberMetadataVisitor visitor(context, namePrefix + node->name.value + L"::", node); - memberDecl->Accept(&visitor); - } - } - - void Visit(WfEnumDeclaration* node)override - { - } - - void Visit(WfStructDeclaration* node)override - { - } - - void Visit(WfVirtualDeclaration* node)override - { - FOREACH(Ptr, decl, node->expandedDeclarations) - { - decl->Accept(this); - } - } - }; - - void GenerateGlobalDeclarationMetadata(WfCodegenContext& context, Ptr declaration, const WString& namePrefix) - { - GenerateGlobalDeclarationMetadataVisitor visitor(context, namePrefix); - declaration->Accept(&visitor); - } - } - } -} - -/*********************************************************************** -EMITTER\WFEMITTER_STATEMENT.CPP -***********************************************************************/ - -namespace vl -{ - namespace workflow - { - namespace emitter - { - using namespace collections; - using namespace reflection; - using namespace reflection::description; - using namespace analyzer; - using namespace runtime; - - typedef WfInstruction Ins; - -#define INSTRUCTION(X) context.AddInstruction(node, X) -#define EXIT_CODE(X) context.AddExitInstruction(node, X) - -/*********************************************************************** -GenerateInstructions(Statement) -***********************************************************************/ - - class GenerateStatementInstructionsVisitor : public Object, public WfStatement::IVisitor - { - public: - WfCodegenContext& context; - - GenerateStatementInstructionsVisitor(WfCodegenContext& _context) - :context(_context) - { - } - - void ApplyExitCode(Ptr scopeContext) - { - context.ApplyExitInstructions(scopeContext); - if (scopeContext->exitStatement) - { - GenerateStatementInstructions(context, scopeContext->exitStatement); - } - } - - void ApplyCurrentScopeExitCode() - { - auto scopeContext = context.functionContext->GetCurrentScopeContext(); - ApplyExitCode(scopeContext); - } - - void InlineScopeExitCode(WfCodegenScopeType untilScopeType, bool exclusive) - { - vint index = context.functionContext->scopeContextStack.Count() - 1; - while (index >= 0) - { - auto scopeContext = context.functionContext->scopeContextStack[index]; - if (exclusive && scopeContext->type == untilScopeType) break; - ApplyExitCode(scopeContext); - if (!exclusive && scopeContext->type == untilScopeType) break; - index--; - } - } - - void Visit(WfBreakStatement* node)override - { - InlineScopeExitCode(WfCodegenScopeType::Loop, false); - context.functionContext->GetCurrentScopeContext(WfCodegenScopeType::Loop)->breakInstructions.Add(INSTRUCTION(Ins::Jump(-1))); - } - - void Visit(WfContinueStatement* node)override - { - InlineScopeExitCode(WfCodegenScopeType::Loop, true); - context.functionContext->GetCurrentScopeContext(WfCodegenScopeType::Loop)->continueInstructions.Add(INSTRUCTION(Ins::Jump(-1))); - } - - void Visit(WfReturnStatement* node)override - { - InlineScopeExitCode(WfCodegenScopeType::Function, false); - if (node->expression) - { - GenerateExpressionInstructions(context, node->expression); - } - else - { - INSTRUCTION(Ins::LoadValue(Value())); - } - INSTRUCTION(Ins::Return()); - } - - void Visit(WfDeleteStatement* node)override - { - GenerateExpressionInstructions(context, node->expression); - INSTRUCTION(Ins::DeleteRawPtr()); - } - - void Visit(WfRaiseExceptionStatement* node)override - { - if (node->expression) - { - GenerateExpressionInstructions(context, node->expression); - } - else - { - auto scope = context.manager->nodeScopes[node]; - while (scope) - { - if (auto tryCatch = scope->ownerNode.Cast()) - { - if (tryCatch->name.value != L"") - { - auto symbol = scope->symbols[tryCatch->name.value][0].Obj(); - vint index = context.functionContext->localVariables[symbol]; - INSTRUCTION(Ins::LoadLocalVar(index)); - break; - } - } - scope = scope->parentScope; - } - } - INSTRUCTION(Ins::RaiseException()); - } - - void Visit(WfIfStatement* node)override - { - vint variableIndex = -1; - - GenerateExpressionInstructions(context, node->expression); - if (node->name.value != L"") - { - auto scope = context.manager->nodeScopes[node]; - auto symbol = scope->symbols[node->name.value][0]; - auto function = context.functionContext->function; - variableIndex = function->argumentNames.Count() + function->localVariableNames.Add(L"" + node->name.value); - context.functionContext->localVariables.Add(symbol.Obj(), variableIndex); - - GenerateTypeCastInstructions(context, symbol->typeInfo, false, node->expression.Obj()); - INSTRUCTION(Ins::StoreLocalVar(variableIndex)); - INSTRUCTION(Ins::LoadLocalVar(variableIndex)); - INSTRUCTION(Ins::LoadValue(Value())); - INSTRUCTION(Ins::CompareReference()); - } - else - { - INSTRUCTION(Ins::OpNot(WfInsType::Bool)); - } - vint fillElseIndex = INSTRUCTION(Ins::JumpIf(-1)); - - GenerateStatementInstructions(context, node->trueBranch); - if (variableIndex != -1) - { - INSTRUCTION(Ins::LoadValue(Value())); - INSTRUCTION(Ins::StoreLocalVar(variableIndex)); - } - vint fillEndIndex = INSTRUCTION(Ins::Jump(-1)); - context.assembly->instructions[fillElseIndex].indexParameter = context.assembly->instructions.Count(); - - if (node->falseBranch) - { - GenerateStatementInstructions(context, node->falseBranch); - } - context.assembly->instructions[fillEndIndex].indexParameter = context.assembly->instructions.Count(); - } - - void Visit(WfWhileStatement* node)override - { - vint continueLabelIndex = -1; - vint breakLabelIndex = -1; - vint loopLabelIndex = -1; - auto loopContext = context.functionContext->PushScopeContext(WfCodegenScopeType::Loop); - - loopLabelIndex = context.assembly->instructions.Count(); - continueLabelIndex = context.assembly->instructions.Count(); - GenerateExpressionInstructions(context, node->condition); - INSTRUCTION(Ins::OpNot(WfInsType::Bool)); - loopContext->breakInstructions.Add(INSTRUCTION(Ins::JumpIf(-1))); - GenerateStatementInstructions(context, node->statement); - INSTRUCTION(Ins::Jump(loopLabelIndex)); - breakLabelIndex = context.assembly->instructions.Count(); - - FOREACH(vint, index, loopContext->continueInstructions) - { - context.assembly->instructions[index].indexParameter = continueLabelIndex; - } - FOREACH(vint, index, loopContext->breakInstructions) - { - context.assembly->instructions[index].indexParameter = breakLabelIndex; - } - context.functionContext->PopScopeContext(); - } - - Pair GenerateTryProtected(WfStatement* node, Ptr protectedStatement, Ptr finallyStatement) - { - auto catchContext = context.functionContext->PushScopeContext(WfCodegenScopeType::TryCatch); - EXIT_CODE(Ins::UninstallTry(0)); - catchContext->exitStatement = finallyStatement; - - vint trap = INSTRUCTION(Ins::InstallTry(-1)); - GenerateStatementInstructions(context, protectedStatement); - context.functionContext->PopScopeContext(); - INSTRUCTION(Ins::UninstallTry(0)); - vint finish = INSTRUCTION(Ins::Jump(-1)); - - return{ trap,finish }; - } - - vint GenerateExceptionVariable(WfTryStatement* node) - { - WfLexicalSymbol* exceptionSymbol = nullptr; - WString exceptionName; - if (node->catchStatement) - { - auto scope = context.manager->nodeScopes[node].Obj(); - exceptionSymbol = scope->symbols[node->name.value][0].Obj(); - exceptionName = L"" + node->name.value; - } - else - { - exceptionName = L""; - } - - auto function = context.functionContext->function; - vint variableIndex = function->argumentNames.Count() + function->localVariableNames.Add(L"" + node->name.value); - if (exceptionSymbol) - { - context.functionContext->localVariables.Add(exceptionSymbol, variableIndex); - } - - return variableIndex; - } - - void GenerateTrap(WfTryStatement* node, vint variableIndex, Pair trap) - { - context.assembly->instructions[trap.key].indexParameter = context.assembly->instructions.Count(); - INSTRUCTION(Ins::LoadException()); - INSTRUCTION(Ins::StoreLocalVar(variableIndex)); - } - - void GenerateFinallyAndRaise(WfTryStatement* node, vint variableIndex) - { - GenerateStatementInstructions(context, node->finallyStatement); - INSTRUCTION(Ins::LoadLocalVar(variableIndex)); - INSTRUCTION(Ins::RaiseException()); - } - - void Visit(WfTryStatement* node)override - { - // try - auto trap1 = GenerateTryProtected(node, node->protectedStatement, node->finallyStatement); - Pair trap2 = { -1,-1 }; - auto variableIndex = GenerateExceptionVariable(node); - - // catch - { - GenerateTrap(node, variableIndex, trap1); - if (node->catchStatement) - { - if (node->finallyStatement) - { - trap2 = GenerateTryProtected(node, node->catchStatement, node->finallyStatement); - GenerateTrap(node, variableIndex, trap2); - GenerateFinallyAndRaise(node, variableIndex); - } - else - { - GenerateStatementInstructions(context, node->catchStatement); - } - } - else - { - GenerateFinallyAndRaise(node, variableIndex); - } - } - - // finally - context.assembly->instructions[trap1.value].indexParameter = context.assembly->instructions.Count(); - if (trap2.value != -1) - { - context.assembly->instructions[trap2.value].indexParameter = context.assembly->instructions.Count(); - } - if (node->finallyStatement) - { - GenerateStatementInstructions(context, node->finallyStatement); - } - } - - void Visit(WfBlockStatement* node)override - { - FOREACH(Ptr, statement, node->statements) - { - GenerateStatementInstructions(context, statement); - } - } - - void Visit(WfExpressionStatement* node)override - { - GenerateExpressionInstructions(context, node->expression); - INSTRUCTION(Ins::Pop()); - } - - void Visit(WfVariableStatement* node)override - { - auto manager = context.manager; - auto scope = manager->nodeScopes[node->variable.Obj()]; - auto symbol = scope->symbols[node->variable->name.value][0].Obj(); - auto function = context.functionContext->function; - vint index = function->argumentNames.Count() + function->localVariableNames.Add(node->variable->name.value); - context.functionContext->localVariables.Add(symbol, index); - - GenerateExpressionInstructions(context, node->variable->expression); - INSTRUCTION(Ins::StoreLocalVar(index)); - } - - void Visit(WfVirtualStatement* node)override - { - GenerateStatementInstructions(context, node->expandedStatement); - } - - void Visit(WfCoroutineStatement* node)override - { - CHECK_FAIL(L"GenerateStatementInstructionsVisitor::Visit(WfCoroutineStatement*)#Internal error, All coroutine statements do not emit instructions."); - } - }; - -#undef EXIT_CODE -#undef INSTRUCTION - - void GenerateStatementInstructions(WfCodegenContext& context, Ptr statement) - { - GenerateStatementInstructionsVisitor visitor(context); - statement->Accept(&visitor); - } - } - } -} - -/*********************************************************************** -EXPRESSION\WFEXPRESSION.CPP +.\EXPRESSION\WFEXPRESSION.CPP ***********************************************************************/ namespace vl @@ -24805,8 +1706,9 @@ Print (Module) } } + /*********************************************************************** -EXPRESSION\WFEXPRESSION_AST.CPP +.\EXPRESSION\WFEXPRESSION_AST.CPP ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -26605,8 +3507,9 @@ namespace vl } } + /*********************************************************************** -EXPRESSION\WFEXPRESSION_COPY.CPP +.\EXPRESSION\WFEXPRESSION_COPY.CPP ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -28471,8 +5374,9 @@ ModuleVisitor } } + /*********************************************************************** -EXPRESSION\WFEXPRESSION_EMPTY.CPP +.\EXPRESSION\WFEXPRESSION_EMPTY.CPP ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -28871,8 +5775,9 @@ ModuleUsingFragmentVisitor } } + /*********************************************************************** -EXPRESSION\WFEXPRESSION_PARSER.CPP +.\EXPRESSION\WFEXPRESSION_PARSER.CPP ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -32650,8 +9555,9 @@ Table Generation } } + /*********************************************************************** -EXPRESSION\WFEXPRESSION_TRAVERSE.CPP +.\EXPRESSION\WFEXPRESSION_TRAVERSE.CPP ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -34420,3 +11326,23183 @@ ModuleVisitor } } } + + +/*********************************************************************** +.\ANALYZER\WFANALYZER.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace analyzer + { + using namespace collections; + using namespace reflection::description; + +/*********************************************************************** +WfLexicalSymbol +***********************************************************************/ + + WfLexicalSymbol::WfLexicalSymbol(WfLexicalScope* _ownerScope) + :ownerScope(_ownerScope) + { + } + + WfLexicalSymbol::~WfLexicalSymbol() + { + } + + WString WfLexicalSymbol::GetFriendlyName() + { + return ownerScope->GetFriendlyName() + L"::" + name; + } + +/*********************************************************************** +WfLexicalScope +***********************************************************************/ + + WfLexicalScope::WfLexicalScope(WfLexicalScopeManager* _ownerManager) + :ownerManager(_ownerManager) + { + } + + WfLexicalScope::WfLexicalScope(Ptr _parentScope) + :ownerManager(0) + , parentScope(_parentScope) + { + } + + WfLexicalScope::~WfLexicalScope() + { + } + + WfLexicalScopeManager* WfLexicalScope::FindManager() + { + WfLexicalScope* scope = this; + while (scope) + { + if (scope->ownerManager) + { + return scope->ownerManager; + } + scope = scope->parentScope.Obj(); + } + return 0; + } + + Ptr WfLexicalScope::FindModule() + { + WfLexicalScope* scope = this; + while (scope) + { + if (auto module = scope->ownerNode.Cast()) + { + return module; + } + scope = scope->parentScope.Obj(); + } + return 0; + } + + WfLexicalScope* WfLexicalScope::FindFunctionScope() + { + auto scope = this; + while (scope) + { + if (scope->functionConfig) + { + return scope; + } + scope = scope->parentScope.Obj(); + } + return nullptr; + } + + WString WfLexicalScope::GetFriendlyName() + { + if (auto module = ownerNode.Cast()) + { + return L"<" + module->name.value + L">"; + } + else if (auto decl = ownerNode.Cast()) + { + auto name = decl->name.value; + if (name == L"") + { + name = L""; + } + return parentScope->GetFriendlyName() + L"::" + name; + } + else if (!parentScope) + { + return L""; + } + else + { + return parentScope->GetFriendlyName() + L"::<>"; + } + } + + Ptr WfLexicalScope::GetOwnerClassMember() + { + if (auto decl = ownerNode.Cast()) + { + return decl->classMember; + } + return nullptr; + } + +/*********************************************************************** +WfLexicalScopeName +***********************************************************************/ + + WfLexicalScopeName::WfLexicalScopeName(bool _imported) + :imported(_imported) + { + } + + WfLexicalScopeName::~WfLexicalScopeName() + { + } + + Ptr WfLexicalScopeName::AccessChild(const WString& name, bool imported) + { + vint index = children.Keys().IndexOf(name); + if (index == -1) + { + Ptr newName = new WfLexicalScopeName(imported); + newName->name = name; + newName->parent = this; + children.Add(name, newName); + return newName; + } + else + { + return children.Values()[index]; + } + } + + void WfLexicalScopeName::RemoveNonTypeDescriptorNames(WfLexicalScopeManager* manager) + { + FOREACH(Ptr, name, children.Values()) + { + name->RemoveNonTypeDescriptorNames(manager); + } + + for (vint i = children.Count() - 1; i >= 0; i--) + { + auto subScopeName = children.Values()[i]; + if (!subScopeName->imported) + { + children.Remove(children.Keys()[i]); + if (subScopeName->typeDescriptor) + { + manager->typeNames.Remove(subScopeName->typeDescriptor); + } + } + } + + declarations.Clear(); + } + + WString WfLexicalScopeName::GetFriendlyName() + { + if (parent) + { + WString parentName = parent->GetFriendlyName(); + if (parentName == L"") + { + return name; + } + else + { + return parentName + L"::" + name; + } + } + else + { + return L""; + } + } + +/*********************************************************************** +ResolveExpressionResult +***********************************************************************/ + + WString ResolveExpressionResult::GetFriendlyName(bool upperCase)const + { + WString typeName, result; + if (type) + { + typeName= + L" of type \"" + type->GetTypeFriendlyName() + L"\""; + } + + if (scopeName) + { + result = scopeName->GetFriendlyName(); + } + else if (symbol) + { + result = symbol->GetFriendlyName() + typeName; + } + else if (propertyInfo) + { + result = L"property \"" + propertyInfo->GetName() + L"\" in \"" + propertyInfo->GetOwnerTypeDescriptor()->GetTypeName() + L"\"" + typeName; + } + else if (methodInfo) + { + if (methodInfo->GetName() == L"") + { + result = L"constructor in \"" + methodInfo->GetOwnerTypeDescriptor()->GetTypeName() + L"\"" + typeName; + } + else + { + result = L"method \"" + methodInfo->GetName() + L"\" in \"" + methodInfo->GetOwnerTypeDescriptor()->GetTypeName() + L"\"" + typeName; + } + } + else if (eventInfo) + { + result = L"event \"" + eventInfo->GetName() + L"\" in \"" + eventInfo->GetOwnerTypeDescriptor()->GetTypeName() + L"\""; + } + else if (type) + { + result = L"expression" + typeName; + } + else + { + result = L""; + } + + if (result.Length() > 0 && upperCase) + { + result = INVLOC.ToUpper(result.Left(1)) + result.Right(result.Length() - 1); + } + return result; + } + + ResolveExpressionResult ResolveExpressionResult::ScopeName(Ptr _scopeName) + { + ResolveExpressionResult result; + result.scopeName = _scopeName; + return result; + } + + ResolveExpressionResult ResolveExpressionResult::ReadonlySymbol(Ptr _symbol) + { + ResolveExpressionResult result; + result.symbol = _symbol; + result.type = _symbol->typeInfo; + return result; + } + + ResolveExpressionResult ResolveExpressionResult::Symbol(Ptr _symbol) + { + ResolveExpressionResult result; + result.symbol = _symbol; + result.type = _symbol->typeInfo; + if (_symbol->creatorNode.Cast()) + { + result.writableType = _symbol->typeInfo; + } + return result; + } + + ResolveExpressionResult ResolveExpressionResult::ReadonlyType(Ptr _type) + { + ResolveExpressionResult result; + result.type = _type; + return result; + } + + ResolveExpressionResult ResolveExpressionResult::WritableType(Ptr _type) + { + ResolveExpressionResult result; + result.type = _type; + result.writableType = _type; + return result; + } + + ResolveExpressionResult ResolveExpressionResult::Property(reflection::description::IPropertyInfo* _propertyInfo) + { + Ptr getterType = CopyTypeInfo(_propertyInfo->GetReturn()); + Ptr setterType; + + if (getterType) + { + if (IMethodInfo* setter = _propertyInfo->GetSetter()) + { + setterType = getterType; + if (setter->GetParameterCount() == 1 && !IsSameType(getterType.Obj(), setter->GetParameter(0)->GetType())) + { + setterType = CopyTypeInfo(setter->GetParameter(0)->GetType()); + } + } + else if (_propertyInfo->IsWritable()) + { + auto td = _propertyInfo->GetOwnerTypeDescriptor(); + if ((td->GetTypeDescriptorFlags() & TypeDescriptorFlags::ReferenceType) != TypeDescriptorFlags::Undefined) + { + setterType = CopyTypeInfo(_propertyInfo->GetReturn()); + } + } + } + + ResolveExpressionResult result; + result.propertyInfo = _propertyInfo; + result.type = getterType; + result.writableType = setterType; + return result; + } + + ResolveExpressionResult ResolveExpressionResult::Method(reflection::description::IMethodInfo* _methodInfo) + { + ResolveExpressionResult result; + result.methodInfo = _methodInfo; + result.type = CreateTypeInfoFromMethodInfo(_methodInfo); + return result; + } + + ResolveExpressionResult ResolveExpressionResult::Constructor(reflection::description::IMethodInfo* _constructorInfo) + { + ResolveExpressionResult result; + result.constructorInfo = _constructorInfo; + result.type = CopyTypeInfo(_constructorInfo->GetReturn()); + return result; + } + + ResolveExpressionResult ResolveExpressionResult::Event(reflection::description::IEventInfo* _eventInfo) + { + ResolveExpressionResult result; + result.eventInfo = _eventInfo; + return result; + } + + bool IsSameTypeOrNull(ITypeInfo* fromType, ITypeInfo* toType) + { + if (fromType == toType) return true; + if ((fromType == nullptr) ^ (toType == nullptr)) return false; + return IsSameType(fromType, toType); + } + + bool ResolveExpressionResult::operator==(const ResolveExpressionResult& result) const + { + if (scopeName != result.scopeName) return false; + if (symbol != result.symbol) return false; + if (propertyInfo != result.propertyInfo) return false; + if (methodInfo != result.methodInfo) return false; + if (constructorInfo != result.constructorInfo) return false; + if (eventInfo != result.eventInfo) return false; + + if (!IsSameTypeOrNull(type.Obj(), result.type.Obj())) return false; + if (!IsSameTypeOrNull(writableType.Obj(), result.writableType.Obj())) return false; + if (!IsSameTypeOrNull(expectedType.Obj(), result.expectedType.Obj())) return false; + return true; + } + + bool ResolveExpressionResult::operator!=(const ResolveExpressionResult& result) const + { + return !(*this == result); + } + +/*********************************************************************** +WfLexicalScopeManager +***********************************************************************/ + + WfLexicalScopeManager::WfLexicalScopeManager(Ptr _parsingTable) + :parsingTable(_parsingTable) + { + attributes.Add({ L"cpp", L"File" }, TypeInfoRetriver::CreateTypeInfo()); + attributes.Add({ L"cpp", L"UserImpl" }, TypeInfoRetriver::CreateTypeInfo()); + attributes.Add({ L"cpp", L"Private" }, TypeInfoRetriver::CreateTypeInfo()); + attributes.Add({ L"cpp", L"Protected" }, TypeInfoRetriver::CreateTypeInfo()); + attributes.Add({ L"cpp", L"Friend" }, TypeInfoRetriver::CreateTypeInfo()); + } + + WfLexicalScopeManager::~WfLexicalScopeManager() + { + } + + vint WfLexicalScopeManager::AddModule(const WString& moduleCode) + { + if (auto module = WfParseModule(moduleCode, parsingTable, errors, usedCodeIndex)) + { + modules.Add(module); + moduleCodes.Add(moduleCode); + } + return usedCodeIndex++; + } + + vint WfLexicalScopeManager::AddModule(Ptr module) + { + module->codeRange.codeIndex = usedCodeIndex; + modules.Add(module); + moduleCodes.Add(L""); + return usedCodeIndex++; + } + + WfLexicalScopeManager::ModuleList& WfLexicalScopeManager::GetModules() + { + return modules; + } + + WfLexicalScopeManager::ModuleCodeList& WfLexicalScopeManager::GetModuleCodes() + { + return moduleCodes; + } + + void WfLexicalScopeManager::Clear(bool keepTypeDescriptorNames, bool deleteModules) + { + if (globalName) + { + if (keepTypeDescriptorNames) + { + globalName->RemoveNonTypeDescriptorNames(this); + } + else + { + globalName = 0; + typeNames.Clear(); + } + } + + if (deleteModules) + { + modules.Clear(); + moduleCodes.Clear(); + usedCodeIndex = 0; + usedTempVars = 0; + } + + errors.Clear(); + namespaceNames.Clear(); + + nodeScopes.Clear(); + expressionResolvings.Clear(); + lambdaCaptures.Clear(); + interfaceMethodImpls.Clear(); + declarationTypes.Clear(); + declarationMemberInfos.Clear(); + baseConstructorCallResolvings.Clear(); + } + +#define CALLBACK(EXPR) if (callback) callback->EXPR + + void WfLexicalScopeManager::Rebuild(bool keepTypeDescriptorNames, IWfCompilerCallback* callback) + { + CALLBACK(OnLoadEnvironment()); + Clear(keepTypeDescriptorNames, false); + if (!globalName) + { + globalName = new WfLexicalScopeName(true); + BuildGlobalNameFromTypeDescriptors(this); + } + + CALLBACK(OnInitialize(this)); + vint errorCount = errors.Count(); + +#define EXIT_IF_ERRORS_EXIST\ + do\ + {\ + if (errors.Count() != errorCount) return;\ + }while (0) + + EXIT_IF_ERRORS_EXIST; + FOREACH(Ptr, module, modules) + { + ContextFreeModuleDesugar(this, module); + ValidateModuleStructure(this, module); + } + + EXIT_IF_ERRORS_EXIST; + BuildGlobalNameFromModules(this); + FOREACH(Ptr, module, modules) + { + BuildScopeForModule(this, module); + } + ValidateScopeName(this, globalName); + CheckScopes_DuplicatedSymbol(this); + + EXIT_IF_ERRORS_EXIST; + FOREACH(Ptr, module, modules) + { + CompleteScopeForModule(this, module); + } + CheckScopes_BaseType(this); + CheckScopes_SymbolType(this); + + EXIT_IF_ERRORS_EXIST; + FOREACH(Ptr, module, modules) + { + CALLBACK(OnValidateModule(module)); + ValidateModuleSemantic(this, module); + } + +#undef EXIT_IF_ERRORS_EXIST + } + +#undef CALLBACK + + bool WfLexicalScopeManager::ResolveMember(ITypeDescriptor* typeDescriptor, const WString& name, bool preferStatic, collections::SortedList& searchedTypes, collections::List& results) + { + if (searchedTypes.Contains(typeDescriptor)) + { + return true; + } + searchedTypes.Add(typeDescriptor); + + bool found = false; + bool foundStaticMember = false; + + + if ((typeDescriptor->GetTypeDescriptorFlags() & TypeDescriptorFlags::EnumType) != TypeDescriptorFlags::Undefined) + { + if (preferStatic) + { + auto enumType = typeDescriptor->GetEnumType(); + vint index = enumType->IndexOfItem(name); + if (index != -1) + { + results.Add(ResolveExpressionResult::ReadonlyType(MakePtr(typeDescriptor, TypeInfoHint::Normal))); + return true; + } + } + return false; + } + + { + auto scopeName = typeNames[typeDescriptor]; + vint index = scopeName->children.Keys().IndexOf(name); + if (index != -1) + { + auto subScopeName = scopeName->children.Values()[index]; + found = true; + foundStaticMember = true; + results.Add(ResolveExpressionResult::ScopeName(subScopeName)); + } + } + + if (auto group = typeDescriptor->GetMethodGroupByName(name, false)) + { + for (vint i = 0; i < group->GetMethodCount(); i++) + { + auto info = group->GetMethod(i); + if (info->IsStatic()) + { + found = true; + foundStaticMember = true; + results.Add(ResolveExpressionResult::Method(info)); + } + } + } + + if (foundStaticMember && preferStatic) + { + return true; + } + + if (auto group = typeDescriptor->GetMethodGroupByName(name, false)) + { + for (vint i = 0; i < group->GetMethodCount(); i++) + { + auto info = group->GetMethod(i); + if (!info->IsStatic()) + { + found = true; + results.Add(ResolveExpressionResult::Method(info)); + } + } + } + if (auto info = typeDescriptor->GetPropertyByName(name, false)) + { + found = true; + results.Add(ResolveExpressionResult::Property(info)); + } + if (auto info = typeDescriptor->GetEventByName(name, false)) + { + found = true; + results.Add(ResolveExpressionResult::Event(info)); + } + + if (!found) + { + vint count = typeDescriptor->GetBaseTypeDescriptorCount(); + for (vint i = 0; i < count; i++) + { + if (ResolveMember(typeDescriptor->GetBaseTypeDescriptor(i), name, preferStatic, searchedTypes, results)) + { + found = true; + } + } + } + return found; + } + + class UsingPathToNameVisitor :public Object, public WfModuleUsingFragment::IVisitor + { + public: + WString name; + WString result; + + UsingPathToNameVisitor(const WString& _name) + :name(_name) + { + } + + void Visit(WfModuleUsingNameFragment* node) + { + result = node->name.value; + } + + void Visit(WfModuleUsingWildCardFragment* node) + { + result = name; + } + + static WString Execute(Ptr fragment, const WString& name) + { + UsingPathToNameVisitor visitor(name); + fragment->Accept(&visitor); + return visitor.result; + } + }; + + bool WfLexicalScopeManager::ResolveName(WfLexicalScope* scope, const WString& name, collections::List& results) + { + vint oldResultCount = results.Count(); + bool visibleToNonStatic = false; + WfLexicalScope* firstConfigScope = nullptr; + while (scope) + { + if (scope->ownerNode.Cast() || scope->ownerNode.Cast()) + { + break; + } + + if (scope->functionConfig) + { + visibleToNonStatic = scope->functionConfig->thisAccessable || scope->functionConfig->parentThisAccessable; + if (!firstConfigScope) + { + firstConfigScope = scope; + } + } + + vint index = scope->symbols.Keys().IndexOf(name); + if (index != -1) + { + if (scope->typeOfThisExpr) + { + if (scope->ownerNode.Cast()) + { + FOREACH(Ptr, symbol, scope->symbols.GetByIndex(index)) + { + if (symbol->creatorNode.Cast()) + { + auto result = ResolveExpressionResult::Symbol(symbol); + if (!results.Contains(result)) + { + results.Add(result); + } + } + else if (symbol->creatorNode.Cast()->classMember->kind == WfClassMemberKind::Normal) + { + if (firstConfigScope->parentScope == scope) + { + auto result = ResolveExpressionResult::Symbol(symbol); + if (!results.Contains(result)) + { + results.Add(result); + } + } + } + } + } + } + else + { + FOREACH(Ptr, symbol, scope->symbols.GetByIndex(index)) + { + auto result = ResolveExpressionResult::Symbol(symbol); + if (!results.Contains(result)) + { + results.Add(result); + } + } + } + } + + if (scope->typeOfThisExpr) + { + SortedList searchedTypes; + ResolveMember(scope->typeOfThisExpr, name, !visibleToNonStatic, searchedTypes, results); + } + + scope = scope->parentScope.Obj(); + } + + while (scope) + { + if (auto nsDecl = scope->ownerNode.Cast()) + { + auto scopeName = namespaceNames[nsDecl.Obj()]; + vint index = scopeName->children.Keys().IndexOf(name); + if (index != -1) + { + auto subScopeName = scopeName->children.Values()[index]; + auto result = ResolveExpressionResult::ScopeName(subScopeName); + if (!results.Contains(result)) + { + results.Add(result); + } + } + scope = scope->parentScope.Obj(); + } + else + { + break; + } + } + + vint index = globalName->children.Keys().IndexOf(name); + if (index != -1) + { + auto subScopeName = globalName->children.Values()[index]; + auto result = ResolveExpressionResult::ScopeName(subScopeName); + if (!results.Contains(result)) + { + results.Add(result); + } + } + + if (auto module = scope->ownerNode.Cast()) + { + FOREACH(Ptr, path, module->paths) + { + auto scopeName = globalName; + FOREACH(Ptr, item, path->items) + { + WString fragmentName; + FOREACH(Ptr, fragment, item->fragments) + { + fragmentName += UsingPathToNameVisitor::Execute(fragment, name); + } + vint index = scopeName->children.Keys().IndexOf(fragmentName); + if (index == -1) goto USING_PATH_MATCHING_FAILED; + scopeName = scopeName->children.Values()[index]; + } + + { + auto result = ResolveExpressionResult::ScopeName(scopeName); + if (!results.Contains(result)) + { + results.Add(result); + } + } + USING_PATH_MATCHING_FAILED:; + } + } + + return results.Count() > oldResultCount; + } + + Ptr WfLexicalScopeManager::GetDeclarationSymbol(WfLexicalScope* scope, WfDeclaration* node) + { + auto symbol = From(scope->parentScope->symbols[node->name.value]) + .Where([=](Ptr symbol) + { + return symbol->creatorNode == node; + }) + .First(); + return symbol; + } + + void WfLexicalScopeManager::CreateLambdaCapture(parsing::ParsingTreeCustomBase* node, Ptr capture) + { + if (!capture) + { + capture = MakePtr(); + } + lambdaCaptures.Add(node, capture); + } + } + } +} + +/*********************************************************************** +.\ANALYZER\WFANALYZER_BUILDGLOBALNAME.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace analyzer + { + using namespace collections; + using namespace reflection::description; + using namespace typeimpl; + +/*********************************************************************** +BuildGlobalNameFromTypeDescriptors +***********************************************************************/ + + void BuildGlobalNameFromTypeDescriptors(WfLexicalScopeManager* manager) + { + for (vint i = 0; i < GetGlobalTypeManager()->GetTypeDescriptorCount(); i++) + { + ITypeDescriptor* typeDescriptor = GetGlobalTypeManager()->GetTypeDescriptor(i); + WString name = typeDescriptor->GetTypeName(); + const wchar_t* reading = name.Buffer(); + Ptr currentName = manager->globalName; + + while (true) + { + WString fragment; + const wchar_t* delimiter = wcsstr(reading, L"::"); + if (delimiter) + { + fragment = WString(reading, vint(delimiter - reading)); + reading = delimiter + 2; + } + else + { + fragment = reading; + reading = 0; + } + + currentName = currentName->AccessChild(fragment, true); + if (!reading) + { + currentName->typeDescriptor = typeDescriptor; + manager->typeNames.Add(typeDescriptor, currentName); + break; + } + } + } + } + +/*********************************************************************** +BuildGlobalNameFromModules +***********************************************************************/ + + class BuildClassMemberVisitor : public Object, public WfDeclaration::IVisitor + { + public: + WfLexicalScopeManager* manager; + Ptr scopeName; + Ptr classDecl; + Ptr td; + + BuildClassMemberVisitor(WfLexicalScopeManager* _manager, Ptr _scopeName, Ptr _classDecl, Ptr _td) + :manager(_manager) + , scopeName(_scopeName) + , classDecl(_classDecl) + , td(_td) + { + } + + static WString GetTypeName(WfLexicalScopeManager* manager, Ptr scopeName) + { + WString typeName = scopeName->name; + { + WfLexicalScopeName* name = scopeName->parent; + while (name && name != manager->globalName.Obj()) + { + typeName = name->name + L"::" + typeName; + name = name->parent; + } + } + return typeName; + } + + static void AddCustomType(WfLexicalScopeManager* manager, Ptr scopeName, Ptr declaration, Ptr td) + { + manager->declarationTypes.Add(declaration, td); + + if (!scopeName->typeDescriptor) + { + scopeName->typeDescriptor = td.Obj(); + manager->typeNames.Add(td.Obj(), scopeName); + } + } + + static void BuildClass(WfLexicalScopeManager* manager, Ptr scopeName, Ptr declaration) + { + WString typeName = GetTypeName(manager, scopeName); + Ptr td; + switch (declaration->kind) + { + case WfClassKind::Class: + td = MakePtr(typeName); + break; + case WfClassKind::Interface: + td = MakePtr(typeName); + break; + } + AddCustomType(manager, scopeName, declaration, td); + + FOREACH(Ptr, memberDecl, declaration->declarations) + { + BuildClassMemberVisitor visitor(manager, scopeName, declaration, td); + memberDecl->Accept(&visitor); + } + } + + void Visit(WfNamespaceDeclaration* node)override + { + } + + void Visit(WfFunctionDeclaration* node)override + { + if (node->classMember->kind == WfClassMemberKind::Static) + { + auto info = MakePtr(); + td->AddMember(node->name.value, info); + manager->declarationMemberInfos.Add(node, info); + } + else + { + switch (classDecl->kind) + { + case WfClassKind::Class: + { + auto info = MakePtr(); + td->AddMember(node->name.value, info); + manager->declarationMemberInfos.Add(node, info); + } + break; + case WfClassKind::Interface: + { + auto info = MakePtr(); + td->AddMember(node->name.value, info); + manager->declarationMemberInfos.Add(node, info); + } + break; + } + } + } + + void Visit(WfVariableDeclaration* node)override + { + auto info = MakePtr(td.Obj(), node->name.value); + td->AddMember(info); + manager->declarationMemberInfos.Add(node, info); + } + + void Visit(WfEventDeclaration* node)override + { + auto info = MakePtr(td.Obj(), node->name.value); + td->AddMember(info); + manager->declarationMemberInfos.Add(node, info); + } + + void Visit(WfPropertyDeclaration* node)override + { + auto info = MakePtr(td.Obj(), node->name.value); + td->AddMember(info); + manager->declarationMemberInfos.Add(node, info); + } + + void Visit(WfConstructorDeclaration* node)override + { + Ptr typeInfo; + { + auto elementType = MakePtr(td.Obj(), TypeInfoHint::Normal); + if (node->constructorType == WfConstructorType::RawPtr) + { + typeInfo = MakePtr(elementType); + } + else + { + typeInfo = MakePtr(elementType); + } + } + + auto info = MakePtr(typeInfo); + td->AddMember(info); + manager->declarationMemberInfos.Add(node, info); + } + + void Visit(WfDestructorDeclaration* node)override + { + } + + void Visit(WfClassDeclaration* node)override + { + auto newScopeName = scopeName->AccessChild(node->name.value, false); + newScopeName->declarations.Add(node); + BuildClass(manager, newScopeName, node); + } + + void Visit(WfEnumDeclaration* node)override + { + BuildNameForDeclaration(manager, scopeName, node); + } + + void Visit(WfStructDeclaration* node)override + { + BuildNameForDeclaration(manager, scopeName, node); + } + + void Visit(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + }; + + class BuildNameDeclarationVisitor + : public empty_visitor::DeclarationVisitor + { + public: + WfLexicalScopeManager* manager; + Ptr scopeName; + + BuildNameDeclarationVisitor(WfLexicalScopeManager* _manager, Ptr _scopeName) + :manager(_manager) + , scopeName(_scopeName) + { + } + + void Dispatch(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + + void Visit(WfNamespaceDeclaration* node)override + { + manager->namespaceNames.Add(node, scopeName); + FOREACH(Ptr, subDecl, node->declarations) + { + BuildNameForDeclaration(manager, scopeName, subDecl.Obj()); + } + } + + void Visit(WfClassDeclaration* node)override + { + BuildClassMemberVisitor::BuildClass(manager, scopeName, node); + } + + void Visit(WfEnumDeclaration* node)override + { + auto td = MakePtr(node->kind == WfEnumKind::Flag, BuildClassMemberVisitor::GetTypeName(manager, scopeName)); + BuildClassMemberVisitor::AddCustomType(manager, scopeName, node, td); + } + + void Visit(WfStructDeclaration* node)override + { + auto td = MakePtr(BuildClassMemberVisitor::GetTypeName(manager, scopeName)); + BuildClassMemberVisitor::AddCustomType(manager, scopeName, node, td); + } + }; + + void BuildNameForDeclaration(WfLexicalScopeManager* manager, Ptr name, WfDeclaration* decl) + { + auto scopeName = name->AccessChild(decl->name.value, false); + scopeName->declarations.Add(decl); + + BuildNameDeclarationVisitor visitor(manager, scopeName); + decl->Accept(&visitor); + } + + void BuildGlobalNameFromModules(WfLexicalScopeManager* manager) + { + FOREACH(Ptr, module, manager->GetModules()) + { + FOREACH(Ptr, decl, module->declarations) + { + BuildNameForDeclaration(manager, manager->globalName, decl.Obj()); + } + } + } + +/*********************************************************************** +ValidateScopeName +***********************************************************************/ + + class ValidateScopeNameDeclarationVisitor + : public Object + , public WfDeclaration::IVisitor + { + public: + enum Category + { + None, + Type, + Variable, + Function, + Event, + Property, + Namespace, + }; + + WfLexicalScopeManager* manager; + Ptr name; + Category category; + + ValidateScopeNameDeclarationVisitor(WfLexicalScopeManager* _manager, Ptr _name) + :manager(_manager) + , name(_name) + , category(name->typeDescriptor && name->imported ? Type : None) + { + } + + void AddError(WfDeclaration* node) + { + WString categoryName; + switch (category) + { + case Type: + categoryName = L"type"; + break; + case Variable: + categoryName = L"variable"; + break; + case Function: + categoryName = L"function"; + break; + case Event: + categoryName = L"event"; + break; + case Property: + categoryName = L"property"; + break; + case Namespace: + categoryName = L"namespace"; + break; + default: + CHECK_FAIL(L"ValidateScopeNameDeclarationVisitor::AddError(WfDeclaration*)#Internal error."); + } + manager->errors.Add(WfErrors::DuplicatedDeclaration(node, categoryName)); + } + + void Visit(WfNamespaceDeclaration* node)override + { + if (category == None) + { + category = Namespace; + } + else if (category != Namespace) + { + AddError(node); + } + } + + void Visit(WfFunctionDeclaration* node)override + { + if (category == None) + { + category = Function; + } + else if (category != Function) + { + AddError(node); + } + } + + void Visit(WfVariableDeclaration* node)override + { + if (category == None) + { + category = Variable; + } + else + { + AddError(node); + } + } + + void Visit(WfEventDeclaration* node)override + { + if (category == None) + { + category = Event; + } + else + { + AddError(node); + } + } + + void Visit(WfPropertyDeclaration* node)override + { + if (category == None) + { + category = Property; + } + else + { + AddError(node); + } + } + + void Visit(WfConstructorDeclaration* node)override + { + } + + void Visit(WfDestructorDeclaration* node)override + { + } + + void Visit(WfClassDeclaration* node)override + { + if (category == None) + { + category = Type; + } + else + { + AddError(node); + } + } + + void Visit(WfEnumDeclaration* node)override + { + if (category == None) + { + category = Type; + } + else + { + AddError(node); + } + } + + void Visit(WfStructDeclaration* node)override + { + if (category == None) + { + category = Type; + } + else + { + AddError(node); + } + } + + void Visit(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + }; + + void ValidateScopeName(WfLexicalScopeManager* manager, Ptr name) + { + ValidateScopeNameDeclarationVisitor visitor(manager, name); + FOREACH(Ptr, declaration, name->declarations) + { + declaration->Accept(&visitor); + } + + FOREACH(Ptr, child, name->children.Values()) + { + ValidateScopeName(manager, child); + } + } + } + } +} + +/*********************************************************************** +.\ANALYZER\WFANALYZER_BUILDSCOPE.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace analyzer + { + using namespace collections; + using namespace parsing; + using namespace reflection; + using namespace reflection::description; + using namespace typeimpl; + +/*********************************************************************** +BuildScopeForDeclaration +***********************************************************************/ + + class BuildScopeForDeclarationVisitor : public Object, public WfDeclaration::IVisitor + { + public: + WfLexicalScopeManager* manager; + ParsingTreeCustomBase* source; + Ptr parentScope; + + Ptr resultScope; + + BuildScopeForDeclarationVisitor(WfLexicalScopeManager* _manager, Ptr _parentScope, ParsingTreeCustomBase* _source) + :manager(_manager) + , source(_source) + , parentScope(_parentScope) + { + } + + void Visit(Ptr scope, List>& attributes) + { + FOREACH(Ptr, attribute, attributes) + { + if (attribute->value) + { + BuildScopeForExpression(manager, scope, attribute->value); + } + } + } + + void Visit(WfNamespaceDeclaration* node)override + { + Ptr symbol = new WfLexicalSymbol(parentScope.Obj()); + symbol->name = node->name.value; + symbol->creatorNode = node; + parentScope->symbols.Add(symbol->name, symbol); + + resultScope = new WfLexicalScope(parentScope); + FOREACH(Ptr, declaration, node->declarations) + { + BuildScopeForDeclaration(manager, resultScope, declaration, node); + } + } + + void Visit(WfFunctionDeclaration* node)override + { + resultScope = new WfLexicalScope(parentScope); + auto config = MakePtr(); + resultScope->functionConfig = config; + resultScope->ownerNodeSource = source; + + if (source) + { + if (dynamic_cast(source)) + { + config->lambda = true; + config->thisAccessable = false; + config->parentThisAccessable = true; + } + else if (dynamic_cast(source)) + { + config->lambda = true; + config->thisAccessable = true; + config->parentThisAccessable = true; + } + else if (dynamic_cast(source)) + { + config->lambda = false; + config->thisAccessable = node->classMember->kind != WfClassMemberKind::Static; + config->parentThisAccessable = false; + } + } + + if (node->anonymity == WfFunctionAnonymity::Named) + { + Ptr functionNameScope = parentScope; + if (source && dynamic_cast(source)) + { + functionNameScope = resultScope; + } + + Ptr symbol = new WfLexicalSymbol(functionNameScope.Obj()); + symbol->name = node->name.value; + symbol->creatorNode = node; + { + Ptr type = new WfFunctionType; + type->result = node->returnType; + FOREACH(Ptr, argument, node->arguments) + { + type->arguments.Add(argument->type); + } + symbol->type = type; + } + functionNameScope->symbols.Add(symbol->name, symbol); + } + + if (node->statement) + { + FOREACH(Ptr, argument, node->arguments) + { + Ptr argumentSymbol = new WfLexicalSymbol(resultScope.Obj()); + argumentSymbol->name = argument->name.value; + argumentSymbol->type = argument->type; + argumentSymbol->creatorNode = argument; + resultScope->symbols.Add(argumentSymbol->name, argumentSymbol); + + Visit(parentScope, argument->attributes); + } + + BuildScopeForStatement(manager, resultScope, node->statement); + } + } + + void Visit(WfVariableDeclaration* node)override + { + Ptr symbol = new WfLexicalSymbol(parentScope.Obj()); + symbol->name = node->name.value; + symbol->creatorNode = node; + symbol->type = node->type; + parentScope->symbols.Add(symbol->name, symbol); + + BuildScopeForExpression(manager, parentScope, node->expression); + } + + void Visit(WfEventDeclaration* node)override + { + Ptr symbol = new WfLexicalSymbol(parentScope.Obj()); + symbol->name = node->name.value; + symbol->creatorNode = node; + parentScope->symbols.Add(symbol->name, symbol); + } + + void Visit(WfPropertyDeclaration* node)override + { + Ptr symbol = new WfLexicalSymbol(parentScope.Obj()); + symbol->name = node->name.value; + symbol->creatorNode = node; + symbol->type = node->type; + parentScope->symbols.Add(symbol->name, symbol); + } + + void Visit(WfConstructorDeclaration* node)override + { + resultScope = new WfLexicalScope(parentScope); + + FOREACH(Ptr, argument, node->arguments) + { + Ptr argumentSymbol = new WfLexicalSymbol(resultScope.Obj()); + argumentSymbol->name = argument->name.value; + argumentSymbol->type = argument->type; + argumentSymbol->creatorNode = argument; + resultScope->symbols.Add(argumentSymbol->name, argumentSymbol); + } + + FOREACH(Ptr, call, node->baseConstructorCalls) + { + FOREACH(Ptr, argument, call->arguments) + { + BuildScopeForExpression(manager, resultScope, argument); + } + } + + auto bodyScope = MakePtr(resultScope); + { + auto config = MakePtr(); + bodyScope->functionConfig = config; + + config->lambda = false; + config->thisAccessable = true; + config->parentThisAccessable = false; + } + BuildScopeForStatement(manager, bodyScope, node->statement); + } + + void Visit(WfDestructorDeclaration* node)override + { + resultScope = new WfLexicalScope(parentScope); + { + auto config = MakePtr(); + resultScope->functionConfig = config; + + config->lambda = false; + config->thisAccessable = true; + config->parentThisAccessable = false; + } + BuildScopeForStatement(manager, resultScope, node->statement); + } + + void Visit(WfClassDeclaration* node)override + { + Ptr symbol = new WfLexicalSymbol(parentScope.Obj()); + symbol->name = node->name.value; + symbol->creatorNode = node; + parentScope->symbols.Add(symbol->name, symbol); + + auto td = manager->declarationTypes[node]; + resultScope = new WfLexicalScope(parentScope); + resultScope->typeOfThisExpr = td.Obj(); + FOREACH(Ptr, memberDecl, node->declarations) + { + BuildScopeForDeclaration(manager, resultScope, memberDecl, node); + } + } + + void Visit(WfEnumDeclaration* node)override + { + Ptr symbol = new WfLexicalSymbol(parentScope.Obj()); + symbol->name = node->name.value; + symbol->creatorNode = node; + parentScope->symbols.Add(symbol->name, symbol); + + FOREACH(Ptr, item, node->items) + { + Visit(parentScope, item->attributes); + } + } + + void Visit(WfStructDeclaration* node)override + { + Ptr symbol = new WfLexicalSymbol(parentScope.Obj()); + symbol->name = node->name.value; + symbol->creatorNode = node; + parentScope->symbols.Add(symbol->name, symbol); + + FOREACH(Ptr, member, node->members) + { + Visit(parentScope, member->attributes); + } + } + + void Visit(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + Execute(manager, parentScope, source, decl); + } + } + + static Ptr Execute(WfLexicalScopeManager* manager, Ptr parentScope, ParsingTreeCustomBase* source, Ptr declaration) + { + BuildScopeForDeclarationVisitor visitor(manager, parentScope, source); + declaration->Accept(&visitor); + visitor.Visit(parentScope, declaration->attributes); + if (visitor.resultScope) + { + manager->nodeScopes.Add(declaration.Obj(), visitor.resultScope); + visitor.resultScope->ownerNode = declaration; + } + else + { + manager->nodeScopes.Add(declaration.Obj(), parentScope); + } + return visitor.resultScope; + } + }; + +/*********************************************************************** +BuildScopeForStatement +***********************************************************************/ + + class BuildScopeForStatementVisitor + : public Object + , public WfStatement::IVisitor + , public WfVirtualStatement::IVisitor + , public WfCoroutineStatement::IVisitor + { + public: + WfLexicalScopeManager* manager; + Ptr parentScope; + Ptr resultScope; + + BuildScopeForStatementVisitor(WfLexicalScopeManager* _manager, Ptr _parentScope) + :manager(_manager) + , parentScope(_parentScope) + { + } + + void Visit(WfBreakStatement* node)override + { + } + + void Visit(WfContinueStatement* node)override + { + } + + void Visit(WfReturnStatement* node)override + { + if (node->expression) + { + BuildScopeForExpression(manager, parentScope, node->expression); + } + } + + void Visit(WfDeleteStatement* node)override + { + BuildScopeForExpression(manager, parentScope, node->expression); + } + + void Visit(WfRaiseExceptionStatement* node)override + { + if (node->expression) + { + BuildScopeForExpression(manager, parentScope, node->expression); + } + } + + void Visit(WfIfStatement* node)override + { + resultScope = new WfLexicalScope(parentScope); + if (node->type) + { + Ptr symbol = new WfLexicalSymbol(resultScope.Obj()); + symbol->name = node->name.value; + symbol->type = node->type; + symbol->creatorNode = node; + resultScope->symbols.Add(symbol->name, symbol); + } + + BuildScopeForExpression(manager, resultScope, node->expression); + BuildScopeForStatement(manager, resultScope, node->trueBranch); + if (node->falseBranch) + { + BuildScopeForStatement(manager, resultScope, node->falseBranch); + } + } + + void Visit(WfWhileStatement* node)override + { + BuildScopeForExpression(manager, parentScope, node->condition); + BuildScopeForStatement(manager, parentScope, node->statement); + } + + void Visit(WfTryStatement* node)override + { + BuildScopeForStatement(manager, parentScope, node->protectedStatement); + if (node->catchStatement) + { + resultScope = new WfLexicalScope(parentScope); + + Ptr symbol = new WfLexicalSymbol(resultScope.Obj()); + symbol->name = node->name.value; + symbol->creatorNode = node; + { + auto system = MakePtr(); + system->name.value = L"system"; + + auto exception = MakePtr(); + exception->parent = system; + exception->name.value = L"Exception"; + + auto sharedPtr = MakePtr(); + sharedPtr->element = exception; + + symbol->type = sharedPtr; + } + resultScope->symbols.Add(symbol->name, symbol); + + BuildScopeForStatement(manager, resultScope, node->catchStatement); + } + if (node->finallyStatement) + { + BuildScopeForStatement(manager, parentScope, node->finallyStatement); + } + } + + void Visit(WfBlockStatement* node)override + { + resultScope = new WfLexicalScope(parentScope); + + FOREACH(Ptr, statement, node->statements) + { + BuildScopeForStatement(manager, resultScope, statement); + } + } + + void Visit(WfExpressionStatement* node)override + { + BuildScopeForExpression(manager, parentScope, node->expression); + } + + void Visit(WfVariableStatement* node)override + { + BuildScopeForDeclaration(manager, parentScope, node->variable, node); + } + + void Visit(WfVirtualStatement* node)override + { + node->Accept((WfVirtualStatement::IVisitor*)this); + if (node->expandedStatement) + { + BuildScopeForStatement(manager, parentScope, node->expandedStatement); + } + } + + void Visit(WfSwitchStatement* node)override + { + BuildScopeForExpression(manager, parentScope, node->expression); + FOREACH(Ptr, switchCase, node->caseBranches) + { + BuildScopeForExpression(manager, parentScope, switchCase->expression); + BuildScopeForStatement(manager, parentScope, switchCase->statement); + } + if (node->defaultBranch) + { + BuildScopeForStatement(manager, parentScope, node->defaultBranch); + } + } + + void Visit(WfForEachStatement* node)override + { + resultScope = new WfLexicalScope(parentScope); + + Ptr symbol = new WfLexicalSymbol(resultScope.Obj()); + symbol->name = node->name.value; + symbol->creatorNode = node; + resultScope->symbols.Add(symbol->name, symbol); + + BuildScopeForExpression(manager, parentScope, node->collection); + BuildScopeForStatement(manager, resultScope, node->statement); + } + + void Visit(WfCoProviderStatement* node)override + { + resultScope = new WfLexicalScope(parentScope); + { + Ptr symbol = new WfLexicalSymbol(resultScope.Obj()); + symbol->name = L"$PROVIDER"; + symbol->creatorNode = node; + resultScope->symbols.Add(symbol->name, symbol); + } + { + Ptr symbol = new WfLexicalSymbol(resultScope.Obj()); + symbol->name = L"$IMPL"; + symbol->creatorNode = node; + resultScope->symbols.Add(symbol->name, symbol); + } + BuildScopeForStatement(manager, resultScope, node->statement); + } + + void Visit(WfCoroutineStatement* node)override + { + node->Accept((WfCoroutineStatement::IVisitor*)this); + } + + void Visit(WfCoPauseStatement* node)override + { + if (node->statement) + { + BuildScopeForStatement(manager, parentScope, node->statement); + } + } + + void Visit(WfCoOperatorStatement* node)override + { + if (node->varName.value != L"") + { + Ptr symbol = new WfLexicalSymbol(parentScope.Obj()); + symbol->name = node->varName.value; + symbol->creatorNode = node; + parentScope->symbols.Add(symbol->name, symbol); + } + + FOREACH(Ptr, argument, node->arguments) + { + BuildScopeForExpression(manager, parentScope, argument); + } + } + + static Ptr Execute(WfLexicalScopeManager* manager, Ptr parentScope, Ptr statement) + { + BuildScopeForStatementVisitor visitor(manager, parentScope); + statement->Accept(&visitor); + if (visitor.resultScope) + { + manager->nodeScopes.Add(statement.Obj(), visitor.resultScope); + visitor.resultScope->ownerNode = statement; + } + else + { + manager->nodeScopes.Add(statement.Obj(), parentScope); + } + return visitor.resultScope; + } + }; + +/*********************************************************************** +BuildScopeForExpression +***********************************************************************/ + + class BuildScopeForExpressionVisitor + : public Object + , public WfExpression::IVisitor + , public WfVirtualExpression::IVisitor + { + public: + WfLexicalScopeManager* manager; + Ptr parentScope; + Ptr resultScope; + + BuildScopeForExpressionVisitor(WfLexicalScopeManager* _manager, Ptr _parentScope) + :manager(_manager) + , parentScope(_parentScope) + { + } + + void Visit(WfThisExpression* node)override + { + } + + void Visit(WfTopQualifiedExpression* node)override + { + } + + void Visit(WfReferenceExpression* node)override + { + } + + void Visit(WfOrderedNameExpression* node)override + { + } + + void Visit(WfOrderedLambdaExpression* node)override + { + manager->CreateLambdaCapture(node); + + SortedList names; + SearchOrderedName(parentScope.Obj(), node->body, names); + + resultScope = new WfLexicalScope(parentScope); + auto config = MakePtr(); + resultScope->functionConfig = config; + + config->lambda = true; + config->thisAccessable = false; + config->parentThisAccessable = true; + + FOREACH(vint, name, names) + { + Ptr symbol = new WfLexicalSymbol(resultScope.Obj()); + symbol->name = L"$" + itow(name); + symbol->creatorNode = node; + resultScope->symbols.Add(symbol->name, symbol); + } + + BuildScopeForExpression(manager, resultScope, node->body); + } + + void Visit(WfMemberExpression* node)override + { + BuildScopeForExpression(manager, parentScope, node->parent); + } + + void Visit(WfChildExpression* node)override + { + BuildScopeForExpression(manager, parentScope, node->parent); + } + + void Visit(WfLiteralExpression* node)override + { + } + + void Visit(WfFloatingExpression* node)override + { + } + + void Visit(WfIntegerExpression* node)override + { + } + + void Visit(WfStringExpression* node)override + { + } + + void Visit(WfUnaryExpression* node)override + { + BuildScopeForExpression(manager, parentScope, node->operand); + } + + void Visit(WfBinaryExpression* node)override + { + BuildScopeForExpression(manager, parentScope, node->first); + BuildScopeForExpression(manager, parentScope, node->second); + } + + void Visit(WfLetExpression* node)override + { + resultScope = new WfLexicalScope(parentScope); + FOREACH(Ptr, variable, node->variables) + { + Ptr symbol = new WfLexicalSymbol(resultScope.Obj()); + symbol->name = variable->name.value; + symbol->creatorNode = node; + resultScope->symbols.Add(symbol->name, symbol); + BuildScopeForExpression(manager, resultScope, variable->value); + } + + BuildScopeForExpression(manager, resultScope, node->expression); + } + + void Visit(WfIfExpression* node)override + { + BuildScopeForExpression(manager, parentScope, node->condition); + BuildScopeForExpression(manager, parentScope, node->trueBranch); + BuildScopeForExpression(manager, parentScope, node->falseBranch); + } + + void Visit(WfRangeExpression* node)override + { + BuildScopeForExpression(manager, parentScope, node->begin); + BuildScopeForExpression(manager, parentScope, node->end); + } + + void Visit(WfSetTestingExpression* node)override + { + BuildScopeForExpression(manager, parentScope, node->element); + BuildScopeForExpression(manager, parentScope, node->collection); + } + + void Visit(WfConstructorExpression* node)override + { + FOREACH(Ptr, argument, node->arguments) + { + BuildScopeForExpression(manager, parentScope, argument->key); + if (argument->value) + { + BuildScopeForExpression(manager, parentScope, argument->value); + } + } + } + + void Visit(WfInferExpression* node)override + { + BuildScopeForExpression(manager, parentScope, node->expression); + } + + void Visit(WfTypeCastingExpression* node)override + { + BuildScopeForExpression(manager, parentScope, node->expression); + } + + void Visit(WfTypeTestingExpression* node)override + { + if (node->expression) + { + BuildScopeForExpression(manager, parentScope, node->expression); + } + } + + void Visit(WfTypeOfTypeExpression* node)override + { + } + + void Visit(WfTypeOfExpressionExpression* node)override + { + BuildScopeForExpression(manager, parentScope, node->expression); + } + + void Visit(WfAttachEventExpression* node)override + { + BuildScopeForExpression(manager, parentScope, node->event); + BuildScopeForExpression(manager, parentScope, node->function); + } + + void Visit(WfDetachEventExpression* node)override + { + BuildScopeForExpression(manager, parentScope, node->event); + BuildScopeForExpression(manager, parentScope, node->handler); + } + + void Visit(WfObserveExpression* node)override + { + BuildScopeForExpression(manager, parentScope, node->parent); + if (node->observeType == WfObserveType::SimpleObserve) + { + BuildScopeForExpression(manager, parentScope, node->expression); + FOREACH(Ptr, event, node->events) + { + BuildScopeForExpression(manager, parentScope, event); + } + } + else + { + resultScope = new WfLexicalScope(parentScope); + { + Ptr symbol = new WfLexicalSymbol(resultScope.Obj()); + symbol->name = node->name.value; + symbol->creatorNode = node; + resultScope->symbols.Add(symbol->name, symbol); + } + + BuildScopeForExpression(manager, resultScope, node->expression); + FOREACH(Ptr, event, node->events) + { + BuildScopeForExpression(manager, resultScope, event); + } + } + } + + void Visit(WfCallExpression* node)override + { + BuildScopeForExpression(manager, parentScope, node->function); + FOREACH(Ptr, argument, node->arguments) + { + BuildScopeForExpression(manager, parentScope, argument); + } + } + + void Visit(WfFunctionExpression* node)override + { + manager->CreateLambdaCapture(node->function.Obj()); + BuildScopeForDeclaration(manager, parentScope, node->function, node); + } + + void Visit(WfNewClassExpression* node)override + { + FOREACH(Ptr, argument, node->arguments) + { + BuildScopeForExpression(manager, parentScope, argument); + } + } + + class CreateLambdaCaptureVisitor + : public empty_visitor::DeclarationVisitor + { + public: + WfLexicalScopeManager* manager; + Ptr capture; + + CreateLambdaCaptureVisitor(WfLexicalScopeManager* _manager, Ptr _capture) + :manager(_manager) + , capture(_capture) + { + } + + void Dispatch(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + + void Visit(WfFunctionDeclaration* node)override + { + manager->CreateLambdaCapture(node, capture); + } + }; + + void Visit(WfNewInterfaceExpression* node)override + { + resultScope = new WfLexicalScope(parentScope); + auto capture = MakePtr(); + manager->CreateLambdaCapture(node, capture); + + CreateLambdaCaptureVisitor visitor(manager, capture); + FOREACH(Ptr, memberDecl, node->declarations) + { + memberDecl->Accept(&visitor); + BuildScopeForDeclaration(manager, resultScope, memberDecl, node); + } + } + + void Visit(WfVirtualExpression* node)override + { + node->Accept((WfVirtualExpression::IVisitor*)this); + if (node->expandedExpression) + { + BuildScopeForExpression(manager, parentScope, node->expandedExpression); + } + } + + void Visit(WfBindExpression* node)override + { + BuildScopeForExpression(manager, parentScope, node->expression); + } + + void Visit(WfFormatExpression* node)override + { + } + + void Visit(WfNewCoroutineExpression* node)override + { + manager->CreateLambdaCapture(node); + + resultScope = new WfLexicalScope(parentScope); + auto config = MakePtr(); + resultScope->functionConfig = config; + + if (node->name.value != L"") + { + Ptr symbol = new WfLexicalSymbol(resultScope.Obj()); + symbol->name = node->name.value; + symbol->creatorNode = node; + symbol->typeInfo = TypeInfoRetriver>::CreateTypeInfo(); + symbol->type = GetTypeFromTypeInfo(symbol->typeInfo.Obj()); + resultScope->symbols.Add(symbol->name, symbol); + } + + config->lambda = true; + config->thisAccessable = false; + config->parentThisAccessable = true; + + BuildScopeForStatement(manager, resultScope, node->statement); + } + + void Visit(WfMixinCastExpression* node)override + { + BuildScopeForExpression(manager, parentScope, node->expression); + } + + void Visit(WfExpectedTypeCastExpression* node)override + { + BuildScopeForExpression(manager, parentScope, node->expression); + } + + static Ptr Execute(WfLexicalScopeManager* manager, Ptr parentScope, Ptr expression) + { + BuildScopeForExpressionVisitor visitor(manager, parentScope); + expression->Accept(&visitor); + if (visitor.resultScope) + { + manager->nodeScopes.Add(expression.Obj(), visitor.resultScope); + visitor.resultScope->ownerNode = expression; + } + else + { + manager->nodeScopes.Add(expression.Obj(), parentScope); + } + return visitor.resultScope; + } + }; + +/*********************************************************************** +BuildScope +***********************************************************************/ + + void BuildScopeForModule(WfLexicalScopeManager* manager, Ptr module) + { + Ptr scope = new WfLexicalScope(manager); + scope->ownerNode = module; + manager->nodeScopes.Add(module.Obj(), scope); + + FOREACH(Ptr, declaration, module->declarations) + { + BuildScopeForDeclaration(manager, scope, declaration, module.Obj()); + } + } + + void BuildScopeForDeclaration(WfLexicalScopeManager* manager, Ptr parentScope, Ptr declaration, parsing::ParsingTreeCustomBase* source) + { + BuildScopeForDeclarationVisitor::Execute(manager, parentScope, source, declaration); + } + + void BuildScopeForStatement(WfLexicalScopeManager* manager, Ptr parentScope, Ptr statement) + { + BuildScopeForStatementVisitor::Execute(manager, parentScope, statement); + } + + void BuildScopeForExpression(WfLexicalScopeManager* manager, Ptr parentScope, Ptr expression) + { + BuildScopeForExpressionVisitor::Execute(manager, parentScope, expression); + } + +/*********************************************************************** +CheckScopes_DuplicatedSymbol +***********************************************************************/ + + bool CheckScopes_DuplicatedSymbol(WfLexicalScopeManager* manager) + { + SortedList analyzedScopes; + vint errorCount = manager->errors.Count(); + FOREACH(Ptr, scope, manager->nodeScopes.Values()) + { + if (!analyzedScopes.Contains(scope.Obj())) + { + analyzedScopes.Add(scope.Obj()); + + for (vint i = 0; i < scope->symbols.Count(); i++) + { + const auto& symbols = scope->symbols.GetByIndex(i); + if (symbols.Count() > 1) + { + if (!scope->ownerNode.Cast() && !scope->ownerNode.Cast()) + { + if (symbols.Count() > 1) + { + FOREACH(Ptr, symbol, From(symbols)) + { + if (auto decl = symbol->creatorNode.Cast()) + { + if (!decl.Cast()) + { + manager->errors.Add(WfErrors::DuplicatedSymbol(decl.Obj(), symbol)); + } + } + else if (auto arg = symbol->creatorNode.Cast()) + { + manager->errors.Add(WfErrors::DuplicatedSymbol(arg.Obj(), symbol)); + } + else if (auto stat = symbol->creatorNode.Cast()) + { + manager->errors.Add(WfErrors::DuplicatedSymbol(stat.Obj(), symbol)); + } + else if (auto expr = symbol->creatorNode.Cast()) + { + manager->errors.Add(WfErrors::DuplicatedSymbol(expr.Obj(), symbol)); + } + } + } + } + } + } + } + } + return errorCount == manager->errors.Count(); + } + } + } +} + + +/*********************************************************************** +.\ANALYZER\WFANALYZER_COMPLETESCOPE.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace analyzer + { + using namespace collections; + using namespace parsing; + using namespace reflection; + using namespace reflection::description; + using namespace typeimpl; + +/*********************************************************************** +CompleteScopeForClassMember +***********************************************************************/ + + class CompleteScopeForClassMemberVisitor : public Object, public WfDeclaration::IVisitor + { + public: + WfLexicalScopeManager* manager; + Ptr td; + Ptr classDecl; + + CompleteScopeForClassMemberVisitor(WfLexicalScopeManager* _manager, Ptr _td, Ptr _classDecl) + :manager(_manager) + , td(_td) + { + } + + void Visit(WfNamespaceDeclaration* node)override + { + } + + void Visit(WfFunctionDeclaration* node)override + { + auto scope = manager->nodeScopes[node]; + auto info = manager->declarationMemberInfos[node].Cast(); + + FOREACH(Ptr, argument, node->arguments) + { + if (auto typeInfo = CreateTypeInfoFromType(scope.Obj(), argument->type)) + { + auto paramInfo = MakePtr(info.Obj(), argument->name.value, typeInfo); + info->AddParameter(paramInfo); + } + } + + if (auto typeInfo = CreateTypeInfoFromType(scope.Obj(), node->returnType)) + { + info->SetReturn(typeInfo); + } + } + + void Visit(WfVariableDeclaration* node)override + { + auto scope = manager->nodeScopes[node]; + if (auto typeInfo = CreateTypeInfoFromType(scope.Obj(), node->type)) + { + auto info = manager->declarationMemberInfos[node].Cast(); + info->SetReturn(typeInfo); + } + } + + void Visit(WfEventDeclaration* node)override + { + auto scope = manager->nodeScopes[node]; + auto type = MakePtr(); + { + auto voidType = MakePtr(); + voidType->name = WfPredefinedTypeName::Void; + type->result = voidType; + } + FOREACH(Ptr, argument, node->arguments) + { + type->arguments.Add(argument); + } + + if (auto typeInfo = CreateTypeInfoFromType(scope.Obj(), type)) + { + auto info = manager->declarationMemberInfos[node].Cast(); + info->SetHandlerType(typeInfo); + } + } + + void Visit(WfPropertyDeclaration* node)override + { + auto scope = manager->nodeScopes[node]; + auto info = manager->declarationMemberInfos[node].Cast(); + + if (node->getter.value != L"") + { + info->SetGetter(dynamic_cast(td->GetMethodGroupByName(node->getter.value, false)->GetMethod(0))); + } + + if (node->setter.value != L"") + { + info->SetSetter(dynamic_cast(td->GetMethodGroupByName(node->setter.value, false)->GetMethod(0))); + } + + if (node->valueChangedEvent.value != L"") + { + info->SetValueChangedEvent(dynamic_cast(td->GetEventByName(node->valueChangedEvent.value, false))); + } + } + + void Visit(WfConstructorDeclaration* node)override + { + auto scope = manager->nodeScopes[node]; + auto info = manager->declarationMemberInfos[node].Cast(); + + FOREACH(Ptr, argument, node->arguments) + { + if (auto typeInfo = CreateTypeInfoFromType(scope.Obj(), argument->type)) + { + auto paramInfo = MakePtr(info.Obj(), argument->name.value, typeInfo); + info->AddParameter(paramInfo); + } + } + } + + void Visit(WfDestructorDeclaration* node)override + { + } + + void Visit(WfClassDeclaration* node)override + { + CompleteScopeForDeclaration(manager, node); + } + + void Visit(WfEnumDeclaration* node)override + { + CompleteScopeForDeclaration(manager, node); + } + + void Visit(WfStructDeclaration* node)override + { + CompleteScopeForDeclaration(manager, node); + } + + void Visit(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + + static void Execute(WfLexicalScopeManager* manager, Ptr td, Ptr classDecl, Ptr memberDecl) + { + CompleteScopeForClassMemberVisitor visitor(manager, td, classDecl); + memberDecl->Accept(&visitor); + } + }; + +/*********************************************************************** +CompleteScopeForDeclaration +***********************************************************************/ + + class CompleteScopeForDeclarationVisitor : public Object, public WfDeclaration::IVisitor + { + public: + WfLexicalScopeManager* manager; + Ptr declaration; + + CompleteScopeForDeclarationVisitor(WfLexicalScopeManager* _manager, Ptr _declaration) + :manager(_manager) + , declaration(_declaration) + { + } + + void Visit(WfNamespaceDeclaration* node)override + { + FOREACH(Ptr, decl, node->declarations) + { + CompleteScopeForDeclaration(manager, decl); + } + } + + void Visit(WfFunctionDeclaration* node)override + { + } + + void Visit(WfVariableDeclaration* node)override + { + } + + void Visit(WfEventDeclaration* node)override + { + } + + void Visit(WfPropertyDeclaration* node)override + { + } + + void Visit(WfConstructorDeclaration* node)override + { + } + + void Visit(WfDestructorDeclaration* node)override + { + } + + void Visit(WfClassDeclaration* node)override + { + auto scope = manager->nodeScopes[node]; + auto td = manager->declarationTypes[node].Cast(); + + if (node->baseTypes.Count() > 0) + { + FOREACH(Ptr, baseType, node->baseTypes) + { + if (auto scopeName = GetScopeNameFromReferenceType(scope->parentScope.Obj(), baseType)) + { + if (scopeName->typeDescriptor) + { + td->AddBaseType(scopeName->typeDescriptor); + } + } + } + } + else if (node->kind == WfClassKind::Class) + { + td->AddBaseType(description::GetTypeDescriptor()); + } + else if (node->kind == WfClassKind::Interface) + { + td->AddBaseType(description::GetTypeDescriptor()); + } + + if (node->kind == WfClassKind::Interface) + { + switch (node->constructorType) + { + case WfConstructorType::SharedPtr: + { + auto elementType = MakePtr(td.Obj(), TypeInfoHint::Normal); + auto pointerType = MakePtr(elementType); + + auto ctor = MakePtr(pointerType); + td->AddMember(ctor); + } + break; + case WfConstructorType::RawPtr: + { + auto elementType = MakePtr(td.Obj(), TypeInfoHint::Normal); + auto pointerType = MakePtr(elementType); + + auto ctor = MakePtr(pointerType); + td->AddMember(ctor); + } + break; + default:; + } + } + + FOREACH(Ptr, memberDecl, node->declarations) + { + CompleteScopeForClassMember(manager, td, node, memberDecl); + } + } + + void Visit(WfEnumDeclaration* node)override + { + auto td = manager->declarationTypes[node].Cast(); + Dictionary items; + FOREACH(Ptr, item, node->items) + { + vuint64_t value = 0; + switch (item->kind) + { + case WfEnumItemKind::Constant: + TypedValueSerializerProvider::Deserialize(item->number.value, value); + break; + case WfEnumItemKind::Intersection: + FOREACH(Ptr, itemInt, item->intersections) + { + value |= items[itemInt->name.value]; + } + break; + } + td->AddEnumItem(item->name.value, value); + items.Add(item->name.value, value); + } + } + + void Visit(WfStructDeclaration* node)override + { + auto scope = manager->nodeScopes[node]; + auto td = manager->declarationTypes[node].Cast(); + FOREACH(Ptr, member, node->members) + { + if (auto typeInfo = CreateTypeInfoFromType(scope.Obj(), member->type)) + { + auto field = MakePtr(td.Obj(), member->name.value); + field->SetReturn(typeInfo); + td->AddMember(field); + } + } + } + + void Visit(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + + static void Execute(WfLexicalScopeManager* manager, Ptr declaration) + { + CompleteScopeForDeclarationVisitor visitor(manager, declaration); + declaration->Accept(&visitor); + } + }; + +/*********************************************************************** +CheckBaseClass +***********************************************************************/ + + class CheckBaseClassDeclarationVisitor : public empty_visitor::DeclarationVisitor + { + public: + WfLexicalScopeManager* manager; + SortedList checkedInterfaces; + SortedList traversedInterfaces; + + CheckBaseClassDeclarationVisitor(WfLexicalScopeManager* _manager) + :manager(_manager) + { + } + + void Dispatch(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + + void Visit(WfNamespaceDeclaration* node)override + { + FOREACH(Ptr, decl, node->declarations) + { + decl->Accept(this); + } + } + + void CheckDuplicatedBaseClass(WfClassDeclaration* node, ITypeDescriptor* td) + { + List baseTypes; + SortedList duplicatedTypes; + baseTypes.Add(td); + + for (vint i = 0; i < baseTypes.Count(); i++) + { + auto currentTd = baseTypes[i]; + vint count = currentTd->GetBaseTypeDescriptorCount(); + for (vint j = 0; j < count; j++) + { + auto baseTd = currentTd->GetBaseTypeDescriptor(j); + if (baseTd->GetTypeDescriptorFlags() == TypeDescriptorFlags::Class && baseTd != description::GetTypeDescriptor()) + { + if (baseTypes.Contains(baseTd)) + { + if (!duplicatedTypes.Contains(baseTd)) + { + duplicatedTypes.Add(baseTd); + manager->errors.Add(WfErrors::DuplicatedBaseClass(node, baseTd)); + } + } + else + { + baseTypes.Add(baseTd); + } + } + } + } + } + + void CheckDuplicatedBaseInterface(WfClassDeclaration* node, ITypeDescriptor* td) + { + if (traversedInterfaces.Contains(td)) + { + manager->errors.Add(WfErrors::DuplicatedBaseInterface(node, td)); + } + else + { + if (checkedInterfaces.Contains(td)) + { + return; + } + checkedInterfaces.Add(td); + + vint index = traversedInterfaces.Add(td); + vint count = td->GetBaseTypeDescriptorCount(); + for (vint i = 0; i < count; i++) + { + CheckDuplicatedBaseInterface(node, td->GetBaseTypeDescriptor(i)); + } + traversedInterfaces.RemoveAt(index); + } + } + + void Visit(WfClassDeclaration* node)override + { + auto scope = manager->nodeScopes[node]; + auto td = manager->declarationTypes[node].Obj(); + + FOREACH(Ptr, baseType, node->baseTypes) + { + if (auto scopeName = GetScopeNameFromReferenceType(scope->parentScope.Obj(), baseType)) + { + if (auto baseTd = scopeName->typeDescriptor) + { + bool isClass = baseTd->GetTypeDescriptorFlags() == TypeDescriptorFlags::Class; + bool isInterface = baseTd->GetTypeDescriptorFlags() == TypeDescriptorFlags::Interface; + + switch (node->kind) + { + case WfClassKind::Class: + { + if (!isClass || !baseTd->IsAggregatable()) + { + if (!dynamic_cast(baseTd)) + { + manager->errors.Add(WfErrors::WrongBaseTypeOfClass(node, baseTd)); + } + } + } + break; + case WfClassKind::Interface: + { + if (!isInterface) + { + manager->errors.Add(WfErrors::WrongBaseTypeOfInterface(node, baseTd)); + } + } + break; + } + } + } + } + + if (node->kind == WfClassKind::Class) + { + CheckDuplicatedBaseClass(node, td); + } + else + { + CheckDuplicatedBaseInterface(node, td); + } + + FOREACH(Ptr, memberDecl, node->declarations) + { + memberDecl->Accept(this); + } + } + + void Visit(WfEnumDeclaration* node)override + { + } + + void Visit(WfStructDeclaration* node)override + { + } + + static void Execute(WfLexicalScopeManager* manager, Ptr declaration) + { + CompleteScopeForDeclarationVisitor visitor(manager, declaration); + declaration->Accept(&visitor); + } + }; + +/*********************************************************************** +CompleteScope +***********************************************************************/ + + void CompleteScopeForClassMember(WfLexicalScopeManager* manager, Ptr td, Ptr classDecl, Ptr memberDecl) + { + CompleteScopeForClassMemberVisitor::Execute(manager, td, classDecl, memberDecl); + } + + void CompleteScopeForDeclaration(WfLexicalScopeManager* manager, Ptr declaration) + { + CompleteScopeForDeclarationVisitor::Execute(manager, declaration); + } + + void CompleteScopeForModule(WfLexicalScopeManager* manager, Ptr module) + { + FOREACH(Ptr, declaration, module->declarations) + { + CompleteScopeForDeclaration(manager, declaration); + } + } + +/*********************************************************************** +CheckScopes_SymbolType +***********************************************************************/ + + bool CheckScopes_SymbolType(WfLexicalScopeManager* manager) + { + SortedList analyzedScopes; + vint errorCount = manager->errors.Count(); + FOREACH(Ptr, scope, manager->nodeScopes.Values()) + { + if (!analyzedScopes.Contains(scope.Obj())) + { + analyzedScopes.Add(scope.Obj()); + + for (vint i = 0; i < scope->symbols.Count(); i++) + { + FOREACH(Ptr, symbol, scope->symbols.GetByIndex(i)) + { + if (symbol->type) + { + vint currentErrorCount = manager->errors.Count(); + symbol->typeInfo = CreateTypeInfoFromType(scope.Obj(), symbol->type); + if (symbol->creatorNode) + { + for (vint i = currentErrorCount; i < manager->errors.Count(); i++) + { + manager->errors[i]->parsingTree = symbol->creatorNode.Obj(); + } + } + } + } + } + } + } + return errorCount == manager->errors.Count(); + } + +/*********************************************************************** +CheckScopes_BaseType +***********************************************************************/ + + bool CheckScopes_BaseType(WfLexicalScopeManager* manager) + { + vint errorCount = manager->errors.Count(); + CheckBaseClassDeclarationVisitor visitor(manager); + FOREACH(Ptr, module, manager->GetModules()) + { + FOREACH(Ptr, declaration, module->declarations) + { + declaration->Accept(&visitor); + } + } + return errorCount == manager->errors.Count(); + } + } + } +} + +/*********************************************************************** +.\ANALYZER\WFANALYZER_CONTEXTFREEDESUGAR.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace analyzer + { + using namespace collections; + using namespace parsing; + using namespace reflection::description; + +/*********************************************************************** +SetCodeRange +***********************************************************************/ + + class SetCodeRangeVisitor : public traverse_visitor::ModuleVisitor + { + public: + ParsingTextRange range; + + SetCodeRangeVisitor(ParsingTextRange _range) + :range(_range) + { + } + + void Traverse(ParsingTreeCustomBase* node)override + { + if (node->codeRange == ParsingTextRange()) + { + node->codeRange = range; + } + } + + void Traverse(ParsingToken& token)override + { + if (token.codeRange == ParsingTextRange()) + { + token.codeRange = range; + } + } + }; + + void SetCodeRange(Ptr node, parsing::ParsingTextRange codeRange) + { + SetCodeRangeVisitor(codeRange).VisitField(node.Obj()); + } + + void SetCodeRange(Ptr node, parsing::ParsingTextRange codeRange) + { + SetCodeRangeVisitor(codeRange).VisitField(node.Obj()); + } + + void SetCodeRange(Ptr node, parsing::ParsingTextRange codeRange) + { + SetCodeRangeVisitor(codeRange).VisitField(node.Obj()); + } + + void SetCodeRange(Ptr node, parsing::ParsingTextRange codeRange) + { + SetCodeRangeVisitor(codeRange).VisitField(node.Obj()); + } + + void SetCodeRange(Ptr node, parsing::ParsingTextRange codeRange) + { + SetCodeRangeVisitor(codeRange).VisitField(node.Obj()); + } + +/*********************************************************************** +ContextFreeModuleDesugar +***********************************************************************/ + + class ContextFreeDesugarVisitor : public traverse_visitor::ModuleVisitor + { + public: + WfLexicalScopeManager* manager; + WfClassDeclaration* surroundingClassDecl = nullptr; + WfNewInterfaceExpression* surroundingLambda = nullptr; + + ContextFreeDesugarVisitor(WfLexicalScopeManager* _manager) + :manager(_manager) + { + } + + void Traverse(WfFormatExpression* node)override + { + if (node->expandedExpression) + { + return; + } + + List> expressions; + const wchar_t* reading = node->value.value.Buffer(); + + while (*reading) + { + const wchar_t* begin = wcsstr(reading, L"$("); + if (begin) + { + Ptr expression = new WfStringExpression; + expression->codeRange = node->codeRange; + expression->value.value = WString(reading, vint(begin - reading)); + expressions.Add(expression); + } + else + { + break; + } + + const wchar_t* end = begin + 2; + vint counter = 1; + while (wchar_t c = *end++) + { + switch (c) + { + case L'(': + counter++; + break; + case L')': + counter--; + break; + } + if (counter == 0) + { + break; + } + } + + if (counter != 0) + { + auto error = WfErrors::WrongFormatStringSyntax(node); + error->errorMessage += L" (Does not find matched close bracket.)"; + manager->errors.Add(error); + return; + } + else + { + WString input(begin + 2, vint(end - begin - 3)); + List> errors; + if (auto expression = WfParseExpression(input, manager->parsingTable, errors)) + { + expressions.Add(expression); + } + FOREACH(Ptr, originalError, errors) + { + auto error = WfErrors::WrongFormatStringSyntax(node); + error->errorMessage += L" (" + originalError->errorMessage + L")"; + manager->errors.Add(error); + } + reading = end; + } + } + if (*reading || expressions.Count() == 0) + { + Ptr expression = new WfStringExpression; + expression->codeRange = node->codeRange; + expression->value.value = reading; + expressions.Add(expression); + } + + if (expressions.Count() > 0) + { + Ptr current = expressions[0]; + FOREACH(Ptr, expression, From(expressions).Skip(1)) + { + Ptr binary = new WfBinaryExpression; + binary->codeRange = node->codeRange; + binary->first = current; + binary->second = expression; + binary->op = WfBinaryOperator::Union; + current = binary; + } + + node->expandedExpression = current; + SetCodeRange(node->expandedExpression, node->codeRange); + } + } + + void Traverse(WfAutoPropertyDeclaration* node)override + { + if (node->expandedDeclarations.Count() > 0) + { + return; + } + + bool needVariable = false; + bool needVirtual = false; + bool needEvent = false; + bool needProperty = false; + + if (surroundingClassDecl) + { + switch (surroundingClassDecl->kind) + { + case WfClassKind::Class: + { + needVariable = true; + needVirtual = false; + needEvent = node->configObserve == WfAPObserve::Observable; + needProperty = true; + } + break; + case WfClassKind::Interface: + { + needVariable = false; + needVirtual = true; + needEvent = node->configObserve == WfAPObserve::Observable; + needProperty = true; + } + break; + } + } + else if (surroundingLambda) + { + needVariable = true; + needVirtual = false; + needEvent = false; + needProperty = false; + } + + auto varName = L"" + node->name.value; + auto getterName = L"Get" + node->name.value; + auto setterName = L"Set" + node->name.value; + auto eventName = node->name.value + L"Changed"; + + if (needVariable && node->expression) + { + auto decl = MakePtr(); + node->expandedDeclarations.Add(decl); + + decl->name.value = varName; + decl->type = CopyType(node->type); + decl->expression = CopyExpression(node->expression); + + auto att = MakePtr(); + att->category.value = L"cpp"; + att->name.value = L"Private"; + decl->attributes.Add(att); + } + + { + auto decl = MakePtr(); + node->expandedDeclarations.Add(decl); + + decl->anonymity = WfFunctionAnonymity::Named; + decl->name.value = getterName; + decl->returnType = CopyType(node->type); + + if (!needVirtual) + { + auto refExpr = MakePtr(); + refExpr->name.value = varName; + + auto returnStat = MakePtr(); + returnStat->expression = refExpr; + + auto block = MakePtr(); + block->statements.Add(returnStat); + decl->statement = block; + } + } + + if (!needVirtual || node->configConst == WfAPConst::Writable) + { + auto decl = MakePtr(); + node->expandedDeclarations.Add(decl); + + decl->anonymity = WfFunctionAnonymity::Named; + decl->name.value = setterName; + + if (node->configConst == WfAPConst::Readonly) + { + auto att = MakePtr(); + att->category.value = L"cpp"; + att->name.value = L"Protected"; + decl->attributes.Add(att); + } + + { + auto argument = MakePtr(); + argument->name.value = L""; + argument->type = CopyType(node->type); + decl->arguments.Add(argument); + } + { + auto voidType = MakePtr(); + voidType->name = WfPredefinedTypeName::Void; + decl->returnType = voidType; + } + + if (!needVirtual) + { + auto block = MakePtr(); + decl->statement = block; + + auto createBinaryExpr = [&](WfBinaryOperator op) + { + auto refArgument = MakePtr(); + refArgument->name.value = L""; + + auto refVar = MakePtr(); + refVar->name.value = varName; + + auto binaryExpr = MakePtr(); + binaryExpr->first = refVar; + binaryExpr->second = refArgument; + binaryExpr->op = op; + + return binaryExpr; + }; + + if (node->configObserve == WfAPObserve::Observable) + { + auto ifStat = MakePtr(); + ifStat->expression = createBinaryExpr(WfBinaryOperator::NE); + + auto trueBlock = MakePtr(); + ifStat->trueBranch = trueBlock; + + { + auto stat = MakePtr(); + stat->expression = createBinaryExpr(WfBinaryOperator::Assign); + trueBlock->statements.Add(stat); + } + { + auto refEvent = MakePtr(); + refEvent->name.value = eventName; + + auto callExpr = MakePtr(); + callExpr->function = refEvent; + + auto stat = MakePtr(); + stat->expression = callExpr; + trueBlock->statements.Add(stat); + } + + block->statements.Add(ifStat); + } + else + { + auto stat = MakePtr(); + stat->expression = createBinaryExpr(WfBinaryOperator::Assign); + + block->statements.Add(stat); + } + } + } + + if (needEvent) + { + auto decl = MakePtr(); + node->expandedDeclarations.Add(decl); + + decl->name.value = eventName; + } + + if (needProperty) + { + auto decl = MakePtr(); + node->expandedDeclarations.Add(decl); + + decl->type = CopyType(node->type); + decl->name.value = node->name.value; + decl->getter.value = getterName; + if (node->configConst == WfAPConst::Writable) + { + decl->setter.value = setterName; + } + if (node->configObserve == WfAPObserve::Observable) + { + decl->valueChangedEvent.value = eventName; + } + } + + FOREACH(Ptr, decl, node->expandedDeclarations) + { + auto classMember = MakePtr(); + decl->classMember = classMember; + + classMember->kind = WfClassMemberKind::Normal; + if (surroundingLambda) + { + if (decl->name.value == getterName) + { + classMember->kind = WfClassMemberKind::Override; + } + else if (decl->name.value == setterName) + { + if (node->configConst == WfAPConst::Writable) + { + classMember->kind = WfClassMemberKind::Override; + } + } + } + + SetCodeRange(decl, node->codeRange); + } + } + + void Traverse(WfCastResultInterfaceDeclaration* node)override + { + if (node->expandedDeclarations.Count() > 0) + { + return; + } + + auto decl = MakePtr(); + node->expandedDeclarations.Add(decl); + decl->kind = WfClassKind::Interface; + decl->constructorType = WfConstructorType::SharedPtr; + decl->name.value = node->name.value; + decl->baseTypes.Add(CopyType(node->baseType)); + + auto funcDecl = MakePtr(); + decl->declarations.Add(funcDecl); + { + funcDecl->classMember = MakePtr(); + funcDecl->classMember->kind = WfClassMemberKind::Static; + } + funcDecl->anonymity = WfFunctionAnonymity::Named; + funcDecl->name.value = L"CastResult"; + funcDecl->returnType = CopyType(node->elementType); + { + auto argument = MakePtr(); + funcDecl->arguments.Add(argument); + argument->name.value = L"value"; + argument->type = GetTypeFromTypeInfo(TypeInfoRetriver::CreateTypeInfo().Obj()); + } + { + auto block = MakePtr(); + funcDecl->statement = block; + + auto refValue = MakePtr(); + refValue->name.value = L"value"; + + auto castExpr = MakePtr(); + castExpr->strategy = WfTypeCastingStrategy::Strong; + castExpr->type = CopyType(node->elementType); + castExpr->expression = refValue; + + auto stat = MakePtr(); + stat->expression = castExpr; + + block->statements.Add(stat); + } + + SetCodeRange(Ptr(decl), node->codeRange); + } + +#define PUSH_SURROUNDING\ + auto o1 = surroundingClassDecl;\ + auto o2 = surroundingLambda;\ + surroundingClassDecl = nullptr;\ + surroundingLambda = nullptr;\ + +#define POP_SURROUNDING\ + surroundingClassDecl = o1;\ + surroundingLambda = o2;\ + + void Visit(WfClassDeclaration* node)override + { + PUSH_SURROUNDING + surroundingClassDecl = node; + traverse_visitor::DeclarationVisitor::Visit(node); + POP_SURROUNDING + } + + void Visit(WfNewInterfaceExpression* node)override + { + PUSH_SURROUNDING + surroundingLambda = node; + traverse_visitor::ExpressionVisitor::Visit(node); + POP_SURROUNDING + } + +#undef PUSH_SURROUNDING +#undef POP_SURROUNDING + }; + + void ContextFreeModuleDesugar(WfLexicalScopeManager* manager, Ptr module) + { + ContextFreeDesugarVisitor(manager).VisitField(module.Obj()); + } + + void ContextFreeDeclarationDesugar(WfLexicalScopeManager* manager, Ptr declaration) + { + ContextFreeDesugarVisitor(manager).VisitField(declaration.Obj()); + } + + void ContextFreeStatementDesugar(WfLexicalScopeManager* manager, Ptr statement) + { + ContextFreeDesugarVisitor(manager).VisitField(statement.Obj()); + } + + void ContextFreeExpressionDesugar(WfLexicalScopeManager* manager, Ptr expression) + { + ContextFreeDesugarVisitor(manager).VisitField(expression.Obj()); + } + } + } +} + +/*********************************************************************** +.\ANALYZER\WFANALYZER_ERRORS.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace analyzer + { + using namespace collections; + using namespace parsing; + using namespace reflection; + using namespace reflection::description; + +/*********************************************************************** +WfErrors +***********************************************************************/ + + Ptr WfErrors::WrongFormatStringSyntax(WfExpression* node) + { + return new ParsingError(node, L"A0: Wrong format string syntax."); + } + + Ptr WfErrors::WrongSimpleObserveExpression(WfExpression* node) + { + return new ParsingError(node, L"A1: Simple observe expression should observe a property under the observed object."); + } + + Ptr WfErrors::WrongSimpleObserveEvent(WfExpression* node) + { + return new ParsingError(node, L"A2: Simple observe expression should react to an event under the observed object."); + } + + Ptr WfErrors::EmptyObserveEvent(WfExpression* node) + { + return new ParsingError(node, L"A2: Observe expression should react to at least one event."); + } + + Ptr WfErrors::ObserveNotInBind(WfExpression* node) + { + return new ParsingError(node, L"A3: Observe expression should appear in a bind expression."); + } + + Ptr WfErrors::ObserveInObserveEvent(WfExpression* node) + { + return new ParsingError(node, L"A4: Observe expression should not appear in the event expression in another observe expression."); + } + + Ptr WfErrors::BindInBind(WfExpression* node) + { + return new ParsingError(node, L"A4: Bind expression should not appear in another bind expression."); + } + + Ptr WfErrors::AttachInBind(WfExpression* node) + { + return new ParsingError(node, L"A4: Attach expression should not appear in another bind expression."); + } + + Ptr WfErrors::DetachInBind(WfExpression* node) + { + return new ParsingError(node, L"A4: Detach expression should not appear in another bind expression."); + } + + Ptr WfErrors::ConstructorMixMapAndList(WfExpression* node) + { + return new ParsingError(node, L"A5: Key-value pairs are not allowed in list constructor expression."); + } + + Ptr WfErrors::ConstructorMixStructAndList(WfExpression* node) + { + return new ParsingError(node, L"A5: Field-value pairs are expected in struct constructor expression."); + } + + Ptr WfErrors::DuplicatedConstructorField(WfReferenceExpression* node) + { + return new ParsingError(node, L"A5: The same field cannot be assigned more than once in struct constructor expression."); + } + + Ptr WfErrors::ConstructorMixClassAndInterface(WfNewClassExpression* node) + { + return new ParsingError(node, L"A6: Arguments are not allowed in new interface expression."); + } + + Ptr WfErrors::ConstructorMixClassAndInterface(WfNewInterfaceExpression* node) + { + return new ParsingError(node, L"A6: Members are not allowed in new class expression."); + } + + Ptr WfErrors::ScopeNameIsNotExpression(WfExpression* node, Ptr scopeName) + { + return new ParsingError(node, L"A7: Symbol \"" + scopeName->GetFriendlyName() + L"\" cannot be used as an expression."); + } + + Ptr WfErrors::EventIsNotExpression(WfExpression* node, reflection::description::IEventInfo* eventInfo) + { + return new ParsingError(node, L"A7: Event \"" + eventInfo->GetName() + L"\" of type \"" + eventInfo->GetOwnerTypeDescriptor()->GetTypeName() + L"\" cannot be used as an expression."); + } + + Ptr WfErrors::ExpressionIsNotScopeName(WfExpression* node) + { + return new ParsingError(node, L"A8: Expression does not reference to a declaration."); + } + + Ptr WfErrors::ExpressionIsNotEvent(WfExpression* node) + { + return new ParsingError(node, L"A8: Expression does not reference to an event."); + } + + Ptr WfErrors::ExpressionCannotResolveType(WfExpression* node, Ptr symbol) + { + return new ParsingError(node, L"A9: Expression referencing to symbol \"" + symbol->name + L"\" failed to resolve its type."); + } + + Ptr WfErrors::NullCannotResolveType(WfExpression* node) + { + return new ParsingError(node, L"A9: Expression \"null\" failed to resolve its type."); + } + + Ptr WfErrors::ConstructorCannotResolveType(WfExpression* node) + { + return new ParsingError(node, L"A9: Expression \"{}\" failed to resolve its type."); + } + + Ptr WfErrors::OrderedLambdaCannotResolveType(WfExpression* node) + { + return new ParsingError(node, L"A9: Ordered lambda expression failed to resolve its type."); + } + + Ptr WfErrors::NullCannotImplicitlyConvertToType(WfExpression* node, reflection::description::ITypeInfo* toType) + { + return new ParsingError(node, L"A10: Expression \"null\" cannot implicitly convert to \"" + toType->GetTypeFriendlyName() + L"\"."); + } + + Ptr WfErrors::ConstructorCannotImplicitlyConvertToType(WfExpression* node, reflection::description::ITypeInfo* toType) + { + return new ParsingError(node, L"A10: Expression \"{}\" cannot implicitly convert to \"" + toType->GetTypeFriendlyName() + L"\"."); + } + + Ptr WfErrors::OrderedLambdaCannotImplicitlyConvertToType(WfExpression* node, reflection::description::ITypeInfo* toType) + { + return new ParsingError(node, L"A10: Ordered lambda expression cannot implicitly convert to \"" + toType->GetTypeFriendlyName() + L"\"."); + } + + Ptr WfErrors::ExpressionCannotImplicitlyConvertToType(WfExpression* node, reflection::description::ITypeInfo* fromType, reflection::description::ITypeInfo* toType) + { + return new ParsingError(node, L"A10: Expression of type \"" + fromType->GetTypeFriendlyName() + L"\" cannot implicitly convert to \"" + toType->GetTypeFriendlyName() + L"\"."); + } + + Ptr WfErrors::ExpressionCannotExplicitlyConvertToType(WfExpression* node, reflection::description::ITypeInfo* fromType, reflection::description::ITypeInfo* toType) + { + return new ParsingError(node, L"A11: Expression of type \"" + fromType->GetTypeFriendlyName() + L"\" cannot explicitly convert to \"" + toType->GetTypeFriendlyName() + L"\"."); + } + + Ptr WfErrors::CannotWeakCastToType(WfExpression* node, reflection::description::ITypeInfo* toType) + { + return new ParsingError(node, L"A12: Expression cannot weakly cast to \"" + toType->GetTypeFriendlyName() + L"\" because it cannot be \"null\"."); + } + + Ptr WfErrors::IntegerLiteralOutOfRange(WfIntegerExpression* node) + { + return new ParsingError(node, L"A13: Integer literal \"" + node->value.value + L"\" out of range."); + } + + Ptr WfErrors::FloatingLiteralOutOfRange(WfFloatingExpression* node) + { + return new ParsingError(node, L"A13: Floating literal \"" + node->value.value + L"\" out of range."); + } + + Ptr WfErrors::CannotMergeTwoType(WfExpression* node, reflection::description::ITypeInfo* firstType, reflection::description::ITypeInfo* secondType) + { + return new ParsingError(node, L"A14: Failed to merge type \"" + firstType->GetTypeFriendlyName() + L"\" with type \"" + secondType->GetTypeFriendlyName() + L"\" together to calculate the result type."); + } + + Ptr WfErrors::RangeShouldBeInteger(WfExpression* node, reflection::description::ITypeInfo* type) + { + return new ParsingError(node, L"A15: Elements in a range expression should be integer, not \"" + type->GetTypeFriendlyName() + L"\"."); + } + + Ptr WfErrors::UnaryOperatorOnWrongType(WfUnaryExpression* node, reflection::description::ITypeInfo* type) + { + return new ParsingError(node, L"A16: Unary operator cannot apply on expression of type \"" + type->GetTypeFriendlyName() + L"\"."); + } + + Ptr WfErrors::BinaryOperatorOnWrongType(WfBinaryExpression* node, reflection::description::ITypeInfo* type) + { + return new ParsingError(node, L"A16: Binary operator cannot apply on expression of type \"" + type->GetTypeFriendlyName() + L"\"."); + } + + Ptr WfErrors::IndexOperatorOnWrongType(WfBinaryExpression* node, reflection::description::ITypeInfo* containerType) + { + return new ParsingError(node, L"A17: Container of type \"" + containerType->GetTypeFriendlyName() + L"\" cannot be accessed using index."); + } + + Ptr WfErrors::ExpressionIsNotCollection(WfExpression* node, reflection::description::ITypeInfo* type) + { + return new ParsingError(node, L"A18: Expression of type \"" + type->GetTypeFriendlyName() + L"\" is not an enumerable type."); + } + + Ptr WfErrors::ExpressionIsNotFunction(WfExpression* node, reflection::description::ITypeInfo* type) + { + return new ParsingError(node, L"A19: Expression of type \"" + type->GetTypeFriendlyName() + L"\" is not an invokable function type."); + } + + Ptr WfErrors::FunctionArgumentCountMismatched(parsing::ParsingTreeCustomBase* node, vint expectedCount, const ResolveExpressionResult& function) + { + return new ParsingError(node, L"A20: Function " + function.GetFriendlyName() + L"\" is not allowed to call with " + itow(expectedCount) + L" arguments."); + } + + Ptr WfErrors::FunctionArgumentTypeMismatched(parsing::ParsingTreeCustomBase* node, const ResolveExpressionResult& function, vint index, reflection::description::ITypeInfo* fromType, reflection::description::ITypeInfo* toType) + { + return new ParsingError(node, L"A21: The " + itow(index) + L"-th argument of function " + function.GetFriendlyName() + L" cannot implicitly convert from \"" + fromType->GetTypeFriendlyName() + L"\" to \"" + toType->GetTypeFriendlyName() + L"\"."); + } + + Ptr WfErrors::CannotPickOverloadedFunctions(parsing::ParsingTreeCustomBase* node, collections::List& results) + { + WString description; + FOREACH_INDEXER(ResolveExpressionResult, result, index, results) + { + description += L"\r\n\t"; + description += result.GetFriendlyName(); + } + return new ParsingError(node, L"A22: Cannot decide which function to call in multiple targets: " + description + L"."); + } + + Ptr WfErrors::ClassContainsNoConstructor(WfExpression* node, reflection::description::ITypeInfo* type) + { + return new ParsingError(node, L"A23: Class \"" + type->GetTypeFriendlyName() + L"\" does not contain any constructor."); + } + + Ptr WfErrors::InterfaceContainsNoConstructor(WfExpression* node, reflection::description::ITypeInfo* type) + { + Ptr proxy = TypeInfoRetriver>::CreateTypeInfo(); + return new ParsingError(node, L"A23: Interface \"" + type->GetTypeFriendlyName() + L"\" does not contain any constructor receiving an \"" + proxy->GetTypeFriendlyName() + L"\"."); + } + + Ptr WfErrors::ConstructorReturnTypeMismatched(WfExpression* node, const ResolveExpressionResult& function, reflection::description::ITypeInfo* fromType, reflection::description::ITypeInfo* toType) + { + return new ParsingError(node, L"A24: The return type of " + function.GetFriendlyName() + L" cannot implicitly convert from \"" + fromType->GetTypeFriendlyName() + L"\" to \"" + toType->GetTypeFriendlyName() + L"\"."); + } + + Ptr WfErrors::ExpressionIsNotLeftValue(WfExpression* node, const ResolveExpressionResult& result) + { + return new ParsingError(node, L"A25: " + result.GetFriendlyName(true) + L" is not assignable."); + } + + Ptr WfErrors::CannotCallMemberOutsideOfClass(WfExpression* node, const ResolveExpressionResult& result) + { + return new ParsingError(node, L"A26: " + result.GetFriendlyName(true) + L" cannot be called as a static member."); + } + + Ptr WfErrors::CannotCallMemberInStaticFunction(WfExpression* node, const ResolveExpressionResult& result) + { + return new ParsingError(node, L"A27: " + result.GetFriendlyName(true) + L" cannot be called in static functions of its class or interface."); + } + + Ptr WfErrors::FieldCannotInitializeUsingEachOther(WfExpression* node, const ResolveExpressionResult& result) + { + return new ParsingError(node, L"A28: " + result.GetFriendlyName(true) + L" cannot be used to initialize other fields in the same type or new interface expression."); + } + + Ptr WfErrors::WrongThisExpression(WfExpression* node) + { + return new ParsingError(node, L"A29: The \"this\" expression can only be used in class methods or functions in new interface expressions"); + } + + Ptr WfErrors::IncorrectTypeForUnion(WfExpression* node, reflection::description::ITypeInfo* type) + { + return new ParsingError(node, L"A30: Expression of type \"" + type->GetTypeFriendlyName() + L"\" cannot be used in union (&) expression because it is not string or flag enum."); + } + + Ptr WfErrors::IncorrectTypeForIntersect(WfExpression* node, reflection::description::ITypeInfo* type) + { + return new ParsingError(node, L"A30: Expression of type \"" + type->GetTypeFriendlyName() + L"\" cannot be used in intersect (|) expression because it is not flag enum."); + } + + Ptr WfErrors::ExpressionIsNotConstant(WfExpression* node) + { + return new ParsingError(node, L"A31: Expression is not constant. A constant expression consists of:\r\n" + L"\tconstant primitive values\r\n" + L"\tenum items\r\n" + L"\tconstant unary (+, -, not) expressions\r\n" + L"\tconstant binary (|) expressions\r\n" + L"\tconstant range expressions\r\n" + L"\tconstant constructor expressions (to create values of structs, lists or dictionarys)\r\n" + L"\ttype() or typeof() expressions."); + } + + Ptr WfErrors::WrongMixinTargetType(WfExpression* node, reflection::description::ITypeInfo* fromType, reflection::description::ITypeInfo* toType) + { + return new ParsingError(node, L"A32: Mixin cast cannot implicitly convert from \"" + fromType->GetTypeFriendlyName() + L"\" to \"" + toType->GetTypeFriendlyName() + L"\". It is only for converting from an interface to a derived interface."); + } + + Ptr WfErrors::ExpectedTypeCastCannotResolveType(WfExpression* node) + { + return new ParsingError(node, L"A33: Cannot resolve type \"*\". This expression should only appear on a place which has an explicit type, including variables and arguments."); + } + + Ptr WfErrors::WrongVoidType(WfType* node) + { + return new ParsingError(node, L"B0: Void is not a type for a value."); + } + + Ptr WfErrors::WrongInterfaceType(WfType* node) + { + return new ParsingError(node, L"B1: Interface is not a type for a value."); + } + + Ptr WfErrors::RawPointerToNonReferenceType(WfType* node, reflection::description::ITypeInfo* typeInfo) + { + return new ParsingError(node, L"B2: A raw pointer" + (typeInfo ? L" \"" + typeInfo->GetTypeFriendlyName() + L"\"" : L"") + L" should point to a class or interface."); + } + + Ptr WfErrors::SharedPointerToNonReferenceType(WfType* node, reflection::description::ITypeInfo* typeInfo) + { + return new ParsingError(node, L"B3: A shared pointer" + (typeInfo ? L" \"" + typeInfo->GetTypeFriendlyName() + L"\"" : L"") + L" should point to a class or interface."); + } + + Ptr WfErrors::NullableToNonReferenceType(WfType* node, reflection::description::ITypeInfo* typeInfo) + { + return new ParsingError(node, L"B4: A nullable value" + (typeInfo ? L" \"" + typeInfo->GetTypeFriendlyName() + L"\"" : L"") + L" should point to a struct."); + } + + Ptr WfErrors::ChildOfNonReferenceType(WfType* node) + { + return new ParsingError(node, L"B5: Only a reference type have child types."); + } + + Ptr WfErrors::TypeNotExists(WfType* node, Ptr scopeName) + { + return new ParsingError(node, L"B6: \"" + scopeName->GetFriendlyName() + L"\" is not a type."); + } + + Ptr WfErrors::TypeNotExists(WfType* node, const ResolveExpressionResult& result) + { + return new ParsingError(node, L"B6: \"" + result.GetFriendlyName() + L"\" is not a type."); + } + + Ptr WfErrors::TypeNotForValue(WfType* node, reflection::description::ITypeInfo* typeInfo) + { + return new ParsingError(node, L"B7: Type \"" + typeInfo->GetTypeFriendlyName() + L"\" is not a type for a value."); + } + + Ptr WfErrors::BreakNotInLoop(WfStatement* node) + { + return new ParsingError(node, L"C0: Break statement should appear in a loop."); + } + + Ptr WfErrors::ContinueNotInLoop(WfStatement* node) + { + return new ParsingError(node, L"C1: Continue statement should appear in a loop."); + } + + Ptr WfErrors::RethrowNotInCatch(WfStatement* node) + { + return new ParsingError(node, L"C2: Re-raise exception statement should appear in catch."); + } + + Ptr WfErrors::TryMissCatchAndFinally(WfStatement* node) + { + return new ParsingError(node, L"C3: Try statement should not appear without both catch and finally."); + } + + Ptr WfErrors::ReturnMissExpression(WfStatement* node, reflection::description::ITypeInfo* type) + { + return new ParsingError(node, L"C4: Return statement requires an expression of type \"" + type->GetTypeFriendlyName() + L"\"."); + } + + Ptr WfErrors::DeleteNonRawPointer(WfStatement* node, reflection::description::ITypeInfo* type) + { + return new ParsingError(node, L"C5: Delete statement cannot apply on an expression of type \"" + type->GetTypeFriendlyName() + L"\", which is expected to be a raw pointer."); + } + + Ptr WfErrors::CannotReturnExpression(WfStatement* node) + { + return new ParsingError(node, L"C6: Return statement cannot have a value inside void functions, constructors, destructors or $coroutine expressions."); + } + + Ptr WfErrors::WrongCoPause(WfStatement* node) + { + return new ParsingError(node, L"C7: $pause statement should appear inside a $coroutine expression, and it cannot be nested."); + } + + Ptr WfErrors::WrongCoOperator(WfStatement* node) + { + return new ParsingError(node, L"C8: $Operator statement should appear inside a coroutine function (which has a functiona body like ${} or $Provider{})."); + } + + Ptr WfErrors::CoProviderNotExists(WfCoProviderStatement* node, collections::List& candidates) + { + WString description; + FOREACH(WString, candidate, candidates) + { + description += L"\r\n\t"; + description += candidate; + } + if (node->name.value == L"") + { + return new ParsingError(node, L"C9: Cannot find a coroutine provider based on the function return type, all of the following types do not exist: " + description + L"."); + } + else + { + return new ParsingError(node, L"C9: Cannot find a coroutine provider based on the provider name \"" + node->name.value.Right(node->name.value.Length() - 1) + L"\", all of the following types do not exist: " + description + L"."); + } + } + + Ptr WfErrors::CoOperatorNotExists(WfReturnStatement* node, reflection::description::ITypeInfo* type) + { + return new ParsingError(node, L"C10: Static function \"ReturnAndExit\" does not exist in coroutine provider \"" + type->GetTypeFriendlyName() + L"\"."); + } + + Ptr WfErrors::CoOperatorNotExists(WfCoOperatorStatement* node, reflection::description::ITypeInfo* type) + { + auto operatorName = node->opName.value.Right(node->opName.value.Length() - 1); + if (node->varName.value == L"") + { + return new ParsingError(node, L"C10: Static functions \"" + operatorName + L"AndPause\" and \"" + operatorName + L"AndRead\" do not exist in coroutine provider \"" + type->GetTypeFriendlyName() + L"\"."); + } + else + { + return new ParsingError(node, L"C10: Static function \"" + operatorName + L"AndRead\" does not exist in coroutine provider \"" + type->GetTypeFriendlyName() + L"\"."); + } + } + + Ptr WfErrors::CoOperatorCannotResolveResultType(WfCoOperatorStatement* node, collections::List& types) + { + auto operatorName = node->opName.value.Right(node->opName.value.Length() - 1); + if (node->arguments.Count() == 0) + { + return new ParsingError(node, L"C11: Failed to resolve the result type of coroutine operator \"" + operatorName + L"\", since there is no argument."); + } + else + { + WString description; + FOREACH(ITypeInfo*, type, types) + { + description += L"\r\n\t"; + description += type->GetTypeFriendlyName(); + } + return new ParsingError(node, L"C11: Failed to resolve the result type of coroutine operator \"" + operatorName + L"\", no appropriate static function \"CastResult\" is found in the following types. It requires exactly one argument of type \"object\" with a return type which is not \"void\": " + description + L"."); + } + } + + Ptr WfErrors::CoProviderCreateNotExists(WfCoProviderStatement* node, reflection::description::ITypeInfo* type) + { + return new ParsingError(node, L"C12: The required static function \"Create\" does not exist in coroutine provider \"" + type->GetTypeFriendlyName() + L"\". It is required to have exactly one argument of a function type, which consumes a pointer type and returns system::Coroutine^"); + } + + Ptr WfErrors::CoProviderCreateAndRunNotExists(WfCoProviderStatement* node, reflection::description::ITypeInfo* type) + { + return new ParsingError(node, L"C12: The required static function \"CreateAndRun\" does not exist in coroutine provider \"" + type->GetTypeFriendlyName() + L"\". It is required to have exactly one argument of a function type, which consumes a pointer type and returns system::Coroutine^"); + } + + Ptr WfErrors::FunctionShouldHaveName(WfDeclaration* node) + { + return new ParsingError(node, L"D0: Function should have a name."); + } + + Ptr WfErrors::FunctionShouldHaveImplementation(WfDeclaration* node) + { + return new ParsingError(node, L"D0: Function should be implemented."); + } + + Ptr WfErrors::InterfaceMethodShouldNotHaveImplementation(WfDeclaration* node) + { + return new ParsingError(node, L"D0: Interface method should not be implemented."); + } + + Ptr WfErrors::DuplicatedDeclaration(WfDeclaration* node, const WString& firstDeclarationCategory) + { + return new ParsingError(node, L"D1: Duplicated declaration \"" + node->name.value + L"\", it has already beed defined as a " + firstDeclarationCategory + L"."); + } + + Ptr WfErrors::DuplicatedSymbol(WfDeclaration* node, Ptr symbol) + { + return new ParsingError(node, L"D2: Duplicated symbol \"" + symbol->name + L"\"."); + } + + Ptr WfErrors::DuplicatedSymbol(WfFunctionArgument* node, Ptr symbol) + { + return new ParsingError(node, L"D2: Duplicated symbol \"" + symbol->name + L"\"."); + } + + Ptr WfErrors::DuplicatedSymbol(WfStatement* node, Ptr symbol) + { + return new ParsingError(node, L"D2: Duplicated symbol \"" + symbol->name + L"\"."); + } + + Ptr WfErrors::DuplicatedSymbol(WfExpression* node, Ptr symbol) + { + return new ParsingError(node, L"D2: Duplicated symbol \"" + symbol->name + L"\"."); + } + + Ptr WfErrors::InterfaceMethodNotImplemented(WfNewInterfaceExpression* node, reflection::description::IMethodInfo* method) + { + auto result = ResolveExpressionResult::Method(method); + return new ParsingError(node, L"D3: Interface method not implemented: " + result.GetFriendlyName() + L"."); + } + + Ptr WfErrors::InterfaceMethodNotFound(WfFunctionDeclaration* node, reflection::description::ITypeInfo* interfaceType, reflection::description::ITypeInfo* methodType) + { + return new ParsingError(node, L"D4: Interface \"" + interfaceType->GetTypeFriendlyName() + L"\" does not contain method \"" + node->name.value + L"\" which is in type \"" + methodType->GetTypeFriendlyName() + L"\"."); + } + + Ptr WfErrors::CannotPickOverloadedInterfaceMethods(WfExpression* node, collections::List& results) + { + WString description; + FOREACH_INDEXER(ResolveExpressionResult, result, index, results) + { + description += L"\r\n\t"; + description += result.GetFriendlyName(); + } + return new ParsingError(node, L"D5: Cannot decide which function to implement in multiple targets: " + description + L"."); + } + + Ptr WfErrors::CannotPickOverloadedImplementMethods(WfFunctionDeclaration* node, reflection::description::ITypeInfo* type) + { + return new ParsingError(node, L"D6: There are some other methods named \"" + node->name.value + L"\" whose types are also \"" + type->GetTypeFriendlyName() + L"\"."); + } + + Ptr WfErrors::WrongDeclaration(WfEventDeclaration* node) + { + return new ParsingError(node, L"D7: Event \"" + node->name.value + L"\" cannot be defined outside of classes or interfaces."); + } + + Ptr WfErrors::WrongDeclaration(WfPropertyDeclaration* node) + { + return new ParsingError(node, L"D7: Property \"" + node->name.value + L"\" cannot be defined outside of classes or interfaces."); + } + + Ptr WfErrors::WrongDeclaration(WfConstructorDeclaration* node) + { + return new ParsingError(node, L"D7: Constructor cannot be defined outside of classes."); + } + + Ptr WfErrors::WrongDeclaration(WfDestructorDeclaration* node) + { + return new ParsingError(node, L"D7: Destructor cannot be defined outside of classes."); + } + + Ptr WfErrors::WrongDeclaration(WfAutoPropertyDeclaration* node) + { + return new ParsingError(node, L"D7: Auto-property cannot be defined outside of classes."); + } + + Ptr WfErrors::WrongDeclarationInInterfaceConstructor(WfDeclaration* node) + { + return new ParsingError(node, L"D8: \"" + node->name.value + L"\" cannot be defined in an new interface expression, only functions, variables and auto-properties are allowed."); + } + + Ptr WfErrors::EnumValuesNotConsecutiveFromZero(WfEnumDeclaration* node) + { + return new ParsingError(node, L"D9: Item values in enum \"" + node->name.value + L"\" should be consecutive and starts from zero, like 0, 1, 2, 3, 4, ..."); + } + + Ptr WfErrors::FlagValuesNotConsecutiveFromZero(WfEnumDeclaration* node) + { + return new ParsingError(node, L"D9: Item values in flag enum \"" + node->name.value + L"\" should be consecutive powers of 2 and starts from zero, like 0, 1, 2, 4, 8, ..."); + } + + Ptr WfErrors::FlagValueNotExists(WfEnumItemIntersection* node, WfEnumDeclaration* owner) + { + return new ParsingError(node, L"D10: Item \"" + node->name.value + L" does not exists in the current flag enum \"" + owner->name.value + L"\"."); + } + + Ptr WfErrors::DuplicatedEnumValue(WfEnumItem* node, WfEnumDeclaration* owner) + { + return new ParsingError(node, L"D11: Item \"" + node->name.value + L" already exists in the current enum \"" + owner->name.value + L"\"."); + } + + Ptr WfErrors::StructContainsNonValueType(WfStructMember* node, WfStructDeclaration* owner) + { + return new ParsingError(node, L"D12: Type of member \"" + node->name.value + L"\" of struct \"" + owner->name.value + L"\" is not value type."); + } + + Ptr WfErrors::StructRecursivelyIncludeItself(WfStructDeclaration* node, const WString& path) + { + return new ParsingError(node, L"D13: Struct \"" + node->name.value + L"\" recursively include itself via \"" + path + L"\"."); + } + + Ptr WfErrors::DuplicatedStructMember(WfStructMember* node, WfStructDeclaration* owner) + { + return new ParsingError(node, L"D14: Member \"" + node->name.value + L"\" already exists in struct \"" + owner->name.value + L"\"."); + } + + Ptr WfErrors::AttributeNotExists(WfAttribute* node) + { + return new ParsingError(node, L"D15: Attribute \"" + node->category.value + L":" + node->name.value + L"\" does not exist."); + } + + Ptr WfErrors::AttributeMissValue(WfAttribute* node) + { + return new ParsingError(node, L"D15: Value of attribute \"" + node->category.value + L":" + node->name.value + L"\" is missing."); + } + + Ptr WfErrors::WrongUsingPathWildCard(WfModuleUsingPath* node) + { + return new ParsingError(node, L"E0: Wild card \"*\" should only appear in the last item of the using path and should appear once."); + } + + Ptr WfErrors::TopQualifiedSymbolNotExists(parsing::ParsingTreeCustomBase* node, const WString& name) + { + return new ParsingError(node, L"F0: Top qualified symbol \"" + name + L"\" does not exist."); + } + + Ptr WfErrors::ChildSymbolNotExists(parsing::ParsingTreeCustomBase* node, Ptr scopeName, const WString& name) + { + return new ParsingError(node, L"F1: Symbol \"" + name + L"\" does not exist in \"" + scopeName->GetFriendlyName() + L"\"."); + } + + Ptr WfErrors::MemberNotExists(parsing::ParsingTreeCustomBase* node, reflection::description::ITypeDescriptor* typeDescriptor, const WString& name) + { + return new ParsingError(node, L"F1: Member \"" + name + L"\" does not exist in \"" + typeDescriptor->GetTypeName() + L"\"."); + } + + Ptr WfErrors::ReferenceNotExists(parsing::ParsingTreeCustomBase* node, const WString& name) + { + return new ParsingError(node, L"F2: Symbol \"" + name + L"\" does not exist in the current scope."); + } + + Ptr WfErrors::TooManyTargets(parsing::ParsingTreeCustomBase* node, collections::List& results, const WString& name) + { + WString description; + FOREACH_INDEXER(ResolveExpressionResult, result, index, results) + { + description += L"\r\n\t"; + description += result.GetFriendlyName(); + } + return new ParsingError(node, L"F3: Symbol \"" + name + L"\" references to too many targets: " + description + L"."); + } + + Ptr WfErrors::EnumItemNotExists(parsing::ParsingTreeCustomBase* node, reflection::description::ITypeDescriptor* typeDescriptor, const WString& name) + { + return new ParsingError(node, L"F2: Enum item \"" + name + L"\" does not exist in enum type \"" + typeDescriptor->GetTypeName() + L"\"."); + } + + Ptr WfErrors::WrongClassMemberConfig(WfDeclaration* node) + { + return new ParsingError(node, L"G1: Class member \"" + node->name.value + L"\" cannot be static or override because it is not a function or a auto-property."); + } + + Ptr WfErrors::FunctionInNewTypeExpressionCannotBeStatic(WfDeclaration* node) + { + return new ParsingError(node, L"G1: Class member \"" + node->name.value + L"\" cannot be static because it is in a new interface expression."); + } + + Ptr WfErrors::AutoPropertyCannotBeNormalOutsideOfClass(WfDeclaration* node) + { + return new ParsingError(node, L"G1: Auto property \"" + node->name.value + L"\" cannot be normal outside of classes or interfaces."); + } + + Ptr WfErrors::AutoPropertyCannotBeStatic(WfDeclaration* node) + { + return new ParsingError(node, L"G1: Auto property \"" + node->name.value + L"\" cannot be static ."); + } + + Ptr WfErrors::WrongClassMember(WfNamespaceDeclaration* node) + { + return new ParsingError(node, L"G2: Namespace \"" + node->name.value + L"\" cannot be a class member."); + } + + Ptr WfErrors::PropertyGetterNotFound(WfPropertyDeclaration* node, WfClassDeclaration* classDecl) + { + return new ParsingError(node, L"G3: Cannot find the getter \"" + node->getter.value + L"\" of property \"" + node->name.value + L"\" in type \"" + classDecl->name.value + L"\". A property getter should be a non-static method in the same type."); + } + + Ptr WfErrors::PropertySetterNotFound(WfPropertyDeclaration* node, WfClassDeclaration* classDecl) + { + return new ParsingError(node, L"G3: Cannot find the setter \"" + node->setter.value + L"\" of property \"" + node->name.value + L"\" in type \"" + classDecl->name.value + L"\". A property setter should be a non-static method in the same type."); + } + + Ptr WfErrors::PropertyEventNotFound(WfPropertyDeclaration* node, WfClassDeclaration* classDecl) + { + return new ParsingError(node, L"G3: Cannot find the event \"" + node->valueChangedEvent.value + L"\" of property \"" + node->name.value + L"\" in type \"" + classDecl->name.value + L"\"."); + } + + Ptr WfErrors::TooManyPropertyGetter(WfPropertyDeclaration* node, WfClassDeclaration* classDecl) + { + return new ParsingError(node, L"G4: Too many symbols found for the getter \"" + node->getter.value + L"\" of property \"" + node->name.value + L"\" in type \"" + classDecl->name.value + L"\"."); + } + + Ptr WfErrors::TooManyPropertySetter(WfPropertyDeclaration* node, WfClassDeclaration* classDecl) + { + return new ParsingError(node, L"G4: Too many symbols found for the setter \"" + node->setter.value + L"\" of property \"" + node->name.value + L"\" in type \"" + classDecl->name.value + L"\"."); + } + + Ptr WfErrors::TooManyPropertyEvent(WfPropertyDeclaration* node, WfClassDeclaration* classDecl) + { + return new ParsingError(node, L"G4: Too many symbols found for the event \"" + node->valueChangedEvent.value + L"\" of property \"" + node->name.value + L"\" in type \"" + classDecl->name.value + L"\"."); + } + + Ptr WfErrors::PropertyGetterTypeMismatched(WfPropertyDeclaration* node, WfClassDeclaration* classDecl) + { + return new ParsingError(node, L"G5: Cannot match the getter \"" + node->getter.value + L"\" of property \"" + node->name.value + L"\" in type \"" + classDecl->name.value + L"\". A property getter should have no argument, and its return type should be identical to the property type."); + } + + Ptr WfErrors::PropertySetterTypeMismatched(WfPropertyDeclaration* node, WfClassDeclaration* classDecl) + { + return new ParsingError(node, L"G5: Cannot match the setter \"" + node->getter.value + L"\" of property \"" + node->name.value + L"\" in type \"" + classDecl->name.value + L"\". A property setter should have no return value and have only one argument, and the argument type should be identical to the property type."); + } + + Ptr WfErrors::WrongBaseType(WfClassDeclaration* node, WfType* type) + { + return new ParsingError(node, L"G6: A base type of the type \"" + node->name.value + L"\" should be another custom type, it cannot be any predefined type, pointer type, shared pointer type, nullable type, collection type, or function type"); + } + + Ptr WfErrors::WrongBaseTypeOfClass(WfClassDeclaration* node, reflection::description::ITypeDescriptor* type) + { + return new ParsingError(node, L"G6: Base type \"" + type->GetTypeName() + L"\" of class \"" + node->name.value + L"\" is not a class, or it is a class but it is not aggregatable."); + } + + Ptr WfErrors::WrongBaseTypeOfInterface(WfClassDeclaration* node, reflection::description::ITypeDescriptor* type) + { + return new ParsingError(node, L"G6: Base type \"" + type->GetTypeName() + L"\" of interface \"" + node->name.value + L"\" is not an interface."); + } + + Ptr WfErrors::WrongInterfaceBaseType(WfClassDeclaration* node, reflection::description::ITypeDescriptor* type) + { + Ptr proxy = TypeInfoRetriver>::CreateTypeInfo(); + return new ParsingError(node, L"G6: Interface \"" + type->GetTypeName() + L"\" should contain a constructor receiving an \"" + proxy->GetTypeFriendlyName() + L"\" to be the base type of \"" + node->name.value + L"\"."); + } + + Ptr WfErrors::ClassWithInterfaceConstructor(WfClassDeclaration* node) + { + return new ParsingError(node, L"G7: Cannot use interface constructor type on class \"" + node->name.value + L"\"."); + } + + Ptr WfErrors::OverrideShouldImplementInterfaceMethod(WfFunctionDeclaration* node) + { + return new ParsingError(node, L"G8: Function \"" + node->name.value + L"\" cannot be override because it doesn't implement any interface methods."); + } + + Ptr WfErrors::OverrideShouldImplementInterfaceMethod(WfAutoPropertyDeclaration* node) + { + return new ParsingError(node, L"G8: Auto-property \"" + node->name.value + L"\" cannot be override because it doesn't implement any interface methods."); + } + + Ptr WfErrors::MissingFieldType(WfVariableDeclaration* node) + { + return new ParsingError(node, L"G9: Type of field \"" + node->name.value + L"\" is missing."); + } + + Ptr WfErrors::DuplicatedBaseClass(WfClassDeclaration* node, reflection::description::ITypeDescriptor* type) + { + return new ParsingError(node, L"G10: Class \"" + node->name.value + L"\" inherits from another class \"" + type->GetTypeName() + L"\" for multiple times."); + } + + Ptr WfErrors::DuplicatedBaseInterface(WfClassDeclaration* node, reflection::description::ITypeDescriptor* type) + { + return new ParsingError(node, L"G10: Interface \"" + type->GetTypeName() + L"\" directly or indirectly inherits from itself."); + } + + Ptr WfErrors::WrongBaseConstructorCall(WfBaseConstructorCall* node, reflection::description::ITypeDescriptor* type) + { + return new ParsingError(node, L"G11: Type \"" + type->GetTypeName() + L"\" is not a base type of this class."); + } + + Ptr WfErrors::DuplicatedBaseConstructorCall(WfBaseConstructorCall* node, reflection::description::ITypeDescriptor* type) + { + return new ParsingError(node, L"G12: Base type \"" + type->GetTypeName() + L"\" has already been initialized."); + } + + Ptr WfErrors::TooManyDestructor(WfDestructorDeclaration* node, WfClassDeclaration* classDecl) + { + return new ParsingError(node, L"G13: Class \"" + classDecl->name.value + L"\" has too many destructors."); + } + + Ptr WfErrors::AutoPropertyShouldBeInitialized(WfAutoPropertyDeclaration* node) + { + return new ParsingError(node, L"G13: Auto property \"" + node->name.value + L"\" should be initialized."); + } + + Ptr WfErrors::AutoPropertyCannotBeInitializedInInterface(WfAutoPropertyDeclaration* node, WfClassDeclaration* classDecl) + { + return new ParsingError(node, L"G13: Auto property \"" + node->name.value + L"\" cannot be initialized in interface \"" + classDecl->name.value + L"\"."); + } + } + } +} + +/*********************************************************************** +.\ANALYZER\WFANALYZER_EXPANDBINDEXPRESSION.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace analyzer + { + using namespace collections; + using namespace reflection; + using namespace reflection::description; + +/*********************************************************************** +observing expressions: + WfObserveExpression + WfMemberExpression that detects the event +***********************************************************************/ + + class BindContext : public Object + { + typedef collections::List ExprList; + typedef collections::Dictionary ExprMap; + typedef collections::Group ExprGroup; + typedef collections::Group ExprEventGroup; + public: + ExprMap observeParents; + ExprEventGroup observeEvents; + ExprList orderedObserves; + ExprList cachedExprs; // expression that need to cache its value + ExprMap renames; // expression -> the expression being renamed + + ExprGroup exprAffects; // observe expression -> all expressions that it can cause to change + ExprGroup exprCauses; // expression -> observe expressions that cause it to change + ExprGroup observeAffects; // observe expression -> all observe expressions that it can cause to change + ExprGroup observeCauses; // observe expression -> observe expressions that cause it to change + + WString GetCacheVariableName(vint index) + { + return L"" + itow(index); + } + + vint GetCachedExpressionIndex(WfExpression* expression, bool ensureExists) + { + vint index = cachedExprs.IndexOf(expression); + if (ensureExists) + { + CHECK_ERROR(index != -1, L"BindContext::GetCachedExpressionIndex(WfExpression*, bool)#Cached expression not exists."); + } + return index; + } + + vint GetCachedExpressionIndexRecursively(WfExpression* expression, bool ensureExists) + { + WfExpression* cache = expression; + while (true) + { + vint index = renames.Keys().IndexOf(cache); + if (index == -1) + { + return GetCachedExpressionIndex(cache, ensureExists); + } + else + { + cache = renames.Values()[index]; + } + } + } + }; + + struct CallbackInfo + { + WfExpression* observe; + IEventInfo* eventInfo; + vint eventIndex; + WString handlerName; + WString callbackName; + }; + + struct BindCallbackInfo + { + Dictionary> handlerVariables; + Dictionary> callbackFunctions; + Group observeCallbackInfos; + }; + +/*********************************************************************** +CreateBindContext +***********************************************************************/ + + class CreateBindContextVisitor : public Object, public WfExpression::IVisitor + { + public: + WfLexicalScopeManager* manager; + BindContext& context; + + CreateBindContextVisitor(WfLexicalScopeManager* _manager, BindContext& _context) + :manager(_manager) + , context(_context) + { + } + + void Call(WfExpression* node) + { + node->Accept(this); + } + + void ObservableDepend(WfExpression* expr, WfExpression* parent) + { + context.orderedObserves.Add(expr); + context.observeParents.Add(expr, parent); + DirectDepend(expr, parent, false); + { + auto cache = parent; + while (true) + { + vint index = context.renames.Keys().IndexOf(cache); + if (index == -1) + { + index = context.cachedExprs.IndexOf(cache); + if (index == -1) + { + context.cachedExprs.Add(cache); + } + break; + } + else + { + cache = context.renames.Values()[index]; + } + } + } + + vint index = context.exprCauses.Keys().IndexOf(parent); + if (index != -1) + { + FOREACH(WfExpression*, observe, context.exprCauses.GetByIndex(index)) + { + context.observeAffects.Add(observe, expr); + context.observeCauses.Add(expr, observe); + } + } + + context.exprAffects.Add(expr, expr); + context.exprCauses.Add(expr, expr); + } + + void DirectDepend(WfExpression* expr, WfExpression* depended, bool processDepended = true) + { + if (processDepended) + { + Call(depended); + } + + vint index = context.exprCauses.Keys().IndexOf(depended); + if (index != -1) + { + FOREACH(WfExpression*, observe, context.exprCauses.GetByIndex(index)) + { + context.exprCauses.Add(expr, observe); + context.exprAffects.Add(observe, expr); + } + } + } + + void Visit(WfThisExpression* node)override + { + // root expression, nothing to do + } + + void Visit(WfTopQualifiedExpression* node)override + { + // root expression, nothing to do + } + + void Visit(WfReferenceExpression* node)override + { + auto result = manager->expressionResolvings[node]; + if (result.symbol) + { + auto scope = result.symbol->ownerScope; + if (auto letExpr = dynamic_cast(scope->ownerNode.Obj())) + { + auto letVar = From(letExpr->variables) + .Where([=](const Ptr& letVar) + { + return letVar->name.value == node->name.value; + }) + .First(); + context.renames.Add(node, letVar->value.Obj()); + DirectDepend(node, letVar->value.Obj(), false); + } + else if (auto observeExpr = dynamic_cast(scope->ownerNode.Obj())) + { + context.renames.Add(node, observeExpr->parent.Obj()); + DirectDepend(node, observeExpr->parent.Obj()); + } + } + } + + void Visit(WfOrderedNameExpression* node)override + { + // root expression, nothing to do + } + + void Visit(WfOrderedLambdaExpression* node)override + { + // root expression, nothing to do + } + + void Visit(WfMemberExpression* node)override + { + Call(node->parent.Obj()); + + auto scope = manager->nodeScopes[node].Obj(); + while (scope) + { + if (scope->ownerNode.Cast()) + { + break; + } + scope = scope->parentScope.Obj(); + } + + if (!scope) + { + auto memberResult = manager->expressionResolvings[node]; + if (memberResult.propertyInfo) + { + auto td = memberResult.propertyInfo->GetOwnerTypeDescriptor(); + auto ev = memberResult.propertyInfo->GetValueChangedEvent(); + if (!ev) + { + ev = td->GetEventByName(memberResult.propertyInfo->GetName() + L"Changed", true); + } + if (ev) + { + ObservableDepend(node, node->parent.Obj()); + context.observeEvents.Add(node, ev); + return; + } + } + } + + DirectDepend(node, node->parent.Obj(), false); + } + + void Visit(WfChildExpression* node)override + { + DirectDepend(node, node->parent.Obj()); + } + + void Visit(WfLiteralExpression* node)override + { + // root expression, nothing to do + } + + void Visit(WfFloatingExpression* node)override + { + // root expression, nothing to do + } + + void Visit(WfIntegerExpression* node)override + { + // root expression, nothing to do + } + + void Visit(WfStringExpression* node)override + { + // root expression, nothing to do + } + + void Visit(WfUnaryExpression* node)override + { + DirectDepend(node, node->operand.Obj()); + } + + void Visit(WfBinaryExpression* node)override + { + DirectDepend(node, node->first.Obj()); + DirectDepend(node, node->second.Obj()); + } + + void Visit(WfLetExpression* node)override + { + FOREACH(Ptr, var, node->variables) + { + DirectDepend(node, var->value.Obj()); + } + DirectDepend(node, node->expression.Obj()); + } + + void Visit(WfIfExpression* node)override + { + DirectDepend(node, node->condition.Obj()); + DirectDepend(node, node->trueBranch.Obj()); + DirectDepend(node, node->falseBranch.Obj()); + } + + void Visit(WfRangeExpression* node)override + { + DirectDepend(node, node->begin.Obj()); + DirectDepend(node, node->end.Obj()); + } + + void Visit(WfSetTestingExpression* node)override + { + DirectDepend(node, node->collection.Obj()); + DirectDepend(node, node->element.Obj()); + } + + void Visit(WfConstructorExpression* node)override + { + auto result = manager->expressionResolvings[node]; + bool isStruct = (result.type->GetTypeDescriptor()->GetTypeDescriptorFlags() == TypeDescriptorFlags::Struct); + + FOREACH(Ptr, argument, node->arguments) + { + if (!isStruct) + { + DirectDepend(node, argument->key.Obj()); + } + DirectDepend(node, argument->value.Obj()); + } + } + + void Visit(WfInferExpression* node)override + { + DirectDepend(node, node->expression.Obj()); + } + + void Visit(WfTypeCastingExpression* node)override + { + DirectDepend(node, node->expression.Obj()); + } + + void Visit(WfTypeTestingExpression* node)override + { + DirectDepend(node, node->expression.Obj()); + } + + void Visit(WfTypeOfTypeExpression* node)override + { + // root expression, nothing to do + } + + void Visit(WfTypeOfExpressionExpression* node)override + { + // root expression, nothing to do + } + + void Visit(WfAttachEventExpression* node)override + { + DirectDepend(node, node->event.Obj()); + DirectDepend(node, node->function.Obj()); + } + + void Visit(WfDetachEventExpression* node)override + { + DirectDepend(node, node->event.Obj()); + DirectDepend(node, node->handler.Obj()); + } + + void Visit(WfObserveExpression* node)override + { + Call(node->parent.Obj()); + ObservableDepend(node, node->parent.Obj()); + Call(node->expression.Obj()); + FOREACH(Ptr, eventExpr, node->events) + { + auto result = manager->expressionResolvings[eventExpr.Obj()]; + context.observeEvents.Add(node, result.eventInfo); + Call(eventExpr.Obj()); + } + } + + void Visit(WfCallExpression* node)override + { + DirectDepend(node, node->function.Obj()); + FOREACH(Ptr, argument, node->arguments) + { + DirectDepend(node, argument.Obj()); + } + } + + void Visit(WfFunctionExpression* node)override + { + // root expression, nothing to do + } + + void Visit(WfNewClassExpression* node)override + { + FOREACH(Ptr, argument, node->arguments) + { + DirectDepend(node, argument.Obj()); + } + } + + void Visit(WfNewInterfaceExpression* node)override + { + // root expression, nothing to do + } + + void Visit(WfVirtualExpression* node)override + { + DirectDepend(node, node->expandedExpression.Obj()); + } + }; + +/*********************************************************************** +Copy(Type|Expression|Statement|Declaration) +***********************************************************************/ + + Ptr CopyType(Ptr type) + { + return copy_visitor::ModuleVisitor().CreateField(type); + } + + Ptr CopyExpression(Ptr expression) + { + return copy_visitor::ModuleVisitor().CreateField(expression); + } + + Ptr CopyStatement(Ptr statement) + { + return copy_visitor::ModuleVisitor().CreateField(statement); + } + + Ptr CopyDeclaration(Ptr declaration) + { + return copy_visitor::ModuleVisitor().CreateField(declaration); + } + +/*********************************************************************** +ExpandObserveExpression +***********************************************************************/ + + Ptr CreateReference(const WString& name) + { + auto ref = MakePtr(); + ref->name.value = name; + return ref; + } + + class ExpandObserveExpressionVisitor + : public copy_visitor::ExpressionVisitor + , public copy_visitor::VirtualExpressionVisitor + { + public: + BindContext& context; + + ExpandObserveExpressionVisitor(BindContext& _context) + :context(_context) + { + } + + static Ptr Execute(WfExpression* expression, BindContext& context, bool expandImmediately = true) + { + if (!expression) + { + return nullptr; + } + + { + vint index = context.GetCachedExpressionIndexRecursively(expression, false); + if (index != -1) + { + if (expandImmediately) + { + return CreateReference(context.GetCacheVariableName(index)); + } + else + { + expression = context.cachedExprs[index]; + } + } + } + + ExpandObserveExpressionVisitor visitor(context); + expression->Accept(&visitor); + return visitor.result.Cast(); + } + + vl::Ptr CreateField(vl::Ptr from)override + { + return Execute(from.Obj(), context); + } + + vl::Ptr CreateField(vl::Ptr from)override + { + return CopyType(from); + } + + vl::Ptr CreateField(vl::Ptr from)override + { + return CopyStatement(from); + } + + vl::Ptr CreateField(vl::Ptr from)override + { + return CopyDeclaration(from); + } + + vl::Ptr Dispatch(WfVirtualExpression* node)override + { + node->Accept((WfVirtualExpression::IVisitor*)this); + return result; + } + + void Visit(WfLetExpression* node)override + { + auto letExpr = MakePtr(); + FOREACH(Ptr, var, node->variables) + { + if (context.GetCachedExpressionIndexRecursively(var->value.Obj(), false) == -1) + { + auto letVar = MakePtr(); + letVar->name.value = var->name.value; + letVar->value = Execute(var->value.Obj(), context); + letExpr->variables.Add(letVar); + } + } + + if (letExpr->variables.Count() == 0) + { + result = Execute(node->expression.Obj(), context); + } + else + { + letExpr->expression = Execute(node->expression.Obj(), context); + result = letExpr; + } + } + + void Visit(WfObserveExpression* node)override + { + if (node->observeType == WfObserveType::SimpleObserve) + { + auto expr = MakePtr(); + expr->parent = CreateField(node->parent); + expr->name.value = node->expression.Cast()->name.value; + result = expr; + } + else + { + result = CreateField(node->expression); + } + } + }; + +/*********************************************************************** +CreateDefaultValue +***********************************************************************/ + + Ptr CreateDefaultValue(ITypeInfo* elementType) + { + auto valueType = elementType->GetTypeDescriptor()->GetValueType(); + if (elementType->GetDecorator()==ITypeInfo::TypeDescriptor && valueType != nullptr) + { + auto value = valueType->CreateDefault(); + switch (GetTypeFlag(elementType)) + { + case TypeFlag::Enum: + { + auto intExpr = MakePtr(); + intExpr->value.value = u64tow(elementType->GetTypeDescriptor()->GetEnumType()->FromEnum(value)); + + auto inferExpr = MakePtr(); + inferExpr->strategy = WfTypeCastingStrategy::Strong; + inferExpr->expression = intExpr; + inferExpr->type = GetTypeFromTypeInfo(CreateTypeInfoFromTypeFlag(TypeFlag::U8).Obj()); + + auto castExpr = MakePtr(); + castExpr->strategy = WfTypeCastingStrategy::Strong; + castExpr->expression = inferExpr; + castExpr->type = GetTypeFromTypeInfo(elementType); + + return castExpr; + } + case TypeFlag::String: + { + auto stringExpr = MakePtr(); + elementType->GetTypeDescriptor()->GetSerializableType()->Serialize(value, stringExpr->value.value); + return stringExpr; + } + break; + case TypeFlag::Struct: + if (elementType->GetTypeDescriptor()->GetSerializableType() == nullptr) + { + auto ctorExpr = MakePtr(); + + auto castExpr = MakePtr(); + castExpr->strategy = WfTypeCastingStrategy::Strong; + castExpr->expression = ctorExpr; + castExpr->type = GetTypeFromTypeInfo(elementType); + + return castExpr; + } + default: + { + auto td = elementType->GetTypeDescriptor(); + if (td == description::GetTypeDescriptor()) + { + auto expr = MakePtr(); + expr->value = WfLiteralValue::False; + return expr; + } + else if (td == description::GetTypeDescriptor() + || td == description::GetTypeDescriptor()) + { + auto valueExpr = MakePtr(); + valueExpr->value.value = L"0"; + + auto inferExpr = MakePtr(); + inferExpr->expression = valueExpr; + inferExpr->type = GetTypeFromTypeInfo(elementType); + + return inferExpr; + } + else if (td == description::GetTypeDescriptor() + || td == description::GetTypeDescriptor() + || td == description::GetTypeDescriptor() + || td == description::GetTypeDescriptor() + || td == description::GetTypeDescriptor() + || td == description::GetTypeDescriptor() + || td == description::GetTypeDescriptor() + || td == description::GetTypeDescriptor()) + { + auto valueExpr = MakePtr(); + valueExpr->value.value = L"0"; + + auto inferExpr = MakePtr(); + inferExpr->expression = valueExpr; + inferExpr->type = GetTypeFromTypeInfo(elementType); + + return inferExpr; + } + else + { + auto stringExpr = MakePtr(); + elementType->GetTypeDescriptor()->GetSerializableType()->Serialize(value, stringExpr->value.value); + + auto castExpr = MakePtr(); + castExpr->strategy = WfTypeCastingStrategy::Strong; + castExpr->expression = stringExpr; + castExpr->type = GetTypeFromTypeInfo(elementType); + + return castExpr; + } + } + } + } + else + { + auto nullExpr = MakePtr(); + nullExpr->value = WfLiteralValue::Null; + + auto inferExpr = MakePtr(); + inferExpr->expression = nullExpr; + inferExpr->type = GetTypeFromTypeInfo(elementType); + + return inferExpr; + } + } + +/*********************************************************************** +CreateBindWritableVariable +***********************************************************************/ + + Ptr CreateWritableVariable(const WString& name, ITypeInfo* type, Ptr value = nullptr) + { + auto decl = MakePtr(); + decl->name.value = name; + decl->type = GetTypeFromTypeInfo(type); + decl->expression = value ? value : CreateDefaultValue(type); + return decl; + } + + Ptr CreateWritableVariableStatement(const WString& name, ITypeInfo* type, Ptr value = nullptr) + { + auto stat = MakePtr(); + stat->variable = CreateWritableVariable(name, type, value); + return stat; + } + +/*********************************************************************** +IValueSubscription::Subscribe +***********************************************************************/ + + Ptr AssignNormalMember(Ptr decl) + { + decl->classMember = MakePtr(); + decl->classMember->kind = WfClassMemberKind::Normal; + return decl; + } + + Ptr AssignOverrideMember(Ptr decl) + { + decl->classMember = MakePtr(); + decl->classMember->kind = WfClassMemberKind::Override; + return decl; + } + +/*********************************************************************** +ExpandObserveEvent +***********************************************************************/ + + Ptr ExpandObserveEvent(WfLexicalScopeManager* manager, WfExpression* observe, vint eventIndex, BindContext& context) + { + auto cacheName = context.GetCacheVariableName(context.GetCachedExpressionIndexRecursively(context.observeParents[observe], true)); + if (auto observeExpr = dynamic_cast(observe)) + { + if (observeExpr->observeType == WfObserveType::SimpleObserve) + { + auto expr = MakePtr(); + expr->parent = CreateReference(cacheName); + expr->name.value = observeExpr->events[eventIndex].Cast()->name.value; + return expr; + } + else + { + return ExpandObserveExpressionVisitor::Execute(observeExpr->events[eventIndex].Obj(), context); + } + } + else + { + auto eventName = context.observeEvents[observe][0]->GetName(); + + auto expr = MakePtr(); + expr->parent = CreateReference(cacheName); + expr->name.value = eventName; + + return expr; + } + } + +/*********************************************************************** +CreateBindAttachStatement +***********************************************************************/ + + void CreateBindAttachStatement(Ptr block, WfLexicalScopeManager* manager, WfExpression* observe, BindContext& context, BindCallbackInfo& info) + { + FOREACH(CallbackInfo, callbackInfo, info.observeCallbackInfos[observe]) + { + auto attach = MakePtr(); + attach->event = ExpandObserveEvent(manager, observe, callbackInfo.eventIndex, context); + attach->function = CreateReference(callbackInfo.callbackName); + + auto assign = MakePtr(); + assign->op = WfBinaryOperator::Assign; + assign->first = CreateReference(callbackInfo.handlerName); + assign->second = attach; + + auto stat = MakePtr(); + stat->expression = assign; + block->statements.Add(stat); + } + } + +/*********************************************************************** +CreateBindDetachStatement +***********************************************************************/ + + void CreateBindDetachStatement(Ptr block, WfLexicalScopeManager* manager, WfExpression* observe, BindContext& context, BindCallbackInfo& info) + { + FOREACH(CallbackInfo, callbackInfo, info.observeCallbackInfos[observe]) + { + auto detach = MakePtr(); + detach->event = ExpandObserveEvent(manager, observe, callbackInfo.eventIndex, context); + detach->handler = CreateReference(callbackInfo.handlerName); + + auto stat = MakePtr(); + stat->expression = detach; + block->statements.Add(stat); + } + } + +/*********************************************************************** +CreateBindCacheAssignStatement +***********************************************************************/ + + void CreateBindCacheAssignStatement(Ptr block, WfExpression* observe, BindContext& context) + { + auto parent = context.observeParents[observe]; + auto cacheName = context.GetCacheVariableName(context.GetCachedExpressionIndexRecursively(parent, true)); + + auto assign = MakePtr(); + assign->op = WfBinaryOperator::Assign; + assign->first = CreateReference(cacheName); + assign->second = ExpandObserveExpressionVisitor::Execute(parent, context, false); + + auto stat = MakePtr(); + stat->expression = assign; + block->statements.Add(stat); + } + +/*********************************************************************** +IValueSubscription::Open +***********************************************************************/ + + Ptr CreateBindOpenFunction(WfLexicalScopeManager* manager, BindContext& context, BindCallbackInfo& info) + { + auto func = MakePtr(); + func->name.value = L"Open"; + func->anonymity = WfFunctionAnonymity::Named; + { + auto typeInfo = TypeInfoRetriver::CreateTypeInfo(); + func->returnType = GetTypeFromTypeInfo(typeInfo.Obj()); + } + + auto block = MakePtr(); + func->statement = block; + { + auto ifStat = MakePtr(); + block->statements.Add(ifStat); + { + auto notExpr = MakePtr(); + notExpr->op = WfUnaryOperator::Not; + notExpr->operand = CreateReference(L""); + ifStat->expression = notExpr; + } + + auto ifBlock = MakePtr(); + ifStat->trueBranch = ifBlock; + { + auto literal = MakePtr(); + literal->value = WfLiteralValue::True; + + auto assign = MakePtr(); + assign->op = WfBinaryOperator::Assign; + assign->first = CreateReference(L""); + assign->second = literal; + + auto stat = MakePtr(); + stat->expression = assign; + ifBlock->statements.Add(stat); + } + { + SortedList assignedParents; + SortedList observes; + CopyFrom(observes, context.observeParents.Keys()); + + SortedList freeObserves; + while (observes.Count() > 0) + { + CopyFrom( + freeObserves, + From(observes) + .Where([&](WfExpression* observe) + { + return !context.observeCauses.Keys().Contains(observe) || + From(context.observeCauses[observe]) + .All([&](WfExpression* depended) + { + return !observes.Contains(depended); + }); + }) + ); + + FOREACH(WfExpression*, observe, context.orderedObserves) + { + if (freeObserves.Contains(observe)) + { + auto parent = context.GetCachedExpressionIndexRecursively(context.observeParents[observe], true); + if (!assignedParents.Contains(parent)) + { + assignedParents.Add(parent); + CreateBindCacheAssignStatement(ifBlock, observe, context); + } + } + } + + FOREACH(WfExpression*, observe, freeObserves) + { + observes.Remove(observe); + } + freeObserves.Clear(); + } + } + { + FOREACH(WfExpression*, observe, context.orderedObserves) + { + CreateBindAttachStatement(ifBlock, manager, observe, context, info); + } + } + { + auto literal = MakePtr(); + literal->value = WfLiteralValue::True; + + auto returnStat = MakePtr(); + returnStat->expression = literal; + ifBlock->statements.Add(returnStat); + } + } + { + auto literal = MakePtr(); + literal->value = WfLiteralValue::False; + + auto returnStat = MakePtr(); + returnStat->expression = literal; + block->statements.Add(returnStat); + } + + return func; + } + +/*********************************************************************** +IValueSubscription::Update +***********************************************************************/ + + Ptr CreateBindUpdateFunction(BindCallbackInfo& info) + { + auto func = MakePtr(); + func->name.value = L"Update"; + func->anonymity = WfFunctionAnonymity::Named; + { + auto typeInfo = TypeInfoRetriver::CreateTypeInfo(); + func->returnType = GetTypeFromTypeInfo(typeInfo.Obj()); + } + + auto block = MakePtr(); + func->statement = block; + { + auto ifStat = MakePtr(); + block->statements.Add(ifStat); + { + auto notExpr = MakePtr(); + notExpr->op = WfUnaryOperator::Not; + notExpr->operand = CreateReference(L""); + + auto andExpr = MakePtr(); + andExpr->op = WfBinaryOperator::And; + andExpr->first = CreateReference(L""); + andExpr->second = notExpr; + + ifStat->expression = andExpr; + } + + auto ifBlock = MakePtr(); + ifStat->trueBranch = ifBlock; + { + auto ref = CreateReference(L""); + + auto call = MakePtr(); + call->function = ref; + + auto stat = MakePtr(); + stat->expression = call; + ifBlock->statements.Add(stat); + } + { + auto literal = MakePtr(); + literal->value = WfLiteralValue::True; + + auto returnStat = MakePtr(); + returnStat->expression = literal; + ifBlock->statements.Add(returnStat); + } + } + { + auto literal = MakePtr(); + literal->value = WfLiteralValue::False; + + auto returnStat = MakePtr(); + returnStat->expression = literal; + block->statements.Add(returnStat); + } + + return func; + } + +/*********************************************************************** +IValueSubscription::Close +***********************************************************************/ + + Ptr CreateBindCloseFunction(WfLexicalScopeManager* manager, BindContext& context, BindCallbackInfo& info) + { + auto func = MakePtr(); + func->name.value = L"Close"; + func->anonymity = WfFunctionAnonymity::Named; + { + auto typeInfo = TypeInfoRetriver::CreateTypeInfo(); + func->returnType = GetTypeFromTypeInfo(typeInfo.Obj()); + } + + auto block = MakePtr(); + func->statement = block; + { + auto ifStat = MakePtr(); + block->statements.Add(ifStat); + { + auto notExpr = MakePtr(); + notExpr->op = WfUnaryOperator::Not; + notExpr->operand = CreateReference(L""); + ifStat->expression = notExpr; + } + + auto ifBlock = MakePtr(); + ifStat->trueBranch = ifBlock; + { + auto literal = MakePtr(); + literal->value = WfLiteralValue::True; + + auto assign = MakePtr(); + assign->op = WfBinaryOperator::Assign; + assign->first = CreateReference(L""); + assign->second = literal; + + auto stat = MakePtr(); + stat->expression = assign; + ifBlock->statements.Add(stat); + } + FOREACH(WfExpression*, observe, context.orderedObserves) + { + CreateBindDetachStatement(ifBlock, manager, observe, context, info); + } + + for (vint i = 0; i < context.cachedExprs.Count(); i++) + { + auto cacheName = context.GetCacheVariableName(i); + auto type = manager->expressionResolvings[context.cachedExprs[i]].type; + + auto assign = MakePtr(); + assign->op = WfBinaryOperator::Assign; + assign->first = CreateReference(cacheName); + assign->second = CreateDefaultValue(type.Obj()); + + auto stat = MakePtr(); + stat->expression = assign; + ifBlock->statements.Add(stat); + } + for (vint i = 0; i < info.handlerVariables.Count(); i++) + { + auto cacheName = info.handlerVariables.Keys()[i]; + auto result = info.handlerVariables.Values()[i]; + + auto assign = MakePtr(); + assign->op = WfBinaryOperator::Assign; + assign->first = CreateReference(cacheName); + assign->second = CreateDefaultValue(result.Obj()); + + auto stat = MakePtr(); + stat->expression = assign; + ifBlock->statements.Add(stat); + } + + { + auto literal = MakePtr(); + literal->value = WfLiteralValue::True; + + auto returnStat = MakePtr(); + returnStat->expression = literal; + ifBlock->statements.Add(returnStat); + } + } + { + auto literal = MakePtr(); + literal->value = WfLiteralValue::False; + + auto returnStat = MakePtr(); + returnStat->expression = literal; + block->statements.Add(returnStat); + } + + return func; + } + +/*********************************************************************** +ExpandBindExpression +***********************************************************************/ + + void ExpandBindExpression(WfLexicalScopeManager* manager, WfBindExpression* node) + { + BindContext context; + CreateBindContextVisitor(manager, context).Call(node->expression.Obj()); + BindCallbackInfo bcInfo; + + auto newSubscription = MakePtr(); + node->expandedExpression = newSubscription; + { + auto typeInfo = TypeInfoRetriver>::CreateTypeInfo(); + newSubscription->type = GetTypeFromTypeInfo(typeInfo.Obj()); + } + { + // stable symbol order by sorting them by code + List orderedObserves; + + auto printExpression = [](WfExpression* observe) + { + stream::MemoryStream stream; + { + stream::StreamWriter writer(stream); + WfPrint(observe, WString::Empty, writer); + } + stream.SeekFromBegin(0); + { + stream::StreamReader reader(stream); + return reader.ReadToEnd(); + } + }; + + FOREACH_INDEXER(WfExpression*, parent, index, context.cachedExprs) + { + WString cacheName = context.GetCacheVariableName(index); + { + auto elementType = manager->expressionResolvings[parent].type; + newSubscription->declarations.Add(AssignNormalMember(CreateWritableVariable(cacheName, elementType.Obj()))); + } + } + + FOREACH_INDEXER(WfExpression*, observe, observeIndex, context.orderedObserves) + { + const auto& events = context.observeEvents[observe]; + FOREACH_INDEXER(IEventInfo*, ev, eventIndex, events) + { + WString handlerName = L"" + itow(observeIndex) + L"_" + itow(eventIndex); + { + auto elementType = TypeInfoRetriver>::CreateTypeInfo(); + bcInfo.handlerVariables.Add(handlerName, elementType); + newSubscription->declarations.Add(AssignNormalMember(CreateWritableVariable(handlerName, elementType.Obj()))); + } + + WString callbackName = L"" + itow(observeIndex) + L"_" + itow(eventIndex); + { + auto elementType = CopyTypeInfo(ev->GetHandlerType()); + bcInfo.callbackFunctions.Add(callbackName, elementType); + } + + CallbackInfo callbackInfo; + callbackInfo.observe = observe; + callbackInfo.eventInfo = ev; + callbackInfo.eventIndex = eventIndex; + callbackInfo.callbackName = callbackName; + callbackInfo.handlerName = handlerName; + bcInfo.observeCallbackInfos.Add(observe, callbackInfo); + } + } + newSubscription->declarations.Add(AssignNormalMember(CreateWritableVariable(L"", TypeInfoRetriver::CreateTypeInfo().Obj()))); + newSubscription->declarations.Add(AssignNormalMember(CreateWritableVariable(L"", TypeInfoRetriver::CreateTypeInfo().Obj()))); + { + auto func = MakePtr(); + func->name.value = L""; + func->anonymity = WfFunctionAnonymity::Named; + func->returnType = GetTypeFromTypeInfo(TypeInfoRetriver::CreateTypeInfo().Obj()); + + auto block = MakePtr(); + func->statement = block; + { + auto var = MakePtr(); + var->name.value = L""; + var->expression = ExpandObserveExpressionVisitor::Execute(node->expression.Obj(), context); + + auto varStat = MakePtr(); + varStat->variable = var; + block->statements.Add(varStat); + } + { + auto call = MakePtr(); + call->function = CreateReference(L"ValueChanged"); + call->arguments.Add(CreateReference(L"")); + + auto stat = MakePtr(); + stat->expression = call; + block->statements.Add(stat); + } + + newSubscription->declarations.Add(AssignNormalMember(func)); + } + FOREACH(WfExpression*, observe, context.orderedObserves) + { + FOREACH(CallbackInfo, callbackInfo, bcInfo.observeCallbackInfos[observe]) + { + auto func = MakePtr(); + func->name.value = callbackInfo.callbackName; + func->anonymity = WfFunctionAnonymity::Named; + { + auto genericType = bcInfo.callbackFunctions[callbackInfo.callbackName]->GetElementType(); + func->returnType = GetTypeFromTypeInfo(genericType->GetGenericArgument(0)); + vint count = genericType->GetGenericArgumentCount(); + for (vint i = 1; i < count; i++) + { + auto arg = MakePtr(); + arg->name.value = L"" + itow(i - 1); + arg->type = GetTypeFromTypeInfo(genericType->GetGenericArgument(i)); + func->arguments.Add(arg); + } + } + auto block = MakePtr(); + func->statement = block; + { + List affected; + affected.Add(observe); + for (vint i = 0; i < affected.Count(); i++) + { + auto current = affected[i]; + vint dependencyIndex = context.observeAffects.Keys().IndexOf(current); + if (dependencyIndex != -1) + { + FOREACH(WfExpression*, affectedObserve, context.observeAffects.GetByIndex(dependencyIndex)) + { + if (affectedObserve && !affected.Contains(affectedObserve)) + { + affected.Add(affectedObserve); + } + } + } + } + affected.Remove(observe); + + FOREACH(WfExpression*, affectedObserve, From(affected).Reverse()) + { + CreateBindDetachStatement(block, manager, affectedObserve, context, bcInfo); + } + { + SortedList assignedParents; + FOREACH(WfExpression*, affectedObserve, affected) + { + auto parent = context.GetCachedExpressionIndexRecursively(context.observeParents[affectedObserve], true); + if (!assignedParents.Contains(parent)) + { + assignedParents.Add(parent); + CreateBindCacheAssignStatement(block, affectedObserve, context); + } + } + } + FOREACH(WfExpression*, affectedObserve, affected) + { + CreateBindAttachStatement(block, manager, affectedObserve, context, bcInfo); + } + } + { + auto ref = CreateReference(L""); + + auto call = MakePtr(); + call->function = ref; + + auto stat = MakePtr(); + stat->expression = call; + block->statements.Add(stat); + } + + newSubscription->declarations.Add(AssignNormalMember(func)); + } + } + } + newSubscription->declarations.Add(AssignOverrideMember(CreateBindOpenFunction(manager, context, bcInfo))); + newSubscription->declarations.Add(AssignOverrideMember(CreateBindUpdateFunction(bcInfo))); + newSubscription->declarations.Add(AssignOverrideMember(CreateBindCloseFunction(manager, context, bcInfo))); + } + } + } +} + +/*********************************************************************** +.\ANALYZER\WFANALYZER_EXPANDMIXINCASTEXPRESSION.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace analyzer + { + using namespace collections; + using namespace reflection; + using namespace reflection::description; + +/*********************************************************************** +ExpandNewCoroutineExpression +***********************************************************************/ + + void ExpandMixinCastExpression(WfLexicalScopeManager* manager, WfMixinCastExpression* node) + { + auto sourceType = manager->expressionResolvings[node->expression.Obj()].type; + + auto newExpr = MakePtr(); + node->expandedExpression = newExpr; + + newExpr->type = CopyType(node->type); + { + auto varDecl = MakePtr(); + newExpr->declarations.Add(varDecl); + { + varDecl->classMember = MakePtr(); + varDecl->classMember->kind = WfClassMemberKind::Normal; + } + varDecl->name.value = L""; + varDecl->expression = CopyExpression(node->expression); + + if (sourceType->GetDecorator() == ITypeInfo::RawPtr) + { + auto tdType = MakePtr(sourceType->GetTypeDescriptor(), TypeInfoHint::Normal); + auto pointerType = MakePtr(tdType); + + auto castExpr = MakePtr(); + castExpr->strategy = WfTypeCastingStrategy::Strong; + castExpr->expression = varDecl->expression; + castExpr->type = GetTypeFromTypeInfo(pointerType.Obj()); + + varDecl->expression = castExpr; + } + } + List unprocessed; + unprocessed.Add(sourceType->GetTypeDescriptor()); + for (vint i = 0; i < unprocessed.Count(); i++) + { + auto td = unprocessed[i]; + vint groupCount = td->GetMethodGroupCount(); + for (vint j = 0; j < groupCount; j++) + { + auto group = td->GetMethodGroup(j); + vint methodCount = group->GetMethodCount(); + for (vint k = 0; k < methodCount; k++) + { + auto method = group->GetMethod(k); + if (!method->IsStatic()) + { + auto funcDecl = MakePtr(); + newExpr->declarations.Add(funcDecl); + { + funcDecl->classMember = MakePtr(); + funcDecl->classMember->kind = WfClassMemberKind::Override; + } + funcDecl->anonymity = WfFunctionAnonymity::Named; + funcDecl->name.value = method->GetName(); + funcDecl->returnType = GetTypeFromTypeInfo(method->GetReturn()); + vint parameterCount = method->GetParameterCount(); + for (vint l = 0; l < parameterCount; l++) + { + auto parameter = method->GetParameter(l); + auto argument = MakePtr(); + argument->name.value = parameter->GetName(); + argument->type = GetTypeFromTypeInfo(parameter->GetType()); + funcDecl->arguments.Add(argument); + } + + auto implBlock = MakePtr(); + funcDecl->statement = implBlock; + { + auto refSource = MakePtr(); + refSource->name.value = L""; + + auto memberExpr = MakePtr(); + if (sourceType->GetTypeDescriptor() == method->GetOwnerTypeDescriptor()) + { + memberExpr->parent = refSource; + } + else if (sourceType->GetTypeDescriptor()->GetMethodGroupByName(method->GetName(), true) == method->GetOwnerMethodGroup()) + { + memberExpr->parent = refSource; + } + else + { + auto castExpr = MakePtr(); + castExpr->strategy = WfTypeCastingStrategy::Strong; + castExpr->expression = refSource; + { + auto tdType = MakePtr(sourceType->GetTypeDescriptor(), TypeInfoHint::Normal); + auto pointerType = MakePtr(tdType); + castExpr->type = GetTypeFromTypeInfo(pointerType.Obj()); + } + + auto inferExpr = MakePtr(); + inferExpr->expression = castExpr; + { + auto tdType = MakePtr(method->GetOwnerTypeDescriptor(), TypeInfoHint::Normal); + auto pointerType = MakePtr(tdType); + inferExpr->type = GetTypeFromTypeInfo(pointerType.Obj()); + } + + memberExpr->parent = inferExpr; + } + memberExpr->name.value = method->GetName(); + + auto callExpr = MakePtr(); + callExpr->function = memberExpr; + + for (vint l = 0; l < parameterCount; l++) + { + auto parameter = method->GetParameter(l); + + auto argumentExpr = MakePtr(); + argumentExpr->name.value = parameter->GetName(); + callExpr->arguments.Add(argumentExpr); + } + + if (method->GetReturn()->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + auto stat = MakePtr(); + stat->expression = callExpr; + implBlock->statements.Add(stat); + } + else + { + auto stat = MakePtr(); + stat->expression = callExpr; + implBlock->statements.Add(stat); + } + } + } + } + } + + vint count = td->GetBaseTypeDescriptorCount(); + for (vint j = 0; j < count; j++) + { + auto baseTd = td->GetBaseTypeDescriptor(j); + if (!unprocessed.Contains(baseTd)) + { + unprocessed.Add(baseTd); + } + } + } + } + } + } +} + +/*********************************************************************** +.\ANALYZER\WFANALYZER_EXPANDNEWCOROUTINEEXPRESSION.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace analyzer + { + using namespace collections; + using namespace reflection; + using namespace reflection::description; + +/*********************************************************************** +FindCoroutineAwaredStatements +***********************************************************************/ + + class FindCoroutineAwaredStatementVisitor : public empty_visitor::StatementVisitor + { + public: + List& awaredStatements; + bool awared = false; + + FindCoroutineAwaredStatementVisitor(List& _awaredStatements) + :awaredStatements(_awaredStatements) + { + } + + bool Call(Ptr node) + { + if (!node) return false; + + awared = false; + node->Accept(this); + if (awared) + { + awaredStatements.Add(node.Obj()); + } + return awared; + } + + void Dispatch(WfVirtualStatement* node)override + { + awared = Call(node->expandedStatement); + } + + void Dispatch(WfCoroutineStatement* node)override + { + awared = true; + } + + void Visit(WfReturnStatement* node)override + { + awared = true; + } + + void Visit(WfIfStatement* node)override + { + bool a = Call(node->trueBranch); + bool b = Call(node->falseBranch); + awared = a || b; + } + + void Visit(WfWhileStatement* node)override + { + awared = Call(node->statement); + } + + void Visit(WfTryStatement* node)override + { + bool a = Call(node->protectedStatement); + bool b = Call(node->catchStatement); + bool c = Call(node->finallyStatement); + awared = a || b || c; + } + + void Visit(WfBlockStatement* node)override + { + bool result = false; + FOREACH(Ptr, stat, node->statements) + { + bool a = Call(stat); + result |= a; + } + awared = result; + } + }; + + void FindCoroutineAwaredStatements(Ptr node, List& awaredStatements) + { + FindCoroutineAwaredStatementVisitor(awaredStatements).Call(node); + } + +/*********************************************************************** +FindCoroutineAwaredVariables +***********************************************************************/ + + class FindCoroutineAwaredVariableVisitor : public empty_visitor::StatementVisitor + { + public: + List& awaredVariables; + + FindCoroutineAwaredVariableVisitor(List& _awaredVariables) + :awaredVariables(_awaredVariables) + { + } + + void Dispatch(WfVirtualStatement* node)override + { + node->expandedStatement->Accept(this); + } + + void Dispatch(WfCoroutineStatement* node)override + { + } + + void Visit(WfVariableStatement* node)override + { + awaredVariables.Add(node); + } + }; + + class FindCoroutineAwaredBlockVisitor : public empty_visitor::StatementVisitor + { + public: + List& awaredVariables; + + FindCoroutineAwaredBlockVisitor(List& _awaredVariables) + :awaredVariables(_awaredVariables) + { + } + + void Dispatch(WfVirtualStatement* node)override + { + // If an virtual node is coroutine awared + // than its expandedStatement is also in the list + // no need to find variables again + } + + void Dispatch(WfCoroutineStatement* node)override + { + } + + void Visit(WfBlockStatement* node)override + { + FindCoroutineAwaredVariableVisitor visitor(awaredVariables); + FOREACH(Ptr, stat, node->statements) + { + stat->Accept(&visitor); + } + } + }; + + void FindCoroutineAwaredVariables(WfStatement* node, List& awaredVariables) + { + FindCoroutineAwaredBlockVisitor visitor(awaredVariables); + node->Accept(&visitor); + } + +/*********************************************************************** +FindCoroutineReferenceRenaming +***********************************************************************/ + + void FindCoroutineReferenceRenaming(WfLexicalScopeManager* manager, List& awaredStatements, List& awaredVariables, Dictionary& referenceRenaming) + { + vint renameCounter = 0; + auto rename = [&](const WString& name) + { + if (name.Length() > 0 && name[0] == L'<') + { + vint index = INVLOC.FindFirst(name, L">", Locale::None).key; + auto category = name.Sub(1, index - 1); + auto local = name.Sub(index + 1, name.Length() - index - 1); + return L"" + local; + } + else + { + return L"" + name; + } + }; + + FOREACH(WfVariableStatement*, stat, awaredVariables) + { + auto scope = manager->nodeScopes[stat]; + auto symbol = scope->symbols[stat->variable->name.value][0]; + auto name = rename(stat->variable->name.value); + referenceRenaming.Add(symbol.Obj(), name); + } + + FOREACH(WfStatement*, stat, awaredStatements) + { + if (auto tryStat = dynamic_cast(stat)) + { + if (tryStat->catchStatement) + { + auto scope = manager->nodeScopes[tryStat->catchStatement.Obj()]->parentScope.Obj(); + auto symbol = scope->symbols[tryStat->name.value][0]; + auto name = rename(tryStat->name.value); + referenceRenaming.Add(symbol.Obj(), name); + } + } + else if (auto ifStat = dynamic_cast(stat)) + { + if (ifStat->name.value != L"") + { + auto scope = manager->nodeScopes[ifStat->trueBranch.Obj()]->parentScope.Obj(); + auto symbol = scope->symbols[ifStat->name.value][0]; + auto name = rename(ifStat->name.value); + referenceRenaming.Add(symbol.Obj(), name); + } + } + } + } + +/*********************************************************************** +FlowChart +***********************************************************************/ + + class FlowChartNode; + + class FlowChartBranch : public Object + { + public: + Ptr condition; + FlowChartNode* destination = nullptr; + }; + + enum class FlowChartNodeAction + { + None, + SetPause, + }; + + class FlowChartNode : public Object + { + public: + FlowChartNodeAction action = FlowChartNodeAction::None; + bool embedInBranch = false; + List> statements; + List> branches; + FlowChartNode* destination = nullptr; + FlowChartNode* exceptionDestination = nullptr; + FlowChartNode* pauseDestination = nullptr; + WfLexicalSymbol* exceptionVariable = nullptr; + }; + + class FlowChart : public Object + { + typedef Dictionary> TempExVarMap; + public: + List> nodes; + FlowChartNode* headNode = nullptr; + FlowChartNode* lastNode = nullptr; + TempExVarMap tempExVars; + + FlowChartNode* CreateNode(FlowChartNode* catchNode) + { + auto node = MakePtr(); + node->exceptionDestination = catchNode; + nodes.Add(node); + return node.Obj(); + } + + FlowChartNode* AppendNode(FlowChartNode* head, FlowChartNode* catchNode, FlowChartNodeAction action = FlowChartNodeAction::None) + { + auto node = CreateNode(catchNode); + node->action = action; + if (head) + { + CHECK_ERROR(head->destination == nullptr, L"FlowChart::AppendNode(FlowChartNode*, FlowChartNode*, FlowChartNodeAction)#Cannot append a new node to a flow chart node that already has a default destination."); + head->destination = node; + } + return node; + } + + FlowChartNode* EnsureAppendStatement(FlowChartNode* head, FlowChartNode* catchNode) + { + if (head == nullptr) + { + return CreateNode(catchNode); + } + else if(head->branches.Count() > 0 || head->exceptionDestination != catchNode) + { + CHECK_ERROR(head->destination == nullptr, L"FlowChart::EnsureAppendStatement(FlowChartNode*, FlowChartNode*)#Cannot append a statement to a flow chart node that already has a default destination."); + auto node = CreateNode(catchNode); + head->destination = node; + return node; + } + else + { + return head; + } + } + }; + +/*********************************************************************** +GenerateFlowChart +***********************************************************************/ + + class GenerateFlowChartModuleVisitor : public copy_visitor::ModuleVisitor + { + public: + WfLexicalScopeManager* manager; + Dictionary& referenceRenaming; + + GenerateFlowChartModuleVisitor(WfLexicalScopeManager* _manager, Dictionary& _referenceRenaming) + :manager(_manager) + , referenceRenaming(_referenceRenaming) + { + } + + void Visit(WfReferenceExpression* node)override + { + copy_visitor::ExpressionVisitor::Visit(node); + vint index = manager->expressionResolvings.Keys().IndexOf(node); + if (index != -1) + { + auto resolvingResult = manager->expressionResolvings.Values()[index]; + vint index = referenceRenaming.Keys().IndexOf(resolvingResult.symbol.Obj()); + if (index != -1) + { + result.Cast()->name.value = referenceRenaming.Values()[index]; + } + } + } + }; + + class GenerateFlowChartStatementVisitor + : public Object + , public WfStatement::IVisitor + , public WfCoroutineStatement::IVisitor + { + public: + enum class ScopeType + { + Function, + Loop, + TryCatch, + }; + + struct ScopeContext + { + ScopeContext* parent = nullptr; + ScopeType type = ScopeType::Function; + FlowChartNode* enterNode = nullptr; + FlowChartNode* leaveNode = nullptr; + ScopeContext* exitStatementScope = nullptr; + Ptr exitStatement; + }; + + public: + WfLexicalScopeManager* manager; + SortedList& awaredStatements; + Dictionary& referenceRenaming; + Ptr flowChart; + FlowChartNode* headNode; + FlowChartNode* catchNode; + ScopeContext* scopeContext; + FlowChartNode* resultHead = nullptr; + FlowChartNode* resultLast = nullptr; + + GenerateFlowChartStatementVisitor(WfLexicalScopeManager* _manager, SortedList& _awaredStatements, Dictionary& _referenceRenaming, Ptr _flowChart, FlowChartNode* _headNode, FlowChartNode* _catchNode, ScopeContext* _scopeContext) + :manager(_manager) + , awaredStatements(_awaredStatements) + , referenceRenaming(_referenceRenaming) + , flowChart(_flowChart) + , headNode(_headNode) + , catchNode(_catchNode) + , scopeContext(_scopeContext) + { + } + +#define COPY_AST(STATEMENT) GenerateFlowChartModuleVisitor(manager, referenceRenaming).CreateField(STATEMENT) + + void AppendAwaredStatement(FlowChartNode* catchNode, ScopeContext* scopeContext, Ptr statement) + { + if (!resultHead) + { + resultHead = flowChart->EnsureAppendStatement(headNode, catchNode); + resultLast = resultHead; + } + resultLast = Execute(resultHead, catchNode, scopeContext, statement).value; + } + + void AppendUnawaredCopiedStatement(FlowChartNode* catchNode, ScopeContext* scopeContext, Ptr statement) + { + if (!resultHead) + { + resultHead = flowChart->EnsureAppendStatement(headNode, catchNode); + resultLast = resultHead; + } + resultHead->statements.Add(statement); + } + + ScopeContext* InlineScopeExitCode(ScopeType untilScopeType, bool exclusive) + { + auto current = scopeContext; + while (current) + { + if (exclusive && current->type == untilScopeType) break; + if (current->exitStatement) + { + AppendAwaredStatement(catchNode, current->exitStatementScope, current->exitStatement); + } + if (!exclusive && current->type == untilScopeType) break; + current = current->parent; + } + return current; + } + + static Pair Execute(WfLexicalScopeManager* manager, SortedList& awaredStatements, Dictionary& referenceRenaming, Ptr flowChart, FlowChartNode* headNode, FlowChartNode* catchNode, ScopeContext* scopeContext, Ptr statement) + { + GenerateFlowChartStatementVisitor visitor(manager, awaredStatements, referenceRenaming, flowChart, headNode, catchNode, scopeContext); + if (awaredStatements.Contains(statement.Obj())) + { + statement->Accept(&visitor); + } + else + { + visitor.AppendUnawaredCopiedStatement(catchNode, scopeContext, COPY_AST(statement)); + } + return{ visitor.resultHead,visitor.resultLast }; + } + + Pair Execute(FlowChartNode* headNode, FlowChartNode* catchNode, ScopeContext* scopeContext, Ptr statement) + { + return Execute(manager, awaredStatements, referenceRenaming, flowChart, headNode, catchNode, scopeContext, statement); + } + + void Visit(WfBreakStatement* node)override + { + auto targetContext = InlineScopeExitCode(ScopeType::Loop, false); + resultLast->destination = targetContext->leaveNode; + } + + void Visit(WfContinueStatement* node)override + { + auto targetContext = InlineScopeExitCode(ScopeType::Loop, true); + resultLast->destination = targetContext->enterNode; + } + + void Visit(WfReturnStatement* node)override + { + auto targetContext = InlineScopeExitCode(ScopeType::Function, false); + AppendUnawaredCopiedStatement(catchNode, scopeContext, COPY_AST(node)); + resultLast->destination = targetContext->leaveNode; + } + + void Visit(WfDeleteStatement* node)override + { + AppendUnawaredCopiedStatement(catchNode, scopeContext, COPY_AST(node)); + } + + void Visit(WfRaiseExceptionStatement* node)override + { + AppendUnawaredCopiedStatement(catchNode, scopeContext, COPY_AST(node)); + } + + void GenerateIfWithVar(WfIfStatement* node) + { + resultHead = flowChart->EnsureAppendStatement(headNode, catchNode); + { + auto branch = MakePtr(); + resultHead->branches.Add(branch); + + auto scope = manager->nodeScopes[node]; + auto symbol = scope->symbols[node->name.value][0].Obj(); + { + auto refExpr = MakePtr(); + refExpr->name.value = referenceRenaming[symbol]; + + auto assignExpr = MakePtr(); + assignExpr->op = WfBinaryOperator::Assign; + assignExpr->first = refExpr; + assignExpr->second = COPY_AST(node->expression); + + auto stat = MakePtr(); + stat->expression = assignExpr; + + SetCodeRange((Ptr)stat, node->expression->codeRange); + resultHead->statements.Add(stat); + } + { + auto refExpr = MakePtr(); + refExpr->name.value = referenceRenaming[symbol]; + + auto testExpr = MakePtr(); + testExpr->test = WfTypeTesting::IsNotNull; + testExpr->expression = refExpr; + + SetCodeRange((Ptr)testExpr, node->expression->codeRange); + branch->condition = testExpr; + } + } + resultLast = flowChart->CreateNode(catchNode); + + { + auto pair = Execute(nullptr, catchNode, scopeContext, node->trueBranch); + pair.value->destination = resultLast; + resultHead->branches[0]->destination = pair.key; + } + + if (node->falseBranch) + { + auto pair = Execute(nullptr, catchNode, scopeContext, node->falseBranch); + pair.value->destination = resultLast; + resultHead->destination = pair.key; + } + else + { + resultHead->destination = resultLast; + } + } + + void GenerateIfWithoutVar(WfIfStatement* node) + { + resultHead = flowChart->EnsureAppendStatement(headNode, catchNode); + resultLast = flowChart->CreateNode(catchNode); + + while (true) + { + auto branch = MakePtr(); + resultHead->branches.Add(branch); + branch->condition = COPY_AST(node->expression); + + auto pair = Execute(nullptr, catchNode, scopeContext, node->trueBranch); + pair.value->destination = resultLast; + branch->destination = pair.key; + + auto next = dynamic_cast(node->falseBranch.Obj()); + if (next && next->name.value == L"") + { + node = next; + } + else + { + break; + } + } + + if (node->falseBranch) + { + auto pair = Execute(nullptr, catchNode, scopeContext, node->falseBranch); + pair.value->destination = resultLast; + resultHead->destination = pair.key; + } + else + { + resultHead->destination = resultLast; + } + } + + void Visit(WfIfStatement* node)override + { + if (node->name.value == L"") + { + GenerateIfWithoutVar(node); + } + else + { + GenerateIfWithVar(node); + } + } + + void Visit(WfWhileStatement* node)override + { + resultHead = flowChart->EnsureAppendStatement(headNode, catchNode); + { + auto branch = MakePtr(); + resultHead->branches.Add(branch); + branch->condition = COPY_AST(node->condition); + } + auto loopEnd = flowChart->CreateNode(catchNode); + { + auto branch = MakePtr(); + loopEnd->branches.Add(branch); + branch->condition = COPY_AST(node->condition); + } + resultLast = flowChart->CreateNode(catchNode); + + ScopeContext loopContext; + loopContext.parent = scopeContext; + loopContext.type = ScopeType::Loop; + loopContext.enterNode = loopEnd; + loopContext.leaveNode = resultLast; + auto pair = Execute(nullptr, catchNode, &loopContext, node->statement); + pair.value->destination = loopEnd; + + resultHead->branches[0]->destination = pair.key; + loopEnd->branches[0]->destination = pair.key; + resultHead->destination = resultLast; + loopEnd->destination = resultLast; + } + + WfLexicalSymbol* GetExceptionVariableSymbol(WfTryStatement* node) + { + if (node->catchStatement) + { + auto scope = manager->nodeScopes[node->catchStatement.Obj()]->parentScope.Obj(); + auto symbol = scope->symbols[node->name.value][0]; + return symbol.Obj(); + } + else + { + vint index = flowChart->tempExVars.Keys().IndexOf(node); + if (index == -1) + { + auto symbol = MakePtr(nullptr); + symbol->name = L"ex"; + symbol->typeInfo = TypeInfoRetriver>::CreateTypeInfo(); + flowChart->tempExVars.Add(node, symbol); + + referenceRenaming.Add(symbol.Obj(), L"tempExVars.Count() - 1) + L">ex"); + return symbol.Obj(); + } + return flowChart->tempExVars.Values()[index].Obj(); + } + } + + Pair GenerateCatch(WfTryStatement* node, FlowChartNode* catchNode) + { + auto pair = Execute(nullptr, catchNode, scopeContext, node->catchStatement); + pair.key->exceptionVariable = GetExceptionVariableSymbol(node); + return pair; + } + + Pair GenerateFinally(WfTryStatement* node, FlowChartNode* catchNode) + { + return Execute(nullptr, catchNode, scopeContext, node->finallyStatement); + } + + Pair GenerateFinallyAndRaise(WfTryStatement* node, FlowChartNode* catchNode) + { + auto pair = Execute(nullptr, catchNode, scopeContext, node->finallyStatement); + auto raiseNode = flowChart->CreateNode(catchNode); + { + pair.key->exceptionVariable = GetExceptionVariableSymbol(node); + + auto refExpr = MakePtr(); + refExpr->name.value = referenceRenaming[pair.key->exceptionVariable]; + + auto memberExpr = MakePtr(); + memberExpr->parent = refExpr; + memberExpr->name.value = L"Message"; + + auto raiseStat = MakePtr(); + raiseStat->expression = memberExpr; + + SetCodeRange((Ptr)raiseStat, node->finallyStatement->codeRange); + raiseNode->statements.Add(raiseStat); + } + pair.value->destination = raiseNode; + return { pair.key,raiseNode }; + } + + void Visit(WfTryStatement* node)override + { + ScopeContext tryContext; + tryContext.parent = scopeContext; + tryContext.type = ScopeType::TryCatch; + if (node->finallyStatement) + { + tryContext.exitStatementScope = scopeContext; + tryContext.exitStatement = node->finallyStatement; + } + + if (node->catchStatement && !node->finallyStatement) + { + auto pairCatch = GenerateCatch(node, catchNode); + AppendAwaredStatement(pairCatch.key, &tryContext, node->protectedStatement); + + auto endNode = flowChart->CreateNode(catchNode); + pairCatch.value->destination = endNode; + resultLast->destination = endNode; + resultLast = endNode; + } + else if (!node->catchStatement && node->finallyStatement) + { + auto pairFinallyAndRaise = GenerateFinallyAndRaise(node, catchNode); + AppendAwaredStatement(pairFinallyAndRaise.key, &tryContext, node->protectedStatement); + auto pairFinally = GenerateFinally(node, catchNode); + + auto endNode = flowChart->CreateNode(catchNode); + resultLast->destination = pairFinally.key; + pairFinally.value->destination = endNode; + pairFinallyAndRaise.value->destination = endNode; + resultLast = endNode; + } + else + { + auto pairFinallyAndRaise = GenerateFinallyAndRaise(node, catchNode); + auto pairCatch = GenerateCatch(node, pairFinallyAndRaise.key); + AppendAwaredStatement(pairCatch.key, &tryContext, node->protectedStatement); + auto pairFinally = GenerateFinally(node, catchNode); + + auto endNode = flowChart->CreateNode(catchNode); + resultLast->destination = pairFinally.key; + pairCatch.value->destination = pairFinally.key; + pairFinally.value->destination = endNode; + pairFinallyAndRaise.value->destination = endNode; + resultLast = endNode; + } + } + + void Visit(WfBlockStatement* node)override + { + resultHead = flowChart->EnsureAppendStatement(headNode, catchNode); + resultLast = resultHead; + + FOREACH_INDEXER(Ptr, stat, index, node->statements) + { + auto pair = Execute(resultLast, catchNode, scopeContext, stat); + resultLast = pair.value; + } + } + + void Visit(WfVariableStatement* node)override + { + resultHead = flowChart->EnsureAppendStatement(headNode, catchNode); + resultLast = resultHead; + + auto scope = manager->nodeScopes[node]; + auto symbol = scope->symbols[node->variable->name.value][0].Obj(); + + auto refExpr = MakePtr(); + refExpr->name.value = referenceRenaming[symbol]; + + auto assignExpr = MakePtr(); + assignExpr->op = WfBinaryOperator::Assign; + assignExpr->first = refExpr; + assignExpr->second = COPY_AST(node->variable->expression); + + auto stat = MakePtr(); + stat->expression = assignExpr; + + SetCodeRange((Ptr)stat, node->codeRange); + AppendUnawaredCopiedStatement(catchNode, scopeContext, stat); + } + + void Visit(WfExpressionStatement* node)override + { + AppendUnawaredCopiedStatement(catchNode, scopeContext, COPY_AST(node)); + } + + void Visit(WfVirtualStatement* node)override + { + node->expandedStatement->Accept(this); + } + + void Visit(WfCoroutineStatement* node)override + { + node->Accept(static_cast(this)); + } + + void Visit(WfCoPauseStatement* node)override + { + resultHead = flowChart->AppendNode(headNode, catchNode, FlowChartNodeAction::SetPause); + resultLast = resultHead; + if (node->statement) + { + AppendUnawaredCopiedStatement(catchNode, scopeContext, COPY_AST(node->statement)); + } + + resultLast = flowChart->AppendNode(resultLast, catchNode); + { + auto pauseStat = MakePtr(); + SetCodeRange((Ptr)pauseStat, node->codeRange); + resultLast->statements.Add(pauseStat); + } + resultLast = flowChart->AppendNode(resultLast, catchNode); + resultHead->pauseDestination = resultLast; + } + + void Visit(WfCoOperatorStatement* node)override + { + CHECK_FAIL(L"GenerateFlowChartStatementVisitor::Visit(WfCoOperatorStatement*)#Internal error, co-operator statement is not allowed in $coroutine expression."); + } + +#undef COPY_STATEMENT + }; + + Ptr GenerateFlowChart(WfLexicalScopeManager* manager, List& awaredStatements, List& awaredVariables, Dictionary& referenceRenaming, Ptr statement) + { + auto flowChart = MakePtr(); + SortedList sortedAwaredStatements; + CopyFrom(sortedAwaredStatements, awaredStatements, true); + CopyFrom(sortedAwaredStatements, awaredVariables, true); + + auto endNode = flowChart->CreateNode(nullptr); + GenerateFlowChartStatementVisitor::ScopeContext context; + context.leaveNode = endNode; + + auto pair = GenerateFlowChartStatementVisitor::Execute(manager, sortedAwaredStatements, referenceRenaming, flowChart, nullptr, nullptr, &context, statement); + pair.value->destination = endNode; + + flowChart->headNode = pair.key; + flowChart->lastNode = endNode; + return flowChart; + } + +/*********************************************************************** +RemoveUnnecessaryNodes +***********************************************************************/ + + void CalculateEnterCounts(Ptr flowChart, Dictionary& enterCounts) + { + const auto& keys = enterCounts.Keys(); + auto& values = const_cast::ValueContainer&>(enterCounts.Values()); + + FOREACH(Ptr, node, flowChart->nodes) + { + enterCounts.Add(node.Obj(), 0); + } + enterCounts.Set(flowChart->headNode, 1); + + auto Inc = [&](FlowChartNode* node) + { + if (node) + { + vint index = keys.IndexOf(node); + values[index]++; + } + }; + + FOREACH(Ptr, node, flowChart->nodes) + { + Inc(node->destination); + Inc(node->exceptionDestination); + Inc(node->pauseDestination); + FOREACH(Ptr, branch, node->branches) + { + Inc(branch->destination); + } + } + } + + void RemoveUnnecessaryNodesPass(Ptr flowChart) + { + Dictionary enterCounts; + CalculateEnterCounts(flowChart, enterCounts); + + SortedList mergableNodes; + List> keepingNodes; + FOREACH(Ptr, node, flowChart->nodes) + { + bool mergable = false; + + if (node->branches.Count() == 0 && node->destination) + { + if (node->statements.Count() == 0 && node->action == FlowChartNodeAction::None && !node->exceptionVariable) + { + mergable = true; + } + else if (node->destination->action == FlowChartNodeAction::None && !node->destination->exceptionVariable && enterCounts[node->destination] == 1) + { + mergable = true; + } + } + + if (mergable) + { + mergableNodes.Add(node.Obj()); + } + else + { + keepingNodes.Add(node); + } + } + + Dictionary merging; + FOREACH(FlowChartNode*, node, mergableNodes) + { + auto current = node; + while (mergableNodes.Contains(current)) + { + auto target = current->destination; + + if (current->action == FlowChartNodeAction::SetPause) + { + target->action = current->action; + target->pauseDestination = current->pauseDestination; + } + if (current->exceptionVariable) + { + target->exceptionVariable = current->exceptionVariable; + } + if (current->statements.Count() > 0) + { + CopyFrom(current->statements, target->statements, true); + CopyFrom(target->statements, current->statements); + current->statements.Clear(); + } + + current = target; + } + merging.Add(node, current); + } + +#define MERGE_FLOW_CHART_NODE(DESTINATION)\ + {\ + vint index = merging.Keys().IndexOf(DESTINATION);\ + if (index != -1) DESTINATION = merging.Values()[index];\ + }\ + + FOREACH(Ptr, node, flowChart->nodes) + { + if (!mergableNodes.Contains(node.Obj())) + { + MERGE_FLOW_CHART_NODE(node->destination); + MERGE_FLOW_CHART_NODE(node->exceptionDestination); + MERGE_FLOW_CHART_NODE(node->pauseDestination); + FOREACH(Ptr, branch, node->branches) + { + MERGE_FLOW_CHART_NODE(branch->destination); + } + } + } + MERGE_FLOW_CHART_NODE(flowChart->headNode); + MERGE_FLOW_CHART_NODE(flowChart->lastNode); + +#undef MERGE_FLOW_CHART_NODE + + vint headNodeIndex = keepingNodes.IndexOf(flowChart->headNode); + if (headNodeIndex != 0) + { + auto headNode = keepingNodes[headNodeIndex]; + keepingNodes.RemoveAt(headNodeIndex); + keepingNodes.Insert(0, headNode); + } + CopyFrom(flowChart->nodes, keepingNodes); + } + + void RemoveUnnecessaryNodes(Ptr flowChart) + { + RemoveUnnecessaryNodesPass(flowChart); + + FOREACH(Ptr, node, flowChart->nodes) + { + if (node->pauseDestination && node->statements.Count() > 0 && node->statements[node->statements.Count() - 1].Cast()) + { + node->destination = nullptr; + } + } + + Dictionary enterCounts; + CalculateEnterCounts(flowChart, enterCounts); + FOREACH(Ptr, node, flowChart->nodes) + { + FOREACH(Ptr, branch, node->branches) + { + if (enterCounts[branch->destination] == 1) + { + branch->destination->embedInBranch = true; + } + } + } + } + +/*********************************************************************** +GenerateSetStatus +***********************************************************************/ + + Ptr GenerateSetStatus(const WString& status) + { + auto refExpr = MakePtr(); + refExpr->name.value = status; + + auto funcExpr = MakePtr(); + funcExpr->name.value = L"SetStatus"; + + auto callExpr = MakePtr(); + callExpr->function = funcExpr; + callExpr->arguments.Add(refExpr); + + auto stat = MakePtr(); + stat->expression = callExpr; + + return stat; + }; + +/*********************************************************************** +GenerateSetCoState +***********************************************************************/ + + Ptr GenerateSetCoState(List& nodeOrders, FlowChartNode* node) + { + auto refState = MakePtr(); + refState->name.value = L""; + + auto intState = MakePtr(); + intState->value.value = itow(nodeOrders.IndexOf(node)); + + auto assignExpr = MakePtr(); + assignExpr->op = WfBinaryOperator::Assign; + assignExpr->first = refState; + assignExpr->second = intState; + + auto stat = MakePtr(); + stat->expression = assignExpr; + + return stat; + }; + +/*********************************************************************** +ExpandExceptionDestination +***********************************************************************/ + + Ptr ExpandExceptionDestination(FlowChartNode* catchNode, Dictionary& referenceRenaming, List& nodeOrders, Ptr stateBlock) + { + ///////////////////////////////////////////////////////////////////////////// + // try { ... } + ///////////////////////////////////////////////////////////////////////////// + + auto nodeTryStat = MakePtr(); + auto nodeBlock = MakePtr(); + nodeTryStat->protectedStatement = nodeBlock; + + ///////////////////////////////////////////////////////////////////////////// + // catch() + // { + // THE_EXCEPTION_VARIABLE = ; + // = THE_EXCEPTION_STATE; + // continue; + // } + ///////////////////////////////////////////////////////////////////////////// + + nodeTryStat->name.value = L""; + auto catchBlock = MakePtr(); + nodeTryStat->catchStatement = catchBlock; + { + auto refTarget = MakePtr(); + refTarget->name.value = referenceRenaming[catchNode->exceptionVariable]; + + auto refEx = MakePtr(); + refEx->name.value = L""; + + auto assignExpr = MakePtr(); + assignExpr->op = WfBinaryOperator::Assign; + assignExpr->first = refTarget; + assignExpr->second = refEx; + + auto stat = MakePtr(); + stat->expression = assignExpr; + catchBlock->statements.Add(stat); + } + catchBlock->statements.Add(GenerateSetCoState(nodeOrders, catchNode)); + catchBlock->statements.Add(MakePtr()); + + stateBlock->statements.Add(nodeTryStat); + return nodeBlock; + } + +/*********************************************************************** +ExpandFlowChartNode +***********************************************************************/ + + void ExpandFlowChartNode(Ptr flowChart, FlowChartNode* flowChartNode, Dictionary& referenceRenaming, List& nodeOrders, FlowChartNode* parentCatchNode, Ptr stateBlock) + { + if (flowChartNode->action == FlowChartNodeAction::SetPause) + { + ///////////////////////////////////////////////////////////////////////////// + // = THE_NEXT_STATE; + // SetStatus(Waiting); + ///////////////////////////////////////////////////////////////////////////// + stateBlock->statements.Add(GenerateSetStatus(L"Waiting")); + stateBlock->statements.Add(GenerateSetCoState(nodeOrders, flowChartNode->pauseDestination)); + } + + auto nodeBlock = stateBlock; + if (flowChartNode->exceptionDestination && parentCatchNode != flowChartNode->exceptionDestination) + { + nodeBlock = ExpandExceptionDestination(flowChartNode->exceptionDestination, referenceRenaming, nodeOrders, stateBlock); + } + + bool exited = false; + FOREACH(Ptr, stat, flowChartNode->statements) + { + if (stat.Cast()) + { + exited = true; + ///////////////////////////////////////////////////////////////////////////// + // return; + ///////////////////////////////////////////////////////////////////////////// + nodeBlock->statements.Add(MakePtr()); + } + else if (stat.Cast()) + { + exited = true; + ///////////////////////////////////////////////////////////////////////////// + // SetStatus(Stopped); + // return; + ///////////////////////////////////////////////////////////////////////////// + stateBlock->statements.Add(GenerateSetStatus(L"Stopped")); + { + auto returnStat = MakePtr(); + stateBlock->statements.Add(returnStat); + } + } + else + { + if (stat.Cast()) + { + exited = true; + } + nodeBlock->statements.Add(stat); + } + } + + FOREACH(Ptr, branch, flowChartNode->branches) + { + auto ifStat = MakePtr(); + ifStat->expression = branch->condition; + + auto trueBlock = MakePtr(); + ifStat->trueBranch = trueBlock; + + if (branch->destination->embedInBranch) + { + ExpandFlowChartNode(flowChart, branch->destination, referenceRenaming, nodeOrders, flowChartNode->exceptionDestination, trueBlock); + } + else + { + trueBlock->statements.Add(GenerateSetCoState(nodeOrders, branch->destination)); + trueBlock->statements.Add(MakePtr()); + } + + nodeBlock->statements.Add(ifStat); + } + + if (!exited) + { + if (flowChartNode == flowChart->lastNode) + { + ///////////////////////////////////////////////////////////////////////////// + // SetStatus(Stopped); + // return; + ///////////////////////////////////////////////////////////////////////////// + stateBlock->statements.Add(GenerateSetStatus(L"Stopped")); + { + auto returnStat = MakePtr(); + stateBlock->statements.Add(returnStat); + } + } + else + { + ///////////////////////////////////////////////////////////////////////////// + // = THE_NEXT_STATE; + // continue; + ///////////////////////////////////////////////////////////////////////////// + stateBlock->statements.Add(GenerateSetCoState(nodeOrders, flowChartNode->destination)); + stateBlock->statements.Add(MakePtr()); + } + } + } + +/*********************************************************************** +ExpandNewCoroutineExpression +***********************************************************************/ + + void ExpandNewCoroutineExpression(WfLexicalScopeManager* manager, WfNewCoroutineExpression* node) + { + List awaredStatements; + List awaredVariables; + Dictionary referenceRenaming; + + FindCoroutineAwaredStatements(node->statement, awaredStatements); + FOREACH(WfStatement*, stat, awaredStatements) + { + FindCoroutineAwaredVariables(stat, awaredVariables); + } + FindCoroutineReferenceRenaming(manager, awaredStatements, awaredVariables, referenceRenaming); + auto flowChart = GenerateFlowChart(manager, awaredStatements, awaredVariables, referenceRenaming, node->statement); + RemoveUnnecessaryNodes(flowChart); + + List nodeOrders; + CopyFrom( + nodeOrders, + From(flowChart->nodes) + .Select([](Ptr node) + { + return node.Obj(); + }) + .Where([](FlowChartNode* node) + { + return !node->embedInBranch; + }) + ); + + auto newExpr = MakePtr(); + node->expandedExpression = newExpr; + newExpr->type = GetTypeFromTypeInfo(TypeInfoRetriver>::CreateTypeInfo().Obj()); + + ///////////////////////////////////////////////////////////////////////////// + // Coroutine Awared Variables + ///////////////////////////////////////////////////////////////////////////// + + FOREACH(WfLexicalSymbol*, symbol, + From(referenceRenaming.Keys()) + .OrderBy([&](WfLexicalSymbol* a, WfLexicalSymbol* b) + { + return WString::Compare(referenceRenaming[a], referenceRenaming[b]); + })) + { + auto varDecl = MakePtr(); + newExpr->declarations.Add(varDecl); + { + auto member = MakePtr(); + member->kind = WfClassMemberKind::Normal; + varDecl->classMember = member; + } + + varDecl->name.value = referenceRenaming[symbol]; + varDecl->type = GetTypeFromTypeInfo(symbol->typeInfo.Obj()); + varDecl->expression = CreateDefaultValue(symbol->typeInfo.Obj()); + } + + ///////////////////////////////////////////////////////////////////////////// + // + ///////////////////////////////////////////////////////////////////////////// + + { + auto varDecl = MakePtr(); + newExpr->declarations.Add(varDecl); + { + auto member = MakePtr(); + member->kind = WfClassMemberKind::Normal; + varDecl->classMember = member; + } + + varDecl->name.value = L""; + varDecl->type = GetTypeFromTypeInfo(TypeInfoRetriver::CreateTypeInfo().Obj()); + + auto stateExpr = MakePtr(); + stateExpr->value.value = L"0"; + varDecl->expression = stateExpr; + } + + ///////////////////////////////////////////////////////////////////////////// + // prop Failure : Exception^ {const, not observe} + ///////////////////////////////////////////////////////////////////////////// + + { + auto propDecl = MakePtr(); + newExpr->declarations.Add(propDecl); + { + auto member = MakePtr(); + member->kind = WfClassMemberKind::Override; + propDecl->classMember = member; + } + + propDecl->name.value = L"Failure"; + propDecl->type = GetTypeFromTypeInfo(TypeInfoRetriver>::CreateTypeInfo().Obj()); + propDecl->configConst = WfAPConst::Readonly; + propDecl->configObserve = WfAPObserve::NotObservable; + + auto nullExpr = MakePtr(); + nullExpr->value = WfLiteralValue::Null; + propDecl->expression = nullExpr; + } + + ///////////////////////////////////////////////////////////////////////////// + // prop Status : CoroutineStatus^ {const, not observe} + ///////////////////////////////////////////////////////////////////////////// + + { + auto propDecl = MakePtr(); + newExpr->declarations.Add(propDecl); + { + auto member = MakePtr(); + member->kind = WfClassMemberKind::Override; + propDecl->classMember = member; + } + + propDecl->name.value = L"Status"; + propDecl->type = GetTypeFromTypeInfo(TypeInfoRetriver::CreateTypeInfo().Obj()); + propDecl->configConst = WfAPConst::Readonly; + propDecl->configObserve = WfAPObserve::NotObservable; + + auto refExpr = MakePtr(); + refExpr->name.value = L"Waiting"; + + propDecl->expression = refExpr; + } + + ///////////////////////////////////////////////////////////////////////////// + // func Resume( : bool, : CoroutineResult^) : void + ///////////////////////////////////////////////////////////////////////////// + + { + auto funcDecl = MakePtr(); + newExpr->declarations.Add(funcDecl); + { + auto member = MakePtr(); + member->kind = WfClassMemberKind::Override; + funcDecl->classMember = member; + } + + funcDecl->name.value = L"Resume"; + funcDecl->returnType = GetTypeFromTypeInfo(TypeInfoRetriver::CreateTypeInfo().Obj()); + { + auto argument = MakePtr(); + funcDecl->arguments.Add(argument); + argument->name.value = L""; + argument->type = GetTypeFromTypeInfo(TypeInfoRetriver::CreateTypeInfo().Obj()); + } + { + auto argument = MakePtr(); + funcDecl->arguments.Add(argument); + if (node->name.value == L"") + { + argument->name.value = L""; + } + else + { + argument->name.value = node->name.value; + } + argument->type = GetTypeFromTypeInfo(TypeInfoRetriver>::CreateTypeInfo().Obj()); + } + + auto block = MakePtr(); + funcDecl->statement = block; + + ///////////////////////////////////////////////////////////////////////////// + // if (Status != Waiting) raise "..."; + ///////////////////////////////////////////////////////////////////////////// + + { + auto ifStat = MakePtr(); + { + auto refStatus = MakePtr(); + refStatus->name.value = L"Status"; + + auto waitingStatus = MakePtr(); + waitingStatus->parent = GetExpressionFromTypeDescriptor(description::GetTypeDescriptor()); + waitingStatus->name.value = L"Waiting"; + + auto compExpr = MakePtr(); + compExpr->op = WfBinaryOperator::NE; + compExpr->first = refStatus; + compExpr->second = waitingStatus; + + ifStat->expression = compExpr; + } + + auto trueBlock = MakePtr(); + ifStat->trueBranch = trueBlock; + { + auto exExpr = MakePtr(); + exExpr->value.value = L"Resume should be called only when the coroutine is in the waiting status."; + + auto raiseStat = MakePtr(); + raiseStat->expression = exExpr; + trueBlock->statements.Add(raiseStat); + } + block->statements.Add(ifStat); + } + + ///////////////////////////////////////////////////////////////////////////// + // SetStatus(Executing); + ///////////////////////////////////////////////////////////////////////////// + + block->statements.Add(GenerateSetStatus(L"Executing")); + { + ///////////////////////////////////////////////////////////////////////////// + // try { ... } + ///////////////////////////////////////////////////////////////////////////// + + auto tryStat = MakePtr(); + auto tryBlock = MakePtr(); + tryStat->protectedStatement = tryBlock; + { + ///////////////////////////////////////////////////////////////////////////// + // while (true) { ... } + ///////////////////////////////////////////////////////////////////////////// + + auto whileStat = MakePtr(); + { + auto trueExpr = MakePtr(); + trueExpr->value = WfLiteralValue::True; + whileStat->condition = trueExpr; + } + + auto whileBlock = MakePtr(); + whileStat->statement = whileBlock; + + using GroupPair = Pair>; + auto nodeByCatches = From(nodeOrders) + .GroupBy([](FlowChartNode* node) + { + return node->exceptionDestination; + }) + .OrderBy([&](const GroupPair& p1, const GroupPair& p2) + { + return nodeOrders.IndexOf(p1.key) - nodeOrders.IndexOf(p2.key); + }); + + FOREACH(GroupPair, group, nodeByCatches) + { + auto catchNode = group.key; + auto groupBlock = whileBlock; + if (catchNode) + { + groupBlock = ExpandExceptionDestination(catchNode, referenceRenaming, nodeOrders, whileBlock); + } + + FOREACH(FlowChartNode*, flowChartNode, group.value) + { + ///////////////////////////////////////////////////////////////////////////// + // if ( == THE_CURRENT_STATE) { ... } + ///////////////////////////////////////////////////////////////////////////// + + auto ifStat = MakePtr(); + groupBlock->statements.Add(ifStat); + { + auto refState = MakePtr(); + refState->name.value = L""; + + auto intState = MakePtr(); + intState->value.value = itow(nodeOrders.IndexOf(flowChartNode)); + + auto compExpr = MakePtr(); + compExpr->op = WfBinaryOperator::EQ; + compExpr->first = refState; + compExpr->second = intState; + + ifStat->expression = compExpr; + } + + auto stateBlock = MakePtr(); + ifStat->trueBranch = stateBlock; + { + ExpandFlowChartNode(flowChart, flowChartNode, referenceRenaming, nodeOrders, catchNode, stateBlock); + } + } + } + tryBlock->statements.Add(whileStat); + } + + ///////////////////////////////////////////////////////////////////////////// + // catch() + // { + // SetFailure(); + // SetStatus(Stopped); + // if () raise ; + // } + ///////////////////////////////////////////////////////////////////////////// + + tryStat->name.value = L""; + auto catchBlock = MakePtr(); + tryStat->catchStatement = catchBlock; + { + auto refExpr = MakePtr(); + refExpr->name.value = L""; + + auto funcExpr = MakePtr(); + funcExpr->name.value = L"SetFailure"; + + auto callExpr = MakePtr(); + callExpr->function = funcExpr; + callExpr->arguments.Add(refExpr); + + auto stat = MakePtr(); + stat->expression = callExpr; + catchBlock->statements.Add(stat); + } + catchBlock->statements.Add(GenerateSetStatus(L"Stopped")); + { + auto refExpr = MakePtr(); + refExpr->name.value = L""; + + auto ifStat = MakePtr(); + ifStat->expression = refExpr; + + auto trueBlock = MakePtr(); + ifStat->trueBranch = trueBlock; + { + auto raiseStat = MakePtr(); + trueBlock->statements.Add(raiseStat); + } + catchBlock->statements.Add(ifStat); + } + + block->statements.Add(tryStat); + } + } + } + } + } +} + +/*********************************************************************** +.\ANALYZER\WFANALYZER_EXPANDSTATEMENT.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace analyzer + { + using namespace collections; + using namespace parsing; + using namespace reflection; + using namespace reflection::description; + +/*********************************************************************** +ExpandSwitchStatement +***********************************************************************/ + + void ExpandSwitchStatement(WfLexicalScopeManager* manager, WfSwitchStatement* node) + { + auto block = MakePtr(); + node->expandedStatement = block; + auto varName = L"" + itow(manager->usedTempVars++); + + { + auto result = manager->expressionResolvings[node->expression.Obj()]; + auto decl = MakePtr(); + decl->name.value = varName; + decl->type = GetTypeFromTypeInfo(result.type.Obj()); + decl->expression = CopyExpression(node->expression); + + auto stat = MakePtr(); + stat->variable = decl; + block->statements.Add(stat); + } + + Ptr rootIfStat; + auto tailIfStat = &rootIfStat; + + FOREACH(Ptr, switchCase, node->caseBranches) + { + auto ifStat = MakePtr(); + *tailIfStat = ifStat; + tailIfStat = &ifStat->falseBranch; + + { + auto refExpr = MakePtr(); + refExpr->name.value = varName; + + auto inferExpr = MakePtr(); + inferExpr->expression= CopyExpression(switchCase->expression); + { + auto result = manager->expressionResolvings[switchCase->expression.Obj()]; + inferExpr->type = GetTypeFromTypeInfo(result.type.Obj()); + } + + auto compare = MakePtr(); + compare->first = refExpr; + compare->second = inferExpr; + compare->op = WfBinaryOperator::EQ; + + ifStat->expression = compare; + } + ifStat->trueBranch = CopyStatement(switchCase->statement); + } + + if (node->defaultBranch) + { + *tailIfStat = CopyStatement(node->defaultBranch); + } + + if (rootIfStat) + { + block->statements.Add(rootIfStat); + } + } + +/*********************************************************************** +ExpandForEachStatement +***********************************************************************/ + + Ptr GenerateForEachStepStatement(WfForEachStatement* node) + { + auto refVar1 = MakePtr(); + refVar1->name.value = node->name.value; + + auto refVar2 = MakePtr(); + refVar2->name.value = node->name.value; + + auto one = MakePtr(); + one->value.value = L"1"; + + auto stepExpr = MakePtr(); + stepExpr->first = refVar2; + stepExpr->second = one; + stepExpr->op = node->direction == WfForEachDirection::Normal ? WfBinaryOperator::Add : WfBinaryOperator::Sub; + + auto assignExpr = MakePtr(); + assignExpr->first = refVar1; + assignExpr->second = stepExpr; + assignExpr->op = WfBinaryOperator::Assign; + + auto stat = MakePtr(); + stat->expression = assignExpr; + return stat; + } + + class CopyForEachRangeBodyVisitor + : public copy_visitor::ModuleVisitor + { + public: + WfLexicalScopeManager* manager; + WfForEachStatement* forEach; + + CopyForEachRangeBodyVisitor(WfLexicalScopeManager* _manager, WfForEachStatement* _forEach) + :manager(_manager) + , forEach(_forEach) + { + } + + void Visit(WfContinueStatement* node) + { + auto scope = manager->nodeScopes[node]; + while (scope) + { + if (scope->ownerNode.Cast()) + { + break; + } + else if (scope->ownerNode.Cast()) + { + if (scope->ownerNode != forEach) + { + break; + } + else + { + auto block = MakePtr(); + block->statements.Add(GenerateForEachStepStatement(forEach)); + block->statements.Add(MakePtr()); + SetCodeRange((Ptr)block, node->codeRange); + result = block; + return; + } + } + scope = scope->parentScope; + } + copy_visitor::StatementVisitor::Visit(node); + } + }; + + void ExpandForEachStatement(WfLexicalScopeManager* manager, WfForEachStatement* node) + { + auto block = MakePtr(); + node->expandedStatement = block; + + if (auto range = node->collection.Cast()) + { + auto varBegin = L"" + node->name.value; + auto varEnd = L"" + node->name.value; + { + auto result = manager->expressionResolvings[range->begin.Obj()]; + auto decl = MakePtr(); + decl->name.value = varBegin; + decl->type = GetTypeFromTypeInfo(result.type.Obj()); + decl->expression = CopyExpression(range->begin); + if (range->beginBoundary == WfRangeBoundary::Exclusive) + { + auto one = MakePtr(); + one->value.value = L"1"; + + auto addExpr = MakePtr(); + addExpr->first = decl->expression; + addExpr->second = one; + addExpr->op = WfBinaryOperator::Add; + + decl->expression = addExpr; + } + + auto stat = MakePtr(); + stat->variable = decl; + block->statements.Add(stat); + } + { + auto result = manager->expressionResolvings[range->end.Obj()]; + auto decl = MakePtr(); + decl->name.value = varEnd; + decl->type = GetTypeFromTypeInfo(result.type.Obj()); + decl->expression = CopyExpression(range->end); + if (range->endBoundary == WfRangeBoundary::Exclusive) + { + auto one = MakePtr(); + one->value.value = L"1"; + + auto subExpr = MakePtr(); + subExpr->first = decl->expression; + subExpr->second = one; + subExpr->op = WfBinaryOperator::Sub; + + decl->expression = subExpr; + } + + auto stat = MakePtr(); + stat->variable = decl; + block->statements.Add(stat); + } + { + auto refBegin = MakePtr(); + refBegin->name.value = node->direction == WfForEachDirection::Normal ? varBegin : varEnd; + + auto decl = MakePtr(); + decl->name.value = node->name.value; + decl->expression = refBegin; + + auto stat = MakePtr(); + stat->variable = decl; + block->statements.Add(stat); + } + { + auto whileStat = MakePtr(); + { + auto refVar = MakePtr(); + refVar->name.value = node->name.value; + + auto refBegin = MakePtr(); + refBegin->name.value = node->direction == WfForEachDirection::Normal ? varEnd : varBegin; + + auto compare = MakePtr(); + compare->first = refVar; + compare->second = refBegin; + compare->op = node->direction == WfForEachDirection::Normal ? WfBinaryOperator::LE : WfBinaryOperator::GE; + + whileStat->condition = compare; + } + { + auto whileBlock = MakePtr(); + whileStat->statement = whileBlock; + + { + CopyForEachRangeBodyVisitor visitor(manager, node); + node->statement->Accept(&visitor); + whileBlock->statements.Add(visitor.result.Cast()); + } + whileBlock->statements.Add(GenerateForEachStepStatement(node)); + } + block->statements.Add(whileStat); + } + } + else + { + auto varEnum = L"" + node->name.value; + auto varIter = L"" + node->name.value; + { + auto decl = MakePtr(); + decl->name.value = varEnum; + if (node->direction == WfForEachDirection::Normal) + { + auto inferExpr = MakePtr(); + inferExpr->expression = CopyExpression(node->collection); + inferExpr->type = GetTypeFromTypeInfo(TypeInfoRetriver>::CreateTypeInfo().Obj()); + + decl->expression = inferExpr; + } + else + { + auto refSystem = MakePtr(); + refSystem->name.value = L"system"; + + auto refSys = MakePtr(); + refSys->parent = refSystem; + refSys->name.value = L"Sys"; + + auto refMethod = MakePtr(); + refMethod->parent = refSys; + refMethod->name.value = L"ReverseEnumerable"; + + auto refCall = MakePtr(); + refCall->function = refMethod; + refCall->arguments.Add(CopyExpression(node->collection)); + + decl->expression = refCall; + } + + auto stat = MakePtr(); + stat->variable = decl; + block->statements.Add(stat); + } + { + auto refEnum = MakePtr(); + refEnum->name.value = varEnum; + + auto refMethod = MakePtr(); + refMethod->parent = refEnum; + refMethod->name.value = L"CreateEnumerator"; + + auto callExpr = MakePtr(); + callExpr->function = refMethod; + + auto decl = MakePtr(); + decl->name.value = varIter; + decl->expression = callExpr; + + auto stat = MakePtr(); + stat->variable = decl; + block->statements.Add(stat); + } + { + auto whileStat = MakePtr(); + { + auto refIter = MakePtr(); + refIter->name.value = varIter; + + auto refMethod = MakePtr(); + refMethod->parent = refIter; + refMethod->name.value = L"Next"; + + auto callExpr = MakePtr(); + callExpr->function = refMethod; + + whileStat->condition = callExpr; + } + { + auto whileBlock = MakePtr(); + whileStat->statement = whileBlock; + + { + auto refIter = MakePtr(); + refIter->name.value = varIter; + + auto refMethod = MakePtr(); + refMethod->parent = refIter; + refMethod->name.value = L"GetCurrent"; + + auto callExpr = MakePtr(); + callExpr->function = refMethod; + + auto castExpr = MakePtr(); + castExpr->expression = callExpr; + castExpr->strategy = WfTypeCastingStrategy::Strong; + { + auto parentScope = manager->nodeScopes[node]; + auto symbol = parentScope->symbols[node->name.value][0]; + castExpr->type = GetTypeFromTypeInfo(symbol->typeInfo.Obj()); + } + + auto decl = MakePtr(); + decl->name.value = node->name.value; + decl->expression = castExpr; + + auto stat = MakePtr(); + stat->variable = decl; + whileBlock->statements.Add(stat); + } + whileBlock->statements.Add(CopyStatement(node->statement)); + } + block->statements.Add(whileStat); + } + } + } + +/*********************************************************************** +ExpandCoProviderStatement +***********************************************************************/ + + class ExpandCoProviderStatementVisitor + : public copy_visitor::StatementVisitor + , public copy_visitor::CoroutineStatementVisitor + { + public: + WfLexicalScopeManager* manager; + + ExpandCoProviderStatementVisitor(WfLexicalScopeManager* _manager) + :manager(_manager) + { + } + + Ptr CreateField(Ptr from)override + { + if (!from) return nullptr; + return CopyExpression(from); + } + + Ptr CreateField(Ptr from)override + { + if (!from) return nullptr; + return CopyType(from); + } + + Ptr CreateField(Ptr from)override + { + if (!from) return nullptr; + from->Accept(this); + return result.Cast(); + } + + void Visit(WfReturnStatement* node)override + { + auto opInfo = manager->coOperatorResolvings[node].methodInfo; + auto block = MakePtr(); + + { + auto refImpl = MakePtr(); + refImpl->name.value = L""; + + auto funcExpr = MakePtr(); + funcExpr->parent = GetExpressionFromTypeDescriptor(opInfo->GetOwnerTypeDescriptor()); + funcExpr->name.value = opInfo->GetName(); + + auto callExpr = MakePtr(); + callExpr->function = funcExpr; + callExpr->arguments.Add(refImpl); + if (node->expression) + { + callExpr->arguments.Add(CreateField(node->expression)); + } + + auto stat = MakePtr(); + stat->expression = callExpr; + block->statements.Add(stat); + } + block->statements.Add(MakePtr()); + + SetCodeRange(Ptr(block), node->codeRange); + result = block; + } + + void Visit(WfCoOperatorStatement* node)override + { + auto opInfo = manager->coOperatorResolvings[node].methodInfo; + auto block = MakePtr(); + + { + auto refImpl = MakePtr(); + refImpl->name.value = L""; + + auto funcExpr = MakePtr(); + funcExpr->parent = GetExpressionFromTypeDescriptor(opInfo->GetOwnerTypeDescriptor()); + funcExpr->name.value = opInfo->GetName(); + + auto callExpr = MakePtr(); + callExpr->function = funcExpr; + callExpr->arguments.Add(refImpl); + FOREACH(Ptr, argument, node->arguments) + { + callExpr->arguments.Add(CreateField(argument)); + } + + auto stat = MakePtr(); + stat->expression = callExpr; + + auto pauseBlock = MakePtr(); + pauseBlock->statements.Add(stat); + + auto pauseStat = MakePtr(); + pauseStat->statement = pauseBlock; + + block->statements.Add(pauseStat); + } + { + Ptr ifHasResultStat; + + if (node->varName.value == L"") + { + ifHasResultStat = MakePtr(); + { + auto refCoResult = MakePtr(); + refCoResult->name.value = L""; + + auto testExpr = MakePtr(); + testExpr->expression = refCoResult; + testExpr->test = WfTypeTesting::IsNotNull; + + ifHasResultStat->expression = testExpr; + } + } + + auto ifStat = MakePtr(); + { + auto refCoResult = MakePtr(); + refCoResult->name.value = L""; + + auto refFailure = MakePtr(); + refFailure->parent = refCoResult; + refFailure->name.value = L"Failure"; + + auto testExpr = MakePtr(); + testExpr->expression = refFailure; + testExpr->test = WfTypeTesting::IsNotNull; + + ifStat->expression = testExpr; + } + { + auto refCoResult = MakePtr(); + refCoResult->name.value = L""; + + auto refFailure = MakePtr(); + refFailure->parent = refCoResult; + refFailure->name.value = L"Failure"; + + auto raiseStat = MakePtr(); + raiseStat->expression = refFailure; + + auto ifBlock = MakePtr(); + ifBlock->statements.Add(raiseStat); + ifStat->trueBranch = ifBlock; + } + + if (ifHasResultStat) + { + auto ifBlock = MakePtr(); + ifHasResultStat->trueBranch = ifBlock; + ifBlock->statements.Add(ifStat); + block->statements.Add(ifHasResultStat); + } + else + { + block->statements.Add(ifStat); + } + } + if (node->varName.value != L"") + { + auto refCoResult = MakePtr(); + refCoResult->name.value = L""; + + auto refResult = MakePtr(); + refResult->parent = refCoResult; + refResult->name.value = L"Result"; + + auto castResultInfo = manager->coCastResultResolvings[node].methodInfo; + auto refCastResult = MakePtr(); + refCastResult->parent = GetExpressionFromTypeDescriptor(castResultInfo->GetOwnerTypeDescriptor()); + refCastResult->name.value = L"CastResult"; + + auto callExpr = MakePtr(); + callExpr->function = refCastResult; + callExpr->arguments.Add(refResult); + + auto varDecl = MakePtr(); + varDecl->name.value = node->varName.value; + varDecl->expression = callExpr; + + auto stat = MakePtr(); + stat->variable = varDecl; + block->statements.Add(stat); + } + + SetCodeRange(Ptr(block), node->codeRange); + result = block; + } + + void Visit(WfBlockStatement* node)override + { + auto block = MakePtr(); + + FOREACH(Ptr, statement, node->statements) + { + while (auto virtualStat = statement.Cast()) + { + statement = virtualStat->expandedStatement; + } + if (auto coOperatorStat = statement.Cast()) + { + coOperatorStat->Accept(this); + CopyFrom(block->statements, result.Cast()->statements, true); + } + else + { + block->statements.Add(CreateField(statement)); + } + } + + SetCodeRange(Ptr(block), node->codeRange); + result = block; + } + + Ptr Dispatch(WfVirtualStatement* node)override + { + node->expandedStatement->Accept(this); + return result; + } + + Ptr Dispatch(WfCoroutineStatement* node)override + { + node->Accept((WfCoroutineStatement::IVisitor*)this); + return result; + } + }; + + void ExpandCoProviderStatement(WfLexicalScopeManager* manager, WfCoProviderStatement* node) + { + auto scope = manager->nodeScopes[node].Obj(); + auto functionScope = scope->FindFunctionScope(); + auto funcDecl = functionScope->ownerNode.Cast(); + auto providerScope = manager->nodeScopes[funcDecl->statement.Obj()]; + auto providerType = providerScope->symbols[L"$PROVIDER"][0]->typeInfo; + auto implType = providerScope->symbols[L"$IMPL"][0]->typeInfo; + + auto coroutineExpr = MakePtr(); + { + coroutineExpr->name.value = L""; + coroutineExpr->statement = ExpandCoProviderStatementVisitor(manager).CreateField(node->statement); + } + + auto creatorExpr = MakePtr(); + { + auto creatorDecl = MakePtr(); + creatorExpr->function = creatorDecl; + creatorDecl->anonymity = WfFunctionAnonymity::Anonymous; + creatorDecl->returnType = GetTypeFromTypeInfo(TypeInfoRetriver>::CreateTypeInfo().Obj()); + { + auto argument = MakePtr(); + creatorDecl->arguments.Add(argument); + argument->name.value = L""; + argument->type = GetTypeFromTypeInfo(implType.Obj()); + } + + auto block = MakePtr(); + creatorDecl->statement = block; + + auto returnStat = MakePtr(); + returnStat->expression = coroutineExpr; + block->statements.Add(returnStat); + } + + auto providerBlock = MakePtr(); + { + auto funcReturnType = CreateTypeInfoFromType(functionScope, funcDecl->returnType); + auto creatorInfo = manager->coProviderResolvings[node].methodInfo; + + auto funcExpr = MakePtr(); + funcExpr->parent = GetExpressionFromTypeDescriptor(creatorInfo->GetOwnerTypeDescriptor()); + funcExpr->name.value = creatorInfo->GetName(); + + auto callExpr = MakePtr(); + callExpr->function = funcExpr; + callExpr->arguments.Add(creatorExpr); + + if (funcReturnType->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + auto stat = MakePtr(); + stat->expression = callExpr; + providerBlock->statements.Add(stat); + } + else + { + if (IsSameType(funcReturnType.Obj(), creatorInfo->GetReturn())) + { + auto stat = MakePtr(); + stat->expression = callExpr; + providerBlock->statements.Add(stat); + } + else if (funcReturnType->GetTypeDescriptor() == creatorInfo->GetReturn()->GetTypeDescriptor()) + { + auto castExpr = MakePtr(); + castExpr->strategy = WfTypeCastingStrategy::Strong; + castExpr->type = GetTypeFromTypeInfo(funcReturnType.Obj()); + castExpr->expression = callExpr; + + auto stat = MakePtr(); + stat->expression = castExpr; + providerBlock->statements.Add(stat); + } + else + { + { + auto varDecl = MakePtr(); + varDecl->name.value = L""; + varDecl->expression = callExpr; + + auto stat = MakePtr(); + stat->variable = varDecl; + providerBlock->statements.Add(stat); + } + { + auto refExpr = MakePtr(); + refExpr->name.value = L""; + + auto castExpr = MakePtr(); + castExpr->type = GetTypeFromTypeInfo(funcReturnType.Obj()); + castExpr->expression = refExpr; + + auto stat = MakePtr(); + stat->expression = castExpr; + providerBlock->statements.Add(stat); + } + } + } + } + + node->expandedStatement = providerBlock; + } + } + } +} + +/*********************************************************************** +.\ANALYZER\WFANALYZER_MISC.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace analyzer + { + using namespace collections; + using namespace reflection; + using namespace reflection::description; + +/*********************************************************************** +IsExpressionDependOnExpectedType(Expression) +***********************************************************************/ + + class IsExpressionDependOnExpectedTypeVisitor + : public empty_visitor::ExpressionVisitor + , public empty_visitor::VirtualExpressionVisitor + { + public: + WfLexicalScopeManager* manager; + bool result; + + IsExpressionDependOnExpectedTypeVisitor(WfLexicalScopeManager* _manager) + :manager(_manager) + , result(false) + { + } + + void Dispatch(WfVirtualExpression* node)override + { + node->Accept(static_cast(this)); + } + + bool Execute(Ptr expression) + { + result = false; + expression->Accept(this); + return result; + } + + void Visit(WfReferenceExpression* node)override + { + auto scope = manager->nodeScopes[node].Obj(); + List testResults; + manager->ResolveName(scope, node->name.value, testResults); + if (testResults.Count() == 0) + { + result = true; + } + } + + void Visit(WfOrderedLambdaExpression* node)override + { + auto scope = manager->nodeScopes[node].Obj(); + result = scope->symbols.Count() > 0; + } + + void Visit(WfLiteralExpression* node)override + { + if (node->value == WfLiteralValue::Null) + { + result = true; + } + } + + void Visit(WfIfExpression* node)override + { + result = Execute(node->trueBranch) && Execute(node->falseBranch); + } + + void Visit(WfConstructorExpression* node)override + { + if (node->arguments.Count() == 0) + { + result = true; + } + else + { + vint possibleFieldCount = 0; + bool unresolvableField = false; + auto scope = manager->nodeScopes[node].Obj(); + + FOREACH(Ptr, argument, node->arguments) + { + if (argument->value) + { + if (auto refExpr = argument->key.Cast()) + { + possibleFieldCount++; + List testResults; + manager->ResolveName(scope, refExpr->name.value, testResults); + if (testResults.Count() == 0) + { + unresolvableField = true; + } + } + } + } + + result = unresolvableField&&possibleFieldCount == node->arguments.Count(); + } + } + + void Visit(WfExpectedTypeCastExpression* node)override + { + result = true; + } + }; + + bool IsExpressionDependOnExpectedType(WfLexicalScopeManager* manager, Ptr expression) + { + IsExpressionDependOnExpectedTypeVisitor visitor(manager); + expression->Accept(&visitor); + return visitor.result; + } + +/*********************************************************************** +GetExpressionName(Expression) +***********************************************************************/ + + class GetExpressionNameVisitor + : public empty_visitor::ExpressionVisitor + , public empty_visitor::VirtualExpressionVisitor + { + public: + WString result; + + void Dispatch(WfVirtualExpression* node)override + { + node->Accept(static_cast(this)); + } + + void Visit(WfTopQualifiedExpression* node)override + { + result = node->name.value; + } + + void Visit(WfReferenceExpression* node)override + { + result = node->name.value; + } + + void Visit(WfOrderedNameExpression* node)override + { + result = node->name.value; + } + + void Visit(WfMemberExpression* node)override + { + result = node->name.value; + } + + void Visit(WfChildExpression* node)override + { + result = node->name.value; + } + }; + + WString GetExpressionName(Ptr expression) + { + GetExpressionNameVisitor visitor; + expression->Accept(&visitor); + return visitor.result; + } + } + } +} + +/*********************************************************************** +.\ANALYZER\WFANALYZER_SEARCHORDEREDNAME.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace analyzer + { + using namespace collections; + +/*********************************************************************** +SearchOrderedName +***********************************************************************/ + + class SearchOrderedNameVisitor : public traverse_visitor::ModuleVisitor + { + public: + WfLexicalScope* scope; + SortedList& names; + + SearchOrderedNameVisitor(WfLexicalScope* _scope, SortedList& _names) + :scope(_scope) + , names(_names) + { + } + + void Traverse(WfOrderedNameExpression* node)override + { + vint name = wtoi(node->name.value.Sub(1, node->name.value.Length() - 1)); + if (!names.Contains(name)) + { + WfLexicalScope* currentScope = scope; + while (currentScope) + { + if (currentScope->symbols.Keys().Contains(node->name.value)) + { + return; + } + currentScope = currentScope->parentScope.Obj(); + } + names.Add(name); + } + } + + void Visit(WfOrderedLambdaExpression* node)override + { + // names in nested ordered lambda expression is not counted + } + + static void Execute(WfLexicalScope* scope, Ptr expression, SortedList& names) + { + SearchOrderedNameVisitor visitor(scope, names); + expression->Accept(&visitor); + } + }; + + void SearchOrderedName(WfLexicalScope* scope, Ptr expression, collections::SortedList& names) + { + SearchOrderedNameVisitor::Execute(scope, expression, names); + } + } + } +} + +/*********************************************************************** +.\ANALYZER\WFANALYZER_TYPEINFO.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace analyzer + { + using namespace collections; + using namespace reflection; + using namespace reflection::description; + +/*********************************************************************** +GetTypeFlag +***********************************************************************/ + + TypeFlag GetTypeFlag(reflection::description::ITypeDescriptor* typeDescriptor) + { + if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::Bool; + if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::I1; + if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::I2; + if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::I4; + if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::I8; + if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::U1; + if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::U2; + if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::U4; + if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::U8; + if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::F4; + if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::F8; + if (typeDescriptor == GetTypeDescriptor()) return TypeFlag::String; + switch (typeDescriptor->GetTypeDescriptorFlags()) + { + case TypeDescriptorFlags::FlagEnum: + case TypeDescriptorFlags::NormalEnum: + return TypeFlag::Enum; + case TypeDescriptorFlags::Struct: + return TypeFlag::Struct; + default: + return TypeFlag::Others; + } + } + + TypeFlag GetTypeFlag(reflection::description::ITypeInfo* typeInfo) + { + ITypeDescriptor* td = typeInfo->GetTypeDescriptor(); + return GetTypeFlag(td); + } + +/*********************************************************************** +CreateTypeInfoFromTypeFlag +***********************************************************************/ + + Ptr CreateTypeInfoFromTypeFlag(TypeFlag flag) + { + switch (flag) + { + case TypeFlag::Bool: return TypeInfoRetriver::CreateTypeInfo(); + case TypeFlag::I1: return TypeInfoRetriver::CreateTypeInfo(); + case TypeFlag::I2: return TypeInfoRetriver::CreateTypeInfo(); + case TypeFlag::I4: return TypeInfoRetriver::CreateTypeInfo(); + case TypeFlag::I8: return TypeInfoRetriver::CreateTypeInfo(); + case TypeFlag::U1: return TypeInfoRetriver::CreateTypeInfo(); + case TypeFlag::U2: return TypeInfoRetriver::CreateTypeInfo(); + case TypeFlag::U4: return TypeInfoRetriver::CreateTypeInfo(); + case TypeFlag::U8: return TypeInfoRetriver::CreateTypeInfo(); + case TypeFlag::F4: return TypeInfoRetriver::CreateTypeInfo(); + case TypeFlag::F8: return TypeInfoRetriver::CreateTypeInfo(); + case TypeFlag::String: return TypeInfoRetriver::CreateTypeInfo(); + default: return nullptr; + } + } + +/*********************************************************************** +GetTypeFragments +***********************************************************************/ + + void GetTypeFragments(reflection::description::ITypeDescriptor* typeDescriptor, collections::List& fragments) + { + WString name = typeDescriptor->GetTypeName(); + const wchar_t* reading = name.Buffer(); + while (reading) + { + const wchar_t* delimiter = wcsstr(reading, L"::"); + if (delimiter) + { + fragments.Add(WString(reading, vint(delimiter - reading))); + reading = delimiter + 2; + } + else + { + fragments.Add(reading); + break; + } + } + } + +/*********************************************************************** +GetExpressionFromTypeDescriptor +***********************************************************************/ + + Ptr GetExpressionFromTypeDescriptor(reflection::description::ITypeDescriptor* typeDescriptor) + { + List fragments; + GetTypeFragments(typeDescriptor, fragments); + + Ptr parentExpr; + FOREACH(WString, fragment, fragments) + { + if (!parentExpr) + { + auto expr = MakePtr(); + expr->name.value = fragment; + parentExpr = expr; + } + else + { + auto expr = MakePtr(); + expr->parent = parentExpr; + expr->name.value = fragment; + parentExpr = expr; + } + } + return parentExpr; + } + +/*********************************************************************** +GetTypeFromTypeInfo +***********************************************************************/ + + Ptr GetTypeFromTypeInfo(reflection::description::ITypeInfo* typeInfo) + { + switch (typeInfo->GetDecorator()) + { + case ITypeInfo::RawPtr: + { + Ptr element = GetTypeFromTypeInfo(typeInfo->GetElementType()); + if (element) + { + Ptr type = new WfRawPointerType; + type->element = element; + return type; + } + return 0; + } + case ITypeInfo::SharedPtr: + { + if (typeInfo->GetElementType()->GetDecorator() == ITypeInfo::Generic) + { + return GetTypeFromTypeInfo(typeInfo->GetElementType()); + } + else + { + Ptr element = GetTypeFromTypeInfo(typeInfo->GetElementType()); + if (element) + { + Ptr type = new WfSharedPointerType; + type->element = element; + return type; + } + return 0; + } + } + case ITypeInfo::Nullable: + { + Ptr element = GetTypeFromTypeInfo(typeInfo->GetElementType()); + if (element) + { + Ptr type = new WfNullableType; + type->element = element; + return type; + } + return 0; + } + case ITypeInfo::TypeDescriptor: + { + List fragments; + GetTypeFragments(typeInfo->GetTypeDescriptor(), fragments); + + Ptr parentType; + FOREACH(WString, fragment, fragments) + { + if (!parentType) + { + auto type = MakePtr(); + type->name.value = fragment; + parentType = type; + } + else + { + auto type = MakePtr(); + type->parent = parentType; + type->name.value = fragment; + parentType = type; + } + } + return parentType; + } + case ITypeInfo::Generic: + { + if (typeInfo->GetElementType()->GetDecorator() == ITypeInfo::TypeDescriptor) + { + if (typeInfo->GetTypeDescriptor() == GetTypeDescriptor()) + { + if (typeInfo->GetGenericArgumentCount() == 1) + { + if (Ptr elementType = GetTypeFromTypeInfo(typeInfo->GetGenericArgument(0))) + { + Ptr type = new WfEnumerableType; + type->element = elementType; + return type; + } + } + } + else if (typeInfo->GetTypeDescriptor() == GetTypeDescriptor()) + { + if (typeInfo->GetGenericArgumentCount() == 1) + { + if (Ptr valueType = GetTypeFromTypeInfo(typeInfo->GetGenericArgument(0))) + { + Ptr type = new WfMapType; + type->writability = WfMapWritability::Readonly; + type->value = valueType; + return type; + } + } + } + else if (typeInfo->GetTypeDescriptor() == GetTypeDescriptor()) + { + if (typeInfo->GetGenericArgumentCount() == 1) + { + if (Ptr valueType = GetTypeFromTypeInfo(typeInfo->GetGenericArgument(0))) + { + Ptr type = new WfMapType; + type->writability = WfMapWritability::Writable; + type->value = valueType; + return type; + } + } + } + else if (typeInfo->GetTypeDescriptor() == GetTypeDescriptor()) + { + if (typeInfo->GetGenericArgumentCount() == 1) + { + if (Ptr elementType = GetTypeFromTypeInfo(typeInfo->GetGenericArgument(0))) + { + Ptr type = new WfObservableListType; + type->element = elementType; + return type; + } + } + } + else if (typeInfo->GetTypeDescriptor() == GetTypeDescriptor()) + { + if (typeInfo->GetGenericArgumentCount() == 2) + { + if (Ptr keyType = GetTypeFromTypeInfo(typeInfo->GetGenericArgument(0))) + if (Ptr valueType = GetTypeFromTypeInfo(typeInfo->GetGenericArgument(1))) + { + Ptr type = new WfMapType; + type->writability = WfMapWritability::Readonly; + type->key = keyType; + type->value = valueType; + return type; + } + } + } + else if (typeInfo->GetTypeDescriptor() == GetTypeDescriptor()) + { + if (typeInfo->GetGenericArgumentCount() == 2) + { + if (Ptr keyType = GetTypeFromTypeInfo(typeInfo->GetGenericArgument(0))) + if (Ptr valueType = GetTypeFromTypeInfo(typeInfo->GetGenericArgument(1))) + { + Ptr type = new WfMapType; + type->writability = WfMapWritability::Writable; + type->key = keyType; + type->value = valueType; + return type; + } + } + } + else if (typeInfo->GetTypeDescriptor() == GetTypeDescriptor()) + { + if (typeInfo->GetGenericArgumentCount() >= 1) + { + if (Ptr returnType = GetTypeFromTypeInfo(typeInfo->GetGenericArgument(0))) + { + Ptr type = new WfFunctionType; + type->result = GetTypeFromTypeInfo(typeInfo->GetGenericArgument(0)); + for (vint i = 1; i < typeInfo->GetGenericArgumentCount(); i++) + { + if (Ptr argumentType = GetTypeFromTypeInfo(typeInfo->GetGenericArgument(i))) + { + type->arguments.Add(argumentType); + } + else + { + return 0; + } + } + return type; + } + } + } + } + return 0; + } + default: + return 0; + } + } + +/*********************************************************************** +GetScopeNameFromReferenceType +***********************************************************************/ + + class GetScopeNameFromReferenceTypeVisitor : public Object, public WfType::IVisitor + { + public: + WfLexicalScope* scope; + Ptr result; + + GetScopeNameFromReferenceTypeVisitor(WfLexicalScope* _scope) + :scope(_scope) + { + } + + Ptr Call(WfType* node) + { + node->Accept(this); + Ptr scopeName = result; + result = 0; + return scopeName; + } + + void Visit(WfPredefinedType* node)override + { + WString name; + switch (node->name) + { + case WfPredefinedTypeName::Void: + name = L"Void"; + break; + case WfPredefinedTypeName::Object: + name = L"Object"; + break; + case WfPredefinedTypeName::Interface: + name = L"Interface"; + break; + case WfPredefinedTypeName::Int: +#if defined VCZH_64 + name = L"Int64"; +#else + name = L"Int32"; +#endif + break; + case WfPredefinedTypeName::UInt: +#if defined VCZH_64 + name = L"UInt64"; +#else + name = L"UInt32"; +#endif + break; + case WfPredefinedTypeName::Float: + name = L"Single"; + break; + case WfPredefinedTypeName::Double: + name = L"Double"; + break; + case WfPredefinedTypeName::String: + name = L"String"; + break; + case WfPredefinedTypeName::Char: + name = L"Char"; + break; + case WfPredefinedTypeName::Bool: + name = L"Boolean"; + break; + default: + CHECK_FAIL(L"GetScopeNameFromReferenceTypeVisitor::Visit(WfPredefinedType*)#Internal error, ValidateTypeStructure function should check correctly."); + } + + Ptr ns = new WfTopQualifiedType; + ns->name.value = L"system"; + + Ptr type = new WfChildType; + type->parent = ns; + type->name.value = name; + + type->Accept(this); + } + + void Visit(WfTopQualifiedType* node)override + { + auto manager = scope->FindManager(); + if (manager->globalName) + { + vint index = manager->globalName->children.Keys().IndexOf(node->name.value); + if (index != -1) + { + result = manager->globalName->children.Values()[index]; + return; + } + } + manager->errors.Add(WfErrors::TopQualifiedSymbolNotExists(node, node->name.value)); + } + + void Visit(WfReferenceType* node)override + { + auto manager = scope->FindManager(); + List results; + manager->ResolveName(scope, node->name.value, results); + + if (results.Count() > 1) + { + manager->errors.Add(WfErrors::TooManyTargets(node, results, node->name.value)); + } + else if (results.Count() == 1) + { + if (auto scopeName = results[0].scopeName) + { + result = scopeName; + } + else + { + manager->errors.Add(WfErrors::TypeNotExists(node, results[0])); + } + } + else + { + manager->errors.Add(WfErrors::ReferenceNotExists(node, node->name.value)); + } + } + + void Visit(WfRawPointerType* node)override + { + CHECK_FAIL(L"GetScopeNameFromReferenceTypeVisitor::Visit(WfRawPointerType*)#Internal error, ValidateTypeStructure function should check correctly."); + } + + void Visit(WfSharedPointerType* node)override + { + CHECK_FAIL(L"GetScopeNameFromReferenceTypeVisitor::Visit(WfSharedPointerType*)#Internal error, ValidateTypeStructure function should check correctly."); + } + + void Visit(WfNullableType* node)override + { + CHECK_FAIL(L"GetScopeNameFromReferenceTypeVisitor::Visit(WfNullableType*)#Internal error, ValidateTypeStructure function should check correctly."); + } + + void Visit(WfEnumerableType* node)override + { + CHECK_FAIL(L"GetScopeNameFromReferenceTypeVisitor::Visit(WfEnumerableType*)#Internal error, ValidateTypeStructure function should check correctly."); + } + + void Visit(WfMapType* node)override + { + CHECK_FAIL(L"GetScopeNameFromReferenceTypeVisitor::Visit(WfMapType*)#Internal error, ValidateTypeStructure function should check correctly."); + } + + void Visit(WfObservableListType* node)override + { + CHECK_FAIL(L"GetScopeNameFromReferenceTypeVisitor::Visit(WfObservableListType*)#Internal error, ValidateTypeStructure function should check correctly."); + } + + void Visit(WfFunctionType* node)override + { + CHECK_FAIL(L"GetScopeNameFromReferenceTypeVisitor::Visit(WfFunctionType*)#Internal error, ValidateTypeStructure function should check correctly."); + } + + void Visit(WfChildType* node)override + { + if (Ptr scopeName = Call(node->parent.Obj())) + { + vint index = scopeName->children.Keys().IndexOf(node->name.value); + if (index != -1) + { + result = scopeName->children.Values()[index]; + return; + } + scope->FindManager()->errors.Add(WfErrors::ChildSymbolNotExists(node, scopeName, node->name.value)); + } + } + + static Ptr Execute(WfLexicalScope* scope, WfType* type) + { + return GetScopeNameFromReferenceTypeVisitor(scope).Call(type); + } + }; + + Ptr GetScopeNameFromReferenceType(WfLexicalScope* scope, Ptr type) + { + return GetScopeNameFromReferenceTypeVisitor::Execute(scope, type.Obj()); + } + +/*********************************************************************** +CreateTypeInfoFromType +***********************************************************************/ + + class CreateTypeInfoFromTypeVisitor : public Object, public WfType::IVisitor + { + public: + WfLexicalScope* scope; + Ptr result; + + CreateTypeInfoFromTypeVisitor(WfLexicalScope* _scope) + :scope(_scope) + { + } + + Ptr Call(WfType* node, bool checkTypeForValue) + { + node->Accept(this); + Ptr typeInfo = result; + result = 0; + if (typeInfo) + { + auto manager = scope->FindManager(); + switch (typeInfo->GetDecorator()) + { + case ITypeInfo::RawPtr: + case ITypeInfo::SharedPtr: + switch (typeInfo->GetTypeDescriptor()->GetTypeDescriptorFlags()) + { + case TypeDescriptorFlags::IDescriptable: + case TypeDescriptorFlags::Class: + case TypeDescriptorFlags::Interface: + break; + default: + if (typeInfo->GetDecorator() == ITypeInfo::RawPtr) + { + manager->errors.Add(WfErrors::RawPointerToNonReferenceType(node, typeInfo.Obj())); + } + else + { + manager->errors.Add(WfErrors::SharedPointerToNonReferenceType(node, typeInfo.Obj())); + } + } + break; + case ITypeInfo::Nullable: + switch (typeInfo->GetTypeDescriptor()->GetTypeDescriptorFlags()) + { + case TypeDescriptorFlags::Primitive: + case TypeDescriptorFlags::Struct: + case TypeDescriptorFlags::FlagEnum: + case TypeDescriptorFlags::NormalEnum: + break; + default: + manager->errors.Add(WfErrors::NullableToNonReferenceType(node, typeInfo.Obj())); + } + break; + case ITypeInfo::TypeDescriptor: + if (checkTypeForValue) + { + switch (typeInfo->GetTypeDescriptor()->GetTypeDescriptorFlags()) + { + case TypeDescriptorFlags::Object: + case TypeDescriptorFlags::Primitive: + case TypeDescriptorFlags::Struct: + case TypeDescriptorFlags::FlagEnum: + case TypeDescriptorFlags::NormalEnum: + break; + default: + manager->errors.Add(WfErrors::TypeNotForValue(node, typeInfo.Obj())); + } + } + break; + case ITypeInfo::Generic: + if (checkTypeForValue) + { + manager->errors.Add(WfErrors::TypeNotForValue(node, typeInfo.Obj())); + } + break; + } + } + return typeInfo; + } + + void VisitReferenceType(WfType* node) + { + if (auto scopeName = GetScopeNameFromReferenceTypeVisitor::Execute(scope, node)) + { + if (scopeName->typeDescriptor) + { + result = MakePtr(scopeName->typeDescriptor, TypeInfoHint::Normal); + } + else + { + scope->FindManager()->errors.Add(WfErrors::TypeNotExists(node, scopeName)); + } + } + } + + void Visit(WfPredefinedType* node)override + { + ITypeDescriptor* typeDescriptor = 0; + switch (node->name) + { + case WfPredefinedTypeName::Void: + typeDescriptor = description::GetTypeDescriptor(); + break; + case WfPredefinedTypeName::Object: + typeDescriptor = description::GetTypeDescriptor(); + break; + case WfPredefinedTypeName::Interface: + typeDescriptor = description::GetTypeDescriptor(); + break; + case WfPredefinedTypeName::Int: + typeDescriptor = description::GetTypeDescriptor(); + break; + case WfPredefinedTypeName::UInt: + typeDescriptor = description::GetTypeDescriptor(); + break; + case WfPredefinedTypeName::Float: + typeDescriptor = description::GetTypeDescriptor(); + break; + case WfPredefinedTypeName::Double: + typeDescriptor = description::GetTypeDescriptor(); + break; + case WfPredefinedTypeName::String: + typeDescriptor = description::GetTypeDescriptor(); + break; + case WfPredefinedTypeName::Char: + typeDescriptor = description::GetTypeDescriptor(); + break; + case WfPredefinedTypeName::Bool: + typeDescriptor = description::GetTypeDescriptor(); + break; + default: + CHECK_FAIL(L"CreateTypeInfoFromTypeVisitor::Visit(WfPredefinedType*)#Internal error, ValidateTypeStructure function should check correctly."); + } + if (typeDescriptor) + { + result = MakePtr(typeDescriptor, TypeInfoHint::Normal); + } + } + + void Visit(WfTopQualifiedType* node)override + { + VisitReferenceType(node); + } + + void Visit(WfReferenceType* node)override + { + VisitReferenceType(node); + } + + void Visit(WfRawPointerType* node)override + { + if (Ptr element = Call(node->element.Obj(), false)) + { + result = MakePtr(element); + } + } + + void Visit(WfSharedPointerType* node)override + { + if (Ptr element = Call(node->element.Obj(), false)) + { + result = MakePtr(element); + } + } + + void Visit(WfNullableType* node)override + { + if (Ptr element = Call(node->element.Obj(), false)) + { + result = MakePtr(element); + } + } + + void Visit(WfEnumerableType* node)override + { + if (Ptr element = Call(node->element.Obj(), true)) + { + auto enumerableTypeInfo = MakePtr(description::GetTypeDescriptor(), TypeInfoHint::Normal); + auto genericTypeInfo = MakePtr(enumerableTypeInfo); + genericTypeInfo->AddGenericArgument(element); + result = MakePtr(genericTypeInfo); + } + } + + void Visit(WfMapType* node)override + { + Ptr key, value; + if (!(value = Call(node->value.Obj(), true))) return; + if (node->key) + { + if (!(key = Call(node->key.Obj(), true))) return; + } + + ITypeDescriptor* typeDescriptor = nullptr; + if (node->writability == WfMapWritability::Writable) + { + if (node->key) + { + typeDescriptor = description::GetTypeDescriptor(); + } + else + { + typeDescriptor = description::GetTypeDescriptor(); + } + } + else + { + if (node->key) + { + typeDescriptor = description::GetTypeDescriptor(); + } + else + { + typeDescriptor = description::GetTypeDescriptor(); + } + } + + auto mapTypeInfo = MakePtr(typeDescriptor, TypeInfoHint::Normal); + auto genericTypeInfo = MakePtr(mapTypeInfo); + if (key) genericTypeInfo->AddGenericArgument(key); + genericTypeInfo->AddGenericArgument(value); + result = MakePtr(genericTypeInfo); + } + + void Visit(WfObservableListType* node)override + { + Ptr element; + if (!(element = Call(node->element.Obj(), true))) return; + + auto typeDescriptor = description::GetTypeDescriptor(); + auto mapTypeInfo = MakePtr(typeDescriptor, TypeInfoHint::Normal); + auto genericTypeInfo = MakePtr(mapTypeInfo); + genericTypeInfo->AddGenericArgument(element); + result = MakePtr(genericTypeInfo); + } + + void Visit(WfFunctionType* node)override + { + if (Ptr returnType = Call(node->result.Obj(), true)) + { + auto enumerableTypeInfo = MakePtr(description::GetTypeDescriptor(), TypeInfoHint::Normal); + auto genericTypeInfo = MakePtr(enumerableTypeInfo); + genericTypeInfo->AddGenericArgument(returnType); + FOREACH(Ptr, argument, node->arguments) + { + if (Ptr argumentType = Call(argument.Obj(), true)) + { + genericTypeInfo->AddGenericArgument(argumentType); + } + else + { + return; + } + } + result = MakePtr(genericTypeInfo); + } + } + + void Visit(WfChildType* node)override + { + VisitReferenceType(node); + } + + static Ptr Execute(WfLexicalScope* scope, WfType* type) + { + return CreateTypeInfoFromTypeVisitor(scope).Call(type, true); + } + }; + + Ptr CreateTypeInfoFromType(WfLexicalScope* scope, Ptr type) + { + return CreateTypeInfoFromTypeVisitor::Execute(scope, type.Obj()); + } + +/*********************************************************************** +CreateTypeInfoFromType +***********************************************************************/ + + Ptr CopyTypeInfoInternal(reflection::description::ITypeInfo* typeInfo) + { + switch (typeInfo->GetDecorator()) + { + case ITypeInfo::RawPtr: + return MakePtr(CopyTypeInfo(typeInfo->GetElementType())); + case ITypeInfo::SharedPtr: + return MakePtr(CopyTypeInfo(typeInfo->GetElementType())); + case ITypeInfo::Nullable: + return MakePtr(CopyTypeInfo(typeInfo->GetElementType())); + case ITypeInfo::TypeDescriptor: + return MakePtr(typeInfo->GetTypeDescriptor(), typeInfo->GetHint()); + case ITypeInfo::Generic: + { + auto impl = MakePtr(typeInfo->GetElementType()); + vint count = typeInfo->GetGenericArgumentCount(); + for (vint i = 0; i < count; i++) + { + impl->AddGenericArgument(CopyTypeInfo(typeInfo->GetGenericArgument(i))); + } + return impl; + } + default:; + return nullptr; + } + } + + Ptr CopyTypeInfo(reflection::description::ITypeInfo* typeInfo) + { + if (!typeInfo) return nullptr; + return CopyTypeInfoInternal(typeInfo); + } + +/*********************************************************************** +CanConvertToType +***********************************************************************/ + + bool CanConvertToType(reflection::description::ITypeInfo* fromType, reflection::description::ITypeInfo* toType, bool explicitly) + { + ITypeDescriptor* objectType = GetTypeDescriptor(); + bool fromObject = fromType->GetDecorator() == ITypeInfo::TypeDescriptor && fromType->GetTypeDescriptor() == objectType; + bool toObject = toType->GetDecorator() == ITypeInfo::TypeDescriptor && toType->GetTypeDescriptor() == objectType; + + if (fromObject && toObject) + { + return true; + } + else if (fromObject) + { + return explicitly; + } + else if (toObject) + { + return true; + } + + switch (fromType->GetDecorator()) + { + case ITypeInfo::RawPtr: + switch (toType->GetDecorator()) + { + case ITypeInfo::RawPtr: + return CanConvertToType(fromType->GetElementType(), toType->GetElementType(), explicitly); + case ITypeInfo::SharedPtr: + return explicitly && CanConvertToType(fromType->GetElementType(), toType->GetElementType(), explicitly); + case ITypeInfo::Nullable: + case ITypeInfo::TypeDescriptor: + case ITypeInfo::Generic: + return false; + } + break; + case ITypeInfo::SharedPtr: + switch (toType->GetDecorator()) + { + case ITypeInfo::RawPtr: + return explicitly && CanConvertToType(fromType->GetElementType(), toType->GetElementType(), explicitly); + case ITypeInfo::SharedPtr: + return CanConvertToType(fromType->GetElementType(), toType->GetElementType(), explicitly); + case ITypeInfo::Nullable: + case ITypeInfo::TypeDescriptor: + case ITypeInfo::Generic: + return false; + } + break; + case ITypeInfo::Nullable: + switch (toType->GetDecorator()) + { + case ITypeInfo::RawPtr: + case ITypeInfo::SharedPtr: + return false; + case ITypeInfo::Nullable: + return CanConvertToType(fromType->GetElementType(), toType->GetElementType(), explicitly); + case ITypeInfo::TypeDescriptor: + return explicitly && CanConvertToType(fromType->GetElementType(), toType, explicitly); + case ITypeInfo::Generic: + return false; + } + break; + case ITypeInfo::TypeDescriptor: + switch (toType->GetDecorator()) + { + case ITypeInfo::RawPtr: + case ITypeInfo::SharedPtr: + return false; + case ITypeInfo::Nullable: + return CanConvertToType(fromType, toType->GetElementType(), explicitly); + case ITypeInfo::TypeDescriptor: + { + ITypeDescriptor* fromTd = fromType->GetTypeDescriptor(); + ITypeDescriptor* toTd = toType->GetTypeDescriptor(); + bool fromValue = (fromTd->GetTypeDescriptorFlags() & TypeDescriptorFlags::ReferenceType) == TypeDescriptorFlags::Undefined; + bool toValue = (toTd->GetTypeDescriptorFlags() & TypeDescriptorFlags::ReferenceType) == TypeDescriptorFlags::Undefined; + if (fromValue != toValue) + { + return false; + } + + if (fromValue) + { + if (fromTd == toTd) + { + return true; + } + else if (fromTd == GetTypeDescriptor()) + { + return explicitly && toTd->GetSerializableType() != nullptr; + } + else if (toTd == GetTypeDescriptor()) + { + return fromTd->GetSerializableType() != nullptr; + } + + TypeFlag fromFlag = GetTypeFlag(fromTd); + TypeFlag toFlag = GetTypeFlag(toTd); + static vint conversionTable[(vint)TypeFlag::Count][(vint)TypeFlag::Count] = { + /*Bool */{1, /**/ 0, 0, 0, 0, /**/ 0, 0, 0, 0, /**/ 0, 0, /**/ 1, 0, 0, 0}, + //------------------------------------------------------------------------------- + /*I1 */{0, /**/ 1, 1, 1, 1, /**/ 2, 2, 2, 2, /**/ 1, 1, /**/ 1, 0, 0, 0}, + /*I2 */{0, /**/ 2, 1, 1, 1, /**/ 2, 2, 2, 2, /**/ 1, 1, /**/ 1, 0, 0, 0}, + /*I4 */{0, /**/ 2, 2, 1, 1, /**/ 2, 2, 2, 2, /**/ 2, 1, /**/ 1, 0, 0, 0}, + /*I8 */{0, /**/ 2, 2, 2, 1, /**/ 2, 2, 2, 2, /**/ 2, 1, /**/ 1, 0, 0, 0}, + //------------------------------------------------------------------------------- + /*U1 */{0, /**/ 2, 2, 2, 2, /**/ 1, 1, 1, 1, /**/ 1, 1, /**/ 1, 0, 0, 0}, + /*U2 */{0, /**/ 2, 2, 2, 2, /**/ 2, 1, 1, 1, /**/ 1, 1, /**/ 1, 0, 0, 0}, + /*U4 */{0, /**/ 2, 2, 2, 2, /**/ 2, 2, 1, 1, /**/ 2, 1, /**/ 1, 0, 0, 0}, + /*U8 */{0, /**/ 2, 2, 2, 2, /**/ 2, 2, 2, 1, /**/ 2, 1, /**/ 1, 2, 0, 0}, + //------------------------------------------------------------------------------- + /*F4 */{0, /**/ 2, 2, 2, 2, /**/ 2, 2, 2, 2, /**/ 1, 1, /**/ 1, 0, 0, 0}, + /*F8 */{0, /**/ 2, 2, 2, 2, /**/ 2, 2, 2, 2, /**/ 2, 1, /**/ 1, 0, 0, 0}, + //------------------------------------------------------------------------------- + /*String */{2, /**/ 2, 2, 2, 2, /**/ 2, 2, 2, 2, /**/ 2, 2, /**/ 1, 0, 0, 0}, + /*Enum */{0, /**/ 0, 0, 0, 0, /**/ 0, 0, 0, 2, /**/ 0, 0, /**/ 0, 0, 0, 0}, + /*Struct */{0, /**/ 0, 0, 0, 0, /**/ 0, 0, 0, 0, /**/ 0, 0, /**/ 0, 0, 0, 0}, + /*Others */{0, /**/ 0, 0, 0, 0, /**/ 0, 0, 0, 0, /**/ 0, 0, /**/ 0, 0, 0, 0}, + }; + vint conversion = conversionTable[(vint)fromFlag][(vint)toFlag]; + return conversion == 1 || (explicitly && conversion == 2); + } + else + { + if (fromTd->CanConvertTo(toTd)) + { + return true; + } + if (explicitly && toTd->CanConvertTo(fromTd)) + { + return true; + } + } + } + break; + case ITypeInfo::Generic: + return explicitly && CanConvertToType(fromType, toType->GetElementType(), explicitly); + } + break; + case ITypeInfo::Generic: + switch (toType->GetDecorator()) + { + case ITypeInfo::RawPtr: + case ITypeInfo::SharedPtr: + case ITypeInfo::Nullable: + return false; + case ITypeInfo::TypeDescriptor: + return CanConvertToType(fromType->GetElementType(), toType, explicitly); + case ITypeInfo::Generic: + if (explicitly) return true; + if (fromType->GetGenericArgumentCount() != toType->GetGenericArgumentCount()) + { + return false; + } + if (!CanConvertToType(fromType->GetElementType(), toType->GetElementType(), explicitly)) return false; + for (vint i = 0; i < fromType->GetGenericArgumentCount(); i++) + { + if (!IsSameType(fromType->GetGenericArgument(i), toType->GetGenericArgument(i))) + { + return false; + } + } + return true; + } + break; + } + return false; + } + +/*********************************************************************** +IsSameType +***********************************************************************/ + + bool IsSameType(reflection::description::ITypeInfo* fromType, reflection::description::ITypeInfo* toType) + { + if (fromType->GetDecorator() != toType->GetDecorator()) + { + return false; + } + switch (fromType->GetDecorator()) + { + case ITypeInfo::RawPtr: + case ITypeInfo::SharedPtr: + case ITypeInfo::Nullable: + return IsSameType(fromType->GetElementType(), toType->GetElementType()); + case ITypeInfo::TypeDescriptor: + return fromType->GetTypeDescriptor() == toType->GetTypeDescriptor(); + case ITypeInfo::Generic: + if (fromType->GetGenericArgumentCount() != toType->GetGenericArgumentCount()) + { + return false; + } + if (!IsSameType(fromType->GetElementType(), toType->GetElementType())) return false; + for (vint i = 0; i < fromType->GetGenericArgumentCount(); i++) + { + if (!IsSameType(fromType->GetGenericArgument(i), toType->GetGenericArgument(i))) + { + return false; + } + } + return true; + } + return false; + } + +/*********************************************************************** +GetMergedType +***********************************************************************/ + + Ptr GetMergedType(Ptr firstType, Ptr secondType) + { + if (CanConvertToType(secondType.Obj(), firstType.Obj(), false)) + { + return firstType; + } + else if (CanConvertToType(firstType.Obj(), secondType.Obj(), false)) + { + return secondType; + } + else + { + return 0; + } + } + +/*********************************************************************** +IsNullAcceptableType +***********************************************************************/ + + bool IsNullAcceptableType(reflection::description::ITypeInfo* type) + { + switch (type->GetDecorator()) + { + case ITypeInfo::RawPtr: + case ITypeInfo::SharedPtr: + case ITypeInfo::Nullable: + return true; + case ITypeInfo::TypeDescriptor: + return type->GetTypeDescriptor() == description::GetTypeDescriptor(); + case ITypeInfo::Generic: + return false; + } + return false; + } + +/*********************************************************************** +CreateTypeInfoFromMethodInfo +***********************************************************************/ + + Ptr CreateTypeInfoFromMethodInfo(reflection::description::IMethodInfo* info) + { + auto elementType = MakePtr(description::GetTypeDescriptor(), TypeInfoHint::Normal); + auto genericType = MakePtr(elementType); + genericType->AddGenericArgument(CopyTypeInfo(info->GetReturn())); + vint parameterCount = info->GetParameterCount(); + for (vint j = 0; j < parameterCount; j++) + { + genericType->AddGenericArgument(CopyTypeInfo(info->GetParameter(j)->GetType())); + } + return MakePtr(genericType); + } + } + } +} + +/*********************************************************************** +.\ANALYZER\WFANALYZER_VALIDATESEMANTIC.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace analyzer + { + using namespace collections; + using namespace reflection; + using namespace reflection::description; + using namespace typeimpl; + +/*********************************************************************** +Helper Functions +***********************************************************************/ + + IMethodInfo* FindInterfaceConstructor(ITypeDescriptor* type) + { + if (auto ctors = type->GetConstructorGroup()) + { + auto proxyTd = description::GetTypeDescriptor(); + for (vint i = 0; i < ctors->GetMethodCount(); i++) + { + IMethodInfo* info = ctors->GetMethod(i); + if (info->GetParameterCount() == 1) + { + ITypeInfo* parameterType = info->GetParameter(0)->GetType(); + if (parameterType->GetDecorator() == ITypeInfo::SharedPtr) + { + parameterType = parameterType->GetElementType(); + if (parameterType->GetDecorator() == ITypeInfo::TypeDescriptor && parameterType->GetTypeDescriptor() == proxyTd) + { + return info; + } + } + } + } + } + return nullptr; + } + + ITypeInfo* GetFunctionType(const ResolveExpressionResult& result) + { + if (result.eventInfo) + { + return result.eventInfo->GetHandlerType(); + } + else if (result.type) + { + return result.type.Obj(); + } + else + { + return nullptr; + } + } + + Ptr SelectFunction(WfLexicalScopeManager* manager, parsing::ParsingTreeCustomBase* node, Ptr functionExpression, List& functions, List>& arguments, vint& selectedFunctionIndex) + { + selectedFunctionIndex = -1; + + List resolvables; + List> types; + FOREACH(Ptr, argument, arguments) + { + if (!argument || IsExpressionDependOnExpectedType(manager, argument)) + { + resolvables.Add(false); + types.Add(nullptr); + } + else + { + resolvables.Add(true); + types.Add(GetExpressionType(manager, argument, 0)); + } + } + + List> functionErrors, nonFunctionErrors; + List selectedFunctionIndices; + ITypeDescriptor* functionFd = description::GetTypeDescriptor(); + for (vint i = 0; i < functions.Count(); i++) + { + bool failed = false; + auto result = functions[i]; + ITypeInfo* expressionType = GetFunctionType(result); + + if (expressionType->GetDecorator() == ITypeInfo::SharedPtr) + { + ITypeInfo* genericType = expressionType->GetElementType(); + if (genericType->GetDecorator() != ITypeInfo::Generic) goto FUNCTION_TYPE_FAILED; + ITypeInfo* functionType = genericType->GetElementType(); + if (functionType->GetDecorator() != ITypeInfo::TypeDescriptor || functionType->GetTypeDescriptor() != functionFd) goto FUNCTION_TYPE_FAILED; + + if (genericType->GetGenericArgumentCount() != types.Count() + 1) + { + functionErrors.Add(WfErrors::FunctionArgumentCountMismatched(node, arguments.Count(), result)); + failed = true; + } + else + { + for (vint j = 0; j < types.Count(); j++) + { + if (resolvables[j] && types[j]) + { + ITypeInfo* argumentType = genericType->GetGenericArgument(j + 1); + if (!CanConvertToType(types[j].Obj(), argumentType, false)) + { + functionErrors.Add(WfErrors::FunctionArgumentTypeMismatched(node, result, j + 1, types[j].Obj(), argumentType)); + failed = true; + } + } + } + } + } + else + { + goto FUNCTION_TYPE_FAILED; + } + + goto FUNCTION_TYPE_FINISHED; + FUNCTION_TYPE_FAILED: + nonFunctionErrors.Add(WfErrors::ExpressionIsNotFunction(functionExpression.Obj(), result.type.Obj())); + failed = true; + FUNCTION_TYPE_FINISHED: + if (!failed) + { + selectedFunctionIndices.Add(i); + } + } + + if (selectedFunctionIndices.Count() == 1) + { + selectedFunctionIndex = selectedFunctionIndices[0]; + ITypeInfo* genericType = GetFunctionType(functions[selectedFunctionIndex])->GetElementType(); + for (vint i = 0; i < types.Count(); i++) + { + if (!resolvables[i]) + { + ITypeInfo* argumentType = genericType->GetGenericArgument(i + 1); + if (arguments[i]) + { + GetExpressionType(manager, arguments[i], CopyTypeInfo(argumentType)); + } + } + } + return CopyTypeInfo(genericType->GetGenericArgument(0)); + } + else + { + if (selectedFunctionIndices.Count() > 1) + { + List overloadedFunctions; + CopyFrom( + overloadedFunctions, + From(selectedFunctionIndices) + .Select([&functions](vint index) + { + return functions[index]; + })); + manager->errors.Add(WfErrors::CannotPickOverloadedFunctions(node, overloadedFunctions)); + } + + if (functionErrors.Count() > 0) + { + CopyFrom(manager->errors, functionErrors, true); + } + else + { + CopyFrom(manager->errors, nonFunctionErrors, true); + } + return nullptr; + } + } + +/*********************************************************************** +ValidateSemantic(ClassMember) +***********************************************************************/ + + class ValidateSemanticClassMemberVisitor : public Object, public WfDeclaration::IVisitor + { + public: + WfLexicalScopeManager* manager; + Ptr td; + Ptr classDecl; + + ValidateSemanticClassMemberVisitor(Ptr _td, Ptr _classDecl, WfLexicalScopeManager* _manager) + :td(_td) + , classDecl(_classDecl) + , manager(_manager) + { + } + + void Visit(WfNamespaceDeclaration* node)override + { + } + + void Visit(WfFunctionDeclaration* node)override + { + ValidateDeclarationSemantic(manager, node); + } + + void Visit(WfVariableDeclaration* node)override + { + ValidateDeclarationSemantic(manager, node); + } + + void Visit(WfEventDeclaration* node)override + { + ValidateDeclarationSemantic(manager, node); + } + + void Visit(WfPropertyDeclaration* node)override + { + ValidateDeclarationSemantic(manager, node); + + auto scope = manager->nodeScopes[node]; + if (auto typeInfo = CreateTypeInfoFromType(scope.Obj(), node->type)) + { + if (node->getter.value != L"") + { + auto getter = td->GetMethodGroupByName(node->getter.value, false)->GetMethod(0); + if (!IsSameType(typeInfo.Obj(), getter->GetReturn()) || getter->GetParameterCount() != 0) + { + manager->errors.Add(WfErrors::PropertyGetterTypeMismatched(node, classDecl.Obj())); + } + } + + if (node->setter.value != L"") + { + auto setter = td->GetMethodGroupByName(node->setter.value, false)->GetMethod(0); + if (setter->GetReturn()->GetTypeDescriptor() != description::GetTypeDescriptor() || setter->GetParameterCount() != 1 || !IsSameType(typeInfo.Obj(), setter->GetParameter(0)->GetType())) + { + manager->errors.Add(WfErrors::PropertySetterTypeMismatched(node, classDecl.Obj())); + } + } + } + } + + static void SelectConstructor(WfLexicalScopeManager* manager, WfConstructorDeclaration* ctorDecl, parsing::ParsingTreeCustomBase* node, ITypeDescriptor* td, List>& arguments) + { + List functions; + if (auto ctors = td->GetConstructorGroup()) + { + vint count = ctors->GetMethodCount(); + for (vint i = 0; i < count; i++) + { + auto ctor = ctors->GetMethod(i); + functions.Add(ResolveExpressionResult::Method(ctor)); + } + } + + vint selectedFunctionIndex = -1; + SelectFunction(manager, node, nullptr, functions, arguments, selectedFunctionIndex); + if (selectedFunctionIndex != -1) + { + auto ctor = functions[selectedFunctionIndex].methodInfo; + auto call = dynamic_cast(node); + manager->baseConstructorCallResolvings.Add({ctorDecl, td}, {call, ctor}); + } + } + + void Visit(WfConstructorDeclaration* node)override + { + ValidateDeclarationSemantic(manager, node); + + auto scope = manager->nodeScopes[node].Obj(); + auto classScope = scope->parentScope.Obj(); + SortedList baseTypes, initTypes; + { + auto td = classScope->typeOfThisExpr; + vint count = td->GetBaseTypeDescriptorCount(); + for (vint i = 0; i < count; i++) + { + auto baseTd = td->GetBaseTypeDescriptor(i); + if (!baseTypes.Contains(baseTd)) + { + baseTypes.Add(baseTd); + } + } + } + + FOREACH(Ptr, call, node->baseConstructorCalls) + { + if (auto scopeName = GetScopeNameFromReferenceType(classScope, call->type)) + { + if (auto td = scopeName->typeDescriptor) + { + if (initTypes.Contains(td)) + { + manager->errors.Add(WfErrors::DuplicatedBaseConstructorCall(call.Obj(), td)); + } + else if (baseTypes.Contains(td)) + { + initTypes.Add(td); + SelectConstructor(manager, node, call.Obj(), td, call->arguments); + } + else + { + manager->errors.Add(WfErrors::WrongBaseConstructorCall(call.Obj(), td)); + } + } + } + } + + { + vint index = -1; + for (vint i = 0; i < initTypes.Count(); i++) + { + while (baseTypes[++index] != initTypes[i]) + { + auto td = baseTypes[index]; + List> arguments; + SelectConstructor(manager, node, node, td, arguments); + } + } + while (++index < baseTypes.Count()) + { + auto td = baseTypes[index]; + List> arguments; + SelectConstructor(manager, node, node, td, arguments); + } + } + + ValidateStatementSemantic(manager, node->statement); + } + + void Visit(WfDestructorDeclaration* node)override + { + ValidateDeclarationSemantic(manager, node); + ValidateStatementSemantic(manager, node->statement); + } + + void Visit(WfClassDeclaration* node)override + { + ValidateDeclarationSemantic(manager, node); + } + + void Visit(WfEnumDeclaration* node)override + { + ValidateDeclarationSemantic(manager, node); + } + + void Visit(WfStructDeclaration* node)override + { + ValidateDeclarationSemantic(manager, node); + } + + void Visit(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + + static void Execute(Ptr td, Ptr classDecl, Ptr memberDecl, WfLexicalScopeManager* manager) + { + ValidateSemanticClassMemberVisitor visitor(td, classDecl, manager); + memberDecl->Accept(&visitor); + } + }; + +/*********************************************************************** +ValidateSemantic(Declaration) +***********************************************************************/ + + class ValidateSemanticDeclarationVisitor : public Object, public WfDeclaration::IVisitor + { + public: + WfLexicalScopeManager* manager; + + ValidateSemanticDeclarationVisitor(WfLexicalScopeManager* _manager) + :manager(_manager) + { + } + + void Visit(List>& attributes) + { + FOREACH(Ptr, attribute, attributes) + { + auto key = Pair(attribute->category.value, attribute->name.value); + vint index = manager->attributes.Keys().IndexOf(key); + if (index == -1) + { + manager->errors.Add(WfErrors::AttributeNotExists(attribute.Obj())); + } + else + { + auto expectedType = manager->attributes.Values()[index]; + if (attribute->value) + { + ValidateConstantExpression(manager, attribute->value, expectedType); + } + else if (expectedType->GetTypeDescriptor() != description::GetTypeDescriptor()) + { + manager->errors.Add(WfErrors::AttributeMissValue(attribute.Obj())); + } + } + } + } + + void Visit(WfNamespaceDeclaration* node)override + { + FOREACH(Ptr, declaration, node->declarations) + { + ValidateDeclarationSemantic(manager, declaration); + } + } + + void Visit(WfFunctionDeclaration* node)override + { + if (node->statement) + { + ValidateStatementSemantic(manager, node->statement); + } + FOREACH(Ptr, argument, node->arguments) + { + Visit(argument->attributes); + } + } + + void Visit(WfVariableDeclaration* node)override + { + auto scope = manager->nodeScopes[node]; + auto symbol = scope->symbols[node->name.value][0]; + symbol->typeInfo = GetExpressionType(manager, node->expression, symbol->typeInfo); + if (symbol->typeInfo && !symbol->type) + { + symbol->type = GetTypeFromTypeInfo(symbol->typeInfo.Obj()); + } + } + + void Visit(WfEventDeclaration* node)override + { + } + + void Visit(WfPropertyDeclaration* node)override + { + } + + void Visit(WfConstructorDeclaration* node)override + { + } + + void Visit(WfDestructorDeclaration* node)override + { + } + + void Visit(WfClassDeclaration* node)override + { + auto scope = manager->nodeScopes[node]; + auto td = manager->declarationTypes[node].Cast(); + + if (node->kind == WfClassKind::Interface) + { + FOREACH(Ptr, baseType, node->baseTypes) + { + auto scopeName = GetScopeNameFromReferenceType(scope->parentScope.Obj(), baseType); + auto baseTd = scopeName->typeDescriptor; + auto ctor = FindInterfaceConstructor(baseTd); + if (ctor == nullptr) + { + manager->errors.Add(WfErrors::WrongInterfaceBaseType(node, baseTd)); + } + } + } + + FOREACH(Ptr, memberDecl, node->declarations) + { + ValidateClassMemberSemantic(manager, td, node, memberDecl); + } + } + + void Visit(WfEnumDeclaration* node)override + { + FOREACH(Ptr, item, node->items) + { + Visit(item->attributes); + } + } + + void SearchForItself(WfStructDeclaration* node, ITypeDescriptor* target, ITypeDescriptor* current, List& path) + { + if (target == current) + { + manager->errors.Add(WfErrors::StructRecursivelyIncludeItself( + node, + From(path).Aggregate([](const WString& a, const WString& b) {return a + L"::" + b; }) + )); + return; + } + + if (current == nullptr) + { + current = target; + } + + vint count = current->GetPropertyCount(); + for (vint i = 0; i < count; i++) + { + auto prop = current->GetProperty(i); + auto propType = prop->GetReturn(); + auto propTd = prop->GetReturn()->GetTypeDescriptor(); + if (propType->GetDecorator()==ITypeInfo::TypeDescriptor && propTd->GetTypeDescriptorFlags() == TypeDescriptorFlags::Struct) + { + vint index = path.Add(prop->GetName()); + SearchForItself(node, target, propTd, path); + path.RemoveAt(index); + } + } + } + + void Visit(WfStructDeclaration* node)override + { + auto scope = manager->nodeScopes[node]; + auto td = manager->declarationTypes[node].Cast(); + FOREACH(Ptr, member, node->members) + { + auto memberTd = td->GetPropertyByName(member->name.value, false)->GetReturn()->GetTypeDescriptor(); + if ((memberTd->GetTypeDescriptorFlags() & TypeDescriptorFlags::ReferenceType) != TypeDescriptorFlags::Undefined) + { + manager->errors.Add(WfErrors::StructContainsNonValueType(member.Obj(), node)); + } + } + List path; + path.Add(td->GetTypeName()); + SearchForItself(node, td.Obj(), nullptr, path); + + FOREACH(Ptr, member, node->members) + { + Visit(member->attributes); + } + } + + void Visit(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + + static void Execute(Ptr declaration, WfLexicalScopeManager* manager) + { + ValidateSemanticDeclarationVisitor visitor(manager); + declaration->Accept(&visitor); + visitor.Visit(declaration->attributes); + } + }; + +/*********************************************************************** +ValidateSemantic(Statement) +***********************************************************************/ + + class ExpandVirtualStatementVisitor : public Object, public WfVirtualStatement::IVisitor + { + public: + WfLexicalScopeManager* manager; + + ExpandVirtualStatementVisitor(WfLexicalScopeManager* _manager) + :manager(_manager) + { + } + + void Visit(WfSwitchStatement* node)override + { + ExpandSwitchStatement(manager, node); + } + + void Visit(WfForEachStatement* node)override + { + ExpandForEachStatement(manager, node); + } + + void Visit(WfCoProviderStatement* node)override + { + ExpandCoProviderStatement(manager, node); + } + }; + + class ValidateSemanticStatementVisitor + : public Object + , public WfStatement::IVisitor + , public WfVirtualStatement::IVisitor + , public WfCoroutineStatement::IVisitor + { + public: + WfLexicalScopeManager* manager; + + ValidateSemanticStatementVisitor(WfLexicalScopeManager* _manager) + :manager(_manager) + { + } + + void Visit(WfBreakStatement* node)override + { + } + + void Visit(WfContinueStatement* node)override + { + } + + void Visit(WfReturnStatement* node)override + { + auto scope = manager->nodeScopes[node].Obj(); + auto functionScope = scope->FindFunctionScope(); + if (auto funcDecl = functionScope->ownerNode.Cast()) + { + auto providerStat = funcDecl->statement.Cast(); + if (providerStat && !providerStat->expandedStatement) + { + auto providerScope = manager->nodeScopes[funcDecl->statement.Obj()]; + auto providerSymbol = providerScope->symbols[L"$PROVIDER"][0]; + auto implSymbol = providerScope->symbols[L"$IMPL"][0]; + if (providerSymbol->typeInfo && implSymbol->typeInfo) + { + if (auto group = providerSymbol->typeInfo->GetTypeDescriptor()->GetMethodGroupByName(L"ReturnAndExit", true)) + { + List functions; + vint count = group->GetMethodCount(); + for (vint i = 0; i < count; i++) + { + auto method = group->GetMethod(i); + if (method->IsStatic()) + { + if (method->GetParameterCount() > 0 && IsSameType(implSymbol->typeInfo.Obj(), method->GetParameter(0)->GetType())) + { + functions.Add(ResolveExpressionResult::Method(method)); + } + } + } + + vint selectedFunctionIndex = -1; + List> arguments; + arguments.Add(nullptr); + if (node->expression) + { + arguments.Add(node->expression); + } + SelectFunction(manager, node, nullptr, functions, arguments, selectedFunctionIndex); + if (selectedFunctionIndex != -1) + { + manager->coOperatorResolvings.Add(node, functions[selectedFunctionIndex]); + } + } + else + { + manager->errors.Add(WfErrors::CoOperatorNotExists(node, providerSymbol->typeInfo.Obj())); + } + } + } + else + { + auto returnType = CreateTypeInfoFromType(scope, funcDecl->returnType); + if (node->expression) + { + if (returnType->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + manager->errors.Add(WfErrors::CannotReturnExpression(node)); + } + else + { + GetExpressionType(manager, node->expression, returnType); + } + } + else if (returnType->GetDecorator() != ITypeInfo::TypeDescriptor || returnType->GetTypeDescriptor() != description::GetTypeDescriptor()) + { + manager->errors.Add(WfErrors::ReturnMissExpression(node, returnType.Obj())); + } + } + } + else + { + if (node->expression) + { + manager->errors.Add(WfErrors::CannotReturnExpression(node)); + } + } + } + + void Visit(WfDeleteStatement* node)override + { + Ptr type = GetExpressionType(manager, node->expression, 0); + if (type) + { + if (type->GetDecorator() != ITypeInfo::RawPtr) + { + manager->errors.Add(WfErrors::DeleteNonRawPointer(node, type.Obj())); + } + } + } + + void Visit(WfRaiseExceptionStatement* node)override + { + if (node->expression) + { + if (auto type = GetExpressionType(manager, node->expression, nullptr)) + { + auto stringType = TypeInfoRetriver::CreateTypeInfo(); + auto exceptionType = TypeInfoRetriver>::CreateTypeInfo(); + if (!CanConvertToType(type.Obj(), stringType.Obj(), false) && !CanConvertToType(type.Obj(), exceptionType.Obj(), false)) + { + manager->errors.Add(WfErrors::ExpressionCannotImplicitlyConvertToType(node->expression.Obj(), type.Obj(), stringType.Obj())); + } + } + } + } + + void Visit(WfIfStatement* node)override + { + if (node->type) + { + auto scope = manager->nodeScopes[node].Obj(); + auto symbol = scope->symbols[node->name.value][0]; + if (!IsNullAcceptableType(symbol->typeInfo.Obj())) + { + manager->errors.Add(WfErrors::NullCannotImplicitlyConvertToType(node->expression.Obj(), symbol->typeInfo.Obj())); + } + GetExpressionType(manager, node->expression, nullptr); + } + else + { + Ptr boolType = TypeInfoRetriver::CreateTypeInfo(); + GetExpressionType(manager, node->expression, boolType); + } + ValidateStatementSemantic(manager, node->trueBranch); + if (node->falseBranch) + { + ValidateStatementSemantic(manager, node->falseBranch); + } + } + + void Visit(WfWhileStatement* node)override + { + Ptr boolType = TypeInfoRetriver::CreateTypeInfo(); + GetExpressionType(manager, node->condition, boolType); + ValidateStatementSemantic(manager, node->statement); + } + + void Visit(WfTryStatement* node)override + { + ValidateStatementSemantic(manager, node->protectedStatement); + if (node->catchStatement) + { + ValidateStatementSemantic(manager, node->catchStatement); + } + if (node->finallyStatement) + { + ValidateStatementSemantic(manager, node->finallyStatement); + } + } + + void Visit(WfBlockStatement* node)override + { + FOREACH(Ptr, statement, node->statements) + { + ValidateStatementSemantic(manager, statement); + } + } + + void Visit(WfExpressionStatement* node)override + { + GetExpressionType(manager, node->expression, 0); + } + + void Visit(WfVariableStatement* node)override + { + ValidateDeclarationSemantic(manager, node->variable); + } + + void Visit(WfVirtualStatement* node)override + { + bool expanded = node->expandedStatement; + vint errorCount = manager->errors.Count(); + node->Accept((WfVirtualStatement::IVisitor*)this); + + if (!expanded && manager->errors.Count() == errorCount) + { + ExpandVirtualStatementVisitor visitor(manager); + node->Accept(&visitor); + SetCodeRange(node->expandedStatement, node->codeRange); + + auto parentScope = manager->nodeScopes[node]; + if (parentScope->ownerNode == node) + { + parentScope = parentScope->parentScope; + } + + ContextFreeStatementDesugar(manager, node->expandedStatement); + BuildScopeForStatement(manager, parentScope, node->expandedStatement); + if (!CheckScopes_DuplicatedSymbol(manager) || !CheckScopes_SymbolType(manager)) + { + return; + } + } + + if (node->expandedStatement) + { + ValidateStatementSemantic(manager, node->expandedStatement); + } + } + + void Visit(WfSwitchStatement* node)override + { + Ptr type = GetExpressionType(manager, node->expression, 0); + FOREACH(Ptr, switchCase, node->caseBranches) + { + Ptr caseType; + if (IsExpressionDependOnExpectedType(manager, switchCase->expression)) + { + caseType = GetExpressionType(manager, switchCase->expression, type); + } + else + { + caseType = GetExpressionType(manager, switchCase->expression, 0); + } + + if (type && caseType) + { + if (!GetMergedType(type, caseType)) + { + manager->errors.Add(WfErrors::CannotMergeTwoType(switchCase->expression.Obj(), type.Obj(), caseType.Obj())); + } + } + ValidateStatementSemantic(manager, switchCase->statement); + } + if (node->defaultBranch) + { + ValidateStatementSemantic(manager, node->defaultBranch); + } + } + + void Visit(WfForEachStatement* node)override + { + Ptr elementType = GetEnumerableExpressionItemType(manager, node->collection, 0); + if (elementType) + { + auto scope = manager->nodeScopes[node].Obj(); + auto symbol = scope->symbols[node->name.value][0]; + symbol->typeInfo = elementType; + symbol->type = GetTypeFromTypeInfo(elementType.Obj()); + } + ValidateStatementSemantic(manager, node->statement); + } + + void Visit(WfCoProviderStatement* node)override + { + auto scope = manager->nodeScopes[node].Obj(); + auto providerSymbol = scope->symbols[L"$PROVIDER"][0]; + auto implSymbol = scope->symbols[L"$IMPL"][0]; + Ptr funcReturnType; + { + auto decl = scope->parentScope->ownerNode.Cast(); + funcReturnType = CreateTypeInfoFromType(scope->parentScope.Obj(), decl->returnType); + } + ITypeDescriptor* selectedProviderTd = nullptr; + List candidates; + + if (node->name.value == L"") + { + if (funcReturnType) + { + List unprocessed; + unprocessed.Add(funcReturnType->GetTypeDescriptor()); + + for (vint i = 0; i < unprocessed.Count(); i++) + { + auto td = unprocessed[i]; + auto candidate = td->GetTypeName() + L"Coroutine"; + if ((selectedProviderTd = description::GetTypeDescriptor(candidate))) + { + break; + } + else + { + candidates.Add(candidate); + } + + vint count = td->GetBaseTypeDescriptorCount(); + for (vint i = 0; i < count; i++) + { + auto baseTd = td->GetBaseTypeDescriptor(i); + if (!unprocessed.Contains(baseTd)) + { + unprocessed.Add(baseTd); + } + } + } + } + } + else + { + List results, resolveResults; + auto providerName = node->name.value.Right(node->name.value.Length() - 1); + + if (manager->ResolveName(scope, providerName, resolveResults)) + { + CopyFrom(results, resolveResults); + + for (vint i = results.Count() - 1; i >= 0; i--) + { + auto& result = results[i]; + ITypeDescriptor* providerTd = nullptr; + + if (result.scopeName && result.scopeName->typeDescriptor) + { + auto candidate = result.scopeName->typeDescriptor->GetTypeName() + L"Coroutine"; + providerTd = description::GetTypeDescriptor(candidate); + if (providerTd) + { + selectedProviderTd = providerTd; + } + else + { + candidates.Add(candidate); + } + } + + if (!providerTd) + { + results.RemoveAt(i); + } + } + + if (results.Count() == 1) + { + goto FINISH_SEARCHING; + } + else if (results.Count() > 1) + { + manager->errors.Add(WfErrors::TooManyTargets(node, resolveResults, providerName)); + goto SKIP_SEARCHING; + } + } + + resolveResults.Clear(); + if (manager->ResolveName(scope, providerName + L"Coroutine", resolveResults)) + { + CopyFrom(results, resolveResults); + + for (vint i = results.Count() - 1; i >= 0; i--) + { + auto& result = results[i]; + + if (result.scopeName && result.scopeName->typeDescriptor) + { + selectedProviderTd = result.scopeName->typeDescriptor; + } + else + { + results.RemoveAt(i); + } + } + + if (results.Count() == 1) + { + goto FINISH_SEARCHING; + } + else if (results.Count() > 1) + { + manager->errors.Add(WfErrors::TooManyTargets(node, resolveResults, providerName)); + goto SKIP_SEARCHING; + } + } + + candidates.Add(providerName); + candidates.Add(providerName + L"Coroutine"); + } + + FINISH_SEARCHING: + if (selectedProviderTd) + { + providerSymbol->typeInfo = MakePtr(selectedProviderTd, TypeInfoHint::Normal); + + if (funcReturnType) + { + WString creatorName; + if (funcReturnType->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + creatorName = L"CreateAndRun"; + } + else + { + creatorName = L"Create"; + } + + if (auto group = selectedProviderTd->GetMethodGroupByName(creatorName, true)) + { + List results; + ITypeInfo* selectedImplType = nullptr; + IMethodInfo* selectedCreator = nullptr; + vint count = group->GetMethodCount(); + + for (vint i = 0; i < count; i++) + { + auto method = group->GetMethod(i); + if (method->IsStatic()) + { + if (method->GetParameterCount() == 1) + { + auto creatorType = method->GetParameter(0)->GetType(); + if (creatorType->GetDecorator() == ITypeInfo::SharedPtr) + { + auto functionType = creatorType->GetElementType(); + if (functionType->GetDecorator() == ITypeInfo::Generic && + functionType->GetGenericArgumentCount() == 2 && + functionType->GetTypeDescriptor() == description::GetTypeDescriptor() + ) + { + auto returnType = functionType->GetGenericArgument(0); + if (returnType->GetDecorator() == ITypeInfo::SharedPtr &&returnType->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + selectedImplType = functionType->GetGenericArgument(1); + selectedCreator = method; + results.Add(ResolveExpressionResult::Method(method)); + } + } + } + } + } + } + + if (results.Count() == 1) + { + implSymbol->typeInfo = CopyTypeInfo(selectedImplType); + manager->coProviderResolvings.Add(node, ResolveExpressionResult::Method(selectedCreator)); + } + else if (results.Count() > 1) + { + manager->errors.Add(WfErrors::TooManyTargets(node, results, creatorName)); + } + } + + if (!implSymbol->typeInfo) + { + if (funcReturnType->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + manager->errors.Add(WfErrors::CoProviderCreateAndRunNotExists(node, providerSymbol->typeInfo.Obj())); + } + else + { + manager->errors.Add(WfErrors::CoProviderCreateNotExists(node, providerSymbol->typeInfo.Obj())); + } + } + } + } + else + { + manager->errors.Add(WfErrors::CoProviderNotExists(node, candidates)); + } + SKIP_SEARCHING: + ValidateStatementSemantic(manager, node->statement); + } + + void Visit(WfCoroutineStatement* node)override + { + node->Accept((WfCoroutineStatement::IVisitor*)this); + } + + void Visit(WfCoPauseStatement* node)override + { + if (node->statement) + { + ValidateStatementSemantic(manager, node->statement); + } + } + + void Visit(WfCoOperatorStatement* node)override + { + auto scope = manager->nodeScopes[node].Obj(); + auto functionScope = scope->FindFunctionScope(); + if (auto funcDecl = functionScope->ownerNode.Cast()) + { + if (funcDecl->statement.Cast()) + { + auto providerScope = manager->nodeScopes[funcDecl->statement.Obj()]; + auto providerSymbol = providerScope->symbols[L"$PROVIDER"][0]; + auto implSymbol = providerScope->symbols[L"$IMPL"][0]; + if (providerSymbol->typeInfo && implSymbol->typeInfo) + { + List groups; + auto operatorName = node->opName.value.Right(node->opName.value.Length() - 1); + if (auto group = providerSymbol->typeInfo->GetTypeDescriptor()->GetMethodGroupByName(operatorName + L"AndRead", true)) + { + groups.Add(group); + } + if (node->varName.value == L"") + { + if (auto group = providerSymbol->typeInfo->GetTypeDescriptor()->GetMethodGroupByName(operatorName + L"AndPause", true)) + { + groups.Add(group); + } + } + + if (groups.Count() == 0) + { + manager->errors.Add(WfErrors::CoOperatorNotExists(node, providerSymbol->typeInfo.Obj())); + } + else + { + List functions; + FOREACH(IMethodGroupInfo*, group, groups) + { + vint count = group->GetMethodCount(); + for (vint i = 0; i < count; i++) + { + auto method = group->GetMethod(i); + if (method->IsStatic()) + { + if (method->GetParameterCount() > 0 && IsSameType(implSymbol->typeInfo.Obj(), method->GetParameter(0)->GetType())) + { + functions.Add(ResolveExpressionResult::Method(method)); + } + } + } + } + + vint selectedFunctionIndex = -1; + vint oldErrorCount = manager->errors.Count(); + List> arguments; + arguments.Add(nullptr); + CopyFrom(arguments, node->arguments, true); + SelectFunction(manager, node, nullptr, functions, arguments, selectedFunctionIndex); + if (selectedFunctionIndex != -1) + { + manager->coOperatorResolvings.Add(node, functions[selectedFunctionIndex]); + if (node->varName.value != L"" && manager->errors.Count() == oldErrorCount) + { + auto symbol = scope->symbols[node->varName.value][0]; + List types; + + FOREACH(Ptr, argument, node->arguments) + { + vint index = manager->expressionResolvings.Keys().IndexOf(argument.Obj()); + if (index != -1) + { + auto type = manager->expressionResolvings.Values()[index].type; + if (!types.Contains(type.Obj())) + { + types.Add(type.Obj()); + if (auto group = type->GetTypeDescriptor()->GetMethodGroupByName(L"CastResult", true)) + { + vint count = group->GetMethodCount(); + for (vint i = 0; i < count; i++) + { + auto method = group->GetMethod(i); + if (method->IsStatic()) + { + if (method->GetParameterCount() == 1 && + method->GetParameter(0)->GetType()->GetTypeDescriptor() == description::GetTypeDescriptor() && + method->GetReturn()->GetTypeDescriptor() != description::GetTypeDescriptor() + ) + { + manager->coCastResultResolvings.Add(node, ResolveExpressionResult::Method(method)); + symbol->typeInfo = CopyTypeInfo(method->GetReturn()); + break; + } + } + } + } + } + } + } + + if (!symbol->typeInfo) + { + manager->errors.Add(WfErrors::CoOperatorCannotResolveResultType(node, types)); + } + } + } + } + } + } + } + } + + static void Execute(Ptr statement, WfLexicalScopeManager* manager) + { + ValidateSemanticStatementVisitor visitor(manager); + statement->Accept(&visitor); + } + }; + +/*********************************************************************** +ValidateSemantic(Expression) +***********************************************************************/ + + class ExpandVirtualExpressionVisitor : public Object, public WfVirtualExpression::IVisitor + { + public: + WfLexicalScopeManager* manager; + Ptr expectedType; + + ExpandVirtualExpressionVisitor(WfLexicalScopeManager* _manager, Ptr _expectedType) + :manager(_manager) + , expectedType(_expectedType) + { + } + + void Visit(WfBindExpression* node)override + { + ExpandBindExpression(manager, node); + } + + void Visit(WfFormatExpression* node)override + { + } + + void Visit(WfNewCoroutineExpression* node)override + { + ExpandNewCoroutineExpression(manager, node); + } + + void Visit(WfMixinCastExpression* node)override + { + ExpandMixinCastExpression(manager, node); + } + + void Visit(WfExpectedTypeCastExpression* node)override + { + auto castExpr = MakePtr(); + castExpr->strategy = node->strategy; + castExpr->expression = CopyExpression(node->expression); + castExpr->type = GetTypeFromTypeInfo(expectedType.Obj()); + node->expandedExpression = castExpr; + } + }; + + class ValidateSemanticExpressionVisitor + : public Object + , public WfExpression::IVisitor + , public WfVirtualExpression::IVisitor + { + public: + WfLexicalScopeManager* manager; + Ptr expectedType; + List& results; + + ValidateSemanticExpressionVisitor(WfLexicalScopeManager* _manager, Ptr _expectedType, List& _results) + :manager(_manager) + , expectedType(_expectedType) + , results(_results) + { + } + + void Visit(WfThisExpression* node)override + { + auto scope = manager->nodeScopes[node].Obj(); + Ptr lastConfig; + while (scope) + { + if (auto config = scope->functionConfig) + { + lastConfig = config; + if (!lastConfig->thisAccessable) + { + break; + } + } + + if (scope->typeOfThisExpr) + { + if (!lastConfig) + { + break; + } + + if (lastConfig->thisAccessable) + { + auto elementType = MakePtr(scope->typeOfThisExpr, TypeInfoHint::Normal); + auto pointerType = MakePtr(elementType); + + results.Add(ResolveExpressionResult::ReadonlyType(pointerType)); + return; + } + } + scope = scope->parentScope.Obj(); + } + manager->errors.Add(WfErrors::WrongThisExpression(node)); + } + + void Visit(WfTopQualifiedExpression* node)override + { + if (manager->globalName) + { + vint index = manager->globalName->children.Keys().IndexOf(node->name.value); + if (index != -1) + { + results.Add(ResolveExpressionResult::ScopeName(manager->globalName->children.Values()[index])); + return; + } + } + manager->errors.Add(WfErrors::TopQualifiedSymbolNotExists(node, node->name.value)); + } + + void ResolveName(WfExpression* node, const WString& name) + { + auto scope = manager->nodeScopes[node].Obj(); + List nameResults; + manager->ResolveName(scope, name, nameResults); + + for (vint i = 0; i < nameResults.Count(); i++) + { + auto& result = nameResults[i]; + if (result.symbol) + { + if (!result.type) + { + manager->errors.Add(WfErrors::ExpressionCannotResolveType(node, result.symbol)); + } + else if (!result.symbol->creatorNode.Cast() || result.symbol->creatorNode.Cast()) + { + bool readonlyCaptured = false; + if (!result.symbol->ownerScope->ownerNode.Cast() && !result.symbol->ownerScope->ownerNode.Cast()) + { + auto currentScope = scope; + WfLexicalScope* firstConfigScope = nullptr; + WfLexicalScope* lastConfigScope = nullptr; + while (currentScope) + { + if (currentScope->functionConfig) + { + if (!firstConfigScope) + { + firstConfigScope = currentScope; + } + lastConfigScope = currentScope; + } + + if (result.symbol->ownerScope == currentScope) + { + if (firstConfigScope && firstConfigScope->functionConfig->lambda) + { + readonlyCaptured = true; + } + + if (currentScope->ownerNode.Cast()) + { + if (firstConfigScope) + { + readonlyCaptured = firstConfigScope != lastConfigScope; + + if (!lastConfigScope->GetOwnerClassMember()) + { + manager->errors.Add(WfErrors::FieldCannotInitializeUsingEachOther(node, result)); + } + } + else + { + manager->errors.Add(WfErrors::FieldCannotInitializeUsingEachOther(node, result)); + } + } + break; + } + + if (currentScope->ownerNode.Cast()) + { + auto capture = manager->lambdaCaptures[currentScope->ownerNode.Obj()]; + if (!capture->ctorArgumentSymbols.Contains(result.symbol.Obj())) + { + if (lastConfigScope == nullptr) + { + capture->ctorArgumentSymbols.Add(result.symbol); + } + else + { + auto functionCapture = manager->lambdaCaptures[lastConfigScope->ownerNode.Obj()]; + if (capture != functionCapture) + { + capture->ctorArgumentSymbols.Add(result.symbol); + } + } + } + } + + if (currentScope->functionConfig) + { + if (currentScope->functionConfig->lambda) + { + auto capture = manager->lambdaCaptures[currentScope->ownerNode.Obj()]; + if (!capture->symbols.Contains(result.symbol.Obj())) + { + capture->symbols.Add(result.symbol); + } + } + } + currentScope = currentScope->parentScope.Obj(); + } + } + + if (readonlyCaptured) + { + results.Add(ResolveExpressionResult::ReadonlySymbol(result.symbol)); + } + else + { + results.Add(ResolveExpressionResult::Symbol(result.symbol)); + } + } + else + { + results.Add(result); + } + } + else + { + if (result.propertyInfo && dynamic_cast(node)) + { + auto currentScope = scope; + WfLexicalScope* firstConfigScope = nullptr; + WfLexicalScope* lastConfigScope = nullptr; + while (currentScope) + { + if (currentScope->functionConfig) + { + if (!firstConfigScope) + { + firstConfigScope = currentScope; + } + lastConfigScope = currentScope; + } + + if (currentScope->ownerNode.Cast() && currentScope->typeOfThisExpr == result.propertyInfo->GetOwnerTypeDescriptor()) + { + if (firstConfigScope) + { + bool inMethodBody = lastConfigScope->GetOwnerClassMember() && lastConfigScope->ownerNode.Cast(); + bool inDtorBody = lastConfigScope->GetOwnerClassMember() && lastConfigScope->ownerNode.Cast(); + bool inCtorBody = lastConfigScope->parentScope->GetOwnerClassMember() && lastConfigScope->parentScope->ownerNode.Cast(); + + if (!inMethodBody && !inDtorBody && !inCtorBody) + { + manager->errors.Add(WfErrors::FieldCannotInitializeUsingEachOther(node, result)); + } + } + else if (!scope->ownerNode.Cast()) + { + manager->errors.Add(WfErrors::FieldCannotInitializeUsingEachOther(node, result)); + } + } + currentScope = currentScope->parentScope.Obj(); + } + } + results.Add(result); + } + } + + if (results.Count() == 0) + { + if (nameResults.Count() > 0) + { + FOREACH(ResolveExpressionResult, result, nameResults) + { + manager->errors.Add(WfErrors::ExpressionCannotResolveType(node, result.symbol)); + } + } + else + { + manager->errors.Add(WfErrors::ReferenceNotExists(node, name)); + } + } + } + + void Visit(WfReferenceExpression* node)override + { + if (expectedType && (expectedType->GetTypeDescriptor()->GetTypeDescriptorFlags() & TypeDescriptorFlags::EnumType) != TypeDescriptorFlags::Undefined) + { + auto scope = manager->nodeScopes[node].Obj(); + List testResults; + manager->ResolveName(scope, node->name.value, testResults); + + if (testResults.Count() == 0) + { + auto enumType = expectedType->GetTypeDescriptor()->GetEnumType(); + if (enumType->IndexOfItem(node->name.value) == -1) + { + manager->errors.Add(WfErrors::EnumItemNotExists(node, expectedType->GetTypeDescriptor(), node->name.value)); + } + else + { + results.Add(ResolveExpressionResult::ReadonlyType(expectedType)); + } + return; + } + } + + ResolveName(node, node->name.value); + FOREACH(ResolveExpressionResult, result, results) + { + ITypeDescriptor* td = nullptr; + if (result.methodInfo) + { + td = result.methodInfo->GetOwnerTypeDescriptor(); + } + else if (result.propertyInfo) + { + td = result.propertyInfo->GetOwnerTypeDescriptor(); + } + else if (result.eventInfo) + { + td = result.eventInfo->GetOwnerTypeDescriptor(); + } + + if (td) + { + auto scope = manager->nodeScopes[node].Obj(); + bool visibleToNonStatic = false; + while (scope) + { + if (scope->functionConfig) + { + visibleToNonStatic = scope->functionConfig->thisAccessable || scope->functionConfig->parentThisAccessable; + } + + if (scope->typeOfThisExpr && scope->typeOfThisExpr->CanConvertTo(td)) + { + if (!visibleToNonStatic) + { + if (result.methodInfo) + { + if (!result.methodInfo->IsStatic()) + { + manager->errors.Add(WfErrors::CannotCallMemberInStaticFunction(node, result)); + } + } + else if (result.propertyInfo) + { + manager->errors.Add(WfErrors::CannotCallMemberInStaticFunction(node, result)); + } + else if (result.eventInfo) + { + manager->errors.Add(WfErrors::CannotCallMemberInStaticFunction(node, result)); + } + break; + } + } + scope = scope->parentScope.Obj(); + } + } + } + } + + void Visit(WfOrderedNameExpression* node)override + { + ResolveName(node, node->name.value); + } + + void Visit(WfOrderedLambdaExpression* node)override + { + auto scope = manager->nodeScopes[node].Obj(); + List> parameterSymbols; + CopyFrom( + parameterSymbols, + Range(0, scope->symbols.Count()) + .Select([scope](vint index)->Ptr{return scope->symbols.GetByIndex(index)[0];}) + .OrderBy([](Ptr a, Ptr b) + { + vint aId = wtoi(a->name.Sub(1, a->name.Length() - 1)); + vint bId = wtoi(b->name.Sub(1, a->name.Length() - 1)); + return aId - bId; + }) + ); + Ptr resultType = expectedType; + + if (!expectedType && parameterSymbols.Count() > 0) + { + manager->errors.Add(WfErrors::OrderedLambdaCannotResolveType(node)); + return; + } + else if (expectedType) + { + ITypeInfo* type = expectedType.Obj(); + if (type->GetDecorator() != ITypeInfo::SharedPtr) + { + goto ORDERED_FAILED; + } + type = type->GetElementType(); + if (type->GetDecorator() != ITypeInfo::Generic) + { + goto ORDERED_FAILED; + } + { + ITypeInfo* functionType = type->GetElementType(); + if (functionType->GetDecorator() != ITypeInfo::TypeDescriptor) + { + goto ORDERED_FAILED; + } + if (functionType->GetTypeDescriptor() != description::GetTypeDescriptor()) + { + goto ORDERED_FAILED; + } + } + + if (type->GetGenericArgumentCount() != parameterSymbols.Count() + 1) + { + goto ORDERED_FAILED; + } + + Ptr resultType = type->GetGenericArgument(0); + FOREACH_INDEXER(Ptr, symbol, index, parameterSymbols) + { + symbol->typeInfo = type->GetGenericArgument(index + 1); + symbol->type = GetTypeFromTypeInfo(symbol->typeInfo.Obj()); + } + GetExpressionType(manager, node->body, resultType); + } + else + { + auto bodyType = GetExpressionType(manager, node->body, 0); + if (bodyType) + { + auto funcType = MakePtr(description::GetTypeDescriptor(), TypeInfoHint::Normal); + auto genericType = MakePtr(funcType); + genericType->AddGenericArgument(bodyType); + + resultType = MakePtr(genericType); + } + } + + goto ORDERED_FINISHED; + ORDERED_FAILED: + manager->errors.Add(WfErrors::OrderedLambdaCannotImplicitlyConvertToType(node, expectedType.Obj())); + ORDERED_FINISHED: + if (resultType) + { + results.Add(ResolveExpressionResult::ReadonlyType(resultType)); + } + } + + void Visit(WfMemberExpression* node)override + { + Ptr type = GetExpressionType(manager, node->parent, 0); + if (type) + { + SortedList searchedTypes; + manager->ResolveMember(type->GetTypeDescriptor(), node->name.value, false, searchedTypes, results); + + if (results.Count() == 0) + { + manager->errors.Add(WfErrors::MemberNotExists(node, type->GetTypeDescriptor(), node->name.value)); + } + } + } + + void Visit(WfChildExpression* node)override + { + if (Ptr scopeName = GetExpressionScopeName(manager, node->parent)) + { + vint index = scopeName->children.Keys().IndexOf(node->name.value); + if (index != -1) + { + results.Add(ResolveExpressionResult::ScopeName(scopeName->children.Values()[index])); + return; + } + + if (scopeName->typeDescriptor) + { + SortedList searchedTypes; + manager->ResolveMember(scopeName->typeDescriptor, node->name.value, true, searchedTypes, results); + + if (results.Count() > 0) + { + FOREACH(ResolveExpressionResult, result, results) + { + if (result.methodInfo) + { + if (!result.methodInfo->IsStatic()) + { + manager->errors.Add(WfErrors::CannotCallMemberOutsideOfClass(node, result)); + } + } + else if (result.propertyInfo) + { + manager->errors.Add(WfErrors::CannotCallMemberOutsideOfClass(node, result)); + } + else if (result.eventInfo) + { + manager->errors.Add(WfErrors::CannotCallMemberOutsideOfClass(node, result)); + } + } + return; + } + } + + if (scopeName->typeDescriptor != nullptr && (scopeName->typeDescriptor->GetTypeDescriptorFlags() & TypeDescriptorFlags::EnumType) != TypeDescriptorFlags::Undefined) + { + manager->errors.Add(WfErrors::EnumItemNotExists(node, scopeName->typeDescriptor, node->name.value)); + } + else + { + manager->errors.Add(WfErrors::ChildSymbolNotExists(node, scopeName, node->name.value)); + } + } + } + + void Visit(WfLiteralExpression* node)override + { + if (node->value == WfLiteralValue::Null) + { + if (!expectedType) + { + manager->errors.Add(WfErrors::NullCannotResolveType(node)); + } + else if (!IsNullAcceptableType(expectedType.Obj())) + { + manager->errors.Add(WfErrors::NullCannotImplicitlyConvertToType(node, expectedType.Obj())); + } + + results.Add(ResolveExpressionResult::ReadonlyType(expectedType)); + } + else + { + results.Add(ResolveExpressionResult::ReadonlyType(TypeInfoRetriver::CreateTypeInfo())); + } + } + + void Visit(WfFloatingExpression* node)override + { + auto typeDescriptor = expectedType ? expectedType->GetTypeDescriptor() : nullptr; + if (!typeDescriptor || typeDescriptor->GetTypeDescriptorFlags() == TypeDescriptorFlags::Object || typeDescriptor == description::GetTypeDescriptor()) + { + typeDescriptor = description::GetTypeDescriptor(); + } + + if (auto serializableType = typeDescriptor->GetSerializableType()) + { + Value output; + if (serializableType->Deserialize(node->value.value, output)) + { + results.Add(ResolveExpressionResult::ReadonlyType(MakePtr(typeDescriptor, TypeInfoHint::Normal))); + return; + } + } + manager->errors.Add(WfErrors::FloatingLiteralOutOfRange(node)); + } + + void Visit(WfIntegerExpression* node)override + { + auto typeDescriptor = expectedType ? expectedType->GetTypeDescriptor() : nullptr; + if (!typeDescriptor || typeDescriptor->GetTypeDescriptorFlags() == TypeDescriptorFlags::Object || typeDescriptor==description::GetTypeDescriptor()) + { +#ifdef VCZH_64 + typeDescriptor = description::GetTypeDescriptor(); +#else + typeDescriptor = description::GetTypeDescriptor(); +#endif + } + + if (auto serializableType = typeDescriptor->GetSerializableType()) + { + Value output; + if (serializableType->Deserialize(node->value.value, output)) + { + results.Add(ResolveExpressionResult::ReadonlyType(MakePtr(typeDescriptor, TypeInfoHint::Normal))); + return; + } + } + manager->errors.Add(WfErrors::IntegerLiteralOutOfRange(node)); + } + + void Visit(WfStringExpression* node)override + { + results.Add(ResolveExpressionResult::ReadonlyType(TypeInfoRetriver::CreateTypeInfo())); + } + + void Visit(WfUnaryExpression* node)override + { + Ptr typeInfo = GetExpressionType(manager, node->operand, 0); + if (typeInfo) + { + TypeFlag flag = GetTypeFlag(typeInfo.Obj()); + switch (node->op) + { + case WfUnaryOperator::Not: + switch (flag) + { + case TypeFlag::F4: + case TypeFlag::F8: + case TypeFlag::String: + case TypeFlag::Enum: + case TypeFlag::Struct: + case TypeFlag::Others: + manager->errors.Add(WfErrors::UnaryOperatorOnWrongType(node, typeInfo.Obj())); + break; + default:; + } + break; + case WfUnaryOperator::Positive: + switch (flag) + { + case TypeFlag::Bool: + case TypeFlag::String: + case TypeFlag::Enum: + case TypeFlag::Struct: + case TypeFlag::Others: + manager->errors.Add(WfErrors::UnaryOperatorOnWrongType(node, typeInfo.Obj())); + break; + default:; + } + break; + case WfUnaryOperator::Negative: + switch (flag) + { + case TypeFlag::Bool: + case TypeFlag::U1: + case TypeFlag::U2: + case TypeFlag::U4: + case TypeFlag::U8: + case TypeFlag::String: + case TypeFlag::Enum: + case TypeFlag::Struct: + case TypeFlag::Others: + manager->errors.Add(WfErrors::UnaryOperatorOnWrongType(node, typeInfo.Obj())); + break; + default:; + } + break; + } + + results.Add(ResolveExpressionResult::ReadonlyType(typeInfo)); + } + } + + void Visit(WfBinaryExpression* node)override + { + if (node->op == WfBinaryOperator::Assign) + { + Ptr variableType = GetLeftValueExpressionType(manager, node->first); + GetExpressionType(manager, node->second, variableType); + if (variableType) + { + results.Add(ResolveExpressionResult::ReadonlyType(variableType)); + } + } + else if (node->op == WfBinaryOperator::Index) + { + Ptr containerType = GetExpressionType(manager, node->first, 0); + if (containerType) + { + if (containerType->GetDecorator() == ITypeInfo::SharedPtr) + { + ITypeInfo* genericType = containerType->GetElementType(); + Ptr indexType; + Ptr resultType; + bool leftValue = false; + + if (genericType->GetDecorator() == ITypeInfo::Generic) + { + ITypeInfo* classType = genericType->GetElementType(); + if (classType->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + indexType = TypeInfoRetriver::CreateTypeInfo(); + resultType = CopyTypeInfo(genericType->GetGenericArgument(0)); + } + else if (classType->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + indexType = TypeInfoRetriver::CreateTypeInfo(); + resultType = CopyTypeInfo(genericType->GetGenericArgument(0)); + leftValue = true; + } + else if (classType->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + indexType = TypeInfoRetriver::CreateTypeInfo(); + resultType = CopyTypeInfo(genericType->GetGenericArgument(0)); + leftValue = true; + } + else if (classType->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + indexType = CopyTypeInfo(genericType->GetGenericArgument(0)); + resultType = CopyTypeInfo(genericType->GetGenericArgument(1)); + } + else if (classType->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + indexType = CopyTypeInfo(genericType->GetGenericArgument(0)); + resultType = CopyTypeInfo(genericType->GetGenericArgument(1)); + leftValue = true; + } + else + { + manager->errors.Add(WfErrors::IndexOperatorOnWrongType(node, containerType.Obj())); + } + } + else + { + if (genericType->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + indexType = TypeInfoRetriver::CreateTypeInfo(); + resultType = TypeInfoRetriver::CreateTypeInfo(); + } + else if (genericType->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + indexType = TypeInfoRetriver::CreateTypeInfo(); + resultType = TypeInfoRetriver::CreateTypeInfo(); + leftValue = true; + } + else if (genericType->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + indexType = TypeInfoRetriver::CreateTypeInfo(); + resultType = TypeInfoRetriver::CreateTypeInfo(); + leftValue = true; + } + else if (genericType->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + indexType = TypeInfoRetriver::CreateTypeInfo(); + resultType = TypeInfoRetriver::CreateTypeInfo(); + } + else if (genericType->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + indexType = TypeInfoRetriver::CreateTypeInfo(); + resultType = TypeInfoRetriver::CreateTypeInfo(); + leftValue = true; + } + else + { + manager->errors.Add(WfErrors::IndexOperatorOnWrongType(node, containerType.Obj())); + } + } + + GetExpressionType(manager, node->second, indexType); + if (resultType) + { + if (leftValue) + { + results.Add(ResolveExpressionResult::WritableType(resultType)); + } + else + { + results.Add(ResolveExpressionResult::ReadonlyType(resultType)); + } + } + } + else + { + manager->errors.Add(WfErrors::IndexOperatorOnWrongType(node, containerType.Obj())); + } + } + } + else if (node->op == WfBinaryOperator::Union) + { + auto typeA = GetExpressionType(manager, node->first, expectedType); + auto typeB = GetExpressionType(manager, node->second, expectedType); + + if (typeA && typeB) + { + if (typeA->GetDecorator() == ITypeInfo::TypeDescriptor && typeB->GetDecorator() == ITypeInfo::TypeDescriptor) + { + auto stringType = TypeInfoRetriver::CreateTypeInfo(); + if (CanConvertToType(typeA.Obj(), stringType.Obj(), false) && CanConvertToType(typeB.Obj(), stringType.Obj(), false)) + { + results.Add(ResolveExpressionResult::ReadonlyType(stringType)); + return; + } + else if (auto type = GetMergedType(typeA, typeB)) + { + if (type->GetTypeDescriptor()->GetTypeDescriptorFlags() != TypeDescriptorFlags::FlagEnum) + { + manager->errors.Add(WfErrors::IncorrectTypeForUnion(node->first.Obj(), type.Obj())); + } + results.Add(ResolveExpressionResult::ReadonlyType(type)); + return; + } + } + manager->errors.Add(WfErrors::CannotMergeTwoType(node, typeA.Obj(), typeB.Obj())); + } + } + else if (node->op == WfBinaryOperator::Intersect) + { + auto typeA = GetExpressionType(manager, node->first, expectedType); + auto typeB = GetExpressionType(manager, node->second, expectedType); + + if (typeA && typeB) + { + if (typeA->GetDecorator() == ITypeInfo::TypeDescriptor && typeB->GetDecorator() == ITypeInfo::TypeDescriptor) + { + if (auto type = GetMergedType(typeA, typeB)) + { + if (type->GetTypeDescriptor()->GetTypeDescriptorFlags() != TypeDescriptorFlags::FlagEnum) + { + manager->errors.Add(WfErrors::IncorrectTypeForIntersect(node->first.Obj(), type.Obj())); + } + results.Add(ResolveExpressionResult::ReadonlyType(type)); + return; + } + } + manager->errors.Add(WfErrors::CannotMergeTwoType(node, typeA.Obj(), typeB.Obj())); + } + } + else if (node->op == WfBinaryOperator::FailedThen) + { + Ptr firstType = GetExpressionType(manager, node->first, 0); + bool depend = IsExpressionDependOnExpectedType(manager, node->second); + Ptr secondType = GetExpressionType(manager, node->second, (depend ? firstType : nullptr)); + + if (firstType && secondType) + { + auto mergedType = GetMergedType(firstType, secondType); + results.Add(ResolveExpressionResult::ReadonlyType(mergedType ? mergedType : firstType)); + } + } + else + { + Ptr firstType = GetExpressionType(manager, node->first, 0); + Ptr secondType = GetExpressionType(manager, node->second, 0); + Ptr elementType; + if (firstType && secondType) + { + if (!(elementType = GetMergedType(firstType, secondType))) + { + manager->errors.Add(WfErrors::CannotMergeTwoType(node, firstType.Obj(), secondType.Obj())); + } + } + + if (elementType) + { + TypeFlag flag = GetTypeFlag(elementType.Obj()); + TypeFlag* selectedTable = 0; + switch (node->op) + { + case WfBinaryOperator::Exp: + { + static TypeFlag conversionTable[(vint)TypeFlag::Count] = { + /*Bool */TypeFlag::Unknown, + /*I1 */TypeFlag::F4, + /*I2 */TypeFlag::F4, + /*I4 */TypeFlag::F8, + /*I8 */TypeFlag::F8, + /*U1 */TypeFlag::F4, + /*U2 */TypeFlag::F4, + /*U4 */TypeFlag::F8, + /*U8 */TypeFlag::F8, + /*F4 */TypeFlag::F4, + /*F8 */TypeFlag::F8, + /*String */TypeFlag::Unknown, + /*Enum */TypeFlag::Unknown, + /*Struct */TypeFlag::Unknown, + /*Others */TypeFlag::Unknown, + }; + selectedTable = conversionTable; + } + break; + case WfBinaryOperator::Add: + case WfBinaryOperator::Sub: + case WfBinaryOperator::Mul: + case WfBinaryOperator::Div: + { + static TypeFlag conversionTable[(vint)TypeFlag::Count] = { + /*Bool */TypeFlag::Unknown, + /*I1 */TypeFlag::I4, + /*I2 */TypeFlag::I4, + /*I4 */TypeFlag::I4, + /*I8 */TypeFlag::I8, + /*U1 */TypeFlag::U4, + /*U2 */TypeFlag::U4, + /*U4 */TypeFlag::U4, + /*U8 */TypeFlag::U8, + /*F4 */TypeFlag::F4, + /*F8 */TypeFlag::F8, + /*String */TypeFlag::Unknown, + /*Enum */TypeFlag::Unknown, + /*Struct */TypeFlag::Unknown, + /*Others */TypeFlag::Unknown, + }; + selectedTable = conversionTable; + } + break; + case WfBinaryOperator::Mod: + case WfBinaryOperator::Shl: + case WfBinaryOperator::Shr: + { + static TypeFlag conversionTable[(vint)TypeFlag::Count] = { + /*Bool */TypeFlag::Unknown, + /*I1 */TypeFlag::I4, + /*I2 */TypeFlag::I4, + /*I4 */TypeFlag::I4, + /*I8 */TypeFlag::I8, + /*U1 */TypeFlag::U4, + /*U2 */TypeFlag::U4, + /*U4 */TypeFlag::U4, + /*U8 */TypeFlag::U8, + /*F4 */TypeFlag::Unknown, + /*F8 */TypeFlag::Unknown, + /*String */TypeFlag::Unknown, + /*Enum */TypeFlag::Unknown, + /*Struct */TypeFlag::Unknown, + /*Others */TypeFlag::Unknown, + }; + selectedTable = conversionTable; + } + break; + case WfBinaryOperator::LT: + case WfBinaryOperator::GT: + case WfBinaryOperator::LE: + case WfBinaryOperator::GE: + { + static TypeFlag conversionTable[(vint)TypeFlag::Count] = { + /*Bool */TypeFlag::Unknown, + /*I1 */TypeFlag::Bool, + /*I2 */TypeFlag::Bool, + /*I4 */TypeFlag::Bool, + /*I8 */TypeFlag::Bool, + /*U1 */TypeFlag::Bool, + /*U2 */TypeFlag::Bool, + /*U4 */TypeFlag::Bool, + /*U8 */TypeFlag::Bool, + /*F4 */TypeFlag::Bool, + /*F8 */TypeFlag::Bool, + /*String */TypeFlag::Bool, + /*Enum */TypeFlag::Unknown, + /*Struct */TypeFlag::Unknown, + /*Others */TypeFlag::Unknown, + }; + selectedTable = conversionTable; + } + break; + case WfBinaryOperator::EQ: + case WfBinaryOperator::NE: + { + results.Add(ResolveExpressionResult::ReadonlyType(TypeInfoRetriver::CreateTypeInfo())); + return; + } + break; + case WfBinaryOperator::Xor: + case WfBinaryOperator::And: + case WfBinaryOperator::Or: + { + static TypeFlag conversionTable[(vint)TypeFlag::Count] = { + /*Bool */TypeFlag::Bool, + /*I1 */TypeFlag::I1, + /*I2 */TypeFlag::I2, + /*I4 */TypeFlag::I4, + /*I8 */TypeFlag::I8, + /*U1 */TypeFlag::U1, + /*U2 */TypeFlag::U2, + /*U4 */TypeFlag::U4, + /*U8 */TypeFlag::U8, + /*F4 */TypeFlag::Unknown, + /*F8 */TypeFlag::Unknown, + /*String */TypeFlag::Unknown, + /*Enum */TypeFlag::Unknown, + /*Struct */TypeFlag::Unknown, + /*Others */TypeFlag::Unknown, + }; + selectedTable = conversionTable; + } + break; + default:; + } + + TypeFlag resultFlag = selectedTable[(vint)flag]; + if (resultFlag == TypeFlag::Unknown) + { + manager->errors.Add(WfErrors::BinaryOperatorOnWrongType(node, elementType.Obj())); + } + else + { + results.Add(ResolveExpressionResult::ReadonlyType(CreateTypeInfoFromTypeFlag(resultFlag))); + } + } + } + } + + void Visit(WfLetExpression* node)override + { + auto scope = manager->nodeScopes[node].Obj(); + + FOREACH(Ptr, variable, node->variables) + { + auto symbol = scope->symbols[variable->name.value][0]; + symbol->typeInfo = GetExpressionType(manager, variable->value, 0); + if (symbol->typeInfo) + { + symbol->type = GetTypeFromTypeInfo(symbol->typeInfo.Obj()); + } + } + Ptr type = GetExpressionType(manager, node->expression, expectedType); + if (type) + { + results.Add(ResolveExpressionResult::ReadonlyType(type)); + } + } + + void Visit(WfIfExpression* node)override + { + Ptr boolType = TypeInfoRetriver::CreateTypeInfo(); + GetExpressionType(manager, node->condition, boolType); + + Ptr firstType, secondType; + + if (expectedType) + { + firstType = GetExpressionType(manager, node->trueBranch, expectedType); + secondType = GetExpressionType(manager, node->falseBranch, expectedType); + } + else + { + bool resolveFirst = !IsExpressionDependOnExpectedType(manager, node->trueBranch); + bool resolveSecond = !IsExpressionDependOnExpectedType(manager, node->falseBranch); + + if (resolveFirst == resolveSecond) + { + firstType = GetExpressionType(manager, node->trueBranch, 0); + secondType = GetExpressionType(manager, node->falseBranch, 0); + } + else if (resolveFirst) + { + firstType = GetExpressionType(manager, node->trueBranch, 0); + secondType = GetExpressionType(manager, node->falseBranch, firstType); + } + else if (resolveSecond) + { + secondType = GetExpressionType(manager, node->falseBranch, 0); + firstType = GetExpressionType(manager, node->trueBranch, secondType); + } + } + + if (firstType && !secondType) + { + results.Add(ResolveExpressionResult::ReadonlyType(firstType)); + } + else if (!firstType && secondType) + { + results.Add(ResolveExpressionResult::ReadonlyType(secondType)); + } + else if (firstType && secondType) + { + if (auto mergedType = GetMergedType(firstType, secondType)) + { + results.Add(ResolveExpressionResult::ReadonlyType(mergedType)); + } + else + { + manager->errors.Add(WfErrors::CannotMergeTwoType(node, firstType.Obj(), secondType.Obj())); + } + } + } + + void Visit(WfRangeExpression* node)override + { + Ptr firstType = GetExpressionType(manager, node->begin, 0); + Ptr secondType = GetExpressionType(manager, node->end, 0); + Ptr elementType; + + if (firstType && !secondType) + { + elementType = firstType; + } + else if (!firstType && secondType) + { + elementType = secondType; + } + else if (firstType && secondType) + { + if (!(elementType = GetMergedType(firstType, secondType))) + { + manager->errors.Add(WfErrors::CannotMergeTwoType(node, firstType.Obj(), secondType.Obj())); + } + } + + if (elementType) + { + TypeFlag flag = GetTypeFlag(elementType.Obj()); + switch (flag) + { + case TypeFlag::I1: + case TypeFlag::I2: + case TypeFlag::I4: + case TypeFlag::I8: + case TypeFlag::U1: + case TypeFlag::U2: + case TypeFlag::U4: + case TypeFlag::U8: + break; + default: + manager->errors.Add(WfErrors::RangeShouldBeInteger(node, elementType.Obj())); + } + + auto enumerableType = MakePtr(description::GetTypeDescriptor(), TypeInfoHint::Normal); + auto genericType = MakePtr(enumerableType); + genericType->AddGenericArgument(elementType); + + auto pointerType = MakePtr(genericType); + results.Add(ResolveExpressionResult::ReadonlyType(pointerType)); + } + } + + void Visit(WfSetTestingExpression* node)override + { + Ptr elementType = GetExpressionType(manager, node->element, 0); + + if (auto range = node->collection.Cast()) + { + Ptr beginType = GetExpressionType(manager, range->begin, 0); + Ptr endType = GetExpressionType(manager, range->end, 0); + + if (elementType && beginType) + { + if (!GetMergedType(elementType, beginType)) + { + manager->errors.Add(WfErrors::CannotMergeTwoType(node, elementType.Obj(), beginType.Obj())); + } + } + if (elementType && endType) + { + if (!GetMergedType(elementType, endType)) + { + manager->errors.Add(WfErrors::CannotMergeTwoType(node, elementType.Obj(), endType.Obj())); + } + } + } + else + { + Ptr itemType = GetEnumerableExpressionItemType(manager, node->collection, 0); + if (elementType && itemType) + { + if (!GetMergedType(elementType, itemType)) + { + manager->errors.Add(WfErrors::CannotMergeTwoType(node, elementType.Obj(), itemType.Obj())); + } + } + } + + results.Add(ResolveExpressionResult::ReadonlyType(TypeInfoRetriver::CreateTypeInfo())); + } + + void Visit(WfConstructorExpression* node)override + { + if (expectedType && expectedType->GetTypeDescriptor()->GetTypeDescriptorFlags() == TypeDescriptorFlags::Struct) + { + SortedList fields; + FOREACH(Ptr, argument, node->arguments) + { + if (!argument->value) + { + manager->errors.Add(WfErrors::ConstructorMixStructAndList(node)); + return; + } + else if (auto field = argument->key.Cast()) + { + if (auto prop = expectedType->GetTypeDescriptor()->GetPropertyByName(field->name.value, true)) + { + if (fields.Contains(field->name.value)) + { + manager->errors.Add(WfErrors::DuplicatedConstructorField(field.Obj())); + } + else + { + fields.Add(field->name.value); + } + GetExpressionType(manager, argument->value, CopyTypeInfo(prop->GetReturn())); + } + else + { + manager->errors.Add(WfErrors::MemberNotExists(field.Obj(), expectedType->GetTypeDescriptor(), field->name.value)); + } + } + else + { + manager->errors.Add(WfErrors::ConstructorMixStructAndList(argument->value.Obj())); + } + } + results.Add(ResolveExpressionResult::ReadonlyType(expectedType)); + } + else if (node->arguments.Count() == 0) + { + if (expectedType) + { + ITypeDescriptor* td = expectedType->GetTypeDescriptor(); + if (!td->CanConvertTo(description::GetTypeDescriptor()) && !td->CanConvertTo(description::GetTypeDescriptor())) + { + manager->errors.Add(WfErrors::ConstructorCannotImplicitlyConvertToType(node, expectedType.Obj())); + } + results.Add(ResolveExpressionResult::ReadonlyType(expectedType)); + } + else + { + manager->errors.Add(WfErrors::ConstructorCannotResolveType(node)); + } + } + else + { + ITypeInfo* expectedKeyType = nullptr; + ITypeInfo* expectedValueType = nullptr; + if (expectedType) + { + if (expectedType->GetDecorator() == ITypeInfo::SharedPtr) + { + auto genericType = expectedType->GetElementType(); + if (genericType->GetDecorator() == ITypeInfo::Generic) + { + if (genericType->GetTypeDescriptor() == description::GetTypeDescriptor() + || genericType->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + if (genericType->GetGenericArgumentCount() == 2) + { + expectedKeyType = genericType->GetGenericArgument(0); + expectedValueType = genericType->GetGenericArgument(1); + } + } + else if (genericType->GetTypeDescriptor() == description::GetTypeDescriptor() + || genericType->GetTypeDescriptor() == description::GetTypeDescriptor() + || genericType->GetTypeDescriptor() == description::GetTypeDescriptor() + || genericType->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + if (genericType->GetGenericArgumentCount() == 1) + { + expectedKeyType = genericType->GetGenericArgument(0); + } + } + } + } + } + + bool map = node->arguments[0]->value; + Ptr keyType, valueType; + FOREACH(Ptr, argument, node->arguments) + { + { + Ptr newKeyType = GetExpressionType(manager, argument->key, expectedKeyType); + if (!keyType) + { + keyType = newKeyType; + } + else if (auto mergedType = GetMergedType(keyType, newKeyType)) + { + keyType = mergedType; + } + else + { + manager->errors.Add(WfErrors::CannotMergeTwoType(node, keyType.Obj(), newKeyType.Obj())); + } + } + if (map) + { + Ptr newValueType = GetExpressionType(manager, argument->value, expectedValueType); + if (!valueType) + { + valueType = newValueType; + } + else if (auto mergedType = GetMergedType(valueType, newValueType)) + { + valueType = mergedType; + } + else + { + manager->errors.Add(WfErrors::CannotMergeTwoType(node, valueType.Obj(), newValueType.Obj())); + } + } + } + + if (map) + { + if (keyType && valueType) + { + auto classType = MakePtr(description::GetTypeDescriptor(), TypeInfoHint::Normal); + auto genericType = MakePtr(classType); + genericType->AddGenericArgument(keyType); + genericType->AddGenericArgument(valueType); + + auto pointerType = MakePtr(genericType); + results.Add(ResolveExpressionResult::ReadonlyType(pointerType)); + } + } + else + { + if (keyType) + { + Ptr classType; + if (expectedType && expectedType->GetTypeDescriptor()==description::GetTypeDescriptor()) + { + classType = MakePtr(description::GetTypeDescriptor(), TypeInfoHint::Normal); + } + else + { + classType = MakePtr(description::GetTypeDescriptor(), TypeInfoHint::Normal); + } + auto genericType = MakePtr(classType); + genericType->AddGenericArgument(keyType); + + auto pointerType = MakePtr(genericType); + results.Add(ResolveExpressionResult::ReadonlyType(pointerType)); + } + } + } + } + + void Visit(WfInferExpression* node)override + { + auto scope = manager->nodeScopes[node].Obj(); + Ptr type = CreateTypeInfoFromType(scope, node->type); + Ptr expressionType = GetExpressionType(manager, node->expression, type); + if (expressionType) + { + results.Add(ResolveExpressionResult::ReadonlyType(type)); + } + } + + void Visit(WfTypeCastingExpression* node)override + { + auto scope = manager->nodeScopes[node].Obj(); + if (auto type = CreateTypeInfoFromType(scope, node->type)) + { + if (auto expressionType = GetExpressionType(manager, node->expression, 0)) + { + if (!CanConvertToType(expressionType.Obj(), type.Obj(), true)) + { + manager->errors.Add(WfErrors::ExpressionCannotExplicitlyConvertToType(node->expression.Obj(), expressionType.Obj(), type.Obj())); + } + } + if (node->strategy == WfTypeCastingStrategy::Weak) + { + switch (type->GetDecorator()) + { + case ITypeInfo::RawPtr: + case ITypeInfo::SharedPtr: + case ITypeInfo::Nullable: + break; + default: + manager->errors.Add(WfErrors::CannotWeakCastToType(node->expression.Obj(), type.Obj())); + } + } + results.Add(ResolveExpressionResult::ReadonlyType(type)); + } + } + + void Visit(WfTypeTestingExpression* node)override + { + Ptr type = GetExpressionType(manager, node->expression, 0); + if (type) + { + switch (node->test) + { + case WfTypeTesting::IsNull: + case WfTypeTesting::IsNotNull: + if (!IsNullAcceptableType(type.Obj())) + { + manager->errors.Add(WfErrors::NullCannotImplicitlyConvertToType(node->expression.Obj(), type.Obj())); + } + break; + default:; + } + } + results.Add(ResolveExpressionResult::ReadonlyType(TypeInfoRetriver::CreateTypeInfo())); + } + + void Visit(WfTypeOfTypeExpression* node)override + { + results.Add(ResolveExpressionResult::ReadonlyType(TypeInfoRetriver::CreateTypeInfo())); + } + + void Visit(WfTypeOfExpressionExpression* node)override + { + GetExpressionType(manager, node->expression, 0); + results.Add(ResolveExpressionResult::ReadonlyType(TypeInfoRetriver::CreateTypeInfo())); + } + + void Visit(WfAttachEventExpression* node)override + { + IEventInfo* eventInfo = GetExpressionEventInfo(manager, node->event); + Ptr functionType; + if (eventInfo) + { + functionType = CopyTypeInfo(eventInfo->GetHandlerType()); + } + GetExpressionType(manager, node->function, functionType); + results.Add(ResolveExpressionResult::ReadonlyType(TypeInfoRetriver>::CreateTypeInfo())); + } + + void Visit(WfDetachEventExpression* node)override + { + GetExpressionEventInfo(manager, node->event); + Ptr pointerType = TypeInfoRetriver>::CreateTypeInfo(); + GetExpressionType(manager, node->handler, pointerType); + results.Add(ResolveExpressionResult::ReadonlyType(TypeInfoRetriver::CreateTypeInfo())); + } + + void Visit(WfObserveExpression* node)override + { + Ptr parentType = GetExpressionType(manager, node->parent, 0); + Ptr observeeType; + if (parentType) + { + if (node->observeType == WfObserveType::SimpleObserve) + { + ITypeDescriptor* td = parentType->GetTypeDescriptor(); + IPropertyInfo* propertyInfo = 0; + { + auto ref = node->expression.Cast(); + propertyInfo = td->GetPropertyByName(ref->name.value, true); + if (propertyInfo) + { + observeeType = CopyTypeInfo(propertyInfo->GetReturn()); + } + else + { + manager->errors.Add(WfErrors::MemberNotExists(ref.Obj(), td, ref->name.value)); + } + } + + if (node->events.Count() == 0) + { + if (propertyInfo) + { + IEventInfo* eventInfo = propertyInfo->GetValueChangedEvent(); + if (!eventInfo) + { + eventInfo = td->GetEventByName(propertyInfo->GetName() + L"Changed", true); + } + if (!eventInfo) + { + manager->errors.Add(WfErrors::MemberNotExists(node->expression.Obj(), td, propertyInfo->GetName() + L"Changed")); + } + } + } + else + { + FOREACH(Ptr, eventExpr, node->events) + { + auto ref = eventExpr.Cast(); + IEventInfo* info = td->GetEventByName(ref->name.value, true); + if (!info) + { + manager->errors.Add(WfErrors::MemberNotExists(ref.Obj(), td, ref->name.value)); + } + } + } + } + else + { + auto scope = manager->nodeScopes[node].Obj(); + auto symbol = scope->symbols[node->name.value][0]; + symbol->typeInfo = parentType; + symbol->type = GetTypeFromTypeInfo(parentType.Obj()); + + observeeType = GetExpressionType(manager, node->expression, 0); + FOREACH(Ptr, eventExpr, node->events) + { + GetExpressionEventInfo(manager, eventExpr); + } + } + } + + if (observeeType) + { + results.Add(ResolveExpressionResult::ReadonlyType(observeeType)); + } + } + + void Visit(WfCallExpression* node)override + { + List functions; + GetExpressionTypes(manager, node->function, nullptr, true, functions); + + vint selectedFunctionIndex = -1; + Ptr resultType = SelectFunction(manager, node, node->function, functions, node->arguments, selectedFunctionIndex); + if (resultType) + { + manager->expressionResolvings.Add(node->function, functions[selectedFunctionIndex]); + results.Add(ResolveExpressionResult::ReadonlyType(resultType)); + } + } + + void Visit(WfFunctionExpression* node)override + { + ValidateDeclarationSemantic(manager, node->function); + auto scope = manager->nodeScopes[node->function.Obj()].Obj(); + + auto classType = MakePtr(description::GetTypeDescriptor(), TypeInfoHint::Normal); + auto genericType = MakePtr(classType); + genericType->AddGenericArgument(CreateTypeInfoFromType(scope, node->function->returnType)); + FOREACH(Ptr, argument, node->function->arguments) + { + genericType->AddGenericArgument(scope->symbols[argument->name.value][0]->typeInfo); + } + + auto pointerType = MakePtr(genericType); + results.Add(ResolveExpressionResult::ReadonlyType(pointerType)); + } + + Ptr GetFunctionDeclarationType(WfLexicalScope* scope, Ptr decl) + { + Ptr symbol = From(manager->nodeScopes[decl.Obj()]->parentScope->symbols[decl->name.value]) + .Where([decl](Ptr symbol) + { + return symbol->creatorNode == decl; + }) + .First(); + return symbol->typeInfo; + } + + class NewInterfaceExpressionVisitor : public empty_visitor::DeclarationVisitor + { + public: + WfLexicalScopeManager* manager; + List> overrideFunctions; + List> variableSymbols; + WfFunctionDeclaration* lastFunction = nullptr; + + NewInterfaceExpressionVisitor(WfLexicalScopeManager* _manager) + :manager(_manager) + { + } + + void Dispatch(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + + void Visit(WfFunctionDeclaration* node)override + { + lastFunction = node; + if (node->classMember->kind == WfClassMemberKind::Override) + { + overrideFunctions.Add(node); + } + } + + void Visit(WfVariableDeclaration* node)override + { + variableSymbols.Add( + From(manager->nodeScopes[node]->symbols[node->name.value]) + .Where([=](Ptr symbol) + { + return symbol->creatorNode == node; + }) + .First() + ); + } + + void Execute(WfNewInterfaceExpression* node) + { + FOREACH(Ptr, memberDecl, node->declarations) + { + memberDecl->Accept(this); + ValidateDeclarationSemantic(manager, memberDecl); + } + } + }; + + void Visit(WfNewClassExpression* node)override + { + auto scope = manager->nodeScopes[node].Obj(); + Ptr type = CreateTypeInfoFromType(scope, node->type); + if (type) + { + ITypeDescriptor* td = type->GetTypeDescriptor(); + IMethodGroupInfo* ctors = td->GetConstructorGroup(); + Ptr selectedType; + IMethodInfo* selectedConstructor = nullptr; + + if (!ctors || ctors->GetMethodCount() == 0) + { + manager->errors.Add(WfErrors::ClassContainsNoConstructor(node, type.Obj())); + } + else + { + if ((td->GetTypeDescriptorFlags() & TypeDescriptorFlags::ClassType) != TypeDescriptorFlags::Undefined) + { + List functions; + for (vint i = 0; i < ctors->GetMethodCount(); i++) + { + IMethodInfo* info = ctors->GetMethod(i); + functions.Add(ResolveExpressionResult::Method(info)); + } + + vint selectedFunctionIndex = -1; + selectedType = SelectFunction(manager, node, nullptr, functions, node->arguments, selectedFunctionIndex); + if (selectedType) + { + selectedConstructor = functions[selectedFunctionIndex].methodInfo; + } + } + else if ((td->GetTypeDescriptorFlags() & TypeDescriptorFlags::InterfaceType) != TypeDescriptorFlags::Undefined) + { + manager->errors.Add(WfErrors::ConstructorMixClassAndInterface(node)); + } + else + { + manager->errors.Add(WfErrors::ClassContainsNoConstructor(node, type.Obj())); + } + } + + if (selectedType) + { + auto result = ResolveExpressionResult::Constructor(selectedConstructor); + if (!IsSameType(selectedType.Obj(), type.Obj())) + { + manager->errors.Add(WfErrors::ConstructorReturnTypeMismatched(node, result, selectedType.Obj(), type.Obj())); + } + results.Add(result); + } + } + } + + void Visit(WfNewInterfaceExpression* node)override + { + auto scope = manager->nodeScopes[node].Obj(); + Ptr type = CreateTypeInfoFromType(scope, node->type); + if (type) + { + ITypeDescriptor* td = type->GetTypeDescriptor(); + IMethodGroupInfo* ctors = td->GetConstructorGroup(); + Ptr selectedType; + IMethodInfo* selectedConstructor = nullptr; + + scope->typeOfThisExpr = td; + + if (!ctors || ctors->GetMethodCount() == 0) + { + manager->errors.Add(WfErrors::ClassContainsNoConstructor(node, type.Obj())); + } + else + { + if ((td->GetTypeDescriptorFlags() & TypeDescriptorFlags::ClassType) != TypeDescriptorFlags::Undefined) + { + manager->errors.Add(WfErrors::ConstructorMixClassAndInterface(node)); + } + else if ((td->GetTypeDescriptorFlags() & TypeDescriptorFlags::InterfaceType) != TypeDescriptorFlags::Undefined) + { + if (auto info = FindInterfaceConstructor(td)) + { + selectedType = CopyTypeInfo(info->GetReturn()); + selectedConstructor = info; + } + else + { + manager->errors.Add(WfErrors::InterfaceContainsNoConstructor(node, type.Obj())); + } + + Group interfaceMethods; + Group> implementMethods; + + { + NewInterfaceExpressionVisitor declVisitor(manager); + declVisitor.Execute(node); + + if (declVisitor.lastFunction) + { + FOREACH(Ptr, func, declVisitor.overrideFunctions) + { + implementMethods.Add(func->name.value, func); + } + + auto capture = manager->lambdaCaptures[declVisitor.lastFunction]; + List> readonlySymbols; + CopyFrom(readonlySymbols, From(capture->symbols).Except(declVisitor.variableSymbols)); + CopyFrom(capture->symbols, declVisitor.variableSymbols); + CopyFrom(capture->symbols, readonlySymbols, true); + } + } + { + SortedList searchedTypes; + List types; + types.Add(td); + vint begin = 0; + + while (begin < types.Count()) + { + ITypeDescriptor* currentType = types[begin++]; + if (searchedTypes.Contains(currentType)) + { + continue; + } + searchedTypes.Add(currentType); + + vint count = currentType->GetBaseTypeDescriptorCount(); + for (vint i = 0; i < count; i++) + { + types.Add(currentType->GetBaseTypeDescriptor(i)); + } + + count = currentType->GetMethodGroupCount(); + for (vint i = 0; i < count; i++) + { + IMethodGroupInfo* group = currentType->GetMethodGroup(i); + vint methodCount = group->GetMethodCount(); + for (vint j = 0; j < methodCount; j++) + { + auto method = group->GetMethod(j); + if (!method->IsStatic()) + { + interfaceMethods.Add(group->GetName(), method); + } + } + } + } + } + + auto discardFirst = [=](const WString& key, const List& methods) + { + FOREACH(IMethodInfo*, method, methods) + { + manager->errors.Add(WfErrors::InterfaceMethodNotImplemented(node, method)); + } + }; + auto discardSecond = [=](const WString& key, const List>& methods) + { + FOREACH(Ptr, decl, methods) + { + Ptr declType = GetFunctionDeclarationType(scope, decl); + manager->errors.Add(WfErrors::InterfaceMethodNotFound(decl.Obj(), type.Obj(), declType.Obj())); + } + }; + + GroupInnerJoin( + interfaceMethods, + implementMethods, + discardFirst, + discardSecond, + [=](const WString& key, const List& interfaces, const List>& implements) + { + Group typedInterfaceMethods; + Group> typedImplementMethods; + + FOREACH(IMethodInfo*, method, interfaces) + { + Ptr methodType = CreateTypeInfoFromMethodInfo(method); + typedInterfaceMethods.Add(methodType->GetTypeFriendlyName(), method); + } + + FOREACH(Ptr, decl, implements) + { + Ptr methodType = GetFunctionDeclarationType(scope, decl); + typedImplementMethods.Add(methodType->GetTypeFriendlyName(), decl); + } + + GroupInnerJoin( + typedInterfaceMethods, + typedImplementMethods, + discardFirst, + discardSecond, + [=](const WString& key, const List& interfaces, const List>& implements) + { + if (interfaces.Count() > 1) + { + List functions; + FOREACH(IMethodInfo*, method, interfaces) + { + functions.Add(ResolveExpressionResult::Constructor(method)); + manager->errors.Add(WfErrors::CannotPickOverloadedInterfaceMethods(node, functions)); + } + } + if (implements.Count() > 1) + { + auto decl = implements[0]; + Ptr methodType = GetFunctionDeclarationType(scope, decl); + manager->errors.Add(WfErrors::CannotPickOverloadedImplementMethods(decl.Obj(), methodType.Obj())); + } + + if (interfaces.Count() == 1 && implements.Count() == 1) + { + manager->interfaceMethodImpls.Add(implements[0].Obj(), interfaces[0]); + } + }); + }); + } + else + { + manager->errors.Add(WfErrors::ClassContainsNoConstructor(node, type.Obj())); + } + } + + if (selectedType) + { + auto result = ResolveExpressionResult::Constructor(selectedConstructor); + if (!IsSameType(selectedType.Obj(), type.Obj())) + { + manager->errors.Add(WfErrors::ConstructorReturnTypeMismatched(node, result, selectedType.Obj(), type.Obj())); + } + results.Add(result); + } + } + } + + void Visit(WfVirtualExpression* node)override + { + bool expanded = node->expandedExpression; + vint errorCount = manager->errors.Count(); + node->Accept((WfVirtualExpression::IVisitor*)this); + + if (!expanded && manager->errors.Count() == errorCount) + { + ExpandVirtualExpressionVisitor visitor(manager, expectedType); + node->Accept(&visitor); + SetCodeRange(node->expandedExpression, node->codeRange); + + auto parentScope = manager->nodeScopes[node]; + if (parentScope->ownerNode == node) + { + parentScope = parentScope->parentScope; + } + + ContextFreeExpressionDesugar(manager, node->expandedExpression); + BuildScopeForExpression(manager, parentScope, node->expandedExpression); + if (!CheckScopes_DuplicatedSymbol(manager) || !CheckScopes_SymbolType(manager)) + { + return; + } + } + + if (node->expandedExpression) + { + if (results.Count() == 1) + { + GetExpressionType(manager, node->expandedExpression, results[0].type); + } + else + { + GetExpressionType(manager, node->expandedExpression, nullptr); + } + } + } + + void Visit(WfBindExpression* node)override + { + GetExpressionType(manager, node->expression, 0); + results.Add(ResolveExpressionResult::ReadonlyType(TypeInfoRetriver>::CreateTypeInfo())); + } + + void Visit(WfFormatExpression* node)override + { + Ptr typeInfo = TypeInfoRetriver::CreateTypeInfo(); + results.Add(ResolveExpressionResult::ReadonlyType(typeInfo)); + } + + void Visit(WfNewCoroutineExpression* node)override + { + Ptr typeInfo = TypeInfoRetriver>::CreateTypeInfo(); + results.Add(ResolveExpressionResult::ReadonlyType(typeInfo)); + ValidateStatementSemantic(manager, node->statement); + } + + void Visit(WfMixinCastExpression* node)override + { + auto scope = manager->nodeScopes[node].Obj(); + auto type = CreateTypeInfoFromType(scope, node->type); + auto expressionType = GetExpressionType(manager, node->expression, 0); + if (type && expressionType) + { + results.Add(ResolveExpressionResult::ReadonlyType(type)); + if (expressionType) + { + auto fromTd = expressionType->GetTypeDescriptor(); + auto toTd = type->GetTypeDescriptor(); + if ((fromTd->GetTypeDescriptorFlags() & TypeDescriptorFlags::InterfaceType) != TypeDescriptorFlags::Undefined) + { + if ((toTd->GetTypeDescriptorFlags() & TypeDescriptorFlags::InterfaceType) != TypeDescriptorFlags::Undefined) + { + if (fromTd != toTd && toTd->CanConvertTo(fromTd)) + { + goto PASS_VALIDATION; + } + } + } + manager->errors.Add(WfErrors::WrongMixinTargetType(node, expressionType.Obj(), type.Obj())); + PASS_VALIDATION:; + } + } + } + + void Visit(WfExpectedTypeCastExpression* node)override + { + GetExpressionType(manager, node->expression, nullptr); + if (expectedType) + { + results.Add(ResolveExpressionResult::ReadonlyType(expectedType)); + } + else + { + manager->errors.Add(WfErrors::ExpectedTypeCastCannotResolveType(node)); + } + } + + static void Execute(Ptr expression, WfLexicalScopeManager* manager, Ptr expectedType, List& results) + { + ValidateSemanticExpressionVisitor visitor(manager, expectedType, results); + expression->Accept(&visitor); + } + }; + +/*********************************************************************** +IsConstantExpression +***********************************************************************/ + + class ValidateConstantExpressionVisitor + : public Object + , public WfExpression::IVisitor + { + public: + WfLexicalScopeManager* manager; + bool isConstant = false; + + ValidateConstantExpressionVisitor(WfLexicalScopeManager* _manager) + :manager(_manager) + { + } + + bool Call(Ptr node) + { + bool cache = isConstant; + isConstant = false; + node->Accept(this); + bool result = isConstant; + isConstant = cache; + return result; + } + + void VisitReferenceExpression(WfExpression* node, const WString& name) + { + auto result = manager->expressionResolvings[node]; + if (auto enumType = result.type->GetTypeDescriptor()->GetEnumType()) + { + vint index = enumType->IndexOfItem(name); + if (index != -1) + { + isConstant = true; + } + } + } + + void Visit(WfThisExpression* node)override + { + } + + void Visit(WfTopQualifiedExpression* node)override + { + } + + void Visit(WfReferenceExpression* node)override + { + VisitReferenceExpression(node, node->name.value); + } + + void Visit(WfOrderedNameExpression* node)override + { + } + + void Visit(WfOrderedLambdaExpression* node)override + { + } + + void Visit(WfMemberExpression* node)override + { + } + + void Visit(WfChildExpression* node)override + { + VisitReferenceExpression(node, node->name.value); + } + + void Visit(WfLiteralExpression* node)override + { + isConstant = true; + } + + void Visit(WfFloatingExpression* node)override + { + isConstant = true; + } + + void Visit(WfIntegerExpression* node)override + { + isConstant = true; + } + + void Visit(WfStringExpression* node)override + { + isConstant = true; + } + + void Visit(WfUnaryExpression* node)override + { + isConstant = Call(node->operand); + } + + void Visit(WfBinaryExpression* node)override + { + if (node->op == WfBinaryOperator::Intersect) + { + isConstant = Call(node->first) && Call(node->second); + } + } + + void Visit(WfLetExpression* node)override + { + } + + void Visit(WfIfExpression* node)override + { + } + + void Visit(WfRangeExpression* node)override + { + isConstant = Call(node->begin) && Call(node->end); + } + + void Visit(WfSetTestingExpression* node)override + { + } + + void Visit(WfConstructorExpression* node)override + { + auto result = manager->expressionResolvings[node]; + bool isStruct = (result.type->GetTypeDescriptor()->GetTypeDescriptorFlags() == TypeDescriptorFlags::Struct); + + FOREACH(Ptr, argument, node->arguments) + { + if (argument->key && !isStruct) + { + if (!Call(argument->key)) return; + } + if (argument->value) + { + if (!Call(argument->value)) return; + } + } + isConstant = true; + } + + void Visit(WfInferExpression* node)override + { + } + + void Visit(WfTypeCastingExpression* node)override + { + } + + void Visit(WfTypeTestingExpression* node)override + { + } + + void Visit(WfTypeOfTypeExpression* node)override + { + isConstant = true; + } + + void Visit(WfTypeOfExpressionExpression* node)override + { + isConstant = true; + } + + void Visit(WfAttachEventExpression* node)override + { + } + + void Visit(WfDetachEventExpression* node)override + { + } + + void Visit(WfObserveExpression* node)override + { + } + + void Visit(WfCallExpression* node)override + { + } + + void Visit(WfFunctionExpression* node)override + { + } + + void Visit(WfNewClassExpression* node)override + { + } + + void Visit(WfNewInterfaceExpression* node)override + { + } + + void Visit(WfVirtualExpression* node)override + { + if (node->expandedExpression) + { + isConstant = Call(node->expandedExpression); + } + } + + static void Execute(Ptr expression, WfLexicalScopeManager* manager, Ptr expectedType) + { + if (GetExpressionType(manager, expression, expectedType)) + { + ValidateConstantExpressionVisitor visitor(manager); + expression->Accept(&visitor); + if (!visitor.isConstant) + { + manager->errors.Add(WfErrors::ExpressionIsNotConstant(expression.Obj())); + } + } + } + }; + +/*********************************************************************** +ValidateSemantic +***********************************************************************/ + + void ValidateModuleSemantic(WfLexicalScopeManager* manager, Ptr module) + { + FOREACH(Ptr, declaration, module->declarations) + { + ValidateDeclarationSemantic(manager, declaration); + } + } + + void ValidateClassMemberSemantic(WfLexicalScopeManager* manager, Ptr td, Ptr classDecl, Ptr memberDecl) + { + return ValidateSemanticClassMemberVisitor::Execute(td, classDecl, memberDecl, manager); + } + + void ValidateDeclarationSemantic(WfLexicalScopeManager* manager, Ptr declaration) + { + return ValidateSemanticDeclarationVisitor::Execute(declaration, manager); + } + + void ValidateStatementSemantic(WfLexicalScopeManager* manager, Ptr statement) + { + return ValidateSemanticStatementVisitor::Execute(statement, manager); + } + + void ValidateExpressionSemantic(WfLexicalScopeManager* manager, Ptr expression, Ptr expectedType, collections::List& results) + { + ValidateSemanticExpressionVisitor::Execute(expression, manager, expectedType, results); + for (vint i = results.Count() - 1; i >= 0; i--) + { + auto result = results[i]; + if (result.scopeName && result.scopeName->declarations.Count() > 0) + { + List replaces; + FOREACH(Ptr, decl, result.scopeName->declarations) + { + vint index = manager->nodeScopes.Keys().IndexOf(decl.Obj()); + if (index == -1) continue; + auto scope = manager->nodeScopes.Values()[index]; + if (scope->ownerNode == decl) + { + scope = scope->parentScope; + } + + index = scope->symbols.Keys().IndexOf(decl->name.value); + if (index == -1) continue; + FOREACH(Ptr, symbol, scope->symbols.GetByIndex(index)) + { + if (symbol->creatorNode == decl && symbol->typeInfo) + { + replaces.Add(ResolveExpressionResult::Symbol(symbol)); + } + } + } + + if (replaces.Count() > 0) + { + results.RemoveAt(i); + FOREACH_INDEXER(ResolveExpressionResult, replaceResult, index, replaces) + { + results.Insert(i + index, replaceResult); + } + } + } + } + } + + void ValidateConstantExpression(WfLexicalScopeManager* manager, Ptr expression, Ptr expectedType) + { + ValidateConstantExpressionVisitor::Execute(expression, manager, expectedType); + } + +/*********************************************************************** +GetExpressionScopeName +***********************************************************************/ + + Ptr GetExpressionScopeName(WfLexicalScopeManager* manager, Ptr expression) + { + List results; + ValidateExpressionSemantic(manager, expression, 0, results); + if (results.Count() == 0) return 0; + + for (vint i = results.Count() - 1; i >= 0; i--) + { + auto& result = results[i]; + if (!result.scopeName) + { + results.RemoveAt(i); + } + } + if (results.Count() == 0) + { + manager->errors.Add(WfErrors::ExpressionIsNotScopeName(expression.Obj())); + return 0; + } + else if (results.Count() > 1) + { + manager->errors.Add(WfErrors::TooManyTargets(expression.Obj(), results, GetExpressionName(expression))); + return 0; + } + + auto result = results[0]; + manager->expressionResolvings.Add(expression, result); + return result.scopeName; + } + +/*********************************************************************** +GetExpressionEventInfo +***********************************************************************/ + + reflection::description::IEventInfo* GetExpressionEventInfo(WfLexicalScopeManager* manager, Ptr expression) + { + List results; + ValidateExpressionSemantic(manager, expression, 0, results); + if (results.Count() == 0) return 0; + + for (vint i = results.Count() - 1; i >= 0; i--) + { + auto& result = results[i]; + if (!result.eventInfo) + { + results.RemoveAt(i); + } + } + if (results.Count() == 0) + { + manager->errors.Add(WfErrors::ExpressionIsNotEvent(expression.Obj())); + return 0; + } + else if (results.Count() > 1) + { + manager->errors.Add(WfErrors::TooManyTargets(expression.Obj(), results, GetExpressionName(expression))); + return 0; + } + + auto result = results[0]; + manager->expressionResolvings.Add(expression, result); + return result.eventInfo; + } + +/*********************************************************************** +GetExpressionTypes/GetExpressionType/GetLeftValueExpressionType +***********************************************************************/ + + void GetExpressionTypes(WfLexicalScopeManager* manager, Ptr expression, Ptr expectedType, bool allowEvent, collections::List& results) + { + ValidateExpressionSemantic(manager, expression, expectedType, results); + if (results.Count() == 0) return; + + Ptr scopeName; + IEventInfo* eventInfo = 0; + for (vint i = results.Count() - 1; i >= 0; i--) + { + auto& result = results[i]; + if (result.scopeName && !scopeName) + { + scopeName = result.scopeName; + } + if (result.eventInfo && !eventInfo) + { + eventInfo = result.eventInfo; + } + if (!result.type && !(allowEvent && eventInfo)) + { + results.RemoveAt(i); + } + } + if (results.Count() == 0) + { + if (scopeName) + { + manager->errors.Add(WfErrors::ScopeNameIsNotExpression(expression.Obj(), scopeName)); + } + if (eventInfo) + { + manager->errors.Add(WfErrors::EventIsNotExpression(expression.Obj(), eventInfo)); + } + } + + if (expectedType) + { + List> failedTypes; + for (vint i = results.Count() - 1; i >= 0; i--) + { + auto& result = results[i]; + if (!CanConvertToType(result.type.Obj(), expectedType.Obj(), false)) + { + failedTypes.Add(result.type); + results.RemoveAt(i); + } + } + + if (results.Count() == 0) + { + FOREACH(Ptr, type, failedTypes) + { + manager->errors.Add(WfErrors::ExpressionCannotImplicitlyConvertToType(expression.Obj(), type.Obj(), expectedType.Obj())); + } + } + } + } + + Ptr GetExpressionType(WfLexicalScopeManager* manager, Ptr expression, Ptr expectedType) + { + List results; + GetExpressionTypes(manager, expression, expectedType, false, results); + + if (results.Count() > 1) + { + manager->errors.Add(WfErrors::TooManyTargets(expression.Obj(), results, GetExpressionName(expression))); + return expectedType; + } + else if (results.Count() == 1) + { + auto result = results[0]; + result.expectedType = expectedType; + manager->expressionResolvings.Add(expression, result); + return expectedType ? expectedType : result.type; + } + else + { + return expectedType; + } + } + + Ptr GetLeftValueExpressionType(WfLexicalScopeManager* manager, Ptr expression) + { + List results; + GetExpressionTypes(manager, expression, nullptr, false, results); + + if (results.Count() > 1) + { + manager->errors.Add(WfErrors::TooManyTargets(expression.Obj(), results, GetExpressionName(expression))); + } + else if (results.Count() == 1) + { + if (results[0].writableType) + { + auto result = results[0]; + manager->expressionResolvings.Add(expression, result); + return result.writableType; + } + else + { + manager->errors.Add(WfErrors::ExpressionIsNotLeftValue(expression.Obj(), results[0])); + } + } + return 0; + } + +/*********************************************************************** +GetEnumerableExpressionItemType +***********************************************************************/ + + Ptr GetEnumerableExpressionItemType(WfLexicalScopeManager* manager, Ptr expression, Ptr expectedType) + { + Ptr collectionType = GetExpressionType(manager, expression, expectedType); + if (collectionType) + { + if (collectionType->GetTypeDescriptor()->CanConvertTo(description::GetTypeDescriptor())) + { + if (collectionType->GetDecorator() == ITypeInfo::SharedPtr) + { + ITypeInfo* genericType = collectionType->GetElementType(); + if (genericType->GetDecorator() == ITypeInfo::Generic && genericType->GetGenericArgumentCount() == 1) + { + return CopyTypeInfo(genericType->GetGenericArgument(0)); + } + } + return TypeInfoRetriver::CreateTypeInfo(); + } + + manager->errors.Add(WfErrors::ExpressionIsNotCollection(expression.Obj(), collectionType.Obj())); + } + return 0; + } + } + } +} + + +/*********************************************************************** +.\ANALYZER\WFANALYZER_VALIDATESTRUCTURE.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace analyzer + { + using namespace collections; + using namespace parsing; + using namespace reflection::description; + +/*********************************************************************** +ValidateStructureContext +***********************************************************************/ + + ValidateStructureContext::ValidateStructureContext() + :currentBindExpression(0) + , currentObserveExpression(0) + , currentLoopStatement(0) + , currentCatchStatement(0) + { + } + +/*********************************************************************** +ValidateStructure(Type) +***********************************************************************/ + + class ValidateReferenceTypeVisitor : public Object, public WfType::IVisitor + { + public: + WfLexicalScopeManager* manager; + bool result; + + ValidateReferenceTypeVisitor(WfLexicalScopeManager* _manager) + :manager(_manager) + , result(true) + { + } + + void Visit(WfPredefinedType* node)override + { + } + + void Visit(WfTopQualifiedType* node)override + { + } + + void Visit(WfReferenceType* node)override + { + } + + void Visit(WfRawPointerType* node)override + { + result = false; + } + + void Visit(WfSharedPointerType* node)override + { + result = false; + } + + void Visit(WfNullableType* node)override + { + result = false; + } + + void Visit(WfEnumerableType* node)override + { + result = false; + } + + void Visit(WfMapType* node)override + { + result = false; + } + + void Visit(WfObservableListType* node)override + { + result = false; + } + + void Visit(WfFunctionType* node)override + { + result = false; + } + + void Visit(WfChildType* node)override + { + node->parent->Accept(this); + } + + static bool Execute(Ptr type, WfLexicalScopeManager* manager) + { + ValidateReferenceTypeVisitor visitor(manager); + type->Accept(&visitor); + return visitor.result; + } + }; + + class ValidateStructureTypeVisitor : public Object, public WfType::IVisitor + { + public: + WfLexicalScopeManager* manager; + ValidateTypeStragety strategy; + WfClassDeclaration* classDecl; + + ValidateStructureTypeVisitor(WfLexicalScopeManager* _manager, ValidateTypeStragety _strategy, WfClassDeclaration* _classDecl) + :manager(_manager) + , strategy(_strategy) + , classDecl(_classDecl) + { + } + + void Visit(WfPredefinedType* node)override + { + switch (node->name) + { + case WfPredefinedTypeName::Void: + switch (strategy) + { + case ValidateTypeStragety::Value: + manager->errors.Add(WfErrors::WrongVoidType(node)); + break; + case ValidateTypeStragety::BaseType: + manager->errors.Add(WfErrors::WrongBaseType(classDecl, node)); + default:; + } + break; + case WfPredefinedTypeName::Interface: + switch (strategy) + { + case ValidateTypeStragety::ReturnType: + case ValidateTypeStragety::Value: + manager->errors.Add(WfErrors::WrongInterfaceType(node)); + break; + default:; + } + default:; + } + } + + void Visit(WfTopQualifiedType* node)override + { + } + + void Visit(WfReferenceType* node)override + { + } + + void Visit(WfRawPointerType* node)override + { + if (strategy == ValidateTypeStragety::BaseType) + { + manager->errors.Add(WfErrors::WrongBaseType(classDecl, node)); + } + + if (!ValidateReferenceTypeVisitor::Execute(node->element, manager)) + { + manager->errors.Add(WfErrors::RawPointerToNonReferenceType(node)); + } + else if (auto predefinedType = node->element.Cast()) + { + if (predefinedType->name != WfPredefinedTypeName::Interface) + { + manager->errors.Add(WfErrors::RawPointerToNonReferenceType(node)); + } + } + } + + void Visit(WfSharedPointerType* node)override + { + if (strategy == ValidateTypeStragety::BaseType) + { + manager->errors.Add(WfErrors::WrongBaseType(classDecl, node)); + } + + if (!ValidateReferenceTypeVisitor::Execute(node->element, manager)) + { + manager->errors.Add(WfErrors::SharedPointerToNonReferenceType(node)); + } + else if (auto predefinedType = node->element.Cast()) + { + if (predefinedType->name != WfPredefinedTypeName::Interface) + { + manager->errors.Add(WfErrors::SharedPointerToNonReferenceType(node)); + } + } + } + + void Visit(WfNullableType* node)override + { + if (strategy == ValidateTypeStragety::BaseType) + { + manager->errors.Add(WfErrors::WrongBaseType(classDecl, node)); + } + + if (!ValidateReferenceTypeVisitor::Execute(node->element, manager)) + { + manager->errors.Add(WfErrors::NullableToNonReferenceType(node)); + } + else if (auto predefinedType = node->element.Cast()) + { + switch (predefinedType->name) + { + case WfPredefinedTypeName::Void: + case WfPredefinedTypeName::Object: + case WfPredefinedTypeName::Interface: + manager->errors.Add(WfErrors::NullableToNonReferenceType(node)); + break; + default:; + } + } + } + + void Visit(WfEnumerableType* node)override + { + if (strategy == ValidateTypeStragety::BaseType) + { + manager->errors.Add(WfErrors::WrongBaseType(classDecl, node)); + } + + ValidateTypeStructure(manager, node->element); + } + + void Visit(WfMapType* node)override + { + if (strategy == ValidateTypeStragety::BaseType) + { + manager->errors.Add(WfErrors::WrongBaseType(classDecl, node)); + } + + if (node->key) + { + ValidateTypeStructure(manager, node->key); + } + ValidateTypeStructure(manager, node->value); + } + + void Visit(WfObservableListType* node)override + { + if (strategy == ValidateTypeStragety::BaseType) + { + manager->errors.Add(WfErrors::WrongBaseType(classDecl, node)); + } + + ValidateTypeStructure(manager, node->element); + } + + void Visit(WfFunctionType* node)override + { + if (strategy == ValidateTypeStragety::BaseType) + { + manager->errors.Add(WfErrors::WrongBaseType(classDecl, node)); + } + + ValidateTypeStructure(manager, node->result, ValidateTypeStragety::ReturnType); + FOREACH(Ptr, argument, node->arguments) + { + ValidateTypeStructure(manager, argument); + } + } + + void Visit(WfChildType* node)override + { + if (!ValidateReferenceTypeVisitor::Execute(node->parent, manager)) + { + manager->errors.Add(WfErrors::ChildOfNonReferenceType(node)); + } + } + + static void Execute(Ptr type, WfLexicalScopeManager* manager, ValidateTypeStragety strategy, WfClassDeclaration* classDecl) + { + ValidateStructureTypeVisitor visitor(manager, strategy, classDecl); + type->Accept(&visitor); + } + }; + +/*********************************************************************** +ValidateStructure(Declaration) +***********************************************************************/ + + class ValidateStructureDeclarationVisitor + : public Object + , public WfDeclaration::IVisitor + , public WfVirtualDeclaration::IVisitor + { + public: + WfLexicalScopeManager* manager; + WfClassDeclaration* classDecl; + WfExpression* surroundingLambda; + + ValidateStructureDeclarationVisitor(WfLexicalScopeManager* _manager, WfClassDeclaration* _classDecl, WfExpression* _surroundingLambda) + :manager(_manager) + , classDecl(_classDecl) + , surroundingLambda(_surroundingLambda) + { + } + + void Visit(WfNamespaceDeclaration* node)override + { + if (dynamic_cast(surroundingLambda)) + { + manager->errors.Add(WfErrors::WrongDeclarationInInterfaceConstructor(node)); + } + if (node->classMember) + { + manager->errors.Add(WfErrors::WrongClassMember(node)); + } + + for (vint i = 0; i < node->declarations.Count(); i++) + { + ValidateDeclarationStructure(manager, node->declarations[i]); + } + } + + void Visit(WfFunctionDeclaration* node)override + { + if (classDecl && node->classMember) + { + switch (classDecl->kind) + { + case WfClassKind::Class: + { + switch (node->classMember->kind) + { + case WfClassMemberKind::Normal: + case WfClassMemberKind::Static: + if (!node->statement) + { + manager->errors.Add(WfErrors::FunctionShouldHaveImplementation(node)); + } + break; + case WfClassMemberKind::Override: + manager->errors.Add(WfErrors::OverrideShouldImplementInterfaceMethod(node)); + break; + } + } + break; + case WfClassKind::Interface: + { + switch (node->classMember->kind) + { + case WfClassMemberKind::Normal: + if (node->statement) + { + manager->errors.Add(WfErrors::InterfaceMethodShouldNotHaveImplementation(node)); + } + break; + case WfClassMemberKind::Static: + if (!node->statement) + { + manager->errors.Add(WfErrors::FunctionShouldHaveImplementation(node)); + } + break; + case WfClassMemberKind::Override: + manager->errors.Add(WfErrors::OverrideShouldImplementInterfaceMethod(node)); + break; + } + } + break; + } + } + else + { + if (dynamic_cast(surroundingLambda)) + { + switch (node->classMember->kind) + { + case WfClassMemberKind::Normal: + break; + case WfClassMemberKind::Static: + manager->errors.Add(WfErrors::FunctionInNewTypeExpressionCannotBeStatic(node)); + break; + case WfClassMemberKind::Override: + break; + } + } + if (!node->statement) + { + manager->errors.Add(WfErrors::FunctionShouldHaveImplementation(node)); + } + } + + if (node->anonymity == WfFunctionAnonymity::Anonymous) + { + if (!dynamic_cast(surroundingLambda)) + { + manager->errors.Add(WfErrors::FunctionShouldHaveName(node)); + } + } + + + ValidateTypeStructure(manager, node->returnType, ValidateTypeStragety::ReturnType); + FOREACH(Ptr, argument, node->arguments) + { + ValidateTypeStructure(manager, argument->type); + } + + if (node->statement) + { + ValidateStructureContext context; + ValidateStatementStructure(manager, &context, node->statement); + } + } + + void Visit(WfVariableDeclaration* node)override + { + if (classDecl && node->classMember) + { + switch (node->classMember->kind) + { + case WfClassMemberKind::Normal: + break; + case WfClassMemberKind::Static: + case WfClassMemberKind::Override: + manager->errors.Add(WfErrors::WrongClassMemberConfig(node)); + break; + } + } + + if (node->type) + { + ValidateTypeStructure(manager, node->type); + } + else if (classDecl) + { + manager->errors.Add(WfErrors::MissingFieldType(node)); + } + ValidateStructureContext context; + ValidateExpressionStructure(manager, &context, node->expression); + } + + void Visit(WfEventDeclaration* node)override + { + if (classDecl && node->classMember) + { + switch (node->classMember->kind) + { + case WfClassMemberKind::Normal: + break; + case WfClassMemberKind::Static: + case WfClassMemberKind::Override: + manager->errors.Add(WfErrors::WrongClassMemberConfig(node)); + break; + } + + FOREACH(Ptr, argument, node->arguments) + { + ValidateTypeStructure(manager, argument); + } + } + else if (dynamic_cast(surroundingLambda)) + { + manager->errors.Add(WfErrors::WrongDeclarationInInterfaceConstructor(node)); + } + else + { + manager->errors.Add(WfErrors::WrongDeclaration(node)); + } + } + + class FindPropertyRelatedDeclVisitor + : public empty_visitor::DeclarationVisitor + { + public: + WfLexicalScopeManager* manager; + WfClassDeclaration* classDecl; + WfPropertyDeclaration* propDecl; + Ptr getter; + Ptr setter; + Ptr valueChangedEvent; + bool duplicateGetter = false; + bool duplicateSetter = false; + bool duplicateEvent = false; + + FindPropertyRelatedDeclVisitor(WfLexicalScopeManager* _manager, WfClassDeclaration* _classDecl, WfPropertyDeclaration* _propDecl) + :manager(_manager) + , classDecl(_classDecl) + , propDecl(_propDecl) + { + } + + void Dispatch(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + Execute(decl); + } + } + + void Execute(Ptr memberDecl) + { + memberDecl->Accept(this); + if (!duplicateGetter && memberDecl->name.value == propDecl->getter.value) + { + if (getter) + { + duplicateGetter = true; + manager->errors.Add(WfErrors::TooManyPropertyGetter(propDecl, classDecl)); + } + else + { + getter = memberDecl; + } + } + + if (!duplicateSetter && propDecl->setter.value != L"" && memberDecl->name.value == propDecl->setter.value) + { + if (setter) + { + duplicateSetter = true; + manager->errors.Add(WfErrors::TooManyPropertySetter(propDecl, classDecl)); + } + else + { + setter = memberDecl; + } + } + + if (!duplicateEvent && propDecl->valueChangedEvent.value != L"" && memberDecl->name.value == propDecl->valueChangedEvent.value) + { + if (valueChangedEvent) + { + duplicateEvent = true; + manager->errors.Add(WfErrors::TooManyPropertyEvent(propDecl, classDecl)); + } + else + { + valueChangedEvent = memberDecl; + } + } + } + }; + + void Visit(WfPropertyDeclaration* node)override + { + if (classDecl && node->classMember) + { + switch (node->classMember->kind) + { + case WfClassMemberKind::Normal: + break; + case WfClassMemberKind::Static: + case WfClassMemberKind::Override: + manager->errors.Add(WfErrors::WrongClassMemberConfig(node)); + break; + } + + ValidateTypeStructure(manager, node->type); + FindPropertyRelatedDeclVisitor visitor(manager, classDecl, node); + + FOREACH(Ptr, memberDecl, classDecl->declarations) + { + visitor.Execute(memberDecl); + } + + if (!visitor.getter || visitor.getter->classMember->kind == WfClassMemberKind::Static || !visitor.getter.Cast()) + { + manager->errors.Add(WfErrors::PropertyGetterNotFound(node, classDecl)); + } + + if (node->setter.value != L"" && (!visitor.setter || visitor.setter->classMember->kind == WfClassMemberKind::Static || !visitor.setter.Cast())) + { + manager->errors.Add(WfErrors::PropertySetterNotFound(node, classDecl)); + } + + if (node->valueChangedEvent.value != L"" && (!visitor.valueChangedEvent || visitor.valueChangedEvent->classMember->kind == WfClassMemberKind::Static || !visitor.valueChangedEvent.Cast())) + { + manager->errors.Add(WfErrors::PropertyEventNotFound(node, classDecl)); + } + } + else if (dynamic_cast(surroundingLambda)) + { + manager->errors.Add(WfErrors::WrongDeclarationInInterfaceConstructor(node)); + } + else + { + manager->errors.Add(WfErrors::WrongDeclaration(node)); + } + } + + void Visit(WfConstructorDeclaration* node)override + { + if (classDecl && node->classMember) + { + switch (node->classMember->kind) + { + case WfClassMemberKind::Normal: + break; + case WfClassMemberKind::Static: + case WfClassMemberKind::Override: + manager->errors.Add(WfErrors::WrongClassMemberConfig(node)); + break; + } + + if (classDecl->kind != WfClassKind::Class) + { + manager->errors.Add(WfErrors::WrongDeclaration(node)); + } + + FOREACH(Ptr, call, node->baseConstructorCalls) + { + ValidateTypeStructure(manager, call->type, ValidateTypeStragety::BaseType, classDecl); + FOREACH(Ptr, argument, call->arguments) + { + ValidateStructureContext context; + ValidateExpressionStructure(manager, &context, argument); + } + } + { + ValidateStructureContext context; + ValidateStatementStructure(manager, &context, node->statement); + } + } + else + { + manager->errors.Add(WfErrors::WrongDeclaration(node)); + } + } + + void Visit(WfDestructorDeclaration* node)override + { + if (classDecl && node->classMember) + { + switch (node->classMember->kind) + { + case WfClassMemberKind::Normal: + break; + case WfClassMemberKind::Static: + case WfClassMemberKind::Override: + manager->errors.Add(WfErrors::WrongClassMemberConfig(node)); + break; + } + + if (classDecl->kind != WfClassKind::Class) + { + manager->errors.Add(WfErrors::WrongDeclaration(node)); + } + + ValidateStructureContext context; + ValidateStatementStructure(manager, &context, node->statement); + } + else + { + manager->errors.Add(WfErrors::WrongDeclaration(node)); + } + } + + class FindCtorVisitor + : public empty_visitor::DeclarationVisitor + { + public: + WfConstructorDeclaration* ctor = nullptr; + + void Dispatch(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + + void Visit(WfConstructorDeclaration* node)override + { + ctor = node; + } + }; + + class TooManyDtorVisitor + : public empty_visitor::DeclarationVisitor + { + public: + WfLexicalScopeManager* manager; + WfClassDeclaration* classDecl; + WfDestructorDeclaration* dtor = nullptr; + + TooManyDtorVisitor(WfLexicalScopeManager* _manager, WfClassDeclaration* _classDecl) + :manager(_manager) + , classDecl(_classDecl) + { + } + + void Dispatch(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + + void Visit(WfDestructorDeclaration* node)override + { + if (!dtor) + { + dtor = node; + } + else + { + manager->errors.Add(WfErrors::TooManyDestructor(node, classDecl)); + } + } + }; + + void Visit(WfClassDeclaration* node)override + { + if (classDecl && node->classMember) + { + switch (node->classMember->kind) + { + case WfClassMemberKind::Normal: + break; + case WfClassMemberKind::Static: + case WfClassMemberKind::Override: + manager->errors.Add(WfErrors::WrongClassMemberConfig(node)); + break; + } + } + else if (dynamic_cast(surroundingLambda)) + { + manager->errors.Add(WfErrors::WrongDeclarationInInterfaceConstructor(node)); + } + + switch (node->kind) + { + case WfClassKind::Class: + { + if (node->constructorType != WfConstructorType::Undefined) + { + manager->errors.Add(WfErrors::ClassWithInterfaceConstructor(node)); + } + { + FindCtorVisitor visitor; + FOREACH(Ptr, memberDecl, node->declarations) + { + memberDecl->Accept(&visitor); + } + + if (!visitor.ctor) + { + auto ctor = MakePtr(); + node->declarations.Add(ctor); + ctor->codeRange = node->codeRange; + ctor->classMember = MakePtr(); + ctor->classMember->codeRange = node->codeRange; + ctor->classMember->kind = WfClassMemberKind::Normal; + + auto stat = MakePtr(); + ctor->statement = stat; + stat->codeRange = node->codeRange; + } + } + } + break; + case WfClassKind::Interface: + break; + } + + FOREACH(Ptr, type, node->baseTypes) + { + ValidateTypeStructure(manager, type, ValidateTypeStragety::BaseType, node); + } + + { + TooManyDtorVisitor visitor(manager, node); + FOREACH(Ptr, memberDecl, node->declarations) + { + ValidateDeclarationStructure(manager, memberDecl, node); + memberDecl->Accept(&visitor); + } + } + } + + void Visit(WfEnumDeclaration* node)override + { + if (classDecl && node->classMember) + { + switch (node->classMember->kind) + { + case WfClassMemberKind::Normal: + break; + case WfClassMemberKind::Static: + case WfClassMemberKind::Override: + manager->errors.Add(WfErrors::WrongClassMemberConfig(node)); + break; + } + } + else if (dynamic_cast(surroundingLambda)) + { + manager->errors.Add(WfErrors::WrongDeclarationInInterfaceConstructor(node)); + } + + vuint64_t current = 0; + bool reportedNotConsecutive = false; + SortedList discoveredItems; + FOREACH(Ptr, item, node->items) + { + switch (item->kind) + { + case WfEnumItemKind::Constant: + { + vuint64_t value = -1; + TypedValueSerializerProvider::Deserialize(item->number.value, value); + if (!reportedNotConsecutive && value != current) + { + reportedNotConsecutive = true; + switch (node->kind) + { + case WfEnumKind::Normal: + manager->errors.Add(WfErrors::EnumValuesNotConsecutiveFromZero(node)); + break; + case WfEnumKind::Flag: + manager->errors.Add(WfErrors::FlagValuesNotConsecutiveFromZero(node)); + break; + } + } + switch (node->kind) + { + case WfEnumKind::Normal: + current++; + break; + case WfEnumKind::Flag: + current = current == 0 ? 1 : current * 2; + break; + } + } + break; + case WfEnumItemKind::Intersection: + FOREACH(Ptr, enumInt, item->intersections) + { + if (!discoveredItems.Contains(enumInt->name.value)) + { + manager->errors.Add(WfErrors::FlagValueNotExists(enumInt.Obj(), node)); + } + } + break; + } + + if (discoveredItems.Contains(item->name.value)) + { + manager->errors.Add(WfErrors::DuplicatedEnumValue(item.Obj(), node)); + } + else + { + discoveredItems.Add(item->name.value); + } + } + } + + void Visit(WfStructDeclaration* node)override + { + if (classDecl && node->classMember) + { + switch (node->classMember->kind) + { + case WfClassMemberKind::Normal: + break; + case WfClassMemberKind::Static: + case WfClassMemberKind::Override: + manager->errors.Add(WfErrors::WrongClassMemberConfig(node)); + break; + } + } + else if (dynamic_cast(surroundingLambda)) + { + manager->errors.Add(WfErrors::WrongDeclarationInInterfaceConstructor(node)); + } + + SortedList discoveredItems; + FOREACH(Ptr, member, node->members) + { + if (discoveredItems.Contains(member->name.value)) + { + manager->errors.Add(WfErrors::DuplicatedStructMember(member.Obj(), node)); + } + else + { + discoveredItems.Add(member->name.value); + } + } + } + + void Visit(WfVirtualDeclaration* node)override + { + node->Accept(static_cast(this)); + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + + void Visit(WfAutoPropertyDeclaration* node)override + { + switch (node->classMember->kind) + { + case WfClassMemberKind::Normal: + if (dynamic_cast(surroundingLambda)) + { + manager->errors.Add(WfErrors::AutoPropertyCannotBeNormalOutsideOfClass(node)); + } + break; + case WfClassMemberKind::Static: + manager->errors.Add(WfErrors::AutoPropertyCannotBeStatic(node)); + break; + case WfClassMemberKind::Override: + if (!dynamic_cast(surroundingLambda)) + { + manager->errors.Add(WfErrors::OverrideShouldImplementInterfaceMethod(node)); + } + break; + } + + if (classDecl) + { + switch (classDecl->kind) + { + case WfClassKind::Class: + if (!node->expression) + { + manager->errors.Add(WfErrors::AutoPropertyShouldBeInitialized(node)); + } + break; + case WfClassKind::Interface: + if (node->expression) + { + manager->errors.Add(WfErrors::AutoPropertyCannotBeInitializedInInterface(node, classDecl)); + } + break; + } + } + else if (dynamic_cast(surroundingLambda)) + { + if (!node->expression) + { + manager->errors.Add(WfErrors::AutoPropertyShouldBeInitialized(node)); + } + } + else + { + manager->errors.Add(WfErrors::WrongDeclaration(node)); + } + + ValidateTypeStructure(manager, node->type); + if (node->expression) + { + ValidateStructureContext context; + ValidateExpressionStructure(manager, &context, node->expression); + } + } + + void Visit(WfCastResultInterfaceDeclaration* node)override + { + } + + static void Execute(Ptr declaration, WfLexicalScopeManager* manager, WfClassDeclaration* classDecl, WfExpression* surroundingLambda) + { + ValidateStructureDeclarationVisitor visitor(manager, classDecl, surroundingLambda); + declaration->Accept(&visitor); + } + }; + +/*********************************************************************** +ValidateStructure(Statement) +***********************************************************************/ + + class ValidateStructureStatementVisitor + : public Object + , public WfStatement::IVisitor + , public WfVirtualStatement::IVisitor + , public WfCoroutineStatement::IVisitor + { + public: + WfLexicalScopeManager* manager; + ValidateStructureContext* context; + Ptr result; + + ValidateStructureStatementVisitor(WfLexicalScopeManager* _manager, ValidateStructureContext* _context) + :manager(_manager) + , context(_context) + { + } + + void Visit(WfBreakStatement* node)override + { + if (!context->currentLoopStatement) + { + manager->errors.Add(WfErrors::BreakNotInLoop(node)); + } + } + + void Visit(WfContinueStatement* node)override + { + if (!context->currentLoopStatement) + { + manager->errors.Add(WfErrors::ContinueNotInLoop(node)); + } + } + + void Visit(WfReturnStatement* node)override + { + if (node->expression) + { + ValidateExpressionStructure(manager, context, node->expression); + } + } + + void Visit(WfDeleteStatement* node)override + { + ValidateExpressionStructure(manager, context, node->expression); + } + + void Visit(WfRaiseExceptionStatement* node)override + { + if (node->expression) + { + ValidateExpressionStructure(manager, context, node->expression); + } + else if (!context->currentCatchStatement) + { + manager->errors.Add(WfErrors::RethrowNotInCatch(node)); + } + } + + void Visit(WfIfStatement* node)override + { + if (node->type) + { + ValidateTypeStructure(manager, node->type); + } + ValidateExpressionStructure(manager, context, node->expression); + ValidateStatementStructure(manager, context, node->trueBranch); + if (node->falseBranch) + { + ValidateStatementStructure(manager, context, node->falseBranch); + } + } + + void Visit(WfWhileStatement* node)override + { + auto oldLoop = context->currentLoopStatement; + context->currentLoopStatement = node; + ValidateExpressionStructure(manager, context, node->condition); + ValidateStatementStructure(manager, context, node->statement); + context->currentLoopStatement = oldLoop; + } + + void Visit(WfTryStatement* node)override + { + ValidateStatementStructure(manager, context, node->protectedStatement); + if (node->catchStatement) + { + auto oldCatch = context->currentCatchStatement; + context->currentCatchStatement = node->catchStatement.Obj(); + ValidateStatementStructure(manager, context, node->catchStatement); + context->currentCatchStatement = oldCatch; + } + if (node->finallyStatement) + { + ValidateStatementStructure(manager, context, node->finallyStatement); + } + if (!node->catchStatement && !node->finallyStatement) + { + manager->errors.Add(WfErrors::TryMissCatchAndFinally(node)); + } + } + + void Visit(WfBlockStatement* node)override + { + for (vint i = 0; i < node->statements.Count(); i++) + { + ValidateStatementStructure(manager, context, node->statements[i]); + } + } + + void Visit(WfExpressionStatement* node)override + { + ValidateExpressionStructure(manager, context, node->expression); + } + + void Visit(WfVariableStatement* node)override + { + ValidateDeclarationStructure(manager, node->variable); + } + + void Visit(WfVirtualStatement* node)override + { + node->Accept((WfVirtualStatement::IVisitor*)this); + if (node->expandedStatement) + { + ValidateStatementStructure(manager, context, node->expandedStatement); + } + } + + void Visit(WfSwitchStatement* node)override + { + ValidateExpressionStructure(manager, context, node->expression); + FOREACH(Ptr, switchCase, node->caseBranches) + { + ValidateExpressionStructure(manager, context, switchCase->expression); + ValidateStatementStructure(manager, context, switchCase->statement); + } + if (node->defaultBranch) + { + ValidateStatementStructure(manager, context, node->defaultBranch); + } + } + + void Visit(WfForEachStatement* node)override + { + auto oldLoop = context->currentLoopStatement; + context->currentLoopStatement = node; + ValidateExpressionStructure(manager, context, node->collection); + ValidateStatementStructure(manager, context, node->statement); + context->currentLoopStatement = oldLoop; + } + + void Visit(WfCoProviderStatement* node)override + { + auto oldProvider = context->currentCoProviderStatement; + context->currentCoProviderStatement = node; + ValidateStatementStructure(manager, context, node->statement); + context->currentCoProviderStatement = oldProvider; + } + + void Visit(WfCoroutineStatement* node)override + { + node->Accept((WfCoroutineStatement::IVisitor*)this); + } + + void Visit(WfCoPauseStatement* node)override + { + if (!context->currentNewCoroutineExpression || context->currentCoPauseStatement) + { + manager->errors.Add(WfErrors::WrongCoPause(node)); + } + if (node->statement) + { + auto oldCpPause = context->currentCoPauseStatement; + context->currentCoPauseStatement = node; + ValidateStatementStructure(manager, context, node->statement); + context->currentCoPauseStatement = oldCpPause; + } + } + + void Visit(WfCoOperatorStatement* node)override + { + if (!context->currentCoProviderStatement) + { + manager->errors.Add(WfErrors::WrongCoOperator(node)); + } + } + + static void Execute(Ptr& statement, WfLexicalScopeManager* manager, ValidateStructureContext* context) + { + ValidateStructureStatementVisitor visitor(manager, context); + statement->Accept(&visitor); + if (visitor.result) + { + statement = visitor.result; + } + } + }; + +/*********************************************************************** +ValidateStructure(Expression) +***********************************************************************/ + + class ValidateStructureExpressionVisitor + : public Object + , public WfExpression::IVisitor + , public WfVirtualExpression::IVisitor + { + public: + WfLexicalScopeManager* manager; + ValidateStructureContext* context; + Ptr result; + + ValidateStructureExpressionVisitor(WfLexicalScopeManager* _manager, ValidateStructureContext* _context) + :manager(_manager) + , context(_context) + { + } + + void Visit(WfThisExpression* node)override + { + if (context->currentBindExpression) + { + manager->errors.Add(WfErrors::WrongThisExpression(node)); + } + } + + void Visit(WfTopQualifiedExpression* node)override + { + } + + void Visit(WfReferenceExpression* node)override + { + } + + void Visit(WfOrderedNameExpression* node)override + { + } + + void Visit(WfOrderedLambdaExpression* node)override + { + auto oldBind = context->currentBindExpression; + context->currentBindExpression = 0; + ValidateExpressionStructure(manager, context, node->body); + context->currentBindExpression = oldBind; + } + + void Visit(WfMemberExpression* node)override + { + ValidateExpressionStructure(manager, context, node->parent); + } + + void Visit(WfChildExpression* node)override + { + ValidateExpressionStructure(manager, context, node->parent); + } + + void Visit(WfLiteralExpression* node)override + { + } + + void Visit(WfFloatingExpression* node)override + { + } + + void Visit(WfIntegerExpression* node)override + { + } + + void Visit(WfStringExpression* node)override + { + } + + void Visit(WfUnaryExpression* node)override + { + ValidateExpressionStructure(manager, context, node->operand); + } + + void Visit(WfBinaryExpression* node)override + { + ValidateExpressionStructure(manager, context, node->first); + ValidateExpressionStructure(manager, context, node->second); + } + + void Visit(WfLetExpression* node)override + { + FOREACH(Ptr, variable, node->variables) + { + ValidateExpressionStructure(manager, context, variable->value); + } + ValidateExpressionStructure(manager, context, node->expression); + } + + void Visit(WfIfExpression* node)override + { + ValidateExpressionStructure(manager, context, node->condition); + ValidateExpressionStructure(manager, context, node->trueBranch); + ValidateExpressionStructure(manager, context, node->falseBranch); + } + + void Visit(WfRangeExpression* node)override + { + ValidateExpressionStructure(manager, context, node->begin); + ValidateExpressionStructure(manager, context, node->end); + } + + void Visit(WfSetTestingExpression* node)override + { + ValidateExpressionStructure(manager, context, node->element); + ValidateExpressionStructure(manager, context, node->collection); + } + + void Visit(WfConstructorExpression* node)override + { + vint listElementCount = 0; + vint mapElementCount = 0; + FOREACH(Ptr, argument, node->arguments) + { + ValidateExpressionStructure(manager, context, argument->key); + if (argument->value) + { + ValidateExpressionStructure(manager, context, argument->value); + mapElementCount++; + } + else + { + listElementCount++; + } + } + + if (listElementCount*mapElementCount != 0) + { + manager->errors.Add(WfErrors::ConstructorMixMapAndList(node)); + } + } + + void Visit(WfInferExpression* node)override + { + ValidateTypeStructure(manager, node->type); + ValidateExpressionStructure(manager, context, node->expression); + } + + void Visit(WfTypeCastingExpression* node)override + { + ValidateTypeStructure(manager, node->type); + ValidateExpressionStructure(manager, context, node->expression); + } + + void Visit(WfTypeTestingExpression* node)override + { + if (node->type) + { + ValidateTypeStructure(manager, node->type); + } + ValidateExpressionStructure(manager, context, node->expression); + } + + void Visit(WfTypeOfTypeExpression* node)override + { + ValidateTypeStructure(manager, node->type); + } + + void Visit(WfTypeOfExpressionExpression* node)override + { + ValidateExpressionStructure(manager, context, node->expression); + } + + void Visit(WfAttachEventExpression* node)override + { + if (context->currentBindExpression) + { + manager->errors.Add(WfErrors::AttachInBind(node)); + } + ValidateExpressionStructure(manager, context, node->event); + ValidateExpressionStructure(manager, context, node->function); + } + + void Visit(WfDetachEventExpression* node)override + { + if (context->currentBindExpression) + { + manager->errors.Add(WfErrors::DetachInBind(node)); + } + ValidateExpressionStructure(manager, context, node->event); + ValidateExpressionStructure(manager, context, node->handler); + } + + void Visit(WfObserveExpression* node)override + { + if (!context->currentBindExpression) + { + manager->errors.Add(WfErrors::ObserveNotInBind(node)); + } + if (context->currentObserveExpression) + { + manager->errors.Add(WfErrors::ObserveInObserveEvent(node)); + } + + if (node->observeType == WfObserveType::SimpleObserve) + { + if (!node->expression.Cast()) + { + manager->errors.Add(WfErrors::WrongSimpleObserveExpression(node->expression.Obj())); + } + FOREACH(Ptr, event, node->events) + { + if (!event.Cast()) + { + manager->errors.Add(WfErrors::WrongSimpleObserveEvent(event.Obj())); + } + } + } + if (node->events.Count() == 0) + { + manager->errors.Add(WfErrors::EmptyObserveEvent(node)); + } + + ValidateExpressionStructure(manager, context, node->parent); + ValidateExpressionStructure(manager, context, node->expression); + context->currentObserveExpression = node; + for (vint i = 0; i < node->events.Count(); i++) + { + ValidateExpressionStructure(manager, context, node->events[i]); + } + context->currentObserveExpression = 0; + } + + void Visit(WfCallExpression* node)override + { + ValidateExpressionStructure(manager, context, node->function); + for (vint i = 0; i < node->arguments.Count(); i++) + { + ValidateExpressionStructure(manager, context, node->arguments[i]); + } + } + + void Visit(WfFunctionExpression* node)override + { + ValidateDeclarationStructure(manager, node->function, nullptr, node); + } + + void Visit(WfNewClassExpression* node)override + { + ValidateTypeStructure(manager, node->type); + for (vint i = 0; i < node->arguments.Count(); i++) + { + ValidateExpressionStructure(manager, context, node->arguments[i]); + } + } + + void Visit(WfNewInterfaceExpression* node)override + { + ValidateTypeStructure(manager, node->type); + FOREACH(Ptr, memberDecl, node->declarations) + { + ValidateDeclarationStructure(manager, memberDecl, nullptr, node); + } + } + + void Visit(WfVirtualExpression* node)override + { + node->Accept((WfVirtualExpression::IVisitor*)this); + if (node->expandedExpression) + { + ValidateExpressionStructure(manager, context, node->expandedExpression); + } + } + + void Visit(WfBindExpression* node)override + { + if (context->currentBindExpression) + { + manager->errors.Add(WfErrors::BindInBind(node)); + } + + auto bind = context->currentBindExpression; + context->currentBindExpression = node; + ValidateExpressionStructure(manager, context, node->expression); + context->currentBindExpression = bind; + } + + void Visit(WfFormatExpression* node)override + { + } + + void Visit(WfNewCoroutineExpression* node)override + { + ValidateStructureContext context; + context.currentNewCoroutineExpression = node; + ValidateStatementStructure(manager, &context, node->statement); + } + + void Visit(WfMixinCastExpression* node)override + { + ValidateTypeStructure(manager, node->type); + ValidateExpressionStructure(manager, context, node->expression); + } + + void Visit(WfExpectedTypeCastExpression* node)override + { + ValidateExpressionStructure(manager, context, node->expression); + } + + static void Execute(Ptr& expression, WfLexicalScopeManager* manager, ValidateStructureContext* context) + { + ValidateStructureExpressionVisitor visitor(manager, context); + expression->Accept(&visitor); + if (visitor.result) + { + expression = visitor.result; + } + } + }; + +/*********************************************************************** +ValidateStructure +***********************************************************************/ + + void ValidateTypeStructure(WfLexicalScopeManager* manager, Ptr type, ValidateTypeStragety strategy, WfClassDeclaration* classDecl) + { + ValidateStructureTypeVisitor::Execute(type, manager, strategy, classDecl); + } + + void ValidateModuleStructure(WfLexicalScopeManager* manager, Ptr module) + { + FOREACH(Ptr, path, module->paths) + { + FOREACH_INDEXER(Ptr, item, index, path->items) + { + vint counter = 0; + FOREACH(Ptr, fragment, item->fragments) + { + if (fragment.Cast()) + { + if (index == path->items.Count() - 1) + { + counter++; + } + else + { + goto USING_PATH_INCORRECT; + } + } + } + + if (index == path->items.Count() - 1 && counter != 1) + { + goto USING_PATH_INCORRECT; + } + } + continue; + USING_PATH_INCORRECT: + manager->errors.Add(WfErrors::WrongUsingPathWildCard(path.Obj())); + } + for (vint i = 0; i < module->declarations.Count(); i++) + { + ValidateDeclarationStructure(manager, module->declarations[i]); + } + } + + void ValidateDeclarationStructure(WfLexicalScopeManager* manager, Ptr declaration, WfClassDeclaration* classDecl, WfExpression* surroundingLambda) + { + ValidateStructureDeclarationVisitor::Execute(declaration, manager, classDecl, surroundingLambda); + } + + void ValidateStatementStructure(WfLexicalScopeManager* manager, ValidateStructureContext* context, Ptr& statement) + { + ValidateStructureStatementVisitor::Execute(statement, manager, context); + } + + void ValidateExpressionStructure(WfLexicalScopeManager* manager, ValidateStructureContext* context, Ptr& expression) + { + ValidateStructureExpressionVisitor::Execute(expression, manager, context); + } + } + } +} + + +/*********************************************************************** +.\CPP\WFCPP.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace cppcodegen + { + using namespace collections; + using namespace regex; + using namespace reflection; + using namespace reflection::description; + using namespace stream; + using namespace emitter; + +/*********************************************************************** +WfCppConfig +***********************************************************************/ + + void WfCppConfig::Collect() + { + FOREACH(Ptr, module, manager->GetModules()) + { + CollectModule(this, module); + } + + FOREACH(Ptr, lambda, lambdaExprs.Keys()) + { + auto closureInfo = CollectClosureInfo(lambda); + closureInfo->lambdaClassName = lambdaExprs[lambda.Obj()]; + closureInfos.Add(lambda, closureInfo); + } + + FOREACH(Ptr, classExpr, classExprs.Keys()) + { + auto closureInfo = CollectClosureInfo(classExpr); + closureInfo->lambdaClassName = classExprs[classExpr.Obj()]; + closureInfos.Add(classExpr, closureInfo); + } + } + + void WfCppConfig::Sort(collections::List>& structDecls) + { + List tds; + FOREACH_INDEXER(Ptr, decl, index, structDecls) + { + tds.Add(manager->declarationTypes[decl.Obj()].Obj()); + } + + for (vint i = 0; i < tds.Count(); i++) + { + for (vint j = i; i < tds.Count(); j++) + { + auto td = tds[j]; + vint count = td->GetPropertyCount(); + bool found = false; + for (vint k = 0; k < count && !found; k++) + { + auto prop = td->GetProperty(k); + auto propTd = prop->GetReturn()->GetTypeDescriptor(); + for (vint l = k + 1; l < tds.Count() && !found; l++) + { + found = tds[l] == propTd; + } + } + + if (!found) + { + if (j != i) + { + auto t = tds[j]; + tds.RemoveAt(j); + tds.Insert(i, t); + + auto decl = structDecls[j]; + structDecls.RemoveAt(j); + structDecls.Insert(i, decl); + } + + break; + } + } + } + } + + WfCppConfig::WfCppConfig(analyzer::WfLexicalScopeManager* _manager, const WString& _assemblyName, const WString& _assemblyNamespace) + :manager(_manager) + , regexSplitName(L"::") + , regexSpecialName(L"/<(/w+)(-(/w+))*/>(/w*)") + , regexTemplate(L", /$Arguments|/$Arguments, |/$/l+") + , assemblyName(_assemblyName) + , assemblyNamespace(_assemblyNamespace) + { + attributeEvaluator = MakePtr(manager); + Collect(); + for (vint i = 0; i < structDecls.Count(); i++) + { + const auto& values = structDecls.GetByIndex(i); + Sort(const_cast>&>(values)); + } + } + + WfCppConfig::~WfCppConfig() + { + } + + void WfCppConfig::WriteFunctionBody(stream::StreamWriter& writer, Ptr expr, const WString& prefix, ITypeInfo* expectedType) + { + writer.WriteString(prefix); + writer.WriteString(L"return "); + GenerateExpression(this, writer, expr, expectedType); + writer.WriteLine(L";"); + } + + void WfCppConfig::WriteFunctionBody(stream::StreamWriter& writer, Ptr stat, const WString& prefix, ITypeInfo* expectedType) + { + GenerateStatement(this, MakePtr(), writer, stat, prefix, WString(L"\t", false), expectedType); + } + + WString WfCppConfig::ConvertName(const WString& name) + { + if (name.Length() > 0 && name[0] == L'$') + { + return L"__vwsno_" + name.Sub(1, name.Length() - 1); + } + + auto match = regexSpecialName.Match(name); + if (match) + { + return L"__vwsn_" + + From(match->Groups()[L"category"]) + .Select([](const RegexString& rs) + { + return rs.Value(); + }) + .Aggregate([](const WString& a, const WString& b) + { + return a + L"_" + b; + }) + + L"_" + match->Groups()[L"name"][0].Value(); + } + else + { + return name; + } + } + + WString WfCppConfig::ConvertFullName(const WString& fullName, WString delimiter) + { + List> matches; + regexSplitName.Split(fullName, false, matches); + return (fullName[0] == L':' ? delimiter : WString::Empty) + From(matches) + .Select([this](Ptr match) + { + return ConvertName(match->Result().Value()); + }) + .Aggregate([&](const WString& a, const WString& b) + { + return a + delimiter + b; + }); + } + + WString WfCppConfig::ConvertFunctionType(IMethodInfo* methodInfo, WString name) + { + WString type = ConvertType(methodInfo->GetReturn()) + name + L"("; + vint count = methodInfo->GetParameterCount(); + for (vint i = 0; i < count; i++) + { + if (i > 0) + { + type += L", "; + } + type += ConvertArgumentType(methodInfo->GetParameter(i)->GetType()); + } + type += L")"; + return type; + } + + WString WfCppConfig::ConvertFunctionType(ITypeInfo* typeInfo) + { + if (typeInfo->GetDecorator() == ITypeInfo::SharedPtr) + { + return ConvertFunctionType(typeInfo->GetElementType()); + } + CHECK_ERROR(typeInfo->GetDecorator() == ITypeInfo::Generic, L"WfCppConfig::ConvertFunctionType(ITypeInfo*)#Wrong function type."); + CHECK_ERROR(typeInfo->GetTypeDescriptor() == description::GetTypeDescriptor(), L"WfCppConfig::ConvertFunctionType(ITypeInfo*)#Wrong function type."); + + WString type = ConvertType(typeInfo->GetGenericArgument(0)) + L"("; + vint count = typeInfo->GetGenericArgumentCount(); + for (vint i = 1; i < count; i++) + { + if (i > 1) type += L", "; + type += ConvertArgumentType(typeInfo->GetGenericArgument(i)); + } + type += L")"; + return type; + } + + bool WfCppConfig::IsSpecialGenericType(ITypeInfo* typeInfo) + { + switch (typeInfo->GetDecorator()) + { + case ITypeInfo::SharedPtr: + if (typeInfo->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + return true; + } + else if (typeInfo->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + return true; + } + else + { + return false; + } + default: + return false; + } + } + + WString WfCppConfig::ConvertType(ITypeDescriptor* typeInfo, WString delimiter) + { + return ConvertFullName(CppGetFullName(typeInfo), delimiter); + } + + WString WfCppConfig::ConvertType(ITypeInfo* typeInfo) + { + switch (typeInfo->GetDecorator()) + { + case ITypeInfo::RawPtr: + return ConvertType(typeInfo->GetElementType()) + L"*"; + case ITypeInfo::SharedPtr: + if (typeInfo->GetElementType()->GetDecorator() == ITypeInfo::Generic) + { + if (typeInfo->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + return ConvertType(typeInfo->GetElementType()); + } + else if (typeInfo->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + return ConvertType(typeInfo->GetElementType()); + } + } + return L"::vl::Ptr<" + ConvertType(typeInfo->GetElementType()) + L">"; + case ITypeInfo::Nullable: + return L"::vl::Nullable<" + ConvertType(typeInfo->GetElementType()) + L">"; + case ITypeInfo::Generic: + if (typeInfo->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + return L"::vl::Func<" + ConvertFunctionType(typeInfo) + L">"; + } + else if(typeInfo->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + return L"::vl::collections::LazyList<" + ConvertType(typeInfo->GetGenericArgument(0)) + L">"; + } + else + { + return ConvertType(typeInfo->GetElementType()); + } + default:; + } + return ConvertType(typeInfo->GetTypeDescriptor()); + } + + WString WfCppConfig::ConvertArgumentType(ITypeInfo* typeInfo) + { + auto td = typeInfo->GetTypeDescriptor(); + bool constRef = + td == description::GetTypeDescriptor() || + td == description::GetTypeDescriptor() || + ( + typeInfo->GetDecorator() == ITypeInfo::SharedPtr && typeInfo->GetElementType()->GetDecorator() == ITypeInfo::Generic && + ( + td == description::GetTypeDescriptor() || + td == description::GetTypeDescriptor() + ) + ); + + if (constRef) + { + return L"const " + ConvertType(typeInfo) + L"&"; + } + else + { + return ConvertType(typeInfo); + } + } + + WString WfCppConfig::DefaultValue(ITypeInfo* typeInfo) + { + switch (typeInfo->GetDecorator()) + { + case ITypeInfo::RawPtr: + return L"nullptr"; + case ITypeInfo::SharedPtr: + return L""; + case ITypeInfo::Nullable: + return L""; + case ITypeInfo::Generic: + return L""; + default:; + } + auto td = typeInfo->GetTypeDescriptor(); + if ((td->GetTypeDescriptorFlags()&TypeDescriptorFlags::EnumType) != TypeDescriptorFlags::Undefined) + { + return L"static_cast<" + ConvertType(typeInfo) + L">(0)"; + } + if (td == description::GetTypeDescriptor()) return L"0"; + if (td == description::GetTypeDescriptor()) return L"0"; + if (td == description::GetTypeDescriptor()) return L"0"; + if (td == description::GetTypeDescriptor()) return L"0"; + if (td == description::GetTypeDescriptor()) return L"0"; + if (td == description::GetTypeDescriptor()) return L"0"; + if (td == description::GetTypeDescriptor()) return L"0"; + if (td == description::GetTypeDescriptor()) return L"0"; + if (td == description::GetTypeDescriptor()) return L"false"; + if (td == description::GetTypeDescriptor()) return L"0.0f"; + if (td == description::GetTypeDescriptor()) return L"0.0"; + return L""; + } + + vint WfCppConfig::CountClassNamespace(Ptr decl) + { + vint result = 0; + auto scope = manager->nodeScopes[decl.Obj()].Obj(); + while (scope) + { + if (scope->ownerNode.Cast()) + { + result++; + } + scope = scope->parentScope.Obj(); + } + return result; + } + + void WfCppConfig::GetClassNamespace(Ptr decl, collections::List& nss) + { + auto td = manager->declarationTypes[decl.Obj()].Obj(); + auto name = ConvertType(td); + vint count = CountClassNamespace(decl); + + List> matches; + regexSplitName.Split(name, false, matches); + + CopyFrom( + nss, + From(matches) + .Take(count) + .Select([this](Ptr match) + { + return ConvertName(match->Result().Value()); + }) + ); + } + + WString WfCppConfig::GetClassBaseName(Ptr decl) + { + auto td = manager->declarationTypes[decl.Obj()].Obj(); + auto name = ConvertType(td); + vint count = CountClassNamespace(decl); + + List> matches; + regexSplitName.Split(name, false, matches); + + return From(matches) + .Skip(count) + .Select([this](Ptr match) + { + return ConvertName(match->Result().Value()); + }) + .Aggregate([](const WString& a, const WString& b) + { + return a + L"::" + b; + }); + } + + WString WfCppConfig::WriteNamespace(stream::StreamWriter& writer, collections::List& nss, collections::List& nss2) + { + vint commonPrefix = 0; + for (vint i = 0; i < nss.Count() && i < nss2.Count(); i++) + { + if (nss[i] == nss2[i]) + { + commonPrefix++; + } + else + { + break; + } + } + + while (nss.Count() > commonPrefix) + { + for (vint i = 1; i < nss.Count(); i++) + { + writer.WriteChar(L'\t'); + } + writer.WriteLine(L"}"); + nss.RemoveAt(nss.Count() - 1); + } + + WString prefix; + for (vint i = 0; i < nss.Count(); i++) + { + prefix += L'\t'; + } + + for (vint i = commonPrefix; i < nss2.Count(); i++) + { + writer.WriteString(prefix); + writer.WriteString(L"namespace "); + writer.WriteLine(nss2[i]); + + writer.WriteString(prefix); + writer.WriteLine(L"{"); + + nss.Add(nss2[i]); + prefix += L'\t'; + } + + return prefix; + } + + WString WfCppConfig::WriteNamespace(stream::StreamWriter& writer, const WString& fullName, collections::List& nss, WString& name) + { + List> matches; + regexSplitName.Split(fullName, false, matches); + + List nss2; + CopyFrom( + nss2, + From(matches) + .Select([this](Ptr match) + { + return ConvertName(match->Result().Value()); + }) + ); + + name = nss2[nss2.Count() - 1]; + nss2.RemoveAt(nss2.Count() - 1); + return WriteNamespace(writer, nss, nss2); + } + + void WfCppConfig::WriteNamespaceEnd(stream::StreamWriter& writer, collections::List& nss) + { + while (nss.Count() > 0) + { + for (vint i = 1; i < nss.Count(); i++) + { + writer.WriteChar(L'\t'); + } + writer.WriteLine(L"}"); + nss.RemoveAt(0); + } + } + } + } +} + + +/*********************************************************************** +.\CPP\WFCPP_CLASS.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace cppcodegen + { + using namespace collections; + using namespace reflection; + using namespace reflection::description; + using namespace analyzer; + + bool IsVirtual(WfCppConfig* config, WfFunctionDeclaration* node) + { + vint index = config->manager->declarationMemberInfos.Keys().IndexOf(node); + if (index != -1) + { + auto methodInfo = dynamic_cast(config->manager->declarationMemberInfos.Values()[index].Obj()); + if (methodInfo->IsStatic()) + { + return false; + } + auto td = methodInfo->GetOwnerTypeDescriptor(); + return td->GetTypeDescriptorFlags() == TypeDescriptorFlags::Interface; + } + return false; + } + +/*********************************************************************** +WfGenerateClassMemberDeclVisitor +***********************************************************************/ + + class WfGenerateClassMemberDeclVisitor : public Object, public WfDeclaration::IVisitor + { + public: + WfCppConfig* config; + stream::StreamWriter& writer; + WString className; + WString prefix; + bool forClassExpr; + + WfGenerateClassMemberDeclVisitor(WfCppConfig* _config, stream::StreamWriter& _writer, const WString& _className, const WString& _prefix, bool _forClassExpr) + :config(_config) + , writer(_writer) + , className(_className) + , prefix(_prefix) + , forClassExpr(_forClassExpr) + { + } + + void Visit(WfNamespaceDeclaration* node)override + { + } + + void Visit(WfFunctionDeclaration* node)override + { + bool isVirtual = IsVirtual(config, node); + + writer.WriteString(prefix); + if (isVirtual) + { + writer.WriteString(L"virtual "); + } + else if (node->classMember->kind == WfClassMemberKind::Static) + { + writer.WriteString(L"static "); + } + config->WriteFunctionHeader(writer, node, config->ConvertName(node->name.value), true); + if (isVirtual) + { + writer.WriteString(L" = 0"); + } + else if (node->classMember->kind == WfClassMemberKind::Override) + { + writer.WriteString(L" override"); + } + writer.WriteLine(L";"); + } + + void Visit(WfVariableDeclaration* node)override + { + auto scope = config->manager->nodeScopes[node].Obj(); + auto symbol = scope->symbols[node->name.value][0]; + auto typeInfo = symbol->typeInfo; + writer.WriteString(prefix + config->ConvertType(typeInfo.Obj()) + L" " + config->ConvertName(node->name.value)); + if (!forClassExpr && node->expression) + { + writer.WriteString(L" = "); + GenerateExpression(config, writer, node->expression, typeInfo.Obj()); + } + else + { + auto defaultValue = config->DefaultValue(typeInfo.Obj()); + if (defaultValue != L"") + { + writer.WriteString(L" = "); + writer.WriteString(defaultValue); + } + } + writer.WriteLine(L";"); + } + + void Visit(WfEventDeclaration* node)override + { + auto eventInfo = dynamic_cast(config->manager->declarationMemberInfos[node].Obj()); + auto typeInfo = eventInfo->GetHandlerType(); + writer.WriteString(prefix); + + writer.WriteString(L"::vl::EventGetGenericArgumentCount(); + for (vint i = 1; i < count; i++) + { + if (i > 1) writer.WriteString(L", "); + writer.WriteString(config->ConvertType(typeInfo->GetGenericArgument(i))); + } + writer.WriteLine(L")> " + config->ConvertName(node->name.value) + L";"); + } + + void Visit(WfPropertyDeclaration* node)override + { + } + + void Visit(WfConstructorDeclaration* node)override + { + auto methodInfo = dynamic_cast(config->manager->declarationMemberInfos[node].Obj()); + writer.WriteString(prefix); + config->WriteFunctionHeader(writer, methodInfo, className, false); + writer.WriteLine(L";"); + } + + void Visit(WfDestructorDeclaration* node)override + { + writer.WriteLine(prefix + L"~" + className + L"();"); + } + + void Visit(WfClassDeclaration* node)override + { + } + + void Visit(WfEnumDeclaration* node)override + { + } + + void Visit(WfStructDeclaration* node)override + { + } + + void Visit(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + }; + + void GenerateClassMemberDecl(WfCppConfig* config, stream::StreamWriter& writer, const WString& className, Ptr memberDecl, const WString& prefix, bool forClassExpr) + { + WfGenerateClassMemberDeclVisitor visitor(config, writer, className, prefix, forClassExpr); + memberDecl->Accept(&visitor); + } + +/*********************************************************************** +WfGenerateClassMemberImplVisitor +***********************************************************************/ + + class WfGenerateClassMemberImplVisitor : public Object, public WfDeclaration::IVisitor + { + public: + WfCppConfig* config; + stream::StreamWriter& writer; + WString classBaseName; + WString className; + WString classFullName; + WString prefix; + bool printableMember = false; + + WfGenerateClassMemberImplVisitor(WfCppConfig* _config, stream::StreamWriter& _writer, const WString& _classBaseName, const WString& _className, const WString& _classFullName, const WString& _prefix) + :config(_config) + , writer(_writer) + , classBaseName(_classBaseName) + , className(_className) + , classFullName(_classFullName) + , prefix(_prefix) + { + } + + void WriteNotImplemented() + { + writer.WriteString(prefix); + writer.WriteLine(L"{"); + writer.WriteString(prefix); + writer.WriteLine(L"\tthrow ::vl::Exception(L\"You should implement this function.\");"); + writer.WriteString(prefix); + writer.WriteLine(L"}"); + } + + void Visit(WfNamespaceDeclaration* node)override + { + } + + void Visit(WfFunctionDeclaration* node)override + { + if (!IsVirtual(config, node)) + { + printableMember = true; + + bool userImpl = config->attributeEvaluator->GetAttribute(node->attributes, L"cpp", L"UserImpl"); + if (userImpl) + { + writer.WriteString(prefix); + writer.WriteString(L"USERIMPL(/* "); + writer.WriteString(classFullName); + writer.WriteLine(L" */)"); + } + + writer.WriteString(prefix); + auto returnType = config->WriteFunctionHeader(writer, node, classBaseName + L"::" + config->ConvertName(node->name.value), true); + writer.WriteLine(L""); + + if (userImpl) + { + WriteNotImplemented(); + } + else + { + config->WriteFunctionBody(writer, node->statement, prefix, returnType); + } + } + } + + void Visit(WfVariableDeclaration* node)override + { + } + + void Visit(WfEventDeclaration* node)override + { + } + + void Visit(WfPropertyDeclaration* node)override + { + } + + void Visit(WfConstructorDeclaration* node)override + { + auto scope = config->manager->nodeScopes[node].Obj(); + printableMember = true; + auto methodInfo = dynamic_cast(config->manager->declarationMemberInfos[node].Obj()); + + List arguments; + FOREACH(Ptr, argument, node->arguments) + { + arguments.Add(config->ConvertName(argument->name.value)); + } + + bool userImpl = config->attributeEvaluator->GetAttribute(node->attributes, L"cpp", L"UserImpl"); + if (userImpl) + { + writer.WriteString(prefix); + writer.WriteString(L"USERIMPL(/* "); + writer.WriteString(classFullName); + writer.WriteLine(L" */)"); + } + + writer.WriteString(prefix); + config->WriteFunctionHeader(writer, methodInfo, arguments, classBaseName + L"::" + className, false); + writer.WriteLine(L""); + FOREACH_INDEXER(Ptr, call, callIndex, node->baseConstructorCalls) + { + auto callType = CreateTypeInfoFromType(scope, call->type); + auto callCtor = config->manager->baseConstructorCallResolvings[{node, callType->GetTypeDescriptor()}].value; + + writer.WriteString(prefix); + if (callIndex == 0) + { + writer.WriteString(L"\t: "); + } + else + { + writer.WriteString(L"\t, "); + } + + writer.WriteString(config->ConvertType(callType->GetTypeDescriptor())); + writer.WriteString(L"("); + FOREACH_INDEXER(Ptr, argument, argumentIndex, call->arguments) + { + if (argumentIndex) writer.WriteString(L", "); + GenerateExpression(config, writer, argument, callCtor->GetParameter(argumentIndex)->GetType()); + } + writer.WriteLine(L")"); + } + + if (userImpl) + { + WriteNotImplemented(); + } + else + { + config->WriteFunctionBody(writer, node->statement, prefix, nullptr); + } + } + + void Visit(WfDestructorDeclaration* node)override + { + printableMember = true; + + bool userImpl = config->attributeEvaluator->GetAttribute(node->attributes, L"cpp", L"UserImpl"); + if (userImpl) + { + writer.WriteString(prefix); + writer.WriteString(L"USERIMPL(/* "); + writer.WriteString(classFullName); + writer.WriteLine(L" */)"); + } + + writer.WriteLine(prefix + classBaseName + L"::~" + className + L"()"); + + if (userImpl) + { + WriteNotImplemented(); + } + else + { + config->WriteFunctionBody(writer, node->statement, prefix, nullptr); + } + } + + void Visit(WfClassDeclaration* node)override + { + } + + void Visit(WfEnumDeclaration* node)override + { + } + + void Visit(WfStructDeclaration* node)override + { + } + + void Visit(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + }; + + bool GenerateClassMemberImpl(WfCppConfig* config, stream::StreamWriter& writer, const WString& classBaseName, const WString& className, const WString& classFullName, Ptr memberDecl, const WString& prefix) + { + WfGenerateClassMemberImplVisitor visitor(config, writer, classBaseName, className, classFullName, prefix); + memberDecl->Accept(&visitor); + return visitor.printableMember; + } + } + } +} + +/*********************************************************************** +.\CPP\WFCPP_COLLECT.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace cppcodegen + { + using namespace collections; + using namespace regex; + using namespace reflection::description; + using namespace analyzer; + +/*********************************************************************** +CollectModule +***********************************************************************/ + + class WfCollectModuleVisitor : public traverse_visitor::ModuleVisitor + { + public: + WfCppConfig* config; + WfClassDeclaration* surroundingClassDecl = nullptr; + WfFunctionDeclaration* funcDeclToSkip = nullptr; + WfVariableDeclaration* varDeclToSkip = nullptr; + + WfCollectModuleVisitor(WfCppConfig* _config) + :config(_config) + { + } + + WString GetScopePostfix(WfLexicalScope* scope) + { + WString name; + while (scope) + { + if (auto decl = scope->ownerNode.Cast()) + { + name = config->ConvertName(decl->name.value) + L"_" + name; + } + scope = scope->parentScope.Obj(); + } + return name; + } + + void Traverse(WfOrderedLambdaExpression* node)override + { + WString prefix = L"__vwsno" + itow(config->lambdaExprs.Count() + 1) + L"_" + config->assemblyName + L"_"; + WString postfix = GetScopePostfix(config->manager->nodeScopes[node].Obj()); + WString name = prefix + postfix; + + config->lambdaExprs.Add(node, name); + config->classClosures.Add(surroundingClassDecl, node); + } + + void Traverse(WfFunctionExpression* node)override + { + WString prefix = L"__vwsnf" + itow(config->lambdaExprs.Count() + 1) + L"_" + config->assemblyName + L"_"; + WString postfix = GetScopePostfix(config->manager->nodeScopes[node].Obj()); + WString name = prefix + postfix; + + config->lambdaExprs.Add(node, name); + config->classClosures.Add(surroundingClassDecl, node); + } + + void Traverse(WfNewInterfaceExpression* node)override + { + WString prefix = L"__vwsnc" + itow(config->classExprs.Count() + 1) + L"_" + config->assemblyName + L"_"; + WString postfix = GetScopePostfix(config->manager->nodeScopes[node].Obj()); + + auto result = config->manager->expressionResolvings[node]; + auto td = result.constructorInfo->GetOwnerTypeDescriptor(); + WString name = prefix + postfix + config->ConvertType(td, L"_"); + + config->classExprs.Add(node, name); + config->classClosures.Add(surroundingClassDecl, node); + } + + void Traverse(WfFunctionDeclaration* node)override + { + if (node != funcDeclToSkip && !node->classMember) + { + config->funcDecls.Add(node); + } + } + + void Traverse(WfVariableDeclaration* node)override + { + if (node != varDeclToSkip && !node->classMember) + { + config->varDecls.Add(node); + } + } + + void AddDeclFile(WfDeclaration* node) + { + if (surroundingClassDecl) + { + auto fileName = config->declFiles[surroundingClassDecl]; + config->declFiles.Add(node, fileName); + } + else + { + config->declFiles.Add(node, L""); + } + } + + void Visit(WfClassDeclaration* node)override + { + config->classDecls.Add(surroundingClassDecl, node); + + if (surroundingClassDecl) + { + AddDeclFile(node); + } + else + { + WString file; + if (auto att = config->attributeEvaluator->GetAttribute(node->attributes, L"cpp", L"File")) + { + file = UnboxValue(config->attributeEvaluator->GetAttributeValue(att)); + } + config->topLevelClassDeclsForFiles.Add(file, node); + config->declFiles.Add(node, file); + } + + auto td = config->manager->declarationTypes[node].Obj(); + vint count = td->GetBaseTypeDescriptorCount(); + for (vint i = 0; i < count; i++) + { + auto baseTd = td->GetBaseTypeDescriptor(i); + auto scopeName = config->manager->typeNames[baseTd]; + if (scopeName->declarations.Count() > 0) + { + config->declDependencies.Add(node, scopeName->declarations[0]); + } + } + + auto oldSurroundingClassDecl = surroundingClassDecl; + surroundingClassDecl = node; + traverse_visitor::DeclarationVisitor::Visit(node); + surroundingClassDecl = oldSurroundingClassDecl; + } + + void Traverse(WfEnumDeclaration* node)override + { + config->enumDecls.Add(surroundingClassDecl, node); + AddDeclFile(node); + } + + void Traverse(WfStructDeclaration* node)override + { + config->structDecls.Add(surroundingClassDecl, node); + AddDeclFile(node); + + auto td = config->manager->declarationTypes[node].Obj(); + vint count = td->GetPropertyCount(); + for (vint i = 0; i < count; i++) + { + auto propTd = td->GetProperty(i)->GetReturn()->GetTypeDescriptor(); + auto scopeName = config->manager->typeNames[propTd]; + if (scopeName->declarations.Count() > 0) + { + config->declDependencies.Add(node, scopeName->declarations[0]); + } + } + } + + void Visit(WfFunctionExpression* node)override + { + auto old = funcDeclToSkip; + funcDeclToSkip = node->function.Obj(); + traverse_visitor::ExpressionVisitor::Visit(node); + funcDeclToSkip = old; + } + + void Visit(WfVariableStatement* node)override + { + auto old = varDeclToSkip; + varDeclToSkip = node->variable.Obj(); + traverse_visitor::StatementVisitor::Visit(node); + varDeclToSkip = old; + } + }; + + void CollectModule(WfCppConfig* config, Ptr module) + { + WfCollectModuleVisitor(config).VisitField(module.Obj()); + } + } + } +} + +/*********************************************************************** +.\CPP\WFCPP_EXPRESSION.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace cppcodegen + { + using namespace collections; + using namespace regex; + using namespace reflection; + using namespace reflection::description; + using namespace analyzer; + +/*********************************************************************** +Expression Helpers +***********************************************************************/ + + template + void WriteBoxValue(WfCppConfig* config, stream::StreamWriter& writer, ITypeInfo* type, const T& writeExpression) + { + writer.WriteString(L"::vl::__vwsn::Box("); + writeExpression(); + writer.WriteString(L")"); + } + + template + void WriteUnboxValue(WfCppConfig* config, stream::StreamWriter& writer, ITypeInfo* type, const T& writeExpression) + { + writer.WriteString(L"::vl::__vwsn::Unbox<"); + writer.WriteString(config->ConvertType(type)); + writer.WriteString(L">("); + writeExpression(); + writer.WriteString(L")"); + } + + template + void WriteUnboxWeakValue(WfCppConfig* config, stream::StreamWriter& writer, ITypeInfo* type, const T& writeExpression) + { + writer.WriteString(L"::vl::__vwsn::UnboxWeak<"); + writer.WriteString(config->ConvertType(type)); + writer.WriteString(L">("); + writeExpression(); + writer.WriteString(L")"); + } + + template + void ConvertValueType(WfCppConfig* config, stream::StreamWriter& writer, ITypeDescriptor* fromTd, ITypeDescriptor* toTd, const T& writeExpression) + { + if (fromTd == toTd) + { + writeExpression(); + } + else if (fromTd == description::GetTypeDescriptor()) + { + writer.WriteString(L"::vl::__vwsn::Parse<"); + writer.WriteString(config->ConvertType(toTd)); + writer.WriteString(L">("); + writeExpression(); + writer.WriteString(L")"); + } + else if (toTd == description::GetTypeDescriptor()) + { + writer.WriteString(L"::vl::__vwsn::ToString("); + writeExpression(); + writer.WriteString(L")"); + } + else + { + writer.WriteString(L"static_cast<"); + writer.WriteString(config->ConvertType(toTd)); + writer.WriteString(L">("); + writeExpression(); + writer.WriteString(L")"); + } + } + + void ConvertType(WfCppConfig* config, stream::StreamWriter& writer, ITypeInfo* fromType, ITypeInfo* toType, const Func& writeExpression, bool strongCast) + { + if (fromType->GetTypeDescriptor()->GetTypeDescriptorFlags() == TypeDescriptorFlags::Object) + { + if (strongCast) + { + WriteUnboxValue(config, writer, toType, writeExpression); + } + else + { + WriteUnboxWeakValue(config, writer, toType, writeExpression); + } + return; + } + else if (toType->GetTypeDescriptor()->GetTypeDescriptorFlags() == TypeDescriptorFlags::Object) + { + WriteBoxValue(config, writer, fromType, writeExpression); + return; + } + else + { + auto tdVe = description::GetTypeDescriptor(); + if (toType->GetTypeDescriptor() == tdVe) + { + if (toType->GetElementType()->GetDecorator() == ITypeInfo::Generic) + { + if ((fromType->GetTypeDescriptor() == tdVe && fromType->GetElementType()->GetDecorator() != ITypeInfo::Generic) + || fromType->GetTypeDescriptor()->CanConvertTo(description::GetTypeDescriptor()) + || fromType->GetTypeDescriptor()->CanConvertTo(description::GetTypeDescriptor()) + ) + { + writer.WriteString(L"::vl::reflection::description::GetLazyList<"); + writer.WriteString(config->ConvertType(toType->GetElementType()->GetGenericArgument(0))); + writer.WriteString(L">("); + writeExpression(); + writer.WriteString(L")"); + return; + } + } + else + { + if ((fromType->GetTypeDescriptor() == tdVe && fromType->GetElementType()->GetDecorator() == ITypeInfo::Generic) + || fromType->GetHint() == TypeInfoHint::NativeCollectionReference + ) + { + writer.WriteString(L"::vl::__vwsn::UnboxCollection<"); + writer.WriteString(config->ConvertType(tdVe)); + writer.WriteString(L">("); + writeExpression(); + writer.WriteString(L")"); + return; + } + } + } + + switch (fromType->GetDecorator()) + { + case ITypeInfo::RawPtr: + { + switch (toType->GetDecorator()) + { + case ITypeInfo::RawPtr: + if (strongCast) writer.WriteString(L"::vl::__vwsn::Ensure("); + if (fromType->GetTypeDescriptor()->CanConvertTo(toType->GetTypeDescriptor())) + { + writer.WriteString(L"static_cast<"); + writer.WriteString(config->ConvertType(toType->GetTypeDescriptor())); + writer.WriteString(L"*>("); + writeExpression(); + writer.WriteString(L")"); + } + else + { + writer.WriteString(L"::vl::__vwsn::RawPtrCast<"); + writer.WriteString(config->ConvertType(toType->GetTypeDescriptor())); + writer.WriteString(L">("); + writeExpression(); + writer.WriteString(L")"); + } + if (strongCast) writer.WriteString(L")"); + return; + case ITypeInfo::SharedPtr: + if (strongCast) writer.WriteString(L"::vl::__vwsn::Ensure("); + if (fromType->GetTypeDescriptor()->CanConvertTo(toType->GetTypeDescriptor())) + { + writer.WriteString(L"::vl::Ptr<"); + writer.WriteString(config->ConvertType(toType->GetTypeDescriptor())); + writer.WriteString(L">("); + writeExpression(); + writer.WriteString(L")"); + } + else + { + writer.WriteString(L"::vl::__vwsn::SharedPtrCast<"); + writer.WriteString(config->ConvertType(toType->GetTypeDescriptor())); + writer.WriteString(L">("); + writeExpression(); + writer.WriteString(L")"); + } + if (strongCast) writer.WriteString(L")"); + return; + default:; + } + } + break; + case ITypeInfo::SharedPtr: + { + switch (toType->GetDecorator()) + { + case ITypeInfo::RawPtr: + if (strongCast) writer.WriteString(L"::vl::__vwsn::Ensure("); + if (fromType->GetTypeDescriptor()->CanConvertTo(toType->GetTypeDescriptor())) + { + writer.WriteString(L"static_cast<"); + writer.WriteString(config->ConvertType(toType->GetTypeDescriptor())); + writer.WriteString(L"*>("); + writeExpression(); + writer.WriteString(L".Obj())"); + } + else + { + writer.WriteString(L"::vl::__vwsn::RawPtrCast<"); + writer.WriteString(config->ConvertType(toType->GetTypeDescriptor())); + writer.WriteString(L">("); + writeExpression(); + writer.WriteString(L".Obj())"); + } + if (strongCast) writer.WriteString(L")"); + return; + case ITypeInfo::SharedPtr: + if (strongCast) writer.WriteString(L"::vl::__vwsn::Ensure("); + if (fromType->GetTypeDescriptor()->CanConvertTo(toType->GetTypeDescriptor())) + { + writer.WriteString(L"::vl::Ptr<"); + writer.WriteString(config->ConvertType(toType->GetTypeDescriptor())); + writer.WriteString(L">("); + writeExpression(); + writer.WriteString(L")"); + } + else + { + writer.WriteString(L"::vl::__vwsn::SharedPtrCast<"); + writer.WriteString(config->ConvertType(toType->GetTypeDescriptor())); + writer.WriteString(L">("); + writeExpression(); + writer.WriteString(L".Obj())"); + } + if (strongCast) writer.WriteString(L")"); + return; + default:; + } + } + break; + case ITypeInfo::Nullable: + { + switch (toType->GetDecorator()) + { + case ITypeInfo::Nullable: + if (strongCast) writer.WriteString(L"::vl::__vwsn::Ensure("); + writer.WriteString(L"::vl::__vwsn::NullableCast<"); + writer.WriteString(config->ConvertType(toType->GetTypeDescriptor())); + writer.WriteString(L">("); + writeExpression(); + writer.WriteString(L")"); + if (strongCast) writer.WriteString(L")"); + return; + case ITypeInfo::TypeDescriptor: + ConvertValueType(config, writer, fromType->GetTypeDescriptor(), toType->GetTypeDescriptor(), [&]() + { + writeExpression(); + writer.WriteString(L".Value()"); + }); + return; + default:; + } + } + break; + case ITypeInfo::TypeDescriptor: + { + switch (toType->GetDecorator()) + { + case ITypeInfo::Nullable: + writer.WriteString(config->ConvertType(toType)); + writer.WriteString(L"("); + ConvertValueType(config, writer, fromType->GetTypeDescriptor(), toType->GetTypeDescriptor(), writeExpression); + writer.WriteString(L")"); + return; + case ITypeInfo::TypeDescriptor: + ConvertValueType(config, writer, fromType->GetTypeDescriptor(), toType->GetTypeDescriptor(), writeExpression); + return; + default:; + } + } + break; + default:; + } + } + writer.WriteString(L"/* NOT EXISTS: convert ("); + writer.WriteString(config->ConvertType(fromType)); + writer.WriteString(L") to ("); + writer.WriteString(config->ConvertType(toType)); + writer.WriteString(L") */ __vwsn_not_exists__("); + writeExpression(); + writer.WriteString(L")"); + } + +/*********************************************************************** +WfGenerateExpressionVisitor +***********************************************************************/ + + class WfGenerateExpressionVisitor + : public Object + , public WfExpression::IVisitor + { + public: + WfCppConfig* config; + stream::StreamWriter& writer; + bool useReturnValue; + + WfGenerateExpressionVisitor(WfCppConfig* _config, stream::StreamWriter& _writer, bool _useReturnValue) + :config(_config) + , writer(_writer) + , useReturnValue(_useReturnValue) + { + } + + bool NeedConvertType(ITypeInfo* fromType, ITypeInfo*& toType) + { + if (toType == nullptr) + { + toType = fromType; + return false; + } + if (IsSameType(fromType, toType)) + { + return false; + } + else + { + return true; + } + } + + template + void WriteBoxValue(ITypeInfo* type, const T& writeExpression) + { + cppcodegen::WriteBoxValue(config, writer, type, writeExpression); + } + + template + void WriteUnboxValue(ITypeInfo* type, const T& writeExpression) + { + cppcodegen::WriteUnboxValue(config, writer, type, writeExpression); + } + + template + void WriteUnboxWeakValue(ITypeInfo* type, const T& writeExpression) + { + cppcodegen::WriteUnboxWeakValue(config, writer, type, writeExpression); + } + + void ConvertMultipleTypes(ITypeInfo** types, vint typesLength, Func writeExpression) + { + if (typesLength == 1) + { + writeExpression(); + } + else if (NeedConvertType(types[0], types[1])) + { + ConvertMultipleTypes(types + 1, typesLength - 1, [&]() + { + auto fromType = types[0]; + auto toType = types[1]; + ConvertType(config, writer, fromType, toType, writeExpression, false); + }); + } + else + { + return ConvertMultipleTypes(types + 1, typesLength - 1, writeExpression); + } + } + + void Call(Ptr node, ITypeInfo* expectedType = nullptr, bool useReturnValue = true) + { + GenerateExpression(config, writer, node, expectedType, useReturnValue); + } + + Ptr GetClosureInfo(WfExpression* node, Ptr testCtorArgumentSymbol = nullptr) + { + Ptr closureInfo; + auto scope = config->manager->nodeScopes[node].Obj(); + + if (dynamic_cast(node)) + { + scope = scope->parentScope.Obj(); + } + + while (scope) + { + if (scope->functionConfig && scope->functionConfig->lambda) + { + auto source = scope->ownerNodeSource ? scope->ownerNodeSource : scope->ownerNode.Obj(); + if (auto ordered = dynamic_cast(source)) + { + closureInfo = config->closureInfos[ordered]; + break; + } + else if (auto funcExpr = dynamic_cast(source)) + { + closureInfo = config->closureInfos[funcExpr]; + break; + } + else if (auto classExpr = dynamic_cast(source)) + { + closureInfo = config->closureInfos[classExpr]; + break; + } + } + else if (auto classExpr = scope->ownerNode.Cast()) + { + auto info = config->closureInfos[classExpr.Obj()]; + if (info->ctorArgumentSymbols.Values().Contains(testCtorArgumentSymbol.Obj())) + { + closureInfo = info; + break; + } + } + scope = scope->parentScope.Obj(); + } + + return closureInfo; + } + + void WriteNotExists(ITypeDescriptor* typeDescriptor) + { + writer.WriteString(L"/* NOT EXISTS: type("); + writer.WriteString(typeDescriptor->GetTypeName()); + writer.WriteString(L") */ __vwsn_not_exists__"); + } + + void WriteNotExists(IMethodInfo* methodInfo) + { + writer.WriteString(L"/* NOT EXISTS: method("); + writer.WriteString(methodInfo->GetName()); + writer.WriteString(L") of type ("); + writer.WriteString(methodInfo->GetOwnerTypeDescriptor()->GetTypeName()); + writer.WriteString(L") */ __vwsn_not_exists__"); + } + + void WriteNotExists(IPropertyInfo* propertyInfo) + { + writer.WriteString(L"/* NOT EXISTS: property("); + writer.WriteString(propertyInfo->GetName()); + writer.WriteString(L") of type ("); + writer.WriteString(propertyInfo->GetOwnerTypeDescriptor()->GetTypeName()); + writer.WriteString(L") */ __vwsn_not_exists__"); + } + + void WriteNotExists(IEventInfo* eventInfo) + { + writer.WriteString(L"/* NOT EXISTS: event("); + writer.WriteString(eventInfo->GetName()); + writer.WriteString(L") of type ("); + writer.WriteString(eventInfo->GetOwnerTypeDescriptor()->GetTypeName()); + writer.WriteString(L") */ __vwsn_not_exists__"); + } + + template + void WriteTemplate(const WString& templateValue, const T& callback) + { + List> matches; + config->regexTemplate.Cut(templateValue, false, matches); + FOREACH(Ptr, match, matches) + { + WString item = match->Result().Value(); + if (match->Success()) + { + if (!callback(item)) + { + writer.WriteString(L"/* NOT EXISTS: "); + writer.WriteString(item); + writer.WriteString(L" */ __vwsn_not_exists__"); + } + } + else + { + writer.WriteString(item); + } + } + } + + void VisitThisExpression(WfExpression* node, ITypeDescriptor* td) + { + if (auto closureInfo = GetClosureInfo(node)) + { + FOREACH_INDEXER(ITypeDescriptor*, thisType, index, closureInfo->thisTypes) + { + if (thisType->CanConvertTo(td)) + { + writer.WriteString(L"__vwsnthis_"); + writer.WriteString(itow(index)); + return; + } + } + } + writer.WriteString(L"this"); + } + + void VisitSymbol(WfExpression* node, Ptr symbol, bool forLambdaArgument) + { + if (auto varDecl = symbol->creatorNode.Cast()) + { + auto ownerNode = symbol->ownerScope->ownerNode; + if (ownerNode.Cast() || ownerNode.Cast()) + { + writer.WriteString(L"GLOBAL_NAME "); + writer.WriteString(config->ConvertName(symbol->name)); + return; + } + else if(auto closureInfo = GetClosureInfo(node, (forLambdaArgument ? nullptr : symbol))) + { + if (closureInfo->symbols.Values().Contains(symbol.Obj())) + { + writer.WriteString(L"this->"); + writer.WriteString(config->ConvertName(symbol->name)); + return; + } + else if (closureInfo->ctorArgumentSymbols.Values().Contains(symbol.Obj())) + { + writer.WriteString(L"__vwsnctor_"); + writer.WriteString(config->ConvertName(symbol->name)); + return; + } + } + writer.WriteString(config->ConvertName(symbol->name)); + return; + } + else if (auto funcDecl = symbol->creatorNode.Cast()) + { + auto ownerNode = symbol->ownerScope->ownerNode; + if (ownerNode.Cast() || ownerNode.Cast()) + { + writer.WriteString(config->ConvertType(symbol->typeInfo.Obj())); + writer.WriteString(L"(GLOBAL_OBJ, &GLOBAL_SYMBOL "); + writer.WriteString(config->ConvertName(symbol->name)); + writer.WriteString(L")"); + return; + } + else if (auto classExpr = ownerNode.Cast()) + { + writer.WriteString(config->ConvertType(symbol->typeInfo.Obj())); + writer.WriteString(L"(this, &"); + writer.WriteString(config->classExprs[classExpr.Obj()]); + writer.WriteString(L"::"); + writer.WriteString(config->ConvertName(symbol->name)); + writer.WriteString(L")"); + return; + } + else if (symbol->ownerScope->functionConfig && symbol->ownerScope->functionConfig->lambda && symbol->name == funcDecl->name.value) + { + auto scope = config->manager->nodeScopes[funcDecl.Obj()]; + auto closureInfo = config->closureInfos[dynamic_cast(scope->ownerNodeSource)]; + + writer.WriteString(L"LAMBDA(::"); + writer.WriteString(config->assemblyNamespace); + writer.WriteString(L"::"); + writer.WriteString(closureInfo->lambdaClassName); + writer.WriteString(L"("); + + FOREACH_INDEXER(WString, symbolName, index, closureInfo->symbols.Keys()) + { + if (index > 0) + { + writer.WriteString(L", "); + } + writer.WriteString(config->ConvertName(symbol->name)); + } + + FOREACH_INDEXER(ITypeDescriptor*, thisType, index, closureInfo->thisTypes) + { + if (index > 0 || closureInfo->symbols.Count() > 0) + { + writer.WriteString(L", "); + } + writer.WriteString(L" __vwsnctorthis_" + itow(index)); + } + + writer.WriteString(L"))"); + return; + } + } + writer.WriteString(config->ConvertName(symbol->name)); + } + + enum class CommaPosition + { + Left, + Right, + No, + }; + + bool IsCppRefGenericType(ITypeInfo* type) + { + switch (type->GetHint()) + { + case TypeInfoHint::Array: + case TypeInfoHint::List: + case TypeInfoHint::SortedList: + case TypeInfoHint::ObservableList: + case TypeInfoHint::Dictionary: + return true; + default: + return false; + } + } + + template + void WriteReturnValue(ITypeInfo* type, const TReturnValue& returnValueCallback, bool castReturnValue) + { + if (castReturnValue) + { + if (IsCppRefGenericType(type) || type->GetHint() == TypeInfoHint::NativeCollectionReference) + { + writer.WriteString(L"::vl::__vwsn::UnboxCollection<"); + writer.WriteString(config->ConvertType(type->GetTypeDescriptor())); + writer.WriteString(L">("); + returnValueCallback(); + writer.WriteString(L")"); + return; + } + } + returnValueCallback(); + } + + template + void WriteInvokeTemplate(vint count, ITypeInfo* returnType, const TType& typeCallback, const TInvoke& invokeCallback, const TArgument& argumentCallback, TInfo* info, bool castReturnValue) + { + if (Range(0, count).Any([&](vint index) {return IsCppRefGenericType(typeCallback(index)); })) + { + writer.WriteString(L"[&]()->decltype(auto){"); + for (vint i = 0; i < count; i++) + { + auto type = typeCallback(i); + if (IsCppRefGenericType(type)) + { + writer.WriteString(L" auto __vwsn_temp_x"); + writer.WriteString(itow(i)); + writer.WriteString(L" = ::vl::__vwsn::Box("); + argumentCallback(info, i); + writer.WriteString(L"); "); + + switch (type->GetHint()) + { + case TypeInfoHint::Array: + writer.WriteString(L"::vl::collections::Array<"); + break; + case TypeInfoHint::List: + writer.WriteString(L"::vl::collections::List<"); + break; + case TypeInfoHint::SortedList: + writer.WriteString(L"::vl::collections::SortedList<"); + break; + case TypeInfoHint::ObservableList: + writer.WriteString(L"::vl::collections::ObservableList<"); + break; + case TypeInfoHint::Dictionary: + writer.WriteString(L"::vl::collections::Dictionary<"); + break; + default:; + } + + vint count = type->GetElementType()->GetGenericArgumentCount(); + for (vint i = 0; i < count; i++) + { + if (i > 0) writer.WriteString(L", "); + writer.WriteString(config->ConvertType(type->GetElementType()->GetGenericArgument(i))); + } + writer.WriteString(L"> __vwsn_temp_"); + writer.WriteString(itow(i)); + writer.WriteString(L"; ::vl::reflection::description::UnboxParameter(__vwsn_temp_x"); + writer.WriteString(itow(i)); + writer.WriteString(L", __vwsn_temp_"); + writer.WriteString(itow(i)); + writer.WriteString(L");"); + } + else + { + writer.WriteString(L" auto __vwsn_temp_"); + writer.WriteString(itow(i)); + writer.WriteString(L" = "); + argumentCallback(info, i); + writer.WriteString(L";"); + } + } + writer.WriteString(L" return "); + WriteReturnValue(returnType, [&]() { invokeCallback(true); }, castReturnValue); + writer.WriteString(L"; }()"); + } + else + { + WriteReturnValue(returnType, [&]() { invokeCallback(false); }, castReturnValue); + } + } + + template + void WriteMethodTemplate(const WString& templateValue, IMethodInfo* methodInfo, const TThis& thisCallback, const TArgument& argumentCallback, bool castReturnValue) + { + WriteInvokeTemplate(methodInfo->GetParameterCount(), methodInfo->GetReturn(), [&](vint index) { return methodInfo->GetParameter(index)->GetType(); }, + [&](bool useTemporaryArgument) + { + WriteTemplate(templateValue, [&](const WString& item) + { + auto cp = CommaPosition::No; + vint count = methodInfo->GetParameterCount(); + + if (item == L"$Type") + { + writer.WriteString(config->ConvertType(methodInfo->GetOwnerTypeDescriptor())); + return true; + } + else if (item == L"$Func") + { + writer.WriteString(config->ConvertFunctionType(methodInfo)); + return true; + } + else if (item == L"$Name") + { + writer.WriteString(config->ConvertName(methodInfo->GetName())); + return true; + } + else if (item == L"$This") + { + if (!methodInfo->IsStatic()) + { + return thisCallback(methodInfo); + } + } + else if (item == L"$Arguments") + { + if (count == 0) + { + return true; + } + } + else if (item == L", $Arguments") + { + if (count == 0) + { + return true; + } + cp = CommaPosition::Left; + } + else if (item == L"$Arguments, ") + { + if (count == 0) + { + return true; + } + cp = CommaPosition::Right; + } + else + { + return false; + } + + if (count > 0) + { + if (cp == CommaPosition::Left) writer.WriteString(L", "); + for (vint i = 0; i < count; i++) + { + if (i > 0) writer.WriteString(L", "); + if (useTemporaryArgument) + { + writer.WriteString(L"__vwsn_temp_"); + writer.WriteString(itow(i)); + } + else + { + argumentCallback(methodInfo, i); + } + } + if (cp == CommaPosition::Right) writer.WriteString(L", "); + } + return true; + }); + }, argumentCallback, methodInfo, castReturnValue); + } + + template + void WritePropertyTemplate(const WString& templateValue, IPropertyInfo* propertyInfo, const TThis& thisCallback, bool castReturnValue) + { + WriteReturnValue(propertyInfo->GetReturn(), + [&]() + { + WriteTemplate(templateValue, [&](const WString& item) + { + if (item == L"$Type") + { + writer.WriteString(config->ConvertType(propertyInfo->GetOwnerTypeDescriptor())); + return true; + } + else if (item == L"$Name") + { + writer.WriteString(config->ConvertName(propertyInfo->GetName())); + return true; + } + else if (item == L"$This") + { + return thisCallback(propertyInfo); + } + return false; + }); + }, castReturnValue); + } + + template + void WriteEventTemplate(const WString& templateValue, IEventInfo* eventInfo, const TThis& thisCallback, const THandler& handlerCallback, const TArgument& argumentCallback) + { + auto handlerType = eventInfo->GetHandlerType()->GetElementType(); + WriteInvokeTemplate(handlerType->GetGenericArgumentCount() - 1, handlerType->GetGenericArgument(0), [&](vint index) { return handlerType->GetGenericArgument(index + 1); }, + [&](bool useTemporaryArgument) + { + WriteTemplate(templateValue, [&](const WString& item) + { + auto cp = CommaPosition::No; + vint count = eventInfo->GetHandlerType()->GetElementType()->GetGenericArgumentCount() - 1; + + if (item == L"$Name") + { + writer.WriteString(config->ConvertName(eventInfo->GetName())); + return true; + } + else if (item == L"$This") + { + return thisCallback(eventInfo); + } + else if (item == L"$Handler") + { + return handlerCallback(eventInfo); + } + else if (item == L"$Arguments") + { + if (count == 0) + { + return true; + } + } + else if (item == L", $Arguments") + { + if (count == 0) + { + return true; + } + cp = CommaPosition::Left; + } + else if (item == L"$Arguments, ") + { + if (count == 0) + { + return true; + } + cp = CommaPosition::Right; + } + else + { + return false; + } + + if (count > 0) + { + if (cp == CommaPosition::Left) writer.WriteString(L", "); + for (vint i = 0; i < count; i++) + { + if (i > 0) writer.WriteString(L", "); + if (useTemporaryArgument) + { + writer.WriteString(L"__vwsn_temp_"); + writer.WriteString(itow(i)); + } + else + { + argumentCallback(eventInfo, i); + } + } + if (cp == CommaPosition::Right) writer.WriteString(L", "); + } + return true; + }); + }, argumentCallback, eventInfo, false); + } + + template + bool WriteReferenceTemplate(ResolveExpressionResult& result, const TMethodThis& methodThis, const TPropertyThis& propertyThis, bool castReturnValue) + { + if (result.methodInfo) + { + if (CppExists(result.methodInfo)) + { + auto methodInfo = result.methodInfo; + WriteMethodTemplate(CppGetClosureTemplate(methodInfo), methodInfo, methodThis, [&](IMethodInfo*, vint){}, castReturnValue); + } + else + { + WriteNotExists(result.methodInfo); + } + return true; + } + else if (result.propertyInfo) + { + if (CppExists(result.propertyInfo)) + { + if (result.propertyInfo->GetCpp() == nullptr && result.propertyInfo->GetGetter() != nullptr) + { + auto methodInfo = result.propertyInfo->GetGetter(); + WriteMethodTemplate(CppGetInvokeTemplate(methodInfo), methodInfo, methodThis, [&](IMethodInfo*, vint){}, castReturnValue); + } + else + { + auto templateValue = CppGetReferenceTemplate(result.propertyInfo); + auto propertyInfo = result.propertyInfo; + WritePropertyTemplate(CppGetReferenceTemplate(propertyInfo), propertyInfo, propertyThis, castReturnValue); + } + } + else + { + WriteNotExists(result.propertyInfo); + } + return true; + } + else + { + return false; + } + } + + void VisitReferenceExpression(WfExpression* node, const WString& name) + { + auto result = config->manager->expressionResolvings[node]; + bool success = WriteReferenceTemplate(result, + [&](IMethodInfo* methodInfo) + { + VisitThisExpression(node, methodInfo->GetOwnerTypeDescriptor()); + return true; + }, + [&](IPropertyInfo* propertyInfo) + { + auto isRef = (propertyInfo->GetOwnerTypeDescriptor()->GetTypeDescriptorFlags() & TypeDescriptorFlags::ReferenceType) != TypeDescriptorFlags::Undefined; + VisitThisExpression(node, propertyInfo->GetOwnerTypeDescriptor()); + return true; + }, useReturnValue); + + if (!success) + { + if (result.symbol) + { + VisitSymbol(node, result.symbol, false); + } + else + { + if ((result.type->GetTypeDescriptor()->GetTypeDescriptorFlags() & TypeDescriptorFlags::EnumType) != TypeDescriptorFlags::Undefined) + { + auto enumType = result.type->GetTypeDescriptor()->GetEnumType(); + Ptr enumValueType; + if (result.type->GetDecorator() == ITypeInfo::TypeDescriptor) + { + enumValueType = result.type; + } + else + { + enumValueType = MakePtr(result.type->GetTypeDescriptor(), TypeInfoHint::Normal); + } + vint index = enumType->IndexOfItem(name); + if (index != -1) + { + ITypeInfo* types[] = { enumValueType.Obj(),result.type.Obj() }; + ConvertMultipleTypes(types, (sizeof(types) / sizeof(*types)), [=]() + { + writer.WriteString(config->ConvertType(result.type->GetTypeDescriptor())); + writer.WriteString(L"::"); + writer.WriteString(name); + }); + return; + } + } + CHECK_FAIL(L"WfGenerateExpressionVisitor::VisitReferenceExpression(WfExpression*, const WString&)#Internal error, cannot find any record of this expression."); + } + } + } + + void WriteClosureArguments(Ptr closureInfo, WfExpression* node) + { + vint index = 0; + + FOREACH(Ptr, symbol, From(closureInfo->symbols.Values()).Union(closureInfo->ctorArgumentSymbols.Values())) + { + if (index++ > 0) + { + writer.WriteString(L", "); + } + VisitSymbol(node, symbol, true); + } + + FOREACH(ITypeDescriptor*, thisType, closureInfo->thisTypes) + { + if (index++ > 0) + { + writer.WriteString(L", "); + } + VisitThisExpression(node, thisType); + } + } + + void Visit(WfThisExpression* node)override + { + auto result = config->manager->expressionResolvings[node]; + VisitThisExpression(node, result.type->GetTypeDescriptor()); + } + + void Visit(WfTopQualifiedExpression* node)override + { + VisitReferenceExpression(node, node->name.value); + } + + void Visit(WfReferenceExpression* node)override + { + VisitReferenceExpression(node, node->name.value); + } + + void Visit(WfOrderedNameExpression* node)override + { + VisitReferenceExpression(node, node->name.value); + } + + void Visit(WfOrderedLambdaExpression* node)override + { + writer.WriteString(L"LAMBDA(::"); + writer.WriteString(config->assemblyNamespace); + writer.WriteString(L"::"); + writer.WriteString(config->lambdaExprs[node]); + writer.WriteString(L"("); + + auto closureInfo = config->closureInfos[node]; + WriteClosureArguments(closureInfo, node); + + writer.WriteString(L"))"); + } + + void Visit(WfMemberExpression* node)override + { + auto result = config->manager->expressionResolvings[node]; + auto parentResult = config->manager->expressionResolvings[node->parent.Obj()]; + WriteReferenceTemplate(result, + [&](IMethodInfo* methodInfo) + { + writer.WriteString(L"::vl::__vwsn::This("); + Call(node->parent); + if (parentResult.type->GetDecorator() == ITypeInfo::SharedPtr) + { + writer.WriteString(L".Obj()"); + } + writer.WriteString(L")"); + return true; + }, + [&](IPropertyInfo* propertyInfo) + { + auto isRef = (propertyInfo->GetOwnerTypeDescriptor()->GetTypeDescriptorFlags() & TypeDescriptorFlags::ReferenceType) != TypeDescriptorFlags::Undefined; + if (isRef) writer.WriteString(L"::vl::__vwsn::This("); + Call(node->parent); + if (parentResult.type->GetDecorator() == ITypeInfo::SharedPtr) + { + writer.WriteString(L".Obj()"); + } + else if (parentResult.type->GetDecorator() == ITypeInfo::Nullable) + { + writer.WriteString(L".Value()"); + } + if (isRef) writer.WriteString(L")"); + return true; + }, useReturnValue); + } + + void Visit(WfChildExpression* node)override + { + VisitReferenceExpression(node, node->name.value); + } + + void Visit(WfLiteralExpression* node)override + { + switch (node->value) + { + case WfLiteralValue::Null: + { + auto result = config->manager->expressionResolvings[node]; + switch (result.type->GetDecorator()) + { + case ITypeInfo::Nullable: + case ITypeInfo::SharedPtr: + writer.WriteString(config->ConvertType(result.type.Obj())); + writer.WriteString(L"()"); + break; + case ITypeInfo::TypeDescriptor: + writer.WriteString(L"::vl::reflection::description::Value()"); + break; + default: + writer.WriteString(L"static_cast<"); + writer.WriteString(config->ConvertType(result.type.Obj())); + writer.WriteString(L">(nullptr)"); + } + } + break; + case WfLiteralValue::True: + writer.WriteString(L"true"); + break; + case WfLiteralValue::False: + writer.WriteString(L"false"); + break; + } + } + + void Visit(WfFloatingExpression* node)override + { + auto result = config->manager->expressionResolvings[node]; + auto td = result.type->GetTypeDescriptor(); + + writer.WriteString(L"static_cast<"); + writer.WriteString(config->ConvertType(td)); + writer.WriteString(L">("); + if (td == description::GetTypeDescriptor()) + { + writer.WriteString(node->value.value + L"f"); + } + else + { + writer.WriteString(node->value.value); + } + writer.WriteString(L")"); + } + + void Visit(WfIntegerExpression* node)override + { + auto result = config->manager->expressionResolvings[node]; + auto td = result.type->GetTypeDescriptor(); + + writer.WriteString(L"static_cast<"); + writer.WriteString(config->ConvertType(td)); + writer.WriteString(L">("); + if (td == description::GetTypeDescriptor()) + { + writer.WriteString(node->value.value + L"U"); + } + else if (td == description::GetTypeDescriptor()) + { + writer.WriteString(node->value.value + L"L"); + } + else if (td == description::GetTypeDescriptor()) + { + writer.WriteString(node->value.value + L"UL"); + } + else + { + writer.WriteString(node->value.value); + } + writer.WriteString(L")"); + } + + void Visit(WfStringExpression* node)override + { + writer.WriteString(L"::vl::WString(L\""); + for (vint i = 0; i < node->value.value.Length(); i++) + { + auto c = node->value.value[i]; + switch (c) + { + case L'\'': writer.WriteString(L"\\\'"); break; + case L'\"': writer.WriteString(L"\\\""); break; + case L'\r': writer.WriteString(L"\\r"); break; + case L'\n': writer.WriteString(L"\\n"); break; + case L'\t': writer.WriteString(L"\\t"); break; + default: writer.WriteChar(c); + } + } + writer.WriteString(L"\", false)"); + } + + void Visit(WfUnaryExpression* node)override + { + auto result = config->manager->expressionResolvings[node]; + switch (node->op) + { + case WfUnaryOperator::Positive: + writer.WriteString(L"(+ "); + Call(node->operand, result.type.Obj()); + writer.WriteString(L")"); + break; + case WfUnaryOperator::Negative: + writer.WriteString(L"(- "); + Call(node->operand, result.type.Obj()); + writer.WriteString(L")"); + break; + case WfUnaryOperator::Not: + { + if (result.type->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + writer.WriteString(L"(! "); + } + else + { + if (BinaryNeedConvert(result.type->GetTypeDescriptor())) + { + writer.WriteString(L"static_cast<"); + writer.WriteString(config->ConvertType(result.type->GetTypeDescriptor())); + writer.WriteString(L">"); + } + writer.WriteString(L"(~ "); + } + Call(node->operand, result.type.Obj()); + writer.WriteString(L")"); + } + break; + } + } + + void VisitBinaryExpression(WfBinaryExpression* node, const wchar_t* op, ITypeDescriptor* resultType, ITypeInfo* operandType) + { + if (resultType) + { + writer.WriteString(L"static_cast<"); + writer.WriteString(config->ConvertType(resultType)); + writer.WriteString(L">"); + } + writer.WriteString(L"("); + Call(node->first, operandType); + writer.WriteString(L" "); + writer.WriteString(op); + writer.WriteString(L" "); + Call(node->second, operandType); + writer.WriteString(L")"); + } + + bool BinaryNeedConvert(ITypeDescriptor* type) + { + return type == description::GetTypeDescriptor() + || type == description::GetTypeDescriptor() + || type == description::GetTypeDescriptor() + || type == description::GetTypeDescriptor() + ; + } + + void Visit(WfBinaryExpression* node)override + { + if (node->op == WfBinaryOperator::Assign) + { + auto result = config->manager->expressionResolvings[node->first.Obj()]; + if (result.propertyInfo) + { + auto propInfo = result.propertyInfo; + auto member = node->first.Cast(); + + if (CppExists(propInfo)) + { + if (propInfo->GetCpp() == nullptr && propInfo->GetSetter() != nullptr) + { + WriteMethodTemplate(CppGetInvokeTemplate(propInfo->GetSetter()), propInfo->GetSetter(), + [&](IMethodInfo*) + { + if (member) + { + writer.WriteString(L"::vl::__vwsn::This("); + Call(member->parent); + auto parentResult = config->manager->expressionResolvings[member->parent.Obj()]; + if (parentResult.type->GetDecorator() == ITypeInfo::SharedPtr) + { + writer.WriteString(L".Obj()"); + } + writer.WriteString(L")"); + } + else + { + VisitThisExpression(node->first.Obj(), propInfo->GetOwnerTypeDescriptor()); + } + return true; + }, + [&](IMethodInfo*, vint index) + { + Call(node->second); + }, useReturnValue); + } + else + { + writer.WriteString(L"("); + WritePropertyTemplate(CppGetReferenceTemplate(propInfo), propInfo, + [&](IPropertyInfo*) + { + if (member) + { + writer.WriteString(L"::vl::__vwsn::This("); + Call(member->parent); + auto parentResult = config->manager->expressionResolvings[member->parent.Obj()]; + if (parentResult.type->GetDecorator() == ITypeInfo::SharedPtr) + { + writer.WriteString(L".Obj()"); + } + writer.WriteString(L")"); + } + else + { + VisitThisExpression(node->first.Obj(), propInfo->GetOwnerTypeDescriptor()); + } + return true; + }, true); + writer.WriteString(L" = "); + Call(node->second, propInfo->GetReturn()); + writer.WriteString(L")"); + } + } + else + { + WriteNotExists(propInfo); + } + } + else if (auto binary = node->first.Cast()) + { + auto containerType = config->manager->expressionResolvings[binary->first.Obj()].type.Obj(); + if (IsCppRefGenericType(containerType)) + { + Call(binary->first, nullptr, false); + writer.WriteString(L".Set("); + Call(binary->second); + writer.WriteString(L", "); + Call(node->second); + writer.WriteString(L")"); + } + else + { + auto keyType = config->manager->expressionResolvings[binary->second.Obj()].type.Obj(); + auto valueType = config->manager->expressionResolvings[node->second.Obj()].type.Obj(); + writer.WriteString(L"::vl::__vwsn::This("); + Call(binary->first); + writer.WriteString(L".Obj())->Set("); + if (containerType->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + WriteBoxValue(keyType, [&]() {Call(binary->second); }); + } + else + { + Call(binary->second); + } + writer.WriteString(L", "); + WriteBoxValue(valueType, [&]() {Call(node->second); }); + writer.WriteString(L")"); + } + } + else + { + VisitBinaryExpression(node, L"=", nullptr, nullptr); + } + } + else if (node->op == WfBinaryOperator::Index) + { + auto containerType = config->manager->expressionResolvings[node->first.Obj()].type.Obj(); + if (IsCppRefGenericType(containerType)) + { + Call(node->first, nullptr, false); + writer.WriteString(L"["); + Call(node->second); + writer.WriteString(L"]"); + } + else + { + auto keyType = config->manager->expressionResolvings[node->second.Obj()].type.Obj(); + auto valueType = config->manager->expressionResolvings[node].type.Obj(); + WriteUnboxValue(valueType, [&]() + { + writer.WriteString(L"::vl::__vwsn::This("); + Call(node->first); + writer.WriteString(L".Obj())->Get("); + if (containerType->GetTypeDescriptor()->CanConvertTo(description::GetTypeDescriptor())) + { + WriteBoxValue(keyType, [&]() {Call(node->second); }); + } + else + { + Call(node->second); + } + writer.WriteString(L")"); + }); + } + } + else if (node->op == WfBinaryOperator::Union) + { + auto type = config->manager->expressionResolvings[node].type; + if (type->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + VisitBinaryExpression(node, L"+", nullptr, type.Obj()); + } + else + { + VisitBinaryExpression(node, L"&", nullptr, nullptr); + } + } + else if (node->op == WfBinaryOperator::Intersect) + { + VisitBinaryExpression(node, L"|", nullptr, nullptr); + } + else if (node->op == WfBinaryOperator::FailedThen) + { + auto firstResult = config->manager->expressionResolvings[node->first.Obj()]; + auto secondResult = config->manager->expressionResolvings[node->second.Obj()]; + auto mergedType = GetMergedType(firstResult.type, secondResult.type); + + writer.WriteString(L"[&](){ try{ return "); + Call(node->first, mergedType.Obj()); + writer.WriteString(L"; } catch(...){ return "); + Call(node->second, mergedType.Obj()); + writer.WriteString(L"; } }()"); + } + else + { + auto result = config->manager->expressionResolvings[node]; + auto firstResult = config->manager->expressionResolvings[node->first.Obj()]; + auto secondResult = config->manager->expressionResolvings[node->second.Obj()]; + auto mergedType = GetMergedType(firstResult.type, secondResult.type); + + switch (node->op) + { + case WfBinaryOperator::Exp: + writer.WriteString(L"static_cast<"); + writer.WriteString(config->ConvertType(result.type->GetTypeDescriptor())); + writer.WriteString(L">(pow(static_cast("); + Call(node->first); + writer.WriteString(L"), static_cast("); + Call(node->second); + writer.WriteString(L")))"); + return; + case WfBinaryOperator::Add: + case WfBinaryOperator::Sub: + case WfBinaryOperator::Mul: + case WfBinaryOperator::Div: + case WfBinaryOperator::Mod: + case WfBinaryOperator::Shl: + case WfBinaryOperator::Shr: + { + const wchar_t* op = nullptr; + switch (node->op) + { + case WfBinaryOperator::Add: op = L"+"; break; + case WfBinaryOperator::Sub: op = L"-"; break; + case WfBinaryOperator::Mul: op = L"*"; break; + case WfBinaryOperator::Div: op = L"/"; break; + case WfBinaryOperator::Mod: op = L"%"; break; + case WfBinaryOperator::Shl: op = L"<<"; break; + case WfBinaryOperator::Shr: op = L">>"; break; + default:; + } + VisitBinaryExpression(node, op, (BinaryNeedConvert(result.type->GetTypeDescriptor()) ? result.type->GetTypeDescriptor() : nullptr), result.type.Obj()); + } + return; + case WfBinaryOperator::EQ: + case WfBinaryOperator::NE: + { + if (firstResult.type->GetDecorator() == ITypeInfo::RawPtr || firstResult.type->GetDecorator() == ITypeInfo::SharedPtr) + { + auto td = mergedType->GetTypeDescriptor(); + auto tdFirst = firstResult.type->GetTypeDescriptor(); + auto tdSecond = secondResult.type->GetTypeDescriptor(); + auto dFirst = firstResult.type->GetDecorator(); + auto dSecond = secondResult.type->GetDecorator(); + + writer.WriteString(L"("); + + if (td != tdFirst) + { + writer.WriteString(L"static_cast<"); + writer.WriteString(config->ConvertType(tdFirst)); + writer.WriteString(L"*>("); + } + Call(node->first); + if (dFirst == ITypeInfo::SharedPtr) + { + writer.WriteString(L".Obj()"); + } + if (td != tdFirst) + { + writer.WriteString(L")"); + } + + if (node->op == WfBinaryOperator::EQ) + { + writer.WriteString(L" == "); + } + else + { + writer.WriteString(L" != "); + } + + if (td != tdSecond) + { + writer.WriteString(L"static_cast<"); + writer.WriteString(config->ConvertType(tdSecond)); + writer.WriteString(L"*>("); + } + Call(node->second); + if (dSecond == ITypeInfo::SharedPtr) + { + writer.WriteString(L".Obj()"); + } + if (td != tdSecond) + { + writer.WriteString(L")"); + } + + writer.WriteString(L")"); + return; + } + } + case WfBinaryOperator::LT: + case WfBinaryOperator::GT: + case WfBinaryOperator::LE: + case WfBinaryOperator::GE: + { + const wchar_t* op = nullptr; + switch (node->op) + { + case WfBinaryOperator::LT: op = L"<"; break; + case WfBinaryOperator::GT: op = L">"; break; + case WfBinaryOperator::LE: op = L"<="; break; + case WfBinaryOperator::GE: op = L">="; break; + case WfBinaryOperator::EQ: op = L"=="; break; + case WfBinaryOperator::NE: op = L"!="; break; + default:; + } + VisitBinaryExpression(node, op, nullptr, mergedType.Obj()); + } + return; + case WfBinaryOperator::Xor: + case WfBinaryOperator::And: + case WfBinaryOperator::Or: + { + auto td = result.type->GetTypeDescriptor(); + const wchar_t* op = nullptr; + if (td == description::GetTypeDescriptor()) + { + switch (node->op) + { + case WfBinaryOperator::Xor: op = L"^"; break; + case WfBinaryOperator::And: op = L"&&"; break; + case WfBinaryOperator::Or: op = L"||"; break; + default:; + } + if (node->op != WfBinaryOperator::Xor) + { + td = nullptr; + } + } + else + { + switch (node->op) + { + case WfBinaryOperator::Xor: op = L"^"; break; + case WfBinaryOperator::And: op = L"&"; break; + case WfBinaryOperator::Or: op = L"|"; break; + default:; + } + if (!BinaryNeedConvert(td)) + { + td = nullptr; + } + } + VisitBinaryExpression(node, op, td, result.type.Obj()); + } + return; + default:; + } + } + } + + void Visit(WfLetExpression* node)override + { + auto scope = config->manager->nodeScopes[node]; + writer.WriteString(L"[&]("); + FOREACH_INDEXER(Ptr, letVar, index, node->variables) + { + if (index > 0) + { + writer.WriteString(L", "); + } + writer.WriteString(L"auto "); + writer.WriteString(config->ConvertName(letVar->name.value)); + } + writer.WriteString(L"){ return "); + Call(node->expression); + writer.WriteString(L"; }("); + FOREACH_INDEXER(Ptr, letVar, index, node->variables) + { + if (index > 0) + { + writer.WriteString(L", "); + } + auto symbol = scope->symbols[letVar->name.value][0]; + Call(letVar->value, symbol->typeInfo.Obj()); + } + writer.WriteString(L")"); + } + + void Visit(WfIfExpression* node)override + { + auto firstResult = config->manager->expressionResolvings[node->trueBranch.Obj()]; + auto secondResult = config->manager->expressionResolvings[node->falseBranch.Obj()]; + auto mergedType = GetMergedType(firstResult.type, secondResult.type); + + writer.WriteString(L"("); + Call(node->condition); + writer.WriteString(L" ? "); + Call(node->trueBranch, mergedType.Obj()); + writer.WriteString(L" : "); + Call(node->falseBranch, mergedType.Obj()); + writer.WriteString(L")"); + } + + void Visit(WfRangeExpression* node)override + { + auto result = config->manager->expressionResolvings[node]; + auto elementType = result.type->GetElementType()->GetGenericArgument(0); + + writer.WriteString(L"::vl::__vwsn::Range("); + Call(node->begin, elementType); + if (node->beginBoundary == WfRangeBoundary::Exclusive) + { + writer.WriteString(L" + 1"); + } + writer.WriteString(L", "); + Call(node->end, elementType); + if (node->endBoundary == WfRangeBoundary::Inclusive) + { + writer.WriteString(L" + 1"); + } + writer.WriteString(L")"); + } + + void Visit(WfSetTestingExpression* node)override + { + if (auto range = node->collection.Cast()) + { + auto resultElement = config->manager->expressionResolvings[node->element.Obj()]; + auto resultBegin = config->manager->expressionResolvings[range->begin.Obj()]; + auto resultEnd = config->manager->expressionResolvings[range->end.Obj()]; + + writer.WriteString(L"[&](auto __vwsn_1){ return "); + if (node->test == WfSetTesting::NotIn) + { + writer.WriteString(L"!"); + } + writer.WriteString(L"("); + + Call(range->begin); + writer.WriteString(range->beginBoundary == WfRangeBoundary::Inclusive ? L" <= " : L" < "); + writer.WriteString(L" __vwsn_1 && __vwsn_1"); + writer.WriteString(range->endBoundary == WfRangeBoundary::Inclusive ? L" <= " : L" < "); + Call(range->end); + + writer.WriteString(L"); }("); + Call(node->element, resultElement.type.Obj()); + writer.WriteString(L")"); + } + else + { + auto result = config->manager->expressionResolvings[node->collection.Obj()]; + auto elementType = result.type->GetElementType()->GetGenericArgument(0); + + if (node->test == WfSetTesting::NotIn) + { + writer.WriteString(L"(! "); + } + + writer.WriteString(L"::vl::__vwsn::InSet("); + Call(node->element, elementType); + writer.WriteString(L", "); + Call(node->collection); + writer.WriteString(L")"); + + if (node->test == WfSetTesting::NotIn) + { + writer.WriteString(L")"); + } + } + } + + void Visit(WfConstructorExpression* node)override + { + auto result = config->manager->expressionResolvings[node]; + auto td = result.type->GetTypeDescriptor(); + if (node->arguments.Count() == 0) + { + if ((td->GetTypeDescriptorFlags() & TypeDescriptorFlags::StructType) != TypeDescriptorFlags::Undefined) + { + writer.WriteString(config->ConvertType(result.type.Obj()) + L"{}"); + } + else + { + writer.WriteString(config->ConvertType(td) + L"::Create()"); + } + } + else + { + if (result.type->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + auto elementType = result.type->GetElementType()->GetGenericArgument(0); + writer.WriteString(L"(::vl::__vwsn::CreateList()"); + + FOREACH(Ptr, argument, node->arguments) + { + writer.WriteString(L".Add("); + Call(argument->key); + writer.WriteString(L")"); + } + + writer.WriteString(L").list"); + } + else if (result.type->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + auto elementType = result.type->GetElementType()->GetGenericArgument(0); + writer.WriteString(L"(::vl::__vwsn::CreateObservableList()"); + + FOREACH(Ptr, argument, node->arguments) + { + writer.WriteString(L".Add("); + Call(argument->key); + writer.WriteString(L")"); + } + + writer.WriteString(L").list"); + } + else if (result.type->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + auto keyType = result.type->GetElementType()->GetGenericArgument(0); + auto valueType = result.type->GetElementType()->GetGenericArgument(1); + writer.WriteString(L"(::vl::__vwsn::CreateDictionary()"); + + FOREACH(Ptr, argument, node->arguments) + { + writer.WriteString(L".Add("); + Call(argument->key); + writer.WriteString(L", "); + Call(argument->value); + writer.WriteString(L")"); + } + + writer.WriteString(L").dictionary"); + } + else + { + writer.WriteString(L"[&](){ "); + writer.WriteString(config->ConvertType(td)); + writer.WriteString(L" __vwsn_temp__;"); + + FOREACH(Ptr, argument, node->arguments) + { + writer.WriteString(L" __vwsn_temp__."); + writer.WriteString(argument->key.Cast()->name.value); + writer.WriteString(L" = "); + Call(argument->value); + writer.WriteString(L";"); + } + + writer.WriteString(L" return __vwsn_temp__; }()"); + } + } + } + + void Visit(WfInferExpression* node)override + { + Call(node->expression); + } + + void Visit(WfTypeCastingExpression* node)override + { + auto scope = config->manager->nodeScopes[node].Obj(); + auto typeInfo = CreateTypeInfoFromType(scope, node->type); + bool strongCast = node->strategy == WfTypeCastingStrategy::Strong; + auto result = config->manager->expressionResolvings[node->expression.Obj()]; + ConvertType(config, writer, result.type.Obj(), typeInfo.Obj(), [&]() {Call(node->expression); }, strongCast); + } + + void Visit(WfTypeTestingExpression* node)override + { + auto result = config->manager->expressionResolvings[node->expression.Obj()]; + Ptr type; + if (node->type) + { + auto scope = config->manager->nodeScopes[node].Obj(); + type = CreateTypeInfoFromType(scope, node->type); + } + + switch (result.type->GetDecorator()) + { + case ITypeInfo::RawPtr: + { + switch (node->test) + { + case WfTypeTesting::IsNull: + writer.WriteString(L"("); + Call(node->expression); + writer.WriteString(L" == nullptr)"); + break; + case WfTypeTesting::IsNotNull: + writer.WriteString(L"("); + Call(node->expression); + writer.WriteString(L" != nullptr)"); + break; + case WfTypeTesting::IsType: + case WfTypeTesting::IsNotType: + if (type->GetDecorator() != ITypeInfo::RawPtr) + { + writer.WriteString(node->test == WfTypeTesting::IsType ? L"false" : L"true"); + } + else + { + writer.WriteString(L"(::vl::__vwsn::RawPtrCast<"); + writer.WriteString(config->ConvertType(type->GetTypeDescriptor())); + writer.WriteString(L">("); + Call(node->expression); + writer.WriteString(L") "); + writer.WriteString(node->test == WfTypeTesting::IsType ? L"!=" : L"=="); + writer.WriteString(L" nullptr)"); + } + break; + } + } + break; + case ITypeInfo::SharedPtr: + { + if (result.type->GetElementType()->GetDecorator() == ITypeInfo::Generic) + { + auto toCode = [&]() + { + stream::MemoryStream stream; + { + stream::StreamWriter writer(stream); + WfPrint(node, WString::Empty, writer); + } + stream.SeekFromBegin(0); + { + stream::StreamReader reader(stream); + return reader.ReadToEnd(); + } + }; + + if (config->IsSpecialGenericType(result.type.Obj())) + { + writer.WriteString(L"/* NOT SUPPORTS: testing against non-reference generic type: "); + writer.WriteString(toCode()); + writer.WriteString(L" */ __vwsn_not_exists__"); + return; + } + } + switch (node->test) + { + case WfTypeTesting::IsNull: + writer.WriteString(L"(! static_cast("); + Call(node->expression); + writer.WriteString(L"))"); + break; + case WfTypeTesting::IsNotNull: + writer.WriteString(L"static_cast("); + Call(node->expression); + writer.WriteString(L")"); + break; + case WfTypeTesting::IsType: + case WfTypeTesting::IsNotType: + if (type->GetDecorator() != ITypeInfo::SharedPtr) + { + writer.WriteString(node->test == WfTypeTesting::IsType ? L"false" : L"true"); + } + else + { + writer.WriteString(L"(::vl::__vwsn::RawPtrCast<"); + writer.WriteString(config->ConvertType(type->GetTypeDescriptor())); + writer.WriteString(L">("); + Call(node->expression); + writer.WriteString(L".Obj()) "); + writer.WriteString(node->test == WfTypeTesting::IsType ? L"!=" : L"=="); + writer.WriteString(L" nullptr)"); + } + break; + } + } + break; + case ITypeInfo::Nullable: + { + switch (node->test) + { + case WfTypeTesting::IsNull: + writer.WriteString(L"(! static_cast("); + Call(node->expression); + writer.WriteString(L"))"); + break; + case WfTypeTesting::IsNotNull: + writer.WriteString(L"static_cast("); + Call(node->expression); + writer.WriteString(L")"); + break; + case WfTypeTesting::IsType: + if (type->GetTypeDescriptor() == result.type->GetTypeDescriptor()) + { + writer.WriteString(L"static_cast("); + Call(node->expression); + writer.WriteString(L")"); + } + else + { + writer.WriteString(L"false"); + } + break; + case WfTypeTesting::IsNotType: + if (type->GetTypeDescriptor() == result.type->GetTypeDescriptor()) + { + writer.WriteString(L"false"); + } + else + { + writer.WriteString(L"true"); + } + break; + } + } + break; + case ITypeInfo::TypeDescriptor: + { + if (result.type->GetTypeDescriptor()->GetTypeDescriptorFlags() == TypeDescriptorFlags::Object) + { + switch (node->test) + { + case WfTypeTesting::IsNull: + Call(node->expression); + writer.WriteString(L".IsNull()"); + break; + case WfTypeTesting::IsNotNull: + writer.WriteString(L"(! "); + Call(node->expression); + writer.WriteString(L".IsNull())"); + break; + case WfTypeTesting::IsType: + case WfTypeTesting::IsNotType: + if ((type->GetTypeDescriptor()->GetTypeDescriptorFlags() & TypeDescriptorFlags::ReferenceType) != TypeDescriptorFlags::Undefined) + { + writer.WriteString(L"[&](){ auto __vwsn_temp__ = "); + Call(node->expression); + writer.WriteString(L"; return "); + if ((type->GetDecorator() == ITypeInfo::RawPtr) == (node->test == WfTypeTesting::IsType)) + { + writer.WriteString(L"!"); + } + writer.WriteString(L"__vwsn_temp__.GetSharedPtr() "); + writer.WriteString(node->test == WfTypeTesting::IsType ? L"&&" : L"||"); + writer.WriteString(L" ::vl::__vwsn::RawPtrCast<"); + writer.WriteString(config->ConvertType(type->GetTypeDescriptor())); + writer.WriteString(L">(__vwsn_temp__.GetRawPtr()) "); + writer.WriteString(node->test == WfTypeTesting::IsType ? L"!=" : L"=="); + writer.WriteString(L" nullptr; }()"); + } + else + { + writer.WriteString(L"(dynamic_cast<::vl::reflection::description::IValueType::TypedBox<"); + writer.WriteString(config->ConvertType(type->GetTypeDescriptor())); + writer.WriteString(L">*>("); + Call(node->expression); + writer.WriteString(L".GetBoxedValue().Obj()) "); + writer.WriteString(node->test == WfTypeTesting::IsType ? L"!=" : L"=="); + writer.WriteString(L" nullptr)"); + } + break; + } + } + else if ((type->GetTypeDescriptor() == result.type->GetTypeDescriptor()) == (node->test == WfTypeTesting::IsType)) + { + writer.WriteString(L"true"); + } + else + { + writer.WriteString(L"false"); + } + } + break; + default:; + } + } + + void Visit(WfTypeOfTypeExpression* node)override + { + writer.WriteString(L"/* NOT SUPPORTS: typeof() */ __vwsn_not_exists__"); + } + + void Visit(WfTypeOfExpressionExpression* node)override + { + writer.WriteString(L"/* NOT SUPPORTS: type() */ __vwsn_not_exists__"); + } + + void Visit(WfAttachEventExpression* node)override + { + auto result = config->manager->expressionResolvings[node->event.Obj()]; + if (CppExists(result.eventInfo)) + { + WriteEventTemplate(CppGetAttachTemplate(result.eventInfo), result.eventInfo, + [&](IEventInfo*) + { + writer.WriteString(L"::vl::__vwsn::This("); + if (auto member = node->event.Cast()) + { + Call(member->parent); + auto parentResult = config->manager->expressionResolvings[member->parent.Obj()]; + if (parentResult.type->GetDecorator() == ITypeInfo::SharedPtr) + { + writer.WriteString(L".Obj()"); + } + } + else + { + VisitThisExpression(node, result.eventInfo->GetOwnerTypeDescriptor()); + } + writer.WriteString(L")"); + return true; + }, + [&](IEventInfo*) + { + Call(node->function); + return true; + }, + [&](IEventInfo*, vint) {}); + } + else + { + WriteNotExists(result.eventInfo); + } + } + + void Visit(WfDetachEventExpression* node)override + { + auto result = config->manager->expressionResolvings[node->event.Obj()]; + if (CppExists(result.eventInfo)) + { + WriteEventTemplate(CppGetDetachTemplate(result.eventInfo), result.eventInfo, + [&](IEventInfo* eventInfo) + { + writer.WriteString(L"::vl::__vwsn::This("); + if (auto member = node->event.Cast()) + { + Call(member->parent); + auto parentResult = config->manager->expressionResolvings[member->parent.Obj()]; + if (parentResult.type->GetDecorator() == ITypeInfo::SharedPtr) + { + writer.WriteString(L".Obj()"); + } + } + else + { + VisitThisExpression(node, eventInfo->GetOwnerTypeDescriptor()); + } + writer.WriteString(L")"); + return true; + }, + [&](IEventInfo*) + { + Call(node->handler); + return true; + }, + [&](IEventInfo*, vint) {}); + } + else + { + WriteNotExists(result.eventInfo); + } + } + + void Visit(WfObserveExpression* node)override + { + } + + void Visit(WfCallExpression* node)override + { + auto thisCallback = [&](ITypeDescriptor* td) + { + if (auto member = node->function.Cast()) + { + writer.WriteString(L"::vl::__vwsn::This("); + Call(member->parent); + auto parentResult = config->manager->expressionResolvings[member->parent.Obj()]; + if (parentResult.type->GetDecorator() == ITypeInfo::SharedPtr) + { + writer.WriteString(L".Obj()"); + } + writer.WriteString(L")"); + } + else + { + VisitThisExpression(node, td); + } + return true; + }; + + auto argumentCallback = [&](IMethodInfo* methodInfo, ITypeInfo* typeInfo, vint index) + { + auto type = methodInfo + ? methodInfo->GetParameter(index)->GetType() + : typeInfo->GetElementType()->GetGenericArgument(index + 1) + ; + Call(node->arguments[index], type); + }; + + auto result = config->manager->expressionResolvings[node->function.Obj()]; + if (result.methodInfo) + { + WriteMethodTemplate(CppGetInvokeTemplate(result.methodInfo), result.methodInfo, + [&](IMethodInfo* methodInfo) { return thisCallback(methodInfo->GetOwnerTypeDescriptor()); }, + [&](IMethodInfo* methodInfo, vint index) { return argumentCallback(methodInfo, nullptr, index); }, + useReturnValue); + return; + } + else if (result.eventInfo) + { + WriteEventTemplate(CppGetInvokeTemplate(result.eventInfo), result.eventInfo, + [&](IEventInfo* eventInfo) { return thisCallback(eventInfo->GetOwnerTypeDescriptor()); }, + [&](IEventInfo*) { return false; }, + [&](IEventInfo* eventInfo, vint index) { return argumentCallback(nullptr, eventInfo->GetHandlerType(), index); } + ); + return; + } + else if (result.symbol) + { + if (auto funcDecl = result.symbol->creatorNode.Cast()) + { + if (result.symbol->ownerScope->ownerNode.Cast()) + { + writer.WriteString(L"this->"); + writer.WriteString(config->ConvertName(result.symbol->name)); + } + else if (result.symbol->ownerScope->functionConfig && result.symbol->ownerScope->functionConfig->lambda && result.symbol->name == funcDecl->name.value) + { + writer.WriteString(L"(*this)"); + } + else + { + writer.WriteString(L"GLOBAL_NAME "); + writer.WriteString(config->ConvertName(result.symbol->name)); + } + writer.WriteString(L"("); + for (vint i = 0; i < node->arguments.Count(); i++) + { + if (i > 0) writer.WriteString(L", "); + argumentCallback(nullptr, result.symbol->typeInfo.Obj(), i); + } + writer.WriteString(L")"); + return; + } + } + Call(node->function); + writer.WriteString(L"("); + for (vint i = 0; i < node->arguments.Count(); i++) + { + if (i > 0) writer.WriteString(L", "); + argumentCallback(nullptr, result.type.Obj(), i); + } + writer.WriteString(L")"); + } + + void Visit(WfFunctionExpression* node)override + { + writer.WriteString(L"LAMBDA(::"); + writer.WriteString(config->assemblyNamespace); + writer.WriteString(L"::"); + writer.WriteString(config->lambdaExprs[node]); + writer.WriteString(L"("); + + auto closureInfo = config->closureInfos[node]; + WriteClosureArguments(closureInfo, node); + + writer.WriteString(L"))"); + } + + void Visit(WfNewClassExpression* node)override + { + auto result = config->manager->expressionResolvings[node]; + auto ctor = result.constructorInfo; + + if (ctor->GetReturn()->GetDecorator() == ITypeInfo::SharedPtr) + { + writer.WriteString(L"::vl::Ptr<"); + writer.WriteString(config->ConvertType(ctor->GetReturn()->GetTypeDescriptor())); + writer.WriteString(L">("); + } + + WriteMethodTemplate(CppGetInvokeTemplate(ctor), ctor, [&](IMethodInfo*) { return false; }, + [&](IMethodInfo*, vint index) + { + Call(node->arguments[index]); + }, useReturnValue); + + if (ctor->GetReturn()->GetDecorator() == ITypeInfo::SharedPtr) + { + writer.WriteString(L")"); + } + } + + void Visit(WfNewInterfaceExpression* node)override + { + auto result = config->manager->expressionResolvings[node]; + auto ctor = result.constructorInfo; + + if (ctor->GetReturn()->GetDecorator() == ITypeInfo::SharedPtr) + { + writer.WriteString(L"::vl::Ptr<"); + writer.WriteString(config->ConvertType(ctor->GetReturn()->GetTypeDescriptor())); + writer.WriteString(L">("); + } + else + { + writer.WriteString(L"static_cast<"); + writer.WriteString(config->ConvertType(ctor->GetReturn()->GetTypeDescriptor())); + writer.WriteString(L"*>("); + } + + writer.WriteString(L"new ::"); + writer.WriteString(config->assemblyNamespace); + writer.WriteString(L"::"); + writer.WriteString(config->classExprs[node]); + writer.WriteString(L"("); + + auto closureInfo = config->closureInfos[node]; + WriteClosureArguments(closureInfo, node); + + writer.WriteString(L"))"); + } + + void Visit(WfVirtualExpression* node)override + { + Call(node->expandedExpression); + } + }; + + void GenerateExpression(WfCppConfig* config, stream::StreamWriter& writer, Ptr node, reflection::description::ITypeInfo* expectedType, bool useReturnValue) + { + WfGenerateExpressionVisitor visitor(config, writer, useReturnValue); + if (useReturnValue) + { + auto result = config->manager->expressionResolvings[node.Obj()]; + ITypeInfo* types[] = { result.type.Obj(), result.expectedType.Obj(), expectedType }; + visitor.ConvertMultipleTypes(types, sizeof(types) / sizeof(*types), [&]() + { + node->Accept(&visitor); + }); + } + else + { + node->Accept(&visitor); + } + } + } + } +} + + +/*********************************************************************** +.\CPP\WFCPP_FILE.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace cppcodegen + { + using namespace collections; + + void WfCppConfig::WritePushCompileOptions(stream::StreamWriter& writer) + { + writer.WriteLine(L"#if defined( _MSC_VER)"); + writer.WriteLine(L"#pragma warning(push)"); + writer.WriteLine(L"#pragma warning(disable:4250)"); + writer.WriteLine(L"#elif defined(__GNUC__)"); + writer.WriteLine(L"#pragma GCC diagnostic push"); + writer.WriteLine(L"#pragma GCC diagnostic ignored \"-Wparentheses-equality\""); + writer.WriteLine(L"#elif defined(__clang__)"); + writer.WriteLine(L"#pragma clang diagnostic push"); + writer.WriteLine(L"#pragma clang diagnostic ignored \"-Wparentheses-equality\""); + writer.WriteLine(L"#endif"); + } + + void WfCppConfig::WritePopCompileOptions(stream::StreamWriter& writer) + { + writer.WriteLine(L"#if defined( _MSC_VER)"); + writer.WriteLine(L"#pragma warning(pop)"); + writer.WriteLine(L"#elif defined(__GNUC__)"); + writer.WriteLine(L"#pragma GCC diagnostic pop"); + writer.WriteLine(L"#elif defined(__clang__)"); + writer.WriteLine(L"#pragma clang diagnostic pop"); + writer.WriteLine(L"#endif"); + } + + void WfCppConfig::WriteCpp_PushMacros(stream::StreamWriter& writer) + { + writer.WriteString(L"#define GLOBAL_SYMBOL "); + writer.WriteString(L"::"); + writer.WriteString(assemblyNamespace); + writer.WriteString(L"::"); + writer.WriteString(assemblyName); + writer.WriteLine(L"::"); + + writer.WriteString(L"#define GLOBAL_NAME "); + writer.WriteString(L"::"); + writer.WriteString(assemblyNamespace); + writer.WriteString(L"::"); + writer.WriteString(assemblyName); + writer.WriteLine(L"::Instance()."); + + writer.WriteString(L"#define GLOBAL_OBJ "); + writer.WriteString(L"&::"); + writer.WriteString(assemblyNamespace); + writer.WriteString(L"::"); + writer.WriteString(assemblyName); + writer.WriteLine(L"::Instance()"); + + writer.WriteLine(L"#define USERIMPL(...)"); + } + + void WfCppConfig::WriteCpp_PopMacros(stream::StreamWriter& writer) + { + writer.WriteLine(L"#undef GLOBAL_SYMBOL"); + writer.WriteLine(L"#undef GLOBAL_NAME"); + writer.WriteLine(L"#undef GLOBAL_OBJ"); + writer.WriteLine(L"#undef USERIMPL"); + } + + void WfCppConfig::WriteHeader(stream::StreamWriter& writer, bool multiFile) + { + WritePushCompileOptions(writer); + writer.WriteLine(L""); + + { + Dictionary> reversedLambdaExprs; + Dictionary> reversedClassExprs; + SortClosure(reversedLambdaExprs, reversedClassExprs); + + if (reversedLambdaExprs.Count() + reversedClassExprs.Count() > 0) + { + writer.WriteString(L"namespace "); + writer.WriteLine(assemblyNamespace); + writer.WriteLine(L"{"); + + FOREACH(Ptr, expr, reversedLambdaExprs.Values()) + { + WriteHeader_ClosurePreDecl(writer, expr); + } + + FOREACH(Ptr, expr, reversedClassExprs.Values()) + { + WriteHeader_ClosurePreDecl(writer, expr); + } + + writer.WriteLine(L"}"); + writer.WriteLine(L""); + } + } + + List nss; + + if (enumDecls.Keys().Contains(nullptr)) + { + FOREACH(Ptr, decl, enumDecls[nullptr]) + { + WriteHeader_Enum(writer, decl, nss); + writer.WriteLine(L""); + } + } + + if (structDecls.Keys().Contains(nullptr)) + { + FOREACH(Ptr, decl, structDecls[nullptr]) + { + WriteHeader_Struct(writer, decl, nss); + writer.WriteLine(L""); + } + } + + if (classDecls.Keys().Contains(nullptr)) + { + FOREACH(Ptr, decl, classDecls[nullptr]) + { + WriteHeader_ClassPreDecl(writer, decl, nss); + } + writer.WriteLine(L""); + if (multiFile) + { + vint index = topLevelClassDeclsForFiles.Keys().IndexOf(L""); + if (index != -1) + { + FOREACH(Ptr, decl, topLevelClassDeclsForFiles.GetByIndex(index)) + { + WriteHeader_TopLevelClass(writer, decl, nss); + writer.WriteLine(L""); + } + } + } + else + { + FOREACH(Ptr, decl, classDecls[nullptr]) + { + WriteHeader_TopLevelClass(writer, decl, nss); + writer.WriteLine(L""); + } + } + } + WriteNamespaceEnd(writer, nss); + + WriteHeader_Global(writer); + + writer.WriteLine(L""); + WritePopCompileOptions(writer); + } + + void WfCppConfig::WriteCpp(stream::StreamWriter& writer, bool multiFile) + { + WritePushCompileOptions(writer); + writer.WriteLine(L""); + WriteCpp_PushMacros(writer); + + writer.WriteLine(L""); + WriteCpp_Global(writer); + writer.WriteLine(L""); + + if (classDecls.Keys().Contains(nullptr)) + { + List nss; + + if (multiFile) + { + vint index = topLevelClassDeclsForFiles.Keys().IndexOf(L""); + if (index != -1) + { + FOREACH(Ptr, decl, topLevelClassDeclsForFiles.GetByIndex(index)) + { + WriteCpp_Class(writer, decl, nss); + } + } + } + else + { + FOREACH(Ptr, decl, classDecls[nullptr]) + { + WriteCpp_Class(writer, decl, nss); + } + } + + WriteNamespaceEnd(writer, nss); + } + + WriteCpp_PopMacros(writer); + + writer.WriteLine(L""); + WritePopCompileOptions(writer); + } + + void WfCppConfig::WriteSubHeader(stream::StreamWriter& writer, const WString& fileName) + { + WritePushCompileOptions(writer); + writer.WriteLine(L""); + List nss; + + FOREACH(Ptr, decl, topLevelClassDeclsForFiles.Get(fileName)) + { + WriteHeader_TopLevelClass(writer, decl, nss); + writer.WriteLine(L""); + } + + WriteNamespaceEnd(writer, nss); + WritePopCompileOptions(writer); + } + + void WfCppConfig::WriteSubCpp(stream::StreamWriter& writer, const WString& fileName) + { + WritePushCompileOptions(writer); + writer.WriteLine(L""); + WriteCpp_PushMacros(writer); + writer.WriteLine(L""); + List nss; + + FOREACH(Ptr, decl, topLevelClassDeclsForFiles.Get(fileName)) + { + WriteCpp_Class(writer, decl, nss); + } + + WriteNamespaceEnd(writer, nss); + WriteCpp_PopMacros(writer); + writer.WriteLine(L""); + WritePopCompileOptions(writer); + } + + void WfCppConfig::WriteReflectionHeader(stream::StreamWriter& writer, bool multiFile) + { + WritePushCompileOptions(writer); + if (manager->declarationTypes.Count() > 0) + { + writer.WriteLine(L""); + WriteHeader_Reflection(writer); + writer.WriteLine(L""); + } + WritePopCompileOptions(writer); + } + + void WfCppConfig::WriteReflectionCpp(stream::StreamWriter& writer, bool multiFile) + { + WritePushCompileOptions(writer); + if (manager->declarationTypes.Count() > 0) + { + writer.WriteLine(L""); + WriteCpp_Reflection(writer); + writer.WriteLine(L""); + } + WritePopCompileOptions(writer); + } + } + } +} + + +/*********************************************************************** +.\CPP\WFCPP_GENERATECPPFILES.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace cppcodegen + { + using namespace collections; + using namespace stream; + using namespace filesystem; + +/*********************************************************************** +WfCppInput +***********************************************************************/ + + WfCppInput::WfCppInput(const WString& _assemblyName) + { + headerGuardPrefix = L"VCZH_WORKFLOW_COMPILER_GENERATED_"; + assemblyName = _assemblyName; + assemblyNamespace = L"vl_workflow_global"; + includeFileName = _assemblyName + L"Includes"; + reflectionFileName = assemblyName + L"Reflection"; + defaultFileName = _assemblyName; + } + +/*********************************************************************** +GenerateCppFiles +***********************************************************************/ + + template + WString GenerateToStream(const TCallback& callback) + { + MemoryStream stream; + { + StreamWriter writer(stream); + callback(writer); + } + stream.SeekFromBegin(0); + { + StreamReader reader(stream); + return reader.ReadToEnd(); + } + } + + void GenerateCppComment(StreamWriter& writer, const WString& comment) + { + writer.WriteLine(L"/***********************************************************************"); + writer.WriteLine(L"!!!!!! DO NOT MODIFY !!!!!!"); + writer.WriteLine(L""); + writer.WriteLine(comment); + writer.WriteLine(L""); + writer.WriteLine(L"This file is generated by Workflow compiler"); + writer.WriteLine(L"https://github.com/vczh-libraries"); + writer.WriteLine(L"***********************************************************************/"); + } + + Ptr GenerateCppFiles(Ptr input, analyzer::WfLexicalScopeManager* manager) + { + WfCppConfig config(manager, input->assemblyName, input->assemblyNamespace); + auto output = MakePtr(); + if (config.manager->declarationTypes.Count() > 0) + { + output->containsReflectionInfo = true; + } + + bool multiFile = false; + switch (input->multiFile) + { + case WfCppFileSwitch::Enabled: + multiFile = true; + break; + case WfCppFileSwitch::Disabled: + multiFile = false; + break; + default: + multiFile = config.topLevelClassDeclsForFiles.Count() > 1; + } + + bool reflection = false; + switch (input->reflection) + { + case WfCppFileSwitch::Enabled: + reflection = true; + break; + case WfCppFileSwitch::Disabled: + reflection = false; + break; + default: + reflection = config.manager->declarationTypes.Count() > 0; + } + + output->multiFile = multiFile; + output->reflection = reflection; + + if (multiFile) + { + output->entryFileName = input->includeFileName; + } + else + { + output->entryFileName = input->defaultFileName; + } + + output->cppFiles.Add(input->defaultFileName + L".h", GenerateToStream([&](StreamWriter& writer) + { + GenerateCppComment(writer, input->comment); + writer.WriteLine(L""); + writer.WriteLine(L"#ifndef " + input->headerGuardPrefix + wupper(input->defaultFileName)); + writer.WriteLine(L"#define " + input->headerGuardPrefix + wupper(input->defaultFileName)); + writer.WriteLine(L""); + FOREACH(WString, include, input->normalIncludes) + { + writer.WriteLine(L"#include \"" + include + L"\""); + } + writer.WriteLine(L""); + config.WriteHeader(writer, multiFile); + writer.WriteLine(L""); + writer.WriteLine(L"#endif"); + })); + + auto extraInclude = [&](StreamWriter& writer) + { + if (reflection || input->reflectionIncludes.Count() > 0) + { + writer.WriteLine(L"/* CodePack:BeginIgnore() */"); + writer.WriteLine(L"#ifndef VCZH_DEBUG_NO_REFLECTION"); + if (reflection) + { + writer.WriteLine(L"/* CodePack:ConditionOff(VCZH_DEBUG_NO_REFLECTION, " + input->reflectionFileName + L".h) */"); + writer.WriteLine(L"#include \"" + input->reflectionFileName + L".h\""); + } + else + { + FOREACH(WString, include, input->reflectionIncludes) + { + writer.WriteLine(L"/* CodePack:ConditionOff(VCZH_DEBUG_NO_REFLECTION, " + include + L") */"); + writer.WriteLine(L"#include \"" + include + L"\""); + } + } + writer.WriteLine(L"#endif"); + writer.WriteLine(L"/* CodePack:EndIgnore() */"); + } + }; + + output->cppFiles.Add(input->defaultFileName + L".cpp", GenerateToStream([&](StreamWriter& writer) + { + GenerateCppComment(writer, input->comment); + writer.WriteLine(L""); + writer.WriteLine(L"#include \"" + output->entryFileName + L".h\""); + extraInclude(writer); + writer.WriteLine(L""); + config.WriteCpp(writer, multiFile); + })); + + if (reflection) + { + output->cppFiles.Add(input->reflectionFileName + L".h", GenerateToStream([&](StreamWriter& writer) + { + GenerateCppComment(writer, input->comment); + writer.WriteLine(L""); + writer.WriteLine(L"#ifndef " + input->headerGuardPrefix + wupper(input->reflectionFileName)); + writer.WriteLine(L"#define " + input->headerGuardPrefix + wupper(input->reflectionFileName)); + writer.WriteLine(L""); + writer.WriteLine(L"#include \"" + output->entryFileName + L".h\""); + if (input->reflectionIncludes.Count() > 0) + { + writer.WriteLine(L"#ifndef VCZH_DEBUG_NO_REFLECTION"); + FOREACH(WString, include, input->reflectionIncludes) + { + writer.WriteLine(L"#include \"" + include + L"\""); + } + writer.WriteLine(L"#endif"); + } + writer.WriteLine(L""); + config.WriteReflectionHeader(writer, multiFile); + writer.WriteLine(L""); + writer.WriteLine(L"#endif"); + })); + + output->cppFiles.Add(input->reflectionFileName + L".cpp", GenerateToStream([&](StreamWriter& writer) + { + GenerateCppComment(writer, input->comment); + writer.WriteLine(L""); + writer.WriteLine(L"#include \"" + input->reflectionFileName + L".h\""); + writer.WriteLine(L""); + config.WriteReflectionCpp(writer, multiFile); + })); + } + + if (multiFile) + { + output->cppFiles.Add(input->includeFileName + L".h", GenerateToStream([&](StreamWriter& writer) + { + GenerateCppComment(writer, input->comment); + writer.WriteLine(L""); + writer.WriteLine(L"#ifndef " + input->headerGuardPrefix + wupper(input->includeFileName)); + writer.WriteLine(L"#define " + input->headerGuardPrefix + wupper(input->includeFileName)); + writer.WriteLine(L""); + + writer.WriteLine(L"#include \"" + input->defaultFileName + L".h\""); + FOREACH(WString, fileName, config.topLevelClassDeclsForFiles.Keys()) + { + if (fileName != L"") + { + writer.WriteLine(L"#include \"" + fileName + L".h\""); + } + } + + writer.WriteLine(L""); + writer.WriteLine(L"#endif"); + })); + + FOREACH(WString, fileName, config.topLevelClassDeclsForFiles.Keys()) + { + if (fileName != L"") + { + output->cppFiles.Add(fileName + L".h", GenerateToStream([&](StreamWriter& writer) + { + GenerateCppComment(writer, input->comment); + writer.WriteLine(L""); + writer.WriteLine(L"#ifndef " + input->headerGuardPrefix + wupper(fileName)); + writer.WriteLine(L"#define " + input->headerGuardPrefix + wupper(fileName)); + writer.WriteLine(L""); + writer.WriteLine(L"#include \"" + input->defaultFileName + L".h\""); + { + List> decls; + CopyFrom(decls, config.topLevelClassDeclsForFiles[fileName]); + for (vint i = 0; i < decls.Count(); i++) + { + if (auto classDecl = decls[i].Cast()) + { + { + vint index = config.enumDecls.Keys().IndexOf(classDecl.Obj()); + if (index != -1) + { + CopyFrom(decls, config.enumDecls.GetByIndex(index), true); + } + } + { + vint index = config.structDecls.Keys().IndexOf(classDecl.Obj()); + if (index != -1) + { + CopyFrom(decls, config.structDecls.GetByIndex(index), true); + } + } + { + vint index = config.classDecls.Keys().IndexOf(classDecl.Obj()); + if (index != -1) + { + CopyFrom(decls, config.classDecls.GetByIndex(index), true); + } + } + } + } + + SortedList fileNames; + FOREACH(Ptr, decl, decls) + { + vint index = config.declDependencies.Keys().IndexOf(decl.Obj()); + if (index != -1) + { + FOREACH(Ptr, declDep, config.declDependencies.GetByIndex(index)) + { + WString fileName = config.declFiles[declDep.Obj()]; + if (fileName != L"" && !fileNames.Contains(fileName)) + { + fileNames.Add(fileName); + } + } + } + } + + FOREACH(WString, fileName, fileNames) + { + writer.WriteLine(L"#include \"" + fileName + L".h\""); + } + } + writer.WriteLine(L""); + config.WriteSubHeader(writer, fileName); + writer.WriteLine(L""); + writer.WriteLine(L"#endif"); + })); + + output->cppFiles.Add(fileName + L".cpp", GenerateToStream([&](StreamWriter& writer) + { + GenerateCppComment(writer, input->comment); + writer.WriteLine(L""); + writer.WriteLine(L"#include \"" + input->includeFileName + L".h\""); + extraInclude(writer); + writer.WriteLine(L""); + config.WriteSubCpp(writer, fileName); + })); + } + } + } + + return output; + } + +/*********************************************************************** +MergeCppFile +***********************************************************************/ + + WString RemoveSpacePrefix(const WString& s) + { + for (vint i = 0; i < s.Length(); i++) + { + if (s[i] != L' '&&s[i] != L'\t') + { + return s.Sub(i, s.Length() - i); + } + } + return WString::Empty; + } + + const vint NORMAL = 0; + const vint WAIT_HEADER = 1; + const vint WAIT_OPEN = 2; + const vint WAIT_CLOSE = 3; + const vint UNUSED_USER_CONTENT = 4; + + template + void ProcessCppContent(const WString& code, const TCallback& callback) + { + vint state = NORMAL; + vint counter = 0; + + StringReader reader(code); + while (!reader.IsEnd()) + { + auto line = reader.ReadLine(); + if (reader.IsEnd() && line == L"") + { + break; + } + + if (line == L"// UNUSED_USER_CONTENT:") + { + state = UNUSED_USER_CONTENT; + } + + if (state == UNUSED_USER_CONTENT) + { + callback(state, state, line, line); + } + else + { + auto content = RemoveSpacePrefix(line); + auto previousState = state; + switch (state) + { + case NORMAL: + if (content.Length() > 9 && content.Sub(0, 9) == L"USERIMPL(") + { + state = WAIT_HEADER; + } + break; + case WAIT_HEADER: + state = WAIT_OPEN; + break; + case WAIT_OPEN: + if (content == L"{") + { + state = WAIT_CLOSE; + } + break; + case WAIT_CLOSE: + if (content == L"{") + { + counter++; + } + else if (content == L"}") + { + if (counter == 0) + { + state = NORMAL; + } + else + { + counter--; + } + } + break; + } + callback(previousState, state, line, content); + } + } + } + + template + void SplitCppContent(const WString& code, Dictionary& userContents, Dictionary& userContentsFull, const TCallback& callback) + { + WString name; + WString userImpl; + WString userImplFull; + ProcessCppContent(code, [&](vint previousState, vint state, const WString& line, const WString& content) + { + if (state == UNUSED_USER_CONTENT) + { + callback(line); + } + else + { + if (previousState == NORMAL && state == WAIT_HEADER) + { + name = content; + userImpl = L""; + userImplFull = L""; + } + else if (previousState == WAIT_HEADER) + { + name += content; + } + else if (previousState == WAIT_CLOSE && state == WAIT_CLOSE) + { + userImpl += line + L"\r\n"; + } + else if (previousState == WAIT_CLOSE && state == NORMAL) + { + userImplFull += L"//" + line + L"\r\n"; + userContents.Add(name, userImpl); + userContentsFull.Add(name, userImplFull); + name = L""; + } + + if (name != L"") + { + userImplFull += L"//" + line + L"\r\n"; + } + } + }); + } + + WString MergeCppMultiPlatform(const WString& code32, const WString& code64) + { + return GenerateToStream([&](StreamWriter& writer) + { + const wchar_t* reading32 = code32.Buffer(); + const wchar_t* reading64 = code64.Buffer(); + const wchar_t* start32 = reading32; + while (true) + { + vint length = 0; + while (reading32[length] && reading64[length]) + { + if (reading32[length] == reading64[length]) + { + length++; + } + else + { + break; + } + } + + writer.WriteString(reading32, length); + reading32 += length; + reading64 += length; + + if (*reading32 == 0 && *reading64 == 0) + { + break; + } + +#define IS_DIGIT(C) (L'0' <= C && C <= L'9') + + if (reading32[0] == L'3' && reading32[1] == L'2' && reading64[0] == L'6' && reading64[1] == L'4') + { + if (length >= 4) + { + if (wcsncmp(reading32 - 4, L"vint32_t", 8) == 0 && wcsncmp(reading64 - 4, L"vint64_t", 8) == 0) + { + reading32 += 4; + reading64 += 4; + goto NEXT_ROUND; + } + } + } + else if (reading64[0] == L'L') + { + if (reading32[0] == reading64[1] && length >= 1) + { + if (IS_DIGIT(reading32[-1]) && !IS_DIGIT(reading32[0])) + { + if (IS_DIGIT(reading64[-1]) && !IS_DIGIT(reading64[1])) + { + reading64 += 1; + goto NEXT_ROUND; + } + } + } + } + else if (reading64[0] == L'U' && reading64[1] == L'L') + { + if (reading32[0] == reading64[2] && length >= 1) + { + if (IS_DIGIT(reading32[-1]) && !IS_DIGIT(reading32[0])) + { + if (IS_DIGIT(reading64[-1]) && !IS_DIGIT(reading64[2])) + { + reading64 += 2; + goto NEXT_ROUND; + } + } + } + } + throw Exception(L"The difference at " + itow((vint)(reading32 - start32)) + L"-th character between Input C++ source files are not " + L"\"vint32_t\" and \"vint64_t\", " + L"\"\" and \"L\", " + L"\"\" and \"UL\"." + ); + NEXT_ROUND:; + +#undef IS_DIGIT + } + }); + } + + WString MergeCppFileContent(const WString& dst, const WString& src) + { + Dictionary userContents, userContentsFull; + WString unusedUserContent = GenerateToStream([&](StreamWriter& writer) + { + SplitCppContent(dst, userContents, userContentsFull, [&](const WString& line) + { + writer.WriteLine(line); + }); + }); + + WString processedUnusedUserContent = GenerateToStream([&](StreamWriter& writer) + { + StringReader reader(unusedUserContent); + while (!reader.IsEnd()) + { + auto line = reader.ReadLine(); + if (line != L"// UNUSED_USER_CONTENT:") + { + if (INVLOC.StartsWith(line, L"//", Locale::None)) + { + line = line.Right(line.Length() - 2); + } + writer.WriteLine(line); + } + } + }); + + SplitCppContent(processedUnusedUserContent, userContents, userContentsFull, [&](const WString& line) {}); + + return GenerateToStream([&](StreamWriter& writer) + { + WString name; + WString userImpl; + ProcessCppContent(src, [&](vint previousState, vint state, const WString& line, const WString& content) + { + if (previousState == NORMAL && state == WAIT_HEADER) + { + name = content; + userImpl = L""; + } + else if (previousState == WAIT_HEADER) + { + name += content; + } + else if (previousState == WAIT_CLOSE && state == WAIT_CLOSE) + { + userImpl += line + L"\r\n"; + return; + } + else if (previousState == WAIT_CLOSE && state == NORMAL) + { + vint index = userContents.Keys().IndexOf(name); + if (index == -1) + { + writer.WriteString(userImpl); + } + else + { + writer.WriteString(userContents.Values()[index]); + userContentsFull.Remove(name); + } + } + writer.WriteLine(line); + }); + + if (userContentsFull.Count() > 0) + { + writer.WriteLine(L"// UNUSED_USER_CONTENT:"); + FOREACH(WString, content, userContentsFull.Values()) + { + writer.WriteString(content); + } + } + }); + } + } + } +} + + +/*********************************************************************** +.\CPP\WFCPP_STATEMENT.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace cppcodegen + { + using namespace collections; + using namespace reflection; + using namespace reflection::description; + using namespace analyzer; + + class WfGenerateStatementVisitor : public Object, public WfStatement::IVisitor + { + public: + WfCppConfig* config; + Ptr functionRecord; + stream::StreamWriter& writer; + WString prefixBlock; + WString prefix; + ITypeInfo* returnType; + + WfGenerateStatementVisitor(WfCppConfig* _config, Ptr _functionRecord, stream::StreamWriter& _writer, const WString& _prefixBlock, const WString& _prefix, ITypeInfo* _returnType) + :config(_config) + , functionRecord(_functionRecord) + , writer(_writer) + , prefixBlock(_prefixBlock) + , prefix(_prefix) + , returnType(_returnType) + { + } + + void Call(Ptr node, WString prefixDelta = WString(L"\t", false)) + { + GenerateStatement(config, functionRecord, writer, node, prefix, prefixDelta, returnType); + } + + void Visit(WfBreakStatement* node)override + { + writer.WriteString(prefix); + writer.WriteLine(L"break;"); + } + + void Visit(WfContinueStatement* node)override + { + writer.WriteString(prefix); + writer.WriteLine(L"continue;"); + } + + void Visit(WfReturnStatement* node)override + { + writer.WriteString(prefix); + if (node->expression) + { + writer.WriteString(L"return "); + GenerateExpression(config, writer, node->expression, returnType); + writer.WriteLine(L";"); + } + else + { + writer.WriteLine(L"return;"); + } + } + + void Visit(WfDeleteStatement* node)override + { + writer.WriteString(prefix); + writer.WriteString(L"::vl::__vwsn::This("); + GenerateExpression(config, writer, node->expression, nullptr); + writer.WriteLine(L")->Dispose(true);"); + } + + void Visit(WfRaiseExceptionStatement* node)override + { + if (node->expression) + { + writer.WriteString(prefix); + writer.WriteString(L"throw ::vl::Exception("); + + auto result = config->manager->expressionResolvings[node->expression.Obj()]; + bool throwString = result.type->GetTypeDescriptor() == description::GetTypeDescriptor(); + if (!throwString) + { + writer.WriteString(L"::vl::__vwsn::This("); + } + GenerateExpression(config, writer, node->expression, result.type.Obj()); + if (!throwString) + { + writer.WriteString(L".Obj())->GetMessage()"); + } + + writer.WriteLine(L");"); + } + else + { + writer.WriteString(prefix); + writer.WriteLine(L"throw;"); + } + } + + void Visit(WfIfStatement* node)override + { + writer.WriteString(prefix); + while (node) + { + writer.WriteString(L"if ("); + if (node->type) + { + auto result = config->manager->expressionResolvings[node->expression.Obj()]; + auto scope = config->manager->nodeScopes[node].Obj(); + auto typeInfo = CreateTypeInfoFromType(scope, node->type); + writer.WriteString(L"auto "); + writer.WriteString(config->ConvertName(node->name.value)); + writer.WriteString(L" = "); + ConvertType(config, writer, result.type.Obj(), typeInfo.Obj(), [&]() {GenerateExpression(config, writer, node->expression, nullptr); }, false); + } + else + { + GenerateExpression(config, writer, node->expression, TypeInfoRetriver::CreateTypeInfo().Obj()); + } + writer.WriteLine(L")"); + Call(node->trueBranch); + if (node->falseBranch) + { + writer.WriteString(prefix); + if (auto ifStat = node->falseBranch.Cast()) + { + writer.WriteString(L"else "); + node = ifStat.Obj(); + continue; + } + else + { + writer.WriteLine(L"else"); + Call(node->falseBranch); + } + } + break; + } + } + + void Visit(WfWhileStatement* node)override + { + writer.WriteString(prefix); + writer.WriteString(L"while ("); + GenerateExpression(config, writer, node->condition, TypeInfoRetriver::CreateTypeInfo().Obj()); + writer.WriteLine(L")"); + Call(node->statement); + } + + void Visit(WfTryStatement* node)override + { + auto exName = L"__vwsne_" + itow(functionRecord->exprCounter++); + + WString tryPrefix = prefix; + if (node->finallyStatement) + { + auto blockName = L"__vwsnb_" + itow(functionRecord->blockCounter++); + tryPrefix += L"\t"; + + writer.WriteString(prefix); + writer.WriteLine(L"{"); + + writer.WriteString(tryPrefix); + writer.WriteString(L"auto "); + writer.WriteString(blockName); + writer.WriteLine(L" = [&]()"); + GenerateStatement(config, functionRecord, writer, node->finallyStatement, tryPrefix, WString(L"\t", false), returnType); + writer.WriteString(tryPrefix); + writer.WriteLine(L";"); + + writer.WriteString(tryPrefix); + writer.WriteString(L"::vl::__vwsn::RunOnExit<::vl::RemoveCVR::Type> "); + writer.WriteString(blockName); + writer.WriteString(L"_dtor(&"); + writer.WriteString(blockName); + writer.WriteLine(L");"); + } + WString bodyPrefix = tryPrefix + L"\t"; + + writer.WriteString(tryPrefix); + writer.WriteLine(L"try"); + writer.WriteString(tryPrefix); + writer.WriteLine(L"{"); + GenerateStatement(config, functionRecord, writer, node->protectedStatement, bodyPrefix, WString(L"\t", false), returnType); + writer.WriteString(tryPrefix); + writer.WriteLine(L"}"); + + writer.WriteString(tryPrefix); + writer.WriteString(L"catch(const ::vl::Exception&"); + if (node->catchStatement) + { + writer.WriteString(L" "); + writer.WriteString(exName); + } + writer.WriteLine(L")"); + writer.WriteString(tryPrefix); + writer.WriteLine(L"{"); + if (node->catchStatement) + { + writer.WriteString(bodyPrefix); + writer.WriteString(L"auto "); + writer.WriteString(config->ConvertName(node->name.value)); + writer.WriteString(L" = ::vl::reflection::description::IValueException::Create("); + writer.WriteString(exName); + writer.WriteLine(L".Message());"); + GenerateStatement(config, functionRecord, writer, node->catchStatement, bodyPrefix, WString(L"\t", false), returnType); + } + writer.WriteString(tryPrefix); + writer.WriteLine(L"}"); + + if (node->finallyStatement) + { + writer.WriteString(prefix); + writer.WriteLine(L"}"); + } + } + + void Visit(WfBlockStatement* node)override + { + writer.WriteString(prefixBlock); + writer.WriteLine(L"{"); + FOREACH(Ptr, statement, node->statements) + { + while (auto virtualStat = statement.Cast()) + { + statement = virtualStat->expandedStatement; + } + + if (statement.Cast()) + { + Call(statement); + } + else + { + Call(statement, WString::Empty); + } + } + writer.WriteString(prefixBlock); + writer.WriteLine(L"}"); + } + + void Visit(WfExpressionStatement* node)override + { + writer.WriteString(prefix); + GenerateExpression(config, writer, node->expression, nullptr, false); + writer.WriteLine(L";"); + } + + void Visit(WfVariableStatement* node)override + { + auto scope = config->manager->nodeScopes[node->variable.Obj()]; + auto symbol = scope->symbols[node->variable->name.value][0].Obj(); + + writer.WriteString(prefix); + if (node->variable->expression) + { + writer.WriteString(L"auto"); + } + else + { + writer.WriteString(config->ConvertType(symbol->typeInfo.Obj())); + } + writer.WriteString(L" "); + writer.WriteString(config->ConvertName(node->variable->name.value)); + + if (node->variable->expression) + { + writer.WriteString(L" = "); + GenerateExpression(config, writer, node->variable->expression, symbol->typeInfo.Obj()); + } + writer.WriteLine(L";"); + } + + void Visit(WfVirtualStatement* node)override + { + node->expandedStatement->Accept(this); + } + + void Visit(WfCoroutineStatement* node)override + { + CHECK_FAIL(L"WfGenerateStatementVisitor::Visit(WfCoroutineStatement*)#Internal error, All coroutine statements do not generate C++ code."); + } + }; + + void GenerateStatement(WfCppConfig* config, Ptr functionRecord, stream::StreamWriter& writer, Ptr node, const WString& prefix, const WString& prefixDelta, reflection::description::ITypeInfo* returnType) + { + WfGenerateStatementVisitor visitor(config, functionRecord, writer, prefix, prefix + prefixDelta, returnType); + node->Accept(&visitor); + } + } + } +} + +/*********************************************************************** +.\CPP\WFCPP_WRITECLASS.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace cppcodegen + { + using namespace collections; + using namespace reflection; + using namespace reflection::description; + + void WfCppConfig::WriteHeader_ClassPreDecl(stream::StreamWriter& writer, Ptr decl, const WString& name, const WString& prefix) + { + writer.WriteLine(prefix + L"class " + name + L";"); + } + + void WfCppConfig::WriteHeader_ClassPreDecl(stream::StreamWriter& writer, Ptr decl, collections::List& nss) + { + auto td = manager->declarationTypes[decl.Obj()].Obj(); + WString name; + auto prefix = WriteNamespace(writer, CppGetFullName(td), nss, name); + WriteHeader_ClassPreDecl(writer, decl, name, prefix); + } + + class WriteHeader_Class_FindClassDeclVisitor + : public empty_visitor::DeclarationVisitor + { + public: + List>& unprocessed; + + WriteHeader_Class_FindClassDeclVisitor(List>& _unprocessed) + :unprocessed(_unprocessed) + { + } + + void Dispatch(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + + void Visit(WfClassDeclaration* node)override + { + unprocessed.Add(node); + } + }; + + void WfCppConfig::WriteHeader_Class(stream::StreamWriter& writer, Ptr decl, const WString& name, const WString& prefix) + { + auto td = manager->declarationTypes[decl.Obj()].Obj(); + + writer.WriteString(prefix + L"class " + name + L" : "); + switch (decl->kind) + { + case WfClassKind::Class: + { + vint count = td->GetBaseTypeDescriptorCount(); + bool hasClassBase = Range(0, count) + .Any([=](vint index) + { + auto baseTd = td->GetBaseTypeDescriptor(index); + return baseTd->GetTypeDescriptorFlags() == TypeDescriptorFlags::Class + && baseTd != description::GetTypeDescriptor(); + }); + + if (!hasClassBase) + { + writer.WriteString(L"public ::vl::Object, "); + } + for (vint i = 0; i < count; i++) + { + auto baseTd = td->GetBaseTypeDescriptor(i); + switch (baseTd->GetTypeDescriptorFlags()) + { + case TypeDescriptorFlags::Class: + if (baseTd != description::GetTypeDescriptor()) + { + writer.WriteString(L"public " + ConvertType(baseTd) + L", "); + } + break; + case TypeDescriptorFlags::Interface: + writer.WriteString(L"public virtual " + ConvertType(baseTd) + L", "); + break; + default:; + } + } + } + break; + case WfClassKind::Interface: + { + vint count = td->GetBaseTypeDescriptorCount(); + for (vint i = 0; i < count; i++) + { + writer.WriteString(L"public virtual " + ConvertType(td->GetBaseTypeDescriptor(i)) + L", "); + } + } + break; + } + writer.WriteLine(L"public ::vl::reflection::Description<" + name + L">"); + writer.WriteLine(prefix + L"{"); + + List> unprocessed; + unprocessed.Add(decl); + + FOREACH(Ptr, attribute, attributeEvaluator->GetAttributes(decl->attributes, L"cpp", L"Friend")) + { + auto td = UnboxValue(attributeEvaluator->GetAttributeValue(attribute)); + + auto scopeName = manager->typeNames[td]; + if (scopeName->declarations.Count() == 0) + { + writer.WriteLine(prefix + L"\tfriend class " + ConvertType(td) + L";"); + } + else + { + auto friendDecl = scopeName->declarations[0].Cast(); + unprocessed.Add(friendDecl); + } + } + + auto declTypeName = ConvertType(manager->declarationTypes[decl.Obj()].Obj()); + for (vint i = 0; i < unprocessed.Count(); i++) + { + auto current = unprocessed[i]; + if (current != decl) + { + auto currentTypeName = ConvertType(manager->declarationTypes[current.Obj()].Obj()); + + bool isInternalClass = false; + if (currentTypeName.Length() > declTypeName.Length() + 2) + { + if (currentTypeName.Left(declTypeName.Length() + 2) == declTypeName + L"::") + { + isInternalClass = true; + } + } + if (!isInternalClass) + { + writer.WriteLine(prefix + L"\tfriend class " + currentTypeName + L";"); + } + } + + vint index = classClosures.Keys().IndexOf(current.Obj()); + if (index != -1) + { + SortedList closureNames; + CopyFrom( + closureNames, + From(classClosures.GetByIndex(index)) + .Select([&](Ptr closure) + { + return (closure.Cast() ? L"class ::" : L"struct ::") + + assemblyNamespace + + L"::" + + closureInfos[closure.Obj()]->lambdaClassName; + }) + ); + FOREACH(WString, closureName, closureNames) + { + writer.WriteLine(prefix + L"\tfriend " + closureName + L";"); + } + } + + WriteHeader_Class_FindClassDeclVisitor visitor(unprocessed); + FOREACH(Ptr, memberDecl, current->declarations) + { + memberDecl->Accept(&visitor); + } + } + writer.WriteLine(L"#ifndef VCZH_DEBUG_NO_REFLECTION"); + writer.WriteLine(prefix + L"\tfriend struct ::vl::reflection::description::CustomTypeDescriptorSelector<" + name + L">;"); + writer.WriteLine(L"#endif"); + + const vint PRIVATE = 0; + const vint PROTECTED = 1; + const vint PUBLIC = 2; + vint accessor = -1; + + { + vint index = enumDecls.Keys().IndexOf(decl.Obj()); + if (index != -1) + { + if (accessor != PUBLIC) + { + accessor = PUBLIC; + writer.WriteLine(prefix + L"public:"); + } + FOREACH(Ptr, decl, enumDecls.GetByIndex(index)) + { + WriteHeader_Enum(writer, decl, ConvertName(decl->name.value), prefix + L"\t"); + writer.WriteLine(L""); + } + } + } + + { + vint index = structDecls.Keys().IndexOf(decl.Obj()); + if (index != -1) + { + if (accessor != PUBLIC) + { + accessor = PUBLIC; + writer.WriteLine(prefix + L"public:"); + } + FOREACH(Ptr, decl, structDecls.GetByIndex(index)) + { + WriteHeader_Struct(writer, decl, ConvertName(decl->name.value), prefix + L"\t"); + writer.WriteLine(L""); + } + } + } + + { + vint index = classDecls.Keys().IndexOf(decl.Obj()); + if (index != -1) + { + if (accessor != PUBLIC) + { + accessor = PUBLIC; + writer.WriteLine(prefix + L"public:"); + } + FOREACH(Ptr, decl, classDecls.GetByIndex(index)) + { + WriteHeader_ClassPreDecl(writer, decl, ConvertName(decl->name.value), prefix + L"\t"); + } + writer.WriteLine(L""); + FOREACH(Ptr, decl, classDecls.GetByIndex(index)) + { + WriteHeader_Class(writer, decl, ConvertName(decl->name.value), prefix + L"\t"); + } + } + } + + FOREACH(Ptr, memberDecl, decl->declarations) + { + vint memberAccessor = PUBLIC; + if (attributeEvaluator->GetAttribute(memberDecl->attributes, L"cpp", L"Private")) + { + memberAccessor = PRIVATE; + } + else if (attributeEvaluator->GetAttribute(memberDecl->attributes, L"cpp", L"Protected")) + { + memberAccessor = PROTECTED; + } + + if (accessor != memberAccessor) + { + accessor = memberAccessor; + switch (accessor) + { + case PRIVATE: + writer.WriteLine(prefix + L"private:"); + break; + case PROTECTED: + writer.WriteLine(prefix + L"protected:"); + break; + case PUBLIC: + writer.WriteLine(prefix + L"public:"); + break; + } + } + GenerateClassMemberDecl(this, writer, ConvertName(decl->name.value), memberDecl, prefix + L"\t", false); + } + + writer.WriteLine(prefix + L"};"); + } + + WString WfCppConfig::WriteHeader_Class(stream::StreamWriter& writer, Ptr decl, collections::List& nss) + { + auto td = manager->declarationTypes[decl.Obj()].Obj(); + WString name; + auto prefix = WriteNamespace(writer, CppGetFullName(td), nss, name); + WriteHeader_Class(writer, decl, name, prefix); + return prefix; + } + + void WfCppConfig::WriteHeader_TopLevelClass(stream::StreamWriter& writer, Ptr decl, collections::List& nss) + { + auto prefix = WriteHeader_Class(writer, decl, nss); + List> classes; + classes.Add(decl); + vint processed = 0; + while (processed < classes.Count()) + { + auto current = classes[processed++]; + { + vint index = enumDecls.Keys().IndexOf(current.Obj()); + if (index != -1) + { + FOREACH(Ptr, enumDecl, enumDecls.GetByIndex(index)) + { + auto td = manager->declarationTypes[enumDecl.Obj()].Obj(); + WriteHeader_EnumOp(writer, enumDecl, ConvertType(td), prefix); + } + } + } + { + vint index = structDecls.Keys().IndexOf(current.Obj()); + if (index != -1) + { + FOREACH(Ptr, structDecl, structDecls.GetByIndex(index)) + { + auto td = manager->declarationTypes[structDecl.Obj()].Obj(); + WriteHeader_StructOp(writer, structDecl, ConvertType(td), prefix); + } + } + } + { + vint index = classDecls.Keys().IndexOf(current.Obj()); + if (index != -1) + { + CopyFrom(classes, classDecls.GetByIndex(index), true); + } + } + } + } + + bool WfCppConfig::WriteCpp_ClassMember(stream::StreamWriter& writer, Ptr decl, Ptr memberDecl, collections::List& nss) + { + List nss2; + GetClassNamespace(decl, nss2); + auto prefix = WriteNamespace(writer, nss, nss2); + + auto td = manager->declarationTypes[decl.Obj()].Obj(); + auto classFullName = CppGetFullName(td); + return GenerateClassMemberImpl(this, writer, GetClassBaseName(decl), ConvertName(decl->name.value), classFullName , memberDecl, prefix); + } + + void WfCppConfig::WriteCpp_Class(stream::StreamWriter& writer, Ptr decl, collections::List& nss) + { + List> classes; + classes.Add(decl); + vint processed = 0; + while (processed < classes.Count()) + { + auto current = classes[processed++]; + + writer.WriteLine(L"/***********************************************************************"); + writer.WriteLine(L"Class (" + CppGetFullName(manager->declarationTypes[current.Obj()].Obj()) + L")"); + writer.WriteLine(L"***********************************************************************/"); + writer.WriteLine(L""); + + FOREACH(Ptr, memberDecl, current->declarations) + { + if (WriteCpp_ClassMember(writer, current, memberDecl, nss)) + { + writer.WriteLine(L""); + } + } + + vint index = classDecls.Keys().IndexOf(current.Obj()); + if (index != -1) + { + CopyFrom(classes, classDecls.GetByIndex(index), true); + } + } + } + } + } +} + + +/*********************************************************************** +.\CPP\WFCPP_WRITEENUM.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace cppcodegen + { + using namespace collections; + + void WfCppConfig::WriteHeader_Enum(stream::StreamWriter& writer, Ptr decl, const WString& name, const WString& prefix) + { + writer.WriteLine(prefix + L"enum class " + name + L" : vl::vuint64_t"); + writer.WriteLine(prefix + L"{"); + FOREACH(Ptr, item, decl->items) + { + switch (item->kind) + { + case WfEnumItemKind::Constant: + writer.WriteLine(prefix + L"\t" + ConvertName(item->name.value) + L" = " + item->number.value + L"UL,"); + break; + case WfEnumItemKind::Intersection: + writer.WriteString(prefix + L"\t" + ConvertName(item->name.value) + L" = "); + FOREACH_INDEXER(Ptr, enumInt, index, item->intersections) + { + if (index > 0) + { + writer.WriteString(L" | "); + } + writer.WriteString(ConvertName(enumInt->name.value)); + } + writer.WriteLine(L","); + break; + } + } + writer.WriteLine(prefix + L"};"); + } + + void WfCppConfig::WriteHeader_EnumOp(stream::StreamWriter& writer, Ptr decl, const WString& name, const WString& prefix) + { + const wchar_t* ops[] = { L"&", L"|" }; + for (auto op : ops) + { + writer.WriteString(prefix); + writer.WriteString(L"inline "); + writer.WriteString(name); + writer.WriteString(L" operator"); + writer.WriteString(op); + writer.WriteString(L" ("); + writer.WriteString(name); + writer.WriteString(L" a, "); + writer.WriteString(name); + writer.WriteString(L" b) { return static_cast<"); + writer.WriteString(name); + writer.WriteString(L">(static_cast<::vl::vuint64_t>(a) "); + writer.WriteString(op); + writer.WriteLine(L" static_cast<::vl::vuint64_t>(b)); }"); + } + } + + void WfCppConfig::WriteHeader_Enum(stream::StreamWriter& writer, Ptr decl, collections::List& nss) + { + auto td = manager->declarationTypes[decl.Obj()].Obj(); + WString name; + auto prefix = WriteNamespace(writer, CppGetFullName(td), nss, name); + WriteHeader_Enum(writer, decl, name, prefix); + WriteHeader_EnumOp(writer, decl, name, prefix); + } + } + } +} + +/*********************************************************************** +.\CPP\WFCPP_WRITEFUNCTIONHEADER.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace cppcodegen + { + using namespace collections; + using namespace reflection::description; + + ITypeInfo* WfCppConfig::WriteFunctionHeader(stream::StreamWriter& writer, ITypeInfo* typeInfo, collections::List& arguments, const WString& name, bool writeReturnType) + { + ITypeInfo* returnType = nullptr; + if (writeReturnType) + { + returnType = typeInfo->GetElementType()->GetGenericArgument(0); + writer.WriteString(ConvertType(returnType)); + writer.WriteChar(L' '); + } + + writer.WriteString(name); + writer.WriteString(L"("); + for (vint i = 0; i < arguments.Count(); i++) + { + if (i > 0) + { + writer.WriteString(L", "); + } + writer.WriteString(ConvertArgumentType(typeInfo->GetElementType()->GetGenericArgument(i + 1))); + writer.WriteChar(L' '); + writer.WriteString(ConvertName(arguments[i])); + } + writer.WriteString(L")"); + + return returnType; + } + + ITypeInfo* WfCppConfig::WriteFunctionHeader(stream::StreamWriter& writer, Ptr ordered, const WString& name, bool writeReturnType) + { + auto result = manager->expressionResolvings[ordered.Obj()]; + auto typeInfo = result.type.Obj(); + + auto scope = manager->nodeScopes[ordered.Obj()].Obj(); + List arguments; + CopyFrom( + arguments, + Range(0, scope->symbols.Count()) + .Select([scope](vint index) + { + return scope->symbols.GetByIndex(index)[0]->name; + }) + .OrderBy((vint(*)(const WString&, const WString&))&WString::Compare) + ); + + return WriteFunctionHeader(writer, typeInfo, arguments, name, writeReturnType); + } + + ITypeInfo* WfCppConfig::WriteFunctionHeader(stream::StreamWriter& writer, Ptr funcExpr, const WString& name, bool writeReturnType) + { + auto result = manager->expressionResolvings[funcExpr.Obj()]; + auto typeInfo = result.type.Obj(); + + List arguments; + CopyFrom( + arguments, + From(funcExpr->function->arguments) + .Select([](Ptr argument) + { + return argument->name.value; + }) + ); + return WriteFunctionHeader(writer, typeInfo, arguments, name, writeReturnType); + } + + ITypeInfo* WfCppConfig::WriteFunctionHeader(stream::StreamWriter& writer, Ptr decl, const WString& name, bool writeReturnType) + { + vint index1 = manager->declarationMemberInfos.Keys().IndexOf(decl.Obj()); + vint index2 = manager->interfaceMethodImpls.Keys().IndexOf(decl.Obj()); + auto methodInfo = + index1 != -1 ? dynamic_cast(manager->declarationMemberInfos.Values()[index1].Obj()) : + index2 != -1 ? manager->interfaceMethodImpls.Values()[index2] : + nullptr; + + List arguments; + CopyFrom( + arguments, + From(decl->arguments) + .Select([](Ptr argument) + { + return argument->name.value; + }) + ); + + if (methodInfo) + { + return WriteFunctionHeader(writer, methodInfo, arguments, name, writeReturnType); + } + else + { + auto scope = manager->nodeScopes[decl.Obj()].Obj(); + auto symbol = manager->GetDeclarationSymbol(scope, decl.Obj()); + auto typeInfo = symbol->typeInfo.Obj(); + + return WriteFunctionHeader(writer, typeInfo, arguments, name, writeReturnType); + } + } + + ITypeInfo* WfCppConfig::WriteFunctionHeader(stream::StreamWriter& writer, IMethodInfo* methodInfo, collections::List& arguments, const WString& name, bool writeReturnType) + { + ITypeInfo* returnType = nullptr; + if (writeReturnType) + { + returnType = methodInfo->GetReturn(); + writer.WriteString(ConvertType(returnType)); + writer.WriteChar(L' '); + } + writer.WriteString(name); + writer.WriteString(L"("); + vint count = methodInfo->GetParameterCount(); + for (vint i = 0; i < count; i++) + { + if (i > 0) + { + writer.WriteString(L", "); + } + writer.WriteString(ConvertArgumentType(methodInfo->GetParameter(i)->GetType())); + writer.WriteChar(L' '); + if (arguments.Count() == 0) + { + writer.WriteString(ConvertName(methodInfo->GetParameter(i)->GetName())); + } + else + { + writer.WriteString(ConvertName(arguments[i])); + } + } + writer.WriteString(L")"); + return returnType; + } + + ITypeInfo* WfCppConfig::WriteFunctionHeader(stream::StreamWriter& writer, IMethodInfo* methodInfo, const WString& name, bool writeReturnType) + { + List arguments; + return WriteFunctionHeader(writer, methodInfo, arguments, name, writeReturnType); + } + } + } +} + +/*********************************************************************** +.\CPP\WFCPP_WRITEGLOBAL.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace cppcodegen + { + using namespace collections; + using namespace reflection; + using namespace reflection::description; + + void WfCppConfig::SortClosure(Dictionary>& reversedLambdaExprs, Dictionary>& reversedClassExprs) + { + CopyFrom( + reversedLambdaExprs, + From(lambdaExprs) + .Select([](Pair, WString> pair) + { + return Pair>(pair.value, pair.key); + }) + ); + + CopyFrom( + reversedClassExprs, + From(classExprs) + .Select([](Pair, WString> pair) + { + return Pair>(pair.value, pair.key); + }) + ); + } + + void WfCppConfig::WriteHeader_Global(stream::StreamWriter& writer) + { + Dictionary> reversedLambdaExprs; + Dictionary> reversedClassExprs; + SortClosure(reversedLambdaExprs, reversedClassExprs); + + writer.WriteLine(L"/***********************************************************************"); + writer.WriteLine(L"Global Variables and Functions"); + writer.WriteLine(L"***********************************************************************/"); + writer.WriteLine(L""); + writer.WriteLine(L"namespace " + assemblyNamespace); + writer.WriteLine(L"{"); + writer.WriteLine(L"\tclass " + assemblyName); + writer.WriteLine(L"\t{"); + writer.WriteLine(L"\tpublic:"); + if (varDecls.Count() > 0) + { + writer.WriteLine(L""); + FOREACH(Ptr, decl, varDecls) + { + auto scope = manager->nodeScopes[decl.Obj()].Obj(); + auto symbol = scope->symbols[decl->name.value][0]; + auto typeInfo = symbol->typeInfo; + writer.WriteString(L"\t\t" + ConvertType(typeInfo.Obj()) + L" " + ConvertName(decl->name.value)); + auto defaultValue = DefaultValue(typeInfo.Obj()); + if (defaultValue != L"") + { + writer.WriteString(L" = "); + writer.WriteString(defaultValue); + } + writer.WriteLine(L";"); + } + } + if (funcDecls.Count() > 0) + { + writer.WriteLine(L""); + FOREACH(Ptr, decl, funcDecls) + { + writer.WriteString(L"\t\t"); + WriteFunctionHeader(writer, decl, ConvertName(decl->name.value), true); + writer.WriteLine(L";"); + } + } + writer.WriteLine(L""); + writer.WriteLine(L"\t\tstatic " + assemblyName + L"& Instance();"); + writer.WriteLine(L"\t};"); + + if (reversedLambdaExprs.Count() + reversedClassExprs.Count() > 0) + { + writer.WriteLine(L""); + writer.WriteLine(L"/***********************************************************************"); + writer.WriteLine(L"Closures"); + writer.WriteLine(L"***********************************************************************/"); + + FOREACH(Ptr, expr, reversedLambdaExprs.Values()) + { + writer.WriteLine(L""); + WriteHeader_LambdaExprDecl(writer, expr); + } + + FOREACH(Ptr, expr, reversedClassExprs.Values()) + { + writer.WriteLine(L""); + WriteHeader_ClassExprDecl(writer, expr); + } + } + + writer.WriteLine(L"}"); + } + + void WfCppConfig::WriteCpp_Global(stream::StreamWriter& writer) + { + Dictionary> reversedLambdaExprs; + Dictionary> reversedClassExprs; + SortClosure(reversedLambdaExprs, reversedClassExprs); + + writer.WriteLine(L"/***********************************************************************"); + writer.WriteLine(L"Global Variables"); + writer.WriteLine(L"***********************************************************************/"); + writer.WriteLine(L""); + + WString storageName = assemblyNamespace + L"_" + assemblyName; + writer.WriteLine(L"BEGIN_GLOBAL_STORAGE_CLASS(" + storageName + L")"); + writer.WriteLine(L"\t" + assemblyNamespace + L"::" + assemblyName + L" instance;"); + writer.WriteLine(L"\tINITIALIZE_GLOBAL_STORAGE_CLASS"); + if (varDecls.Count() > 0) + { + writer.WriteLine(L""); + FOREACH(Ptr, decl, varDecls) + { + auto scope = manager->nodeScopes[decl.Obj()].Obj(); + auto symbol = scope->symbols[decl->name.value][0]; + auto typeInfo = symbol->typeInfo; + if (decl->expression) + { + writer.WriteString(L"\t\tinstance." + ConvertName(decl->name.value) + L" = "); + GenerateExpression(this, writer, decl->expression, typeInfo.Obj()); + writer.WriteLine(L";"); + } + } + } + writer.WriteLine(L"\tFINALIZE_GLOBAL_STORAGE_CLASS"); + if (varDecls.Count() > 0) + { + writer.WriteLine(L""); + FOREACH(Ptr, decl, varDecls) + { + auto scope = manager->nodeScopes[decl.Obj()].Obj(); + auto symbol = scope->symbols[decl->name.value][0]; + auto typeInfo = symbol->typeInfo; + switch (typeInfo->GetDecorator()) + { + case ITypeInfo::RawPtr: + case ITypeInfo::SharedPtr: + writer.WriteLine(L"\t\tinstance." + ConvertName(decl->name.value) + L" = nullptr;"); + break; + case ITypeInfo::Nullable: + writer.WriteString(L"\t\tinstance." + ConvertName(decl->name.value) + L" = "); + ConvertType(typeInfo.Obj()); + writer.WriteLine(L"();"); + break; + default: + if (typeInfo->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + writer.WriteLine(L"\t\tinstance." + ConvertName(decl->name.value) + L" = ::vl::WString::Empty;"); + } + else if (typeInfo->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + writer.WriteLine(L"\t\tinstance." + ConvertName(decl->name.value) + L" = ::vl::reflection::description::Value();"); + } + } + } + } + writer.WriteLine(L"END_GLOBAL_STORAGE_CLASS(" + storageName + L")"); + writer.WriteLine(L""); + + writer.WriteString(L"namespace "); + writer.WriteLine(assemblyNamespace); + writer.WriteLine(L"{"); + + writer.WriteLine(L"/***********************************************************************"); + writer.WriteLine(L"Global Functions"); + writer.WriteLine(L"***********************************************************************/"); + + FOREACH(Ptr, decl, funcDecls) + { + writer.WriteLine(L""); + writer.WriteString(L"\t"); + auto returnType = WriteFunctionHeader(writer, decl, assemblyName + L"::" + ConvertName(decl->name.value), true); + writer.WriteLine(L""); + WriteFunctionBody(writer, decl->statement, L"\t", returnType); + } + + writer.WriteLine(L""); + writer.WriteLine(L"\t" + assemblyName + L"& " + assemblyName + L"::Instance()"); + writer.WriteLine(L"\t{"); + writer.WriteLine(L"\t\treturn Get" + storageName + L"().instance;"); + writer.WriteLine(L"\t}"); + + if (reversedLambdaExprs.Count() + reversedClassExprs.Count() > 0) + { + writer.WriteLine(L""); + writer.WriteLine(L"/***********************************************************************"); + writer.WriteLine(L"Closures"); + writer.WriteLine(L"***********************************************************************/"); + + FOREACH(Ptr, expr, reversedLambdaExprs.Values()) + { + writer.WriteLine(L""); + writer.WriteLine(L"\t//-------------------------------------------------------------------"); + writer.WriteLine(L""); + WriteCpp_LambdaExprImpl(writer, expr); + } + + if (reversedClassExprs.Count() > 0) + { + writer.WriteLine(L""); + FOREACH(Ptr, expr, reversedClassExprs.Values()) + { + writer.WriteLine(L"\t//-------------------------------------------------------------------"); + writer.WriteLine(L""); + WriteCpp_ClassExprImpl(writer, expr); + } + } + } + + writer.WriteLine(L"}"); + } + } + } +} + +/*********************************************************************** +.\CPP\WFCPP_WRITELAMBDA.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace cppcodegen + { + using namespace collections; + using namespace parsing; + using namespace analyzer; + using namespace reflection; + using namespace reflection::description; + +/*********************************************************************** +WfCppConfig::CollectClosureInfo +***********************************************************************/ + + class WfCppCollectClassExprInfoVisitor : public empty_visitor::DeclarationVisitor + { + public: + WfCppConfig* config; + vint variableCount = 0; + Ptr capture; + + WfCppCollectClassExprInfoVisitor(WfCppConfig* _config) + :config(_config) + { + } + + void Visit(WfVariableDeclaration* node)override + { + variableCount++; + } + + void Dispatch(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + + void Execute(WfNewInterfaceExpression* node) + { + capture = config->manager->lambdaCaptures[node]; + FOREACH(Ptr, memberDecl, node->declarations) + { + memberDecl->Accept(this); + } + } + }; + + Ptr WfCppConfig::CollectClosureInfo(Ptr closure) + { + using SymbolPair = Pair>; + + auto info = MakePtr(); + WfLexicalScope* scope = nullptr; + + if (auto ordered = closure.Cast()) + { + // stable symbol order by sorting them by name + CopyFrom( + info->symbols, + From(manager->lambdaCaptures[ordered.Obj()]->symbols) + .Select([](Ptr symbol) + { + return SymbolPair(symbol->name, symbol); + }) + ); + scope = manager->nodeScopes[ordered.Obj()].Obj(); + } + else if (auto funcExpr = closure.Cast()) + { + // stable symbol order by sorting them by name + CopyFrom( + info->symbols, + From(manager->lambdaCaptures[funcExpr->function.Obj()]->symbols) + .Select([](Ptr symbol) + { + return SymbolPair(symbol->name, symbol); + }) + ); + scope = manager->nodeScopes[funcExpr->function.Obj()].Obj(); + } + else if (auto classExpr = closure.Cast()) + { + WfCppCollectClassExprInfoVisitor visitor(this); + visitor.Execute(classExpr.Obj()); + + if (visitor.capture) + { + // stable symbol order by sorting them by name + CopyFrom( + info->symbols, + From(visitor.capture->symbols) + .Skip(visitor.variableCount) + .Select([](Ptr symbol) + { + return SymbolPair(symbol->name, symbol); + }) + ); + + CopyFrom( + info->ctorArgumentSymbols, + From(visitor.capture->ctorArgumentSymbols) + .Select([](Ptr symbol) + { + return SymbolPair(symbol->name, symbol); + }) + ); + } + + scope = manager->nodeScopes[classExpr.Obj()].Obj(); + } + + Ptr methodConfig; + while (scope) + { + if (scope->typeOfThisExpr) + { + if (methodConfig) + { + info->thisTypes.Add(scope->typeOfThisExpr); + if (!methodConfig->parentThisAccessable) + { + break; + } + methodConfig = nullptr; + } + } + + if (scope->functionConfig) + { + if (scope->functionConfig->thisAccessable) + { + methodConfig = scope->functionConfig; + } + } + scope = scope->parentScope.Obj(); + } + + return info; + } + +/*********************************************************************** +WfCppConfig::WriteCpp +***********************************************************************/ + + void WfCppConfig::WriteHeader_ClosurePreDecl(stream::StreamWriter& writer, Ptr closure) + { + auto info = closureInfos[closure.Obj()]; + writer.WriteString(L"\t"); + if (closure.Cast()) + { + writer.WriteString(L"class "); + } + else + { + writer.WriteString(L"struct "); + } + writer.WriteString(info->lambdaClassName); + writer.WriteLine(L";"); + } + + void WfCppConfig::WriteHeader_LambdaExprDecl(stream::StreamWriter& writer, Ptr lambda) + { + if (auto ordered = lambda.Cast()) + { + auto name = lambdaExprs[lambda.Obj()]; + writer.WriteLine(L"\tstruct " + name); + writer.WriteLine(L"\t{"); + + if (WriteCpp_ClosureMembers(writer, lambda)) + { + writer.WriteLine(L""); + } + writer.WriteString(L"\t\t"); + WriteCpp_ClosureCtor(writer, lambda, name); + writer.WriteLine(L";"); + writer.WriteLine(L""); + + writer.WriteString(L"\t\t"); + WriteFunctionHeader(writer, ordered, L"operator()", true); + writer.WriteLine(L" const;"); + writer.WriteLine(L"\t};"); + } + else if (auto funcExpr = lambda.Cast()) + { + auto name = lambdaExprs[lambda.Obj()]; + writer.WriteLine(L"\tstruct " + name); + writer.WriteLine(L"\t{"); + + if (WriteCpp_ClosureMembers(writer, lambda)) + { + writer.WriteLine(L""); + } + writer.WriteString(L"\t\t"); + WriteCpp_ClosureCtor(writer, lambda, name); + writer.WriteLine(L";"); + writer.WriteLine(L""); + + writer.WriteString(L"\t\t"); + WriteFunctionHeader(writer, funcExpr, L"operator()", true); + writer.WriteLine(L" const;"); + writer.WriteLine(L"\t};"); + } + } + + void WfCppConfig::WriteHeader_ClassExprDecl(stream::StreamWriter& writer, Ptr lambda) + { + auto result = manager->expressionResolvings[lambda.Obj()]; + auto td = result.constructorInfo->GetOwnerTypeDescriptor(); + auto name = classExprs[lambda.Obj()]; + writer.WriteLine(L"\tclass " + name + L" : public ::vl::Object, public virtual " + ConvertType(td)); + writer.WriteLine(L"\t{"); + writer.WriteLine(L"\tpublic:"); + + if (WriteCpp_ClosureMembers(writer, lambda)) + { + writer.WriteLine(L""); + } + writer.WriteString(L"\t\t"); + WriteCpp_ClosureCtor(writer, lambda, name); + writer.WriteLine(L";"); + writer.WriteLine(L""); + + FOREACH(Ptr, memberDecl, lambda->declarations) + { + GenerateClassMemberDecl(this, writer, name, memberDecl, L"\t\t", true); + } + writer.WriteLine(L"\t};"); + } + + bool WfCppConfig::WriteCpp_ClosureMembers(stream::StreamWriter& writer, Ptr closure) + { + auto info = closureInfos[closure.Obj()]; + + FOREACH(Ptr, symbol, info->symbols.Values()) + { + writer.WriteString(L"\t\t"); + writer.WriteString(ConvertType(symbol->typeInfo.Obj())); + writer.WriteString(L" "); + writer.WriteString(ConvertName(symbol->name)); + writer.WriteLine(L";"); + } + + FOREACH_INDEXER(ITypeDescriptor*, thisType, index, info->thisTypes) + { + auto typeInfo = MakePtr(MakePtr(thisType, TypeInfoHint::Normal)); + + writer.WriteString(L"\t\t"); + writer.WriteString(ConvertType(typeInfo.Obj())); + writer.WriteString(L" "); + writer.WriteString(L"__vwsnthis_" + itow(index)); + writer.WriteLine(L";"); + } + + return info->symbols.Count() + info->thisTypes.Count() > 0; + } + + void WfCppConfig::WriteCpp_ClosureCtor(stream::StreamWriter& writer, Ptr closure, const WString& name) + { + auto info = closureInfos[closure.Obj()]; + + writer.WriteString(name); + writer.WriteString(L"("); + + vint argumentIndex = 0; + + FOREACH_INDEXER(Ptr, symbol, index, From(info->symbols.Values()).Concat(info->ctorArgumentSymbols.Values())) + { + if (argumentIndex++ > 0) + { + writer.WriteString(L", "); + } + writer.WriteString(ConvertType(symbol->typeInfo.Obj())); + writer.WriteString(L" __vwsnctor_"); + writer.WriteString(ConvertName(symbol->name)); + } + + FOREACH_INDEXER(ITypeDescriptor*, thisType, index, info->thisTypes) + { + auto typeInfo = MakePtr(MakePtr(thisType, TypeInfoHint::Normal)); + + if (argumentIndex++ > 0) + { + writer.WriteString(L", "); + } + writer.WriteString(ConvertType(typeInfo.Obj())); + writer.WriteString(L" __vwsnctorthis_" + itow(index)); + } + + writer.WriteString(L")"); + } + + void WfCppConfig::WriteCpp_ClosureCtorInitList(stream::StreamWriter& writer, Ptr closure) + { + auto info = closureInfos[closure.Obj()]; + + FOREACH_INDEXER(Ptr, symbol, index, info->symbols.Values()) + { + if (index > 0) + { + writer.WriteString(L"\t\t, "); + } + else + { + writer.WriteString(L"\t\t:"); + } + writer.WriteString(ConvertName(symbol->name)); + writer.WriteString(L"(__vwsnctor_"); + writer.WriteString(ConvertName(symbol->name)); + writer.WriteLine(L")"); + } + + FOREACH_INDEXER(ITypeDescriptor*, thisType, index, info->thisTypes) + { + if (index > 0 || info->symbols.Count() > 0) + { + writer.WriteString(L"\t\t, "); + } + else + { + writer.WriteString(L"\t\t:"); + } + writer.WriteString(L"__vwsnthis_" + itow(index)); + writer.WriteString(L"(::vl::__vwsn::This(__vwsnctorthis_" + itow(index)); + writer.WriteLine(L"))"); + } + } + + void WfCppConfig::WriteCpp_LambdaExprImpl(stream::StreamWriter& writer, Ptr lambda) + { + if (auto ordered = lambda.Cast()) + { + auto name = lambdaExprs[lambda.Obj()]; + + writer.WriteString(L"\t"); + WriteCpp_ClosureCtor(writer, lambda, name + L"::" + name); + writer.WriteLine(L""); + WriteCpp_ClosureCtorInitList(writer, lambda); + writer.WriteLine(L"\t{"); + writer.WriteLine(L"\t}"); + writer.WriteLine(L""); + + writer.WriteString(L"\t"); + auto returnType = WriteFunctionHeader(writer, ordered, name + L"::operator()", true); + writer.WriteLine(L" const"); + writer.WriteLine(L"\t{"); + WriteFunctionBody(writer, ordered->body, L"\t\t", returnType); + writer.WriteLine(L"\t}"); + } + else if (auto funcExpr = lambda.Cast()) + { + auto name = lambdaExprs[lambda.Obj()]; + + writer.WriteString(L"\t"); + WriteCpp_ClosureCtor(writer, lambda, name + L"::" + name); + writer.WriteLine(L""); + WriteCpp_ClosureCtorInitList(writer, lambda); + writer.WriteLine(L"\t{"); + writer.WriteLine(L"\t}"); + writer.WriteLine(L""); + + writer.WriteString(L"\t"); + auto returnType = WriteFunctionHeader(writer, funcExpr, name + L"::operator()", true); + writer.WriteLine(L" const"); + WriteFunctionBody(writer, funcExpr->function->statement, L"\t", returnType); + } + } + + class WriteCpp_ClassExprImpl_InitFieldVisitor + : public empty_visitor::DeclarationVisitor + { + public: + WfCppConfig* config; + stream::StreamWriter& writer; + + WriteCpp_ClassExprImpl_InitFieldVisitor(WfCppConfig* _config, stream::StreamWriter& _writer) + :config(_config) + , writer(_writer) + { + } + + void Dispatch(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + + void Visit(WfVariableDeclaration* node)override + { + if (node->expression) + { + auto scope = config->manager->nodeScopes[node].Obj(); + auto symbol = scope->symbols[node->name.value][0]; + auto typeInfo = symbol->typeInfo; + writer.WriteString(L"\t\tthis->"); + writer.WriteString(config->ConvertName(node->name.value)); + writer.WriteString(L" = "); + GenerateExpression(config, writer, node->expression, typeInfo.Obj()); + writer.WriteLine(L";"); + } + } + }; + + void WfCppConfig::WriteCpp_ClassExprImpl(stream::StreamWriter& writer, Ptr lambda) + { + auto name = classExprs[lambda.Obj()]; + + writer.WriteString(L"\t"); + WriteCpp_ClosureCtor(writer, lambda, name + L"::" + name); + writer.WriteLine(L""); + WriteCpp_ClosureCtorInitList(writer, lambda); + writer.WriteLine(L"\t{"); + + { + WriteCpp_ClassExprImpl_InitFieldVisitor visitor(this, writer); + FOREACH(Ptr, memberDecl, lambda->declarations) + { + memberDecl->Accept(&visitor); + } + } + + writer.WriteLine(L"\t}"); + writer.WriteLine(L""); + + WString classFullName = L"::" + assemblyNamespace + L"::" + name; + FOREACH(Ptr, memberDecl, lambda->declarations) + { + if (GenerateClassMemberImpl(this, writer, name, name, classFullName, memberDecl, L"\t")) + { + writer.WriteLine(L""); + } + } + } + } + } +} + +/*********************************************************************** +.\CPP\WFCPP_WRITEREFLECTION.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace cppcodegen + { + using namespace collections; + using namespace reflection; + using namespace reflection::description; + + void LoadTypes(WfCppConfig* config, List& tds) + { + CopyFrom( + tds, + From(config->manager->declarationTypes.Values()) + .OrderBy([](Ptr a, Ptr b) + { + return WString::Compare(a->GetTypeName(), b->GetTypeName()); + }) + .Select([](Ptr td) + { + return td.Obj(); + }) + ); + } + + void WfCppConfig::WriteHeader_Reflection(stream::StreamWriter& writer) + { + writer.WriteLine(L"/***********************************************************************"); + writer.WriteLine(L"Reflection"); + writer.WriteLine(L"***********************************************************************/"); + writer.WriteLine(L""); + List tds; + LoadTypes(this, tds); + + writer.WriteLine(L"namespace vl"); + writer.WriteLine(L"{"); + writer.WriteLine(L"\tnamespace reflection"); + writer.WriteLine(L"\t{"); + writer.WriteLine(L"\t\tnamespace description"); + writer.WriteLine(L"\t\t{"); + writer.WriteLine(L"#ifndef VCZH_DEBUG_NO_REFLECTION"); + + FOREACH(ITypeDescriptor*, td, tds) + { + writer.WriteString(L"\t\t\tDECL_TYPE_INFO("); + writer.WriteString(ConvertType(td)); + writer.WriteLine(L")"); + } + + List tdInterfaces; + CopyFrom( + tdInterfaces, + From(tds) + .Where([](ITypeDescriptor* td) + { + return td->GetTypeDescriptorFlags() == TypeDescriptorFlags::Interface; + }) + ); + { + vint processed = 0; + while (processed < tdInterfaces.Count()) + { + vint count = tdInterfaces.Count(); + for (vint i = processed; i < count; i++) + { + auto td = tdInterfaces[i]; + if (Range(0, td->GetBaseTypeDescriptorCount()) + .All([&](vint baseIndex) + { + return tdInterfaces.IndexOf(td->GetBaseTypeDescriptor(baseIndex)) < processed; + })) + { + tdInterfaces.RemoveAt(i); + tdInterfaces.Insert(processed++, td); + } + } + } + } + + if (tdInterfaces.Count() > 0) + { + FOREACH(ITypeDescriptor*, td, tdInterfaces) + { + List baseTds; + CopyFrom( + baseTds, + Range(0, td->GetBaseTypeDescriptorCount()) + .Select([&](vint index) + { + return td->GetBaseTypeDescriptor(index); + }) + .Where([&](ITypeDescriptor* baseTd) + { + return baseTd->GetTypeDescriptorFlags() != TypeDescriptorFlags::IDescriptable; + }) + ); + + writer.WriteLine(L""); + if (baseTds.Count() > 0) + { + writer.WriteString(L"\t\t\tBEGIN_INTERFACE_PROXY_SHAREDPTR("); + writer.WriteString(ConvertType(td)); + FOREACH(ITypeDescriptor*, baseTd, baseTds) + { + writer.WriteString(L", "); + writer.WriteString(ConvertType(baseTd)); + } + writer.WriteLine(L")"); + } + else + { + writer.WriteString(L"\t\t\tBEGIN_INTERFACE_PROXY_NOPARENT_SHAREDPTR("); + writer.WriteString(ConvertType(td)); + writer.WriteLine(L")"); + } + + vint methodGroupCount = td->GetMethodGroupCount(); + for (vint i = 0; i < methodGroupCount; i++) + { + auto methodGroup = td->GetMethodGroup(i); + vint methodCount = methodGroup->GetMethodCount(); + for (vint j = 0; j < methodCount; j++) + { + auto methodInfo = methodGroup->GetMethod(j); + if (!methodInfo->IsStatic()) + { + writer.WriteString(L"\t\t\t\t"); + WriteFunctionHeader(writer, methodInfo, ConvertName(methodInfo->GetName()), true); + writer.WriteLine(L" override"); + writer.WriteLine(L"\t\t\t\t{"); + + if (methodInfo->GetReturn()->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + writer.WriteString(L"\t\t\t\t\tINVOKE_INTERFACE_PROXY"); + } + else + { + writer.WriteString(L"\t\t\t\t\tINVOKEGET_INTERFACE_PROXY"); + } + + if (methodInfo->GetParameterCount() > 0) + { + writer.WriteString(L"("); + writer.WriteString(ConvertName(methodInfo->GetName())); + vint parameterCount = methodInfo->GetParameterCount(); + for (vint k = 0; k < parameterCount; k++) + { + writer.WriteString(L", "); + writer.WriteString(ConvertName(methodInfo->GetParameter(k)->GetName())); + } + writer.WriteLine(L");"); + } + else + { + writer.WriteString(L"_NOPARAMS("); + writer.WriteString(ConvertName(methodInfo->GetName())); + writer.WriteLine(L");"); + } + + writer.WriteLine(L"\t\t\t\t}"); + } + } + } + + writer.WriteString(L"\t\t\tEND_INTERFACE_PROXY("); + writer.WriteString(ConvertType(td)); + writer.WriteLine(L")"); + } + } + + writer.WriteLine(L"#endif"); + writer.WriteLine(L""); + + writer.WriteString(L"\t\t\textern bool Load"); + writer.WriteString(assemblyName); + writer.WriteLine(L"Types();"); + writer.WriteLine(L"\t\t}"); + writer.WriteLine(L"\t}"); + writer.WriteLine(L"}"); + } + + void WfCppConfig::WriteCpp_Reflection(stream::StreamWriter& writer) + { + writer.WriteLine(L"/***********************************************************************"); + writer.WriteLine(L"Reflection"); + writer.WriteLine(L"***********************************************************************/"); + writer.WriteLine(L""); + List tds; + LoadTypes(this, tds); + + writer.WriteLine(L"namespace vl"); + writer.WriteLine(L"{"); + writer.WriteLine(L"\tnamespace reflection"); + writer.WriteLine(L"\t{"); + writer.WriteLine(L"\t\tnamespace description"); + writer.WriteLine(L"\t\t{"); + writer.WriteLine(L"#ifndef VCZH_DEBUG_NO_REFLECTION"); + + FOREACH(ITypeDescriptor*, td, tds) + { + writer.WriteString(L"\t\t\tIMPL_CPP_TYPE_INFO("); + WString type = ConvertType(td); + if (type.Length() > 2 && type.Sub(0, 2) == L"::") + { + type = type.Sub(2, type.Length() - 2); + } + writer.WriteString(type); + writer.WriteLine(L")"); + } + writer.WriteLine(L""); + + writer.WriteLine(L"#define _ ,"); + FOREACH(ITypeDescriptor*, td, tds) + { + switch (td->GetTypeDescriptorFlags()) + { + case TypeDescriptorFlags::NormalEnum: + case TypeDescriptorFlags::FlagEnum: + { + writer.WriteString(L"\t\t\tBEGIN_ENUM_ITEM"); + if (td->GetTypeDescriptorFlags() == TypeDescriptorFlags::FlagEnum) + { + writer.WriteString(L"_MERGABLE"); + } + writer.WriteString(L"("); + writer.WriteString(ConvertType(td)); + writer.WriteLine(L")"); + + auto enumType = td->GetEnumType(); + vint count = enumType->GetItemCount(); + for (vint i = 0; i < count; i++) + { + writer.WriteString(L"\t\t\t\tENUM_CLASS_ITEM("); + writer.WriteString(ConvertName(enumType->GetItemName(i))); + writer.WriteLine(L")"); + } + + writer.WriteString(L"\t\t\tEND_ENUM_ITEM("); + writer.WriteString(ConvertType(td)); + writer.WriteLine(L")"); + } + break; + case TypeDescriptorFlags::Struct: + { + writer.WriteString(L"\t\t\tBEGIN_STRUCT_MEMBER("); + writer.WriteString(ConvertType(td)); + writer.WriteLine(L")"); + + vint count = td->GetPropertyCount(); + for (vint i = 0; i < count; i++) + { + writer.WriteString(L"\t\t\t\tSTRUCT_MEMBER("); + writer.WriteString(ConvertName(td->GetProperty(i)->GetName())); + writer.WriteLine(L")"); + } + + writer.WriteString(L"\t\t\tEND_STRUCT_MEMBER("); + writer.WriteString(ConvertType(td)); + writer.WriteLine(L")"); + } + break; + case TypeDescriptorFlags::Interface: + case TypeDescriptorFlags::Class: + { + if (td->GetTypeDescriptorFlags() == TypeDescriptorFlags::Interface) + { + writer.WriteString(L"\t\t\tBEGIN_INTERFACE_MEMBER("); + } + else + { + writer.WriteString(L"\t\t\tBEGIN_CLASS_MEMBER("); + } + writer.WriteString(ConvertType(td)); + writer.WriteLine(L")"); + + if (td->GetTypeDescriptorFlags() == TypeDescriptorFlags::Class) + { + auto methodGroup = td->GetConstructorGroup(); + vint methodCount = methodGroup->GetMethodCount(); + for (vint j = 0; j < methodCount; j++) + { + auto methodInfo = methodGroup->GetMethod(j); + vint parameterCount = methodInfo->GetParameterCount(); + + writer.WriteString(L"\t\t\t\tCLASS_MEMBER_CONSTRUCTOR("); + writer.WriteString(ConvertType(methodInfo->GetReturn())); + writer.WriteString(L"("); + for (vint k = 0; k < parameterCount; k++) + { + if (k > 0) + { + writer.WriteString(L", "); + } + writer.WriteString(ConvertArgumentType(methodInfo->GetParameter(k)->GetType())); + } + writer.WriteString(L")"); + + if (parameterCount > 0) + { + writer.WriteString(L", {"); + for (vint k = 0; k < parameterCount; k++) + { + if (k > 0) + { + writer.WriteString(L" _"); + } + writer.WriteString(L" L\""); + writer.WriteString(ConvertName(methodInfo->GetParameter(k)->GetName())); + writer.WriteString(L"\""); + } + writer.WriteLine(L" })"); + } + else + { + writer.WriteLine(L", NO_PARAMETER)"); + } + } + } + + vint methodGroupCount = td->GetMethodGroupCount(); + for (vint i = 0; i < methodGroupCount; i++) + { + auto methodGroup = td->GetMethodGroup(i); + vint methodCount = methodGroup->GetMethodCount(); + for (vint j = 0; j < methodCount; j++) + { + auto methodInfo = methodGroup->GetMethod(j); + if (methodInfo->IsStatic()) + { + writer.WriteString(L"\t\t\t\tCLASS_MEMBER_STATIC_METHOD"); + } + else + { + writer.WriteString(L"\t\t\t\tCLASS_MEMBER_METHOD"); + } + if (methodCount > 1) + { + writer.WriteString(L"_OVERLOAD"); + } + writer.WriteString(L"("); + writer.WriteString(ConvertName(methodInfo->GetName())); + + vint parameterCount = methodInfo->GetParameterCount(); + if (parameterCount > 0) + { + writer.WriteString(L", {"); + for (vint k = 0; k < parameterCount; k++) + { + if (k > 0) + { + writer.WriteString(L" _"); + } + writer.WriteString(L" L\""); + writer.WriteString(ConvertName(methodInfo->GetParameter(k)->GetName())); + writer.WriteString(L"\""); + } + writer.WriteString(L" }"); + } + else + { + writer.WriteString(L", NO_PARAMETER"); + } + if (methodCount > 1) + { + writer.WriteString(L", "); + auto typeDecorator = methodInfo->IsStatic() ? WString(L"(*)", false) : L"(" + ConvertType(td) + L"::*)"; + writer.WriteString(ConvertFunctionType(methodInfo, typeDecorator)); + } + writer.WriteLine(L")"); + } + } + + vint eventCount = td->GetEventCount(); + for (vint i = 0; i < eventCount; i++) + { + auto eventInfo = td->GetEvent(i); + writer.WriteString(L"\t\t\t\tCLASS_MEMBER_EVENT("); + writer.WriteString(ConvertName(eventInfo->GetName())); + writer.WriteLine(L")"); + } + + vint propertyCount = td->GetPropertyCount(); + for (vint i = 0; i < propertyCount; i++) + { + auto propertyInfo = td->GetProperty(i); + if (auto getter = propertyInfo->GetGetter()) + { + if (auto eventInfo = propertyInfo->GetValueChangedEvent()) + { + if (auto setter = propertyInfo->GetSetter()) + { + writer.WriteString(L"\t\t\t\tCLASS_MEMBER_PROPERTY_EVENT("); + writer.WriteString(ConvertName(propertyInfo->GetName())); + writer.WriteString(L", "); + writer.WriteString(ConvertName(getter->GetName())); + writer.WriteString(L", "); + writer.WriteString(ConvertName(setter->GetName())); + writer.WriteString(L", "); + writer.WriteString(ConvertName(eventInfo->GetName())); + writer.WriteLine(L")"); + } + else + { + writer.WriteString(L"\t\t\t\tCLASS_MEMBER_PROPERTY_EVENT_READONLY("); + writer.WriteString(ConvertName(propertyInfo->GetName())); + writer.WriteString(L", "); + writer.WriteString(ConvertName(getter->GetName())); + writer.WriteString(L", "); + writer.WriteString(ConvertName(eventInfo->GetName())); + writer.WriteLine(L")"); + } + } + else + { + if (auto setter = propertyInfo->GetSetter()) + { + writer.WriteString(L"\t\t\t\tCLASS_MEMBER_PROPERTY("); + writer.WriteString(ConvertName(propertyInfo->GetName())); + writer.WriteString(L", "); + writer.WriteString(ConvertName(getter->GetName())); + writer.WriteString(L", "); + writer.WriteString(ConvertName(setter->GetName())); + writer.WriteLine(L")"); + } + else + { + writer.WriteString(L"\t\t\t\tCLASS_MEMBER_PROPERTY_READONLY("); + writer.WriteString(ConvertName(propertyInfo->GetName())); + writer.WriteString(L", "); + writer.WriteString(ConvertName(getter->GetName())); + writer.WriteLine(L")"); + } + } + } + else + { + writer.WriteString(L"\t\t\t\tCLASS_MEMBER_FIELD("); + writer.WriteString(ConvertName(propertyInfo->GetName())); + writer.WriteLine(L")"); + } + } + + if (td->GetTypeDescriptorFlags() == TypeDescriptorFlags::Interface) + { + writer.WriteString(L"\t\t\tEND_INTERFACE_MEMBER("); + } + else + { + writer.WriteString(L"\t\t\tEND_CLASS_MEMBER("); + } + writer.WriteString(ConvertType(td)); + writer.WriteLine(L")"); + } + break; + default:; + } + writer.WriteLine(L""); + } + writer.WriteLine(L"#undef _"); + + writer.WriteString(L"\t\t\tclass "); + writer.WriteString(assemblyName); + writer.WriteLine(L"TypeLoader : public Object, public ITypeLoader"); + writer.WriteLine(L"\t\t\t{"); + writer.WriteLine(L"\t\t\tpublic:"); + writer.WriteLine(L"\t\t\t\tvoid Load(ITypeManager* manager)"); + writer.WriteLine(L"\t\t\t\t{"); + + FOREACH(ITypeDescriptor*, td, tds) + { + writer.WriteString(L"\t\t\t\t\tADD_TYPE_INFO("); + writer.WriteString(ConvertType(td)); + writer.WriteLine(L")"); + } + writer.WriteLine(L"\t\t\t\t}"); + writer.WriteLine(L""); + writer.WriteLine(L"\t\t\t\tvoid Unload(ITypeManager* manager)"); + writer.WriteLine(L"\t\t\t\t{"); + writer.WriteLine(L"\t\t\t\t}"); + writer.WriteLine(L"\t\t\t};"); + + writer.WriteLine(L"#endif"); + writer.WriteLine(L""); + + writer.WriteString(L"\t\t\tbool Load"); + writer.WriteString(assemblyName); + writer.WriteLine(L"Types()"); + writer.WriteLine(L"\t\t\t{"); + writer.WriteLine(L"#ifndef VCZH_DEBUG_NO_REFLECTION"); + writer.WriteLine(L"\t\t\t\tif (auto manager = GetGlobalTypeManager())"); + writer.WriteLine(L"\t\t\t\t{"); + writer.WriteString(L"\t\t\t\t\treturn manager->AddTypeLoader(MakePtr<"); + writer.WriteString(assemblyName); + writer.WriteLine(L"TypeLoader>());"); + writer.WriteLine(L"\t\t\t\t}"); + writer.WriteLine(L"#endif"); + writer.WriteLine(L"\t\t\t\treturn false;"); + writer.WriteLine(L"\t\t\t}"); + + writer.WriteLine(L"\t\t}"); + writer.WriteLine(L"\t}"); + writer.WriteLine(L"}"); + } + } + } +} + +/*********************************************************************** +.\CPP\WFCPP_WRITESTRUCT.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace cppcodegen + { + using namespace collections; + + void WfCppConfig::WriteHeader_Struct(stream::StreamWriter& writer, Ptr decl, const WString& name, const WString& prefix) + { + auto td = manager->declarationTypes[decl.Obj()].Obj(); + writer.WriteLine(prefix + L"struct " + name); + writer.WriteLine(prefix + L"{"); + FOREACH(Ptr, member, decl->members) + { + auto prop = td->GetPropertyByName(member->name.value, false); + auto defaultValue = DefaultValue(prop->GetReturn()); + if (defaultValue != L"") + { + defaultValue = L" = " + defaultValue; + } + writer.WriteLine(prefix + L"\t" + ConvertType(prop->GetReturn()) + L" " + ConvertName(member->name.value) + defaultValue + L";"); + } + writer.WriteLine(prefix + L"};"); + } + + void WfCppConfig::WriteHeader_StructOp(stream::StreamWriter& writer, Ptr decl, const WString& name, const WString& prefix) + { + using opt = Tuple; + opt ops[] = { + opt(L"==", L"false", L"true"), + opt(L"!=", L"true", L"false") + }; + for (auto op : ops) + { + writer.WriteString(prefix); + writer.WriteString(L"inline bool operator"); + writer.WriteString(op.f0); + writer.WriteString(L" (const "); + writer.WriteString(name); + writer.WriteString(L"& a, const "); + writer.WriteString(name); + writer.WriteLine(L"& b)"); + + writer.WriteString(prefix); + writer.WriteLine(L"{"); + + FOREACH(Ptr, member, decl->members) + { + writer.WriteString(prefix); + writer.WriteString(L"\tif (a."); + writer.WriteString(ConvertName(member->name.value)); + writer.WriteString(L" != b."); + writer.WriteString(ConvertName(member->name.value)); + writer.WriteString(L") return "); + writer.WriteString(op.f1); + writer.WriteLine(L";"); + } + writer.WriteString(prefix); + writer.WriteString(L"\treturn "); + writer.WriteString(op.f2); + writer.WriteLine(L";"); + + writer.WriteString(prefix); + writer.WriteLine(L"}"); + } + } + + void WfCppConfig::WriteHeader_Struct(stream::StreamWriter& writer, Ptr decl, collections::List& nss) + { + auto td = manager->declarationTypes[decl.Obj()].Obj(); + WString name; + auto prefix = WriteNamespace(writer, CppGetFullName(td), nss, name); + WriteHeader_Struct(writer, decl, name, prefix); + WriteHeader_StructOp(writer, decl, name, prefix); + } + } + } +} + +/*********************************************************************** +.\EMITTER\WFEMITTER.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace emitter + { + using namespace parsing; + using namespace reflection::description; + using namespace analyzer; + using namespace runtime; + +/*********************************************************************** +WfAttributeEvaluator +***********************************************************************/ + + WfAttributeEvaluator::WfAttributeEvaluator(analyzer::WfLexicalScopeManager* _manager) + :manager(_manager) + { + } + + Ptr WfAttributeEvaluator::GetAttribute(collections::List>& atts, const WString& category, const WString& name) + { + return From(GetAttributes(atts, category, name)).First(nullptr); + } + + collections::LazyList> WfAttributeEvaluator::GetAttributes(collections::List>& atts, const WString& category, const WString& name) + { + return From(atts) + .Where([=](Ptr att) + { + return att->category.value == category && att->name.value == name; + }); + } + + Value WfAttributeEvaluator::GetAttributeValue(Ptr att) + { + if (!att->value) + { + return Value(); + } + + { + vint index = attributeValues.Keys().IndexOf(att.Obj()); + if (index != -1) + { + return attributeValues.Values()[index]; + } + } + + if (!attributeAssembly) + { + attributeAssembly = MakePtr(); + + auto func = MakePtr(); + func->name = L""; + func->firstInstruction = 0; + + vint index = attributeAssembly->functions.Add(func); + attributeAssembly->functionByName.Add(func->name, index); + } + + attributeAssembly->insBeforeCodegen = MakePtr(); + attributeAssembly->insAfterCodegen = MakePtr(); + attributeAssembly->instructions.Clear(); + + WfCodegenContext context(attributeAssembly, manager); + { + auto recorderBefore = new ParsingGeneratedLocationRecorder(context.nodePositionsBeforeCodegen); + auto recorderAfter = new ParsingGeneratedLocationRecorder(context.nodePositionsAfterCodegen); + auto recorderOriginal = new ParsingOriginalLocationRecorder(recorderBefore); + auto recorderMultiple = new ParsingMultiplePrintNodeRecorder; + recorderMultiple->AddRecorder(recorderOriginal); + recorderMultiple->AddRecorder(recorderAfter); + + stream::MemoryStream memoryStream; + { + stream::StreamWriter streamWriter(memoryStream); + ParsingWriter parsingWriter(streamWriter, recorderMultiple); + WfPrint(att->value, L"", parsingWriter); + } + } + auto typeInfo = manager->attributes[{att->category.value, att->name.value}]; + GenerateExpressionInstructions(context, att->value, typeInfo); + attributeAssembly->instructions.Add(WfInstruction::Return()); + + if (!attributeGlobalContext) + { + attributeGlobalContext = MakePtr(attributeAssembly); + } + auto func = LoadFunction(attributeGlobalContext, L""); + auto value = func(); + attributeValues.Add(att, value); + return func(); + } + +/*********************************************************************** +WfCodegenFunctionContext +***********************************************************************/ + + WfCodegenFunctionContext::WfCodegenFunctionContext() + { + scopeContextStack.Add(new WfCodegenScopeContext); + } + + Ptr WfCodegenFunctionContext::GetCurrentScopeContext() + { + return scopeContextStack[scopeContextStack.Count() - 1]; + } + + Ptr WfCodegenFunctionContext::GetCurrentScopeContext(WfCodegenScopeType type) + { + for (vint i = scopeContextStack.Count() - 1; i >= 0; i--) + { + auto context = scopeContextStack[i]; + if (context->type == type) + { + return context; + } + } + return 0; + } + + Ptr WfCodegenFunctionContext::PushScopeContext(WfCodegenScopeType type) + { + auto context = MakePtr(); + context->type = type; + scopeContextStack.Add(context); + return context; + } + + void WfCodegenFunctionContext::PopScopeContext() + { + scopeContextStack.RemoveAt(scopeContextStack.Count() - 1); + } + +/*********************************************************************** +WfCodegenContext +***********************************************************************/ + + WfCodegenContext::WfCodegenContext(Ptr _assembly, analyzer::WfLexicalScopeManager* _manager) + :assembly(_assembly) + , manager(_manager) + { + } + + vint WfCodegenContext::AddInstruction(parsing::ParsingTreeCustomBase* node, const runtime::WfInstruction& ins) + { + auto index = assembly->instructions.Add(ins); + if (node) + { + assembly->insBeforeCodegen->instructionCodeMapping.Add(nodePositionsBeforeCodegen[node]); + assembly->insAfterCodegen->instructionCodeMapping.Add(nodePositionsAfterCodegen[node]); + } + else + { + parsing::ParsingTextRange range; + assembly->insBeforeCodegen->instructionCodeMapping.Add(range); + assembly->insAfterCodegen->instructionCodeMapping.Add(range); + } + return index; + } + + void WfCodegenContext::AddExitInstruction(parsing::ParsingTreeCustomBase* node, const runtime::WfInstruction& ins) + { + auto context = functionContext->GetCurrentScopeContext(); + context->exitInstructions.Add(ins); + context->instructionCodeMappingBeforeCodegen.Add(nodePositionsBeforeCodegen[node]); + context->instructionCodeMappingAfterCodegen.Add(nodePositionsAfterCodegen[node]); + } + + void WfCodegenContext::ApplyExitInstructions(Ptr scopeContext) + { + if (scopeContext->exitInstructions.Count() > 0) + { + CopyFrom(assembly->instructions, scopeContext->exitInstructions, true); + CopyFrom(assembly->insBeforeCodegen->instructionCodeMapping, scopeContext->instructionCodeMappingBeforeCodegen, true); + CopyFrom(assembly->insAfterCodegen->instructionCodeMapping, scopeContext->instructionCodeMappingAfterCodegen, true); + } + } + + vint WfCodegenContext::GetThisStackCount(analyzer::WfLexicalScope* scope) + { + vint count = 0; + Ptr firstConfig, methodConfig; + while (scope) + { + if (scope->typeOfThisExpr) + { + if (methodConfig) + { + count++; + if (!methodConfig->parentThisAccessable) + { + break; + } + methodConfig = nullptr; + } + } + + if (scope->functionConfig) + { + if (!firstConfig) + { + vint index = thisStackCounts.Keys().IndexOf(scope->functionConfig.Obj()); + if (index == -1) + { + firstConfig = scope->functionConfig; + } + else + { + return thisStackCounts.Values()[index]; + } + } + if (scope->functionConfig->thisAccessable) + { + methodConfig = scope->functionConfig; + } + } + scope = scope->parentScope.Obj(); + } + + if (firstConfig) + { + thisStackCounts.Add(firstConfig, count); + } + return count; + } + } + } +} + +/*********************************************************************** +.\EMITTER\WFEMITTER_ASSEMBLY.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace emitter + { + using namespace parsing; + using namespace reflection::description; + using namespace analyzer; + using namespace runtime; + using namespace typeimpl; + + typedef WfInstruction Ins; + +#define INSTRUCTION(X) context.AddInstruction(node, X) + +/*********************************************************************** +GenerateTypeCastInstructions +***********************************************************************/ + + void GenerateTypeCastInstructions(WfCodegenContext& context, Ptr expectedType, bool strongCast, WfExpression* node) + { + if (expectedType->GetTypeDescriptor() != GetTypeDescriptor()) + { + if (strongCast) + { + switch (expectedType->GetDecorator()) + { + case ITypeInfo::RawPtr: + INSTRUCTION(Ins::ConvertToType(Value::RawPtr, expectedType->GetTypeDescriptor())); + break; + case ITypeInfo::SharedPtr: + INSTRUCTION(Ins::ConvertToType(Value::SharedPtr, expectedType->GetTypeDescriptor())); + break; + case ITypeInfo::Nullable: + case ITypeInfo::TypeDescriptor: + case ITypeInfo::Generic: + INSTRUCTION(Ins::ConvertToType(Value::BoxedValue, expectedType->GetTypeDescriptor())); + break; + } + } + else + { + switch (expectedType->GetDecorator()) + { + case ITypeInfo::RawPtr: + INSTRUCTION(Ins::TryConvertToType(Value::RawPtr, expectedType->GetTypeDescriptor())); + break; + case ITypeInfo::SharedPtr: + INSTRUCTION(Ins::TryConvertToType(Value::SharedPtr, expectedType->GetTypeDescriptor())); + break; + case ITypeInfo::Nullable: + case ITypeInfo::TypeDescriptor: + case ITypeInfo::Generic: + INSTRUCTION(Ins::TryConvertToType(Value::BoxedValue, expectedType->GetTypeDescriptor())); + break; + } + } + } + } + +/*********************************************************************** +GetInstructionTypeArgument +***********************************************************************/ + + void GenerateTypeTestingInstructions(WfCodegenContext& context, Ptr expectedType, WfExpression* node) + { + if (expectedType->GetTypeDescriptor() != GetTypeDescriptor()) + { + switch (expectedType->GetDecorator()) + { + case ITypeInfo::RawPtr: + INSTRUCTION(Ins::TestType(Value::RawPtr, expectedType->GetTypeDescriptor())); + break; + case ITypeInfo::SharedPtr: + INSTRUCTION(Ins::TestType(Value::SharedPtr, expectedType->GetTypeDescriptor())); + break; + case ITypeInfo::Nullable: + case ITypeInfo::TypeDescriptor: + case ITypeInfo::Generic: + INSTRUCTION(Ins::TestType(Value::BoxedValue, expectedType->GetTypeDescriptor())); + break; + } + } + else + { + INSTRUCTION(Ins::Pop()); + INSTRUCTION(Ins::LoadValue(BoxValue(true))); + } + } + +/*********************************************************************** +GenerateTypeCastInstructions +***********************************************************************/ + + runtime::WfInsType GetInstructionTypeArgument(Ptr expectedType) + { + auto td = expectedType->GetTypeDescriptor(); + if (td == GetTypeDescriptor()) return WfInsType::Bool; + if (td == GetTypeDescriptor()) return WfInsType::I1; + if (td == GetTypeDescriptor()) return WfInsType::I2; + if (td == GetTypeDescriptor()) return WfInsType::I4; + if (td == GetTypeDescriptor()) return WfInsType::I8; + if (td == GetTypeDescriptor()) return WfInsType::U1; + if (td == GetTypeDescriptor()) return WfInsType::U2; + if (td == GetTypeDescriptor()) return WfInsType::U4; + if (td == GetTypeDescriptor()) return WfInsType::U8; + if (td == GetTypeDescriptor()) return WfInsType::F4; + if (td == GetTypeDescriptor()) return WfInsType::F8; + if (td == GetTypeDescriptor()) return WfInsType::String; + return WfInsType::Unknown; + } + +/*********************************************************************** +GenerateAssembly +***********************************************************************/ + +#define CALLBACK(EXPR) if (callback) callback->EXPR + + Ptr GenerateAssembly(analyzer::WfLexicalScopeManager* manager, IWfCompilerCallback* callback) + { + CALLBACK(OnGenerateMetadata()); + auto assembly = MakePtr(); + assembly->insBeforeCodegen = new WfInstructionDebugInfo; + assembly->insAfterCodegen = new WfInstructionDebugInfo; + + WfCodegenContext context(assembly, manager); + FOREACH_INDEXER(Ptr, module, index, manager->GetModules()) + { + auto codeBeforeCodegen = manager->GetModuleCodes()[index]; + + auto recorderBefore = new ParsingGeneratedLocationRecorder(context.nodePositionsBeforeCodegen); + auto recorderAfter = new ParsingGeneratedLocationRecorder(context.nodePositionsAfterCodegen); + auto recorderOriginal = new ParsingOriginalLocationRecorder(recorderBefore); + auto recorderMultiple = new ParsingMultiplePrintNodeRecorder; + recorderMultiple->AddRecorder(recorderOriginal); + recorderMultiple->AddRecorder(recorderAfter); + + stream::MemoryStream memoryStream; + { + stream::StreamWriter streamWriter(memoryStream); + ParsingWriter parsingWriter(streamWriter, recorderMultiple, index); + WfPrint(module, L"", parsingWriter); + } + + memoryStream.SeekFromBegin(0); + auto codeAfterCodegen = stream::StreamReader(memoryStream).ReadToEnd(); + + assembly->insBeforeCodegen->moduleCodes.Add(codeBeforeCodegen); + assembly->insAfterCodegen->moduleCodes.Add(codeAfterCodegen); + } + + if (manager->declarationTypes.Count() > 0) + { + assembly->typeImpl = new WfTypeImpl; + FOREACH(Ptr, td, manager->declarationTypes.Values()) + { + if (auto tdClass = td.Cast()) + { + assembly->typeImpl->classes.Add(tdClass); + } + else if (auto tdInterface = td.Cast()) + { + assembly->typeImpl->interfaces.Add(tdInterface); + } + else if (auto tdStruct = td.Cast()) + { + assembly->typeImpl->structs.Add(tdStruct); + } + else if (auto tdEnum = td.Cast()) + { + assembly->typeImpl->enums.Add(tdEnum); + } + } + } + + FOREACH(Ptr, module, manager->GetModules()) + { + FOREACH(Ptr, decl, module->declarations) + { + GenerateGlobalDeclarationMetadata(context, decl); + } + } + + { + auto meta = MakePtr(); + meta->name = L""; + vint functionIndex = assembly->functions.Add(meta); + assembly->functionByName.Add(meta->name, functionIndex); + + auto functionContext = MakePtr(); + functionContext->function = meta; + context.functionContext = functionContext; + + meta->firstInstruction = assembly->instructions.Count(); + FOREACH(Ptr, module, manager->GetModules()) + { + FOREACH(Ptr, decl, module->declarations) + { + GenerateInitializeInstructions(context, decl); + } + } + + // define node for INSTRUCTION + parsing::ParsingTreeCustomBase* node = nullptr; + INSTRUCTION(Ins::LoadValue(Value())); + INSTRUCTION(Ins::Return()); + + meta->lastInstruction = assembly->instructions.Count() - 1; + + context.functionContext = 0; + GenerateClosureInstructions(context, functionContext); + } + + FOREACH(Ptr, module, manager->GetModules()) + { + CALLBACK(OnGenerateCode(module)); + FOREACH(Ptr, decl, module->declarations) + { + GenerateDeclarationInstructions(context, decl); + } + } + + CALLBACK(OnGenerateDebugInfo()); + assembly->Initialize(); + return assembly; + } + +#undef CALLBACK +#undef INSTRUCTION + +/*********************************************************************** +Compile +***********************************************************************/ + + Ptr Compile(Ptr table, analyzer::WfLexicalScopeManager* manager, collections::List& moduleCodes, collections::List>& errors) + { + manager->Clear(true, true); + FOREACH(WString, code, moduleCodes) + { + manager->AddModule(code); + } + + if (manager->errors.Count() > 0) + { + CopyFrom(errors, manager->errors); + return 0; + } + + manager->Rebuild(true); + if (manager->errors.Count() > 0) + { + CopyFrom(errors, manager->errors); + return 0; + } + + return GenerateAssembly(manager); + } + + Ptr Compile(Ptr table, collections::List& moduleCodes, collections::List>& errors) + { + WfLexicalScopeManager manager(table); + return Compile(table, &manager, moduleCodes, errors); + } + } + } +} + +/*********************************************************************** +.\EMITTER\WFEMITTER_DECLARATION.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace emitter + { + using namespace collections; + using namespace parsing; + using namespace reflection::description; + using namespace analyzer; + using namespace runtime; + using namespace typeimpl; + + typedef WfInstruction Ins; + +#define INSTRUCTION(X) context.AddInstruction(node, X) + +/*********************************************************************** +GenerateInstructions(Initialize) +***********************************************************************/ + + class GenerateInitializeInstructionsVisitor : public Object, public WfDeclaration::IVisitor + { + public: + WfCodegenContext& context; + + GenerateInitializeInstructionsVisitor(WfCodegenContext& _context) + :context(_context) + { + } + + void Visit(WfNamespaceDeclaration* node)override + { + FOREACH(Ptr, decl, node->declarations) + { + GenerateInitializeInstructions(context, decl); + } + } + + void Visit(WfFunctionDeclaration* node)override + { + } + + void Visit(WfVariableDeclaration* node)override + { + auto scope = context.manager->nodeScopes[node].Obj(); + auto symbol = scope->symbols[node->name.value][0]; + vint variableIndex = context.globalVariables[symbol.Obj()]; + GenerateExpressionInstructions(context, node->expression); + INSTRUCTION(Ins::StoreGlobalVar(variableIndex)); + } + + void Visit(WfEventDeclaration* node)override + { + } + + void Visit(WfPropertyDeclaration* node)override + { + } + + void Visit(WfConstructorDeclaration* node)override + { + } + + void Visit(WfDestructorDeclaration* node)override + { + } + + void Visit(WfClassDeclaration* node)override + { + } + + void Visit(WfEnumDeclaration* node)override + { + } + + void Visit(WfStructDeclaration* node)override + { + } + + void Visit(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + }; + + void GenerateInitializeInstructions(WfCodegenContext& context, Ptr declaration) + { + GenerateInitializeInstructionsVisitor visitor(context); + declaration->Accept(&visitor); + } + +/*********************************************************************** +GenerateInstructions(Declaration) +***********************************************************************/ + + Ptr GenerateFunctionInstructions_Prolog(WfCodegenContext& context, WfLexicalScope* scope, Ptr meta, Ptr returnType, Ptr recursiveLambdaSymbol, const List>& argumentSymbols, const List>& capturedSymbols, ParsingTreeCustomBase* node) + { + auto functionContext = MakePtr(); + functionContext->function = meta; + context.functionContext = functionContext; + { + FOREACH_INDEXER(Ptr, argumentSymbol, index, argumentSymbols) + { + functionContext->arguments.Add(argumentSymbol.Obj(), index); + } + FOREACH_INDEXER(Ptr, capturedSymbol, index, capturedSymbols) + { + functionContext->capturedVariables.Add(capturedSymbol.Obj(), index); + } + } + if (recursiveLambdaSymbol) + { + vint variableIndex = meta->argumentNames.Count() + meta->localVariableNames.Add(L"" + recursiveLambdaSymbol->name); + functionContext->localVariables.Add(recursiveLambdaSymbol.Obj(), variableIndex); + } + + meta->firstInstruction = context.assembly->instructions.Count(); + if (recursiveLambdaSymbol) + { + INSTRUCTION(Ins::LoadClosureContext()); + INSTRUCTION(Ins::LoadFunction(context.assembly->functions.IndexOf(meta.Obj()))); + INSTRUCTION(Ins::CreateClosure()); + INSTRUCTION(Ins::StoreLocalVar(functionContext->localVariables[recursiveLambdaSymbol.Obj()])); + } + return functionContext; + } + + void GenerateFunctionInstructions_Epilog(WfCodegenContext& context, WfLexicalScope* scope, Ptr meta, Ptr returnType, Ptr recursiveLambdaSymbol, const List>& argumentSymbols, const List>& capturedSymbols, Ptr functionContext, ParsingTreeCustomBase* node) + { + Value result; + if (returnType->GetDecorator() == ITypeInfo::TypeDescriptor) + { + if (auto vt = returnType->GetTypeDescriptor()->GetValueType()) + { + result = vt->CreateDefault(); + } + } + INSTRUCTION(Ins::LoadValue(Value())); + INSTRUCTION(Ins::Return()); + meta->lastInstruction = context.assembly->instructions.Count() - 1; + context.functionContext = 0; + + GenerateClosureInstructions(context, functionContext); + } + + void GenerateFunctionInstructions(WfCodegenContext& context, WfLexicalScope* scope, Ptr meta, Ptr returnType, Ptr recursiveLambdaSymbol, const List>& argumentSymbols, const List>& capturedSymbols, Ptr statementBody, ParsingTreeCustomBase* node) + { + auto functionContext = GenerateFunctionInstructions_Prolog(context, scope, meta, returnType, recursiveLambdaSymbol, argumentSymbols, capturedSymbols, node); + GenerateStatementInstructions(context, statementBody); + GenerateFunctionInstructions_Epilog(context, scope, meta, returnType, recursiveLambdaSymbol, argumentSymbols, capturedSymbols, functionContext, node); + } + + void GenerateFunctionInstructions(WfCodegenContext& context, WfLexicalScope* scope, Ptr meta, Ptr returnType, Ptr recursiveLambdaSymbol, const List>& argumentSymbols, const List>& capturedSymbols, Ptr expressionBody, ParsingTreeCustomBase* node) + { + auto functionContext = GenerateFunctionInstructions_Prolog(context, scope, meta, returnType, recursiveLambdaSymbol, argumentSymbols, capturedSymbols, node); + GenerateExpressionInstructions(context, expressionBody); + INSTRUCTION(Ins::Return()); + GenerateFunctionInstructions_Epilog(context, scope, meta, returnType, recursiveLambdaSymbol, argumentSymbols, capturedSymbols, functionContext, node); + } + + void GenerateFunctionDeclarationInstructions(WfCodegenContext& context, WfFunctionDeclaration* node, WfLexicalScope* scope, Ptr meta, Ptr recursiveLambdaSymbol) + { + List> argumentSymbols, capturedSymbols; + { + FOREACH(Ptr, argument, node->arguments) + { + auto symbol = scope->symbols[argument->name.value][0]; + argumentSymbols.Add(symbol); + } + + vint index = context.manager->lambdaCaptures.Keys().IndexOf(node); + if (index != -1) + { + auto capture = context.manager->lambdaCaptures.Values()[index]; + FOREACH(Ptr, symbol, capture->symbols) + { + capturedSymbols.Add(symbol); + } + } + } + + auto returnType = CreateTypeInfoFromType(scope, node->returnType); + GenerateFunctionInstructions(context, scope, meta, returnType, recursiveLambdaSymbol, argumentSymbols, capturedSymbols, node->statement, node); + } + + class GenerateClassMemberInstructionsVisitor : public Object, public WfDeclaration::IVisitor + { + public: + WfCodegenContext& context; + Ptr classDecl; + + GenerateClassMemberInstructionsVisitor(WfCodegenContext& _context, Ptr _classDecl) + :context(_context) + , classDecl(_classDecl) + { + } + + void Visit(WfNamespaceDeclaration* node)override + { + } + + void Visit(WfFunctionDeclaration* node)override + { + if (node->classMember->kind == WfClassMemberKind::Static) + { + GenerateDeclarationInstructions(context, node); + } + else if (classDecl->kind == WfClassKind::Class) + { + GenerateDeclarationInstructions(context, node); + } + } + + void Visit(WfVariableDeclaration* node)override + { + } + + void Visit(WfEventDeclaration* node)override + { + } + + void Visit(WfPropertyDeclaration* node)override + { + } + + class InitializeFieldVisitor + : public empty_visitor::DeclarationVisitor + { + public: + WfCodegenContext& context; + + InitializeFieldVisitor(WfCodegenContext& _context) + :context(_context) + { + } + + void Dispatch(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + + void Visit(WfVariableDeclaration* node)override + { + auto info = context.manager->declarationMemberInfos[node].Cast().Obj(); + GenerateExpressionInstructions(context, node->expression); + INSTRUCTION(Ins::LoadCapturedVar(0)); + INSTRUCTION(Ins::SetProperty(info)); + } + }; + + void Visit(WfConstructorDeclaration* node)override + { + auto meta = context.assembly->functions[context.constructors[node]]; + auto functionContext = MakePtr(); + functionContext->function = meta; + context.functionContext = functionContext; + meta->firstInstruction = context.assembly->instructions.Count(); + + auto scope = context.manager->nodeScopes[node].Obj(); + { + FOREACH_INDEXER(Ptr, argument, index, node->arguments) + { + auto symbol = scope->symbols[argument->name.value][0]; + functionContext->arguments.Add(symbol.Obj(), index); + } + } + + if (classDecl->baseTypes.Count() > 0) + { + auto td = scope->parentScope->typeOfThisExpr; + vint count = td->GetBaseTypeDescriptorCount(); + for (vint i = 0; i < count; i++) + { + auto baseTd = td->GetBaseTypeDescriptor(i); + auto ctor = context.manager->baseConstructorCallResolvings[{node, baseTd}]; + if (ctor.key) + { + FOREACH(Ptr, argument, ctor.key->arguments) + { + GenerateExpressionInstructions(context, argument); + } + INSTRUCTION(Ins::LoadCapturedVar(0)); + INSTRUCTION(Ins::InvokeBaseCtor(ctor.value, ctor.key->arguments.Count())); + } + else + { + INSTRUCTION(Ins::LoadCapturedVar(0)); + INSTRUCTION(Ins::InvokeBaseCtor(ctor.value, 0)); + } + INSTRUCTION(Ins::Pop()); + } + } + + { + InitializeFieldVisitor visitor(context); + FOREACH(Ptr, memberDecl, classDecl->declarations) + { + memberDecl->Accept(&visitor); + } + } + GenerateStatementInstructions(context, node->statement); + + INSTRUCTION(Ins::LoadValue(Value())); + INSTRUCTION(Ins::Return()); + meta->lastInstruction = context.assembly->instructions.Count() - 1; + context.functionContext = 0; + GenerateClosureInstructions(context, functionContext); + } + + void Visit(WfDestructorDeclaration* node)override + { + auto meta = context.assembly->functions[context.destructors[node]]; + auto functionContext = MakePtr(); + functionContext->function = meta; + context.functionContext = functionContext; + meta->firstInstruction = context.assembly->instructions.Count(); + + auto scope = context.manager->nodeScopes[node].Obj(); + GenerateStatementInstructions(context, node->statement); + + INSTRUCTION(Ins::LoadValue(Value())); + INSTRUCTION(Ins::Return()); + meta->lastInstruction = context.assembly->instructions.Count() - 1; + context.functionContext = 0; + GenerateClosureInstructions(context, functionContext); + } + + void Visit(WfClassDeclaration* node)override + { + GenerateDeclarationInstructions(context, node); + } + + void Visit(WfEnumDeclaration* node)override + { + } + + void Visit(WfStructDeclaration* node)override + { + } + + void Visit(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + }; + + class GenerateDeclarationInstructionsVisitor : public Object, public WfDeclaration::IVisitor + { + public: + WfCodegenContext& context; + + GenerateDeclarationInstructionsVisitor(WfCodegenContext& _context) + :context(_context) + { + } + + void Visit(WfNamespaceDeclaration* node)override + { + FOREACH(Ptr, decl, node->declarations) + { + GenerateDeclarationInstructions(context, decl); + } + } + + void Visit(WfFunctionDeclaration* node)override + { + auto scope = context.manager->nodeScopes[node].Obj(); + auto symbol = context.manager->GetDeclarationSymbol(scope, node); + auto meta = context.assembly->functions[context.globalFunctions[symbol.Obj()]]; + GenerateFunctionDeclarationInstructions(context, node, scope, meta, 0); + } + + void Visit(WfVariableDeclaration* node)override + { + } + + void Visit(WfEventDeclaration* node)override + { + } + + void Visit(WfPropertyDeclaration* node)override + { + } + + void Visit(WfConstructorDeclaration* node)override + { + } + + void Visit(WfDestructorDeclaration* node)override + { + } + + void Visit(WfClassDeclaration* node)override + { + FOREACH(Ptr, memberDecl, node->declarations) + { + GenerateClassMemberInstructionsVisitor visitor(context, node); + memberDecl->Accept(&visitor); + } + } + + void Visit(WfEnumDeclaration* node)override + { + } + + void Visit(WfStructDeclaration* node)override + { + } + + void Visit(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + }; + + void GenerateDeclarationInstructions(WfCodegenContext& context, Ptr declaration) + { + GenerateDeclarationInstructionsVisitor visitor(context); + declaration->Accept(&visitor); + } + +/*********************************************************************** +GenerateInstructions(Closure) +***********************************************************************/ + + void GenerateClosureInstructions_Function(WfCodegenContext& context, vint functionIndex, WfFunctionDeclaration* node, bool createInterface) + { + auto scope = context.manager->nodeScopes[node].Obj(); + auto meta = context.assembly->functions[functionIndex]; + GenerateFunctionDeclarationMetadata(context, node, meta); + Ptr recursiveLambdaSymbol; + if (!createInterface && node->name.value != L"") + { + recursiveLambdaSymbol = scope->symbols[node->name.value][0]; + } + GenerateFunctionDeclarationInstructions(context, node, scope, meta, recursiveLambdaSymbol); + } + + void GenerateClosureInstructions_Ordered(WfCodegenContext& context, vint functionIndex, WfOrderedLambdaExpression* node) + { + auto scope = context.manager->nodeScopes[node].Obj(); + List> argumentSymbols, capturedSymbols; + CopyFrom( + argumentSymbols, + Range(0, scope->symbols.Count()) + .Select([scope](vint index)->Ptr{return scope->symbols.GetByIndex(index)[0];}) + .OrderBy([](Ptr a, Ptr b) + { + vint aId = wtoi(a->name.Sub(1, a->name.Length() - 1)); + vint bId = wtoi(b->name.Sub(1, a->name.Length() - 1)); + return aId - bId; + }) + ); + + auto meta = context.assembly->functions[functionIndex]; + FOREACH(Ptr, symbol, argumentSymbols) + { + meta->argumentNames.Add(symbol->name); + } + { + auto capture = context.manager->lambdaCaptures.Get(node); + FOREACH(Ptr, symbol, capture->symbols) + { + meta->capturedVariableNames.Add(L"" + symbol->name); + capturedSymbols.Add(symbol); + } + + vint count = context.GetThisStackCount(scope); + for (vint i = 0; i < count; i++) + { + meta->capturedVariableNames.Add(L"" + itow(i)); + } + } + + auto result = context.manager->expressionResolvings[node]; + auto returnType = CopyTypeInfo(result.type->GetElementType()->GetGenericArgument(0)); + GenerateFunctionInstructions(context, scope, meta, returnType, 0, argumentSymbols, capturedSymbols, node->body, node); + } + + void GenerateClosureInstructions(WfCodegenContext& context, Ptr functionContext) + { + for (vint i = 0; i < functionContext->closuresToCodegen.Count(); i++) + { + vint functionIndex = functionContext->closuresToCodegen.Keys()[i]; + auto closure = functionContext->closuresToCodegen.Values()[i]; + + if (closure.functionExpression) + { + GenerateClosureInstructions_Function(context, functionIndex, closure.functionExpression->function.Obj(), false); + } + else if (closure.orderedLambdaExpression) + { + GenerateClosureInstructions_Ordered(context, functionIndex, closure.orderedLambdaExpression); + } + else if (closure.functionDeclaration) + { + GenerateClosureInstructions_Function(context, functionIndex, closure.functionDeclaration, true); + } + } + } + +#undef INSTRUCTION + } + } +} + +/*********************************************************************** +.\EMITTER\WFEMITTER_EXPRESSION.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace emitter + { + using namespace collections; + using namespace parsing; + using namespace reflection; + using namespace reflection::description; + using namespace analyzer; + using namespace runtime; + + typedef WfInstruction Ins; + +#define INSTRUCTION(X) context.AddInstruction(node, X) + +/*********************************************************************** +GenerateInstructions(Expression) +***********************************************************************/ + + class GenerateExpressionInstructionsVisitor + : public Object + , public WfExpression::IVisitor + { + public: + WfCodegenContext& context; + + GenerateExpressionInstructionsVisitor(WfCodegenContext& _context) + :context(_context) + { + } + + static void GenerateLoadSymbolInstructions(WfCodegenContext& context, WfLexicalSymbol* symbol, parsing::ParsingTreeCustomBase* node) + { + vint index = -1; + if ((index = context.globalFunctions.Keys().IndexOf(symbol)) != -1) + { + vint functionIndex = context.globalFunctions.Values()[index]; + INSTRUCTION(Ins::CreateClosureContext(0)); + INSTRUCTION(Ins::LoadFunction(functionIndex)); + INSTRUCTION(Ins::CreateClosure()); + } + else if ((index = context.globalVariables.Keys().IndexOf(symbol)) != -1) + { + vint variableIndex = context.globalVariables.Values()[index]; + INSTRUCTION(Ins::LoadGlobalVar(variableIndex)); + } + else if ((index = context.functionContext->capturedVariables.Keys().IndexOf(symbol)) != -1) + { + vint variableIndex = context.functionContext->capturedVariables.Values()[index]; + INSTRUCTION(Ins::LoadCapturedVar(variableIndex)); + } + else if ((index = context.functionContext->localVariables.Keys().IndexOf(symbol)) != -1) + { + vint variableIndex = context.functionContext->localVariables.Values()[index]; + INSTRUCTION(Ins::LoadLocalVar(variableIndex)); + } + else if ((index = context.functionContext->arguments.Keys().IndexOf(symbol)) != -1) + { + vint variableIndex = context.functionContext->arguments.Values()[index]; + INSTRUCTION(Ins::LoadLocalVar(variableIndex)); + } + else if ((index = context.closureFunctions.Keys().IndexOf(symbol)) != -1) + { + vint functionIndex = context.closureFunctions.Values()[index]; + INSTRUCTION(Ins::LoadClosureContext()); + INSTRUCTION(Ins::LoadFunction(functionIndex)); + INSTRUCTION(Ins::CreateClosure()); + } + else + { + CHECK_FAIL(L"GenerateExpressionInstructionsVisitor::GenerateLoadSymbolInstructions(WfCodegenContext&, WfLexicalSymbol*, ParsingTreeCustomBase*)#Internal error, cannot find any record of this symbol."); + } + } + + static vint PushCapturedThisValues(WfCodegenContext& context, WfLexicalScope* lambdaScopeParent, ParsingTreeCustomBase* node) + { + auto scope = lambdaScopeParent; + while (scope) + { + if (scope->functionConfig) + { + vint parentThisCount = context.GetThisStackCount(scope); + if (scope->functionConfig->lambda) + { + auto capture = context.manager->lambdaCaptures[scope->ownerNode.Obj()]; + vint captureCount = capture->symbols.Count(); + for (vint i = 0; i < parentThisCount; i++) + { + INSTRUCTION(Ins::LoadCapturedVar(captureCount + i)); + } + } + else if (parentThisCount > 0) + { + CHECK_ERROR(parentThisCount == 1, L"GenerateExpressionInstructionsVisitor::PushCapturedThisValues(WfCodegenContext&, WfLexicalScope*, ParsingTreeCustomBase*)#Internal error, wrong parentThisCount value."); + INSTRUCTION(Ins::LoadCapturedVar(0)); + } + return parentThisCount; + } + scope = scope->parentScope.Obj(); + } + return 0; + } + + static vint AddClosure(WfCodegenContext& context, WfCodegenLambdaContext lc, const Func& getName) + { + auto meta = MakePtr(); + vint functionIndex = context.assembly->functions.Add(meta); + meta->name = getName(functionIndex); + context.assembly->functionByName.Add(meta->name, functionIndex); + context.functionContext->closuresToCodegen.Add(functionIndex, lc); + return functionIndex; + } + + void VisitReferenceExpression(WfExpression* node, const WString& name) + { + auto result = context.manager->expressionResolvings[node]; + if (result.symbol) + { + GenerateLoadSymbolInstructions(context, result.symbol.Obj(), node); + } + else if (result.methodInfo) + { + if (result.methodInfo->IsStatic()) + { + INSTRUCTION(Ins::LoadValue(Value())); + } + else + { + VisitThisExpression(node, result.methodInfo->GetOwnerTypeDescriptor()); + } + INSTRUCTION(Ins::LoadMethodClosure(result.methodInfo)); + } + else if (result.propertyInfo) + { + if (auto getter = result.propertyInfo->GetGetter()) + { + VisitThisExpression(node, getter->GetOwnerTypeDescriptor()); + INSTRUCTION(Ins::InvokeMethod(getter, 0)); + } + else + { + VisitThisExpression(node, result.propertyInfo->GetOwnerTypeDescriptor()); + INSTRUCTION(Ins::GetProperty(result.propertyInfo)); + } + } + else + { + if ((result.type->GetTypeDescriptor()->GetTypeDescriptorFlags() & TypeDescriptorFlags::EnumType) != TypeDescriptorFlags::Undefined) + { + auto enumType = result.type->GetTypeDescriptor()->GetEnumType(); + vint index = enumType->IndexOfItem(name); + if (index != -1) + { + auto intValue = enumType->GetItemValue(index); + INSTRUCTION(Ins::LoadValue(enumType->ToEnum(intValue))); + return; + } + } + CHECK_FAIL(L"GenerateExpressionInstructionsVisitor::VisitReferenceExpression(WfExpression*, const WString&)#Internal error, cannot find any record of this expression."); + } + } + + void VisitThisExpression(WfExpression* node, ITypeDescriptor* td) + { + auto scope = context.manager->nodeScopes[node].Obj(); + vint count = context.GetThisStackCount(scope); + vint offset = 0; + + Ptr capture; + Ptr lastConfig; + while (scope) + { + if (scope->typeOfThisExpr) + { + if (scope->typeOfThisExpr->CanConvertTo(td)) + { + if (capture) + { + INSTRUCTION(Ins::LoadCapturedVar(capture->symbols.Count() + count - offset - 1)); + } + else + { + INSTRUCTION(Ins::LoadCapturedVar(0)); + } + return; + } + else + { + offset++; + } + + if (lastConfig) + { + if (!lastConfig->parentThisAccessable) + { + break; + } + } + } + + if (scope->functionConfig) + { + lastConfig = scope->functionConfig; + if (!capture) + { + vint index = context.manager->lambdaCaptures.Keys().IndexOf(scope->ownerNode.Obj()); + if (index != -1) + { + capture = context.manager->lambdaCaptures.Values()[index]; + } + } + } + + scope = scope->parentScope.Obj(); + } + CHECK_FAIL(L"GenerateExpressionInstructionsVisitor::VisitThisExpression(WfExpression*, ITypeDescriptor*)#Internal error, cannot find any record of the this value."); + } + + void Visit(WfThisExpression* node)override + { + auto scope = context.manager->nodeScopes[node].Obj(); + while (scope) + { + if (scope->functionConfig) + { + if (scope->functionConfig->thisAccessable) + { + if (scope->functionConfig->lambda) + { + auto capture = context.manager->lambdaCaptures[scope->ownerNode.Obj()]; + auto count = context.GetThisStackCount(scope); + INSTRUCTION(Ins::LoadCapturedVar(capture->symbols.Count() + count - 1)); + } + else + { + INSTRUCTION(Ins::LoadCapturedVar(0)); + } + return; + } + CHECK_FAIL(L"GenerateExpressionInstructionsVisitor::Visit(WfThisExpression*)#Internal error, this expression is illegal here."); + } + scope = scope->parentScope.Obj(); + } + CHECK_FAIL(L"GenerateExpressionInstructionsVisitor::Visit(WfThisExpression*)#Internal error, this expression is illegal here."); + } + + void Visit(WfTopQualifiedExpression* node)override + { + VisitReferenceExpression(node, node->name.value); + } + + void Visit(WfReferenceExpression* node)override + { + VisitReferenceExpression(node, node->name.value); + } + + void Visit(WfOrderedNameExpression* node)override + { + VisitReferenceExpression(node, node->name.value); + } + + void Visit(WfOrderedLambdaExpression* node)override + { + auto scope = context.manager->nodeScopes[node].Obj(); + + WfCodegenLambdaContext lc; + lc.orderedLambdaExpression = node; + auto functionIndex = AddClosure(context, lc, [=](vint index) + { + return L" in " + context.functionContext->function->name; + }); + + auto capture = context.manager->lambdaCaptures.Get(node); + FOREACH(Ptr, symbol, capture->symbols) + { + GenerateLoadSymbolInstructions(context, symbol.Obj(), node); + } + vint thisCount = PushCapturedThisValues(context, scope->parentScope.Obj(), node); + INSTRUCTION(Ins::CreateClosureContext(capture->symbols.Count() + thisCount)); + INSTRUCTION(Ins::LoadFunction(functionIndex)); + INSTRUCTION(Ins::CreateClosure()); + } + + void Visit(WfMemberExpression* node)override + { + auto result = context.manager->expressionResolvings[node]; + if (result.propertyInfo) + { + GenerateExpressionInstructions(context, node->parent); + if (result.propertyInfo->GetGetter()) + { + INSTRUCTION(Ins::InvokeMethod(result.propertyInfo->GetGetter(), 0)); + } + else + { + INSTRUCTION(Ins::GetProperty(result.propertyInfo)); + } + } + else + { + GenerateExpressionInstructions(context, node->parent); + INSTRUCTION(Ins::LoadMethodClosure(result.methodInfo)); + } + } + + void Visit(WfChildExpression* node)override + { + VisitReferenceExpression(node, node->name.value); + } + + void Visit(WfLiteralExpression* node)override + { + switch (node->value) + { + case WfLiteralValue::Null: + INSTRUCTION(Ins::LoadValue(Value())); + break; + case WfLiteralValue::True: + INSTRUCTION(Ins::LoadValue(BoxValue(true))); + break; + case WfLiteralValue::False: + INSTRUCTION(Ins::LoadValue(BoxValue(false))); + break; + } + } + + void Visit(WfFloatingExpression* node)override + { + auto result = context.manager->expressionResolvings[node]; + auto td = result.type->GetTypeDescriptor(); + Value output; + td->GetSerializableType()->Deserialize(node->value.value, output); + INSTRUCTION(Ins::LoadValue(output)); + } + + void Visit(WfIntegerExpression* node)override + { + auto result = context.manager->expressionResolvings[node]; + auto td = result.type->GetTypeDescriptor(); + Value output; + td->GetSerializableType()->Deserialize(node->value.value, output); + INSTRUCTION(Ins::LoadValue(output)); + } + + void Visit(WfStringExpression* node)override + { + INSTRUCTION(Ins::LoadValue(BoxValue(node->value.value))); + } + + void Visit(WfUnaryExpression* node)override + { + auto type = GenerateExpressionInstructions(context, node->operand); + switch (node->op) + { + case WfUnaryOperator::Not: + INSTRUCTION(Ins::OpNot(GetInstructionTypeArgument(type))); + break; + case WfUnaryOperator::Positive: + INSTRUCTION(Ins::OpPositive(GetInstructionTypeArgument(type))); + break; + case WfUnaryOperator::Negative: + INSTRUCTION(Ins::OpNegative(GetInstructionTypeArgument(type))); + break; + } + } + + void Visit(WfBinaryExpression* node)override + { + if (node->op == WfBinaryOperator::Assign) + { + if (auto binary = node->first.Cast()) + { + auto result = context.manager->expressionResolvings[binary->first.Obj()]; + auto containerType = result.expectedType ? result.expectedType : result.type; + auto methodInfo = containerType->GetTypeDescriptor()->GetMethodGroupByName(L"Set", true)->GetMethod(0); + GenerateExpressionInstructions(context, binary->second); + INSTRUCTION(Ins::Duplicate(0)); + GenerateExpressionInstructions(context, node->second); + GenerateExpressionInstructions(context, binary->first); + INSTRUCTION(Ins::InvokeMethod(methodInfo, 2)); + INSTRUCTION(Ins::Pop()); + } + else if (auto member = node->first.Cast()) + { + auto result = context.manager->expressionResolvings[member.Obj()]; + if (auto methodInfo = result.propertyInfo->GetSetter()) + { + GenerateExpressionInstructions(context, node->second); + INSTRUCTION(Ins::Duplicate(0)); + GenerateExpressionInstructions(context, member->parent); + INSTRUCTION(Ins::InvokeMethod(methodInfo, 1)); + INSTRUCTION(Ins::Pop()); + } + else + { + GenerateExpressionInstructions(context, node->second); + INSTRUCTION(Ins::Duplicate(0)); + GenerateExpressionInstructions(context, member->parent); + INSTRUCTION(Ins::SetProperty(result.propertyInfo)); + } + } + else + { + GenerateExpressionInstructions(context, node->second); + INSTRUCTION(Ins::Duplicate(0)); + auto result = context.manager->expressionResolvings[node->first.Obj()]; + vint index = -1; + if ((index = context.globalVariables.Keys().IndexOf(result.symbol.Obj())) != -1) + { + vint variableIndex = context.globalVariables.Values()[index]; + INSTRUCTION(Ins::StoreGlobalVar(variableIndex)); + } + else if ((index = context.functionContext->localVariables.Keys().IndexOf(result.symbol.Obj())) != -1) + { + vint variableIndex = context.functionContext->localVariables.Values()[index]; + INSTRUCTION(Ins::StoreLocalVar(variableIndex)); + } + else if ((index = context.functionContext->capturedVariables.Keys().IndexOf(result.symbol.Obj())) != -1) + { + vint variableIndex = context.functionContext->capturedVariables.Values()[index]; + INSTRUCTION(Ins::StoreCapturedVar(variableIndex)); + } + else if (result.propertyInfo) + { + if (auto setter = result.propertyInfo->GetSetter()) + { + VisitThisExpression(node, setter->GetOwnerTypeDescriptor()); + INSTRUCTION(Ins::InvokeMethod(setter, 1)); + INSTRUCTION(Ins::Pop()); + } + else + { + VisitThisExpression(node, result.propertyInfo->GetOwnerTypeDescriptor()); + INSTRUCTION(Ins::SetProperty(result.propertyInfo)); + } + } + else + { + CHECK_FAIL(L"GenerateExpressionInstructionsVisitor::Visit(WfBinaryExpression*)#Internal error, cannot find any record of this assignable symbol."); + } + } + } + else if (node->op == WfBinaryOperator::Index) + { + auto result = context.manager->expressionResolvings[node->first.Obj()]; + auto containerType = result.expectedType ? result.expectedType : result.type; + auto methodInfo = containerType->GetTypeDescriptor()->GetMethodGroupByName(L"Get", true)->GetMethod(0); + GenerateExpressionInstructions(context, node->second); + GenerateExpressionInstructions(context, node->first); + INSTRUCTION(Ins::InvokeMethod(methodInfo, 1)); + } + else if (node->op == WfBinaryOperator::Union) + { + auto type = context.manager->expressionResolvings[node].type; + if (type->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + GenerateExpressionInstructions(context, node->first, type); + GenerateExpressionInstructions(context, node->second, type); + INSTRUCTION(Ins::OpConcat()); + } + else + { + GenerateExpressionInstructions(context, node->first, type); + INSTRUCTION(Ins::ConvertToType(Value::BoxedValue, description::GetTypeDescriptor())); + GenerateExpressionInstructions(context, node->second, type); + INSTRUCTION(Ins::ConvertToType(Value::BoxedValue, description::GetTypeDescriptor())); + INSTRUCTION(Ins::OpAnd(WfInsType::U8)); + INSTRUCTION(Ins::ConvertToType(Value::BoxedValue, type->GetTypeDescriptor())); + } + } + else if (node->op == WfBinaryOperator::Intersect) + { + auto type = context.manager->expressionResolvings[node].type; + GenerateExpressionInstructions(context, node->first, type); + INSTRUCTION(Ins::ConvertToType(Value::BoxedValue, description::GetTypeDescriptor())); + GenerateExpressionInstructions(context, node->second, type); + INSTRUCTION(Ins::ConvertToType(Value::BoxedValue, description::GetTypeDescriptor())); + INSTRUCTION(Ins::OpOr(WfInsType::U8)); + INSTRUCTION(Ins::ConvertToType(Value::BoxedValue, type->GetTypeDescriptor())); + } + else if (node->op == WfBinaryOperator::FailedThen) + { + auto result = context.manager->expressionResolvings[node]; + vint trapInstruction = INSTRUCTION(Ins::InstallTry(-1)); + GenerateExpressionInstructions(context, node->first, result.type); + INSTRUCTION(Ins::UninstallTry(1)); + vint finishInstruction = INSTRUCTION(Ins::Jump(-1)); + + context.assembly->instructions[trapInstruction].indexParameter = context.assembly->instructions.Count(); + GenerateExpressionInstructions(context, node->second, result.type); + + context.assembly->instructions[finishInstruction].indexParameter = context.assembly->instructions.Count(); + } + else + { + Ptr mergedType; + switch (node->op) + { + case WfBinaryOperator::Exp: + case WfBinaryOperator::Add: + case WfBinaryOperator::Sub: + case WfBinaryOperator::Mul: + case WfBinaryOperator::Div: + case WfBinaryOperator::Mod: + case WfBinaryOperator::Shl: + case WfBinaryOperator::Shr: + { + auto result = context.manager->expressionResolvings[node]; + mergedType = result.type; + } + break; + default: + { + auto firstResult = context.manager->expressionResolvings[node->first.Obj()]; + auto secondResult = context.manager->expressionResolvings[node->second.Obj()]; + auto firstType = firstResult.expectedType ? firstResult.expectedType : firstResult.type; + auto secondType = secondResult.expectedType ? secondResult.expectedType : secondResult.type; + if (node->op == WfBinaryOperator::EQ || node->op == WfBinaryOperator::NE) + { + if (firstType->GetDecorator() == ITypeInfo::RawPtr || firstType->GetDecorator() == ITypeInfo::SharedPtr) + { + GenerateExpressionInstructions(context, node->first); + GenerateExpressionInstructions(context, node->second); + INSTRUCTION(Ins::CompareReference()); + if (node->op == WfBinaryOperator::NE) + { + INSTRUCTION(Ins::OpNot(WfInsType::Bool)); + } + return; + } + } + + mergedType = GetMergedType(firstType, secondType); + if (node->op == WfBinaryOperator::EQ || node->op == WfBinaryOperator::NE) + { + GenerateExpressionInstructions(context, node->first); + GenerateExpressionInstructions(context, node->second); + INSTRUCTION(Ins::CompareValue()); + if (node->op == WfBinaryOperator::NE) + { + INSTRUCTION(Ins::OpNot(WfInsType::Bool)); + } + return; + } + } + } + + GenerateExpressionInstructions(context, node->first, mergedType); + GenerateExpressionInstructions(context, node->second, mergedType); + + switch (node->op) + { + case WfBinaryOperator::Exp: + INSTRUCTION(Ins::OpExp(GetInstructionTypeArgument(mergedType))); + break; + case WfBinaryOperator::Add: + INSTRUCTION(Ins::OpAdd(GetInstructionTypeArgument(mergedType))); + break; + case WfBinaryOperator::Sub: + INSTRUCTION(Ins::OpSub(GetInstructionTypeArgument(mergedType))); + break; + case WfBinaryOperator::Mul: + INSTRUCTION(Ins::OpMul(GetInstructionTypeArgument(mergedType))); + break; + case WfBinaryOperator::Div: + INSTRUCTION(Ins::OpDiv(GetInstructionTypeArgument(mergedType))); + break; + case WfBinaryOperator::Mod: + INSTRUCTION(Ins::OpMod(GetInstructionTypeArgument(mergedType))); + break; + case WfBinaryOperator::Shl: + INSTRUCTION(Ins::OpShl(GetInstructionTypeArgument(mergedType))); + break; + case WfBinaryOperator::Shr: + INSTRUCTION(Ins::OpShr(GetInstructionTypeArgument(mergedType))); + break; + case WfBinaryOperator::LT: + INSTRUCTION(Ins::CompareLiteral(GetInstructionTypeArgument(mergedType))); + INSTRUCTION(Ins::OpLT()); + break; + case WfBinaryOperator::GT: + INSTRUCTION(Ins::CompareLiteral(GetInstructionTypeArgument(mergedType))); + INSTRUCTION(Ins::OpGT()); + break; + case WfBinaryOperator::LE: + INSTRUCTION(Ins::CompareLiteral(GetInstructionTypeArgument(mergedType))); + INSTRUCTION(Ins::OpLE()); + break; + case WfBinaryOperator::GE: + INSTRUCTION(Ins::CompareLiteral(GetInstructionTypeArgument(mergedType))); + INSTRUCTION(Ins::OpGE()); + break; + case WfBinaryOperator::EQ: + INSTRUCTION(Ins::CompareLiteral(GetInstructionTypeArgument(mergedType))); + INSTRUCTION(Ins::OpEQ()); + break; + case WfBinaryOperator::NE: + INSTRUCTION(Ins::CompareLiteral(GetInstructionTypeArgument(mergedType))); + INSTRUCTION(Ins::OpNE()); + break; + case WfBinaryOperator::Xor: + INSTRUCTION(Ins::OpXor(GetInstructionTypeArgument(mergedType))); + break; + case WfBinaryOperator::And: + INSTRUCTION(Ins::OpAnd(GetInstructionTypeArgument(mergedType))); + break; + case WfBinaryOperator::Or: + INSTRUCTION(Ins::OpOr(GetInstructionTypeArgument(mergedType))); + break; + default:; + } + } + } + + void Visit(WfLetExpression* node)override + { + auto scope = context.manager->nodeScopes[node].Obj(); + Array variableIndices(node->variables.Count()); + auto function = context.functionContext->function; + FOREACH_INDEXER(Ptr, var, index, node->variables) + { + auto symbol = scope->symbols[var->name.value][0]; + vint variableIndex = function->argumentNames.Count() + function->localVariableNames.Add(L"" + var->name.value); + context.functionContext->localVariables.Add(symbol.Obj(), variableIndex); + variableIndices[index] = variableIndex; + + GenerateExpressionInstructions(context, var->value); + INSTRUCTION(Ins::StoreLocalVar(variableIndex)); + } + GenerateExpressionInstructions(context, node->expression); + FOREACH_INDEXER(Ptr, var, index, node->variables) + { + INSTRUCTION(Ins::LoadValue(Value())); + INSTRUCTION(Ins::StoreLocalVar(variableIndices[index])); + } + } + + void Visit(WfIfExpression* node)override + { + auto result = context.manager->expressionResolvings[node]; + GenerateExpressionInstructions(context, node->condition); + vint fillTrueIndex = INSTRUCTION(Ins::JumpIf(-1)); + GenerateExpressionInstructions(context, node->falseBranch, result.type); + vint fillEndIndex = INSTRUCTION(Ins::Jump(-1)); + context.assembly->instructions[fillTrueIndex].indexParameter = context.assembly->instructions.Count(); + GenerateExpressionInstructions(context, node->trueBranch, result.type); + context.assembly->instructions[fillEndIndex].indexParameter = context.assembly->instructions.Count(); + } + + void Visit(WfRangeExpression* node)override + { + auto result = context.manager->expressionResolvings[node]; + auto elementType = result.type->GetElementType()->GetGenericArgument(0); + auto type = GetInstructionTypeArgument(elementType); + + GenerateExpressionInstructions(context, node->begin, elementType); + if (node->beginBoundary == WfRangeBoundary::Exclusive) + { + INSTRUCTION(Ins::LoadValue(BoxValue(1))); + INSTRUCTION(Ins::OpAdd(type)); + } + + GenerateExpressionInstructions(context, node->end, elementType); + if (node->endBoundary == WfRangeBoundary::Exclusive) + { + INSTRUCTION(Ins::LoadValue(BoxValue(1))); + INSTRUCTION(Ins::OpSub(type)); + } + + INSTRUCTION(Ins::CreateRange(type)); + } + + void Visit(WfSetTestingExpression* node)override + { + if (auto range = node->collection.Cast()) + { + auto resultElement = context.manager->expressionResolvings[node->element.Obj()]; + auto resultBegin = context.manager->expressionResolvings[range->begin.Obj()]; + auto resultEnd = context.manager->expressionResolvings[range->end.Obj()]; + auto typeElement = resultElement.expectedType ? resultElement.expectedType : resultElement.type; + auto typeBegin = resultBegin.expectedType ? resultBegin.expectedType : resultBegin.type; + auto typeEnd = resultEnd.expectedType ? resultEnd.expectedType : resultEnd.type; + auto typeLeft = GetMergedType(typeElement, typeBegin); + auto typeRight = GetMergedType(typeElement, typeEnd); + + auto function = context.functionContext->function; + vint index = function->argumentNames.Count() + function->localVariableNames.Add(L""); + GenerateExpressionInstructions(context, node->element); + INSTRUCTION(Ins::StoreLocalVar(index)); + + INSTRUCTION(Ins::LoadLocalVar(index)); + if (!IsSameType(typeElement.Obj(), typeLeft.Obj())) + { + GenerateTypeCastInstructions(context, typeLeft, true, node); + } + GenerateExpressionInstructions(context, range->begin, typeLeft); + INSTRUCTION(Ins::CompareLiteral(GetInstructionTypeArgument(typeLeft))); + if (range->beginBoundary == WfRangeBoundary::Exclusive) + { + INSTRUCTION(Ins::OpGT()); + } + else + { + INSTRUCTION(Ins::OpGE()); + } + + INSTRUCTION(Ins::LoadLocalVar(index)); + if (!IsSameType(typeElement.Obj(), typeRight.Obj())) + { + GenerateTypeCastInstructions(context, typeRight, true, node); + } + GenerateExpressionInstructions(context, range->end, typeRight); + INSTRUCTION(Ins::CompareLiteral(GetInstructionTypeArgument(typeRight))); + if (range->endBoundary == WfRangeBoundary::Exclusive) + { + INSTRUCTION(Ins::OpLT()); + } + else + { + INSTRUCTION(Ins::OpLE()); + } + + INSTRUCTION(Ins::OpAnd(WfInsType::Bool)); + if (node->test == WfSetTesting::NotIn) + { + INSTRUCTION(Ins::OpNot(WfInsType::Bool)); + } + INSTRUCTION(Ins::LoadValue(Value())); + INSTRUCTION(Ins::StoreLocalVar(index)); + } + else + { + auto result = context.manager->expressionResolvings[node->collection.Obj()]; + auto type = result.expectedType ? result.expectedType : result.type; + + GenerateExpressionInstructions(context, node->element); + GenerateExpressionInstructions(context, node->collection); + + auto tdList = description::GetTypeDescriptor(); + if (result.type->GetTypeDescriptor()->CanConvertTo(tdList)) + { + auto method = tdList->GetMethodGroupByName(L"Contains", true)->GetMethod(0); + INSTRUCTION(Ins::InvokeMethod(method, 1)); + } + else + { + INSTRUCTION(Ins::TestElementInSet()); + } + + if (node->test == WfSetTesting::NotIn) + { + INSTRUCTION(Ins::OpNot(WfInsType::Bool)); + } + } + } + + void Visit(WfConstructorExpression* node)override + { + auto result = context.manager->expressionResolvings[node]; + + if (result.type->GetTypeDescriptor()->GetTypeDescriptorFlags() == TypeDescriptorFlags::Struct) + { + auto td = result.type->GetTypeDescriptor(); + INSTRUCTION(Ins::CreateStruct(Value::BoxedValue, td)); + + FOREACH(Ptr, argument, node->arguments) + { + auto prop = td->GetPropertyByName(argument->key.Cast()->name.value, true); + GenerateExpressionInstructions(context, argument->value, CopyTypeInfo(prop->GetReturn())); + INSTRUCTION(Ins::UpdateProperty(prop)); + } + } + else if (result.type->GetTypeDescriptor() == description::GetTypeDescriptor() + || result.type->GetTypeDescriptor() == description::GetTypeDescriptor() + || result.type->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + Ptr keyType = CopyTypeInfo(result.type->GetElementType()->GetGenericArgument(0)); + FOREACH(Ptr, argument, From(node->arguments).Reverse()) + { + GenerateExpressionInstructions(context, argument->key, keyType); + } + INSTRUCTION(Ins::CreateArray(node->arguments.Count())); + } + else if (result.type->GetTypeDescriptor() == description::GetTypeDescriptor()) + { + Ptr keyType = CopyTypeInfo(result.type->GetElementType()->GetGenericArgument(0)); + FOREACH(Ptr, argument, From(node->arguments).Reverse()) + { + GenerateExpressionInstructions(context, argument->key, keyType); + } + INSTRUCTION(Ins::CreateObservableList(node->arguments.Count())); + } + else + { + Ptr keyType = CopyTypeInfo(result.type->GetElementType()->GetGenericArgument(0)); + Ptr valueType = CopyTypeInfo(result.type->GetElementType()->GetGenericArgument(1)); + FOREACH(Ptr, argument, From(node->arguments).Reverse()) + { + GenerateExpressionInstructions(context, argument->key, keyType); + GenerateExpressionInstructions(context, argument->value, valueType); + } + INSTRUCTION(Ins::CreateMap(node->arguments.Count() * 2)); + } + } + + void Visit(WfInferExpression* node)override + { + GenerateExpressionInstructions(context, node->expression); + } + + void Visit(WfTypeCastingExpression* node)override + { + if (node->strategy == WfTypeCastingStrategy::Strong) + { + auto result = context.manager->expressionResolvings[node]; + GenerateExpressionInstructions(context, node->expression, result.type); + } + else + { + auto scope = context.manager->nodeScopes[node].Obj(); + auto type = CreateTypeInfoFromType(scope, node->type); + GenerateExpressionInstructions(context, node->expression); + GenerateTypeCastInstructions(context, type, false, node); + } + } + + void Visit(WfTypeTestingExpression* node)override + { + switch (node->test) + { + case WfTypeTesting::IsNull: + GenerateExpressionInstructions(context, node->expression); + INSTRUCTION(Ins::LoadValue(Value())); + INSTRUCTION(Ins::CompareReference()); + break; + case WfTypeTesting::IsNotNull: + GenerateExpressionInstructions(context, node->expression); + INSTRUCTION(Ins::LoadValue(Value())); + INSTRUCTION(Ins::CompareReference()); + INSTRUCTION(Ins::OpNot(WfInsType::Bool)); + break; + case WfTypeTesting::IsType: + { + auto scope = context.manager->nodeScopes[node].Obj(); + auto type = CreateTypeInfoFromType(scope, node->type); + GenerateExpressionInstructions(context, node->expression); + GenerateTypeTestingInstructions(context, type, node); + } + break; + case WfTypeTesting::IsNotType: + { + auto scope = context.manager->nodeScopes[node].Obj(); + auto type = CreateTypeInfoFromType(scope, node->type); + GenerateExpressionInstructions(context, node->expression); + GenerateTypeTestingInstructions(context, type, node); + INSTRUCTION(Ins::OpNot(WfInsType::Bool)); + } + break; + } + } + + void Visit(WfTypeOfTypeExpression* node)override + { + auto scope = context.manager->nodeScopes[node].Obj(); + auto type = CreateTypeInfoFromType(scope, node->type); + auto value = Value::From(type->GetTypeDescriptor()); + INSTRUCTION(Ins::LoadValue(value)); + } + + void Visit(WfTypeOfExpressionExpression* node)override + { + GenerateExpressionInstructions(context, node->expression); + INSTRUCTION(Ins::GetType()); + } + + void Visit(WfAttachEventExpression* node)override + { + auto result = context.manager->expressionResolvings[node->event.Obj()]; + if (auto member = node->event.Cast()) + { + GenerateExpressionInstructions(context, member->parent); + } + else + { + VisitThisExpression(node, result.eventInfo->GetOwnerTypeDescriptor()); + } + GenerateExpressionInstructions(context, node->function); + INSTRUCTION(Ins::AttachEvent(result.eventInfo)); + } + + void Visit(WfDetachEventExpression* node)override + { + auto result = context.manager->expressionResolvings[node->event.Obj()]; + if (auto member = node->event.Cast()) + { + GenerateExpressionInstructions(context, member->parent); + } + else + { + VisitThisExpression(node, result.eventInfo->GetOwnerTypeDescriptor()); + } + GenerateExpressionInstructions(context, node->handler); + INSTRUCTION(Ins::DetachEvent(result.eventInfo)); + } + + void Visit(WfObserveExpression* node)override + { + } + + void Visit(WfCallExpression* node)override + { + FOREACH(Ptr, argument, node->arguments) + { + GenerateExpressionInstructions(context, argument); + } + + auto result = context.manager->expressionResolvings[node->function.Obj()]; + if (result.methodInfo) + { + if (result.methodInfo->IsStatic()) + { + INSTRUCTION(Ins::LoadValue(Value())); + } + else if (auto member = node->function.Cast()) + { + GenerateExpressionInstructions(context, member->parent); + } + else + { + VisitThisExpression(node, result.methodInfo->GetOwnerTypeDescriptor()); + } + + INSTRUCTION(Ins::InvokeMethod(result.methodInfo, node->arguments.Count())); + return; + } + else if (result.eventInfo) + { + if(auto member = node->function.Cast()) + { + GenerateExpressionInstructions(context, member->parent); + } + else + { + VisitThisExpression(node, result.eventInfo->GetOwnerTypeDescriptor()); + } + INSTRUCTION(Ins::InvokeEvent(result.eventInfo, node->arguments.Count())); + return; + } + else if (result.symbol) + { + if (result.symbol->creatorNode.Cast()) + { + if (result.symbol->ownerScope->ownerNode.Cast()) + { + vint functionIndex = context.closureFunctions[result.symbol.Obj()]; + INSTRUCTION(Ins::InvokeWithContext(functionIndex, node->arguments.Count())); + return; + } + else + { + vint index = context.globalFunctions.Keys().IndexOf(result.symbol.Obj()); + if (index != -1) + { + vint functionIndex = context.globalFunctions.Values()[index]; + INSTRUCTION(Ins::Invoke(functionIndex, node->arguments.Count())); + return; + } + } + } + } + + GenerateExpressionInstructions(context, node->function); + INSTRUCTION(Ins::InvokeProxy(node->arguments.Count())); + } + + static void VisitFunction(WfCodegenContext& context, WfFunctionDeclaration* node, WfCodegenLambdaContext lc, const Func& getName) + { + auto scope = context.manager->nodeScopes[node].Obj(); + bool inNewInterfaceExpr = scope->parentScope && scope->parentScope->ownerNode.Cast(); + auto functionIndex = AddClosure(context, lc, getName); + + if (inNewInterfaceExpr) + { + INSTRUCTION(Ins::LoadFunction(functionIndex)); + } + else + { + auto capture = context.manager->lambdaCaptures.Get(node); + FOREACH(Ptr, symbol, capture->symbols) + { + GenerateLoadSymbolInstructions(context, symbol.Obj(), node); + } + vint thisCount = PushCapturedThisValues(context, scope->parentScope.Obj(), node); + INSTRUCTION(Ins::CreateClosureContext(capture->symbols.Count() + thisCount)); + INSTRUCTION(Ins::LoadFunction(functionIndex)); + INSTRUCTION(Ins::CreateClosure()); + } + } + + void Visit(WfFunctionExpression* node)override + { + WfCodegenLambdaContext lc; + lc.functionExpression = node; + VisitFunction(context, node->function.Obj(), lc, [=](vint index) + { + return L"function->name.value + L"(" + itow(index) + L")> in " + context.functionContext->function->name; + }); + } + + class NewInterfaceExpressionVisitor : public empty_visitor::DeclarationVisitor + { + public: + WfCodegenContext& context; + vint variableCount = 0; + List> variableSymbols; + List> closureFunctions; + List> overrideFunctions; + WfFunctionDeclaration* firstFunction = nullptr; + + NewInterfaceExpressionVisitor(WfCodegenContext& _context) + :context(_context) + { + } + + void Dispatch(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + + void Visit(WfFunctionDeclaration* node)override + { + if (!firstFunction) + { + firstFunction = node; + } + + if (node->classMember->kind == WfClassMemberKind::Normal) + { + closureFunctions.Add(node); + } + else + { + overrideFunctions.Add(node); + } + } + + void Visit(WfVariableDeclaration* node)override + { + variableCount++; + } + + void Execute(WfNewInterfaceExpression* node) + { + FOREACH(Ptr, memberDecl, node->declarations) + { + memberDecl->Accept(this); + } + + if (firstFunction != nullptr && variableCount > 0) + { + auto capture = context.manager->lambdaCaptures.Get(firstFunction); + CopyFrom(variableSymbols, From(capture->symbols).Take(variableCount)); + } + } + }; + + void Visit(WfNewClassExpression* node)override + { + auto result = context.manager->expressionResolvings[node]; + FOREACH(Ptr, argument, node->arguments) + { + GenerateExpressionInstructions(context, argument); + } + INSTRUCTION(Ins::LoadValue(Value())); + INSTRUCTION(Ins::InvokeMethod(result.constructorInfo, node->arguments.Count())); + } + + void Visit(WfNewInterfaceExpression* node)override + { + auto result = context.manager->expressionResolvings[node]; + NewInterfaceExpressionVisitor declVisitor(context); + declVisitor.Execute(node); + + if (declVisitor.firstFunction != nullptr) + { + for (vint i = 0; i < declVisitor.variableCount; i++) + { + auto var = declVisitor.variableSymbols[i]->creatorNode.Cast(); + GenerateExpressionInstructions(context, var->expression); + } + + auto capture = context.manager->lambdaCaptures.Get(declVisitor.firstFunction); + for (vint i = declVisitor.variableCount; i < capture->symbols.Count(); i++) + { + GenerateLoadSymbolInstructions(context, capture->symbols[i].Obj(), node); + } + auto scope = context.manager->nodeScopes[node].Obj(); + vint thisCount = PushCapturedThisValues(context, scope, node); + INSTRUCTION(Ins::LoadValue(Value())); + INSTRUCTION(Ins::CreateClosureContext(capture->symbols.Count() + thisCount + 1)); + + FOREACH(Ptr, func, declVisitor.closureFunctions) + { + WfCodegenLambdaContext lc; + lc.functionDeclaration = func.Obj(); + auto functionIndex = AddClosure(context, lc, [=](vint index) + { + return L"name.value + L"<" + result.type->GetTypeDescriptor()->GetTypeName() + L">(" + itow(index) + L")> in " + context.functionContext->function->name; + }); + + auto scope = context.manager->nodeScopes[func.Obj()].Obj(); + auto symbol = context.manager->GetDeclarationSymbol(scope, func.Obj()); + context.closureFunctions.Add(symbol.Obj(), functionIndex); + } + + FOREACH(Ptr, func, declVisitor.overrideFunctions) + { + auto methodInfo = context.manager->interfaceMethodImpls[func.Obj()]; + INSTRUCTION(Ins::LoadMethodInfo(methodInfo)); + WfCodegenLambdaContext lc; + lc.functionDeclaration = func.Obj(); + VisitFunction(context, func.Obj(), lc, [=, &declVisitor](vint index) + { + return L"name.value + L"<" + result.type->GetTypeDescriptor()->GetTypeName() + L">(" + itow(index + declVisitor.closureFunctions.Count()) + L")> in " + context.functionContext->function->name; + }); + } + } + + INSTRUCTION(Ins::CreateInterface(result.constructorInfo, declVisitor.overrideFunctions.Count() * 2)); + } + + void Visit(WfVirtualExpression* node)override + { + GenerateExpressionInstructions(context, node->expandedExpression); + } + }; + +#undef INSTRUCTION + + Ptr GenerateExpressionInstructions(WfCodegenContext& context, Ptr expression, Ptr expectedType) + { + GenerateExpressionInstructionsVisitor visitor(context); + expression->Accept(&visitor); + + auto result = context.manager->expressionResolvings[expression.Obj()]; + auto type = result.type; + + if (result.expectedType && !IsSameType(type.Obj(), result.expectedType.Obj())) + { + type = result.expectedType; + GenerateTypeCastInstructions(context, type, true, expression.Obj()); + } + + if (expectedType && !IsSameType(type.Obj(), expectedType.Obj())) + { + type = expectedType; + GenerateTypeCastInstructions(context, type, true, expression.Obj()); + } + + return type; + } + } + } +} + + +/*********************************************************************** +.\EMITTER\WFEMITTER_METADATA.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace emitter + { + using namespace collections; + using namespace reflection::description; + using namespace analyzer; + using namespace runtime; + using namespace typeimpl; + +/*********************************************************************** +GenerateGlobalDeclarationMetadata +***********************************************************************/ + + void GenerateFunctionDeclarationMetadata(WfCodegenContext& context, WfFunctionDeclaration* node, Ptr meta) + { + FOREACH(Ptr, argument, node->arguments) + { + meta->argumentNames.Add(argument->name.value); + } + { + vint index = context.manager->lambdaCaptures.Keys().IndexOf(node); + if (index != -1) + { + auto capture = context.manager->lambdaCaptures.Values()[index]; + FOREACH(Ptr, symbol, capture->symbols) + { + meta->capturedVariableNames.Add(L"" + symbol->name); + } + } + + auto scope = context.manager->nodeScopes[node]; + vint count = context.GetThisStackCount(scope.Obj()); + for (vint i = 0; i < count; i++) + { + meta->capturedVariableNames.Add(L"" + itow(i)); + } + } + } + + class GenerateGlobalClassMemberMetadataVisitor : public Object, public WfDeclaration::IVisitor + { + public: + WfCodegenContext& context; + WString namePrefix; + Ptr classDecl; + + GenerateGlobalClassMemberMetadataVisitor(WfCodegenContext& _context, const WString& _namePrefix, Ptr _classDecl) + :context(_context) + , namePrefix(_namePrefix) + , classDecl(_classDecl) + { + } + + void Visit(WfNamespaceDeclaration* node)override + { + } + + void Visit(WfFunctionDeclaration* node)override + { + if (node->classMember->kind == WfClassMemberKind::Static) + { + GenerateGlobalDeclarationMetadata(context, node, namePrefix); + auto scope = context.manager->nodeScopes[node].Obj(); + auto symbol = context.manager->GetDeclarationSymbol(scope, node); + auto index = context.globalFunctions[symbol.Obj()]; + auto info = context.manager->declarationMemberInfos[node].Cast(); + info->functionIndex = index; + } + else if (classDecl->kind == WfClassKind::Class) + { + GenerateGlobalDeclarationMetadata(context, node, namePrefix); + auto scope = context.manager->nodeScopes[node].Obj(); + auto symbol = context.manager->GetDeclarationSymbol(scope, node); + auto index = context.globalFunctions[symbol.Obj()]; + auto info = context.manager->declarationMemberInfos[node].Cast(); + info->functionIndex = index; + } + } + + void Visit(WfVariableDeclaration* node)override + { + } + + void Visit(WfEventDeclaration* node)override + { + } + + void Visit(WfPropertyDeclaration* node)override + { + } + + void Visit(WfConstructorDeclaration* node)override + { + auto meta = MakePtr(); + meta->name = namePrefix + L"#ctor"; + FOREACH(Ptr, argument, node->arguments) + { + meta->argumentNames.Add(argument->name.value); + } + meta->capturedVariableNames.Add(L"0"); + + vint index = context.assembly->functions.Add(meta); + context.assembly->functionByName.Add(meta->name, index); + context.constructors.Add(node, index); + + auto info = context.manager->declarationMemberInfos[node].Cast(); + info->functionIndex = index; + } + + void Visit(WfDestructorDeclaration* node)override + { + auto meta = MakePtr(); + meta->name = namePrefix + L"#dtor"; + meta->capturedVariableNames.Add(L"0"); + + vint index = context.assembly->functions.Add(meta); + context.assembly->functionByName.Add(meta->name, index); + context.destructors.Add(node, index); + + auto info = context.manager->declarationTypes[classDecl.Obj()].Cast(); + info->destructorFunctionIndex = index; + } + + void Visit(WfClassDeclaration* node)override + { + GenerateGlobalDeclarationMetadata(context, node, namePrefix); + } + + void Visit(WfEnumDeclaration* node)override + { + } + + void Visit(WfStructDeclaration* node)override + { + } + + void Visit(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + }; + + class GenerateGlobalDeclarationMetadataVisitor : public Object, public WfDeclaration::IVisitor + { + public: + WfCodegenContext& context; + WString namePrefix; + + GenerateGlobalDeclarationMetadataVisitor(WfCodegenContext& _context, const WString& _namePrefix) + :context(_context) + , namePrefix(_namePrefix) + { + } + + void Visit(WfNamespaceDeclaration* node)override + { + FOREACH(Ptr, decl, node->declarations) + { + GenerateGlobalDeclarationMetadata(context, decl, namePrefix + node->name.value + L"::"); + } + } + + void Visit(WfFunctionDeclaration* node)override + { + auto meta = MakePtr(); + meta->name = namePrefix + node->name.value; + GenerateFunctionDeclarationMetadata(context, node, meta); + + vint index = context.assembly->functions.Add(meta); + context.assembly->functionByName.Add(meta->name, index); + + auto scope = context.manager->nodeScopes[node].Obj(); + auto symbol = context.manager->GetDeclarationSymbol(scope, node); + context.globalFunctions.Add(symbol.Obj(), index); + } + + void Visit(WfVariableDeclaration* node)override + { + vint index = context.assembly->variableNames.Add(namePrefix + node->name.value); + + auto scope = context.manager->nodeScopes[node].Obj(); + auto symbol = scope->symbols[node->name.value][0]; + context.globalVariables.Add(symbol.Obj(), index); + } + + void Visit(WfEventDeclaration* node)override + { + } + + void Visit(WfPropertyDeclaration* node)override + { + } + + void Visit(WfConstructorDeclaration* node)override + { + } + + void Visit(WfDestructorDeclaration* node)override + { + } + + void Visit(WfClassDeclaration* node)override + { + FOREACH(Ptr, memberDecl, node->declarations) + { + GenerateGlobalClassMemberMetadataVisitor visitor(context, namePrefix + node->name.value + L"::", node); + memberDecl->Accept(&visitor); + } + } + + void Visit(WfEnumDeclaration* node)override + { + } + + void Visit(WfStructDeclaration* node)override + { + } + + void Visit(WfVirtualDeclaration* node)override + { + FOREACH(Ptr, decl, node->expandedDeclarations) + { + decl->Accept(this); + } + } + }; + + void GenerateGlobalDeclarationMetadata(WfCodegenContext& context, Ptr declaration, const WString& namePrefix) + { + GenerateGlobalDeclarationMetadataVisitor visitor(context, namePrefix); + declaration->Accept(&visitor); + } + } + } +} + +/*********************************************************************** +.\EMITTER\WFEMITTER_STATEMENT.CPP +***********************************************************************/ + +namespace vl +{ + namespace workflow + { + namespace emitter + { + using namespace collections; + using namespace reflection; + using namespace reflection::description; + using namespace analyzer; + using namespace runtime; + + typedef WfInstruction Ins; + +#define INSTRUCTION(X) context.AddInstruction(node, X) +#define EXIT_CODE(X) context.AddExitInstruction(node, X) + +/*********************************************************************** +GenerateInstructions(Statement) +***********************************************************************/ + + class GenerateStatementInstructionsVisitor : public Object, public WfStatement::IVisitor + { + public: + WfCodegenContext& context; + + GenerateStatementInstructionsVisitor(WfCodegenContext& _context) + :context(_context) + { + } + + void ApplyExitCode(Ptr scopeContext) + { + context.ApplyExitInstructions(scopeContext); + if (scopeContext->exitStatement) + { + GenerateStatementInstructions(context, scopeContext->exitStatement); + } + } + + void ApplyCurrentScopeExitCode() + { + auto scopeContext = context.functionContext->GetCurrentScopeContext(); + ApplyExitCode(scopeContext); + } + + void InlineScopeExitCode(WfCodegenScopeType untilScopeType, bool exclusive) + { + vint index = context.functionContext->scopeContextStack.Count() - 1; + while (index >= 0) + { + auto scopeContext = context.functionContext->scopeContextStack[index]; + if (exclusive && scopeContext->type == untilScopeType) break; + ApplyExitCode(scopeContext); + if (!exclusive && scopeContext->type == untilScopeType) break; + index--; + } + } + + void Visit(WfBreakStatement* node)override + { + InlineScopeExitCode(WfCodegenScopeType::Loop, false); + context.functionContext->GetCurrentScopeContext(WfCodegenScopeType::Loop)->breakInstructions.Add(INSTRUCTION(Ins::Jump(-1))); + } + + void Visit(WfContinueStatement* node)override + { + InlineScopeExitCode(WfCodegenScopeType::Loop, true); + context.functionContext->GetCurrentScopeContext(WfCodegenScopeType::Loop)->continueInstructions.Add(INSTRUCTION(Ins::Jump(-1))); + } + + void Visit(WfReturnStatement* node)override + { + InlineScopeExitCode(WfCodegenScopeType::Function, false); + if (node->expression) + { + GenerateExpressionInstructions(context, node->expression); + } + else + { + INSTRUCTION(Ins::LoadValue(Value())); + } + INSTRUCTION(Ins::Return()); + } + + void Visit(WfDeleteStatement* node)override + { + GenerateExpressionInstructions(context, node->expression); + INSTRUCTION(Ins::DeleteRawPtr()); + } + + void Visit(WfRaiseExceptionStatement* node)override + { + if (node->expression) + { + GenerateExpressionInstructions(context, node->expression); + } + else + { + auto scope = context.manager->nodeScopes[node]; + while (scope) + { + if (auto tryCatch = scope->ownerNode.Cast()) + { + if (tryCatch->name.value != L"") + { + auto symbol = scope->symbols[tryCatch->name.value][0].Obj(); + vint index = context.functionContext->localVariables[symbol]; + INSTRUCTION(Ins::LoadLocalVar(index)); + break; + } + } + scope = scope->parentScope; + } + } + INSTRUCTION(Ins::RaiseException()); + } + + void Visit(WfIfStatement* node)override + { + vint variableIndex = -1; + + GenerateExpressionInstructions(context, node->expression); + if (node->name.value != L"") + { + auto scope = context.manager->nodeScopes[node]; + auto symbol = scope->symbols[node->name.value][0]; + auto function = context.functionContext->function; + variableIndex = function->argumentNames.Count() + function->localVariableNames.Add(L"" + node->name.value); + context.functionContext->localVariables.Add(symbol.Obj(), variableIndex); + + GenerateTypeCastInstructions(context, symbol->typeInfo, false, node->expression.Obj()); + INSTRUCTION(Ins::StoreLocalVar(variableIndex)); + INSTRUCTION(Ins::LoadLocalVar(variableIndex)); + INSTRUCTION(Ins::LoadValue(Value())); + INSTRUCTION(Ins::CompareReference()); + } + else + { + INSTRUCTION(Ins::OpNot(WfInsType::Bool)); + } + vint fillElseIndex = INSTRUCTION(Ins::JumpIf(-1)); + + GenerateStatementInstructions(context, node->trueBranch); + if (variableIndex != -1) + { + INSTRUCTION(Ins::LoadValue(Value())); + INSTRUCTION(Ins::StoreLocalVar(variableIndex)); + } + vint fillEndIndex = INSTRUCTION(Ins::Jump(-1)); + context.assembly->instructions[fillElseIndex].indexParameter = context.assembly->instructions.Count(); + + if (node->falseBranch) + { + GenerateStatementInstructions(context, node->falseBranch); + } + context.assembly->instructions[fillEndIndex].indexParameter = context.assembly->instructions.Count(); + } + + void Visit(WfWhileStatement* node)override + { + vint continueLabelIndex = -1; + vint breakLabelIndex = -1; + vint loopLabelIndex = -1; + auto loopContext = context.functionContext->PushScopeContext(WfCodegenScopeType::Loop); + + loopLabelIndex = context.assembly->instructions.Count(); + continueLabelIndex = context.assembly->instructions.Count(); + GenerateExpressionInstructions(context, node->condition); + INSTRUCTION(Ins::OpNot(WfInsType::Bool)); + loopContext->breakInstructions.Add(INSTRUCTION(Ins::JumpIf(-1))); + GenerateStatementInstructions(context, node->statement); + INSTRUCTION(Ins::Jump(loopLabelIndex)); + breakLabelIndex = context.assembly->instructions.Count(); + + FOREACH(vint, index, loopContext->continueInstructions) + { + context.assembly->instructions[index].indexParameter = continueLabelIndex; + } + FOREACH(vint, index, loopContext->breakInstructions) + { + context.assembly->instructions[index].indexParameter = breakLabelIndex; + } + context.functionContext->PopScopeContext(); + } + + Pair GenerateTryProtected(WfStatement* node, Ptr protectedStatement, Ptr finallyStatement) + { + auto catchContext = context.functionContext->PushScopeContext(WfCodegenScopeType::TryCatch); + EXIT_CODE(Ins::UninstallTry(0)); + catchContext->exitStatement = finallyStatement; + + vint trap = INSTRUCTION(Ins::InstallTry(-1)); + GenerateStatementInstructions(context, protectedStatement); + context.functionContext->PopScopeContext(); + INSTRUCTION(Ins::UninstallTry(0)); + vint finish = INSTRUCTION(Ins::Jump(-1)); + + return{ trap,finish }; + } + + vint GenerateExceptionVariable(WfTryStatement* node) + { + WfLexicalSymbol* exceptionSymbol = nullptr; + WString exceptionName; + if (node->catchStatement) + { + auto scope = context.manager->nodeScopes[node].Obj(); + exceptionSymbol = scope->symbols[node->name.value][0].Obj(); + exceptionName = L"" + node->name.value; + } + else + { + exceptionName = L""; + } + + auto function = context.functionContext->function; + vint variableIndex = function->argumentNames.Count() + function->localVariableNames.Add(L"" + node->name.value); + if (exceptionSymbol) + { + context.functionContext->localVariables.Add(exceptionSymbol, variableIndex); + } + + return variableIndex; + } + + void GenerateTrap(WfTryStatement* node, vint variableIndex, Pair trap) + { + context.assembly->instructions[trap.key].indexParameter = context.assembly->instructions.Count(); + INSTRUCTION(Ins::LoadException()); + INSTRUCTION(Ins::StoreLocalVar(variableIndex)); + } + + void GenerateFinallyAndRaise(WfTryStatement* node, vint variableIndex) + { + GenerateStatementInstructions(context, node->finallyStatement); + INSTRUCTION(Ins::LoadLocalVar(variableIndex)); + INSTRUCTION(Ins::RaiseException()); + } + + void Visit(WfTryStatement* node)override + { + // try + auto trap1 = GenerateTryProtected(node, node->protectedStatement, node->finallyStatement); + Pair trap2 = { -1,-1 }; + auto variableIndex = GenerateExceptionVariable(node); + + // catch + { + GenerateTrap(node, variableIndex, trap1); + if (node->catchStatement) + { + if (node->finallyStatement) + { + trap2 = GenerateTryProtected(node, node->catchStatement, node->finallyStatement); + GenerateTrap(node, variableIndex, trap2); + GenerateFinallyAndRaise(node, variableIndex); + } + else + { + GenerateStatementInstructions(context, node->catchStatement); + } + } + else + { + GenerateFinallyAndRaise(node, variableIndex); + } + } + + // finally + context.assembly->instructions[trap1.value].indexParameter = context.assembly->instructions.Count(); + if (trap2.value != -1) + { + context.assembly->instructions[trap2.value].indexParameter = context.assembly->instructions.Count(); + } + if (node->finallyStatement) + { + GenerateStatementInstructions(context, node->finallyStatement); + } + } + + void Visit(WfBlockStatement* node)override + { + FOREACH(Ptr, statement, node->statements) + { + GenerateStatementInstructions(context, statement); + } + } + + void Visit(WfExpressionStatement* node)override + { + GenerateExpressionInstructions(context, node->expression); + INSTRUCTION(Ins::Pop()); + } + + void Visit(WfVariableStatement* node)override + { + auto manager = context.manager; + auto scope = manager->nodeScopes[node->variable.Obj()]; + auto symbol = scope->symbols[node->variable->name.value][0].Obj(); + auto function = context.functionContext->function; + vint index = function->argumentNames.Count() + function->localVariableNames.Add(node->variable->name.value); + context.functionContext->localVariables.Add(symbol, index); + + GenerateExpressionInstructions(context, node->variable->expression); + INSTRUCTION(Ins::StoreLocalVar(index)); + } + + void Visit(WfVirtualStatement* node)override + { + GenerateStatementInstructions(context, node->expandedStatement); + } + + void Visit(WfCoroutineStatement* node)override + { + CHECK_FAIL(L"GenerateStatementInstructionsVisitor::Visit(WfCoroutineStatement*)#Internal error, All coroutine statements do not emit instructions."); + } + }; + +#undef EXIT_CODE +#undef INSTRUCTION + + void GenerateStatementInstructions(WfCodegenContext& context, Ptr statement) + { + GenerateStatementInstructionsVisitor visitor(context); + statement->Accept(&visitor); + } + } + } +} diff --git a/Import/VlppWorkflowCompiler.h b/Import/VlppWorkflowCompiler.h index 9f6e719d..ee7928b4 100644 --- a/Import/VlppWorkflowCompiler.h +++ b/Import/VlppWorkflowCompiler.h @@ -2,11 +2,11 @@ THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY DEVELOPER: Zihan Chen(vczh) ***********************************************************************/ -#include "Vlpp.h" #include "VlppWorkflow.h" +#include "Vlpp.h" /*********************************************************************** -EXPRESSION\WFEXPRESSION_AST.H +.\EXPRESSION\WFEXPRESSION_AST.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -2107,63 +2107,7 @@ namespace vl #endif /*********************************************************************** -EXPRESSION\WFEXPRESSION_PARSER.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Parser::WfExpression.parser.txt - -This file is generated by: Vczh Parser Generator -***********************************************************************/ - -#ifndef VCZH_WORKFLOW_EXPRESSION_WFEXPRESSIONPARSER_PARSER -#define VCZH_WORKFLOW_EXPRESSION_WFEXPRESSIONPARSER_PARSER - - -namespace vl -{ - namespace workflow - { - extern vl::WString WfGetParserTextBuffer(); - extern vl::Ptr WfConvertParsingTreeNode(vl::Ptr node, const vl::collections::List& tokens); - extern vl::Ptr WfLoadTable(); - - extern vl::Ptr WfParseCoProviderStatementAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); - extern vl::Ptr WfParseCoProviderStatementAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); - extern vl::Ptr WfParseCoProviderStatement(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); - extern vl::Ptr WfParseCoProviderStatement(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); - - extern vl::Ptr WfParseDeclarationAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); - extern vl::Ptr WfParseDeclarationAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); - extern vl::Ptr WfParseDeclaration(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); - extern vl::Ptr WfParseDeclaration(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); - - extern vl::Ptr WfParseExpressionAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); - extern vl::Ptr WfParseExpressionAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); - extern vl::Ptr WfParseExpression(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); - extern vl::Ptr WfParseExpression(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); - - extern vl::Ptr WfParseModuleAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); - extern vl::Ptr WfParseModuleAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); - extern vl::Ptr WfParseModule(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); - extern vl::Ptr WfParseModule(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); - - extern vl::Ptr WfParseStatementAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); - extern vl::Ptr WfParseStatementAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); - extern vl::Ptr WfParseStatement(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); - extern vl::Ptr WfParseStatement(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); - - extern vl::Ptr WfParseTypeAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); - extern vl::Ptr WfParseTypeAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); - extern vl::Ptr WfParseType(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); - extern vl::Ptr WfParseType(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); - } -} -#endif - -/*********************************************************************** -EXPRESSION\WFEXPRESSION_COPY.H +.\EXPRESSION\WFEXPRESSION_COPY.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -2579,7 +2523,242 @@ namespace vl #endif /*********************************************************************** -EXPRESSION\WFEXPRESSION_TRAVERSE.H +.\EXPRESSION\WFEXPRESSION_EMPTY.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Parser::WfExpression.parser.txt + +This file is generated by: Vczh Parser Generator +***********************************************************************/ + +#ifndef VCZH_WORKFLOW_EXPRESSION_WFEXPRESSIONPARSER_EMPTY +#define VCZH_WORKFLOW_EXPRESSION_WFEXPRESSIONPARSER_EMPTY + + +namespace vl +{ + namespace workflow + { + namespace empty_visitor + { + class TypeVisitor : public Object, public WfType::IVisitor + { + public: + + // Visitor Members ----------------------------------- + void Visit(WfPredefinedType* node)override; + void Visit(WfTopQualifiedType* node)override; + void Visit(WfReferenceType* node)override; + void Visit(WfRawPointerType* node)override; + void Visit(WfSharedPointerType* node)override; + void Visit(WfNullableType* node)override; + void Visit(WfEnumerableType* node)override; + void Visit(WfMapType* node)override; + void Visit(WfObservableListType* node)override; + void Visit(WfFunctionType* node)override; + void Visit(WfChildType* node)override; + }; + + class ExpressionVisitor : public Object, public WfExpression::IVisitor + { + public: + + // Dispatch (virtual) -------------------------------- + virtual void Dispatch(WfVirtualExpression* node) = 0; + + // Visitor Members ----------------------------------- + void Visit(WfThisExpression* node)override; + void Visit(WfTopQualifiedExpression* node)override; + void Visit(WfReferenceExpression* node)override; + void Visit(WfOrderedNameExpression* node)override; + void Visit(WfOrderedLambdaExpression* node)override; + void Visit(WfMemberExpression* node)override; + void Visit(WfChildExpression* node)override; + void Visit(WfLiteralExpression* node)override; + void Visit(WfFloatingExpression* node)override; + void Visit(WfIntegerExpression* node)override; + void Visit(WfStringExpression* node)override; + void Visit(WfUnaryExpression* node)override; + void Visit(WfBinaryExpression* node)override; + void Visit(WfLetExpression* node)override; + void Visit(WfIfExpression* node)override; + void Visit(WfRangeExpression* node)override; + void Visit(WfSetTestingExpression* node)override; + void Visit(WfConstructorExpression* node)override; + void Visit(WfInferExpression* node)override; + void Visit(WfTypeCastingExpression* node)override; + void Visit(WfTypeTestingExpression* node)override; + void Visit(WfTypeOfTypeExpression* node)override; + void Visit(WfTypeOfExpressionExpression* node)override; + void Visit(WfAttachEventExpression* node)override; + void Visit(WfDetachEventExpression* node)override; + void Visit(WfObserveExpression* node)override; + void Visit(WfCallExpression* node)override; + void Visit(WfFunctionExpression* node)override; + void Visit(WfNewClassExpression* node)override; + void Visit(WfNewInterfaceExpression* node)override; + void Visit(WfVirtualExpression* node)override; + }; + + class StatementVisitor : public Object, public WfStatement::IVisitor + { + public: + + // Dispatch (virtual) -------------------------------- + virtual void Dispatch(WfVirtualStatement* node) = 0; + virtual void Dispatch(WfCoroutineStatement* node) = 0; + + // Visitor Members ----------------------------------- + void Visit(WfBreakStatement* node)override; + void Visit(WfContinueStatement* node)override; + void Visit(WfReturnStatement* node)override; + void Visit(WfDeleteStatement* node)override; + void Visit(WfRaiseExceptionStatement* node)override; + void Visit(WfIfStatement* node)override; + void Visit(WfWhileStatement* node)override; + void Visit(WfTryStatement* node)override; + void Visit(WfBlockStatement* node)override; + void Visit(WfVariableStatement* node)override; + void Visit(WfExpressionStatement* node)override; + void Visit(WfVirtualStatement* node)override; + void Visit(WfCoroutineStatement* node)override; + }; + + class DeclarationVisitor : public Object, public WfDeclaration::IVisitor + { + public: + + // Dispatch (virtual) -------------------------------- + virtual void Dispatch(WfVirtualDeclaration* node) = 0; + + // Visitor Members ----------------------------------- + void Visit(WfNamespaceDeclaration* node)override; + void Visit(WfFunctionDeclaration* node)override; + void Visit(WfVariableDeclaration* node)override; + void Visit(WfEventDeclaration* node)override; + void Visit(WfPropertyDeclaration* node)override; + void Visit(WfConstructorDeclaration* node)override; + void Visit(WfDestructorDeclaration* node)override; + void Visit(WfClassDeclaration* node)override; + void Visit(WfEnumDeclaration* node)override; + void Visit(WfStructDeclaration* node)override; + void Visit(WfVirtualDeclaration* node)override; + }; + + class VirtualDeclarationVisitor : public Object, public WfVirtualDeclaration::IVisitor + { + public: + + // Visitor Members ----------------------------------- + void Visit(WfAutoPropertyDeclaration* node)override; + void Visit(WfCastResultInterfaceDeclaration* node)override; + }; + + class VirtualStatementVisitor : public Object, public WfVirtualStatement::IVisitor + { + public: + + // Visitor Members ----------------------------------- + void Visit(WfForEachStatement* node)override; + void Visit(WfSwitchStatement* node)override; + void Visit(WfCoProviderStatement* node)override; + }; + + class CoroutineStatementVisitor : public Object, public WfCoroutineStatement::IVisitor + { + public: + + // Visitor Members ----------------------------------- + void Visit(WfCoPauseStatement* node)override; + void Visit(WfCoOperatorStatement* node)override; + }; + + class VirtualExpressionVisitor : public Object, public WfVirtualExpression::IVisitor + { + public: + + // Visitor Members ----------------------------------- + void Visit(WfBindExpression* node)override; + void Visit(WfFormatExpression* node)override; + void Visit(WfNewCoroutineExpression* node)override; + void Visit(WfMixinCastExpression* node)override; + void Visit(WfExpectedTypeCastExpression* node)override; + }; + + class ModuleUsingFragmentVisitor : public Object, public WfModuleUsingFragment::IVisitor + { + public: + + // Visitor Members ----------------------------------- + void Visit(WfModuleUsingNameFragment* node)override; + void Visit(WfModuleUsingWildCardFragment* node)override; + }; + + } + } +} +#endif + +/*********************************************************************** +.\EXPRESSION\WFEXPRESSION_PARSER.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +Parser::WfExpression.parser.txt + +This file is generated by: Vczh Parser Generator +***********************************************************************/ + +#ifndef VCZH_WORKFLOW_EXPRESSION_WFEXPRESSIONPARSER_PARSER +#define VCZH_WORKFLOW_EXPRESSION_WFEXPRESSIONPARSER_PARSER + + +namespace vl +{ + namespace workflow + { + extern vl::WString WfGetParserTextBuffer(); + extern vl::Ptr WfConvertParsingTreeNode(vl::Ptr node, const vl::collections::List& tokens); + extern vl::Ptr WfLoadTable(); + + extern vl::Ptr WfParseCoProviderStatementAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); + extern vl::Ptr WfParseCoProviderStatementAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); + extern vl::Ptr WfParseCoProviderStatement(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); + extern vl::Ptr WfParseCoProviderStatement(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); + + extern vl::Ptr WfParseDeclarationAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); + extern vl::Ptr WfParseDeclarationAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); + extern vl::Ptr WfParseDeclaration(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); + extern vl::Ptr WfParseDeclaration(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); + + extern vl::Ptr WfParseExpressionAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); + extern vl::Ptr WfParseExpressionAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); + extern vl::Ptr WfParseExpression(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); + extern vl::Ptr WfParseExpression(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); + + extern vl::Ptr WfParseModuleAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); + extern vl::Ptr WfParseModuleAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); + extern vl::Ptr WfParseModule(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); + extern vl::Ptr WfParseModule(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); + + extern vl::Ptr WfParseStatementAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); + extern vl::Ptr WfParseStatementAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); + extern vl::Ptr WfParseStatement(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); + extern vl::Ptr WfParseStatement(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); + + extern vl::Ptr WfParseTypeAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); + extern vl::Ptr WfParseTypeAsParsingTreeNode(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); + extern vl::Ptr WfParseType(const vl::WString& input, vl::Ptr table, vl::collections::List>& errors, vl::vint codeIndex = -1); + extern vl::Ptr WfParseType(const vl::WString& input, vl::Ptr table, vl::vint codeIndex = -1); + } +} +#endif + +/*********************************************************************** +.\EXPRESSION\WFEXPRESSION_TRAVERSE.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -3009,186 +3188,7 @@ namespace vl #endif /*********************************************************************** -EXPRESSION\WFEXPRESSION_EMPTY.H -***********************************************************************/ -/*********************************************************************** -Vczh Library++ 3.0 -Developer: Zihan Chen(vczh) -Parser::WfExpression.parser.txt - -This file is generated by: Vczh Parser Generator -***********************************************************************/ - -#ifndef VCZH_WORKFLOW_EXPRESSION_WFEXPRESSIONPARSER_EMPTY -#define VCZH_WORKFLOW_EXPRESSION_WFEXPRESSIONPARSER_EMPTY - - -namespace vl -{ - namespace workflow - { - namespace empty_visitor - { - class TypeVisitor : public Object, public WfType::IVisitor - { - public: - - // Visitor Members ----------------------------------- - void Visit(WfPredefinedType* node)override; - void Visit(WfTopQualifiedType* node)override; - void Visit(WfReferenceType* node)override; - void Visit(WfRawPointerType* node)override; - void Visit(WfSharedPointerType* node)override; - void Visit(WfNullableType* node)override; - void Visit(WfEnumerableType* node)override; - void Visit(WfMapType* node)override; - void Visit(WfObservableListType* node)override; - void Visit(WfFunctionType* node)override; - void Visit(WfChildType* node)override; - }; - - class ExpressionVisitor : public Object, public WfExpression::IVisitor - { - public: - - // Dispatch (virtual) -------------------------------- - virtual void Dispatch(WfVirtualExpression* node) = 0; - - // Visitor Members ----------------------------------- - void Visit(WfThisExpression* node)override; - void Visit(WfTopQualifiedExpression* node)override; - void Visit(WfReferenceExpression* node)override; - void Visit(WfOrderedNameExpression* node)override; - void Visit(WfOrderedLambdaExpression* node)override; - void Visit(WfMemberExpression* node)override; - void Visit(WfChildExpression* node)override; - void Visit(WfLiteralExpression* node)override; - void Visit(WfFloatingExpression* node)override; - void Visit(WfIntegerExpression* node)override; - void Visit(WfStringExpression* node)override; - void Visit(WfUnaryExpression* node)override; - void Visit(WfBinaryExpression* node)override; - void Visit(WfLetExpression* node)override; - void Visit(WfIfExpression* node)override; - void Visit(WfRangeExpression* node)override; - void Visit(WfSetTestingExpression* node)override; - void Visit(WfConstructorExpression* node)override; - void Visit(WfInferExpression* node)override; - void Visit(WfTypeCastingExpression* node)override; - void Visit(WfTypeTestingExpression* node)override; - void Visit(WfTypeOfTypeExpression* node)override; - void Visit(WfTypeOfExpressionExpression* node)override; - void Visit(WfAttachEventExpression* node)override; - void Visit(WfDetachEventExpression* node)override; - void Visit(WfObserveExpression* node)override; - void Visit(WfCallExpression* node)override; - void Visit(WfFunctionExpression* node)override; - void Visit(WfNewClassExpression* node)override; - void Visit(WfNewInterfaceExpression* node)override; - void Visit(WfVirtualExpression* node)override; - }; - - class StatementVisitor : public Object, public WfStatement::IVisitor - { - public: - - // Dispatch (virtual) -------------------------------- - virtual void Dispatch(WfVirtualStatement* node) = 0; - virtual void Dispatch(WfCoroutineStatement* node) = 0; - - // Visitor Members ----------------------------------- - void Visit(WfBreakStatement* node)override; - void Visit(WfContinueStatement* node)override; - void Visit(WfReturnStatement* node)override; - void Visit(WfDeleteStatement* node)override; - void Visit(WfRaiseExceptionStatement* node)override; - void Visit(WfIfStatement* node)override; - void Visit(WfWhileStatement* node)override; - void Visit(WfTryStatement* node)override; - void Visit(WfBlockStatement* node)override; - void Visit(WfVariableStatement* node)override; - void Visit(WfExpressionStatement* node)override; - void Visit(WfVirtualStatement* node)override; - void Visit(WfCoroutineStatement* node)override; - }; - - class DeclarationVisitor : public Object, public WfDeclaration::IVisitor - { - public: - - // Dispatch (virtual) -------------------------------- - virtual void Dispatch(WfVirtualDeclaration* node) = 0; - - // Visitor Members ----------------------------------- - void Visit(WfNamespaceDeclaration* node)override; - void Visit(WfFunctionDeclaration* node)override; - void Visit(WfVariableDeclaration* node)override; - void Visit(WfEventDeclaration* node)override; - void Visit(WfPropertyDeclaration* node)override; - void Visit(WfConstructorDeclaration* node)override; - void Visit(WfDestructorDeclaration* node)override; - void Visit(WfClassDeclaration* node)override; - void Visit(WfEnumDeclaration* node)override; - void Visit(WfStructDeclaration* node)override; - void Visit(WfVirtualDeclaration* node)override; - }; - - class VirtualDeclarationVisitor : public Object, public WfVirtualDeclaration::IVisitor - { - public: - - // Visitor Members ----------------------------------- - void Visit(WfAutoPropertyDeclaration* node)override; - void Visit(WfCastResultInterfaceDeclaration* node)override; - }; - - class VirtualStatementVisitor : public Object, public WfVirtualStatement::IVisitor - { - public: - - // Visitor Members ----------------------------------- - void Visit(WfForEachStatement* node)override; - void Visit(WfSwitchStatement* node)override; - void Visit(WfCoProviderStatement* node)override; - }; - - class CoroutineStatementVisitor : public Object, public WfCoroutineStatement::IVisitor - { - public: - - // Visitor Members ----------------------------------- - void Visit(WfCoPauseStatement* node)override; - void Visit(WfCoOperatorStatement* node)override; - }; - - class VirtualExpressionVisitor : public Object, public WfVirtualExpression::IVisitor - { - public: - - // Visitor Members ----------------------------------- - void Visit(WfBindExpression* node)override; - void Visit(WfFormatExpression* node)override; - void Visit(WfNewCoroutineExpression* node)override; - void Visit(WfMixinCastExpression* node)override; - void Visit(WfExpectedTypeCastExpression* node)override; - }; - - class ModuleUsingFragmentVisitor : public Object, public WfModuleUsingFragment::IVisitor - { - public: - - // Visitor Members ----------------------------------- - void Visit(WfModuleUsingNameFragment* node)override; - void Visit(WfModuleUsingWildCardFragment* node)override; - }; - - } - } -} -#endif - -/*********************************************************************** -EXPRESSION\WFEXPRESSION.H +.\EXPRESSION\WFEXPRESSION.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -3276,7 +3276,7 @@ namespace vl #endif /*********************************************************************** -ANALYZER\WFANALYZER.H +.\ANALYZER\WFANALYZER.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -3832,7 +3832,7 @@ Error Messages #endif /*********************************************************************** -EMITTER\WFEMITTER.H +.\EMITTER\WFEMITTER.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -3996,7 +3996,7 @@ Code Generation #endif /*********************************************************************** -CPP\WFCPP.H +.\CPP\WFCPP.H ***********************************************************************/ /*********************************************************************** Vczh Library++ 3.0 @@ -4152,6 +4152,8 @@ namespace vl void WriteCpp(stream::StreamWriter& writer, bool multiFile); void WriteSubHeader(stream::StreamWriter& writer, const WString& fileName); void WriteSubCpp(stream::StreamWriter& writer, const WString& fileName); + void WriteReflectionHeader(stream::StreamWriter& writer, bool multiFile); + void WriteReflectionCpp(stream::StreamWriter& writer, bool multiFile); }; /*********************************************************************** @@ -4182,7 +4184,7 @@ WfCppConfig::Write GenerateCppFiles ***********************************************************************/ - enum class WfCppMultiFile + enum class WfCppFileSwitch { Enabled, Disabled, @@ -4192,12 +4194,14 @@ GenerateCppFiles class WfCppInput : public Object { public: - WfCppMultiFile multiFile = WfCppMultiFile::Enabled; + WfCppFileSwitch multiFile = WfCppFileSwitch::Enabled; + WfCppFileSwitch reflection = WfCppFileSwitch::Enabled; WString comment; WString headerGuardPrefix; WString assemblyName; WString assemblyNamespace; WString includeFileName; + WString reflectionFileName; WString defaultFileName; collections::List normalIncludes; collections::List reflectionIncludes; @@ -4211,6 +4215,7 @@ GenerateCppFiles collections::Dictionary cppFiles; bool containsReflectionInfo = false; bool multiFile = false; + bool reflection = false; WString entryFileName; }; diff --git a/Tools/CppMerge.exe b/Tools/CppMerge.exe new file mode 100644 index 00000000..351473da Binary files /dev/null and b/Tools/CppMerge.exe differ diff --git a/Tools/Deploy.bat b/Tools/Deploy.bat new file mode 100644 index 00000000..d6f76e5b --- /dev/null +++ b/Tools/Deploy.bat @@ -0,0 +1,8 @@ +copy ..\..\Tools\Tools\ParserGen.exe . +copy ..\..\Tools\Tools\GacGen32.exe . +copy ..\..\Tools\Tools\GacGen64.exe . +copy ..\..\Tools\Tools\CppMerge.exe . +copy ..\..\Tools\Tools\RunAndLock.bat . +copy ..\..\Tools\Tools\WaitForLock.bat . +copy ..\..\Tools\Tools\GacGen.bat . +copy ..\..\Tools\Tools\GacMerge.bat . \ No newline at end of file diff --git a/Tools/GacGen.bat b/Tools/GacGen.bat new file mode 100644 index 00000000..7e61265e --- /dev/null +++ b/Tools/GacGen.bat @@ -0,0 +1,16 @@ +del *.wait.tmp +start %~dp0RunAndLock %RANDOM% "%~dp0GacGen32.exe /P %1" +start %~dp0RunAndLock %RANDOM% "%~dp0GacGen64.exe /P %1" +call %~dp0WaitForLock + +@if exist %1.log\x32\Error.txt ( + @echo "Error occurs: %1.log\x32\Error.txt" + @exit +) + +@if exist %1.log\x64\Error.txt ( + @echo "Error occurs: %1.log\x64\Error.txt" + @exit +) + +call %~dp0GacMerge %1 \ No newline at end of file diff --git a/Tools/GacGen.exe b/Tools/GacGen32.exe similarity index 61% rename from Tools/GacGen.exe rename to Tools/GacGen32.exe index 71e3085d..37fab741 100644 Binary files a/Tools/GacGen.exe and b/Tools/GacGen32.exe differ diff --git a/Tools/GacGen64.exe b/Tools/GacGen64.exe new file mode 100644 index 00000000..cf306edc Binary files /dev/null and b/Tools/GacGen64.exe differ diff --git a/Tools/GacMerge.bat b/Tools/GacMerge.bat new file mode 100644 index 00000000..8901e966 --- /dev/null +++ b/Tools/GacMerge.bat @@ -0,0 +1,5 @@ +@set /P CppOutput=< %1.log\x32\CppOutput.txt +@for %%i in (%1.log\x32\Source\*.*) do @( + echo Processing %%~nxi ... + %~dp0CppMerge.exe %1.log\x32\Source\%%~nxi %1.log\x64\Source\%%~nxi %CppOutput%\%%~nxi +) \ No newline at end of file diff --git a/Tools/ParserGen.exe b/Tools/ParserGen.exe index e536ecc3..00c12020 100644 Binary files a/Tools/ParserGen.exe and b/Tools/ParserGen.exe differ diff --git a/Tools/RunAndLock.bat b/Tools/RunAndLock.bat new file mode 100644 index 00000000..c6737fdd --- /dev/null +++ b/Tools/RunAndLock.bat @@ -0,0 +1,4 @@ +echo > %1.wait.tmp +call %~2 +del %1.wait.tmp +exit \ No newline at end of file diff --git a/Tools/WaitForLock.bat b/Tools/WaitForLock.bat new file mode 100644 index 00000000..88b47c9d --- /dev/null +++ b/Tools/WaitForLock.bat @@ -0,0 +1,6 @@ +@timeout 1 > nul +:wait_for_lock +@if not exist *.wait.tmp goto :finish_lock + @timeout 1 > nul +@goto wait_for_lock +:finish_lock \ No newline at end of file